types

package
v0.0.0-...-ab1d363 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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
)
View Source
const (
	DefaultParamspace = ModuleName
)

Default Parameters namespace

View Source
const (
	ItemPrefix = "item-"
)

ItemPrefix

View Source
const QueryDenom = "denom"
View Source
const QueryGetItem = "get-item"
View Source
const QueryListItem = "list-item"

Query parameters

View Source
const QueryOwner = "owner"
View Source
const QuerySupply = "supply"

Variables

View Source
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

View Source
var (
	CollectionsKeyPrefix = []byte{0x00} // key for Item Collection
	OwnersKeyPrefix      = []byte{0x01}
)

KeyPrefix for query

View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

Functions

func FindUtil

func FindUtil(group Findable, el string) int

FindUtil is a binary search funcion for types that support the Findable interface (elements must be sorted)

func GetCollectionKey

func GetCollectionKey(denom string) []byte

GetCollectionKey gets the key of a collection

func GetOwnerKey

func GetOwnerKey(address sdk.AccAddress) []byte

GetOwnerKey returns owner address as a key

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for affondra module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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

type Findable interface {
	ElAtIndex(index int) string
	Len() int
}

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

func (item Item) GetAffiliate() sdk.Coin

GetAffiliate returns affiliate reward

func (Item) GetDenom

func (item Item) GetDenom() string

GetDenom returns item denom

func (Item) GetDescription

func (item Item) GetDescription() string

GetDescription returns item description

func (Item) GetID

func (item Item) GetID() string

GetID returns item id

func (Item) GetInSale

func (item Item) GetInSale() bool

GetInSale returns item is in sale or not

func (Item) GetNftid

func (item Item) GetNftid() string

GetNftid returns item nft id

func (Item) GetOwner

func (item Item) GetOwner() sdk.AccAddress

GetOwner returns creator address

func (Item) GetPrice

func (item Item) GetPrice() sdk.Coin

GetPrice returns item price

func (Item) GetReceiver

func (item Item) GetReceiver() sdk.AccAddress

GetReceiver returns receiver address

func (Item) GetTokenURI

func (item Item) GetTokenURI() string

GetTokenURI returns item token uri

func (*Item) SetDescription

func (item *Item) SetDescription(desc string)

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

func (*Item) SetTokenURI

func (item *Item) SetTokenURI(tokenURI string)

SetTokenURI set item URI

func (Item) String

func (item Item) String() string

type ItemJSON

type ItemJSON map[string]Item

ItemJSON is the exported Item format for clients

type Items

type Items []Item

Items define a list of Item

func NewItems

func NewItems(items ...Item) Items

NewItems is a constructor function for Items

func (Items) Append

func (items Items) Append(itemsB ...Item) Items

Append appends two set of Items

func (Items) ElAtIndex

func (items Items) ElAtIndex(index int) string

ElAtIndex is Findable and Sort interface

func (Items) Empty

func (items Items) Empty() bool

Empty returns true if there are no items and false otherwise.

func (Items) Find

func (items Items) Find(id string) (item Item, found bool)

Find returns searched item from the set

func (Items) Len

func (items Items) Len() int

func (Items) Less

func (items Items) Less(i, j int) bool

func (Items) MarshalJSON

func (items Items) MarshalJSON() ([]byte, error)

MarshalJSON for Items

func (Items) Remove

func (items Items) Remove(id string) (Items, bool)

Remove removes an Item from the set of Items

func (Items) Sort

func (items Items) Sort() Items

Sort is a helper function to sort the set of coins in place

func (Items) String

func (items Items) String() string

String follows stringer interface

func (Items) Swap

func (items Items) Swap(i, j int)

func (*Items) UnmarshalJSON

func (items *Items) UnmarshalJSON(b []byte) error

UnmarshalJSON for Items

func (Items) Update

func (items Items) Update(id string, item Item) (Items, bool)

Update removes and replaces an item from the set

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) Route

func (msg MsgBuyItem) Route() string

Route Implements Msg

func (MsgBuyItem) Type

func (msg MsgBuyItem) Type() string

Type 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) Route

func (msg MsgCreateItem) Route() string

Route Implements Msg

func (MsgCreateItem) Type

func (msg MsgCreateItem) Type() string

Type 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) Route

func (msg MsgDeleteItem) Route() string

Route Implements Msg

func (MsgDeleteItem) Type

func (msg MsgDeleteItem) Type() string

Type 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) Route

func (msg MsgSetItem) Route() string

Route Implements Msg

func (MsgSetItem) Type

func (msg MsgSetItem) Type() string

Type 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) AddItem

func (owner Owner) AddItem(item Item) (Owner, error)

AddItem adds an Item to the owner

func (Owner) ContainsItem

func (owner Owner) ContainsItem(id string) bool

ContainsItem returns whether or not a owner contains an Item

func (Owner) DeleteItem

func (owner Owner) DeleteItem(item Item) (Owner, error)

DeleteItem deletes an Item from a owner

func (Owner) GetItem

func (owner Owner) GetItem(id string) (item Item, err error)

GetItem gets a Item from the owner

func (Owner) String

func (owner Owner) String() string

func (Owner) Supply

func (owner Owner) Supply() int

Supply return total item

func (Owner) UpdateItem

func (owner Owner) UpdateItem(item Item) (Owner, error)

UpdateItem updates 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 NewParams

func NewParams() Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs - Implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL