Skip to content

Commit

Permalink
Fix legacy REST API (cosmos#352)
Browse files Browse the repository at this point in the history
* fix legacy amino register

* add label for '/wasm/code/{codeId}'

* cleanup
  • Loading branch information
chengwenxi authored Jan 5, 2021
1 parent e8d26c7 commit 6acc712
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions x/wasm/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions x/wasm/internal/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6acc712

Please sign in to comment.