tokens

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllAccounts uint64 = 0
)

Variables

View Source
var (
	ErrNoFeeCredit           = errors.New("no fee credit in token wallet")
	ErrInsufficientFeeCredit = errors.New("insufficient fee credit balance for transaction(s)")
)

Functions

func BearerPredicateFromPubKey added in v0.1.4

func BearerPredicateFromPubKey(receiverPubKey wallet.PubKey) wallet.Predicate

func DecodeHexOrEmpty added in v0.2.0

func DecodeHexOrEmpty(input string) ([]byte, error)

func FeeCreditRecordIDFromPublicKey added in v0.2.0

func FeeCreditRecordIDFromPublicKey(shardPart, pubKey []byte) types.UnitID

func ParsePredicateClause added in v0.1.3

func ParsePredicateClause(clause string, keyNr uint64, am account.Manager) ([]byte, error)

Types

type AttrWithInvariantPredicateInputs

type AttrWithInvariantPredicateInputs interface {
	types.SigBytesProvider
	SetInvariantPredicateSignatures([][]byte)
}

type AttrWithSubTypeCreationInputs

type AttrWithSubTypeCreationInputs interface {
	types.SigBytesProvider
	SetSubTypeCreationPredicateSignatures([][]byte)
}

type CreateFungibleTokenTypeAttributes added in v0.1.4

type CreateFungibleTokenTypeAttributes struct {
	Symbol                   string
	Name                     string
	Icon                     *Icon
	DecimalPlaces            uint32
	ParentTypeId             twb.TokenTypeID
	SubTypeCreationPredicate wallet.Predicate
	TokenCreationPredicate   wallet.Predicate
	InvariantPredicate       wallet.Predicate
}

type CreateNonFungibleTokenTypeAttributes added in v0.1.4

type CreateNonFungibleTokenTypeAttributes struct {
	Symbol                   string
	Name                     string
	Icon                     *Icon
	ParentTypeId             twb.TokenTypeID
	SubTypeCreationPredicate wallet.Predicate
	TokenCreationPredicate   wallet.Predicate
	InvariantPredicate       wallet.Predicate
	DataUpdatePredicate      wallet.Predicate
}

type Icon added in v0.2.0

type Icon struct {
	Type string
	Data []byte
}

type MintAttr

type MintAttr interface {
	types.SigBytesProvider
	SetBearer([]byte)
	SetTokenCreationPredicateSignatures([][]byte)
}

type MintNonFungibleTokenAttributes added in v0.1.4

type MintNonFungibleTokenAttributes struct {
	Name                string
	NftType             twb.TokenTypeID
	Uri                 string
	Data                []byte
	Bearer              wallet.Predicate
	DataUpdatePredicate wallet.Predicate
}

type MoneyDataProvider added in v0.2.0

type MoneyDataProvider interface {
	SystemID() []byte
	fees.TxPublisher
}

type PredicateInput

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

func ParsePredicates added in v0.1.3

func ParsePredicates(arguments []string, keyNr uint64, am account.Manager) ([]*PredicateInput, error)

type SubmissionResult added in v0.2.0

type SubmissionResult struct {
	TokenTypeID   backend.TokenTypeID
	TokenID       backend.TokenID
	AccountNumber uint64
	FeeSum        uint64
}

type TokenBackend added in v0.1.3

type TokenBackend interface {
	GetToken(ctx context.Context, id backend.TokenID) (*backend.TokenUnit, error)
	GetTokens(ctx context.Context, kind backend.Kind, owner wallet.PubKey, offset string, limit int) ([]*backend.TokenUnit, string, error)
	GetTokenTypes(ctx context.Context, kind backend.Kind, creator wallet.PubKey, offset string, limit int) ([]*backend.TokenUnitType, string, error)
	GetTypeHierarchy(ctx context.Context, id backend.TokenTypeID) ([]*backend.TokenUnitType, error)
	GetRoundNumber(ctx context.Context) (uint64, error)
	PostTransactions(ctx context.Context, pubKey wallet.PubKey, txs *wallet.Transactions) error
	GetTxProof(ctx context.Context, unitID types.UnitID, txHash wallet.TxHash) (*wallet.Proof, error)
	GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*wallet.Bill, error)
}

