contract

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContractNotFound = errors.New("contract not found")
)

Functions

func CallContract

func CallContract(ps Process, addr, entry Reader, argb Reader) int

func ECRecover

func ECRecover(ps Process, h, v, r, s Reader, ret Writer) int

func ECRecoverAddress

func ECRecoverAddress(ps Process, h, v, r, s Reader, ret Writer) int

func GetArg

func GetArg(ps Process, idx, offset int, buf Writer) int

func GetSender

func GetSender(ps Process, w Writer) int

func Log

func Log(ps Process, msg Reader) int

func Read

func Read(ps Process, id, offset int, buf Writer) int

func ReadState

func ReadState(ps Process, key Reader, offset int, buf Writer) int

func SetResponse

func SetResponse(ps Process, val Reader) int

func WriteState

func WriteState(ps Process, key, val Reader) int

Types

type Args

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

func DeserializeArgs

func DeserializeArgs(b []byte) (Args, error)

DeserializeArgs returns args bytes format is <elem_num: 4byte>|<elem1_size: 4byte>|<elem1_data>|<elem2_size: 4byte>|<elem2_data>|...

func NewArgs

func NewArgs(bs [][]byte) Args

func NewArgsFromStrings

func NewArgsFromStrings(ss []string) Args

func (Args) Get

func (a Args) Get(idx int) []byte

func (*Args) Len

func (a *Args) Len() int

func (*Args) PushBytes

func (a *Args) PushBytes(b []byte)

func (*Args) PushString

func (a *Args) PushString(s string)

type Contract

type Contract struct {
	Owner common.Address
	Code  []byte
}

func TxToContract

func TxToContract(tx *transaction.ContractDeployTx) *Contract

func (*Contract) Address

func (c *Contract) Address() common.Address

func (*Contract) Bytes

func (c *Contract) Bytes() []byte

func (*Contract) Decode

func (c *Contract) Decode(b []byte) error

func (*Contract) Encode

func (c *Contract) Encode() ([]byte, error)

type ContractManager

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

func NewContractManager

func NewContractManager(mp ContractMapper) *ContractManager

func (*ContractManager) DeployContract

func (cm *ContractManager) DeployContract(ctx types.Context, tx *transaction.ContractDeployTx) (common.Address, error)

func (*ContractManager) GetContract

func (cm *ContractManager) GetContract(ctx types.Context, addr common.Address) (*Contract, error)

func (*ContractManager) SaveContract

func (cm *ContractManager) SaveContract(ctx types.Context, addr common.Address, c *Contract) error

type ContractMapper

type ContractMapper interface {
	Put(ctx types.Context, addr common.Address, c *Contract)
	Get(ctx types.Context, addr common.Address) (*Contract, error)
}

func NewContractMapper

func NewContractMapper(storeKey types.StoreKey) ContractMapper

type Env

type Env struct {
	Context sdk.Context
	Logger  logger.Logger
	Sender  common.Address
	Args    Args

	EnvManager *EnvManager
	Contract   *Contract
	VMProvider VMProvider

	DB *db.VersionedDB
	// contains filtered or unexported fields
}

func (*Env) Exec

func (env *Env) Exec(ctx sdk.Context, entry string) (*Result, error)

func (*Env) GetReponse

func (env *Env) GetReponse() []byte

func (*Env) SetResponse

func (env *Env) SetResponse(v []byte)

type EnvManager

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

func NewEnvManager

func NewEnvManager(key sdk.StoreKey, cm ContractMapper) *EnvManager

func (*EnvManager) Get

func (em *EnvManager) Get(ctx sdk.Context, sender, addr common.Address, args Args) (*Env, error)

type Process

type Process interface {
	Logger() logger.Logger
	Sender() common.Address
	Args() Args
	State() db.StateDB
	SetResponse([]byte)
	Call(addr common.Address, entry []byte, args Args) (int, error)
	Read(id int) ([]byte, error)
	ValueTable() ValueTable
}

func NewProcess

func NewProcess(vm *exec.VirtualMachine, env *Env, logger logger.Logger, vt ValueTable) Process

NewProcess create a new process

type Reader

type Reader interface {
	Len() int
	Read() []byte
}

func NewReader

func NewReader(mem []byte, pos, len int64) Reader

type Resolver

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

func NewResolver

func NewResolver(env *Env) *Resolver

func (*Resolver) ResolveFunc

func (r *Resolver) ResolveFunc(module, field string) exec.FunctionImport

ResolveFunc defines a set of import functions that may be called within a WebAssembly module.

func (*Resolver) ResolveGlobal

func (r *Resolver) ResolveGlobal(module, field string) int64

ResolveGlobal defines a set of global variables for use within a WebAssembly module.

type Result

type Result struct {
	Code     int32
	Response []byte
	RWSets   *db.RWSets
}

type VM

type VM struct {
	*exec.VirtualMachine
}

func DefaultVMProvider

func DefaultVMProvider(env *Env) (*VM, error)

type VMProvider

type VMProvider func(*Env) (*VM, error)

type ValueTable

type ValueTable interface {
	Get(id int) ([]byte, error)
	Put(v []byte) (int, error)
}

ValueTable manages values that external contract returns.

type Writer

type Writer interface {
	Len() int
	Write([]byte) int
}

func NewWriter

func NewWriter(mem []byte, pos, len int64) Writer

Jump to

Keyboard shortcuts

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