Skip to content

Commit

Permalink
Add Submit text proposal method for broadcaster (#88)
Browse files Browse the repository at this point in the history
* add submit proposal method
  • Loading branch information
lukachi authored Mar 22, 2024
1 parent 2048f26 commit 052fb87
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/client",
"version": "2.2.0",
"version": "2.3.0",
"description": "The Rarimo chain client",
"repository": {
"type": "git",
Expand Down
32 changes: 30 additions & 2 deletions packages/client/src/broadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -129,6 +132,31 @@ export const makeRarimoBroadcaster = async (
},

// gov
submitTextProposal: (
proposer: string,
initialDeposit: Coin[],
title: string,
description: string,
) => {
return broadcaster<MsgSubmitProposal>(
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<MsgVote>(
MessageTypeUrls.Vote,
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/enums/msg-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/types/broadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export type RarimoBroadcaster = {
) => Promise<DeliverTxResponse>

// gov
submitTextProposal(
proposer: string,
initialDeposit: Coin[],
title: string,
description: string,
): Promise<DeliverTxResponse>

voteProposal(
voter: string,
proposalId: number,
Expand Down
2 changes: 1 addition & 1 deletion packages/nft-checkout/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/provider/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/providers-evm/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/providers-near/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/providers-solana/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-nft-checkout/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-provider/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/swap/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 052fb87

Please sign in to comment.