state

package
v0.0.0-...-886a677 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 22 Imported by: 14

Documentation

Index

Constants

View Source
const TokenTransferBatchSize = 128

TokenTransferBatchSize is the maximum number of entries for TokenTransferLog.

Variables

This section is empty.

Functions

func CreateContractHash

func CreateContractHash(sender util.Uint160, checksum uint32, name string) util.Uint160

CreateContractHash creates a deployed contract hash from the transaction sender and the contract script.

func CreateNativeContractHash

func CreateNativeContractHash(name string) util.Uint160

CreateNativeContractHash calculates the hash for the native contract with the given name.

Types

type AppExecResult

type AppExecResult struct {
	Container util.Uint256
	Execution
}

AppExecResult represents the result of the script execution, gathering together all resulting notifications, state, stack and other metadata.

func (*AppExecResult) DecodeBinary

func (aer *AppExecResult) DecodeBinary(r *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*AppExecResult) EncodeBinary

func (aer *AppExecResult) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the Serializable interface.

func (*AppExecResult) EncodeBinaryWithContext

func (aer *AppExecResult) EncodeBinaryWithContext(w *io.BinWriter, sc *stackitem.SerializationContext)

EncodeBinaryWithContext is the same as EncodeBinary, but allows to efficiently reuse stack item serialization context.

func (*AppExecResult) MarshalJSON

func (aer *AppExecResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*AppExecResult) UnmarshalJSON

