mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 03:41:45 +00:00
1237c719e3
The text must appear as the first line of a properly formatted Go // comment, and that comment must appear before but not be attached to the package clause and before any /* */ comment. Closes #3254 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
63 lines
3 KiB
Go
63 lines
3 KiB
Go
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
|
|
|
// Package nonnepxxcontractwithiterators contains RPC wrappers for Non-NEPXX contract with iterators contract.
|
|
package nonnepxxcontractwithiterators
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
|
)
|
|
|
|
// Hash contains contract hash.
|
|
var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x0}
|
|
|
|
// Invoker is used by ContractReader to call various safe methods.
|
|
type Invoker interface {
|
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
|
CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...any) (*result.Invoke, error)
|
|
TerminateSession(sessionID uuid.UUID) error
|
|
TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
|
|
}
|
|
|
|
// ContractReader implements safe contract methods.
|
|
type ContractReader struct {
|
|
invoker Invoker
|
|
hash util.Uint160
|
|
}
|
|
|
|
// NewReader creates an instance of ContractReader using Hash and the given Invoker.
|
|
func NewReader(invoker Invoker) *ContractReader {
|
|
var hash = Hash
|
|
return &ContractReader{invoker, hash}
|
|
}
|
|
|
|
// Tokens invokes `tokens` method of contract.
|
|
func (c *ContractReader) Tokens() (uuid.UUID, result.Iterator, error) {
|
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "tokens"))
|
|
}
|
|
|
|
// TokensExpanded is similar to Tokens (uses the same contract
|
|
// method), but can be useful if the server used doesn't support sessions and
|
|
// doesn't expand iterators. It creates a script that will get the specified
|
|
// number of result items from the iterator right in the VM and return them to
|
|
// you. It's only limited by VM stack and GAS available for RPC invocations.
|
|
func (c *ContractReader) TokensExpanded(_numOfIteratorItems int) ([]stackitem.Item, error) {
|
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "tokens", _numOfIteratorItems))
|
|
}
|
|
|
|
// GetAllRecords invokes `getAllRecords` method of contract.
|
|
func (c *ContractReader) GetAllRecords(name string) (uuid.UUID, result.Iterator, error) {
|
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "getAllRecords", name))
|
|
}
|
|
|
|
// GetAllRecordsExpanded is similar to GetAllRecords (uses the same contract
|
|
// method), but can be useful if the server used doesn't support sessions and
|
|
// doesn't expand iterators. It creates a script that will get the specified
|
|
// number of result items from the iterator right in the VM and return them to
|
|
// you. It's only limited by VM stack and GAS available for RPC invocations.
|
|
func (c *ContractReader) GetAllRecordsExpanded(name string, _numOfIteratorItems int) ([]stackitem.Item, error) {
|
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "getAllRecords", _numOfIteratorItems, name))
|
|
}
|