Skip to content

Commit

Permalink
Merge pull request cosmos#437 from CosmWasm/wasm-migrate-msg
Browse files Browse the repository at this point in the history
Encode WasmMsg::Migrate and test
  • Loading branch information
ethanfrey authored Mar 5, 2021
2 parents b98353e + 27d5351 commit d51a1b8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions x/wasm/internal/keeper/handler_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ func EncodeWasmMsg(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]sdk.Msg,
Funds: coins,
}
return []sdk.Msg{&sdkMsg}, nil
case msg.Migrate != nil:
sdkMsg := types.MsgMigrateContract{
Sender: sender.String(),
Contract: msg.Migrate.ContractAddr,
CodeID: msg.Migrate.NewCodeID,
MigrateMsg: msg.Migrate.Msg,
}
return []sdk.Msg{&sdkMsg}, nil
default:
return nil, sdkerrors.Wrap(types.ErrInvalidMsg, "Unknown variant of Wasm")
}
Expand Down
20 changes: 20 additions & 0 deletions x/wasm/internal/keeper/handler_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,26 @@ func TestEncoding(t *testing.T) {
},
},
},
"wasm migrate": {
sender: addr2,
srcMsg: wasmvmtypes.CosmosMsg{
Wasm: &wasmvmtypes.WasmMsg{
Migrate: &wasmvmtypes.MigrateMsg{
ContractAddr: addr1.String(),
NewCodeID: 12,
Msg: jsonMsg,
},
},
},
output: []sdk.Msg{
&types.MsgMigrateContract{
Sender: addr2.String(),
Contract: addr1.String(),
CodeID: 12,
MigrateMsg: jsonMsg,
},
},
},
"staking delegate": {
sender: addr1,
srcMsg: wasmvmtypes.CosmosMsg{
Expand Down

0 comments on commit d51a1b8

Please sign in to comment.