client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 17 Imported by: 22

Documentation

Index

Constants

View Source
const RoundLatest = coreClient.RoundLatest

RoundLatest is a special round number always referring to the latest round.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockEvents added in v0.2.0

type BlockEvents struct {
	// Round is the round of the block.
	Round uint64

	// Events are the decoded events.
	Events []DecodedEvent
}

BlockEvents are the events emitted in a block.

type CheckTxError added in v0.2.0

type CheckTxError struct {
	Module  string
	Code    uint32
	Message string
}

CheckTxError describes an error that happened during transaction check.

type DecodedEvent added in v0.2.0

type DecodedEvent interface{}

DecodedEvent is a decoded event.

type EventDecoder added in v0.2.0

type EventDecoder interface {
	// DecodeEvent decodes an event. In case the event is not relevant, `nil, nil` should be returned.
	DecodeEvent(*types.Event) ([]DecodedEvent, error)
}

EventDecoder is an event decoder interface.

type RuntimeClient

type RuntimeClient interface {
	// GetInfo returns information about the runtime.
	GetInfo(ctx context.Context) (*types.RuntimeInfo, error)

	// SubmitTxRaw submits a transaction to the runtime transaction scheduler and waits
	// for transaction execution results.
	SubmitTxRaw(ctx context.Context, tx *types.UnverifiedTransaction) (*types.CallResult, error)

	// SubmitTxRawMeta submits a transaction to the runtime transaction scheduler and waits
	// for transaction execution results.
	//
	// Response includes transaction metadata - e.g. round at which the transaction was included
	// in a block.
	SubmitTxRawMeta(ctx context.Context, tx *types.UnverifiedTransaction) (*SubmitTxRawMeta, error)

	// SubmitTx submits a transaction to the runtime transaction scheduler and waits
	// for transaction execution results.
	//
	// If there is a possibility that the result is Unknown then the caller must use SubmitTxRaw
	// instead as this method will return an error.
	SubmitTx(ctx context.Context, tx *types.UnverifiedTransaction) (cbor.RawMessage, error)

	// SubmitTx submits a transaction to the runtime transaction scheduler and waits
	// for transaction execution results.
	//
	// If there is a possibility that the result is Unknown then the caller must use SubmitTxRaw
	// instead as this method will return an error.
	//
	// Response includes transaction metadata - e.g. round at which the transaction was included
	// in a block.
	SubmitTxMeta(ctx context.Context, tx *types.UnverifiedTransaction) (*SubmitTxMeta, error)

	// SubmitTxNoWait submits a transaction to the runtime transaction scheduler but does
	// not wait for transaction execution.
	SubmitTxNoWait(ctx context.Context, tx *types.UnverifiedTransaction) error

	// GetGenesisBlock returns the genesis block.
	GetGenesisBlock(ctx context.Context) (*block.Block, error)

	// GetBlock fetches the given runtime block.
	GetBlock(ctx context.Context, round uint64) (*block.Block, error)

	// GetLastRetainedBlock returns the last retained block.
	GetLastRetainedBlock(ctx context.Context) (*block.Block, error)

	// GetTransactions returns all transactions that are part of a given block.
	GetTransactions(ctx context.Context, round uint64) ([]*types.UnverifiedTransaction, error)

	// GetTransactionsWithResults returns all transactions that are part of a given block together
	// with their results and emitted events.
	GetTransactionsWithResults(ctx context.Context, round uint64) ([]*TransactionWithResults, error)

	// GetEventsRaw returns all events emitted in a given block.
	GetEventsRaw(ctx context.Context, round uint64) ([]*types.Event, error)

	// GetEvents returns and decodes events emitted in a given block with the provided decoders.
	GetEvents(ctx context.Context, round uint64, decoders []EventDecoder, includeUndecoded bool) ([]DecodedEvent, error)

	// WatchBlocks subscribes to blocks for a specific runtimes.
	WatchBlocks(ctx context.Context) (<-chan *roothash.AnnotatedBlock, pubsub.ClosableSubscription, error)

	// WatchEvents subscribes and decodes runtime events.
	WatchEvents(ctx context.Context, decoders []EventDecoder, includeUndecoded bool) (<-chan *BlockEvents, error)

	// Query makes a runtime-specific query.
	Query(ctx context.Context, round uint64, method string, args, rsp interface{}) error
}

RuntimeClient is a client interface for runtimes based on the Oasis Runtime SDK.

func New

func New(conn *grpc.ClientConn, runtimeID common.Namespace) RuntimeClient

