forked from TrueCloudLab/frostfs-contract
Evgenii Stratonikov
43097d2152
Autorization can be dedicated to a separate contract, iterating over multiple keys can be costly. Also add committee as "default" admin: everything is allowed for it. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2233 lines
79 KiB
Go
2233 lines
79 KiB
Go
// Package identity contains RPC wrappers for Identity contract.
|
|
//
|
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
|
package identity
|
|
|
|
import (
|
|
"crypto/elliptic"
|
|
"errors"
|
|
"fmt"
|
|
"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)
|
|
}
|
|
|
|
// 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"))
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// AddSubjectToNamespace creates a transaction invoking `addSubjectToNamespace` 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) AddSubjectToNamespace(addr util.Uint160, ns string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "addSubjectToNamespace", addr, ns)
|
|
}
|
|
|
|
// AddSubjectToNamespaceTransaction creates a transaction invoking `addSubjectToNamespace` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) AddSubjectToNamespaceTransaction(addr util.Uint160, ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "addSubjectToNamespace", addr, ns)
|
|
}
|
|
|
|
// AddSubjectToNamespaceUnsigned creates a transaction invoking `addSubjectToNamespace` 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) AddSubjectToNamespaceUnsigned(addr util.Uint160, ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "addSubjectToNamespace", nil, addr, ns)
|
|
}
|
|
|
|
// 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(key *keys.PublicKey) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "createSubject", 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(key *keys.PublicKey) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "createSubject", 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(key *keys.PublicKey) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "createSubject", nil, 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)
|
|
}
|
|
|
|
// GetGroup creates a transaction invoking `getGroup` 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) GetGroup(ns string, groupID *big.Int) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getGroup", ns, groupID)
|
|
}
|
|
|
|
// GetGroupTransaction creates a transaction invoking `getGroup` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetGroupTransaction(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getGroup", ns, groupID)
|
|
}
|
|
|
|
// GetGroupUnsigned creates a transaction invoking `getGroup` 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) GetGroupUnsigned(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getGroup", nil, ns, groupID)
|
|
}
|
|
|
|
// GetGroupExtended creates a transaction invoking `getGroupExtended` 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) GetGroupExtended(ns string, groupID *big.Int) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getGroupExtended", ns, groupID)
|
|
}
|
|
|
|
// GetGroupExtendedTransaction creates a transaction invoking `getGroupExtended` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetGroupExtendedTransaction(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getGroupExtended", ns, groupID)
|
|
}
|
|
|
|
// GetGroupExtendedUnsigned creates a transaction invoking `getGroupExtended` 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) GetGroupExtendedUnsigned(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getGroupExtended", nil, ns, groupID)
|
|
}
|
|
|
|
// GetGroupIDByName creates a transaction invoking `getGroupIDByName` 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) GetGroupIDByName(ns string, name string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getGroupIDByName", ns, name)
|
|
}
|
|
|
|
// GetGroupIDByNameTransaction creates a transaction invoking `getGroupIDByName` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetGroupIDByNameTransaction(ns string, name string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getGroupIDByName", ns, name)
|
|
}
|
|
|
|
// GetGroupIDByNameUnsigned creates a transaction invoking `getGroupIDByName` 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) GetGroupIDByNameUnsigned(ns string, name string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getGroupIDByName", nil, ns, name)
|
|
}
|
|
|
|
// GetNamespace creates a transaction invoking `getNamespace` 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) GetNamespace(ns string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getNamespace", ns)
|
|
}
|
|
|
|
// GetNamespaceTransaction creates a transaction invoking `getNamespace` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetNamespaceTransaction(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getNamespace", ns)
|
|
}
|
|
|
|
// GetNamespaceUnsigned creates a transaction invoking `getNamespace` 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) GetNamespaceUnsigned(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getNamespace", nil, ns)
|
|
}
|
|
|
|
// GetNamespaceExtended creates a transaction invoking `getNamespaceExtended` 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) GetNamespaceExtended(ns string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getNamespaceExtended", ns)
|
|
}
|
|
|
|
// GetNamespaceExtendedTransaction creates a transaction invoking `getNamespaceExtended` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetNamespaceExtendedTransaction(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getNamespaceExtended", ns)
|
|
}
|
|
|
|
// GetNamespaceExtendedUnsigned creates a transaction invoking `getNamespaceExtended` 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) GetNamespaceExtendedUnsigned(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getNamespaceExtended", nil, ns)
|
|
}
|
|
|
|
// GetSubject creates a transaction invoking `getSubject` 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) GetSubject(addr util.Uint160) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getSubject", addr)
|
|
}
|
|
|
|
// GetSubjectTransaction creates a transaction invoking `getSubject` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetSubjectTransaction(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getSubject", addr)
|
|
}
|
|
|
|
// GetSubjectUnsigned creates a transaction invoking `getSubject` 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) GetSubjectUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getSubject", nil, addr)
|
|
}
|
|
|
|
// GetSubjectByKey creates a transaction invoking `getSubjectByKey` 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) GetSubjectByKey(key *keys.PublicKey) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getSubjectByKey", key)
|
|
}
|
|
|
|
// GetSubjectByKeyTransaction creates a transaction invoking `getSubjectByKey` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetSubjectByKeyTransaction(key *keys.PublicKey) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getSubjectByKey", key)
|
|
}
|
|
|
|
// GetSubjectByKeyUnsigned creates a transaction invoking `getSubjectByKey` 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) GetSubjectByKeyUnsigned(key *keys.PublicKey) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getSubjectByKey", nil, key)
|
|
}
|
|
|
|
// GetSubjectExtended creates a transaction invoking `getSubjectExtended` 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) GetSubjectExtended(addr util.Uint160) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getSubjectExtended", addr)
|
|
}
|
|
|
|
// GetSubjectExtendedTransaction creates a transaction invoking `getSubjectExtended` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetSubjectExtendedTransaction(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getSubjectExtended", addr)
|
|
}
|
|
|
|
// GetSubjectExtendedUnsigned creates a transaction invoking `getSubjectExtended` 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) GetSubjectExtendedUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getSubjectExtended", nil, addr)
|
|
}
|
|
|
|
// GetSubjectKeyByName creates a transaction invoking `getSubjectKeyByName` 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) GetSubjectKeyByName(ns string, name string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "getSubjectKeyByName", ns, name)
|
|
}
|
|
|
|
// GetSubjectKeyByNameTransaction creates a transaction invoking `getSubjectKeyByName` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) GetSubjectKeyByNameTransaction(ns string, name string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "getSubjectKeyByName", ns, name)
|
|
}
|
|
|
|
// GetSubjectKeyByNameUnsigned creates a transaction invoking `getSubjectKeyByName` 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) GetSubjectKeyByNameUnsigned(ns string, name string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "getSubjectKeyByName", nil, ns, name)
|
|
}
|
|
|
|
// ListGroupSubjects creates a transaction invoking `listGroupSubjects` 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) ListGroupSubjects(ns string, groupID *big.Int) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "listGroupSubjects", ns, groupID)
|
|
}
|
|
|
|
// ListGroupSubjectsTransaction creates a transaction invoking `listGroupSubjects` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) ListGroupSubjectsTransaction(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "listGroupSubjects", ns, groupID)
|
|
}
|
|
|
|
// ListGroupSubjectsUnsigned creates a transaction invoking `listGroupSubjects` 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) ListGroupSubjectsUnsigned(ns string, groupID *big.Int) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "listGroupSubjects", nil, ns, groupID)
|
|
}
|
|
|
|
// ListGroups creates a transaction invoking `listGroups` 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) ListGroups(ns string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "listGroups", ns)
|
|
}
|
|
|
|
// ListGroupsTransaction creates a transaction invoking `listGroups` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) ListGroupsTransaction(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "listGroups", ns)
|
|
}
|
|
|
|
// ListGroupsUnsigned creates a transaction invoking `listGroups` 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) ListGroupsUnsigned(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "listGroups", nil, ns)
|
|
}
|
|
|
|
// ListNamespaceSubjects creates a transaction invoking `listNamespaceSubjects` 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) ListNamespaceSubjects(ns string) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "listNamespaceSubjects", ns)
|
|
}
|
|
|
|
// ListNamespaceSubjectsTransaction creates a transaction invoking `listNamespaceSubjects` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) ListNamespaceSubjectsTransaction(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "listNamespaceSubjects", ns)
|
|
}
|
|
|
|
// ListNamespaceSubjectsUnsigned creates a transaction invoking `listNamespaceSubjects` 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) ListNamespaceSubjectsUnsigned(ns string) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "listNamespaceSubjects", nil, ns)
|
|
}
|
|
|
|
// ListNamespaces creates a transaction invoking `listNamespaces` 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) ListNamespaces() (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "listNamespaces")
|
|
}
|
|
|
|
// ListNamespacesTransaction creates a transaction invoking `listNamespaces` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) ListNamespacesTransaction() (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "listNamespaces")
|
|
}
|
|
|
|
// ListNamespacesUnsigned creates a transaction invoking `listNamespaces` 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) ListNamespacesUnsigned() (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "listNamespaces", nil)
|
|
}
|
|
|
|
// ListSubjects creates a transaction invoking `listSubjects` 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) ListSubjects() (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "listSubjects")
|
|
}
|
|
|
|
// ListSubjectsTransaction creates a transaction invoking `listSubjects` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) ListSubjectsTransaction() (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "listSubjects")
|
|
}
|
|
|
|
// ListSubjectsUnsigned creates a transaction invoking `listSubjects` 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) ListSubjectsUnsigned() (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "listSubjects", nil)
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// RemoveSubjectFromNamespace creates a transaction invoking `removeSubjectFromNamespace` 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) RemoveSubjectFromNamespace(addr util.Uint160) (util.Uint256, uint32, error) {
|
|
return c.actor.SendCall(c.hash, "removeSubjectFromNamespace", addr)
|
|
}
|
|
|
|
// RemoveSubjectFromNamespaceTransaction creates a transaction invoking `removeSubjectFromNamespace` method of the contract.
|
|
// This transaction is signed, but not sent to the network, instead it's
|
|
// returned to the caller.
|
|
func (c *Contract) RemoveSubjectFromNamespaceTransaction(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeCall(c.hash, "removeSubjectFromNamespace", addr)
|
|
}
|
|
|
|
// RemoveSubjectFromNamespaceUnsigned creates a transaction invoking `removeSubjectFromNamespace` 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) RemoveSubjectFromNamespaceUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
|
|
return c.actor.MakeUnsignedCall(c.hash, "removeSubjectFromNamespace", nil, addr)
|
|
}
|
|
|
|
// 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
|
|
}
|