-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nft type generation and message update (now complete to upgrade whole…
… process of cosmos sdk 0.42.x base version)
- Loading branch information
Showing
14 changed files
with
4,735 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.