From 052fb877779e3aae6021d4445a30559dd54d952f Mon Sep 17 00:00:00 2001 From: Phat <39623143+lukachi@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:33:13 +0200 Subject: [PATCH] Add Submit text proposal method for broadcaster (#88) * add submit proposal method --- CHANGELOG.md | 7 +++++- packages/bridge/package.json | 2 +- packages/client/package.json | 2 +- packages/client/src/broadcaster.ts | 32 ++++++++++++++++++++++-- packages/client/src/enums/msg-urls.ts | 1 + packages/client/src/types/broadcaster.ts | 7 ++++++ packages/nft-checkout/package.json | 2 +- packages/provider/package.json | 2 +- packages/providers-evm/package.json | 2 +- packages/providers-near/package.json | 2 +- packages/providers-solana/package.json | 2 +- packages/react-nft-checkout/package.json | 2 +- packages/react-provider/package.json | 2 +- packages/shared/package.json | 2 +- packages/swap/package.json | 2 +- 15 files changed, 55 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0eac22..1e44eb40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.3.0] - 2024-03-22 +### Added +- `@rarimo/client` - Submit text proposal + ## [2.2.0] - 2024-03-19 ### Added - `@rarimo/client` - Proposal type @@ -531,7 +535,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Under the hood changes - Initiated repo with `@rarimo/provider` and `@rarimo/nft-checkout` packages -[Unreleased]: https://github.com/rarimo/js-sdk/compare/2.2.0...HEAD +[Unreleased]: https://github.com/rarimo/js-sdk/compare/2.3.0...HEAD +[2.3.0]: https://github.com/rarimo/js-sdk/compare/2.2.0...2.3.0 [2.2.0]: https://github.com/rarimo/js-sdk/compare/2.1.0...2.2.0 [2.1.0]: https://github.com/rarimo/js-sdk/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/rarimo/js-sdk/compare/2.0.0-rc.34...2.0.0 diff --git a/packages/bridge/package.json b/packages/bridge/package.json index 8374923f..db0d3170 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/bridge", - "version": "2.2.0", + "version": "2.3.0", "description": "Internal tools that other Rarimo packages use to bridge tokens.", "repository": { "type": "git", diff --git a/packages/client/package.json b/packages/client/package.json index 358bb1f5..1749cb98 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/client", - "version": "2.2.0", + "version": "2.3.0", "description": "The Rarimo chain client", "repository": { "type": "git", diff --git a/packages/client/src/broadcaster.ts b/packages/client/src/broadcaster.ts index 947ec038..2708c55c 100644 --- a/packages/client/src/broadcaster.ts +++ b/packages/client/src/broadcaster.ts @@ -7,8 +7,11 @@ import { MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, } from '@/codec/cosmos/distribution/v1beta1/tx' -import { VoteOption as EVoteOption } from '@/codec/cosmos/gov/v1beta1/gov' -import { MsgVote } from '@/codec/cosmos/gov/v1beta1/tx' +import { + TextProposal, + VoteOption as EVoteOption, +} from '@/codec/cosmos/gov/v1beta1/gov' +import { MsgSubmitProposal, MsgVote } from '@/codec/cosmos/gov/v1beta1/tx' import { MsgDelegate, MsgUndelegate } from '@/codec/cosmos/staking/tx' import { Any } from '@/codec/google/protobuf/any' import { MessageTypeUrls, VoteOption } from '@/enums' @@ -129,6 +132,31 @@ export const makeRarimoBroadcaster = async ( }, // gov + submitTextProposal: ( + proposer: string, + initialDeposit: Coin[], + title: string, + description: string, + ) => { + return broadcaster( + MessageTypeUrls.SubmitProposal, + MsgSubmitProposal, + )( + MsgSubmitProposal.fromPartial({ + proposer, + initialDeposit, + content: encodeAsAny( + MessageTypeUrls.TextProposal, + TextProposal, + TextProposal.fromPartial({ + title, + description, + }), + ), + }), + ) + }, + voteProposal: (voter: string, proposalId: number, option: VoteOption) => { return broadcaster( MessageTypeUrls.Vote, diff --git a/packages/client/src/enums/msg-urls.ts b/packages/client/src/enums/msg-urls.ts index ee448b79..036c5012 100644 --- a/packages/client/src/enums/msg-urls.ts +++ b/packages/client/src/enums/msg-urls.ts @@ -22,6 +22,7 @@ export enum MessageTypeUrls { Deposit = '/cosmos.gov.v1beta1.MsgDeposit', VoteWeighted = '/cosmos.gov.v1beta1.MsgVoteWeighted', SubmitProposal = '/cosmos.gov.v1beta1.MsgSubmitProposal', + TextProposal = '/cosmos.gov.v1beta1.TextProposal', Unjail = '/cosmos.slashing.v1beta1.MsgUnjail', diff --git a/packages/client/src/types/broadcaster.ts b/packages/client/src/types/broadcaster.ts index 25be46e1..1a6bb093 100644 --- a/packages/client/src/types/broadcaster.ts +++ b/packages/client/src/types/broadcaster.ts @@ -45,6 +45,13 @@ export type RarimoBroadcaster = { ) => Promise // gov + submitTextProposal( + proposer: string, + initialDeposit: Coin[], + title: string, + description: string, + ): Promise + voteProposal( voter: string, proposalId: number, diff --git a/packages/nft-checkout/package.json b/packages/nft-checkout/package.json index 74b786d3..c3875489 100644 --- a/packages/nft-checkout/package.json +++ b/packages/nft-checkout/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/nft-checkout", - "version": "2.2.0", + "version": "2.3.0", "description": "Features of the Rarimo SDK that create cross-chain transactions based on the Rarimo protocol.", "repository": { "type": "git", diff --git a/packages/provider/package.json b/packages/provider/package.json index c70df50b..2e18f03b 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/provider", - "version": "2.2.0", + "version": "2.3.0", "description": "A common interface for access to wallets (EVM and non-EVM) in the Rarimo SDK, used by packages that provide access to wallets on specific chains such as @rarimo/providers-evm, @rarimo/providers-solana, and @rarimo/providers-near.", "repository": { "type": "git", diff --git a/packages/providers-evm/package.json b/packages/providers-evm/package.json index a9469dbc..c0ca2869 100644 --- a/packages/providers-evm/package.json +++ b/packages/providers-evm/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/providers-evm", - "version": "2.2.0", + "version": "2.3.0", "description": "Features of the Rarimo SDK that provide access to wallets and the ability to interact with them on EVM-compatible blockchains.", "repository": { "type": "git", diff --git a/packages/providers-near/package.json b/packages/providers-near/package.json index a141ccd5..0ab89997 100644 --- a/packages/providers-near/package.json +++ b/packages/providers-near/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/providers-near", - "version": "2.2.0", + "version": "2.3.0", "description": "Features of the Rarimo SDK that provide access to wallets and the ability to interact with them on the NEAR blockchain.", "repository": { "type": "git", diff --git a/packages/providers-solana/package.json b/packages/providers-solana/package.json index 186daae5..fa2c658b 100644 --- a/packages/providers-solana/package.json +++ b/packages/providers-solana/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/providers-solana", - "version": "2.2.0", + "version": "2.3.0", "description": "Features of the Rarimo SDK that provide access to wallets and the ability to interact with them on the Solana blockchain.", "repository": { "type": "git", diff --git a/packages/react-nft-checkout/package.json b/packages/react-nft-checkout/package.json index 9f965c37..ed968f1e 100644 --- a/packages/react-nft-checkout/package.json +++ b/packages/react-nft-checkout/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/react-nft-checkout", - "version": "2.2.0", + "version": "2.3.0", "description": "React components that you can use in your UI to create cross-chain transactions with the Rarimo protocol.", "license": "MIT", "repository": { diff --git a/packages/react-provider/package.json b/packages/react-provider/package.json index 884a069d..171a5a8b 100644 --- a/packages/react-provider/package.json +++ b/packages/react-provider/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/react-provider", - "version": "2.2.0", + "version": "2.3.0", "description": "Tools to connect to wallets in React applications through the Rarimo SDK.", "repository": { "type": "git", diff --git a/packages/shared/package.json b/packages/shared/package.json index 828c0af5..5e1d8d56 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/shared", - "version": "2.2.0", + "version": "2.3.0", "description": "Utility functions, types and constants shared across Rarimo packages.", "repository": { "type": "git", diff --git a/packages/swap/package.json b/packages/swap/package.json index 8d04c02d..31a79420 100644 --- a/packages/swap/package.json +++ b/packages/swap/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/swap", - "version": "2.2.0", + "version": "2.3.0", "description": "Internal tools that other Rarimo packages use to swap tokens.", "repository": { "type": "git",