Skip to content

Commit

Permalink
refactor: rename subscription to email-subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Nov 23, 2024
1 parent 8fdef57 commit 086ad9e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 81 deletions.
23 changes: 0 additions & 23 deletions src/schemas/delete-subscription.json

This file was deleted.

28 changes: 28 additions & 0 deletions src/schemas/email-subscription.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
4 changes: 2 additions & 2 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
28 changes: 0 additions & 28 deletions src/schemas/subscription.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/sign/hashedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
"4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement",
"d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal",
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal",
"499ff7269df478dede66b3c0b96a0b90286c479b4013b423ac7cf8628a94e6db": "subscription",
"da79044f9b55496aed0fa5fdb25aff50b07f59fde4d22e02ab5da9d65da546e1": "delete-subscription"
"e3bd9bf9665e4dd5be252408e6d7c9e9a4572897153171a31e39e11641162003": "email-subscription",
"339bef62ba146350b9dfdcf04203c2b3c7f19effd1d8804954a8189645112394": "delete-email-subscription"
}
25 changes: 15 additions & 10 deletions src/sign/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
Profile,
Alias,
DeleteSpace,
Subscription,
DeleteSubscription,
EmailSubscription,
DeleteEmailSubscription,
Statement,
spaceTypes,
proposalTypes,
Expand All @@ -39,8 +39,8 @@ import {
aliasTypes,
deleteSpaceType,
statementTypes,
subscriptionTypes,
deleteSubscriptionTypes
emailSubscriptionTypes,
deleteEmailSubscriptionTypes
} from './types';
import constants from '../constants.json';

Expand Down Expand Up @@ -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
);
}
}
26 changes: 10 additions & 16 deletions src/sign/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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' }
]
};

0 comments on commit 086ad9e

Please sign in to comment.