native

package
v0.90.0-pre Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 19 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deploy

func Deploy(ic *interop.Context, _ *vm.VM) error

Deploy deploys native contract.

func ModifyAccountVotes

func ModifyAccountVotes(acc *state.Account, d dao.DAO, value util.Fixed8) error

ModifyAccountVotes modifies votes of the specified account by value (can be negative).

Types

type Contract

type Contract interface {
	Metadata() *ContractMD
	OnPersist(*interop.Context) error
}

Contract is an interface for all native contracts.

type ContractMD

type ContractMD struct {
	Manifest    manifest.Manifest
	ServiceName string
	ServiceID   uint32
	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 Contracts

type Contracts struct {
	NEO       *NEO
	GAS       *GAS
	Contracts []Contract
}

Contracts is a set of registered native contracts.

func NewContracts

func NewContracts() *Contracts

NewContracts returns new empty set of native contracts.

func (*Contracts) Add

func (cs *Contracts) Add(c Contract)

Add adds new native contracts to the list.

func (*Contracts) ByHash

func (cs *Contracts) ByHash(h util.Uint160) Contract

ByHash returns native contract with the specified hash.

func (*Contracts) ByID

func (cs *Contracts) ByID(id uint32) Contract

ByID returns native contract with the specified id.

func (*Contracts) GetNativeInterop

func (cs *Contracts) GetNativeInterop(ic *interop.Context) func(uint32) *vm.InteropFuncPrice

GetNativeInterop returns an interop getter for a given set of contracts.

func (*Contracts) SetGAS

func (cs *Contracts) SetGAS(g *GAS)

SetGAS sets GAS native contract.

func (*Contracts) SetNEO

func (cs *Contracts) SetNEO(n *NEO)

SetNEO sets NEO native contract.

type GAS

type GAS struct {
	NEO *NEO
	// contains filtered or unexported fields
}

GAS represents GAS native contract.

func NewGAS

func NewGAS() *GAS

NewGAS returns GAS native contract.

func (*GAS) Decimals

func (c *GAS) Decimals(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*GAS) Initialize

func (g *GAS) Initialize(ic *interop.Context) error

Initialize initializes GAS contract.

func (*GAS) Metadata

func (c *GAS) Metadata() *ContractMD

func (*GAS) Name

func (c *GAS) Name(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*GAS) OnPersist

func (g *GAS) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*GAS) Symbol

func (c *GAS) Symbol(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*GAS) Transfer

func (c *GAS) Transfer(ic *interop.Context, args []vm.StackItem) vm.StackItem

type Method

type Method = func(ic *interop.Context, args []vm.StackItem) vm.StackItem

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.

type NEO

type NEO struct {
	GAS *GAS
	// contains filtered or unexported fields
}

NEO represents NEO native contract.

func NewNEO

func NewNEO() *NEO

NewNEO returns NEO native contract.

func (*NEO) Decimals

func (c *NEO) Decimals(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*NEO) GetNextBlockValidatorsInternal

func (n *NEO) GetNextBlockValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) ([]*keys.PublicKey, error)

GetNextBlockValidatorsInternal returns next block validators.

func (*NEO) GetValidatorsInternal

func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) ([]*keys.PublicKey, error)

GetValidatorsInternal returns a list of current validators.

func (*NEO) Initialize

func (n *NEO) Initialize(ic *interop.Context) error

Initialize initializes NEO contract.

func (*NEO) Metadata

func (c *NEO) Metadata() *ContractMD

func (*NEO) Name

func (c *NEO) Name(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*NEO) OnPersist

func (n *NEO) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*NEO) Symbol

func (c *NEO) Symbol(_ *interop.Context, _ []vm.StackItem) vm.StackItem

func (*NEO) Transfer

func (c *NEO) Transfer(ic *interop.Context, args []vm.StackItem) vm.StackItem

func (*NEO) VoteInternal

func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pubs keys.PublicKeys) error

VoteInternal votes from account h for validarors specified in pubs.

Jump to

Keyboard shortcuts

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