Documentation ¶
Index ¶
- Constants
- Variables
- func FindUtil(group Findable, el string) int
- func GetCollectionKey(denom string) []byte
- func GetOwnerKey(address sdk.AccAddress) []byte
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func SplitOwnerKey(key []byte) (sdk.AccAddress, []byte)
- func ValidateGenesis(data GenesisState) error
- type Collection
- func (collection Collection) AddItem(item Item) (Collection, error)
- func (collection Collection) ContainsItem(id string) bool
- func (collection Collection) DeleteItem(item Item) (Collection, error)
- func (collection Collection) GetItem(id string) (item Item, err error)
- func (collection Collection) String() string
- func (collection Collection) Supply() int
- func (collection Collection) UpdateItem(item Item) (Collection, error)
- type Findable
- type GenesisState
- type Item
- func (item *Item) ChangeInSaleStatus()
- func (item Item) GetAffiliate() sdk.Coin
- func (item Item) GetDenom() string
- func (item Item) GetDescription() string
- func (item Item) GetID() string
- func (item Item) GetInSale() bool
- func (item Item) GetNftid() string
- func (item Item) GetOwner() sdk.AccAddress
- func (item Item) GetPrice() sdk.Coin
- func (item Item) GetReceiver() sdk.AccAddress
- func (item Item) GetTokenURI() string
- func (item *Item) SetDescription(desc string)
- func (item *Item) SetOwner(addr sdk.AccAddress)
- func (item *Item) SetReceiver(addr sdk.AccAddress)
- func (item *Item) SetTokenURI(tokenURI string)
- func (item Item) String() string
- type ItemJSON
- type Items
- func (items Items) Append(itemsB ...Item) Items
- func (items Items) ElAtIndex(index int) string
- func (items Items) Empty() bool
- func (items Items) Find(id string) (item Item, found bool)
- func (items Items) Len() int
- func (items Items) Less(i, j int) bool
- func (items Items) MarshalJSON() ([]byte, error)
- func (items Items) Remove(id string) (Items, bool)
- func (items Items) Sort() Items
- func (items Items) String() string
- func (items Items) Swap(i, j int)
- func (items *Items) UnmarshalJSON(b []byte) error
- func (items Items) Update(id string, item Item) (Items, bool)
- type MsgBuyItem
- type MsgCreateItem
- type MsgDeleteItem
- type MsgSetItem
- type Owner
- func (owner Owner) AddItem(item Item) (Owner, error)
- func (owner Owner) ContainsItem(id string) bool
- func (owner Owner) DeleteItem(item Item) (Owner, error)
- func (owner Owner) GetItem(id string) (item Item, err error)
- func (owner Owner) String() string
- func (owner Owner) Supply() int
- func (owner Owner) UpdateItem(item Item) (Owner, error)
- type ParamSubspace
- type Params
- type QueryCollectionParams
- type QueryOwnerParams
Constants ¶
const ( // TODO: Create your event types // EventType<Action> = "action" EventTypeCreateItem = "create_item" EventTypeBuyItem = "buy_item" EventTypeChangeInSaleStatus = "change_insale_status" EventTypeSetItem = "set_item" EventTypeDeleteItem = "delete_item" // TODO: Create keys fo your events, the values will be derivided from the msg // AttributeKeyAddress = "address" AttributeKeyDenom = "denom" AttributeKeyNftId = "nft_id" AttributeKeyReceiver = "receiver" AttributeKeyID = "ID" AttributeValueCategory = ModuleName )
affondra module event types
const ( // ModuleName is the name of the module ModuleName = "affondra" // StoreKey to be used when creating the KVStore StoreKey = ModuleName // RouterKey to be used for routing msgs RouterKey = ModuleName // QuerierRoute to be used for querier msgs QuerierRoute = ModuleName )
const (
DefaultParamspace = ModuleName
)
Default Parameters namespace
const (
ItemPrefix = "item-"
)
ItemPrefix
const QueryDenom = "denom"
const QueryGetItem = "get-item"
const QueryListItem = "list-item"
Query parameters
const QueryOwner = "owner"
const QuerySupply = "supply"
Variables ¶
var ( ErrInvalidAffiliatePrice = sdkerrors.Register(ModuleName, 1, "[affondra] Affiliate should be less than Price") ErrAlreadyOnSale = sdkerrors.Register(ModuleName, 2, "[affondra] The NFT is already on Sale") ErrUnknownID = sdkerrors.Register(ModuleName, 3, "[affondra] Unknown Item collection") ErrUnknownItem = sdkerrors.Register(ModuleName, 4, "[affondra] Unknown Item collection") ErrItemAlreadyExists = sdkerrors.Register(ModuleName, 5, "[affondra] Item Already exists") ErrUnknownCollection = sdkerrors.Register(ModuleName, 6, "[affondra] Unknown Item collection") ErrOutOfSale = sdkerrors.Register(ModuleName, 7, "[affondra] The Item is not on Sale") ErrNotEnoughCoin = sdkerrors.Register(ModuleName, 8, "[affondra] Not enough coin to buy") )
x/affondra errors
var ( CollectionsKeyPrefix = []byte{0x00} // key for Item Collection OwnersKeyPrefix = []byte{0x01} )
KeyPrefix for query
var ModuleCdc *codec.Codec
ModuleCdc defines the module codec
Functions ¶
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) []byte
GetOwnerKey returns owner address as a key
func RegisterCodec ¶
RegisterCodec registers concrete types on codec
func SplitOwnerKey ¶
func SplitOwnerKey(key []byte) (sdk.AccAddress, []byte)
SplitOwnerKey returns address as a key
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the affondra genesis parameters
Types ¶
type Collection ¶
type Collection struct { Denom string `json:"denom,omitempty" yaml:"denom"` Items Items `json:"items" yaml:"items"` }
Collection is a set of items categorized by denom
func EmptyCollection ¶
func EmptyCollection() Collection
EmptyCollection returns an empty collection
func NewCollection ¶
func NewCollection(denom string, items Items) Collection
NewCollection is a constructor function for Collection
func (Collection) AddItem ¶
func (collection Collection) AddItem(item Item) (Collection, error)
AddItem adds an Item to the collection
func (Collection) ContainsItem ¶
func (collection Collection) ContainsItem(id string) bool
ContainsItem returns whether or not a Collection contains an Item
func (Collection) DeleteItem ¶
func (collection Collection) DeleteItem(item Item) (Collection, error)
DeleteItem deletes an Item from a collection
func (Collection) GetItem ¶
func (collection Collection) GetItem(id string) (item Item, err error)
GetItem gets a Item from the 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 Items of a collection
func (Collection) UpdateItem ¶
func (collection Collection) UpdateItem(item Item) (Collection, error)
UpdateItem updates an Item from a collection
type Findable ¶
Findable is an interface for iterable types that allows the FindUtil function to work
type GenesisState ¶
type GenesisState struct { }
GenesisState - all affondra state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState - default GenesisState used by Cosmos Hub
func NewGenesisState ¶
func NewGenesisState() GenesisState
NewGenesisState creates a new GenesisState object
type Item ¶
type Item struct { Creator sdk.AccAddress `json:"creator" yaml:"creator"` ID string `json:"id" yaml:"id"` Denom string `json:"denom" yaml:"denom"` NftId string `json:"nftId" yaml:"nftId"` TokenURI string `json:"token_uri" yaml:"token_uri"` Price sdk.Coin `json:"price" yaml:"price"` Affiliate sdk.Coin `json:"affiliate" yaml:"affiliate"` Receiver sdk.AccAddress `json:"receiver" yaml:"receiver"` Description string `json:"description" yaml:"description"` InSale bool `json:"inSale" yaml:"inSale"` }
Item defines item struct
func NewItem ¶
func NewItem(id string, owner sdk.AccAddress, denom string, nftId string, tokenURI string, price sdk.Coin, affiliate sdk.Coin, description string, inSale bool) Item
NewItem is a constructor function for Item
func (*Item) ChangeInSaleStatus ¶
func (item *Item) ChangeInSaleStatus()
ChangeInSaleStatus set item sale status
func (Item) GetAffiliate ¶
GetAffiliate returns affiliate reward
func (Item) GetDescription ¶
GetDescription returns item description
func (Item) GetReceiver ¶
func (item Item) GetReceiver() sdk.AccAddress
GetReceiver returns receiver address
func (*Item) SetDescription ¶
SetDescription set item description
func (*Item) SetOwner ¶
func (item *Item) SetOwner(addr sdk.AccAddress)
SetOwner set item owner address
func (*Item) SetReceiver ¶
func (item *Item) SetReceiver(addr sdk.AccAddress)
SetReceiver set item receiver
type Items ¶
type Items []Item
Items define a list of Item
func (*Items) UnmarshalJSON ¶
UnmarshalJSON for Items
type MsgBuyItem ¶
type MsgBuyItem struct { ID string `json:"id" yaml:"id"` Receiver sdk.AccAddress `json:"receiver" yaml:"receiver"` IntroducedBy sdk.AccAddress `json:"introduced_by" yaml:"introduced_by"` }
MsgBuyItem degines buy item message
func NewMsgBuyItem ¶
func NewMsgBuyItem(id string, receiver sdk.AccAddress, introducedBy sdk.AccAddress) MsgBuyItem
NewMsgBuyItem is a constructor function for MsgBuyItem
func (MsgBuyItem) GetSignBytes ¶
func (msg MsgBuyItem) GetSignBytes() []byte
GetSignBytes Implements Msg
func (MsgBuyItem) GetSigners ¶
func (msg MsgBuyItem) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgBuyItem) ValidateBasic ¶
func (msg MsgBuyItem) ValidateBasic() error
ValidateBasic Implements Msg
type MsgCreateItem ¶
type MsgCreateItem struct { ID string Creator sdk.AccAddress `json:"creator" yaml:"creator"` Denom string `json:"denom" yaml:"denom"` NftId string `json:"nftId" yaml:"nftId"` Price sdk.Coin `json:"price" yaml:"price"` Affiliate sdk.Coin `json:"affiliate" yaml:"affiliate"` Description string `json:"description" yaml:"description"` InSale bool `json:"inSale" yaml:"inSale"` }
MsgCreateItem defines create item message
func NewMsgCreateItem ¶
func NewMsgCreateItem(creator sdk.AccAddress, denom string, nftId string, price sdk.Coin, affiliate sdk.Coin, description string, inSale bool) MsgCreateItem
NewMsgCreateItem is a constructor function for MsgCreateItem
func (MsgCreateItem) GetSignBytes ¶
func (msg MsgCreateItem) GetSignBytes() []byte
GetSignBytes Implements Msg
func (MsgCreateItem) GetSigners ¶
func (msg MsgCreateItem) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgCreateItem) ValidateBasic ¶
func (msg MsgCreateItem) ValidateBasic() error
ValidateBasic Implements Msg
type MsgDeleteItem ¶
type MsgDeleteItem struct { ID string `json:"id" yaml:"id"` Creator sdk.AccAddress `json:"creator" yaml:"creator"` }
MsgDeleteItem defines delete item message
func NewMsgDeleteItem ¶
func NewMsgDeleteItem(id string, creator sdk.AccAddress) MsgDeleteItem
NewMsgDeleteItem is a constructor function for MsgDeleteItem
func (MsgDeleteItem) GetSignBytes ¶
func (msg MsgDeleteItem) GetSignBytes() []byte
GetSignBytes Implements Msg
func (MsgDeleteItem) GetSigners ¶
func (msg MsgDeleteItem) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgDeleteItem) ValidateBasic ¶
func (msg MsgDeleteItem) ValidateBasic() error
ValidateBasic Implements Msg
type MsgSetItem ¶
type MsgSetItem struct { ID string `json:"id" yaml:"id"` Creator sdk.AccAddress `json:"creator" yaml:"creator"` Denom string `json:"denom" yaml:"denom"` NftId string `json:"nftId" yaml:"nftId"` Price sdk.Coin `json:"price" yaml:"price"` Affiliate sdk.Coin `json:"affiliate" yaml:"affiliate"` Description string `json:"description" yaml:"description"` InSale bool `json:"inSale" yaml:"inSale"` }
MsgSetItem defines set item message
func NewMsgSetItem ¶
func NewMsgSetItem(creator sdk.AccAddress, id string, denom string, nftId string, price sdk.Coin, affiliate sdk.Coin, description string, inSale bool) MsgSetItem
NewMsgSetItem is a constructor function for MsgSetItem
func (MsgSetItem) GetSignBytes ¶
func (msg MsgSetItem) GetSignBytes() []byte
GetSignBytes Implements Msg
func (MsgSetItem) GetSigners ¶
func (msg MsgSetItem) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgSetItem) ValidateBasic ¶
func (msg MsgSetItem) ValidateBasic() error
ValidateBasic Implements Msg
type Owner ¶
type Owner struct { Address sdk.AccAddress `json:"address" yaml:"address"` Items Items `json:"items" yaml:"items"` }
Owner defines key(address) -> value(items) for query
func NewOwner ¶
func NewOwner(owner sdk.AccAddress, items Items) Owner
NewOwner is a constructor function for Owner
func (Owner) ContainsItem ¶
ContainsItem returns whether or not a owner contains an Item
func (Owner) DeleteItem ¶
DeleteItem deletes an Item from a owner
type ParamSubspace ¶
type ParamSubspace interface { WithKeyTable(table params.KeyTable) params.Subspace Get(ctx sdk.Context, key []byte, ptr interface{}) GetParamSet(ctx sdk.Context, ps params.ParamSet) SetParamSet(ctx sdk.Context, ps params.ParamSet) }
ParamSubspace defines the expected Subspace interfacace
type Params ¶
type Params struct { }
Params - used for initializing default parameter for affondra at genesis
func DefaultParams ¶
func DefaultParams() Params
DefaultParams defines the parameters for this module
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs - Implements params.ParamSet
type QueryCollectionParams ¶
type QueryCollectionParams struct {
Denom string
}
QueryCollectionParams defines the params for queries:
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 QueryOwnerParams ¶
type QueryOwnerParams struct {
Owner sdk.AccAddress
}