Skip to content

Commit

Permalink
Merge pull request #1519 from CosmWasm/mergify/bp/releases/v0.3x/pr-1458
Browse files Browse the repository at this point in the history
Add Encodings For `MsgFundCommunityPool` from Distribution (backport #1458)
  • Loading branch information
alpe committed Jul 18, 2023
2 parents c2a8e51 + 6164b8b commit b41fc0a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions x/wasm/keeper/handler_plugin_encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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, sdkerrors.Wrap(types.ErrUnknownMsg, "unknown variant of Distribution")
}
Expand Down
22 changes: 22 additions & 0 deletions x/wasm/keeper/handler_plugin_encoders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,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{
Expand Down

0 comments on commit b41fc0a

Please sign in to comment.