interop

package
v0.90.1-pre Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Chain         blockchainer.Blockchainer
	Container     crypto.Verifiable
	Natives       []Contract
	Trigger       trigger.Type
	Block         *block.Block
	Tx            *transaction.Transaction
	DAO           *dao.Cached
	Notifications []state.NotificationEvent
	Log           *zap.Logger
	Invocations   map[util.Uint160]int
}

Context represents context in which interops are executed.

func NewContext

func NewContext(trigger trigger.Type, bc blockchainer.Blockchainer, d dao.DAO, natives []Contract, block *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context

NewContext returns new interop context.

type Contract

type Contract interface {
	Initialize(*Context) error
	Metadata() *ContractMD
}

Contract is an interface for all native contracts.

type ContractMD

type ContractMD struct {
	Manifest    manifest.Manifest
	ServiceName string
	ServiceID   uint32
	ContractID  int32
	Script      []byte
	Hash        util.Uint160
	Methods     map[string]MethodAndPrice
}

ContractMD represents native contract instance.

func NewContractMD

func NewContractMD(name string) *ContractMD

NewContractMD returns Contract with the specified list of methods.

func (*ContractMD) AddEvent

func (c *ContractMD) AddEvent(name string, ps ...manifest.Parameter)

AddEvent adds new event to a native contract.

func (*ContractMD) AddMethod

func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method, safe bool)

AddMethod adds new method to a native contract.

type Function

type Function struct {
	ID    uint32
	Name  string
	Func  func(*Context, *vm.VM) error
	Price int64
	// AllowedTriggers is a set of triggers which are allowed to initiate invocation.
	AllowedTriggers trigger.Type
	// RequiredFlags is a set of flags which must be set during script invocations.
	// Default value is NoneFlag i.e. no flags are required.
	RequiredFlags smartcontract.CallFlag
}

Function binds function name, id with the function itself and price, it's supposed to be inited once for all interopContexts, so it doesn't use vm.InteropFuncPrice directly.

type Method

type Method = func(ic *Context, args []stackitem.Item) stackitem.Item

Method is a signature for a native method.

type MethodAndPrice

type MethodAndPrice struct {
	Func          Method
	Price         int64
	RequiredFlags smartcontract.CallFlag
}

MethodAndPrice is a native-contract method descriptor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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