From 071172e71c6a32d08d15e455b7498e0fb5dad112 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:23:52 +0900 Subject: [PATCH] feat: add unsubscription type --- scripts/generateHashWithTypes.ts | 9 ++++----- src/schemas/unsubscription.json | 23 +++++++++++++++++++++++ src/sign/hashedTypes.json | 3 ++- src/sign/types.ts | 9 +++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/schemas/unsubscription.json diff --git a/scripts/generateHashWithTypes.ts b/scripts/generateHashWithTypes.ts index f8c820a4b..51b1f9aa0 100644 --- a/scripts/generateHashWithTypes.ts +++ b/scripts/generateHashWithTypes.ts @@ -1,12 +1,11 @@ const { createHash } = require('crypto'); const types = { - Statement: [ + Unsubscription: [ { name: 'from', type: 'address' }, - { name: 'timestamp', type: 'uint64' }, - { name: 'space', type: 'string' }, - { name: 'about', type: 'string' }, - { name: 'statement', type: 'string' } + { name: 'type', type: 'string' }, + { name: 'value', type: 'string' }, + { name: 'timestamp', type: 'uint64' } ] }; function sha256(str) { diff --git a/src/schemas/unsubscription.json b/src/schemas/unsubscription.json new file mode 100644 index 000000000..32f0b6985 --- /dev/null +++ b/src/schemas/unsubscription.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Unsubscription", + "definitions": { + "Unsubscription": { + "title": "Unsubscription", + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["email"] + }, + "value": { + "type": "string", + "title": "value", + "maxLength": 256 + } + }, + "required": ["type", "value"], + "additionalProperties": false + } + } +} diff --git a/src/sign/hashedTypes.json b/src/sign/hashedTypes.json index fc3c33c64..a9d90852f 100644 --- a/src/sign/hashedTypes.json +++ b/src/sign/hashedTypes.json @@ -63,5 +63,6 @@ "4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement", "d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal", "df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal", - "499ff7269df478dede66b3c0b96a0b90286c479b4013b423ac7cf8628a94e6db": "subscription" + "499ff7269df478dede66b3c0b96a0b90286c479b4013b423ac7cf8628a94e6db": "subscription", + "07332dd26824595cc95dcb5c2f13173c57c23944b328220ce46de163f0e94191": "unsubscription" } diff --git a/src/sign/types.ts b/src/sign/types.ts index 278161ba9..170a54b4b 100644 --- a/src/sign/types.ts +++ b/src/sign/types.ts @@ -355,3 +355,12 @@ export const subscriptionTypes = { { name: 'timestamp', type: 'uint64' } ] }; + +export const unsubscriptionTypes = { + Unsubscription: [ + { name: 'from', type: 'address' }, + { name: 'type', type: 'string' }, + { name: 'value', type: 'string' }, + { name: 'timestamp', type: 'uint64' } + ] +};