github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/app/crypto/ethsecp256k1/codec.go (about)

     1  package ethsecp256k1
     2  
     3  import (
     4  	cryptoamino "github.com/fibonacci-chain/fbc/libs/tendermint/crypto/encoding/amino"
     5  
     6  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
     7  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/crypto/keys"
     8  )
     9  
    10  // CryptoCodec is the default amino codec used by ethermint
    11  var CryptoCodec = codec.New()
    12  
    13  func init() {
    14  	// replace the keyring codec with the ethermint crypto codec to prevent
    15  	// amino panics because of unregistered Priv/PubKey
    16  	keys.CryptoCdc = CryptoCodec
    17  	keys.RegisterCodec(CryptoCodec)
    18  	cryptoamino.RegisterAmino(CryptoCodec)
    19  	RegisterCodec(CryptoCodec)
    20  }
    21  
    22  // RegisterCodec registers all the necessary types with amino for the given
    23  // codec.
    24  func RegisterCodec(cdc *codec.Codec) {
    25  	cdc.RegisterConcrete(PubKey{}, PubKeyName, nil)
    26  	cdc.RegisterConcrete(PrivKey{}, PrivKeyName, nil)
    27  }