2018-08-09 01:06:34 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2018-10-24 14:49:37 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-04-22 19:26:01 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
2018-08-09 01:06:34 +00:00
|
|
|
)
|
|
|
|
|
2019-11-13 17:00:21 +00:00
|
|
|
const (
|
|
|
|
// Amino encoding name
|
2020-04-22 19:26:01 +00:00
|
|
|
EthermintAccountName = "ethermint/EthAccount"
|
2019-11-13 17:00:21 +00:00
|
|
|
)
|
|
|
|
|
2020-04-22 19:26:01 +00:00
|
|
|
// Codec defines the interface needed to serialize x/auth state. It must be
|
|
|
|
// aware of all concrete account types.
|
|
|
|
type Codec interface {
|
|
|
|
codec.Marshaler
|
|
|
|
|
|
|
|
MarshalAccount(acc exported.Account) ([]byte, error)
|
|
|
|
UnmarshalAccount(bz []byte) (exported.Account, error)
|
|
|
|
|
|
|
|
MarshalAccountJSON(acc exported.Account) ([]byte, error)
|
|
|
|
UnmarshalAccountJSON(bz []byte) (exported.Account, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterCodec registers the account interfaces and concrete types on the
|
|
|
|
// provided Amino codec.
|
2018-10-24 14:49:37 +00:00
|
|
|
func RegisterCodec(cdc *codec.Codec) {
|
2020-04-22 19:26:01 +00:00
|
|
|
cdc.RegisterConcrete(&EthAccount{}, EthermintAccountName, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
amino = codec.New()
|
|
|
|
|
|
|
|
// ModuleCdc references the global x/auth module codec. Note, the codec should
|
|
|
|
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
|
|
|
|
// still used for that purpose.
|
|
|
|
//
|
|
|
|
// The actual codec used for serialization should be provided to x/auth and
|
|
|
|
// defined at the application level.
|
|
|
|
ModuleCdc = codec.NewHybridCodec(amino)
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RegisterCodec(amino)
|
|
|
|
codec.RegisterCrypto(amino)
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|