refactor: decouple from sdk/codec in amino codec usage (#20369)

This commit is contained in:
Matt Kocubinski 2024-05-14 12:52:51 -04:00 committed by GitHub
parent fbc61d2f5d
commit 493d486bc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
63 changed files with 286 additions and 195 deletions

View File

@ -118,6 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### API Breaking Changes
* (types)[#20369](https://github.com/cosmos/cosmos-sdk/pull/20369) The signature of `HasAminoCodec` has changed to accept a `core/legacy.Amino` interface instead of `codec.LegacyAmino`.
* (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument.
* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
* (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes:

View File

@ -186,6 +186,13 @@ The signature of the extension interface `HasRegisterInterfaces` has been change
+func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
```
The signature of the extension interface `HasAminoCodec` has been changed to accept a `cosmossdk.io/core/legacy.Amino` instead of a `codec.LegacyAmino`. Modules should update their `HasAminoCodec` implementation to accept a `cosmossdk.io/core/legacy.Amino` interface.
```diff
-func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
+func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
```
##### Simulation
`MsgSimulatorFn` has been updated to return an error. Its context argument has been removed, and an address.Codec has

View File

@ -10,6 +10,8 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
"github.com/tendermint/go-amino"
"cosmossdk.io/core/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
)
@ -23,15 +25,17 @@ func (cdc *LegacyAmino) Seal() {
cdc.Amino.Seal()
}
var _ legacy.Amino = &LegacyAmino{}
func NewLegacyAmino() *LegacyAmino {
return &LegacyAmino{amino.NewCodec()}
}
// RegisterEvidences registers CometBFT evidence types with the provided Amino
// codec.
func RegisterEvidences(cdc *LegacyAmino) {
cdc.Amino.RegisterInterface((*cmttypes.Evidence)(nil), nil)
cdc.Amino.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil)
func RegisterEvidences(cdc legacy.Amino) {
cdc.RegisterInterface((*cmttypes.Evidence)(nil), nil)
cdc.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence")
}
// MarshalJSONIndent provides a utility for indented JSON encoding of an object
@ -175,12 +179,19 @@ func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error {
return errors.New("AminoCodec can't handle unpack protobuf Any's")
}
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions) {
cdc.Amino.RegisterInterface(ptr, iopts)
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *legacy.InterfaceOptions) {
if iopts == nil {
cdc.Amino.RegisterInterface(ptr, nil)
} else {
cdc.Amino.RegisterInterface(ptr, &amino.InterfaceOptions{
Priority: iopts.Priority,
AlwaysDisambiguate: iopts.AlwaysDisambiguate,
})
}
}
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions) {
cdc.Amino.RegisterConcrete(o, name, copts)
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string) {
cdc.Amino.RegisterConcrete(o, name, nil)
}
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) {

View File

@ -17,8 +17,8 @@ func createTestCodec() *codec.LegacyAmino {
cdc.RegisterInterface((*testdata.Animal)(nil), nil)
// NOTE: since we unmarshal interface using pointers, we need to register a pointer
// types here.
cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog", nil)
cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat", nil)
cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog")
cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat")
return cdc
}

47
codec/depinject.go Normal file
View File

@ -0,0 +1,47 @@
package codec
import (
"github.com/cosmos/gogoproto/proto"
"cosmossdk.io/core/address"
"cosmossdk.io/core/legacy"
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec/types"
)
func ProvideInterfaceRegistry(
addressCodec address.Codec,
validatorAddressCodec address.ValidatorAddressCodec,
customGetSigners []signing.CustomGetSigner,
) (types.InterfaceRegistry, error) {
signingOptions := signing.Options{
AddressCodec: addressCodec,
ValidatorAddressCodec: validatorAddressCodec,
}
for _, signer := range customGetSigners {
signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn)
}
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signingOptions,
})
if err != nil {
return nil, err
}
if err := interfaceRegistry.SigningContext().Validate(); err != nil {
return nil, err
}
return interfaceRegistry, nil
}
func ProvideLegacyAmino() legacy.Amino {
return NewLegacyAmino()
}
func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {
return NewProtoCodec(interfaceRegistry)
}

View File

@ -3,16 +3,17 @@ package legacy
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// RegisterAminoMsg first checks that the msgName is <40 chars
// (else this would break ledger nano signing: https://github.com/cosmos/cosmos-sdk/issues/10870),
// then registers the concrete msg type with amino.
func RegisterAminoMsg(cdc *codec.LegacyAmino, msg sdk.Msg, msgName string) {
func RegisterAminoMsg(cdc legacy.Amino, msg sdk.Msg, msgName string) {
if len(msgName) > 39 {
panic(fmt.Errorf("msg name %s is too long to be registered with amino", msgName))
}
cdc.RegisterConcrete(msg, msgName, nil)
cdc.RegisterConcrete(msg, msgName)
}

14
core/legacy/amino.go Normal file
View File

@ -0,0 +1,14 @@
package legacy
type Amino interface {
// RegisterInterface registers an interface and its concrete type with the Amino codec.
RegisterInterface(interfacePtr any, iopts *InterfaceOptions)
// RegisterConcrete registers a concrete type with the Amino codec.
RegisterConcrete(cdcType interface{}, name string)
}
type InterfaceOptions struct {
Priority []string // Disamb priority.
AlwaysDisambiguate bool // If true, include disamb for all types.
}

View File

@ -3,7 +3,8 @@ package codec
import (
"github.com/cometbft/cometbft/crypto/sr25519"
"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/legacy"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@ -12,22 +13,22 @@ import (
// RegisterCrypto registers all crypto dependency types with the provided Amino
// codec.
func RegisterCrypto(cdc *codec.LegacyAmino) {
func RegisterCrypto(cdc legacy.Amino) {
cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
sr25519.PubKeyName)
cdc.RegisterConcrete(&ed25519.PubKey{},
ed25519.PubKeyName, nil)
ed25519.PubKeyName)
cdc.RegisterConcrete(&secp256k1.PubKey{},
secp256k1.PubKeyName, nil)
secp256k1.PubKeyName)
cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{},
kmultisig.PubKeyAminoRoute, nil)
kmultisig.PubKeyAminoRoute)
cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PrivKey{},
sr25519.PrivKeyName, nil)
sr25519.PrivKeyName)
cdc.RegisterConcrete(&ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
ed25519.PrivKeyName)
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
secp256k1.PrivKeyName)
}

View File

@ -13,9 +13,9 @@ func init() {
// RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*LegacyInfo)(nil), nil)
cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params", nil)
cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo", nil)
cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo", nil)
cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo", nil)
cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo", nil)
cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params")
cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo")
cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo")
cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo")
cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo")
}

View File

@ -22,11 +22,11 @@ var AminoCdc = codec.NewLegacyAmino()
func init() {
AminoCdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil)
AminoCdc.RegisterConcrete(ed25519.PubKey{},
ed25519.PubKeyName, nil)
ed25519.PubKeyName)
AminoCdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
sr25519.PubKeyName)
AminoCdc.RegisterConcrete(&secp256k1.PubKey{},
secp256k1.PubKeyName, nil)
secp256k1.PubKeyName)
AminoCdc.RegisterConcrete(&LegacyAminoPubKey{},
PubKeyAminoRoute, nil)
PubKeyAminoRoute)
}

View File

@ -15,5 +15,5 @@ func init() {
// RegisterAmino registers all go-crypto related types in the given (amino) codec.
func RegisterAmino(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(PrivKeyLedgerSecp256k1{},
"tendermint/PrivKeyLedgerSecp256k1", nil)
"tendermint/PrivKeyLedgerSecp256k1")
}

View File

@ -10,6 +10,7 @@ import (
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
authtx "cosmossdk.io/x/auth/tx"
@ -46,7 +47,7 @@ type App struct {
storeKeys []storetypes.StoreKey
interfaceRegistry codectypes.InterfaceRegistry
cdc codec.Codec
amino *codec.LegacyAmino
amino legacy.Amino
baseAppOptions []BaseAppOption
msgServiceRouter *baseapp.MsgServiceRouter
grpcQueryRouter *baseapp.GRPCQueryRouter

View File

@ -19,12 +19,12 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/genesis"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
@ -93,7 +93,11 @@ func init() {
appconfig.RegisterModule(&runtimev1alpha1.Module{},
appconfig.Provide(
ProvideApp,
ProvideInterfaceRegistry,
// to decouple runtime from sdk/codec ProvideInterfaceReistry can be registered from the app
// i.e. in the call to depinject.Inject(...)
codec.ProvideInterfaceRegistry,
codec.ProvideLegacyAmino,
codec.ProvideProtoCodec,
ProvideKVStoreKey,
ProvideTransientStoreKey,
ProvideMemoryStoreKey,
@ -109,9 +113,11 @@ func init() {
)
}
func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) (
codec.Codec,
*codec.LegacyAmino,
func ProvideApp(
interfaceRegistry codectypes.InterfaceRegistry,
amino legacy.Amino,
protoCodec *codec.ProtoCodec,
) (
*AppBuilder,
*baseapp.MsgServiceRouter,
*baseapp.GRPCQueryRouter,
@ -130,25 +136,22 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) (
_, _ = fmt.Fprintln(os.Stderr, err.Error())
}
amino := codec.NewLegacyAmino()
std.RegisterInterfaces(interfaceRegistry)
std.RegisterLegacyAminoCodec(amino)
cdc := codec.NewProtoCodec(interfaceRegistry)
msgServiceRouter := baseapp.NewMsgServiceRouter()
grpcQueryRouter := baseapp.NewGRPCQueryRouter()
app := &App{
storeKeys: nil,
interfaceRegistry: interfaceRegistry,
cdc: cdc,
cdc: protoCodec,
amino: amino,
msgServiceRouter: msgServiceRouter,
grpcQueryRouter: grpcQueryRouter,
}
appBuilder := &AppBuilder{app}
return cdc, amino, appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil
return appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil
}
type AppInputs struct {
@ -161,7 +164,7 @@ type AppInputs struct {
ModuleManager *module.Manager
BaseAppOptions []BaseAppOption
InterfaceRegistry codectypes.InterfaceRegistry
LegacyAmino *codec.LegacyAmino
LegacyAmino legacy.Amino
}
func SetupAppBuilder(inputs AppInputs) {
@ -175,34 +178,6 @@ func SetupAppBuilder(inputs AppInputs) {
app.ModuleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino)
}
func ProvideInterfaceRegistry(
addressCodec address.Codec,
validatorAddressCodec address.ValidatorAddressCodec,
customGetSigners []signing.CustomGetSigner,
) (codectypes.InterfaceRegistry, error) {
signingOptions := signing.Options{
AddressCodec: addressCodec,
ValidatorAddressCodec: validatorAddressCodec,
}
for _, signer := range customGetSigners {
signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn)
}
interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signingOptions,
})
if err != nil {
return nil, err
}
if err := interfaceRegistry.SigningContext().Validate(); err != nil {
return nil, err
}
return interfaceRegistry, nil
}
func registerStoreKey(wrapper *AppBuilder, key storetypes.StoreKey) {
wrapper.app.storeKeys = append(wrapper.app.storeKeys, key)
}

View File

@ -12,6 +12,7 @@ import (
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cast"
"cosmossdk.io/core/legacy"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
@ -67,7 +68,7 @@ var (
// capabilities aren't needed for testing.
type SimApp struct {
*runtime.App
legacyAmino *codec.LegacyAmino
legacyAmino legacy.Amino
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry
@ -342,7 +343,12 @@ func (app *SimApp) Close() error {
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *SimApp) LegacyAmino() *codec.LegacyAmino {
return app.legacyAmino
switch cdc := app.legacyAmino.(type) {
case *codec.LegacyAmino:
return cdc
default:
panic("unexpected codec type")
}
}
// AppCodec returns SimApp's app codec.

View File

@ -12,6 +12,7 @@ import (
"cosmossdk.io/client/v2/autocli"
clientv2keyring "cosmossdk.io/client/v2/autocli/keyring"
"cosmossdk.io/core/address"
"cosmossdk.io/core/legacy"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/simapp"
@ -100,7 +101,7 @@ func ProvideClientContext(
appCodec codec.Codec,
interfaceRegistry codectypes.InterfaceRegistry,
txConfigOpts tx.ConfigOptions,
legacyAmino *codec.LegacyAmino,
legacyAmino legacy.Amino,
addressCodec address.Codec,
validatorAddressCodec address.ValidatorAddressCodec,
consensusAddressCodec address.ConsensusAddressCodec,
@ -109,10 +110,15 @@ func ProvideClientContext(
) client.Context {
var err error
amino, ok := legacyAmino.(*codec.LegacyAmino)
if !ok {
panic("ProvideClientContext requires a *codec.LegacyAmino instance")
}
clientCtx := client.Context{}.
WithCodec(appCodec).
WithInterfaceRegistry(interfaceRegistry).
WithLegacyAmino(legacyAmino).
WithLegacyAmino(amino).
WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}).
WithAddressCodec(addressCodec).

View File

@ -1,6 +1,8 @@
package std
import (
"cosmossdk.io/core/legacy"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
@ -9,7 +11,7 @@ import (
)
// RegisterLegacyAminoCodec registers types with the Amino codec.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc legacy.Amino) {
sdk.RegisterLegacyAminoCodec(cdc)
cryptocodec.RegisterCrypto(cdc)
codec.RegisterEvidences(cdc)

View File

@ -57,7 +57,6 @@ type SimTestSuite struct {
ctx sdk.Context
app *runtime.App
legacyAmino *codec.LegacyAmino
codec codec.Codec
interfaceRegistry codectypes.InterfaceRegistry
txConfig client.TxConfig
@ -72,7 +71,6 @@ func (suite *SimTestSuite) SetupTest() {
AppConfig,
depinject.Supply(log.NewNopLogger()),
),
&suite.legacyAmino,
&suite.codec,
&suite.interfaceRegistry,
&suite.txConfig,

View File

@ -49,7 +49,6 @@ type SimTestSuite struct {
accountKeeper authkeeper.AccountKeeper
bankKeeper bankkeeper.Keeper
cdc codec.Codec
legacyAmino *codec.LegacyAmino
}
func (suite *SimTestSuite) SetupTest() {
@ -74,7 +73,6 @@ func (suite *SimTestSuite) SetupTest() {
&suite.interfaceRegistry,
&suite.txConfig,
&suite.cdc,
&suite.legacyAmino,
)
suite.Require().NoError(err)

View File

@ -47,7 +47,6 @@ type SimTestSuite struct {
accounts []simtypes.Account
app *runtime.App
legacyAmino *codec.LegacyAmino
codec codec.Codec
interfaceRegistry codectypes.InterfaceRegistry
txConfig client.TxConfig
@ -86,7 +85,6 @@ func (suite *SimTestSuite) SetupTest() {
depinject.Supply(log.NewNopLogger()),
),
startupCfg,
&suite.legacyAmino,
&suite.codec,
&suite.interfaceRegistry,
&suite.txConfig,

View File

@ -21,6 +21,7 @@ import (
"github.com/spf13/cobra"
"cosmossdk.io/core/address"
"cosmossdk.io/core/legacy"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
@ -184,7 +185,7 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
var (
appBuilder *runtime.AppBuilder
txConfig client.TxConfig
legacyAmino *codec.LegacyAmino
legacyAmino legacy.Amino
cdc codec.Codec
interfaceRegistry codectypes.InterfaceRegistry
addressCodec address.Codec
@ -214,7 +215,11 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
})
cfg.Codec = cdc
cfg.TxConfig = txConfig
cfg.LegacyAmino = legacyAmino
amino, ok := legacyAmino.(*codec.LegacyAmino)
if !ok {
return Config{}, errors.New("legacyAmino must be a *codec.LegacyAmino")
}
cfg.LegacyAmino = amino
cfg.InterfaceRegistry = interfaceRegistry
cfg.GenesisState = appBuilder.DefaultGenesis()
cfg.AppConstructor = func(val ValidatorI) servertypes.Application {

View File

@ -1,9 +1,9 @@
package types
import (
"cosmossdk.io/core/legacy"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
)
@ -13,7 +13,7 @@ const (
)
// RegisterLegacyAminoCodec registers the sdk message type.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc legacy.Amino) {
cdc.RegisterInterface((*coretransaction.Msg)(nil), nil)
cdc.RegisterInterface((*Tx)(nil), nil)
}

View File

@ -9,11 +9,11 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/genesis"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -198,9 +198,9 @@ func (c coreAppModuleAdaptor) RegisterInterfaces(reg registry.InterfaceRegistrar
}
// RegisterLegacyAminoCodec implements HasAminoCodec
func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino legacy.Amino) {
if mod, ok := c.module.(interface {
RegisterLegacyAminoCodec(amino *codec.LegacyAmino)
RegisterLegacyAminoCodec(amino legacy.Amino)
}); ok {
mod.RegisterLegacyAminoCodec(amino)
}

View File

@ -34,12 +34,12 @@ 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"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -78,7 +78,7 @@ type HasGenesisBasics interface {
// 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(*codec.LegacyAmino)
RegisterLegacyAminoCodec(legacy.Amino)
}
// HasGRPCGateway is the interface for modules to register their gRPC gateway routes.
@ -299,7 +299,7 @@ func (m *Manager) SetOrderMigrations(moduleNames ...string) {
}
// RegisterLegacyAminoCodec registers all module codecs
func (m *Manager) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (m *Manager) RegisterLegacyAminoCodec(cdc legacy.Amino) {
for _, b := range m.Modules {
if mod, ok := b.(HasAminoCodec); ok {
mod.RegisterLegacyAminoCodec(cdc)

View File

@ -108,7 +108,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
require.NoError(t, err)
// We're using TestMsg encoding in some tests, so register it here.
suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil)
suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg")
testdata.RegisterInterfaces(suite.encCfg.InterfaceRegistry)
suite.clientCtx = client.Context{}.

View File

@ -1,9 +1,9 @@
package legacytx
import (
"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/legacy"
)
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil)
func RegisterLegacyAminoCodec(cdc legacy.Amino) {
cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx")
}

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/auth/keeper"
"cosmossdk.io/x/auth/simulation"
@ -48,7 +49,12 @@ type AppModule struct {
func (am AppModule) IsAppModule() {}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, ak types.AccountsModKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule {
func NewAppModule(
cdc codec.Codec,
accountKeeper keeper.AccountKeeper,
ak types.AccountsModKeeper,
randGenAccountsFn types.RandomGenesisAccountsFn,
) AppModule {
return AppModule{
accountKeeper: accountKeeper,
randGenAccountsFn: randGenAccountsFn,
@ -63,7 +69,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the auth module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,11 +1,11 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"cosmossdk.io/x/auth/migrations/legacytx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -13,14 +13,14 @@ import (
// RegisterLegacyAminoCodec registers the account interfaces and concrete types on the
// provided LegacyAmino codec. These types are used for Amino JSON serialization
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterInterface((*sdk.ModuleAccountI)(nil), nil)
cdc.RegisterInterface((*GenesisAccount)(nil), nil)
cdc.RegisterInterface((*sdk.AccountI)(nil), nil)
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil)
cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil)
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil)
cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential", nil)
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount")
cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount")
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params")
cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/auth/MsgUpdateParams")

View File

@ -2,11 +2,11 @@ package vesting
import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/auth/keeper"
"cosmossdk.io/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
)
@ -38,8 +38,8 @@ func (AppModule) Name() string {
return types.ModuleName
}
// RegisterCodec registers the module's types with the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// RegisterLegacyAminoCodec registers the module's types with the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,12 +1,12 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/auth/vesting/exported"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
@ -14,13 +14,13 @@ import (
// RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the
// provided LegacyAmino codec. These types are used for Amino JSON serialization
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterInterface((*exported.VestingAccount)(nil), nil)
cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil)
cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil)
cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil)
cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil)
cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount", nil)
cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount")
cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount")
cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount")
cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount")
cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount")
legacy.RegisterAminoMsg(cdc, &MsgCreateVestingAccount{}, "cosmos-sdk/MsgCreateVestingAccount")
legacy.RegisterAminoMsg(cdc, &MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount")
legacy.RegisterAminoMsg(cdc, &MsgCreatePeriodicVestingAccount{}, "cosmos-sdk/MsgCreatePeriodVestAccount")

View File

@ -1,25 +1,25 @@
package authz
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
bank "cosmossdk.io/x/bank/types"
staking "cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgGrant{}, "cosmos-sdk/MsgGrant")
legacy.RegisterAminoMsg(cdc, &MsgRevoke{}, "cosmos-sdk/MsgRevoke")
legacy.RegisterAminoMsg(cdc, &MsgExec{}, "cosmos-sdk/MsgExec")
cdc.RegisterInterface((*Authorization)(nil), nil)
cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization", nil)
cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization")
}
// RegisterInterfaces registers the interfaces types with the interface registry

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/errors"
"cosmossdk.io/x/authz"
@ -50,7 +51,13 @@ type AppModule struct {
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak authz.AccountKeeper, bk authz.BankKeeper, registry cdctypes.InterfaceRegistry) AppModule {
func NewAppModule(
cdc codec.Codec,
keeper keeper.Keeper,
ak authz.AccountKeeper,
bk authz.BankKeeper,
registry cdctypes.InterfaceRegistry,
) AppModule {
return AppModule{
cdc: cdc,
keeper: keeper,
@ -87,7 +94,7 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
}
// RegisterLegacyAminoCodec registers the authz module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
authz.RegisterLegacyAminoCodec(cdc)
}

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/bank/client/cli"
"cosmossdk.io/x/bank/keeper"
@ -63,7 +64,7 @@ func (am AppModule) IsAppModule() {}
func (AppModule) Name() string { return types.ModuleName }
// RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,24 +1,24 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgSend{}, "cosmos-sdk/MsgSend")
legacy.RegisterAminoMsg(cdc, &MsgMultiSend{}, "cosmos-sdk/MsgMultiSend")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/bank/MsgUpdateParams")
legacy.RegisterAminoMsg(cdc, &MsgSetSendEnabled{}, "cosmos-sdk/MsgSetSendEnabled")
cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization", nil)
cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params", nil)
cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization")
cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params")
}
func RegisterInterfaces(registrar registry.InterfaceRegistrar) {

View File

@ -7,6 +7,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/consensus/keeper"
"cosmossdk.io/x/consensus/types"
@ -49,7 +50,7 @@ func (AppModule) IsAppModule() {}
func (AppModule) Name() string { return types.ModuleName }
// RegisterLegacyAminoCodec registers the consensus module's types on the LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,10 +1,10 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
@ -20,6 +20,6 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) {
// RegisterLegacyAminoCodec registers the necessary x/consensus interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/consensus/MsgUpdateParams")
}

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"github.com/cosmos/cosmos-sdk/codec"
@ -66,7 +67,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the crisis module's types on the given LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,17 +1,17 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers the necessary x/crisis interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/crisis/MsgUpdateParams")
}

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/distribution/client/cli"
"cosmossdk.io/x/distribution/keeper"
@ -75,7 +76,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the distribution module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,10 +1,10 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
@ -12,14 +12,14 @@ import (
// RegisterLegacyAminoCodec registers the necessary x/distribution interfaces
// and concrete types on the provided LegacyAmino codec. These types are used
// for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward")
legacy.RegisterAminoMsg(cdc, &MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValCommission")
legacy.RegisterAminoMsg(cdc, &MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/distribution/MsgUpdateParams")
legacy.RegisterAminoMsg(cdc, &MsgDepositValidatorRewardsPool{}, "cosmos-sdk/distr/MsgDepositValRewards")
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params", nil)
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params")
}
func RegisterInterfaces(registrar registry.InterfaceRegistrar) {

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/x/epochs/keeper"
"cosmossdk.io/x/epochs/simulation"
"cosmossdk.io/x/epochs/types"
@ -55,8 +56,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the epochs module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
}
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the epochs module.
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {

View File

@ -11,6 +11,7 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
eviclient "cosmossdk.io/x/evidence/client"
"cosmossdk.io/x/evidence/client/cli"
@ -65,7 +66,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the evidence module's types to the LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,21 +1,21 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"cosmossdk.io/x/evidence/exported"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
// evidence module.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterInterface((*exported.Evidence)(nil), nil)
legacy.RegisterAminoMsg(cdc, &MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence")
cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil)
cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation")
}
// RegisterInterfaces registers the interfaces types with the interface registry.

View File

@ -1,24 +1,24 @@
package feegrant
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers the necessary x/feegrant interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgGrantAllowance{}, "cosmos-sdk/MsgGrantAllowance")
legacy.RegisterAminoMsg(cdc, &MsgRevokeAllowance{}, "cosmos-sdk/MsgRevokeAllowance")
cdc.RegisterInterface((*FeeAllowanceI)(nil), nil)
cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance", nil)
cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance", nil)
cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance", nil)
cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance")
cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance")
cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance")
}
// RegisterInterfaces registers the interfaces types with the interface registry

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/errors"
"cosmossdk.io/x/feegrant"
@ -66,7 +67,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the feegrant module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
feegrant.RegisterLegacyAminoCodec(cdc)
}

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
govclient "cosmossdk.io/x/gov/client"
"cosmossdk.io/x/gov/client/cli"
@ -79,7 +80,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the gov module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
v1beta1.RegisterLegacyAminoCodec(cdc)
v1.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,17 +1,17 @@
package v1
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
// governance module.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/v1/MsgSubmitProposal")
legacy.RegisterAminoMsg(cdc, &MsgSubmitMultipleChoiceProposal{}, "gov/MsgSubmitMultipleChoiceProposal")
legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/v1/MsgDeposit")

View File

@ -1,23 +1,23 @@
package v1beta1
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
// governance module.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterInterface((*Content)(nil), nil)
legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal")
legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/MsgDeposit")
legacy.RegisterAminoMsg(cdc, &MsgVote{}, "cosmos-sdk/MsgVote")
legacy.RegisterAminoMsg(cdc, &MsgVoteWeighted{}, "cosmos-sdk/MsgVoteWeighted")
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal")
}
// RegisterInterfaces registers the interfaces types with the Interface Registry.

View File

@ -1,10 +1,10 @@
package group
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
codectypes "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
@ -12,10 +12,10 @@ import (
// RegisterLegacyAminoCodec registers all the necessary group module concrete
// types and interfaces with the provided codec reference.
// These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codectypes.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterInterface((*DecisionPolicy)(nil), nil)
cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy", nil)
cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy", nil)
cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy")
cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy")
legacy.RegisterAminoMsg(cdc, &MsgCreateGroup{}, "cosmos-sdk/MsgCreateGroup")
legacy.RegisterAminoMsg(cdc, &MsgUpdateGroupMembers{}, "cosmos-sdk/MsgUpdateGroupMembers")

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/group"
"cosmossdk.io/x/group/client/cli"
@ -88,7 +89,7 @@ func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) {
}
// RegisterLegacyAminoCodec registers the group module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
group.RegisterLegacyAminoCodec(cdc)
}

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/mint/keeper"
"cosmossdk.io/x/mint/simulation"
@ -77,7 +78,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,17 +1,17 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil)
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/mint/MsgUpdateParams")
}

View File

@ -34,7 +34,7 @@ type s struct {
func createTestCodec() *codec.LegacyAmino {
cdc := codec.NewLegacyAmino()
sdk.RegisterLegacyAminoCodec(cdc)
cdc.RegisterConcrete(s{}, "test/s", nil)
cdc.RegisterConcrete(invalid{}, "test/invalid", nil)
cdc.RegisterConcrete(s{}, "test/s")
cdc.RegisterConcrete(invalid{}, "test/invalid")
return cdc
}

View File

@ -7,12 +7,12 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/params/keeper"
"cosmossdk.io/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
@ -52,7 +52,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
proposal.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,15 +1,14 @@
package proposal
import (
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
govtypes "cosmossdk.io/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/codec"
)
// RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil)
func RegisterLegacyAminoCodec(cdc legacy.Amino) {
cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal")
}
func RegisterInterfaces(registrar registry.InterfaceRegistrar) {

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/protocolpool/keeper"
"cosmossdk.io/x/protocolpool/types"
@ -60,7 +61,7 @@ func (AppModule) IsAppModule() {}
func (AppModule) Name() string { return types.ModuleName }
// RegisterLegacyAminoCodec registers the pool module's types on the LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {

View File

@ -35,7 +35,6 @@ type ModuleInputs struct {
Config *modulev1.Module
Environment appmodule.Environment
Cdc codec.Codec
LegacyAmino *codec.LegacyAmino
Registry cdctypes.InterfaceRegistry
CometService comet.Service
@ -64,7 +63,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
panic(fmt.Errorf("unable to decode authority in slashing: %w", err))
}
k := keeper.NewKeeper(in.Environment, in.Cdc, in.LegacyAmino, in.StakingKeeper, authStr)
k := keeper.NewKeeper(in.Environment, in.Cdc, nil, in.StakingKeeper, authStr)
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.Registry, in.CometService)
return ModuleOutputs{
Keeper: k,

View File

@ -20,7 +20,8 @@ import (
type Keeper struct {
appmodule.Environment
cdc codec.BinaryCodec
cdc codec.BinaryCodec
// deprecated!
legacyAmino *codec.LegacyAmino
sk types.StakingKeeper

View File

@ -10,6 +10,7 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/slashing/keeper"
"cosmossdk.io/x/slashing/simulation"
@ -81,7 +82,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the slashing module's types for the given codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,17 +1,17 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params", nil)
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params")
legacy.RegisterAminoMsg(cdc, &MsgUnjail{}, "cosmos-sdk/MsgUnjail")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/slashing/MsgUpdateParams")
}

View File

@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/depinject"
"cosmossdk.io/x/staking/client/cli"
@ -76,7 +77,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the staking module's types on the given LegacyAmino codec.
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,17 +1,17 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
legacy.RegisterAminoMsg(cdc, &MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator")
legacy.RegisterAminoMsg(cdc, &MsgEditValidator{}, "cosmos-sdk/MsgEditValidator")
legacy.RegisterAminoMsg(cdc, &MsgDelegate{}, "cosmos-sdk/MsgDelegate")
@ -22,10 +22,10 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgRotateConsPubKey{}, "cosmos-sdk/MsgRotateConsPubKey")
cdc.RegisterInterface((*isStakeAuthorization_Validators)(nil), nil)
cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList", nil)
cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList", nil)
cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization", nil)
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params", nil)
cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList")
cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList")
cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization")
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params")
}
// RegisterInterfaces registers the x/staking interfaces types with the interface registry

View File

@ -10,20 +10,16 @@ import (
"google.golang.org/grpc"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/upgrade/client/cli"
"cosmossdk.io/x/upgrade/keeper"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
)
func init() {
types.RegisterLegacyAminoCodec(codec.NewLegacyAmino())
}
// ConsensusVersion defines the current x/upgrade module consensus version.
const ConsensusVersion uint64 = 3
@ -61,7 +57,7 @@ func (AppModule) Name() string {
}
// RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {
types.RegisterLegacyAminoCodec(cdc)
}

View File

@ -1,19 +1,19 @@
package types
import (
corelegacy "cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil)
cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil)
cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil)
func RegisterLegacyAminoCodec(cdc corelegacy.Amino) {
cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan")
cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal")
cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal")
legacy.RegisterAminoMsg(cdc, &MsgSoftwareUpgrade{}, "cosmos-sdk/MsgSoftwareUpgrade")
legacy.RegisterAminoMsg(cdc, &MsgCancelUpgrade{}, "cosmos-sdk/MsgCancelUpgrade")
}