tokens

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: AGPL-3.0, ISC Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllAccounts int = -1

	FungibleTokenType    = TokenType | Fungible
	NonFungibleTokenType = TokenType | NonFungible
	FungibleToken        = Token | Fungible
	NonFungibleToken     = Token | NonFungible
)

Variables

View Source
var (
	ErrInvalidBlockSystemID = goerrors.New("invalid system identifier")
	ErrAttributesMissing    = goerrors.New("attributes missing")
	ErrInvalidURILength     = fmt.Errorf("URI exceeds the maximum allowed size of %v bytes", uriMaxSize)
	ErrInvalidDataLength    = fmt.Errorf("data exceeds the maximum allowed size of %v bytes", dataMaxSize)
)

Functions

This section is empty.

Types

type AttrWithInvariantPredicateInputs

type AttrWithInvariantPredicateInputs interface {
	proto.Message
	SetInvariantPredicateSignatures([][]byte)
}

type AttrWithSubTypeCreationInputs

type AttrWithSubTypeCreationInputs interface {
	proto.Message
	SetSubTypeCreationPredicateSignatures([][]byte)
}

type BlockListener

type BlockListener func(b *block.Block) error

func (BlockListener) ProcessBlock

func (l BlockListener) ProcessBlock(b *block.Block) error

type Db

type Db interface {
	Do() TokenTxContext
	WithTransaction(func(tx TokenTxContext) error) error
	Close()
	DeleteDb()
}

type MintAttr

type MintAttr interface {
	proto.Message
	SetBearer([]byte)
	SetTokenCreationPredicateSignatures([][]byte)
}

type PredicateInput

type PredicateInput struct {
	// first priority
	Argument tokens.Predicate
	// if Argument empty, check AccountNumber
	AccountNumber uint64
}

type Proof

type Proof struct {
	BlockNumber uint64                `json:"blockNumber"`
	Tx          *txsystem.Transaction `json:"tx"`
	Proof       *block.BlockProof     `json:"proof"`
}

type PublicKey

type PublicKey []byte

type TokenID

type TokenID []byte

func RandomID

func RandomID() (TokenID, error)

func (TokenID) String

func (id TokenID) String() string

type TokenKind

type TokenKind uint
const (
	Any TokenKind = 1 << iota
	TokenType
	Token
	Fungible
	NonFungible
)

TokenKind enum Only insert new values to the end of the enum NB! remember to update stringer method

func (TokenKind) String

func (k TokenKind) String() string

type TokenTxContext

type TokenTxContext interface {
	GetBlockNumber() (uint64, error)
	SetBlockNumber(blockNumber uint64) error

	AddTokenType(token *TokenUnitType) error
	GetTokenType(typeId TokenTypeID) (*TokenUnitType, error)
	GetTokenTypes() ([]*TokenUnitType, error)
	// SetToken accountNumber == 0 is the one for "always true" predicates
	// keys with accountIndex from the money wallet have tokens here under accountNumber which is accountIndex+1
	SetToken(accountNumber uint64, token *TokenUnit) error
	RemoveToken(accountNumber uint64, id TokenID) error
	GetToken(accountNumber uint64, tokenId TokenID) (*TokenUnit, error)
	GetTokens(accountNumber uint64) ([]*TokenUnit, error)
}

type TokenTypeID

type TokenTypeID []byte

type TokenTypeInfo

type TokenTypeInfo interface {
	GetSymbol() string
	GetTypeId() TokenTypeID
}

type TokenUnit

type TokenUnit struct {
	ID       TokenID     `json:"id"`
	Kind     TokenKind   `json:"kind"`
	Symbol   string      `json:"symbol"`
	TypeID   TokenTypeID `json:"typeId"`
	Amount   uint64      `json:"amount"`        // fungible only
	URI      string      `json:"uri,omitempty"` // nft only
	Backlink []byte      `json:"backlink"`
	Proof    *Proof      `json:"proof"`
}

