diff --git a/app/codec.go b/app/codec.go index 86a5633..32b0041 100644 --- a/app/codec.go +++ b/app/codec.go @@ -1,7 +1,9 @@ package app import ( + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdktypes "github.com/cosmos/cosmos-sdk/types" crypto "github.com/artela-network/artela-rollkit/ethereum/crypto/codec" "github.com/artela-network/artela-rollkit/ethereum/types" @@ -12,3 +14,10 @@ func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { crypto.RegisterInterfaces(interfaceRegistry) types.RegisterInterfaces(interfaceRegistry) } + +// RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + sdktypes.RegisterLegacyAminoCodec(cdc) + crypto.RegisterCrypto(cdc) + codec.RegisterEvidences(cdc) +} diff --git a/app/encoding.go b/app/encoding.go new file mode 100644 index 0000000..2b489e6 --- /dev/null +++ b/app/encoding.go @@ -0,0 +1,30 @@ +package app + +import ( + amino "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + + "github.com/artela-network/artela-rollkit/app/params" +) + +// MakeConfig creates an EncodingConfig for testing +func MakeConfig(mb module.BasicManager) params.EncodingConfig { + cdc := amino.NewLegacyAmino() + interfaceRegistry := types.NewInterfaceRegistry() + codec := amino.NewProtoCodec(interfaceRegistry) + + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: codec, + TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), + Amino: cdc, + } + + RegisterLegacyAminoCodec(encodingConfig.Amino) + mb.RegisterLegacyAminoCodec(encodingConfig.Amino) + RegisterInterfaces(encodingConfig.InterfaceRegistry) + mb.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig +} diff --git a/cmd/artrolld/cmd/root.go b/cmd/artrolld/cmd/root.go index 2597a8d..eb4fb74 100644 --- a/cmd/artrolld/cmd/root.go +++ b/cmd/artrolld/cmd/root.go @@ -112,6 +112,9 @@ func NewRootCmd() *cobra.Command { autoCliOpts.Modules[name] = mod } + // RegisterInterfaces & RegisterLegacyAminoCodec + app.MakeConfig(moduleBasicManager) + initRootCmd(rootCmd, clientCtx.TxConfig, moduleBasicManager) overwriteFlagDefaults(rootCmd, map[string]string{