2020-03-05 06:32:43 -08:00
|
|
|
package std
|
2020-02-18 04:50:13 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-05-05 07:28:20 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
2020-06-04 03:38:24 -07:00
|
|
|
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
2020-02-18 04:50:13 -08:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Codec defines the application-level codec. This codec contains all the
|
|
|
|
// required module-specific codecs that are to be provided upon initialization.
|
|
|
|
type Codec struct {
|
|
|
|
codec.Marshaler
|
|
|
|
|
|
|
|
// Keep reference to the amino codec to allow backwards compatibility along
|
|
|
|
// with type, and interface registration.
|
|
|
|
amino *codec.Codec
|
2020-05-05 07:28:20 -07:00
|
|
|
|
|
|
|
anyUnpacker types.AnyUnpacker
|
2020-02-18 04:50:13 -08:00
|
|
|
}
|
|
|
|
|
2020-05-05 07:28:20 -07:00
|
|
|
func NewAppCodec(amino *codec.Codec, anyUnpacker types.AnyUnpacker) *Codec {
|
|
|
|
return &Codec{Marshaler: codec.NewHybridCodec(amino, anyUnpacker), amino: amino, anyUnpacker: anyUnpacker}
|
2020-02-18 04:50:13 -08:00
|
|
|
}
|
|
|
|
|
2020-02-24 08:05:21 -08:00
|
|
|
// ----------------------------------------------------------------------------
|
2020-02-18 04:50:13 -08:00
|
|
|
// necessary types and interfaces registered. This codec is provided to all the
|
|
|
|
// modules the application depends on.
|
|
|
|
//
|
|
|
|
// NOTE: This codec will be deprecated in favor of AppCodec once all modules are
|
|
|
|
// migrated.
|
|
|
|
func MakeCodec(bm module.BasicManager) *codec.Codec {
|
|
|
|
cdc := codec.New()
|
|
|
|
|
|
|
|
bm.RegisterCodec(cdc)
|
|
|
|
vesting.RegisterCodec(cdc)
|
|
|
|
sdk.RegisterCodec(cdc)
|
2020-06-04 03:38:24 -07:00
|
|
|
cryptocodec.RegisterCrypto(cdc)
|
2020-02-18 04:50:13 -08:00
|
|
|
|
|
|
|
return cdc
|
|
|
|
}
|
2020-05-20 12:21:00 -07:00
|
|
|
|
|
|
|
// RegisterInterfaces registers Interfaces from sdk/types and vesting
|
|
|
|
func RegisterInterfaces(interfaceRegistry types.InterfaceRegistry) {
|
|
|
|
sdk.RegisterInterfaces(interfaceRegistry)
|
|
|
|
vesting.RegisterInterfaces(interfaceRegistry)
|
|
|
|
}
|