-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.go
31 lines (27 loc) · 1020 Bytes
/
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
package codec
import (
commoncodec "github.com/bianjieai/chain-parser/common-parser/codec"
"github.com/cosmos/cosmos-sdk/codec"
ctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)
// MakeEncodingConfig 初始化账户地址前缀
func MakeEncodingConfig() {
var cdc = codec.NewLegacyAmino()
cryptocodec.RegisterCrypto(cdc)
interfaceRegistry := ctypes.NewInterfaceRegistry()
moduleBasics := module.NewBasicManager(commoncodec.AppModules...)
moduleBasics.RegisterInterfaces(interfaceRegistry)
std.RegisterInterfaces(interfaceRegistry)
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)
commoncodec.Encodecfg = commoncodec.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: marshaler,
TxConfig: txCfg,
Amino: cdc,
}
}