/
codec.go
39 lines (33 loc) · 1.19 KB
/
codec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package types
import (
"github.com/evoblockchain/evochain/libs/cosmos-sdk/codec"
"github.com/evoblockchain/evochain/libs/cosmos-sdk/x/auth/exported"
"github.com/tendermint/go-amino"
)
// ModuleCdc auth module wide codec
var ModuleCdc = codec.New()
// RegisterCodec registers concrete types on the codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterInterface((*exported.GenesisAccount)(nil), nil)
cdc.RegisterInterface((*exported.Account)(nil), nil)
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil)
cdc.RegisterConcrete(&StdTx{}, "cosmos-sdk/StdTx", nil)
cdc.RegisterConcreteUnmarshaller("cosmos-sdk/StdTx", func(c *amino.Codec, bytes []byte) (interface{}, int, error) {
var tx StdTx
err := tx.UnmarshalFromAmino(c, bytes)
if err != nil {
return nil, 0, err
}
return &tx, len(bytes), nil
})
cdc.RegisterConcrete(&ProtobufViewMsg{}, "evoblockchain/ProtobufMsgWrapper", nil)
}
// RegisterAccountTypeCodec registers an external account type defined in
// another module for the internal ModuleCdc.
func RegisterAccountTypeCodec(o interface{}, name string) {
ModuleCdc.RegisterConcrete(o, name, nil)
}
func init() {
RegisterCodec(ModuleCdc)
codec.RegisterCrypto(ModuleCdc)
}