Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 1007 Bytes

File metadata and controls

25 lines (18 loc) · 1007 Bytes

Codec File

To register your types with Amino so that they can be encoded/decoded, there is a bit of code that needs to be placed in ./x/nameservice/types/codec.go. Any interface you create and any struct that implements an interface needs to be declared in the RegisterCodec function. In this module the two Msg implementations (SetName and BuyName) need to be registered, but your Whois query return type does not. In addition, we define a module specific codec for use later.

package types

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

var ModuleCdc = codec.New()

func init() {
	RegisterCodec(ModuleCdc)
}

// RegisterCodec registers concrete types on the Amino codec
func RegisterCodec(cdc *codec.Codec) {
	cdc.RegisterConcrete(MsgSetName{}, "nameservice/SetName", nil)
	cdc.RegisterConcrete(MsgBuyName{}, "nameservice/BuyName", nil)
}

Next you need to define CLI interactions with your module.