Skip to content

Commit

Permalink
nft type generation and message update (now complete to upgrade whole…
Browse files Browse the repository at this point in the history
… process of cosmos sdk 0.42.x base version)
  • Loading branch information
fly33499 committed Aug 30, 2021
1 parent 5c7efda commit 27e928a
Show file tree
Hide file tree
Showing 14 changed files with 4,735 additions and 0 deletions.
34 changes: 34 additions & 0 deletions x/nft/types/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package types

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

func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgTransfer{}, "nft/Transfer", nil)
cdc.RegisterConcrete(&MsgBurn{}, "nft/Burn", nil)
cdc.RegisterConcrete(&MsgMint{}, "nft/Mint", nil)

}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgTransfer{},
)
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgBurn{},
)
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgMint{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)
12 changes: 12 additions & 0 deletions x/nft/types/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package types

// DONTCOVER

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

// x/nft module sentinel errors
var (
ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error")
)
1 change: 1 addition & 0 deletions x/nft/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package types
31 changes: 31 additions & 0 deletions x/nft/types/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package types

import (
"fmt"
)

// DefaultIndex is the default capability global index
const DefaultIndex uint64 = 1

// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
NftItemList: []*NftItem{},
}
}

// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
// Check for duplicated ID in nftItem
nftItemIdMap := make(map[uint64]bool)

for _, elem := range gs.NftItemList {
if _, ok := nftItemIdMap[elem.Id]; ok {
return fmt.Errorf("duplicated id for nftItem")
}
nftItemIdMap[elem.Id] = true
}

return nil
}
Loading

0 comments on commit 27e928a

Please sign in to comment.