func (aer *AppExecResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type ContainedNotificationEvent

type ContainedNotificationEvent struct {
	// Container hash is the hash of script container which is either a block or a transaction.
	Container util.Uint256
	NotificationEvent
}

ContainedNotificationEvent represents a wrapper for a notification from script execution.

func (*ContainedNotificationEvent) MarshalJSON

func (ne *ContainedNotificationEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ContainedNotificationEvent) UnmarshalJSON

func (ne *ContainedNotificationEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Contract

type Contract struct {
	ContractBase
	UpdateCounter uint16 `json:"updatecounter"`
}

Contract holds information about a smart contract in the Neo blockchain.

func (*Contract) FromStackItem

func (c *Contract) FromStackItem(item stackitem.Item) error

FromStackItem fills Contract's data from the given stack itemized contract representation.

func (*Contract) ToStackItem

func (c *Contract) ToStackItem() (stackitem.Item, error)

ToStackItem converts state.Contract to stackitem.Item.

type ContractBase

type ContractBase struct {
	ID       int32             `json:"id"`
	Hash     util.Uint160      `json:"hash"`
	NEF      nef.File          `json:"nef"`
	Manifest manifest.Manifest `json:"manifest"`
}

ContractBase represents a part shared by native and user-deployed contracts.

type Deposit

type Deposit struct {
	Amount *big.Int
	Till   uint32
}

Deposit represents GAS deposit from a Notary contract.

func (*Deposit) FromStackItem

func (d *Deposit) FromStackItem(it stackitem.Item) error

FromStackItem implements stackitem.Convertible interface.

func (*Deposit) ToStackItem

func (d *Deposit) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible interface. It never returns an error.

type Execution

type Execution struct {
	Trigger        trigger.Type
	VMState        vmstate.State
	GasConsumed    int64
	Stack          []stackitem.Item
	Events         []NotificationEvent
	FaultException string
}

Execution represents the result of a single script execution, gathering together all resulting notifications, state, stack and other metadata.

func (Execution) MarshalJSON

func (e Execution) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Execution) UnmarshalJSON

func (e *Execution) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type MPTRoot

type MPTRoot struct {
	Version byte                  `json:"version"`
	Index   uint32                `json:"index"`
	Root    util.Uint256          `json:"roothash"`
	Witness []transaction.Witness `json:"witnesses"`
}

MPTRoot represents the storage state root together with sign info.

func (*MPTRoot) DecodeBinary

func (s *MPTRoot) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable.

func (*MPTRoot) DecodeBinaryUnsigned

func (s *MPTRoot) DecodeBinaryUnsigned(r *io.BinReader)

DecodeBinaryUnsigned decodes the hashable part of the state root.

func (*MPTRoot) EncodeBinary

func (s *MPTRoot) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable.

func (*MPTRoot) EncodeBinaryUnsigned

func (s *MPTRoot) EncodeBinaryUnsigned(w *io.BinWriter)

EncodeBinaryUnsigned encodes the hashable part of the state root.

func (*MPTRoot) Hash

func (s *MPTRoot) Hash() util.Uint256

Hash returns the hash of s.

type NEOBalance

type NEOBalance struct {
	NEP17Balance
	BalanceHeight  uint32
	VoteTo         *keys.PublicKey
	LastGasPerVote big.Int
}

NEOBalance represents the balance state of a NEO-token.

func NEOBalanceFromBytes

func NEOBalanceFromBytes(b []byte) (*NEOBalance, error)

NEOBalanceFromBytes converts the serialized NEOBalance to a structure.

func (*NEOBalance) Bytes

Bytes returns a serialized NEOBalance.

func (*NEOBalance) FromStackItem

func (s *NEOBalance) FromStackItem(item stackitem.Item) error

FromStackItem converts stackitem.Item to NEOBalance.

func (*NEOBalance) ToStackItem

func (s *NEOBalance) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible interface. It never returns an error.

type NEP11Transfer

type NEP11Transfer struct {
	NEP17Transfer

	// ID is a NEP-11 token ID.
	ID []byte
}

NEP11Transfer represents a single NEP-11 Transfer event.

func (*NEP11Transfer) DecodeBinary

func (t *NEP11Transfer) DecodeBinary(r *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*NEP11Transfer) EncodeBinary

func (t *NEP11Transfer) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the io.Serializable interface.

type NEP17Balance

type NEP17Balance struct {
	Balance big.Int
}

NEP17Balance represents the balance state of a NEP-17-token.

func NEP17BalanceFromBytes

func NEP17BalanceFromBytes(b []byte) (*NEP17Balance, error)

NEP17BalanceFromBytes converts the serialized NEP17Balance to a structure.

func (*NEP17Balance) Bytes

func (s *NEP17Balance) Bytes(buf []byte) []byte

Bytes returns serialized NEP17Balance.

func (*NEP17Balance) FromStackItem

func (s *NEP17Balance) FromStackItem(item stackitem.Item) error

FromStackItem implements stackitem.Convertible.

func (*NEP17Balance) ToStackItem

func (s *NEP17Balance) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible. It never returns an error.

type NEP17Transfer

type NEP17Transfer struct {
	// Asset is a NEP-17 contract ID.
	Asset int32
	// Counterparty is the address of the sender/receiver (the other side of the transfer).
	Counterparty util.Uint160
	// Amount is the amount of tokens transferred.
	// It is negative when tokens are sent and positive if they are received.
	Amount *big.Int
	// Block is a number of block when the event occurred.
	Block uint32
	// Timestamp is the timestamp of the block where transfer occurred.
	Timestamp uint64
	// Tx is a hash the transaction.
	Tx util.Uint256
}

NEP17Transfer represents a single NEP-17 Transfer event.

func (*NEP17Transfer) DecodeBinary

func (t *NEP17Transfer) DecodeBinary(r *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*NEP17Transfer) EncodeBinary

func (t *NEP17Transfer) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the io.Serializable interface.

type NotificationEvent

type NotificationEvent struct {
	ScriptHash util.Uint160     `json:"contract"`
	Name       string           `json:"eventname"`
	Item       *stackitem.Array `json:"state"`
}

NotificationEvent is a tuple of the scripthash that has emitted the Item as a notification and the item itself.

func (*NotificationEvent) DecodeBinary

func (ne *NotificationEvent) DecodeBinary(r *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*NotificationEvent) EncodeBinary

func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the Serializable interface.

func (*NotificationEvent) EncodeBinaryWithContext

func (ne *NotificationEvent) EncodeBinaryWithContext(w *io.BinWriter, sc *stackitem.SerializationContext)

EncodeBinaryWithContext is the same as EncodeBinary, but allows to efficiently reuse stack item serialization context.

func (NotificationEvent) MarshalJSON

func (ne NotificationEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*NotificationEvent) UnmarshalJSON

func (ne *NotificationEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type OracleRequest

type OracleRequest struct {
	OriginalTxID     util.Uint256
	GasForResponse   uint64
	URL              string
	Filter           *string
	CallbackContract util.Uint160
	CallbackMethod   string
	UserData         []byte
}

OracleRequest represents an oracle request.

func (*OracleRequest) FromStackItem

func (o *OracleRequest) FromStackItem(it stackitem.Item) error

FromStackItem implements stackitem.Convertible interface.

func (*OracleRequest) ToStackItem

func (o *OracleRequest) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible interface. It never returns an error.

type StorageItem

type StorageItem []byte

StorageItem is the value to be stored with read-only flag.

type TokenTransferInfo

type TokenTransferInfo struct {
	LastUpdated map[int32]uint32
	// NextNEP11Batch stores the index of the next NEP-11 transfer batch.
	NextNEP11Batch uint32
	// NextNEP17Batch stores the index of the next NEP-17 transfer batch.
	NextNEP17Batch uint32
	// NextNEP11NewestTimestamp stores the block timestamp of the first NEP-11 transfer in raw.
	NextNEP11NewestTimestamp uint64
	// NextNEP17NewestTimestamp stores the block timestamp of the first NEP-17 transfer in raw.
	NextNEP17NewestTimestamp uint64
	// NewNEP11Batch is true if batch with the `NextNEP11Batch` index should be created.
	NewNEP11Batch bool
	// NewNEP17Batch is true if batch with the `NextNEP17Batch` index should be created.
	NewNEP17Batch bool
}

TokenTransferInfo stores a map of the contract IDs to the balance's last updated block trackers along with the information about NEP-17 and NEP-11 transfer batch.

func NewTokenTransferInfo

func NewTokenTransferInfo() *TokenTransferInfo

NewTokenTransferInfo returns new TokenTransferInfo.

func (*TokenTransferInfo) DecodeBinary

func (bs *TokenTransferInfo) DecodeBinary(r *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*TokenTransferInfo) EncodeBinary

func (bs *TokenTransferInfo) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the io.Serializable interface.

type TokenTransferLog

type TokenTransferLog struct {
	Raw []byte
	// contains filtered or unexported fields
}

TokenTransferLog is a serialized log of token transfers.

func (*TokenTransferLog) Append

func (lg *TokenTransferLog) Append(tr io.Serializable) error

Append appends a single transfer to a log.

func (*TokenTransferLog) ForEachNEP11

func (lg *TokenTransferLog) ForEachNEP11(f func(*NEP11Transfer) (bool, error)) (bool, error)

ForEachNEP11 iterates over a transfer log returning on the first error.

func (*TokenTransferLog) ForEachNEP17

func (lg *TokenTransferLog) ForEachNEP17(f func(*NEP17Transfer) (bool, error)) (bool, error)

ForEachNEP17 iterates over a transfer log returning on the first error.

func (*TokenTransferLog) Reset

func (lg *TokenTransferLog) Reset()

Reset resets the state of the log, clearing all entries, but keeping existing buffer for future writes.

func (*TokenTransferLog) Size

func (lg *TokenTransferLog) Size() int

Size returns the amount of the transfer written in the log.

type Validator

type Validator struct {
	Key   *keys.PublicKey
	Votes *big.Int
}

Validator holds the state of a validator (its key and votes balance).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL