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:
Aaron Craelius
2020-06-04 10:38:24 +00:00
committed by GitHub
co-authored by Federico Kunze
parent dcbf152ae5
commit 81d647e505
62 changed files with 216 additions and 133 deletions
+5 -20
View File
@@ -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)
}
+19
View File
@@ -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()
}
+4
View File
@@ -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