unwrap

package
v0.99.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 9 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

This section is empty.

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 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 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 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.

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