Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MsgFundCommunityPool to the Distribution Msgs #433

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type RedelegateMsg struct {
type DistributionMsg struct {
SetWithdrawAddress *SetWithdrawAddressMsg `json:"set_withdraw_address,omitempty"`
WithdrawDelegatorReward *WithdrawDelegatorRewardMsg `json:"withdraw_delegator_reward,omitempty"`
FundCommunityPool *FundCommunityPoolMsg `json:"fund_community_pool",omitempty"`
}

// SetWithdrawAddressMsg is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37).
Expand All @@ -264,6 +265,14 @@ type WithdrawDelegatorRewardMsg struct {
Validator string `json:"validator"`
}

// FundCommunityPoolMsg is translated to a [MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2).
type FundCommunityPoolMsg struct {
// Amount is the list of coins to be send to the community pool
Amount Coins `json:"amount"`
// Depositor is the funding account
Depositor string `json:"depositor"`
fragwuerdig marked this conversation as resolved.
Show resolved Hide resolved
}

// StargateMsg is encoded the same way as a protobof [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto).
// This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)
type StargateMsg struct {
Expand Down
11 changes: 11 additions & 0 deletions types/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,14 @@ func TestGovMsgVoteWeightedSerialization(t *testing.T) {
{Abstain, "0.5"},
}, msg.VoteWeighted.Options)
}

func TestMsgFundCommunityPoolSerialization(t *testing.T) {
document := []byte(`{"fund_community_pool":{"amount":[{"amount":"300","denom":"adenom"},{"amount":"400","denom":"bdenom"}],"depositor":"generousone"}}`)

var msg DistributionMsg
err := json.Unmarshal(document, &msg)
require.NoError(t, err)

require.Equal(t, Coins{{"adenom", "300"},{"bdenom", "400"}}, msg.FundCommunityPool.Amount)
require.Equal(t, "generousone", msg.FundCommunityPool.Depositor)
}