Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTestAddrs(numAddrs int) []sdk.AccAddress
- func ErrEmptyMetadata(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidCollection(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidNFT(codespace sdk.CodespaceType) sdk.Error
- func ErrNFTAlreadyExists(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrUnknownCollection(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrUnknownNFT(codespace sdk.CodespaceType, msg string) sdk.Error
- func FindUtil(group Findable, el string) int
- func GetCollectionKey(denom string) []byte
- func GetOwnerKey(address sdk.AccAddress, denom string) []byte
- func GetOwnersKey(address sdk.AccAddress) []byte
- func RegisterCodec(cdc *codec.Codec)
- func SplitOwnerKey(key []byte) (sdk.AccAddress, []byte)
- func ValidateGenesis(data GenesisState) error
- type BaseNFT
- type CodeType
- type Collection
- func (collection Collection) AddNFT(nft exported.NFT) (Collection, sdk.Error)
- func (collection Collection) ContainsNFT(id string) bool
- func (collection Collection) DeleteNFT(nft exported.NFT) (Collection, sdk.Error)
- func (collection Collection) GetNFT(id string) (nft exported.NFT, err sdk.Error)
- func (collection Collection) String() string
- func (collection Collection) Supply() int
- func (collection Collection) UpdateNFT(nft exported.NFT) (Collection, sdk.Error)
- type CollectionJSON
- type Collections
- func (collections Collections) Append(collectionsB ...Collection) Collections
- func (collections Collections) ElAtIndex(index int) string
- func (collections Collections) Empty() bool
- func (collections Collections) Find(denom string) (Collection, bool)
- func (collections Collections) Len() int
- func (collections Collections) Less(i, j int) bool
- func (collections Collections) MarshalJSON() ([]byte, error)
- func (collections Collections) Remove(denom string) (Collections, bool)
- func (collections Collections) Sort() Collections
- func (collections Collections) String() string
- func (collections Collections) Swap(i, j int)
- func (collections *Collections) UnmarshalJSON(b []byte) error
- type Findable
- type GenesisState
- type IDCollection
- func (idCollection IDCollection) AddID(id string) IDCollection
- func (idCollection IDCollection) DeleteID(id string) (IDCollection, sdk.Error)
- func (idCollection IDCollection) Exists(id string) (exists bool)
- func (idCollection IDCollection) String() string
- func (idCollection IDCollection) Supply() int
- type IDCollections
- func (idCollections IDCollections) Append(idCollections2 ...IDCollection) IDCollections
- func (idCollections IDCollections) ElAtIndex(index int) string
- func (idCollections IDCollections) Len() int
- func (idCollections IDCollections) Less(i, j int) bool
- func (idCollections IDCollections) Sort() IDCollections
- func (idCollections IDCollections) String() string
- func (idCollections IDCollections) Swap(i, j int)
- type MsgBurnNFT
- type MsgEditNFTMetadata
- type MsgMintNFT
- type MsgTransferNFT
- type NFTJSON
- type NFTs
- func (nfts NFTs) Append(nftsB ...exported.NFT) NFTs
- func (nfts NFTs) ElAtIndex(index int) string
- func (nfts NFTs) Empty() bool
- func (nfts NFTs) Find(id string) (nft exported.NFT, found bool)
- func (nfts NFTs) Len() int
- func (nfts NFTs) Less(i, j int) bool
- func (nfts NFTs) MarshalJSON() ([]byte, error)
- func (nfts NFTs) Remove(id string) (NFTs, bool)
- func (nfts NFTs) Sort() NFTs
- func (nfts NFTs) String() string
- func (nfts NFTs) Swap(i, j int)
- func (nfts *NFTs) UnmarshalJSON(b []byte) error
- func (nfts NFTs) Update(id string, nft exported.NFT) (NFTs, bool)
- type Owner
- type QueryBalanceParams
- type QueryCollectionParams
- type QueryNFTParams
- type SortedStringArray
Constants ¶
const ( // ModuleName is the name of the module ModuleName = "nft" // StoreKey is the default store key for NFT StoreKey = ModuleName // QuerierRoute is the querier route for the NFT store. QuerierRoute = ModuleName // RouterKey is the message route for the NFT module RouterKey = ModuleName )
Variables ¶
var ( EventTypeTransfer = "transfer_nft" EventTypeEditNFTMetadata = "edit_nft_metadata" EventTypeMintNFT = "mint_nft" EventTypeBurnNFT = "burn_nft" AttributeValueCategory = ModuleName AttributeKeySender = "sender" AttributeKeyRecipient = "recipient" AttributeKeyOwner = "owner" AttributeKeyNFTID = "nft-id" AttributeKeyNFTTokenURI = "token-uri" AttributeKeyDenom = "denom" )
NFT module event types
var ( CollectionsKeyPrefix = []byte{0x00} // key for NFT collections OwnersKeyPrefix = []byte{0x01} // key for balance of NFTs held by an address )
NFTs are stored as follow:
- Colections: 0x00<denom_bytes_key> :<Collection>
- Owners: 0x01<address_bytes_key><denom_bytes_key>: <Owner>
var ModuleCdc *codec.Codec
ModuleCdc generic sealed codec to be used throughout this module
Functions ¶
func CreateTestAddrs ¶
func CreateTestAddrs(numAddrs int) []sdk.AccAddress
CreateTestAddrs creates test addresses
func ErrEmptyMetadata ¶
func ErrEmptyMetadata(codespace sdk.CodespaceType, msg string) sdk.Error
ErrEmptyMetadata is an error when metadata is empty
func ErrInvalidCollection ¶
func ErrInvalidCollection(codespace sdk.CodespaceType) sdk.Error
ErrInvalidCollection is an error
func ErrInvalidNFT ¶
func ErrInvalidNFT(codespace sdk.CodespaceType) sdk.Error
ErrInvalidNFT is an error
func ErrNFTAlreadyExists ¶
func ErrNFTAlreadyExists(codespace sdk.CodespaceType, msg string) sdk.Error
ErrNFTAlreadyExists is an error when an invalid NFT is minted
func ErrUnknownCollection ¶
func ErrUnknownCollection(codespace sdk.CodespaceType, msg string) sdk.Error
ErrUnknownCollection is an error
func ErrUnknownNFT ¶
func ErrUnknownNFT(codespace sdk.CodespaceType, msg string) sdk.Error
ErrUnknownNFT is an error
func FindUtil ¶
FindUtil is a binary search funcion for types that support the Findable interface (elements must be sorted)
func GetCollectionKey ¶
GetCollectionKey gets the key of a collection
func GetOwnerKey ¶
func GetOwnerKey(address sdk.AccAddress, denom string) []byte
GetOwnerKey gets the key of a collection owned by an account address
func GetOwnersKey ¶
func GetOwnersKey(address sdk.AccAddress) []byte
GetOwnersKey gets the key prefix for all the collections owned by an account address
func SplitOwnerKey ¶
func SplitOwnerKey(key []byte) (sdk.AccAddress, []byte)
SplitOwnerKey gets an address and denom from an owner key
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of nfts genesis data returning an error for any failed validation criteria.
Types ¶
type BaseNFT ¶
type BaseNFT struct { ID string `json:"id,omitempty" yaml:"id"` // id of the token; not exported to clients Owner sdk.AccAddress `json:"owner" yaml:"owner"` // account address that owns the NFT TokenURI string `json:"token_uri" yaml:"token_uri"` // optional extra properties available for querying }
BaseNFT non fungible token definition
func NewBaseNFT ¶
func NewBaseNFT(id string, owner sdk.AccAddress, tokenURI string) BaseNFT
NewBaseNFT creates a new NFT instance
func (*BaseNFT) EditMetadata ¶
EditMetadata edits metadata of an nft
func (BaseNFT) GetOwner ¶
func (bnft BaseNFT) GetOwner() sdk.AccAddress
GetOwner returns the account address that owns the NFT
func (BaseNFT) GetTokenURI ¶
GetTokenURI returns the path to optional extra properties
func (*BaseNFT) SetOwner ¶
func (bnft *BaseNFT) SetOwner(address sdk.AccAddress)
SetOwner updates the owner address of the NFT
type CodeType ¶
CodeType definition
const ( DefaultCodespace sdk.CodespaceType = ModuleName CodeInvalidCollection CodeType = 650 CodeUnknownCollection CodeType = 651 CodeInvalidNFT CodeType = 652 CodeUnknownNFT CodeType = 653 CodeNFTAlreadyExists CodeType = 654 CodeEmptyMetadata CodeType = 655 )
NFT error code
type Collection ¶
type Collection struct { Denom string `json:"denom,omitempty" yaml:"denom"` // name of the collection; not exported to clients NFTs NFTs `json:"nfts" yaml:"nfts"` // NFTs that belong to a collection }
Collection of non fungible tokens
func EmptyCollection ¶
func EmptyCollection() Collection
EmptyCollection returns an empty collection
func NewCollection ¶
func NewCollection(denom string, nfts NFTs) Collection
NewCollection creates a new NFT Collection
func (Collection) AddNFT ¶
func (collection Collection) AddNFT(nft exported.NFT) (Collection, sdk.Error)
AddNFT adds an NFT to the collection
func (Collection) ContainsNFT ¶
func (collection Collection) ContainsNFT(id string) bool
ContainsNFT returns whether or not a Collection contains an NFT
func (Collection) DeleteNFT ¶
func (collection Collection) DeleteNFT(nft exported.NFT) (Collection, sdk.Error)
DeleteNFT deletes an NFT from a collection
func (Collection) String ¶
func (collection Collection) String() string
String follows stringer interface
func (Collection) Supply ¶
func (collection Collection) Supply() int
Supply gets the total supply of NFTs of a collection
func (Collection) UpdateNFT ¶
func (collection Collection) UpdateNFT(nft exported.NFT) (Collection, sdk.Error)
UpdateNFT updates an NFT from a collection
type CollectionJSON ¶
type CollectionJSON map[string]Collection
CollectionJSON is the exported Collection format for clients
type Collections ¶
type Collections []Collection
Collections define an array of Collection
func NewCollections ¶
func NewCollections(collections ...Collection) Collections
NewCollections creates a new set of NFTs
func (Collections) Append ¶
func (collections Collections) Append(collectionsB ...Collection) Collections
Append appends two sets of Collections
func (Collections) ElAtIndex ¶
func (collections Collections) ElAtIndex(index int) string
func (Collections) Empty ¶
func (collections Collections) Empty() bool
Empty returns true if there are no collections and false otherwise.
func (Collections) Find ¶
func (collections Collections) Find(denom string) (Collection, bool)
Find returns the searched collection from the set
func (Collections) Len ¶
func (collections Collections) Len() int
func (Collections) Less ¶
func (collections Collections) Less(i, j int) bool
func (Collections) MarshalJSON ¶
func (collections Collections) MarshalJSON() ([]byte, error)
MarshalJSON for Collections
func (Collections) Remove ¶
func (collections Collections) Remove(denom string) (Collections, bool)
Remove removes a collection from the set of collections
func (Collections) Sort ¶
func (collections Collections) Sort() Collections
Sort is a helper function to sort the set of coins inplace
func (Collections) String ¶
func (collections Collections) String() string
String follows stringer interface
func (Collections) Swap ¶
func (collections Collections) Swap(i, j int)
func (*Collections) UnmarshalJSON ¶
func (collections *Collections) UnmarshalJSON(b []byte) error
UnmarshalJSON for Collections
type Findable ¶
Findable is an interface for iterable types that allows the FindUtil function to work
type GenesisState ¶
type GenesisState struct { Owners []Owner `json:"owners"` Collections Collections `json:"collections"` }
GenesisState is the state that must be provided at genesis.
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns a default genesis state
func NewGenesisState ¶
func NewGenesisState(owners []Owner, collections Collections) GenesisState
NewGenesisState creates a new genesis state.
type IDCollection ¶
type IDCollection struct { Denom string `json:"denom" yaml:"denom"` IDs SortedStringArray `json:"ids" yaml:"ids"` }
IDCollection defines a set of nft ids that belong to a specific collection
func NewIDCollection ¶
func NewIDCollection(denom string, ids []string) IDCollection
NewIDCollection creates a new IDCollection instance
func (IDCollection) AddID ¶
func (idCollection IDCollection) AddID(id string) IDCollection
AddID adds an ID to the idCollection
func (IDCollection) DeleteID ¶
func (idCollection IDCollection) DeleteID(id string) (IDCollection, sdk.Error)
DeleteID deletes an ID from an ID Collection
func (IDCollection) Exists ¶
func (idCollection IDCollection) Exists(id string) (exists bool)
Exists determines whether an ID is in the IDCollection
func (IDCollection) String ¶
func (idCollection IDCollection) String() string
String follows stringer interface
func (IDCollection) Supply ¶
func (idCollection IDCollection) Supply() int
Supply gets the total supply of NFTIDs of a balance
type IDCollections ¶
type IDCollections []IDCollection
IDCollections is an array of ID Collections whose sole purpose is for find
func (IDCollections) Append ¶
func (idCollections IDCollections) Append(idCollections2 ...IDCollection) IDCollections
Append appends IDCollections to IDCollections
func (IDCollections) ElAtIndex ¶
func (idCollections IDCollections) ElAtIndex(index int) string
func (IDCollections) Len ¶
func (idCollections IDCollections) Len() int
func (IDCollections) Less ¶
func (idCollections IDCollections) Less(i, j int) bool
func (IDCollections) Sort ¶
func (idCollections IDCollections) Sort() IDCollections
Sort is a helper function to sort the set of strings in place
func (IDCollections) String ¶
func (idCollections IDCollections) String() string
String follows stringer interface
func (IDCollections) Swap ¶
func (idCollections IDCollections) Swap(i, j int)
type MsgBurnNFT ¶
type MsgBurnNFT struct { Sender sdk.AccAddress ID string Denom string }
MsgBurnNFT defines a BurnNFT message
func NewMsgBurnNFT ¶
func NewMsgBurnNFT(sender sdk.AccAddress, id string, denom string) MsgBurnNFT
NewMsgBurnNFT is a constructor function for MsgBurnNFT
func (MsgBurnNFT) GetSignBytes ¶
func (msg MsgBurnNFT) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgBurnNFT) GetSigners ¶
func (msg MsgBurnNFT) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgBurnNFT) ValidateBasic ¶
func (msg MsgBurnNFT) ValidateBasic() sdk.Error
ValidateBasic Implements Msg.
type MsgEditNFTMetadata ¶
type MsgEditNFTMetadata struct { Sender sdk.AccAddress ID string Denom string TokenURI string }
MsgEditNFTMetadata edits an NFT's metadata
func NewMsgEditNFTMetadata ¶
func NewMsgEditNFTMetadata(sender sdk.AccAddress, id, denom, tokenURI string, ) MsgEditNFTMetadata
NewMsgEditNFTMetadata is a constructor function for MsgSetName
func (MsgEditNFTMetadata) GetSignBytes ¶
func (msg MsgEditNFTMetadata) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgEditNFTMetadata) GetSigners ¶
func (msg MsgEditNFTMetadata) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgEditNFTMetadata) ValidateBasic ¶
func (msg MsgEditNFTMetadata) ValidateBasic() sdk.Error
ValidateBasic Implements Msg.
type MsgMintNFT ¶
type MsgMintNFT struct { Sender sdk.AccAddress Recipient sdk.AccAddress ID string Denom string TokenURI string }
MsgMintNFT defines a MintNFT message
func NewMsgMintNFT ¶
func NewMsgMintNFT(sender, recipient sdk.AccAddress, id, denom, tokenURI string) MsgMintNFT
NewMsgMintNFT is a constructor function for MsgMintNFT
func (MsgMintNFT) GetSignBytes ¶
func (msg MsgMintNFT) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgMintNFT) GetSigners ¶
func (msg MsgMintNFT) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgMintNFT) ValidateBasic ¶
func (msg MsgMintNFT) ValidateBasic() sdk.Error
ValidateBasic Implements Msg.
type MsgTransferNFT ¶
type MsgTransferNFT struct { Sender sdk.AccAddress Recipient sdk.AccAddress Denom string ID string }
MsgTransferNFT defines a TransferNFT message
func NewMsgTransferNFT ¶
func NewMsgTransferNFT(sender, recipient sdk.AccAddress, denom, id string) MsgTransferNFT
NewMsgTransferNFT is a constructor function for MsgSetName
func (MsgTransferNFT) GetSignBytes ¶
func (msg MsgTransferNFT) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgTransferNFT) GetSigners ¶
func (msg MsgTransferNFT) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgTransferNFT) ValidateBasic ¶
func (msg MsgTransferNFT) ValidateBasic() sdk.Error
ValidateBasic Implements Msg.
type NFTs ¶
NFTs define a list of NFT
type Owner ¶
type Owner struct { Address sdk.AccAddress `json:"address" yaml:"address"` IDCollections IDCollections `json:"idCollections" yaml:"idCollections"` }
Owner of non fungible tokens
func NewOwner ¶
func NewOwner(owner sdk.AccAddress, idCollections ...IDCollection) Owner
NewOwner creates a new Owner
func (Owner) GetIDCollection ¶
func (owner Owner) GetIDCollection(denom string) (IDCollection, bool)
GetIDCollection gets the IDCollection from the owner
func (Owner) UpdateIDCollection ¶
func (owner Owner) UpdateIDCollection(idCollection IDCollection) (Owner, sdk.Error)
UpdateIDCollection updates the ID Collection of an owner
type QueryBalanceParams ¶
type QueryBalanceParams struct { Owner sdk.AccAddress Denom string // optional }
QueryBalanceParams params for query 'custom/nfts/balance'
func NewQueryBalanceParams ¶
func NewQueryBalanceParams(owner sdk.AccAddress, denom ...string) QueryBalanceParams
NewQueryBalanceParams creates a new instance of QuerySupplyParams
type QueryCollectionParams ¶
type QueryCollectionParams struct {
Denom string
}
QueryCollectionParams defines the params for queries: - 'custom/nft/supply' - 'custom/nft/collection'
func NewQueryCollectionParams ¶
func NewQueryCollectionParams(denom string) QueryCollectionParams
NewQueryCollectionParams creates a new instance of QuerySupplyParams
func (QueryCollectionParams) Bytes ¶
func (q QueryCollectionParams) Bytes() []byte
Bytes exports the Denom as bytes
type QueryNFTParams ¶
QueryNFTParams params for query 'custom/nfts/nft'
func NewQueryNFTParams ¶
func NewQueryNFTParams(denom, id string) QueryNFTParams
NewQueryNFTParams creates a new instance of QueryNFTParams
type SortedStringArray ¶
type SortedStringArray []string
SortedStringArray is an array of strings whose sole purpose is to help with find
func (SortedStringArray) ElAtIndex ¶
func (sa SortedStringArray) ElAtIndex(index int) string
func (SortedStringArray) Len ¶
func (sa SortedStringArray) Len() int
func (SortedStringArray) Less ¶
func (sa SortedStringArray) Less(i, j int) bool
func (SortedStringArray) Sort ¶
func (sa SortedStringArray) Sort() SortedStringArray
Sort is a helper function to sort the set of strings in place
func (SortedStringArray) String ¶
func (sa SortedStringArray) String() string
String is the string representation
func (SortedStringArray) Swap ¶
func (sa SortedStringArray) Swap(i, j int)