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 ¶
- Variables
- func Array(r *result.Invoke, err error) ([]stackitem.Item, error)
- func ArrayAndSessionIterator(r *result.Invoke, err error) ([]stackitem.Item, uuid.UUID, result.Iterator, error)
- func ArrayOfBigInts(r *result.Invoke, err error) ([]*big.Int, error)
- func ArrayOfBools(r *result.Invoke, err error) ([]bool, error)
- func ArrayOfBytes(r *result.Invoke, err error) ([][]byte, error)
- func ArrayOfPublicKeys(r *result.Invoke, err error) (keys.PublicKeys, error)
- func ArrayOfUTF8Strings(r *result.Invoke, err error) ([]string, error)
- func ArrayOfUint160(r *result.Invoke, err error) ([]util.Uint160, error)
- func ArrayOfUint256(r *result.Invoke, err error) ([]util.Uint256, error)
- func BigInt(r *result.Invoke, err error) (*big.Int, error)
- func Bool(r *result.Invoke, err error) (bool, error)
- func Bytes(r *result.Invoke, err error) ([]byte, error)
- func Int64(r *result.Invoke, err error) (int64, error)
- func Item(r *result.Invoke, err error) (stackitem.Item, error)
- func LimitedInt64(r *result.Invoke, err error, min int64, max int64) (int64, error)
- func Map(r *result.Invoke, err error) (*stackitem.Map, error)
- func Nothing(r *result.Invoke, err error) error
- func PrintableASCIIString(r *result.Invoke, err error) (string, error)
- func PublicKey(r *result.Invoke, err error) (*keys.PublicKey, error)
- func SessionIterator(r *result.Invoke, err error) (uuid.UUID, result.Iterator, error)
- func UTF8String(r *result.Invoke, err error) (string, error)
- func Uint160(r *result.Invoke, err error) (util.Uint160, error)
- func Uint256(r *result.Invoke, err error) (util.Uint256, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ArrayAndSessionIterator ¶ added in v0.105.0
func ArrayAndSessionIterator(r *result.Invoke, err error) ([]stackitem.Item, uuid.UUID, result.Iterator, error)
ArrayAndSessionIterator expects correct execution (HALT state) with one or two stack items returned. If there is 1 item, it must be an array. If there is a second item, it must be an iterator. This is exactly the result of smartcontract.CreateCallAndPrefetchIteratorScript. Sessions must be enabled on the RPC server for this to function correctly.
func ArrayOfBigInts ¶ added in v0.99.6
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
ArrayOfBools checks the result for correct state (HALT) and then extracts a slice of boolean values from the returned stack item.
func ArrayOfBytes ¶
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
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
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
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
ArrayOfUint256 checks the result for correct state (HALT) and then extracts a slice of util.Uint256 from the returned stack item.
func BigInt ¶
BigInt expects correct execution (HALT state) with a single stack item returned. A big.Int is extracted from this item and returned.
func Bool ¶
Bool expects correct execution (HALT state) with a single stack item returned. A bool is extracted from this item and returned.
func Bytes ¶
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 ¶
Int64 expects correct execution (HALT state) with a single stack item returned. An int64 is extracted from this item and returned.
func Item ¶
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 ¶
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 ¶
Map expects correct execution (HALT state) with a single stack item returned. A stackitem.Map is extracted from this item and returned.
func Nothing ¶ added in v0.102.0
Nothing expects zero stack items and a successful invocation (HALT state).
func PrintableASCIIString ¶
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
PublicKey expects correct execution (HALT state) with a single stack item returned. A public key is extracted from this item and returned.
func SessionIterator ¶
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 ¶
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.
Types ¶
This section is empty.