frostfs-contract/rpcclient/frostfsid/client.go

2011 lines
67 KiB
Go
Raw Normal View History

// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
// Package identity contains RPC wrappers for Identity contract.
package identity
import (
"crypto/elliptic"
"errors"
"fmt"
"github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"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"
"unicode/utf8"
)
// CreateSubjectEvent represents "CreateSubject" event emitted by the contract.
type CreateSubjectEvent struct {
SubjectAddress util.Uint160
}
// AddSubjectKeyEvent represents "AddSubjectKey" event emitted by the contract.
type AddSubjectKeyEvent struct {
SubjectAddress util.Uint160
SubjectKey *keys.PublicKey
}
// RemoveSubjectKeyEvent represents "RemoveSubjectKey" event emitted by the contract.
type RemoveSubjectKeyEvent struct {
SubjectAddress util.Uint160
SubjectKey *keys.PublicKey
}
// SetSubjectNameEvent represents "SetSubjectName" event emitted by the contract.
type SetSubjectNameEvent struct {
SubjectAddress util.Uint160
Name string
}
// SetSubjectKVEvent represents "SetSubjectKV" event emitted by the contract.
type SetSubjectKVEvent struct {
SubjectAddress util.Uint160
Key string
Value string
}
// DeleteSubjectKVEvent represents "DeleteSubjectKV" event emitted by the contract.
type DeleteSubjectKVEvent struct {
SubjectAddress util.Uint160
Key string
}
// DeleteSubjectEvent represents "DeleteSubject" event emitted by the contract.
type DeleteSubjectEvent struct {
SubjectAddress util.Uint160
}
// CreateNamespaceEvent represents "CreateNamespace" event emitted by the contract.
type CreateNamespaceEvent struct {
Namespace string
}
// AddSubjectToNamespaceEvent represents "AddSubjectToNamespace" event emitted by the contract.
type AddSubjectToNamespaceEvent struct {
SubjectAddress util.Uint160
Namespace string
}
// RemoveSubjectFromNamespaceEvent represents "RemoveSubjectFromNamespace" event emitted by the contract.
type RemoveSubjectFromNamespaceEvent struct {
SubjectAddress util.Uint160
Namespace string
}
// CreateGroupEvent represents "CreateGroup" event emitted by the contract.
type CreateGroupEvent struct {
Namespace string
Group string
}
// SetGroupNameEvent represents "SetGroupName" event emitted by the contract.
type SetGroupNameEvent struct {
Namespace string
GroupID *big.Int
Name string
}
// SetGroupKVEvent represents "SetGroupKV" event emitted by the contract.
type SetGroupKVEvent struct {
Namespace string
GroupID *big.Int
Key string
Value string
}
// DeleteGroupKVEvent represents "DeleteGroupKV" event emitted by the contract.
type DeleteGroupKVEvent struct {
Namespace string
GroupID *big.Int
Key string
}
// AddSubjectToGroupEvent represents "AddSubjectToGroup" event emitted by the contract.
type AddSubjectToGroupEvent struct {
SubjectAddress util.Uint160
Namespace string
GroupID *big.Int
}
// RemoveSubjectFromGroupEvent represents "RemoveSubjectFromGroup" event emitted by the contract.
type RemoveSubjectFromGroupEvent struct {
SubjectAddress util.Uint160
Namespace string
GroupID *big.Int
}
// DeleteGroupEvent represents "DeleteGroup" event emitted by the contract.
type DeleteGroupEvent struct {
Namespace string
GroupID *big.Int
}
// 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)
}
// 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}
}
// GetAdmin invokes `getAdmin` method of contract.
func (c *ContractReader) GetAdmin() (util.Uint160, error) {
return unwrap.Uint160(c.invoker.Call(c.hash, "getAdmin"))
}
// GetGroup invokes `getGroup` method of contract.
func (c *ContractReader) GetGroup(ns string, groupID *big.Int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getGroup", ns, groupID))
}
// GetGroupByName invokes `getGroupByName` method of contract.
func (c *ContractReader) GetGroupByName(ns string, name string) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getGroupByName", ns, name))
}
// GetGroupExtended invokes `getGroupExtended` method of contract.
func (c *ContractReader) GetGroupExtended(ns string, groupID *big.Int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getGroupExtended", ns, groupID))
}
// GetGroupIDByName invokes `getGroupIDByName` method of contract.
func (c *ContractReader) GetGroupIDByName(ns string, name string) (*big.Int, error) {
return unwrap.BigInt(c.invoker.Call(c.hash, "getGroupIDByName", ns, name))
}
// GetNamespace invokes `getNamespace` method of contract.
func (c *ContractReader) GetNamespace(ns string) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getNamespace", ns))
}
// GetNamespaceExtended invokes `getNamespaceExtended` method of contract.
func (c *ContractReader) GetNamespaceExtended(ns string) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getNamespaceExtended", ns))
}
// GetSubject invokes `getSubject` method of contract.
func (c *ContractReader) GetSubject(addr util.Uint160) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getSubject", addr))
}
// GetSubjectByKey invokes `getSubjectByKey` method of contract.
func (c *ContractReader) GetSubjectByKey(key *keys.PublicKey) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getSubjectByKey", key))
}
// GetSubjectByName invokes `getSubjectByName` method of contract.
func (c *ContractReader) GetSubjectByName(ns string, name string) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getSubjectByName", ns, name))
}
// GetSubjectExtended invokes `getSubjectExtended` method of contract.
func (c *ContractReader) GetSubjectExtended(addr util.Uint160) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.Call(c.hash, "getSubjectExtended", addr))
}
// GetSubjectKeyByName invokes `getSubjectKeyByName` method of contract.
func (c *ContractReader) GetSubjectKeyByName(ns string, name string) (*keys.PublicKey, error) {
return unwrap.PublicKey(c.invoker.Call(c.hash, "getSubjectKeyByName", ns, name))
}
// ListGroupSubjects invokes `listGroupSubjects` method of contract.
func (c *ContractReader) ListGroupSubjects(ns string, groupID *big.Int) (uuid.UUID, result.Iterator, error) {
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listGroupSubjects", ns, groupID))
}
// ListGroupSubjectsExpanded is similar to ListGroupSubjects (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) ListGroupSubjectsExpanded(ns string, groupID *big.Int, _numOfIteratorItems int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listGroupSubjects", _numOfIteratorItems, ns, groupID))
}
// ListGroups invokes `listGroups` method of contract.
func (c *ContractReader) ListGroups(ns string) (uuid.UUID, result.Iterator, error) {
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listGroups", ns))
}
// ListGroupsExpanded is similar to ListGroups (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) ListGroupsExpanded(ns string, _numOfIteratorItems int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listGroups", _numOfIteratorItems, ns))
}
// ListNamespaceSubjects invokes `listNamespaceSubjects` method of contract.
func (c *ContractReader) ListNamespaceSubjects(ns string) (uuid.UUID, result.Iterator, error) {
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listNamespaceSubjects", ns))
}
// ListNamespaceSubjectsExpanded is similar to ListNamespaceSubjects (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) ListNamespaceSubjectsExpanded(ns string, _numOfIteratorItems int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listNamespaceSubjects", _numOfIteratorItems, ns))
}
// ListNamespaces invokes `listNamespaces` method of contract.
func (c *ContractReader) ListNamespaces() (uuid.UUID, result.Iterator, error) {
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listNamespaces"))
}
// ListNamespacesExpanded is similar to ListNamespaces (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) ListNamespacesExpanded(_numOfIteratorItems int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listNamespaces", _numOfIteratorItems))
}
// ListSubjects invokes `listSubjects` method of contract.
func (c *ContractReader) ListSubjects() (uuid.UUID, result.Iterator, error) {
return unwrap.SessionIterator(c.invoker.Call(c.hash, "listSubjects"))
}
// ListSubjectsExpanded is similar to ListSubjects (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) ListSubjectsExpanded(_numOfIteratorItems int) ([]stackitem.Item, error) {
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "listSubjects", _numOfIteratorItems))
}
// Version invokes `version` method of contract.
func (c *ContractReader) Version() (*big.Int, error) {
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
}
// AddSubjectKey creates a transaction invoking `addSubjectKey` 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) AddSubjectKey(addr util.Uint160, key *keys.PublicKey) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "addSubjectKey", addr, key)
}
// AddSubjectKeyTransaction creates a transaction invoking `addSubjectKey` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) AddSubjectKeyTransaction(addr util.Uint160, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "addSubjectKey", addr, key)
}
// AddSubjectKeyUnsigned creates a transaction invoking `addSubjectKey` 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) AddSubjectKeyUnsigned(addr util.Uint160, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "addSubjectKey", nil, addr, key)
}
// AddSubjectToGroup creates a transaction invoking `addSubjectToGroup` 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) AddSubjectToGroup(addr util.Uint160, groupID *big.Int) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "addSubjectToGroup", addr, groupID)
}
// AddSubjectToGroupTransaction creates a transaction invoking `addSubjectToGroup` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) AddSubjectToGroupTransaction(addr util.Uint160, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "addSubjectToGroup", addr, groupID)
}
// AddSubjectToGroupUnsigned creates a transaction invoking `addSubjectToGroup` 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) AddSubjectToGroupUnsigned(addr util.Uint160, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "addSubjectToGroup", nil, addr, groupID)
}
// ClearAdmin creates a transaction invoking `clearAdmin` 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) ClearAdmin() (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "clearAdmin")
}
// ClearAdminTransaction creates a transaction invoking `clearAdmin` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) ClearAdminTransaction() (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "clearAdmin")
}
// ClearAdminUnsigned creates a transaction invoking `clearAdmin` 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) ClearAdminUnsigned() (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "clearAdmin", nil)
}
// CreateGroup creates a transaction invoking `createGroup` 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) CreateGroup(ns string, group string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "createGroup", ns, group)
}
// CreateGroupTransaction creates a transaction invoking `createGroup` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) CreateGroupTransaction(ns string, group string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "createGroup", ns, group)
}
// CreateGroupUnsigned creates a transaction invoking `createGroup` 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) CreateGroupUnsigned(ns string, group string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "createGroup", nil, ns, group)
}
// CreateNamespace creates a transaction invoking `createNamespace` 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) CreateNamespace(ns string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "createNamespace", ns)
}
// CreateNamespaceTransaction creates a transaction invoking `createNamespace` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) CreateNamespaceTransaction(ns string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "createNamespace", ns)
}
// CreateNamespaceUnsigned creates a transaction invoking `createNamespace` 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) CreateNamespaceUnsigned(ns string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "createNamespace", nil, ns)
}
// CreateSubject creates a transaction invoking `createSubject` 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) CreateSubject(ns string, key *keys.PublicKey) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "createSubject", ns, key)
}
// CreateSubjectTransaction creates a transaction invoking `createSubject` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) CreateSubjectTransaction(ns string, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "createSubject", ns, key)
}
// CreateSubjectUnsigned creates a transaction invoking `createSubject` 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) CreateSubjectUnsigned(ns string, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "createSubject", nil, ns, key)
}
// DeleteGroup creates a transaction invoking `deleteGroup` 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) DeleteGroup(ns string, groupID *big.Int) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "deleteGroup", ns, groupID)
}
// DeleteGroupTransaction creates a transaction invoking `deleteGroup` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) DeleteGroupTransaction(ns string, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "deleteGroup", ns, groupID)
}
// DeleteGroupUnsigned creates a transaction invoking `deleteGroup` 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) DeleteGroupUnsigned(ns string, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "deleteGroup", nil, ns, groupID)
}
// DeleteGroupKV creates a transaction invoking `deleteGroupKV` 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) DeleteGroupKV(ns string, groupID *big.Int, key string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "deleteGroupKV", ns, groupID, key)
}
// DeleteGroupKVTransaction creates a transaction invoking `deleteGroupKV` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) DeleteGroupKVTransaction(ns string, groupID *big.Int, key string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "deleteGroupKV", ns, groupID, key)
}
// DeleteGroupKVUnsigned creates a transaction invoking `deleteGroupKV` 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) DeleteGroupKVUnsigned(ns string, groupID *big.Int, key string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "deleteGroupKV", nil, ns, groupID, key)
}
// DeleteSubject creates a transaction invoking `deleteSubject` 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) DeleteSubject(addr util.Uint160) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "deleteSubject", addr)
}
// DeleteSubjectTransaction creates a transaction invoking `deleteSubject` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) DeleteSubjectTransaction(addr util.Uint160) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "deleteSubject", addr)
}
// DeleteSubjectUnsigned creates a transaction invoking `deleteSubject` 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) DeleteSubjectUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "deleteSubject", nil, addr)
}
// DeleteSubjectKV creates a transaction invoking `deleteSubjectKV` 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) DeleteSubjectKV(addr util.Uint160, key string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "deleteSubjectKV", addr, key)
}
// DeleteSubjectKVTransaction creates a transaction invoking `deleteSubjectKV` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) DeleteSubjectKVTransaction(addr util.Uint160, key string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "deleteSubjectKV", addr, key)
}
// DeleteSubjectKVUnsigned creates a transaction invoking `deleteSubjectKV` 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) DeleteSubjectKVUnsigned(addr util.Uint160, key string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "deleteSubjectKV", nil, addr, key)
}
// RemoveSubjectFromGroup creates a transaction invoking `removeSubjectFromGroup` 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) RemoveSubjectFromGroup(addr util.Uint160, groupID *big.Int) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "removeSubjectFromGroup", addr, groupID)
}
// RemoveSubjectFromGroupTransaction creates a transaction invoking `removeSubjectFromGroup` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) RemoveSubjectFromGroupTransaction(addr util.Uint160, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "removeSubjectFromGroup", addr, groupID)
}
// RemoveSubjectFromGroupUnsigned creates a transaction invoking `removeSubjectFromGroup` 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) RemoveSubjectFromGroupUnsigned(addr util.Uint160, groupID *big.Int) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "removeSubjectFromGroup", nil, addr, groupID)
}
// RemoveSubjectKey creates a transaction invoking `removeSubjectKey` 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) RemoveSubjectKey(addr util.Uint160, key *keys.PublicKey) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "removeSubjectKey", addr, key)
}
// RemoveSubjectKeyTransaction creates a transaction invoking `removeSubjectKey` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) RemoveSubjectKeyTransaction(addr util.Uint160, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "removeSubjectKey", addr, key)
}
// RemoveSubjectKeyUnsigned creates a transaction invoking `removeSubjectKey` 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) RemoveSubjectKeyUnsigned(addr util.Uint160, key *keys.PublicKey) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "removeSubjectKey", nil, addr, key)
}
// 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)
}
// SetGroupKV creates a transaction invoking `setGroupKV` 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) SetGroupKV(ns string, groupID *big.Int, key string, val string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "setGroupKV", ns, groupID, key, val)
}
// SetGroupKVTransaction creates a transaction invoking `setGroupKV` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) SetGroupKVTransaction(ns string, groupID *big.Int, key string, val string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "setGroupKV", ns, groupID, key, val)
}
// SetGroupKVUnsigned creates a transaction invoking `setGroupKV` 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) SetGroupKVUnsigned(ns string, groupID *big.Int, key string, val string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "setGroupKV", nil, ns, groupID, key, val)
}
// SetGroupName creates a transaction invoking `setGroupName` 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) SetGroupName(ns string, groupID *big.Int, name string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "setGroupName", ns, groupID, name)
}
// SetGroupNameTransaction creates a transaction invoking `setGroupName` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) SetGroupNameTransaction(ns string, groupID *big.Int, name string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "setGroupName", ns, groupID, name)
}
// SetGroupNameUnsigned creates a transaction invoking `setGroupName` 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) SetGroupNameUnsigned(ns string, groupID *big.Int, name string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "setGroupName", nil, ns, groupID, name)
}
// SetSubjectKV creates a transaction invoking `setSubjectKV` 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) SetSubjectKV(addr util.Uint160, key string, val string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "setSubjectKV", addr, key, val)
}
// SetSubjectKVTransaction creates a transaction invoking `setSubjectKV` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) SetSubjectKVTransaction(addr util.Uint160, key string, val string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "setSubjectKV", addr, key, val)
}
// SetSubjectKVUnsigned creates a transaction invoking `setSubjectKV` 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) SetSubjectKVUnsigned(addr util.Uint160, key string, val string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "setSubjectKV", nil, addr, key, val)
}
// SetSubjectName creates a transaction invoking `setSubjectName` 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) SetSubjectName(addr util.Uint160, name string) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "setSubjectName", addr, name)
}
// SetSubjectNameTransaction creates a transaction invoking `setSubjectName` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) SetSubjectNameTransaction(addr util.Uint160, name string) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "setSubjectName", addr, name)
}
// SetSubjectNameUnsigned creates a transaction invoking `setSubjectName` 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) SetSubjectNameUnsigned(addr util.Uint160, name string) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "setSubjectName", nil, addr, name)
}
// Update creates a transaction invoking `update` 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) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "update", script, manifest, data)
}
// UpdateTransaction creates a transaction invoking `update` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
}
// UpdateUnsigned creates a transaction invoking `update` 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) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
}
// CreateSubjectEventsFromApplicationLog retrieves a set of all emitted events
// with "CreateSubject" name from the provided [result.ApplicationLog].
func CreateSubjectEventsFromApplicationLog(log *result.ApplicationLog) ([]*CreateSubjectEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*CreateSubjectEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "CreateSubject" {
continue
}
event := new(CreateSubjectEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize CreateSubjectEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to CreateSubjectEvent or
// returns an error if it's not possible to do to so.
func (e *CreateSubjectEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 1 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
return nil
}
// AddSubjectKeyEventsFromApplicationLog retrieves a set of all emitted events
// with "AddSubjectKey" name from the provided [result.ApplicationLog].
func AddSubjectKeyEventsFromApplicationLog(log *result.ApplicationLog) ([]*AddSubjectKeyEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*AddSubjectKeyEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "AddSubjectKey" {
continue
}
event := new(AddSubjectKeyEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize AddSubjectKeyEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to AddSubjectKeyEvent or
// returns an error if it's not possible to do to so.
func (e *AddSubjectKeyEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.SubjectKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
}
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
if err != nil {
return nil, err
}
return k, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectKey: %w", err)
}
return nil
}
// RemoveSubjectKeyEventsFromApplicationLog retrieves a set of all emitted events
// with "RemoveSubjectKey" name from the provided [result.ApplicationLog].
func RemoveSubjectKeyEventsFromApplicationLog(log *result.ApplicationLog) ([]*RemoveSubjectKeyEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*RemoveSubjectKeyEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "RemoveSubjectKey" {
continue
}
event := new(RemoveSubjectKeyEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize RemoveSubjectKeyEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to RemoveSubjectKeyEvent or
// returns an error if it's not possible to do to so.
func (e *RemoveSubjectKeyEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.SubjectKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
b, err := item.TryBytes()
if err != nil {
return nil, err
}
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
if err != nil {
return nil, err
}
return k, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectKey: %w", err)
}
return nil
}
// SetSubjectNameEventsFromApplicationLog retrieves a set of all emitted events
// with "SetSubjectName" name from the provided [result.ApplicationLog].
func SetSubjectNameEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetSubjectNameEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*SetSubjectNameEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "SetSubjectName" {
continue
}
event := new(SetSubjectNameEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize SetSubjectNameEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to SetSubjectNameEvent or
// returns an error if it's not possible to do to so.
func (e *SetSubjectNameEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
return nil
}
// SetSubjectKVEventsFromApplicationLog retrieves a set of all emitted events
// with "SetSubjectKV" name from the provided [result.ApplicationLog].
func SetSubjectKVEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetSubjectKVEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*SetSubjectKVEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "SetSubjectKV" {
continue
}
event := new(SetSubjectKVEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize SetSubjectKVEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to SetSubjectKVEvent or
// returns an error if it's not possible to do to so.
func (e *SetSubjectKVEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 3 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Key, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Key: %w", err)
}
index++
e.Value, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Value: %w", err)
}
return nil
}
// DeleteSubjectKVEventsFromApplicationLog retrieves a set of all emitted events
// with "DeleteSubjectKV" name from the provided [result.ApplicationLog].
func DeleteSubjectKVEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteSubjectKVEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*DeleteSubjectKVEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "DeleteSubjectKV" {
continue
}
event := new(DeleteSubjectKVEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize DeleteSubjectKVEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to DeleteSubjectKVEvent or
// returns an error if it's not possible to do to so.
func (e *DeleteSubjectKVEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Key, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Key: %w", err)
}
return nil
}
// DeleteSubjectEventsFromApplicationLog retrieves a set of all emitted events
// with "DeleteSubject" name from the provided [result.ApplicationLog].
func DeleteSubjectEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteSubjectEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*DeleteSubjectEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "DeleteSubject" {
continue
}
event := new(DeleteSubjectEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize DeleteSubjectEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to DeleteSubjectEvent or
// returns an error if it's not possible to do to so.
func (e *DeleteSubjectEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 1 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
return nil
}
// CreateNamespaceEventsFromApplicationLog retrieves a set of all emitted events
// with "CreateNamespace" name from the provided [result.ApplicationLog].
func CreateNamespaceEventsFromApplicationLog(log *result.ApplicationLog) ([]*CreateNamespaceEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*CreateNamespaceEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "CreateNamespace" {
continue
}
event := new(CreateNamespaceEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize CreateNamespaceEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to CreateNamespaceEvent or
// returns an error if it's not possible to do to so.
func (e *CreateNamespaceEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 1 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
return nil
}
// AddSubjectToNamespaceEventsFromApplicationLog retrieves a set of all emitted events
// with "AddSubjectToNamespace" name from the provided [result.ApplicationLog].
func AddSubjectToNamespaceEventsFromApplicationLog(log *result.ApplicationLog) ([]*AddSubjectToNamespaceEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*AddSubjectToNamespaceEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "AddSubjectToNamespace" {
continue
}
event := new(AddSubjectToNamespaceEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize AddSubjectToNamespaceEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to AddSubjectToNamespaceEvent or
// returns an error if it's not possible to do to so.
func (e *AddSubjectToNamespaceEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
return nil
}
// RemoveSubjectFromNamespaceEventsFromApplicationLog retrieves a set of all emitted events
// with "RemoveSubjectFromNamespace" name from the provided [result.ApplicationLog].
func RemoveSubjectFromNamespaceEventsFromApplicationLog(log *result.ApplicationLog) ([]*RemoveSubjectFromNamespaceEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*RemoveSubjectFromNamespaceEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "RemoveSubjectFromNamespace" {
continue
}
event := new(RemoveSubjectFromNamespaceEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize RemoveSubjectFromNamespaceEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to RemoveSubjectFromNamespaceEvent or
// returns an error if it's not possible to do to so.
func (e *RemoveSubjectFromNamespaceEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
return nil
}
// CreateGroupEventsFromApplicationLog retrieves a set of all emitted events
// with "CreateGroup" name from the provided [result.ApplicationLog].
func CreateGroupEventsFromApplicationLog(log *result.ApplicationLog) ([]*CreateGroupEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*CreateGroupEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "CreateGroup" {
continue
}
event := new(CreateGroupEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize CreateGroupEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to CreateGroupEvent or
// returns an error if it's not possible to do to so.
func (e *CreateGroupEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.Group, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Group: %w", err)
}
return nil
}
// SetGroupNameEventsFromApplicationLog retrieves a set of all emitted events
// with "SetGroupName" name from the provided [result.ApplicationLog].
func SetGroupNameEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetGroupNameEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*SetGroupNameEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "SetGroupName" {
continue
}
event := new(SetGroupNameEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize SetGroupNameEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to SetGroupNameEvent or
// returns an error if it's not possible to do to so.
func (e *SetGroupNameEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 3 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
index++
e.Name, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Name: %w", err)
}
return nil
}
// SetGroupKVEventsFromApplicationLog retrieves a set of all emitted events
// with "SetGroupKV" name from the provided [result.ApplicationLog].
func SetGroupKVEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetGroupKVEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*SetGroupKVEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "SetGroupKV" {
continue
}
event := new(SetGroupKVEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize SetGroupKVEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to SetGroupKVEvent or
// returns an error if it's not possible to do to so.
func (e *SetGroupKVEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 4 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
index++
e.Key, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Key: %w", err)
}
index++
e.Value, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Value: %w", err)
}
return nil
}
// DeleteGroupKVEventsFromApplicationLog retrieves a set of all emitted events
// with "DeleteGroupKV" name from the provided [result.ApplicationLog].
func DeleteGroupKVEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteGroupKVEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*DeleteGroupKVEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "DeleteGroupKV" {
continue
}
event := new(DeleteGroupKVEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize DeleteGroupKVEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to DeleteGroupKVEvent or
// returns an error if it's not possible to do to so.
func (e *DeleteGroupKVEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 3 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
index++
e.Key, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Key: %w", err)
}
return nil
}
// AddSubjectToGroupEventsFromApplicationLog retrieves a set of all emitted events
// with "AddSubjectToGroup" name from the provided [result.ApplicationLog].
func AddSubjectToGroupEventsFromApplicationLog(log *result.ApplicationLog) ([]*AddSubjectToGroupEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*AddSubjectToGroupEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "AddSubjectToGroup" {
continue
}
event := new(AddSubjectToGroupEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize AddSubjectToGroupEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to AddSubjectToGroupEvent or
// returns an error if it's not possible to do to so.
func (e *AddSubjectToGroupEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 3 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
return nil
}
// RemoveSubjectFromGroupEventsFromApplicationLog retrieves a set of all emitted events
// with "RemoveSubjectFromGroup" name from the provided [result.ApplicationLog].
func RemoveSubjectFromGroupEventsFromApplicationLog(log *result.ApplicationLog) ([]*RemoveSubjectFromGroupEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*RemoveSubjectFromGroupEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "RemoveSubjectFromGroup" {
continue
}
event := new(RemoveSubjectFromGroupEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize RemoveSubjectFromGroupEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to RemoveSubjectFromGroupEvent or
// returns an error if it's not possible to do to so.
func (e *RemoveSubjectFromGroupEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 3 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.SubjectAddress, err = func(item stackitem.Item) (util.Uint160, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint160{}, err
}
u, err := util.Uint160DecodeBytesBE(b)
if err != nil {
return util.Uint160{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field SubjectAddress: %w", err)
}
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
return nil
}
// DeleteGroupEventsFromApplicationLog retrieves a set of all emitted events
// with "DeleteGroup" name from the provided [result.ApplicationLog].
func DeleteGroupEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteGroupEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*DeleteGroupEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "DeleteGroup" {
continue
}
event := new(DeleteGroupEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize DeleteGroupEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to DeleteGroupEvent or
// returns an error if it's not possible to do to so.
func (e *DeleteGroupEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Namespace, err = func(item stackitem.Item) (string, error) {
b, err := item.TryBytes()
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", errors.New("not a UTF-8 string")
}
return string(b), nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Namespace: %w", err)
}
index++
e.GroupID, err = arr[index].TryInteger()
if err != nil {
return fmt.Errorf("field GroupID: %w", err)
}
return nil
}