policy

package
v0.99.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package policy allows to work with the native PolicyContract contract via RPC.

Safe methods are encapsulated into ContractReader structure while Contract provides various methods to perform PolicyContract state-changing calls.

Index

Constants

This section is empty.

Variables

Hash stores the hash of the native PolicyContract contract.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	Invoker

	MakeCall(contract util.Uint160, method string, params ...interface{}) (*transaction.Transaction, error)
	MakeRun(script []byte) (*transaction.Transaction, error)
	MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...interface{}) (*transaction.Transaction, error)
	MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
	SendCall(contract util.Uint160, method string, params ...interface{}) (util.Uint256, uint32, error)
	SendRun(script []byte) (util.Uint256, uint32, error)
}

Actor is used by Contract to create and send transactions.

type Contract

type Contract struct {
	ContractReader
	// contains filtered or unexported fields
}

Contract represents a PolicyContract contract client that can be used to invoke all of its methods.

func New

func New(actor Actor) *Contract

New creates an instance of Contract to perform actions using the given Actor. Notice that PolicyContract's state can be changed only by the network's committee, so the Actor provided must be a committee actor for all methods to work properly.

func (*Contract) BlockAccount

func (c *Contract) BlockAccount(account util.Uint160) (util.Uint256, uint32, error)

BlockAccount creates and sends a transaction that blocks an account on the network (via `blockAccount` method), it fails (with FAULT state) if it's not successful. The returned values are transaction hash, its ValidUntilBlock value and an error if any.

func (*Contract) BlockAccountTransaction

func (c *Contract) BlockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)

BlockAccountTransaction creates a transaction that blocks an account on the network and checks for the result of the appropriate call, failing the transaction if it's not true. This transaction is signed, but not sent to the network, instead it's returned to the caller.

func (*Contract) BlockAccountUnsigned

func (c *Contract) BlockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)

BlockAccountUnsigned creates a transaction that blocks an account on the network and checks for the result of the appropriate call, failing the transaction if it's not true. This transaction is not signed and just returned to the caller.

func (*Contract) SetExecFeeFactor

func (c *Contract) SetExecFeeFactor(value int64) (util.Uint256, uint32, error)

SetExecFeeFactor creates and sends a transaction that sets the new execution fee factor for the network to use. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.

func (*Contract) SetExecFeeFactorTransaction

func (c *Contract) SetExecFeeFactorTransaction(value int64) (*transaction.Transaction, error)

SetExecFeeFactorTransaction creates a transaction that sets the new execution fee factor. This transaction is signed, but not sent to the network, instead it's returned to the caller.

func (*Contract) SetExecFeeFactorUnsigned

func (c *Contract) SetExecFeeFactorUnsigned(value int64) (*transaction.Transaction, error)

SetExecFeeFactorUnsigned creates a transaction that sets the new execution fee factor. This transaction is not signed and just returned to the caller.

func (*Contract) SetFeePerByte

func (c *Contract) SetFeePerByte(value int64) (util.Uint256, uint32, error)

SetFeePerByte creates and sends a transaction that sets the new minimal per-byte network fee value. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.

func (*Contract) SetFeePerByteTransaction

func (c *Contract) SetFeePerByteTransaction(value int64) (*transaction.Transaction, error)

SetFeePerByteTransaction creates a transaction that sets the new minimal per-byte network fee value. This transaction is signed, but not sent to the network, instead it's returned to the caller.

func (*Contract) SetFeePerByteUnsigned

func (c *Contract) SetFeePerByteUnsigned(value int64) (*transaction.Transaction, error)

SetFeePerByteUnsigned creates a transaction that sets the new minimal per-byte network fee value. This transaction is not signed and just returned to the caller.

func (*Contract) SetStoragePrice

func (c *Contract) SetStoragePrice(value int64) (util.Uint256, uint32, error)

SetStoragePrice creates and sends a transaction that sets the storage price for contracts. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.

func (*Contract) SetStoragePriceTransaction

func (c *Contract) SetStoragePriceTransaction(value int64) (*transaction.Transaction, error)

SetStoragePriceTransaction creates a transaction that sets the storage price for contracts. This transaction is signed, but not sent to the network, instead it's returned to the caller.

func (*Contract) SetStoragePriceUnsigned

func (c *Contract) SetStoragePriceUnsigned(value int64) (*transaction.Transaction, error)

SetStoragePriceUnsigned creates a transaction that sets the storage price for contracts. This transaction is not signed and just returned to the caller.

func (*Contract) UnblockAccount

func (c *Contract) UnblockAccount(account util.Uint160) (util.Uint256, uint32, error)

UnblockAccount creates and sends a transaction that removes previously blocked account from the stop list. It uses `unblockAccount` method and checks for the result returned, failing the transaction if it's not true. The returned values are transaction hash, its ValidUntilBlock value and an error if any.

func (*Contract) UnblockAccountTransaction

func (c *Contract) UnblockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)

UnblockAccountTransaction creates a transaction that unblocks previously blocked account via `unblockAccount` method and checks for the result returned, failing the transaction if it's not true. This transaction is signed, but not sent to the network, instead it's returned to the caller.

func (*Contract) UnblockAccountUnsigned

func (c *Contract) UnblockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)

UnblockAccountUnsigned creates a transaction that unblocks the given account if it was blocked previously. It uses `unblockAccount` method and checks for its return value, failing the transaction if it's not true. This transaction is not signed and just returned to the caller.

type ContractReader

type ContractReader struct {
	// contains filtered or unexported fields
}

ContractReader provides an interface to call read-only PolicyContract contract's methods.

func NewReader

func NewReader(invoker Invoker) *ContractReader

NewReader creates an instance of ContractReader that can be used to read data from the contract.

func (*ContractReader) GetExecFeeFactor

func (c *ContractReader) GetExecFeeFactor() (int64, error)

GetExecFeeFactor returns current execution fee factor used by the network. This setting affects all executions of all transactions.

func (*ContractReader) GetFeePerByte

func (c *ContractReader) GetFeePerByte() (int64, error)

GetFeePerByte returns current minimal per-byte network fee value which affects all transactions on the network.

func (*ContractReader) GetStoragePrice

func (c *ContractReader) GetStoragePrice() (int64, error)

GetStoragePrice returns current per-byte storage price. Any contract saving data to the storage pays for it according to this value.

func (*ContractReader) IsBlocked

func (c *ContractReader) IsBlocked(account util.Uint160) (bool, error)

IsBlocked checks if the given account is blocked in the PolicyContract.

type Invoker

type Invoker interface {
	Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)
}

Invoker is used by ContractReader to call various methods.

Jump to

Keyboard shortcuts

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