diff --git a/x/wasm/internal/keeper/handler_plugin.go b/x/wasm/internal/keeper/handler_plugin.go index ba880bbe73..02fb42ad98 100644 --- a/x/wasm/internal/keeper/handler_plugin.go +++ b/x/wasm/internal/keeper/handler_plugin.go @@ -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") } diff --git a/x/wasm/internal/keeper/handler_plugin_test.go b/x/wasm/internal/keeper/handler_plugin_test.go index 3348d8bcb0..b2a6700b31 100644 --- a/x/wasm/internal/keeper/handler_plugin_test.go +++ b/x/wasm/internal/keeper/handler_plugin_test.go @@ -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{