Move codec.RegisterCrypto and codec.Cdc to new packages (#6330)
* Move codec.Cdc to legacy_global.Cdc * Update CHANGELOG.md * Updates * nit * Fix imports * Updates * Use cosmos multisig instead of tendermint multisig everywhere * Fix tests * Rename legacy_global -> legacy * Add doc.go * Linting, move all RegisterCrypto calls to crypto/codec * Update crypto/codec/amino.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze
parent
dcbf152ae5
commit
81d647e505
+5
-20
@@ -4,27 +4,14 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
// Cdc defines a global generic sealed Amino codec to be used throughout sdk. It
|
||||
// has all Tendermint crypto and evidence types registered.
|
||||
//
|
||||
// TODO: Consider removing this global.
|
||||
var Cdc *Codec
|
||||
|
||||
func init() {
|
||||
Cdc = New()
|
||||
RegisterCrypto(Cdc)
|
||||
RegisterEvidences(Cdc)
|
||||
Cdc.Seal()
|
||||
}
|
||||
|
||||
// deprecated: Codec defines a wrapper for an Amino codec that properly handles protobuf
|
||||
// types with Any's
|
||||
type Codec struct {
|
||||
@@ -41,12 +28,6 @@ func New() *Codec {
|
||||
return &Codec{amino.NewCodec()}
|
||||
}
|
||||
|
||||
// RegisterCrypto registers all crypto dependency types with the provided Amino
|
||||
// codec.
|
||||
func RegisterCrypto(cdc *Codec) {
|
||||
cryptoamino.RegisterAmino(cdc.Amino)
|
||||
}
|
||||
|
||||
// RegisterEvidences registers Tendermint evidence types with the provided Amino
|
||||
// codec.
|
||||
func RegisterEvidences(cdc *Codec) {
|
||||
@@ -208,3 +189,7 @@ func (cdc *Codec) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byt
|
||||
}
|
||||
return cdc.Amino.MarshalJSONIndent(o, prefix, indent)
|
||||
}
|
||||
|
||||
func (cdc *Codec) PrintTypes(out io.Writer) error {
|
||||
return cdc.Amino.PrintTypes(out)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package legacy
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
)
|
||||
|
||||
// Deprecated: Cdc defines a global generic sealed Amino codec to be used throughout sdk. It
|
||||
// has all Tendermint crypto and evidence types registered.
|
||||
//
|
||||
// TODO: remove this global.
|
||||
var Cdc *codec.Codec
|
||||
|
||||
func init() {
|
||||
Cdc = codec.New()
|
||||
cryptocodec.RegisterCrypto(Cdc)
|
||||
codec.RegisterEvidences(Cdc)
|
||||
Cdc.Seal()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Package legacy contains a global amino Cdc which is deprecated but
|
||||
// still used in several places within the SDK. This package is intended
|
||||
// to be removed at some point in the future when the global Cdc is removed.
|
||||
package legacy
|
||||
Reference in New Issue
Block a user