From 592941a7c4f7f9bf18c2e957fccc336d795dd4bc Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Fri, 29 Nov 2024 08:23:55 +0530 Subject: [PATCH] feat: new privacy type (#1087) * feat: Add new privacy type * add privacy to update-proposal * Update src/schemas/space.json * Update test/examples/space.json * add back blind * add privacy on proposal or update-proposal --- src/schemas/proposal.json | 4 ++++ src/schemas/space.json | 2 +- src/schemas/update-proposal.json | 4 ++++ src/sign/hashedTypes.json | 4 +++- src/sign/index.ts | 2 ++ src/sign/types.ts | 6 +++++- test/examples/proposal.json | 1 + test/examples/space.json | 3 ++- 8 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/schemas/proposal.json b/src/schemas/proposal.json index 7a916fb58..18bda0069 100644 --- a/src/schemas/proposal.json +++ b/src/schemas/proposal.json @@ -84,6 +84,10 @@ "type": "string", "title": "app", "maxLength": 128 + }, + "privacy": { + "type": "string", + "enum": ["", "shutter"] } }, "required": ["name", "body", "choices", "snapshot", "start", "end"], diff --git a/src/schemas/space.json b/src/schemas/space.json index ade9e1eba..9c4e41d7b 100644 --- a/src/schemas/space.json +++ b/src/schemas/space.json @@ -335,7 +335,7 @@ }, "privacy": { "type": "string", - "enum": ["", "shutter"] + "enum": ["", "shutter", "any"] } }, "additionalProperties": false diff --git a/src/schemas/update-proposal.json b/src/schemas/update-proposal.json index 41becd41e..e565d7587 100644 --- a/src/schemas/update-proposal.json +++ b/src/schemas/update-proposal.json @@ -66,6 +66,10 @@ "metadata": { "type": "object", "title": "metadata" + }, + "privacy": { + "type": "string", + "enum": ["", "shutter"] } }, "required": ["proposal", "name", "body", "discussion", "choices", "type", "metadata"], diff --git a/src/sign/hashedTypes.json b/src/sign/hashedTypes.json index 039741d3b..7e36a2d38 100644 --- a/src/sign/hashedTypes.json +++ b/src/sign/hashedTypes.json @@ -62,5 +62,7 @@ "2ffbebcbd22ef48fd2f4a1182ff1feda7795b57689bd6f0dd73c89e925e7fefb": "profile", "4288d50b713081aae77d60d596d75864bff7acf7791a00183401e58658ee9da5": "statement", "d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal", - "df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal" + "df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal", + "beda1f464a6112f9ed6335c4614e32a97f0e18ef4ac10b4b1c8239c475f2d8e8": "proposal", + "ff74674f39ca59b60056ecddaada0cb513c4729e634e99cb778f53ee404ac806": "update-proposal" } diff --git a/src/sign/index.ts b/src/sign/index.ts index af38c293f..d7d852219 100644 --- a/src/sign/index.ts +++ b/src/sign/index.ts @@ -126,6 +126,7 @@ export default class Client { ) { if (!message.discussion) message.discussion = ''; if (!message.app) message.app = ''; + if (!message.privacy) message.privacy = ''; return await this.sign(web3, address, message, proposalTypes); } @@ -134,6 +135,7 @@ export default class Client { address: string, message: UpdateProposal ) { + if (!message.privacy) message.privacy = ''; return await this.sign(web3, address, message, updateProposalTypes); } diff --git a/src/sign/types.ts b/src/sign/types.ts index 6979d8e6c..06a1a7a04 100644 --- a/src/sign/types.ts +++ b/src/sign/types.ts @@ -21,6 +21,7 @@ export interface Proposal { title: string; body: string; discussion: string; + privacy?: string; choices: string[]; labels?: string[]; start: number; @@ -39,6 +40,7 @@ export interface UpdateProposal { title: string; body: string; discussion: string; + privacy?: string; choices: string[]; labels?: string[]; plugins: string; @@ -150,6 +152,7 @@ export const proposalTypes = { { name: 'end', type: 'uint64' }, { name: 'snapshot', type: 'uint64' }, { name: 'plugins', type: 'string' }, + { name: 'privacy', type: 'string' }, { name: 'app', type: 'string' } ] }; @@ -166,7 +169,8 @@ export const updateProposalTypes = { { name: 'discussion', type: 'string' }, { name: 'choices', type: 'string[]' }, { name: 'labels', type: 'string[]' }, - { name: 'plugins', type: 'string' } + { name: 'plugins', type: 'string' }, + { name: 'privacy', type: 'string' } ] }; diff --git a/test/examples/proposal.json b/test/examples/proposal.json index a28ad8794..c6cbcd154 100644 --- a/test/examples/proposal.json +++ b/test/examples/proposal.json @@ -15,6 +15,7 @@ "end": 1620316800, "snapshot": 12345167, "discussion": "https://...", + "privacy": "shutter", "metadata": { "network": "1" } diff --git a/test/examples/space.json b/test/examples/space.json index ceae1f49b..6087b8c34 100644 --- a/test/examples/space.json +++ b/test/examples/space.json @@ -33,7 +33,8 @@ "voting": { "delay": 2592000, "period": 15552000, - "quorum": 100 + "quorum": 100, + "privacy": "any" }, "treasuries": [ {