github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/app/codec/codec.go (about) 1 package codec 2 3 import ( 4 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 5 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec/types" 6 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/crypto/keys" 7 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 8 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module" 9 cosmoscryptocodec "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/ibc-tx" 10 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/vesting" 11 12 cryptocodec "github.com/fibonacci-chain/fbc/app/crypto/ethsecp256k1" 13 ethermint "github.com/fibonacci-chain/fbc/app/types" 14 ) 15 16 // MakeCodec registers the necessary types and interfaces for an sdk.App. This 17 // codec is provided to all the modules the application depends on. 18 // 19 // NOTE: This codec will be deprecated in favor of AppCodec once all modules are 20 // migrated to protobuf. 21 func MakeCodec(bm module.BasicManager) *codec.Codec { 22 cdc := codec.New() 23 24 bm.RegisterCodec(cdc) 25 vesting.RegisterCodec(cdc) 26 sdk.RegisterCodec(cdc) 27 cryptocodec.RegisterCodec(cdc) 28 codec.RegisterCrypto(cdc) 29 ethermint.RegisterCodec(cdc) 30 keys.RegisterCodec(cdc) // temporary. Used to register keyring.Info 31 32 return cdc 33 } 34 35 func MakeIBC(bm module.BasicManager) types.InterfaceRegistry { 36 interfaceReg := types.NewInterfaceRegistry() 37 bm.RegisterInterfaces(interfaceReg) 38 cosmoscryptocodec.PubKeyRegisterInterfaces(interfaceReg) 39 return interfaceReg 40 } 41 42 func MakeCodecSuit(bm module.BasicManager) (*codec.CodecProxy, types.InterfaceRegistry) { 43 aminoCodec := MakeCodec(bm) 44 interfaceReg := MakeIBC(bm) 45 protoCdc := codec.NewProtoCodec(interfaceReg) 46 return codec.NewCodecProxy(protoCdc, aminoCodec), interfaceReg 47 }