From 6acc71218bdebfe9c6f720adfa378bef0d65fd07 Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 5 Jan 2021 21:07:48 +0800 Subject: [PATCH] Fix legacy REST API (#352) * fix legacy amino register * add label for '/wasm/code/{codeId}' * cleanup --- x/wasm/client/rest/tx.go | 2 ++ x/wasm/internal/types/codec.go | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/x/wasm/client/rest/tx.go b/x/wasm/client/rest/tx.go index 8f5e9c69315..d761cd994ed 100644 --- a/x/wasm/client/rest/tx.go +++ b/x/wasm/client/rest/tx.go @@ -29,6 +29,7 @@ type storeCodeReq struct { type instantiateContractReq struct { BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Label string `json:"label" yaml:"label"` Deposit sdk.Coins `json:"deposit" yaml:"deposit"` Admin string `json:"admin,omitempty" yaml:"admin"` InitMsg []byte `json:"init_msg" yaml:"init_msg"` @@ -109,6 +110,7 @@ func instantiateContractHandlerFn(cliCtx client.Context) http.HandlerFunc { msg := types.MsgInstantiateContract{ Sender: req.BaseReq.From, CodeID: codeID, + Label: req.Label, InitFunds: req.Deposit, InitMsg: req.InitMsg, Admin: req.Admin, diff --git a/x/wasm/internal/types/codec.go b/x/wasm/internal/types/codec.go index 5a7e3b0c0bd..0015caf587d 100644 --- a/x/wasm/internal/types/codec.go +++ b/x/wasm/internal/types/codec.go @@ -10,18 +10,18 @@ import ( // RegisterLegacyAminoCodec registers the account types and interface func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(MsgStoreCode{}, "wasm/MsgStoreCode", nil) - cdc.RegisterConcrete(MsgInstantiateContract{}, "wasm/MsgInstantiateContract", nil) - cdc.RegisterConcrete(MsgExecuteContract{}, "wasm/MsgExecuteContract", nil) - cdc.RegisterConcrete(MsgMigrateContract{}, "wasm/MsgMigrateContract", nil) - cdc.RegisterConcrete(MsgUpdateAdmin{}, "wasm/MsgUpdateAdmin", nil) - cdc.RegisterConcrete(MsgClearAdmin{}, "wasm/MsgClearAdmin", nil) - - cdc.RegisterConcrete(StoreCodeProposal{}, "wasm/StoreCodeProposal", nil) - cdc.RegisterConcrete(InstantiateContractProposal{}, "wasm/InstantiateContractProposal", nil) - cdc.RegisterConcrete(MigrateContractProposal{}, "wasm/MigrateContractProposal", nil) - cdc.RegisterConcrete(UpdateAdminProposal{}, "wasm/UpdateAdminProposal", nil) - cdc.RegisterConcrete(ClearAdminProposal{}, "wasm/ClearAdminProposal", nil) + cdc.RegisterConcrete(&MsgStoreCode{}, "wasm/MsgStoreCode", nil) + cdc.RegisterConcrete(&MsgInstantiateContract{}, "wasm/MsgInstantiateContract", nil) + cdc.RegisterConcrete(&MsgExecuteContract{}, "wasm/MsgExecuteContract", nil) + cdc.RegisterConcrete(&MsgMigrateContract{}, "wasm/MsgMigrateContract", nil) + cdc.RegisterConcrete(&MsgUpdateAdmin{}, "wasm/MsgUpdateAdmin", nil) + cdc.RegisterConcrete(&MsgClearAdmin{}, "wasm/MsgClearAdmin", nil) + + cdc.RegisterConcrete(&StoreCodeProposal{}, "wasm/StoreCodeProposal", nil) + cdc.RegisterConcrete(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal", nil) + cdc.RegisterConcrete(&MigrateContractProposal{}, "wasm/MigrateContractProposal", nil) + cdc.RegisterConcrete(&UpdateAdminProposal{}, "wasm/UpdateAdminProposal", nil) + cdc.RegisterConcrete(&ClearAdminProposal{}, "wasm/ClearAdminProposal", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) {