diff --git a/src/schemas/delete-subscription.json b/src/schemas/delete-subscription.json deleted file mode 100644 index 9a86a7105..000000000 --- a/src/schemas/delete-subscription.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "#/definitions/DeleteSubscription", - "definitions": { - "DeleteSubscription": { - "title": "DeleteSubscription", - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["email"] - }, - "value": { - "type": "string", - "title": "value", - "maxLength": 256 - } - }, - "required": ["type", "value"], - "additionalProperties": false - } - } -} diff --git a/src/schemas/email-subscription.json b/src/schemas/email-subscription.json new file mode 100644 index 000000000..677282831 --- /dev/null +++ b/src/schemas/email-subscription.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/EmailSubscription", + "definitions": { + "EmailSubscription": { + "title": "EmailSubscription", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "title": "value", + "maxLength": 256 + }, + "subscriptions": { + "title": "subscriptions", + "type": "array", + "items": { + "type": "string", + "enum": ["summary", "newProposal", "closedProposal"] + } + } + }, + "required": [], + "additionalProperties": false + } + } +} diff --git a/src/schemas/index.ts b/src/schemas/index.ts index f5e603210..f8f795f7f 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -3,7 +3,7 @@ import proposal from './proposal.json'; import updateProposal from './update-proposal.json'; import vote from './vote.json'; import profile from './profile.json'; -import subscription from './subscription.json'; +import emailSubscription from './email-subscription.json'; import statement from './statement.json'; import zodiac from './zodiac.json'; import alias from './alias.json'; @@ -14,7 +14,7 @@ export default { updateProposal: updateProposal.definitions.UpdateProposal, vote: vote.definitions.Vote, profile: profile.definitions.Profile, - subscription: subscription.definitions.Subscription, + emailSubscription: emailSubscription.definitions.EmailSubscription, statement: statement.definitions.Statement, zodiac: zodiac.definitions.Zodiac, alias: alias.definitions.Alias diff --git a/src/schemas/subscription.json b/src/schemas/subscription.json deleted file mode 100644 index 02217deb7..000000000 --- a/src/schemas/subscription.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "#/definitions/Subscription", - "definitions": { - "Subscription": { - "title": "Subscription", - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["email"] - }, - "value": { - "type": "string", - "format": "email", - "title": "value", - "maxLength": 256 - }, - "metadata": { - "type": "string", - "title": "metadata" - } - }, - "required": ["type", "value"], - "additionalProperties": false - } - } -} diff --git a/src/sign/hashedTypes.json b/src/sign/hashedTypes.json index 07ea361ea..c1b41244c 100644 --- a/src/sign/hashedTypes.json +++ b/src/sign/hashedTypes.json @@ -63,6 +63,6 @@ "4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement", "d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal", "df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal", - "499ff7269df478dede66b3c0b96a0b90286c479b4013b423ac7cf8628a94e6db": "subscription", - "da79044f9b55496aed0fa5fdb25aff50b07f59fde4d22e02ab5da9d65da546e1": "delete-subscription" + "e3bd9bf9665e4dd5be252408e6d7c9e9a4572897153171a31e39e11641162003": "email-subscription", + "339bef62ba146350b9dfdcf04203c2b3c7f19effd1d8804954a8189645112394": "delete-email-subscription" } diff --git a/src/sign/index.ts b/src/sign/index.ts index 0683b77ae..2aaa8806f 100644 --- a/src/sign/index.ts +++ b/src/sign/index.ts @@ -16,8 +16,8 @@ import { Profile, Alias, DeleteSpace, - Subscription, - DeleteSubscription, + EmailSubscription, + DeleteEmailSubscription, Statement, spaceTypes, proposalTypes, @@ -39,8 +39,8 @@ import { aliasTypes, deleteSpaceType, statementTypes, - subscriptionTypes, - deleteSubscriptionTypes + emailSubscriptionTypes, + deleteEmailSubscriptionTypes } from './types'; import constants from '../constants.json'; @@ -239,19 +239,24 @@ export default class Client { return await this.sign(web3, address, message, deleteSpaceType); } - async subscription( + async emailSubscription( web3: Web3Provider | Wallet, address: string, - message: Subscription + message: EmailSubscription ) { - return await this.sign(web3, address, message, subscriptionTypes); + return await this.sign(web3, address, message, emailSubscriptionTypes); } - async deleteSubscription( + async deleteEmailSubscription( web3: Web3Provider | Wallet, address: string, - message: DeleteSubscription + message: DeleteEmailSubscription ) { - return await this.sign(web3, address, message, deleteSubscriptionTypes); + return await this.sign( + web3, + address, + message, + deleteEmailSubscriptionTypes + ); } } diff --git a/src/sign/types.ts b/src/sign/types.ts index 9b19d77d1..7f0732778 100644 --- a/src/sign/types.ts +++ b/src/sign/types.ts @@ -126,18 +126,15 @@ export interface DeleteSpace { timestamp?: number; } -export interface Subscription { +export interface EmailSubscription { from?: string; - type: string; - value: string; - metadata: string; + email: string; + subscriptions: string[]; timestamp?: number; } -export interface DeleteSubscription { +export interface DeleteEmailSubscription { from?: string; - type: string; - value: string; timestamp?: number; } @@ -361,21 +358,18 @@ export const deleteSpaceType = { ] }; -export const subscriptionTypes = { - Subscription: [ +export const emailSubscriptionTypes = { + EmailSubscription: [ { name: 'from', type: 'address' }, - { name: 'type', type: 'string' }, - { name: 'value', type: 'string' }, - { name: 'metadata', type: 'string' }, + { name: 'email', type: 'string' }, + { name: 'subscriptions', type: 'string[]' }, { name: 'timestamp', type: 'uint64' } ] }; -export const deleteSubscriptionTypes = { - DeleteSubscription: [ +export const deleteEmailSubscriptionTypes = { + DeleteEmailSubscription: [ { name: 'from', type: 'address' }, - { name: 'type', type: 'string' }, - { name: 'value', type: 'string' }, { name: 'timestamp', type: 'uint64' } ] };