Skip to content

Commit

Permalink
fix(wasm): add legacy wasm types (#259)
Browse files Browse the repository at this point in the history
Co-authored-by: Till Ziegler <tz@schoeneweide.tk>
Co-authored-by: Inon Man <121477599+inon-man@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 21, 2023
1 parent 5dd891a commit 7d59142
Show file tree
Hide file tree
Showing 41 changed files with 12,885 additions and 309 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Types of changes (Stanzas):
Ref: https://keepachangelog.com/en/1.0.0/
-->
# Changelog
## [Unreleased]
### Bug fixes
* (wasm) [#259](https://github.com/classic-terra/core/pull/259) add legacy wasm types

## [v2.1.1](https://github.com/classic-terra/core/releases/tag/v2.1.1) - Jun 10, 2023
### State Machine Breaking
Expand Down
Binary file modified contrib/localnet/simulation/misc/cw721_base.wasm
Binary file not shown.
41 changes: 30 additions & 11 deletions custom/auth/tx/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 11 additions & 19 deletions custom/auth/tx/service.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions custom/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package wasm
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/spf13/cobra"

"github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/simulation"
"github.com/CosmWasm/wasmd/x/wasm/types"

customcli "github.com/classic-terra/core/v2/custom/wasm/client/cli"
customrest "github.com/classic-terra/core/v2/custom/wasm/client/rest"
"github.com/classic-terra/core/v2/custom/wasm/simulation"
"github.com/classic-terra/core/v2/x/market/types"
customtypes "github.com/classic-terra/core/v2/custom/wasm/types/legacy"
)

var _ module.AppModuleBasic = AppModuleBasic{}
Expand All @@ -28,6 +30,13 @@ func (AppModuleBasic) RegisterRESTRoutes(cliCtx client.Context, rtr *mux.Router)
customrest.RegisterRoutes(cliCtx, rtr)
}

// RegisterInterfaces implements InterfaceModule
func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
// register canonical wasm types
types.RegisterInterfaces(registry)
customtypes.RegisterInterfaces(registry)
}

// GetTxCmd returns the root tx command for the wasm module.
func (b AppModuleBasic) GetTxCmd() *cobra.Command {
return customcli.GetTxCmd()
Expand Down
48 changes: 48 additions & 0 deletions custom/wasm/types/legacy/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package legacy

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// RegisterLegacyAminoCodec registers the wasm types and interface
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgStoreCode{}, "wasm/MsgStoreCode", nil)
cdc.RegisterConcrete(&MsgMigrateCode{}, "wasm/MsgMigrateCode", nil)
cdc.RegisterConcrete(&MsgInstantiateContract{}, "wasm/MsgInstantiateContract", nil)
cdc.RegisterConcrete(&MsgExecuteContract{}, "wasm/MsgExecuteContract", nil)
cdc.RegisterConcrete(&MsgMigrateContract{}, "wasm/MsgMigrateContract", nil)
cdc.RegisterConcrete(&MsgUpdateContractAdmin{}, "wasm/MsgUpdateContractAdmin", nil)
cdc.RegisterConcrete(&MsgClearContractAdmin{}, "wasm/MsgClearContractAdmin", nil)
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
// register legacy wasm msgs (to be used in archives)
registry.RegisterInterface("terra.wasm.v1beta1.MsgInstantiateContract", (*sdk.Msg)(nil), &MsgInstantiateContract{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgExecuteContract", (*sdk.Msg)(nil), &MsgExecuteContract{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgStoreCode", (*sdk.Msg)(nil), &MsgStoreCode{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgExecuteContract", (*sdk.Msg)(nil), &MsgMigrateCode{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgMigrateCode", (*sdk.Msg)(nil), &MsgMigrateContract{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgUpdateContractAdmin", (*sdk.Msg)(nil), &MsgUpdateContractAdmin{})
registry.RegisterInterface("terra.wasm.v1beta1.MsgClearContractAdmin", (*sdk.Msg)(nil), &MsgClearContractAdmin{})
}

var (
amino = codec.NewLegacyAmino()

// ModuleCdc references the global x/market module codec. Note, the codec should
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
// still used for that purpose.
//
// The actual codec used for serialization should be provided to x/staking and
// defined at the application level.
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
Loading

0 comments on commit 7d59142

Please sign in to comment.