2023-10-19 16:33:02 +00:00
|
|
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
2024-01-11 12:36:31 +00:00
|
|
|
|
|
|
|
// Package ape contains RPC wrappers for APE contract.
|
2023-10-19 16:33:02 +00:00
|
|
|
package ape
|
|
|
|
|
|
|
|
import (
|
2024-01-26 14:39:33 +00:00
|
|
|
"github.com/google/uuid"
|
2023-10-19 16:33:02 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
|
|
|
"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"
|
|
|
|
"math/big"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Invoker is used by ContractReader to call various safe methods.
|
|
|
|
type Invoker interface {
|
|
|
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
2024-01-26 14:39:33 +00:00
|
|
|
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)
|
2023-10-19 16:33:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Actor is used by Contract to call state-changing methods.
|
|
|
|
type Actor interface {
|
|
|
|
Invoker
|
|
|
|
|
|
|
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
|
|
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
|
|
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
|
|
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
|
|
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
|
|
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContractReader implements safe contract methods.
|
|
|
|
type ContractReader struct {
|
|
|
|
invoker Invoker
|
|
|
|
hash util.Uint160
|
|
|
|
}
|
|
|
|
|
|
|
|
// Contract implements all contract methods.
|
|
|
|
type Contract struct {
|
|
|
|
ContractReader
|
|
|
|
actor Actor
|
|
|
|
hash util.Uint160
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
|
|
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
|
|
|
return &ContractReader{invoker, hash}
|
|
|
|
}
|
|
|
|
|
|
|
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
|
|
|
func New(actor Actor, hash util.Uint160) *Contract {
|
|
|
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
|
|
|
}
|
|
|
|
|
2023-11-24 08:08:49 +00:00
|
|
|
// GetAdmin invokes `getAdmin` method of contract.
|
|
|
|
func (c *ContractReader) GetAdmin() (util.Uint160, error) {
|
|
|
|
return unwrap.Uint160(c.invoker.Call(c.hash, "getAdmin"))
|
|
|
|
}
|
|
|
|
|
2023-11-17 08:06:08 +00:00
|
|
|
// GetChain invokes `getChain` method of contract.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *ContractReader) GetChain(entity *big.Int, entityName string, name []byte) ([]byte, error) {
|
2023-11-17 08:06:08 +00:00
|
|
|
return unwrap.Bytes(c.invoker.Call(c.hash, "getChain", entity, entityName, name))
|
|
|
|
}
|
|
|
|
|
2024-01-26 14:39:33 +00:00
|
|
|
// IteratorChainsByPrefix invokes `iteratorChainsByPrefix` method of contract.
|
|
|
|
func (c *ContractReader) IteratorChainsByPrefix(entity *big.Int, entityName string, prefix []byte) (uuid.UUID, result.Iterator, error) {
|
|
|
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "iteratorChainsByPrefix", entity, entityName, prefix))
|
|
|
|
}
|
|
|
|
|
|
|
|
// IteratorChainsByPrefixExpanded is similar to IteratorChainsByPrefix (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) IteratorChainsByPrefixExpanded(entity *big.Int, entityName string, prefix []byte, _numOfIteratorItems int) ([]stackitem.Item, error) {
|
|
|
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "iteratorChainsByPrefix", _numOfIteratorItems, entity, entityName, prefix))
|
|
|
|
}
|
|
|
|
|
2023-10-19 16:33:02 +00:00
|
|
|
// ListChains invokes `listChains` method of contract.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *ContractReader) ListChains(namespace string, container string, name []byte) ([]stackitem.Item, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return unwrap.Array(c.invoker.Call(c.hash, "listChains", namespace, container, name))
|
|
|
|
}
|
|
|
|
|
2023-11-17 08:06:08 +00:00
|
|
|
// ListChainsByPrefix invokes `listChainsByPrefix` method of contract.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *ContractReader) ListChainsByPrefix(entity *big.Int, entityName string, prefix []byte) ([]stackitem.Item, error) {
|
2023-11-17 08:06:08 +00:00
|
|
|
return unwrap.Array(c.invoker.Call(c.hash, "listChainsByPrefix", entity, entityName, prefix))
|
|
|
|
}
|
|
|
|
|
2024-02-09 14:28:42 +00:00
|
|
|
// ListTargets invokes `listTargets` method of contract.
|
|
|
|
func (c *ContractReader) ListTargets(entity *big.Int) (uuid.UUID, result.Iterator, error) {
|
|
|
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listTargets", entity))
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListTargetsExpanded is similar to ListTargets (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) ListTargetsExpanded(entity *big.Int, _numOfIteratorItems int) ([]stackitem.Item, error) {
|
|
|
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listTargets", _numOfIteratorItems, entity))
|
|
|
|
}
|
|
|
|
|
2024-01-11 12:36:55 +00:00
|
|
|
// Version invokes `version` method of contract.
|
|
|
|
func (c *ContractReader) Version() (*big.Int, error) {
|
|
|
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
|
|
|
}
|
|
|
|
|
2023-10-19 16:33:02 +00:00
|
|
|
// AddChain creates a transaction invoking `addChain` method of the contract.
|
|
|
|
// This transaction is signed and immediately sent to the network.
|
|
|
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) AddChain(entity *big.Int, entityName string, name []byte, chain []byte) (util.Uint256, uint32, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.SendCall(c.hash, "addChain", entity, entityName, name, chain)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddChainTransaction creates a transaction invoking `addChain` method of the contract.
|
|
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
|
|
// returned to the caller.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) AddChainTransaction(entity *big.Int, entityName string, name []byte, chain []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeCall(c.hash, "addChain", entity, entityName, name, chain)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddChainUnsigned creates a transaction invoking `addChain` method of the contract.
|
|
|
|
// This transaction is not signed, it's simply returned to the caller.
|
|
|
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
|
|
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) AddChainUnsigned(entity *big.Int, entityName string, name []byte, chain []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeUnsignedCall(c.hash, "addChain", nil, entity, entityName, name, chain)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChain creates a transaction invoking `removeChain` method of the contract.
|
|
|
|
// This transaction is signed and immediately sent to the network.
|
|
|
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChain(entity *big.Int, entityName string, name []byte) (util.Uint256, uint32, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.SendCall(c.hash, "removeChain", entity, entityName, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChainTransaction creates a transaction invoking `removeChain` method of the contract.
|
|
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
|
|
// returned to the caller.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChainTransaction(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeCall(c.hash, "removeChain", entity, entityName, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChainUnsigned creates a transaction invoking `removeChain` method of the contract.
|
|
|
|
// This transaction is not signed, it's simply returned to the caller.
|
|
|
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
|
|
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChainUnsigned(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeUnsignedCall(c.hash, "removeChain", nil, entity, entityName, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChainsByPrefix creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
|
|
|
// This transaction is signed and immediately sent to the network.
|
|
|
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChainsByPrefix(entity *big.Int, entityName string, name []byte) (util.Uint256, uint32, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.SendCall(c.hash, "removeChainsByPrefix", entity, entityName, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChainsByPrefixTransaction creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
|
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
|
|
// returned to the caller.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChainsByPrefixTransaction(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeCall(c.hash, "removeChainsByPrefix", entity, entityName, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChainsByPrefixUnsigned creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
|
|
|
// This transaction is not signed, it's simply returned to the caller.
|
|
|
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
|
|
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
2023-11-28 09:30:04 +00:00
|
|
|
func (c *Contract) RemoveChainsByPrefixUnsigned(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
2023-10-19 16:33:02 +00:00
|
|
|
return c.actor.MakeUnsignedCall(c.hash, "removeChainsByPrefix", nil, entity, entityName, name)
|
|
|
|
}
|
2023-11-24 08:08:49 +00:00
|
|
|
|
|
|
|
// SetAdmin creates a transaction invoking `setAdmin` method of the contract.
|
|
|
|
// This transaction is signed and immediately sent to the network.
|
|
|
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
|
|
|
func (c *Contract) SetAdmin(addr util.Uint160) (util.Uint256, uint32, error) {
|
|
|
|
return c.actor.SendCall(c.hash, "setAdmin", addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAdminTransaction creates a transaction invoking `setAdmin` method of the contract.
|
|
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
|
|
// returned to the caller.
|
|
|
|
func (c *Contract) SetAdminTransaction(addr util.Uint160) (*transaction.Transaction, error) {
|
|
|
|
return c.actor.MakeCall(c.hash, "setAdmin", addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAdminUnsigned creates a transaction invoking `setAdmin` method of the contract.
|
|
|
|
// This transaction is not signed, it's simply returned to the caller.
|
|
|
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
|
|
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
|
|
|
func (c *Contract) SetAdminUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
|
|
|
|
return c.actor.MakeUnsignedCall(c.hash, "setAdmin", nil, addr)
|
|
|
|
}
|