Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 745 Bytes

Codec.md

File metadata and controls

29 lines (21 loc) · 745 Bytes

Codec

Once we have defined our messages, we need to describe to our encoder how they should be stored as bytes. To do this we edit the file located at ./nfts/internals/types/codec.go. By describing our types as follows they will work with our encoding library:

package types

import (
    "github.com/cosmos/cosmos-sdk/codec"
    "github.com/cosmos/cosmos-sdk/codec/types"
)

func RegisterCodec(cdc *codec.Codec) {
    cdc.RegisterConcrete(MsgMintTweetNFT{}, "nft/MsgMintTweetNFT", nil)
    cdc.RegisterConcrete(BaseTweetNFT{}, "nft/BaseTweetNFT", nil)
}

var (
    amino     = codec.New()
    ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry())
)

func init() {
    RegisterCodec(amino)
    amino.Seal()
}