Skip to content

Commit 37a0014

Browse files
committed
feat: add Subscription schema
1 parent ed5304c commit 37a0014

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

src/schemas/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import proposal from './proposal.json';
33
import updateProposal from './update-proposal.json';
44
import vote from './vote.json';
55
import profile from './profile.json';
6+
import subscription from './subscription.json';
67
import statement from './statement.json';
78
import zodiac from './zodiac.json';
89
import alias from './alias.json';
@@ -13,6 +14,7 @@ export default {
1314
updateProposal: updateProposal.definitions.UpdateProposal,
1415
vote: vote.definitions.Vote,
1516
profile: profile.definitions.Profile,
17+
subscription: subscription.definitions.Subscription,
1618
statement: statement.definitions.Statement,
1719
zodiac: zodiac.definitions.Zodiac,
1820
alias: alias.definitions.Alias

src/schemas/subscription.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/Subscription",
4+
"definitions": {
5+
"Subscription": {
6+
"title": "Subscription",
7+
"type": "object",
8+
"properties": {
9+
"type": {
10+
"type": "string",
11+
"enum": ["email"]
12+
},
13+
"value": {
14+
"type": "string",
15+
"title": "value",
16+
"maxLength": 256
17+
}
18+
},
19+
"required": ["type", "value"],
20+
"additionalProperties": false
21+
}
22+
}
23+
}

src/sign/hashedTypes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@
6262
"2ffbebcbd22ef48fd2f4a1182ff1feda7795b57689bd6f0dd73c89e925e7fefb": "profile",
6363
"4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement",
6464
"d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal",
65-
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal"
65+
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal",
66+
"3c211382d04e80cbd21f3275e0674387bde366bbb885215e3735151763ca2813": "subscription"
6667
}

src/sign/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,12 @@ export const deleteSpaceType = {
345345
{ name: 'timestamp', type: 'uint64' }
346346
]
347347
};
348+
349+
export const subscriptionTypes = {
350+
Subscription: [
351+
{ name: 'from', type: 'address' },
352+
{ name: 'type', type: 'string' },
353+
{ name: 'value', type: 'string' },
354+
{ name: 'timestamp', type: 'uint64' }
355+
]
356+
};

test/examples/subscription.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "email",
3+
"value": "[email protected]"
4+
}

test/schema.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import proposalTurbo from './examples/proposal-turbo.json';
88
import vote from './examples/vote.json';
99
import profile from './examples/profile.json';
1010
import profileUpdateEmailSubscription from './examples/profile-updateEmailSubscription.json';
11+
import subscription from './examples/subscription.json';
1112
import statement from './examples/statement.json';
1213
import alias from './examples/alias.json';
1314
import schemas from '../src/schemas';
@@ -30,6 +31,11 @@ describe.each([
3031
schema: schemas.profile,
3132
example: profileUpdateEmailSubscription
3233
},
34+
{
35+
schemaType: 'subscription',
36+
schema: schemas.subscription,
37+
example: subscription
38+
},
3339
{ schemaType: 'statement', schema: schemas.statement, example: statement },
3440
{ schemaType: 'zodiac', schema: schemas.zodiac, example: space },
3541
{ schemaType: 'alias', schema: schemas.alias, example: alias }

0 commit comments

Comments
 (0)