Skip to content

feat: add email subscription #1081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +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 statement from './statement.json';
import zodiac from './zodiac.json';
import alias from './alias.json';
Expand All @@ -13,6 +14,7 @@ export default {
updateProposal: updateProposal.definitions.UpdateProposal,
vote: vote.definitions.Vote,
profile: profile.definitions.Profile,
subscription: subscription.definitions.Subscription,
statement: statement.definitions.Statement,
zodiac: zodiac.definitions.Zodiac,
alias: alias.definitions.Alias
Expand Down
6 changes: 6 additions & 0 deletions src/schemas/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
"title": "farcaster",
"pattern": "^[a-z0-9-]*$",
"maxLength": 17
},
"emailSubscriptions": {
"type": "array",
"title": "email subscriptions",
"uniqueItems": true,
"items": { "type": "string" }
}
},
"required": [],
Expand Down
23 changes: 23 additions & 0 deletions src/schemas/subscription.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$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",
"title": "value",
"maxLength": 256
}
},
"required": ["type", "value"],
"additionalProperties": false
}
}
}
3 changes: 2 additions & 1 deletion src/sign/hashedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
"2ffbebcbd22ef48fd2f4a1182ff1feda7795b57689bd6f0dd73c89e925e7fefb": "profile",
"4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement",
"d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal",
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal"
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal",
"3c211382d04e80cbd21f3275e0674387bde366bbb885215e3735151763ca2813": "subscription"
}
9 changes: 9 additions & 0 deletions src/sign/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,12 @@ export const deleteSpaceType = {
{ name: 'timestamp', type: 'uint64' }
]
};

export const subscriptionTypes = {
Subscription: [
{ name: 'from', type: 'address' },
{ name: 'type', type: 'string' },
{ name: 'value', type: 'string' },
{ name: 'timestamp', type: 'uint64' }
]
};
6 changes: 6 additions & 0 deletions test/examples/profile-updateEmailSubscription.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Vitalik",
"avatar": "ipfs://NnVTdgcFciJUoxqgsNe9Hy2R7rgvEb5jDu5Pa5mmEG3UghbubTf2M78jUXbKLqKM",
"about": "This is my about info",
"emailSubscriptions": ["summary", "newProposal"]
}
4 changes: 4 additions & 0 deletions test/examples/subscription.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "email",
"value": "[email protected]"
}
12 changes: 12 additions & 0 deletions test/schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import spaceStarknetDelegation from './examples/space-starknet-delegation.json';
import proposalTurbo from './examples/proposal-turbo.json';
import vote from './examples/vote.json';
import profile from './examples/profile.json';
import profileUpdateEmailSubscription from './examples/profile-updateEmailSubscription.json';
import subscription from './examples/subscription.json';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should rename this file also to avoid confusions

import statement from './examples/statement.json';
import alias from './examples/alias.json';
import schemas from '../src/schemas';
Expand All @@ -24,6 +26,16 @@ describe.each([
{ schemaType: 'proposal', schema: schemas.proposal, example: proposal },
{ schemaType: 'vote', schema: schemas.vote, example: vote },
{ schemaType: 'profile', schema: schemas.profile, example: profile },
{
schemaType: 'profile',
schema: schemas.profile,
example: profileUpdateEmailSubscription
},
{
schemaType: 'subscription',
schema: schemas.subscription,
example: subscription
},
{ schemaType: 'statement', schema: schemas.statement, example: statement },
{ schemaType: 'zodiac', schema: schemas.zodiac, example: space },
{ schemaType: 'alias', schema: schemas.alias, example: alias }
Expand Down
Loading