Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix / Legacy Amino codec registration #262

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions x/bet/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { return AppModuleB
// Name returns the module's name.
func (AppModuleBasic) Name() string { return types.ModuleName }

// RegisterCodec registers the codec for the app module basic
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }

// RegisterLegacyAminoCodec registers the legacy amino codec for the app module basic
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
Expand Down
21 changes: 15 additions & 6 deletions x/bet/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package types

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

"github.com/cosmos/cosmos-sdk/types/msgservice"
)

// RegisterCodec registers module codec to the app codec
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgWager{}, "bet/Wager", nil)
// RegisterLegacyAminoCodec registers the necessary x/bet interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgWager{}, "bet/Wager")
}

// RegisterInterfaces registers the module interface types
Expand All @@ -23,8 +26,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
18 changes: 13 additions & 5 deletions x/house/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz"

Expand All @@ -12,8 +14,8 @@ import (
// RegisterLegacyAminoCodec registers the necessary x/house interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgDeposit{}, "house/Deposit", nil)
cdc.RegisterConcrete(&MsgWithdraw{}, "house/Withdraw", nil)
legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "house/Deposit")
legacy.RegisterAminoMsg(cdc, &MsgWithdraw{}, "house/Withdraw")
}

// RegisterInterfaces registers the x/house interfaces types with the interface registry
Expand All @@ -32,8 +34,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
7 changes: 1 addition & 6 deletions x/market/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

// RegisterCodec registers the codec for the app module basic
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

// RegisterLegacyAminoCodec registers the legacy amino codec for the app module basic
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
Expand Down
25 changes: 17 additions & 8 deletions x/market/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package types

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

"github.com/cosmos/cosmos-sdk/types/msgservice"
)

// RegisterCodec registers module codec to the app codec
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAdd{}, "market/Add", nil)
cdc.RegisterConcrete(&MsgResolve{}, "market/Resolve", nil)
cdc.RegisterConcrete(&MsgUpdate{}, "market/Update", nil)
// RegisterLegacyAminoCodec registers the necessary x/market interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgAdd{}, "market/Add")
legacy.RegisterAminoMsg(cdc, &MsgResolve{}, "market/Resolve")
legacy.RegisterAminoMsg(cdc, &MsgUpdate{}, "market/Update")
}

// RegisterInterfaces registers the module interface types
Expand All @@ -32,8 +35,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
7 changes: 3 additions & 4 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic {
// Name returns the module's name.
func (AppModuleBasic) Name() string { return types.ModuleName }

// RegisterCodec registers the codec for the app module basic
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }

// RegisterLegacyAminoCodec registers the lagacy amino codec for the app module basic
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
Expand Down
19 changes: 14 additions & 5 deletions x/mint/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

// RegisterCodec registers module codec to the app codec
func RegisterCodec(_ *codec.LegacyAmino) {
// RegisterLegacyAminoCodec registers the necessary x/mint interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {
// left empty because no message is available in this module
}

Expand All @@ -17,8 +20,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
7 changes: 3 additions & 4 deletions x/orderbook/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { return AppModuleB
// Name returns the orderbook module's name.
func (AppModuleBasic) Name() string { return types.ModuleName }

// RegisterCodec registers the codec for the app module basic
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }

// RegisterLegacyAminoCodec registers the legacy amino codec for the app module basic
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
Expand Down
20 changes: 15 additions & 5 deletions x/orderbook/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// RegisterCodec registers module codec to the app codec
func RegisterCodec(_ *codec.LegacyAmino) {}
// RegisterLegacyAminoCodec registers the necessary x/orderbook interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {
// left empty because no message is available in this module
}

// RegisterInterfaces registers the module interface types
func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil))
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
7 changes: 3 additions & 4 deletions x/ovm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { return AppModuleB
// Name returns the module's name.
func (AppModuleBasic) Name() string { return types.ModuleName }

// RegisterCodec registers the codec for the app module basic
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }

// RegisterLegacyAminoCodec registers the lagacy amino codec for the app module basic
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) }
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
Expand Down
27 changes: 16 additions & 11 deletions x/ovm/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ package types

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

// RegisterCodec registers module codec to the app codec
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(
&MsgSubmitPubkeysChangeProposalRequest{},
"ovm/SubmitPubkeysChangeProposal",
nil,
)
cdc.RegisterConcrete(&MsgVotePubkeysChangeRequest{}, "ovm/VotePubkeysChange", nil)
// RegisterLegacyAminoCodec registers the necessary x/ovm interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgSubmitPubkeysChangeProposalRequest{}, "ovm/SubmitPubkeysChangeProposal")
legacy.RegisterAminoMsg(cdc, &MsgVotePubkeysChangeRequest{}, "ovm/VotePubkeysChange")
}

// RegisterInterfaces registers the module interface types
Expand All @@ -27,8 +26,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
// Amino is the legacy amino codec
Amino = codec.NewLegacyAmino()
// amino is the legacy amino codec
amino = codec.NewLegacyAmino()
// ModuleCdc is the codec of the module
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

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