From e716ec157e436fe1084bfb2f39c5b1a8bf75de51 Mon Sep 17 00:00:00 2001 From: Dmytro Tolok Date: Thu, 28 Sep 2023 11:11:54 +0200 Subject: [PATCH] feat(flag proposal): add actions for flagging proposals (#903) * feat(flag proposal): add actions for flagging proposals * fix(sign): add timestamp to the message * fix(flag proposal): removes redundant adding timestamp check in function --- package.json | 2 +- src/sign/index.ts | 10 ++++++++++ src/sign/types.json | 1 + src/sign/types.ts | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 35dd90975..7247dc52c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snapshot-labs/snapshot.js", - "version": "0.6.2", + "version": "0.6.3", "repository": "snapshot-labs/snapshot.js", "license": "MIT", "main": "dist/snapshot.cjs.js", diff --git a/src/sign/index.ts b/src/sign/index.ts index 6c703a61d..007fccfb5 100644 --- a/src/sign/index.ts +++ b/src/sign/index.ts @@ -6,6 +6,7 @@ import { Space, Proposal, UpdateProposal, + FlagProposal, CancelProposal, Vote, Follow, @@ -19,6 +20,7 @@ import { spaceTypes, proposalTypes, updateProposalTypes, + flagProposalTypes, cancelProposalTypes, cancelProposal2Types, voteTypes, @@ -121,6 +123,14 @@ export default class Client { return await this.sign(web3, address, message, updateProposalTypes); } + async flagProposal( + web3: Web3Provider | Wallet, + address: string, + message: FlagProposal + ) { + return await this.sign(web3, address, message, flagProposalTypes); + } + async cancelProposal( web3: Web3Provider | Wallet, address: string, diff --git a/src/sign/types.json b/src/sign/types.json index 7b37e7d71..b0d01f8c3 100644 --- a/src/sign/types.json +++ b/src/sign/types.json @@ -5,6 +5,7 @@ "9ff8af4cfb586e2c7962d792b99328fb47e8a4e73cc89873c0980484bc1063a5": "delete-proposal", "734df82cdad586386defa4cb55adda7cb1b2a56929c4e6c3dc676f9901947288": "delete-proposal", "4e5fa89616761defa1274103441809c8445f8404306890ad36ec653d90201d58": "update-proposal", + "4bbf83a627c4afc26a1b9490127c1712d844fb0806131ee9860e7b298b0a828e": "flag-proposal", "50084aae0fe117c83ddf855557dde35ae2872e9045443a15f72aa6c68ea3943b": "vote", "1dfe3863f6333a85581fb150d4ee77c95a6d026c518ca1b11c08ae1d98acd598": "vote-array", "1814c3dd303c5919ce488b924f92b9a42a0834972f514e55b1879fda48e67736": "vote-string", diff --git a/src/sign/types.ts b/src/sign/types.ts index 39bc70791..4fc3012a5 100644 --- a/src/sign/types.ts +++ b/src/sign/types.ts @@ -42,6 +42,13 @@ export interface UpdateProposal { plugins: string; } +export interface FlagProposal { + from: string; + space: string; + proposal: string; + timestamp?: number; +} + export interface CancelProposal { from?: string; space: string; @@ -154,6 +161,15 @@ export const updateProposalTypes = { ] }; +export const flagProposalTypes = { + FlagProposal: [ + { name: 'from', type: 'address' }, + { name: 'space', type: 'string' }, + { name: 'proposal', type: 'string' }, + { name: 'timestamp', type: 'uint64' } + ] +}; + export const cancelProposalTypes = { CancelProposal: [ { name: 'from', type: 'address' },