2019-06-05 16:26:17 -07:00
|
|
|
package types
|
2018-09-13 11:17:32 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-05-20 12:21:00 -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"
|
2018-09-13 11:17:32 -07:00
|
|
|
)
|
|
|
|
|
2020-02-18 04:50:13 -08:00
|
|
|
// RegisterCodec registers the account interfaces and concrete types on the
|
|
|
|
// provided Amino codec.
|
2018-09-13 11:17:32 -07:00
|
|
|
func RegisterCodec(cdc *codec.Codec) {
|
2020-05-20 12:21:00 -07:00
|
|
|
cdc.RegisterInterface((*ModuleAccountI)(nil), nil)
|
|
|
|
cdc.RegisterInterface((*GenesisAccount)(nil), nil)
|
|
|
|
cdc.RegisterInterface((*AccountI)(nil), nil)
|
|
|
|
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil)
|
2020-04-20 12:32:10 -07:00
|
|
|
cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil)
|
2019-06-28 13:11:27 -07:00
|
|
|
cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil)
|
2019-02-08 13:35:19 -08:00
|
|
|
}
|
|
|
|
|
2020-05-20 12:21:00 -07:00
|
|
|
// RegisterInterface associates protoName with AccountI interface
|
|
|
|
// and creates a registry of it's concrete implementations
|
|
|
|
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
|
|
|
registry.RegisterInterface(
|
|
|
|
"cosmos_sdk.auth.v1.AccountI",
|
|
|
|
(*AccountI)(nil),
|
|
|
|
&BaseAccount{},
|
|
|
|
&ModuleAccount{},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-03-30 15:09:28 -07:00
|
|
|
// RegisterKeyTypeCodec registers an external concrete type defined in
|
|
|
|
// another module for the internal ModuleCdc.
|
|
|
|
func RegisterKeyTypeCodec(o interface{}, name string) {
|
|
|
|
amino.RegisterConcrete(o, name, nil)
|
|
|
|
}
|
|
|
|
|
2020-02-18 04:50:13 -08:00
|
|
|
var (
|
|
|
|
amino = codec.New()
|
2020-05-20 12:21:00 -07:00
|
|
|
|
|
|
|
ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry())
|
2020-02-18 04:50:13 -08:00
|
|
|
)
|
2018-09-13 11:17:32 -07:00
|
|
|
|
|
|
|
func init() {
|
2020-02-18 04:50:13 -08:00
|
|
|
RegisterCodec(amino)
|
2020-06-04 03:38:24 -07:00
|
|
|
cryptocodec.RegisterCrypto(amino)
|
2018-09-13 11:17:32 -07:00
|
|
|
}
|