client

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package client implements "spacesvm" client SDK.

Index

Constants

This section is empty.

Variables

View Source
var ErrIntegrityFailure = errors.New("received file that does not match hash")

Functions

func PPActivity

func PPActivity(a []*chain.Activity) error

func PPInfo

func PPInfo(info *chain.SpaceInfo)

func SignIssueRawTx

func SignIssueRawTx(
	ctx context.Context,
	cli Client,
	utx chain.UnsignedTransaction,
	priv *ecdsa.PrivateKey,
	opts ...OpOption,
) (txID ids.ID, cost uint64, err error)

Signs and issues the transaction (local construction).

func SignIssueTx

func SignIssueTx(
	ctx context.Context,
	cli Client,
	input *chain.Input,
	priv *ecdsa.PrivateKey,
	opts ...OpOption,
) (txID ids.ID, cost uint64, err error)

Signs and issues the transaction (node construction).

Types

type Client

type Client interface {
	// Pings the VM.
	Ping(ctx context.Context) (bool, error)
	// Network information about this instance of the VM
	Network(ctx context.Context) (uint32, ids.ID, ids.ID, error)

	// Returns the VM genesis.
	Genesis(ctx context.Context) (*chain.Genesis, error)
	// Accepted fetches the ID of the last accepted block.
	Accepted(ctx context.Context) (ids.ID, error)

	// Returns if a space is already claimed
	Claimed(ctx context.Context, space string) (bool, error)
	// Returns the corresponding space information.
	Info(ctx context.Context, space string) (*chain.SpaceInfo, []*chain.KeyValueMeta, error)
	// Balance returns the balance of an account
	Balance(ctx context.Context, addr common.Address) (bal uint64, err error)
	// Resolve returns the value associated with a path
	Resolve(ctx context.Context, path string) (exists bool, value []byte, valueMeta *chain.ValueMeta, err error)

	// Requests the suggested price and cost from VM.
	SuggestedRawFee(ctx context.Context) (uint64, uint64, error)
	// Issues the transaction and returns the transaction ID.
	IssueRawTx(ctx context.Context, d []byte) (ids.ID, error)

	// Requests the suggested price and cost from VM, returns the input as
	// TypedData.
	SuggestedFee(ctx context.Context, i *chain.Input) (*tdata.TypedData, uint64, error)
	// Issues a human-readable transaction and returns the transaction ID.
	IssueTx(ctx context.Context, td *tdata.TypedData, sig []byte) (ids.ID, error)

	// Checks the status of the transaction, and returns "true" if confirmed.
	HasTx(ctx context.Context, id ids.ID) (bool, error)
	// Polls the transactions until its status is confirmed.
	PollTx(ctx context.Context, txID ids.ID) (confirmed bool, err error)

	// Recent actions on the network (sorted from recent to oldest)
	RecentActivity(ctx context.Context) ([]*chain.Activity, error)
	// All spaces owned by a given address
	Owned(ctx context.Context, owner common.Address) ([]string, error)
}

Client defines spacesvm client operations.

func New

func New(uri string, reqTimeout time.Duration) Client

New creates a new client object.

type Op

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

type OpOption

type OpOption func(*Op)

func WithBalance

func WithBalance() OpOption

func WithInfo

func WithInfo(space string) OpOption

Non-empty to print out space information.

func WithPollTx

func WithPollTx() OpOption

"true" to poll transaction for its confirmation.

Jump to

Keyboard shortcuts

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