invoker

package
v0.99.3-pre Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 5 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Invoker

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

Invoker allows to test-execute things using RPC client. Its API simplifies reusing the same signers list for a series of invocations and at the same time uses regular Go types for call parameters. It doesn't do anything with the result of invocation, that's left for upper (contract) layer to deal with. Invoker does not produce any transactions and does not change the state of the chain.

func New

func New(client RPCInvoke, signers []transaction.Signer) *Invoker

New creates an Invoker to test-execute things at the current blockchain height.

func NewHistoricAtBlock

func NewHistoricAtBlock(block util.Uint256, client RPCInvokeHistoric, signers []transaction.Signer) *Invoker

NewHistoricAtBlock creates an Invoker to test-execute things at some given block.

func NewHistoricAtHeight

func NewHistoricAtHeight(height uint32, client RPCInvokeHistoric, signers []transaction.Signer) *Invoker

NewHistoricAtHeight creates an Invoker to test-execute things at some given height.

func NewHistoricWithState

func NewHistoricWithState(root util.Uint256, client RPCInvokeHistoric, signers []transaction.Signer) *Invoker

NewHistoricWithState creates an Invoker to test-execute things with some given state.

func (*Invoker) Call

func (v *Invoker) Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)

Call invokes a method of the contract with the given parameters (and Invoker-specific list of signers) and returns the result as is.

func (*Invoker) CallAndExpandIterator

func (v *Invoker) CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...interface{}) (*result.Invoke, error)

CallAndExpandIterator creates a script containing a call of the specified method of a contract with given parameters (similar to how Call operates). But then this script contains additional code that expects that the result of the first call is an iterator. This iterator is traversed extracting values from it and adding them into an array until maxItems is reached or iterator has no more elements. The result of the whole script is an array containing up to maxResultItems elements from the iterator returned from the contract's method call. This script is executed using regular JSON-API (according to the way Iterator is set up).

func (*Invoker) Run

func (v *Invoker) Run(script []byte) (*result.Invoke, error)

Run executes given bytecode with Invoker-specific list of signers.

func (*Invoker) Verify

func (v *Invoker) Verify(contract util.Uint160, witnesses []transaction.Witness, params ...interface{}) (*result.Invoke, error)

Verify invokes contract's verify method in the verification context with Invoker-specific signers and given witnesses and parameters.

type RPCInvoke

type RPCInvoke interface {
	InvokeContractVerify(contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error)
	InvokeFunction(contract util.Uint160, operation string, params []smartcontract.Parameter, signers []transaction.Signer) (*result.Invoke, error)
	InvokeScript(script []byte, signers []transaction.Signer) (*result.Invoke, error)
}

RPCInvoke is a set of RPC methods needed to execute things at the current blockchain height.

type RPCInvokeHistoric

type RPCInvokeHistoric interface {
	InvokeContractVerifyAtBlock(blockHash util.Uint256, contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error)
	InvokeContractVerifyAtHeight(height uint32, contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error)
	InvokeContractVerifyWithState(stateroot util.Uint256, contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error)
	InvokeFunctionAtBlock(blockHash util.Uint256, contract util.Uint160, operation string, params []smartcontract.Parameter, signers []transaction.Signer) (*result.Invoke, error)
	InvokeFunctionAtHeight(height uint32, contract util.Uint160, operation string, params []smartcontract.Parameter, signers []transaction.Signer) (*result.Invoke, error)
	InvokeFunctionWithState(stateroot util.Uint256, contract util.Uint160, operation string, params []smartcontract.Parameter, signers []transaction.Signer) (*result.Invoke, error)
	InvokeScriptAtBlock(blockHash util.Uint256, script []byte, signers []transaction.Signer) (*result.Invoke, error)
	InvokeScriptAtHeight(height uint32, script []byte, signers []transaction.Signer) (*result.Invoke, error)
	InvokeScriptWithState(stateroot util.Uint256, script []byte, signers []transaction.Signer) (*result.Invoke, error)
}

RPCInvokeHistoric is a set of RPC methods needed to execute things at some fixed point in blockchain's life.

Jump to

Keyboard shortcuts

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