refactor(core): move amino registrar and drop legacy package (backport #21531) (#21561)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot]
2024-09-05 13:04:00 +00:00
committed by GitHub
co-authored by Julien Robert
parent a6f0b642d8
commit 68ec945293
104 changed files with 306 additions and 346 deletions
+6 -6
View File
@@ -10,7 +10,7 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
"github.com/tendermint/go-amino"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"github.com/cosmos/cosmos-sdk/codec/types"
)
@@ -25,7 +25,7 @@ func (cdc *LegacyAmino) Seal() {
cdc.Amino.Seal()
}
var _ legacy.Amino = &LegacyAmino{}
var _ registry.AminoRegistrar = &LegacyAmino{}
func NewLegacyAmino() *LegacyAmino {
return &LegacyAmino{amino.NewCodec()}
@@ -33,9 +33,9 @@ func NewLegacyAmino() *LegacyAmino {
// RegisterEvidences registers CometBFT evidence types with the provided Amino
// codec.
func RegisterEvidences(cdc legacy.Amino) {
cdc.RegisterInterface((*cmttypes.Evidence)(nil), nil)
cdc.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence")
func RegisterEvidences(registrar registry.AminoRegistrar) {
registrar.RegisterInterface((*cmttypes.Evidence)(nil), nil)
registrar.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence")
}
// MarshalJSONIndent provides a utility for indented JSON encoding of an object
@@ -179,7 +179,7 @@ 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 *legacy.InterfaceOptions) {
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *registry.AminoInterfaceOptions) {
if iopts == nil {
cdc.Amino.RegisterInterface(ptr, nil)
} else {
+1 -2
View File
@@ -8,7 +8,6 @@ import (
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
"cosmossdk.io/depinject"
"cosmossdk.io/x/tx/signing"
@@ -45,7 +44,7 @@ func ProvideInterfaceRegistry(
return interfaceRegistry, interfaceRegistry, nil
}
func ProvideLegacyAmino() legacy.Amino {
func ProvideLegacyAmino() registry.AminoRegistrar {
return NewLegacyAmino()
}
+3 -3
View File
@@ -3,7 +3,7 @@ package legacy
import (
"fmt"
"cosmossdk.io/core/legacy"
"cosmossdk.io/core/registry"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -11,9 +11,9 @@ import (
// 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 legacy.Amino, msg sdk.Msg, msgName string) {
func RegisterAminoMsg(registrar registry.AminoRegistrar, 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)
registrar.RegisterConcrete(msg, msgName)
}