Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
a6f0b642d8
commit
68ec945293
+4
-5
@@ -1,9 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"cosmossdk.io/core/legacy"
|
||||
"cosmossdk.io/core/registry"
|
||||
coretransaction "cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/core/transaction"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -12,9 +11,9 @@ const (
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the sdk message type.
|
||||
func RegisterLegacyAminoCodec(cdc legacy.Amino) {
|
||||
cdc.RegisterInterface((*coretransaction.Msg)(nil), nil)
|
||||
cdc.RegisterInterface((*Tx)(nil), nil)
|
||||
func RegisterLegacyAminoCodec(registrar registry.AminoRegistrar) {
|
||||
registrar.RegisterInterface((*transaction.Msg)(nil), nil)
|
||||
registrar.RegisterInterface((*Tx)(nil), nil)
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the sdk message type.
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/genesis"
|
||||
"cosmossdk.io/core/legacy"
|
||||
"cosmossdk.io/core/registry"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
@@ -198,9 +197,9 @@ func (c coreAppModuleAdaptor) RegisterInterfaces(reg registry.InterfaceRegistrar
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec implements HasAminoCodec
|
||||
func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino legacy.Amino) {
|
||||
func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino registry.AminoRegistrar) {
|
||||
if mod, ok := c.module.(interface {
|
||||
RegisterLegacyAminoCodec(amino legacy.Amino)
|
||||
RegisterLegacyAminoCodec(amino registry.AminoRegistrar)
|
||||
}); ok {
|
||||
mod.RegisterLegacyAminoCodec(amino)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/genesis"
|
||||
"cosmossdk.io/core/legacy"
|
||||
"cosmossdk.io/core/registry"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
@@ -69,7 +68,7 @@ type HasGenesisBasics = appmodule.HasGenesisBasics
|
||||
// HasAminoCodec is the interface for modules that have amino codec registration.
|
||||
// Deprecated: modules should not need to register their own amino codecs.
|
||||
type HasAminoCodec interface {
|
||||
RegisterLegacyAminoCodec(legacy.Amino)
|
||||
RegisterLegacyAminoCodec(registry.AminoRegistrar)
|
||||
}
|
||||
|
||||
// HasGRPCGateway is the interface for modules to register their gRPC gateway routes.
|
||||
@@ -294,14 +293,14 @@ func (m *Manager) SetOrderMigrations(moduleNames ...string) {
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec registers all module codecs
|
||||
func (m *Manager) RegisterLegacyAminoCodec(cdc legacy.Amino) {
|
||||
func (m *Manager) RegisterLegacyAminoCodec(registrar registry.AminoRegistrar) {
|
||||
for name, b := range m.Modules {
|
||||
if _, ok := b.(interface{ RegisterLegacyAminoCodec(*codec.LegacyAmino) }); ok {
|
||||
panic(fmt.Sprintf("%s uses a deprecated amino registration api, implement HasAminoCodec instead if necessary", name))
|
||||
}
|
||||
|
||||
if mod, ok := b.(HasAminoCodec); ok {
|
||||
mod.RegisterLegacyAminoCodec(cdc)
|
||||
mod.RegisterLegacyAminoCodec(registrar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user