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)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Next you need to define CLI interactions with your module.