Skip to content

Commit

Permalink
Add Encodings For MsgFundCommunityPool from Distribution (#1458)
Browse files Browse the repository at this point in the history
* add FundCommunityPoolMsg to DistributionMsgs

* gofumpt

(cherry picked from commit c23ecae)
  • Loading branch information
fragwuerdig authored and mergify[bot] committed Jul 18, 2023
1 parent c2a8e51 commit 6164b8b
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

Check warning on line 149 in x/wasm/keeper/handler_plugin_encoders.go

View check run for this annotation

Codecov / codecov/patch

x/wasm/keeper/handler_plugin_encoders.go#L149

Added line #L149 was not covered by tests
}
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 6164b8b

Please sign in to comment.