type TxPublisher added in v0.2.0

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

func NewTxPublisher added in v0.2.0

func NewTxPublisher(backendClient *client.TokenBackend) *TxPublisher

func (*TxPublisher) Close added in v0.2.0

func (w *TxPublisher) Close()

func (*TxPublisher) SendTx added in v0.2.0

func (w *TxPublisher) SendTx(ctx context.Context, tx *types.TransactionOrder, senderPubKey []byte) (*wallet.Proof, error)

SendTx sends tx and waits for confirmation, returns tx proof

type Wallet

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

func New added in v0.1.3

func New(systemID []byte, backendUrl string, am account.Manager, confirmTx bool, feeManager *fees.FeeManager) (*Wallet, error)

func (*Wallet) AddFeeCredit added in v0.2.0

func (w *Wallet) AddFeeCredit(ctx context.Context, cmd fees.AddFeeCmd) (*fees.AddFeeCmdResponse, error)

func (*Wallet) CollectDust added in v0.2.0

func (w *Wallet) CollectDust(ctx context.Context, accountNumber uint64, allowedTokenTypes []twb.TokenTypeID, invariantPredicateArgs []*PredicateInput) ([]*SubmissionResult, error)

func (*Wallet) GetAccountManager

func (w *Wallet) GetAccountManager() account.Manager

func (*Wallet) GetFeeCredit added in v0.2.0

func (w *Wallet) GetFeeCredit(ctx context.Context, cmd fees.GetFeeCreditCmd) (*wallet.Bill, error)

GetFeeCredit returns fee credit bill for given account, can return nil if fee credit bill has not been created yet.

func (*Wallet) GetFeeCreditBill added in v0.2.0

func (w *Wallet) GetFeeCreditBill(ctx context.Context, unitID []byte) (*wallet.Bill, error)

GetFeeCreditBill returns fee credit bill for given unitID can return nil if fee credit bill has not been created yet.

func (*Wallet) GetRoundNumber added in v0.2.0

func (w *Wallet) GetRoundNumber(ctx context.Context) (uint64, error)

func (*Wallet) GetToken added in v0.1.3

func (w *Wallet) GetToken(ctx context.Context, owner wallet.PubKey, kind backend.Kind, tokenId backend.TokenID) (*backend.TokenUnit, error)

func (*Wallet) GetTokenType

func (w *Wallet) GetTokenType(ctx context.Context, typeId backend.TokenTypeID) (*backend.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, accountNumber uint64, kind backend.Kind) ([]*backend.TokenUnitType, error)

func (*Wallet) ListTokens

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

ListTokens specify accountNumber=0 to list tokens from all accounts

func (*Wallet) NewFungibleToken

func (w *Wallet) NewFungibleToken(ctx context.Context, accNr uint64, typeId backend.TokenTypeID, amount uint64, bearerPredicate wallet.Predicate, mintPredicateArgs []*PredicateInput) (*SubmissionResult, error)

func (*Wallet) NewFungibleType

func (w *Wallet) NewFungibleType(ctx context.Context, accNr uint64, attrs CreateFungibleTokenTypeAttributes, typeId backend.TokenTypeID, subtypePredicateArgs []*PredicateInput) (*SubmissionResult, error)

func (*Wallet) NewNFT

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

func (*Wallet) NewNonFungibleType

func (w *Wallet) NewNonFungibleType(ctx context.Context, accNr uint64, attrs CreateNonFungibleTokenTypeAttributes, typeId backend.TokenTypeID, subtypePredicateArgs []*PredicateInput) (*SubmissionResult, error)

func (*Wallet) ReclaimFeeCredit added in v0.2.0

func (w *Wallet) ReclaimFeeCredit(ctx context.Context, cmd fees.ReclaimFeeCmd) (*fees.ReclaimFeeCmdResponse, error)

func (*Wallet) SendFungible

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

func (*Wallet) Shutdown

func (w *Wallet) Shutdown()

func (*Wallet) TransferNFT

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

func (*Wallet) UpdateNFTData

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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