unwrap

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 11 Imported by: 33

Documentation

Overview

Package unwrap provides a set of proxy methods to process invocation results.

Functions implemented there are intended to be used as wrappers for other functions that return (*result.Invoke, error) pair (of which there are many). These functions will check for error, check for VM state, check the number of results, cast them to appropriate type (if everything is OK) and then return a result or error. They're mostly useful for other higher-level contract-specific packages.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSessionID = errors.New("server returned iterator ID, but no session ID")

ErrNoSessionID is returned from the SessionIterator when the server does not have sessions enabled and does not perform automatic iterator expansion. It means you have no way to get the data from returned iterators using this server, other than expanding it in the VM script.

Functions

func Array

func Array(r *result.Invoke, err error) ([]stackitem.Item, error)

Array expects correct execution (HALT state) with a single array stack item returned. This item is returned to the caller. Notice that this function can be used for structures as well since they're also represented as slices of stack items (the number of them and their types are structure-specific).

func ArrayOfBigInts added in v0.99.6

func ArrayOfBigInts(r *result.Invoke, err error) ([]*big.Int, error)

ArrayOfBigInts checks the result for correct state (HALT) and then extracts a slice of (big) integer values from the returned stack item.

func ArrayOfBools added in v0.99.6

func ArrayOfBools(r *result.Invoke, err error) ([]bool, error)

ArrayOfBools checks the result for correct state (HALT) and then extracts a slice of boolean values from the returned stack item.

func ArrayOfBytes

func ArrayOfBytes(r *result.Invoke, err error) ([][]byte, error)

ArrayOfBytes checks the result for correct state (HALT) and then extracts a slice of byte slices from the returned stack item.

func ArrayOfPublicKeys added in v0.99.3

func ArrayOfPublicKeys(r *result.Invoke, err error) (keys.PublicKeys, error)

ArrayOfPublicKeys checks the result for correct state (HALT) and then extracts a slice of public keys from the returned stack item.

func ArrayOfUTF8Strings added in v0.99.6

func ArrayOfUTF8Strings(r *result.Invoke, err error) ([]string, error)

ArrayOfUTB8Strings checks the result for correct state (HALT) and then extracts a slice of UTF-8 strings from the returned stack item.

func ArrayOfUint160 added in v0.99.3

func ArrayOfUint160(r *result.Invoke, err error) ([]util.Uint160, error)

ArrayOfUint160 checks the result for correct state (HALT) and then extracts a slice of util.Uint160 from the returned stack item.

func ArrayOfUint256 added in v0.99.6

func ArrayOfUint256(r *result.Invoke, err error) ([]util.Uint256, error)

ArrayOfUint256 checks the result for correct state (HALT) and then extracts a slice of util.Uint256 from the returned stack item.

func BigInt

func BigInt(r *result.Invoke, err error) (*big.Int, error)

BigInt expects correct execution (HALT state) with a single stack item returned. A big.Int is extracted from this item and returned.

func Bool

func Bool(r *result.Invoke, err error) (bool, error)

Bool expects correct execution (HALT state) with a single stack item returned. A bool is extracted from this item and returned.

func Bytes

func Bytes(r *result.Invoke, err error) ([]byte, error)

Bytes expects correct execution (HALT state) with a single stack item returned. A slice of bytes is extracted from this item and returned.

func Int64

func Int64(r *result.Invoke, err error) (int64, error)

Int64 expects correct execution (HALT state) with a single stack item returned. An int64 is extracted from this item and returned.

func Item

func Item(r *result.Invoke, err error) (stackitem.Item, error)

Item returns a stack item from the result if execution was successful (HALT state) and if it's the only element on the result stack.

func LimitedInt64

func LimitedInt64(r *result.Invoke, err error, min int64, max int64) (int64, error)

LimitedInt64 is similar to Int64 except it allows to set minimum and maximum limits to be checked, so if it doesn't return an error the value is more than min and less than max.

func Map

func Map(r *result.Invoke, err error) (*stackitem.Map, error)

Map expects correct execution (HALT state) with a single stack item returned. A stackitem.Map is extracted from this item and returned.

func PrintableASCIIString

func PrintableASCIIString(r *result.Invoke, err error) (string, error)

PrintableASCIIString expects correct execution (HALT state) with a single stack item returned. A string is extracted from this item and checked to only contain ASCII characters in printable range, valid strings are then returned.

func PublicKey added in v0.99.5

func PublicKey(r *result.Invoke, err error) (*keys.PublicKey, error)

PublicKey expects correct execution (HALT state) with a single stack item returned. A public key is extracted from this item and returned.

func SessionIterator

func SessionIterator(r *result.Invoke, err error) (uuid.UUID, result.Iterator, error)

SessionIterator expects correct execution (HALT state) with a single stack item returned. If this item is an iterator it's returned to the caller along with the session ID. Notice that this function also returns successfully with zero session ID (but an appropriate Iterator holding all the data received) when RPC server performs (limited) iterator expansion which is the default behavior for NeoGo servers with SessionEnabled set to false.

func UTF8String

func UTF8String(r *result.Invoke, err error) (string, error)

UTF8String expects correct execution (HALT state) with a single stack item returned. A string is extracted from this item and checked for UTF-8 correctness, valid strings are then returned.

func Uint160

func Uint160(r *result.Invoke, err error) (util.Uint160, error)

Uint160 expects correct execution (HALT state) with a single stack item returned. An util.Uint160 is extracted from this item and returned.

func Uint256

func Uint256(r *result.Invoke, err error) (util.Uint256, error)

Uint256 expects correct execution (HALT state) with a single stack item returned. An util.Uint256 is extracted from this item and returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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