From e7b1edccbaaf370537e9d9fc0a12392a5d8a03ff Mon Sep 17 00:00:00 2001 From: Till Ziegler Date: Thu, 22 Jun 2023 21:27:07 +0200 Subject: [PATCH 1/2] add FundCommunityPoolMsg to DistributionMsgs --- x/wasm/keeper/handler_plugin_encoders.go | 10 +++++++++ x/wasm/keeper/handler_plugin_encoders_test.go | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/x/wasm/keeper/handler_plugin_encoders.go b/x/wasm/keeper/handler_plugin_encoders.go index f4545fca3f..f10bd17690 100644 --- a/x/wasm/keeper/handler_plugin_encoders.go +++ b/x/wasm/keeper/handler_plugin_encoders.go @@ -145,6 +145,16 @@ func EncodeDistributionMsg(sender sdk.AccAddress, msg *wasmvmtypes.DistributionM ValidatorAddress: msg.WithdrawDelegatorReward.Validator, } return []sdk.Msg{&withdrawMsg}, nil + case msg.FundCommunityPool != nil: + amt, err := ConvertWasmCoinsToSdkCoins(msg.FundCommunityPool.Amount) + if err != nil { + return nil, err + } + fundMsg := distributiontypes.MsgFundCommunityPool{ + Depositor: sender.String(), + Amount: amt, + } + return []sdk.Msg{&fundMsg}, nil default: return nil, errorsmod.Wrap(types.ErrUnknownMsg, "unknown variant of Distribution") } diff --git a/x/wasm/keeper/handler_plugin_encoders_test.go b/x/wasm/keeper/handler_plugin_encoders_test.go index d27d6654f4..9b1c6e550e 100644 --- a/x/wasm/keeper/handler_plugin_encoders_test.go +++ b/x/wasm/keeper/handler_plugin_encoders_test.go @@ -383,6 +383,28 @@ func TestEncoding(t *testing.T) { }, }, }, + "distribution fund community pool": { + sender: addr1, + srcMsg: wasmvmtypes.CosmosMsg{ + Distribution: &wasmvmtypes.DistributionMsg { + FundCommunityPool: &wasmvmtypes.FundCommunityPoolMsg{ + Amount: wasmvmtypes.Coins{ + wasmvmtypes.NewCoin(200, "stones"), + wasmvmtypes.NewCoin(200, "feathers"), + }, + }, + }, + }, + output: []sdk.Msg{ + &distributiontypes.MsgFundCommunityPool{ + Depositor: addr1.String(), + Amount: sdk.NewCoins( + sdk.NewInt64Coin("stones", 200), + sdk.NewInt64Coin("feathers", 200), + ), + }, + }, + }, "stargate encoded bank msg": { sender: addr2, srcMsg: wasmvmtypes.CosmosMsg{ From a8de8f96dcdca6fad05018342d5c7706c3e2e3ec Mon Sep 17 00:00:00 2001 From: Till Ziegler Date: Thu, 22 Jun 2023 23:53:32 +0200 Subject: [PATCH 2/2] gofumpt --- x/wasm/keeper/handler_plugin_encoders.go | 4 ++-- x/wasm/keeper/handler_plugin_encoders_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/wasm/keeper/handler_plugin_encoders.go b/x/wasm/keeper/handler_plugin_encoders.go index f10bd17690..984815cdd7 100644 --- a/x/wasm/keeper/handler_plugin_encoders.go +++ b/x/wasm/keeper/handler_plugin_encoders.go @@ -146,13 +146,13 @@ func EncodeDistributionMsg(sender sdk.AccAddress, msg *wasmvmtypes.DistributionM } return []sdk.Msg{&withdrawMsg}, nil case msg.FundCommunityPool != nil: - amt, err := ConvertWasmCoinsToSdkCoins(msg.FundCommunityPool.Amount) + amt, err := ConvertWasmCoinsToSdkCoins(msg.FundCommunityPool.Amount) if err != nil { return nil, err } fundMsg := distributiontypes.MsgFundCommunityPool{ Depositor: sender.String(), - Amount: amt, + Amount: amt, } return []sdk.Msg{&fundMsg}, nil default: diff --git a/x/wasm/keeper/handler_plugin_encoders_test.go b/x/wasm/keeper/handler_plugin_encoders_test.go index 9b1c6e550e..c4417f5dba 100644 --- a/x/wasm/keeper/handler_plugin_encoders_test.go +++ b/x/wasm/keeper/handler_plugin_encoders_test.go @@ -386,7 +386,7 @@ func TestEncoding(t *testing.T) { "distribution fund community pool": { sender: addr1, srcMsg: wasmvmtypes.CosmosMsg{ - Distribution: &wasmvmtypes.DistributionMsg { + Distribution: &wasmvmtypes.DistributionMsg{ FundCommunityPool: &wasmvmtypes.FundCommunityPoolMsg{ Amount: wasmvmtypes.Coins{ wasmvmtypes.NewCoin(200, "stones"),