func (*TokenUnit) GetSymbol

func (t *TokenUnit) GetSymbol() string

func (*TokenUnit) GetTypeId

func (t *TokenUnit) GetTypeId() TokenTypeID

func (*TokenUnit) IsFungible

func (t *TokenUnit) IsFungible() bool

type TokenUnitType

type TokenUnitType struct {
	ID            TokenTypeID `json:"id"`
	ParentTypeID  TokenTypeID `json:"typeId"`
	Kind          TokenKind   `json:"kind"`
	Symbol        string      `json:"symbol"`
	DecimalPlaces uint32      `json:"decimalPlaces"`
	Proof         *Proof      `json:"proof"`
}

func (*TokenUnitType) GetSymbol

func (tp *TokenUnitType) GetSymbol() string

func (*TokenUnitType) GetTypeId

func (tp *TokenUnitType) GetTypeId() TokenTypeID

type TokenWithOwner

type TokenWithOwner struct {
	Token *TokenUnit
	Owner PublicKey
}

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func Load

func Load(mw *money.Wallet, sync bool) (*Wallet, error)

func (*Wallet) GetAccountManager

func (w *Wallet) GetAccountManager() wallet.AccountManager

func (*Wallet) GetTokenType

func (w *Wallet) GetTokenType(ctx context.Context, typeId TokenTypeID) (*TokenUnitType, error)

GetTokenType returns non-nil TokenUnitType or error if not found or other issues

func (*Wallet) ListTokenTypes

func (w *Wallet) ListTokenTypes(ctx context.Context, kind TokenKind) ([]*TokenUnitType, error)

func (*Wallet) ListTokens

func (w *Wallet) ListTokens(ctx context.Context, kind TokenKind, accountNumber int) (map[uint64][]*TokenUnit, error)

ListTokens specify accountNumber=-1 to list tokens from all accounts

func (*Wallet) NewFungibleToken

func (w *Wallet) NewFungibleToken(ctx context.Context, accNr uint64, attrs *tokens.MintFungibleTokenAttributes, mintPredicateArgs []*PredicateInput) (TokenID, error)

func (*Wallet) NewFungibleType

func (w *Wallet) NewFungibleType(ctx context.Context, attrs *tokens.CreateFungibleTokenTypeAttributes, typeId TokenTypeID, subtypePredicateArgs []*PredicateInput) (TokenID, error)

func (*Wallet) NewNFT

func (w *Wallet) NewNFT(ctx context.Context, accNr uint64, attrs *tokens.MintNonFungibleTokenAttributes, tokenId TokenID, mintPredicateArgs []*PredicateInput) (TokenID, error)

func (*Wallet) NewNonFungibleType

func (w *Wallet) NewNonFungibleType(ctx context.Context, attrs *tokens.CreateNonFungibleTokenTypeAttributes, typeId TokenTypeID, subtypePredicateArgs []*PredicateInput) (TokenID, error)

func (*Wallet) ProcessBlock

func (w *Wallet) ProcessBlock(b *block.Block) error

func (*Wallet) SendFungible

func (w *Wallet) SendFungible(ctx context.Context, accountNumber uint64, typeId TokenTypeID, targetAmount uint64, receiverPubKey []byte, invariantPredicateArgs []*PredicateInput) error

func (*Wallet) Shutdown

func (w *Wallet) Shutdown()

func (*Wallet) Sync

func (w *Wallet) Sync(ctx context.Context) error

func (*Wallet) TransferNFT

func (w *Wallet) TransferNFT(ctx context.Context, accountNumber uint64, tokenId TokenID, receiverPubKey PublicKey, invariantPredicateArgs []*PredicateInput) error

func (*Wallet) UpdateNFTData

func (w *Wallet) UpdateNFTData(ctx context.Context, accountNumber uint64, tokenId []byte, data []byte, updatePredicateArgs []*PredicateInput) error

Jump to

Keyboard shortcuts

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