Skip to content

Commit

Permalink
Fix amino registry for custom modules
Browse files Browse the repository at this point in the history
  • Loading branch information
udpatil committed Oct 3, 2024
1 parent 2d51df9 commit 8b6edfa
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 20 deletions.
2 changes: 1 addition & 1 deletion testutil/keeper/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func EpochKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
codec.NewLegacyAmino(),
storeKey,
memStoreKey,
"EpochParams",
Expand Down
9 changes: 7 additions & 2 deletions x/epoch/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
amino.Seal()
}
12 changes: 10 additions & 2 deletions x/evm/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
AminoCdc = codec.NewAminoCodec(amino)
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
Expand All @@ -31,6 +31,14 @@ func GetAmino() *codec.LegacyAmino {
return amino
}

func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAssociate{}, "evm/MsgAssociate", nil)
cdc.RegisterConcrete(&MsgEVMTransaction{}, "evm/MsgEVMTransaction", nil)
cdc.RegisterConcrete(&MsgSend{}, "evm/MsgSend", nil)
cdc.RegisterConcrete(&MsgRegisterPointer{}, "evm/MsgRegisterPointer", nil)
cdc.RegisterConcrete(&MsgAssociateContractAddress{}, "evm/MsgAssociateContractAddress", nil)
}

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*govtypes.Content)(nil),
&AddERCNativePointerProposal{},
Expand Down
8 changes: 5 additions & 3 deletions x/mint/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

var amino = codec.NewLegacyAmino()
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
Expand All @@ -23,5 +27,3 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&UpdateMinterProposal{},
)
}

var ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
2 changes: 1 addition & 1 deletion x/oracle/keeper/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig {

ModuleBasics.RegisterLegacyAminoCodec(amino)
ModuleBasics.RegisterInterfaces(interfaceRegistry)
types.RegisterLegacyAminoCodec(amino)
types.RegisterCodec(amino)
types.RegisterInterfaces(interfaceRegistry)
return simparams.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (AppModuleBasic) Name() string {

// RegisterLegacyAminoCodec registers the module's types on the given LegacyAmino codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
types.RegisterCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
Expand Down
12 changes: 9 additions & 3 deletions x/oracle/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAggregateExchangeRateVote{}, "oracle/MsgAggregateExchangeRateVote", nil)
cdc.RegisterConcrete(&MsgDelegateFeedConsent{}, "oracle/MsgDelegateFeedConsent", nil)
}
Expand All @@ -24,6 +24,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
sdk.RegisterLegacyAminoCodec(amino)
amino.Seal()
}
2 changes: 1 addition & 1 deletion x/tokenfactory/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMigrate2to3(t *testing.T) {
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
codec.NewLegacyAmino(),
storeKey,
memStoreKey,
"TokenfactoryParams",
Expand Down
19 changes: 13 additions & 6 deletions x/tokenfactory/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
)

func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgCreateDenom{}, "tokenfactory/create-denom", nil)
cdc.RegisterConcrete(&MsgMint{}, "tokenfactory/mint", nil)
cdc.RegisterConcrete(&MsgBurn{}, "tokenfactory/burn", nil)
cdc.RegisterConcrete(&MsgChangeAdmin{}, "tokenfactory/change-admin", nil)
cdc.RegisterConcrete(&MsgCreateDenom{}, "tokenfactory/MsgCreateDenom", nil)
cdc.RegisterConcrete(&MsgMint{}, "tokenfactory/MsgMint", nil)
cdc.RegisterConcrete(&MsgBurn{}, "tokenfactory/MsgBurn", nil)
cdc.RegisterConcrete(&MsgChangeAdmin{}, "tokenfactory/MsgChangeAdmin", nil)
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
Expand All @@ -34,6 +34,13 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
sdk.RegisterLegacyAminoCodec(amino)

amino.Seal()
}

0 comments on commit 8b6edfa

Please sign in to comment.