client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRequest is returned when backend responded with 4nn status code, use errors.Is to check for it.
	ErrInvalidRequest = errors.New("invalid request")
	// ErrNotFound is returned when backend responded with 404 status code, use errors.Is to check for it.
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type TokenBackend

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

func New

func New(abAddr url.URL) *TokenBackend

New creates REST API client for token wallet backend. The "abAddr" is address of the backend, Scheme and Host fields must be assigned.

func (*TokenBackend) GetClosedFeeCredit added in v0.2.0

func (tb *TokenBackend) GetClosedFeeCredit(ctx context.Context, fcbID []byte) (*types.TransactionRecord, error)

func (*TokenBackend) GetFeeCreditBill added in v0.2.0

func (tb *TokenBackend) GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*sdk.Bill, error)

func (*TokenBackend) GetRoundNumber

func (tb *TokenBackend) GetRoundNumber(ctx context.Context) (uint64, error)

func (*TokenBackend) GetToken

func (tb *TokenBackend) GetToken(ctx context.Context, id backend.TokenID) (*backend.TokenUnit, error)

func (*TokenBackend) GetTokenTypes

func (tb *TokenBackend) GetTokenTypes(ctx context.Context, kind backend.Kind, creator sdk.PubKey, offset string, limit int) ([]*backend.TokenUnitType, string, error)

GetTokenTypes returns token types of particular kind (may be Any, ie all kinds), the optional "creator" parameter allows to further filter the types by it's creator public key. The "offsetKey" and "limit" parameters are for batched / paginated query support.

Returns:

  • token types matching the query;
  • offset for the next batch (if empty then there is no more data to query);
  • non-nil error when something failed;

func (*TokenBackend) GetTokens

func (tb *TokenBackend) GetTokens(ctx context.Context, kind backend.Kind, owner sdk.PubKey, offset string, limit int) ([]*backend.TokenUnit, string, error)

GetTokens returns tokens owned by "owner" and matching "kind" (may be Any, ie all kinds). For batched querying "offsetKey" must be set to the value returned by previous batch, empty string means "start from the beginning of the dataset". The "limit" parameter allows to set the max batch size (but smaller result set might be returned even when there is more data in the backend ie the "offsetKey" returned is not empty).

Returns:

  • tokens matching the query;
  • offset for the next batch (if empty then there is no more data to query);
  • non-nil error when something failed;

func (*TokenBackend) GetTxProof

func (tb *TokenBackend) GetTxProof(ctx context.Context, unitID types.UnitID, txHash sdk.TxHash) (*sdk.Proof, error)

func (*TokenBackend) GetTypeHierarchy

func (tb *TokenBackend) GetTypeHierarchy(ctx context.Context, id backend.TokenTypeID) ([]*backend.TokenUnitType, error)

func (*TokenBackend) PostTransactions

func (tb *TokenBackend) PostTransactions(ctx context.Context, pubKey sdk.PubKey, txs *sdk.Transactions) error

Jump to

Keyboard shortcuts

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