New creates a new runtime client for the specified runtime.

type SubmitTxMeta added in v0.2.0

type SubmitTxMeta struct {
	TransactionMeta

	// Result is the call result.
	Result cbor.RawMessage
}

SubmitTxMeta is the result of SubmitTxMeta call.

type SubmitTxRawMeta added in v0.2.0

type SubmitTxRawMeta struct {
	TransactionMeta

	// Result is the call result.
	Result types.CallResult
}

SubmitTxRawMeta is the result of SubmitTxRawMeta call.

type TransactionBuilder

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

TransactionBuilder is a helper for building and submitting transactions.

func NewTransactionBuilder

func NewTransactionBuilder(rc RuntimeClient, method string, body interface{}) *TransactionBuilder

NewTransactionBuilder creates a new transaction builder.

func (*TransactionBuilder) AppendAuthMultisig

func (tb *TransactionBuilder) AppendAuthMultisig(config *types.MultisigConfig, nonce uint64) *TransactionBuilder

AppendAuthMultisig appends a new transaction signer information with a multisig address specification to the transaction.

func (*TransactionBuilder) AppendAuthSignature

func (tb *TransactionBuilder) AppendAuthSignature(spec types.SignatureAddressSpec, nonce uint64) *TransactionBuilder

AppendAuthSignature appends a new transaction signer information with a signature address specification to the transaction.

func (*TransactionBuilder) AppendSign

func (tb *TransactionBuilder) AppendSign(ctx context.Context, signer signature.Signer) error

AppendSign signs the transaction and appends the signature.

The signer must be specified in the AuthInfo.

func (*TransactionBuilder) GetTransaction

func (tb *TransactionBuilder) GetTransaction() *types.Transaction

GetTransaction returns the underlying unsigned transaction.

func (*TransactionBuilder) SetCallFormat added in v0.2.0

func (tb *TransactionBuilder) SetCallFormat(ctx context.Context, format types.CallFormat) error

SetCallFormat changes the transaction's call format.

Depending on the call format this operation my require queries into the runtime in order to retrieve the required parameters.

This method can only be called as long as the current call format is CallFormatPlain and will fail otherwise.

func (*TransactionBuilder) SetFeeAmount

func (tb *TransactionBuilder) SetFeeAmount(amount types.BaseUnits) *TransactionBuilder

SetFeeAmount configures the fee amount to be paid by the caller.

func (*TransactionBuilder) SetFeeConsensusMessages added in v0.2.0

func (tb *TransactionBuilder) SetFeeConsensusMessages(consensusMessages uint32) *TransactionBuilder

SetFeeConsensusMessages configures the maximum number of consensus messages that can be emitted by the transaction.

func (*TransactionBuilder) SetFeeGas

func (tb *TransactionBuilder) SetFeeGas(gas uint64) *TransactionBuilder

SetFeeGas configures the maximum gas amount that can be used by the transaction.

func (*TransactionBuilder) SubmitTx

func (tb *TransactionBuilder) SubmitTx(ctx context.Context, rsp interface{}) error

SubmitTx submits a transaction to the runtime transaction scheduler and waits for transaction execution results.

func (*TransactionBuilder) SubmitTxMeta added in v0.2.0

func (tb *TransactionBuilder) SubmitTxMeta(ctx context.Context, rsp interface{}) (*TransactionMeta, error)

SubmitTxMeta submits a transaction to the runtime transaction scheduler and waits for transaction execution results.

Response includes transaction metadata - e.g. round at which the transaction was included in a block.

func (*TransactionBuilder) SubmitTxNoWait

func (tb *TransactionBuilder) SubmitTxNoWait(ctx context.Context) error

SubmitTxNoWait submits a transaction to the runtime transaction scheduler but does not wait for transaction execution.

type TransactionMeta added in v0.2.0

type TransactionMeta struct {
	// Round is the roothash round in which the transaction was executed.
	Round uint64
	// BatchOrder is the order of the transaction in the execution batch.
	BatchOrder uint32

	// CheckTxError is the CheckTx error in case transaction failed the transaction check.
	CheckTxError *CheckTxError
}

TransactionMeta are the metadata about transaction execution.

type TransactionWithResults added in v0.2.0

type TransactionWithResults struct {
	Tx     types.UnverifiedTransaction
	Result types.CallResult
	Events []*types.Event
}

TransactionWithResults is an SDK transaction together with its results and emitted events.

Jump to

Keyboard shortcuts

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