diff --git a/CHANGELOG.md b/CHANGELOG.md index 40aec8c334..4aafbc2baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to ([#1647]) - cosmwasm-std: Add `DistributionQuery::DelegatorWithdrawAddress`. Also needs the `cosmwasm_1_3` feature (see above). ([#1593]) +- cosmwasm-std: Add `DistributionMsg::FundCommunityPool`. Also needs the + `cosmwasm_1_3` feature (see above). ([#1747]) - cosmwasm-std: Add `FromStr` impl for `Coin`. ([#1684]) - cosmwasm-std: Add `Coins` helper to handle multiple coins. ([#1687]) - cosmwasm-vm: Add `Cache::save_wasm_unchecked` to save Wasm blobs that have @@ -33,6 +35,7 @@ and this project adheres to [#1684]: https://github.com/CosmWasm/cosmwasm/pull/1684 [#1687]: https://github.com/CosmWasm/cosmwasm/pull/1687 [#1727]: https://github.com/CosmWasm/cosmwasm/issues/1727 +[#1747]: https://github.com/CosmWasm/cosmwasm/pull/1747 [#1748]: https://github.com/CosmWasm/cosmwasm/pull/1748 ### Changed diff --git a/docs/CAPABILITIES-BUILT-IN.md b/docs/CAPABILITIES-BUILT-IN.md index 11990c839a..2f2268e4e7 100644 --- a/docs/CAPABILITIES-BUILT-IN.md +++ b/docs/CAPABILITIES-BUILT-IN.md @@ -15,7 +15,7 @@ might define others. CosmWasm `1.1.0` or higher support this. - `cosmwasm_1_2` enables the `GovMsg::VoteWeighted` and `WasmMsg::Instantiate2` messages. Only chains running CosmWasm `1.2.0` or higher support this. -- `cosmwasm_1_3` enables the `BankQuery::AllDenomMetadata` and - `BankQuery::DenomMetadata` queries, as well as - `DistributionQuery::DelegatorWithdrawAddress`. Only chains running CosmWasm - `1.3.0` or higher support this. +- `cosmwasm_1_3` enables the `BankQuery::AllDenomMetadata`, + `BankQuery::DenomMetadata` and `DistributionQuery::DelegatorWithdrawAddress` + queries, as well as `DistributionMsg::FundCommunityPool`. Only chains running + CosmWasm `1.3.0` or higher support this. diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 3e93ba1868..9502f3efc6 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -111,6 +111,13 @@ pub enum DistributionMsg { /// The `validator_address` validator: String, }, + /// This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). + /// `depositor` is automatically filled with the current contract's address. + #[cfg(feature = "cosmwasm_1_3")] + FundCommunityPool { + /// The amount to spend + amount: Vec, + }, } fn binary_to_string(data: &Binary, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { @@ -463,6 +470,39 @@ mod tests { } } + #[test] + #[cfg(feature = "cosmwasm_1_3")] + fn msg_distribution_serializes_to_correct_json() { + // FundCommunityPool + let fund_coins = vec![coin(200, "feathers"), coin(200, "stones")]; + let fund_msg = DistributionMsg::FundCommunityPool { amount: fund_coins }; + let fund_json = to_binary(&fund_msg).unwrap(); + assert_eq!( + String::from_utf8_lossy(&fund_json), + r#"{"fund_community_pool":{"amount":[{"denom":"feathers","amount":"200"},{"denom":"stones","amount":"200"}]}}"#, + ); + + // SetWithdrawAddress + let set_msg = DistributionMsg::SetWithdrawAddress { + address: String::from("withdrawer"), + }; + let set_json = to_binary(&set_msg).unwrap(); + assert_eq!( + String::from_utf8_lossy(&set_json), + r#"{"set_withdraw_address":{"address":"withdrawer"}}"#, + ); + + // WithdrawDelegatorRewards + let withdraw_msg = DistributionMsg::WithdrawDelegatorReward { + validator: String::from("fancyoperator"), + }; + let withdraw_json = to_binary(&withdraw_msg).unwrap(); + assert_eq!( + String::from_utf8_lossy(&withdraw_json), + r#"{"withdraw_delegator_reward":{"validator":"fancyoperator"}}"# + ); + } + #[test] fn wasm_msg_debug_decodes_binary_string_when_possible() { #[cosmwasm_schema::cw_serde]