Documentation
¶
Overview ¶
Package api provides the interfaces for the virtual machine that executes smart contracts. This package defines the API between the blockchain and the VM, but is not directly used by smart contracts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BuildParams = []string{"build", "-o", "contract.wasm", "-target", "wasi", "-opt", "z", "-no-debug", "./"}
View Source
var Builder = "tinygo"
Functions ¶
This section is empty.
Types ¶
type ContractConfig ¶
type ContractConfig struct { // MaxGas is the maximum amount of gas that can be used by a contract MaxGas uint64 // MaxCallDepth is the maximum depth of contract calls MaxCallDepth uint8 // MaxCodeSize is the maximum size of contract code in bytes MaxCodeSize uint64 // AllowedImports contains the packages that can be imported by contracts AllowedImports []string }
ContractConfig defines configuration for contract validation and execution
type IContractConfigGenerator ¶
type IContractConfigGenerator func() ContractConfig
var DefaultContractConfig IContractConfigGenerator = func() ContractConfig { return ContractConfig{ MaxGas: 1000000, MaxCallDepth: 8, MaxCodeSize: 1024 * 1024, AllowedImports: []string{ "github.com/govm-net/vm/core", }, } }
type IGoModGenerator ¶
type IKeywordValidator ¶
var DefaultKeywordValidator IKeywordValidator = func(node ast.Node) error { if node == nil { return nil } switch n := node.(type) { case *ast.EmptyStmt: if n.Implicit { return fmt.Errorf("restricted keyword ';' is not allowed") } case *ast.IfStmt: if n.Init != nil { return fmt.Errorf("semicolon in if statement initialization is not allowed") } case *ast.ForStmt: if n.Init != nil { return fmt.Errorf("semicolon in for statement initialization is not allowed") } case *ast.GoStmt: return fmt.Errorf("restricted keyword 'go' is not allowed") case *ast.SelectStmt: return fmt.Errorf("restricted keyword 'select' is not allowed") case *ast.RangeStmt: return fmt.Errorf("restricted keyword 'range' is not allowed") case *ast.ChanType: return fmt.Errorf("restricted keyword 'chan' is not allowed") case *ast.CallExpr: if ident, ok := node.(*ast.CallExpr).Fun.(*ast.Ident); ok && ident.Name == "recover" { return fmt.Errorf("restricted keyword 'recover' is not allowed") } } return nil }
Click to show internal directories.
Click to hide internal directories.