Documentation
¶
Index ¶
- Variables
- type Context
- type DefaultImportsAsyncCall
- type DefaultImportsChainOperation
- type DefaultImportsContext
- type DefaultImportsEventType
- type DefaultImportsKVStore
- type DefaultImportsMQTT
- type DefaultImportsMetrics
- type DefaultImportsResource
- type DefaultImportsSQL
- type DefaultImportsSystem
- func (l *DefaultImportsSystem) Abort(msg, filename string, line, col int32)
- func (l *DefaultImportsSystem) Env(key string) (string, bool)
- func (l *DefaultImportsSystem) FlushLog()
- func (l *DefaultImportsSystem) Log(level consts.LogLevel, msg string)
- func (l *DefaultImportsSystem) LogInternal(level consts.LogLevel, msg string, args ...any)
- func (l *DefaultImportsSystem) Seed() float64
- func (l *DefaultImportsSystem) Trace(msg string, trace string)
- type Exports
- type Function
- type ImportsAsyncCall
- type ImportsChainOperation
- type ImportsContext
- type ImportsEventType
- type ImportsHandler
- type ImportsKVStore
- type ImportsMQTT
- type ImportsMetrics
- type ImportsResource
- type ImportsSQL
- type ImportsSystem
- type Instance
- type Module
- type VM
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
Name() string
GetImports() ImportsHandler
SetImports(ImportsHandler)
GetExports() Exports
GetInstance() Instance
SetInstance(Instance)
OnCreated(Instance)
OnDestroy(Instance)
}
type DefaultImportsAsyncCall ¶
type DefaultImportsAsyncCall struct{}
func (*DefaultImportsAsyncCall) AsyncAPICall ¶
func (*DefaultImportsAsyncCall) AsyncAPICall(req []byte) ([]byte, error)
type DefaultImportsChainOperation ¶
type DefaultImportsChainOperation struct{}
func (*DefaultImportsChainOperation) CallContract ¶
func (*DefaultImportsChainOperation) CallContract(chainID uint32, data []byte) ([]byte, error)
func (*DefaultImportsChainOperation) SendTX ¶
func (*DefaultImportsChainOperation) SendTX(chainID uint32, data []byte) (string, error)
func (*DefaultImportsChainOperation) SendTXWithOperator ¶
func (*DefaultImportsChainOperation) SendTXWithOperator(chainID uint32, data []byte) (string, error)
type DefaultImportsContext ¶
type DefaultImportsContext struct {
// contains filtered or unexported fields
}
func NewDefaultImportsContext ¶
func NewDefaultImportsContext() *DefaultImportsContext
func (*DefaultImportsContext) ContextID ¶
func (c *DefaultImportsContext) ContextID() string
func (*DefaultImportsContext) Entry ¶
func (c *DefaultImportsContext) Entry(cid string) bool
func (*DefaultImportsContext) Leave ¶
func (c *DefaultImportsContext) Leave(cid string) bool
type DefaultImportsEventType ¶
type DefaultImportsEventType struct {
}
func (*DefaultImportsEventType) GetEventType ¶
func (v *DefaultImportsEventType) GetEventType(uint32) (string, bool)
func (*DefaultImportsEventType) RemoveEventType ¶
func (v *DefaultImportsEventType) RemoveEventType(uint32)
func (*DefaultImportsEventType) SetEventType ¶
func (v *DefaultImportsEventType) SetEventType(uint32, string) error
type DefaultImportsKVStore ¶
type DefaultImportsKVStore struct{}
type DefaultImportsMQTT ¶
type DefaultImportsMQTT struct{}
type DefaultImportsMetrics ¶
type DefaultImportsMetrics struct{}
func (*DefaultImportsMetrics) SubmitMetrics ¶
func (*DefaultImportsMetrics) SubmitMetrics(data []byte) error
type DefaultImportsResource ¶
type DefaultImportsResource struct {
}
func (*DefaultImportsResource) GetResourceData ¶
func (v *DefaultImportsResource) GetResourceData(uint32) ([]byte, bool)
func (*DefaultImportsResource) RemoveResourceData ¶
func (v *DefaultImportsResource) RemoveResourceData(uint32)
func (*DefaultImportsResource) SetResourceData ¶
func (v *DefaultImportsResource) SetResourceData(uint32, []byte) error
type DefaultImportsSQL ¶
type DefaultImportsSQL struct{}
func (*DefaultImportsSQL) ExecSQL ¶
func (*DefaultImportsSQL) ExecSQL(string) error
type DefaultImportsSystem ¶
type DefaultImportsSystem struct {
// contains filtered or unexported fields
}
func (*DefaultImportsSystem) Abort ¶
func (l *DefaultImportsSystem) Abort(msg, filename string, line, col int32)
func (*DefaultImportsSystem) FlushLog ¶
func (l *DefaultImportsSystem) FlushLog()
func (*DefaultImportsSystem) Log ¶
func (l *DefaultImportsSystem) Log(level consts.LogLevel, msg string)
func (*DefaultImportsSystem) LogInternal ¶
func (l *DefaultImportsSystem) LogInternal(level consts.LogLevel, msg string, args ...any)
func (*DefaultImportsSystem) Seed ¶
func (l *DefaultImportsSystem) Seed() float64
func (*DefaultImportsSystem) Trace ¶
func (l *DefaultImportsSystem) Trace(msg string, trace string)
type ImportsAsyncCall ¶
type ImportsChainOperation ¶
type ImportsChainOperation interface {
// SendTX send tx by chain id and data, returns tx hash and error
SendTX(chainID uint32, data []byte) (string, error)
// SendTXWithOperator
SendTXWithOperator(chainID uint32, data []byte) (string, error)
// CallContract call contract by chain id and data, returns call result
CallContract(chainID uint32, data []byte) ([]byte, error)
}
type ImportsContext ¶
type ImportsEventType ¶
type ImportsHandler ¶
type ImportsHandler interface {
ImportsSystem
ImportsContext
ImportsResource
ImportsEventType
ImportsKVStore
ImportsSQL
ImportsChainOperation
ImportsMQTT
ImportsMetrics
ImportsAsyncCall
}
func NewDefaultImports ¶
func NewDefaultImports() ImportsHandler
type ImportsKVStore ¶
type ImportsMQTT ¶
type ImportsMetrics ¶
type ImportsResource ¶
type ImportsResource interface {
// GetResourceData get resource data by resource id
GetResourceData(rid uint32) ([]byte, bool)
// SetResourceData set resource data by resource id
SetResourceData(rid uint32, data []byte) error
// RemoveResourceData remove resource data by resource id
RemoveResourceData(rid uint32)
}
type ImportsSQL ¶
type ImportsSystem ¶
type ImportsSystem interface {
// Log host log
Log(level consts.LogLevel, msg string)
// LogInternal
LogInternal(level consts.LogLevel, msg string, args ...any)
// FlushLog
FlushLog()
// Env get env var by key
Env(key string) (string, bool)
// Abort
Abort(msg, filename string, line, col int32)
// Trace is reserved for imported func env.trace() which is auto-generated by assembly-script
Trace(msg string, trace string)
// Seed is reserved for imported func env.seed() which is auto-generated by assembly-script
Seed() float64
}
type Instance ¶
type Instance interface {
ID() string
// RegisterImports
RegisterImports(name string) error
// Start starts wasm instance
Start() error
// Stop stops wasm instance
Stop()
// Started returns if instance is started
Started() bool
// GetModule get current wasm module
GetModule() Module
// GetExportsFunc returns the exported func of the wasm instance by name
GetExportsFunc(name string) (Function, error)
// GetExportsMem returns the exported memory of the wasm instance
GetExportsMem(name string) ([]byte, error)
// GetByte returns the wasm byte from the specified addr
GetByte(addr int32) (byte, error)
// PutByte set a wasm byte to specified addr
PutByte(addr int32, v byte) error
// GetUint32 returns the u32 value from the specified addr
GetUint32(addr int32) (uint32, error)
// PutUint32 sets u32 value to the specified addr
PutUint32(addr int32, v uint32) error
// GetMemory returns wasm memory
GetMemory(addr int32, size int32) ([]byte, error)
// PutMemory
PutMemory(addr int32, size int32, data []byte) error
// Malloc allocates size of memory from wasm default memory
Malloc(size int32) (int32, error)
// GetUserdata get user-defined data
GetUserdata() any
// SetUserdata set user-define data into wasm instance
SetUserdata(any)
// Lock gets the exclusive ownership of the wasm instance and sets userdata
Lock(any)
// Unlock releases the exclusive ownership of the wasm instance and unref userdata
Unlock()
// Acquire increases the refer count of wasm instance
Acquire() bool
// Release decreases the refer count of wasm instance
Release()
// Call wasm function with name and args, returns wasm return value, fuel consumed, and error
Call(string, ...interface{}) (interface{}, uint64, error)
HandleError(error)
}
Instance defines the wasm instance
type Module ¶
type Module interface {
// Init was invoked when creating a wasm module
Init()
// NewInstance instantiates a wasm vm instance
NewInstance() Instance
// GetABINameList returns the abi name list exported from wasm module
GetABINameList() []string
}
Module defines interface of the wasm module
type VM ¶
type VM interface {
ID() string
// Name the name of the wasm vm
Name() string
// Init was invoked when creating a new wasm vm
Init()
// NewModule compile user code into a wasm module
NewModule(code []byte) (Module, error)
// Close to prevent from memory leaking
Close() error
}
VM defines interface of the wasm virtual machine(engine)
Click to show internal directories.
Click to hide internal directories.