github.com/InjectiveLabs/sdk-go@v1.53.0/chain/insurance/types/codec.go (about)

     1  package types
     2  
     3  import (
     4  	"github.com/cosmos/cosmos-sdk/codec"
     5  	"github.com/cosmos/cosmos-sdk/codec/types"
     6  	cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
     7  	sdk "github.com/cosmos/cosmos-sdk/types"
     8  	"github.com/cosmos/cosmos-sdk/types/msgservice"
     9  	authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec"
    10  )
    11  
    12  // RegisterLegacyAminoCodec registers the necessary x/insurance interfaces and concrete types
    13  // on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
    14  func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
    15  	cdc.RegisterConcrete(&MsgCreateInsuranceFund{}, "insurance/MsgCreateInsuranceFund", nil)
    16  	cdc.RegisterConcrete(&MsgUnderwrite{}, "insurance/MsgUnderwrite", nil)
    17  	cdc.RegisterConcrete(&MsgRequestRedemption{}, "insurance/MsgRequestRedemption", nil)
    18  	cdc.RegisterConcrete(&MsgUpdateParams{}, "insurance/MsgUpdateParams", nil)
    19  	cdc.RegisterConcrete(&Params{}, "insurance/Params", nil)
    20  
    21  }
    22  
    23  func RegisterInterfaces(registry types.InterfaceRegistry) {
    24  	registry.RegisterImplementations((*sdk.Msg)(nil),
    25  		&MsgCreateInsuranceFund{},
    26  		&MsgUnderwrite{},
    27  		&MsgRequestRedemption{},
    28  		&MsgUpdateParams{},
    29  	)
    30  
    31  	msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
    32  }
    33  
    34  var (
    35  	// ModuleCdc references the global x/insurance module codec. Note, the codec should
    36  	// ONLY be used in certain instances of tests and for JSON encoding as Amino is
    37  	// still used for that purpose.
    38  	//
    39  	// The actual codec used for serialization should be provided to x/insurance and
    40  	// defined at the application level.
    41  	ModuleCdc = codec.NewLegacyAmino()
    42  )
    43  
    44  func init() {
    45  	RegisterLegacyAminoCodec(ModuleCdc)
    46  	cryptocodec.RegisterCrypto(ModuleCdc)
    47  	ModuleCdc.Seal()
    48  
    49  	RegisterLegacyAminoCodec(authzcdc.Amino)
    50  }