-
Notifications
You must be signed in to change notification settings - Fork 182
/
codec.go
47 lines (40 loc) · 1.57 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
40
41
42
43
44
45
46
47
package codec
import (
"github.com/okex/exchain/libs/cosmos-sdk/codec"
"github.com/okex/exchain/libs/cosmos-sdk/codec/types"
"github.com/okex/exchain/libs/cosmos-sdk/crypto/keys"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/cosmos-sdk/types/module"
cosmoscryptocodec "github.com/okex/exchain/libs/cosmos-sdk/x/auth/ibc-tx"
"github.com/okex/exchain/libs/cosmos-sdk/x/auth/vesting"
cryptocodec "github.com/okex/exchain/app/crypto/ethsecp256k1"
ethermint "github.com/okex/exchain/app/types"
)
// MakeCodec registers the necessary types and interfaces for an sdk.App. 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 to protobuf.
func MakeCodec(bm module.BasicManager) *codec.Codec {
cdc := codec.New()
bm.RegisterCodec(cdc)
vesting.RegisterCodec(cdc)
sdk.RegisterCodec(cdc)
cryptocodec.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
ethermint.RegisterCodec(cdc)
keys.RegisterCodec(cdc) // temporary. Used to register keyring.Info
return cdc
}
func MakeIBC(bm module.BasicManager) types.InterfaceRegistry {
interfaceReg := types.NewInterfaceRegistry()
bm.RegisterInterfaces(interfaceReg)
cosmoscryptocodec.PubKeyRegisterInterfaces(interfaceReg)
return interfaceReg
}
func MakeCodecSuit(bm module.BasicManager) (*codec.CodecProxy, types.InterfaceRegistry) {
aminoCodec := MakeCodec(bm)
interfaceReg := MakeIBC(bm)
protoCdc := codec.NewProtoCodec(interfaceReg)
return codec.NewCodecProxy(protoCdc, aminoCodec), interfaceReg
}