Documentation
¶
Index ¶
- Constants
- Variables
- func CodeToHashValue(code []byte) *interpreter.ArrayValue
- func ExportType(t sema.Type, results map[sema.TypeID]cadence.Type) cadence.Type
- func ExportValue(value interpreter.Value, inter *interpreter.Interpreter) cadence.Value
- func LiteralValue(expression ast.Expression, ty sema.Type) (cadence.Value, error)
- func NewBlockValue(block Block) interpreter.BlockValue
- func ParseLiteral(literal string, ty sema.Type) (cadence.Value, error)
- type Address
- type Block
- type BlockHash
- type Cache
- type CacheEntry
- type ComputationLimitExceededError
- type Context
- type CoverageReport
- type EmptyRuntimeInterface
- func (i *EmptyRuntimeInterface) AddAccountKey(_ Address, _ []byte) error
- func (i *EmptyRuntimeInterface) CacheProgram(_ Location, _ *ast.Program) error
- func (i *EmptyRuntimeInterface) CreateAccount(_ Address) (address Address, err error)
- func (i *EmptyRuntimeInterface) DecodeArgument(_ []byte, _ cadence.Type) (cadence.Value, error)
- func (i *EmptyRuntimeInterface) EmitEvent(_ cadence.Event) error
- func (i *EmptyRuntimeInterface) GenerateUUID() (uint64, error)
- func (i *EmptyRuntimeInterface) GetAccountContractCode(_ Address, _ string) (code []byte, err error)
- func (i *EmptyRuntimeInterface) GetBlockAtHeight(_ uint64) (block Block, exists bool, err error)
- func (i *EmptyRuntimeInterface) GetCachedProgram(_ Location) (*ast.Program, error)
- func (i *EmptyRuntimeInterface) GetCode(_ Location) ([]byte, error)
- func (i *EmptyRuntimeInterface) GetComputationLimit() uint64
- func (i *EmptyRuntimeInterface) GetCurrentBlockHeight() (uint64, error)
- func (i *EmptyRuntimeInterface) GetSigningAccounts() ([]Address, error)
- func (i EmptyRuntimeInterface) GetStorageCapacity(_ Address) (uint64, error)
- func (i EmptyRuntimeInterface) GetStorageUsed(_ Address) (uint64, error)
- func (i *EmptyRuntimeInterface) GetValue(_, _ []byte) (value []byte, err error)
- func (i *EmptyRuntimeInterface) Hash(_ []byte, _ string) ([]byte, error)
- func (i *EmptyRuntimeInterface) Log(_ string) error
- func (i *EmptyRuntimeInterface) RemoveAccountContractCode(_ Address, _ string) (err error)
- func (i *EmptyRuntimeInterface) RemoveAccountKey(_ Address, _ int) (publicKey []byte, err error)
- func (i *EmptyRuntimeInterface) ResolveLocation(identifiers []Identifier, location Location) ([]ResolvedLocation, error)
- func (i *EmptyRuntimeInterface) SetComputationUsed(uint64) error
- func (i *EmptyRuntimeInterface) SetValue(_, _, _ []byte) error
- func (i *EmptyRuntimeInterface) UnsafeRandom() (uint64, error)
- func (i *EmptyRuntimeInterface) UpdateAccountCode(_ Address, _ []byte) error
- func (i *EmptyRuntimeInterface) UpdateAccountContractCode(_ Address, _ string, _ []byte) (err error)
- func (i *EmptyRuntimeInterface) ValueExists(_, _ []byte) (exists bool, err error)
- func (i *EmptyRuntimeInterface) VerifySignature(_ []byte, _ string, _ []byte, _ []byte, _ string, _ string) (bool, error)
- type Error
- type HighLevelStorage
- type Identifier
- type ImportResolver
- type Interface
- type InvalidContractDeploymentError
- type InvalidContractDeploymentOriginError
- type InvalidEntryPointArgumentError
- type InvalidEntryPointParameterCountError
- type InvalidScriptReturnTypeError
- type InvalidTransactionAuthorizerCountError
- type InvalidTransactionCountError
- type InvalidTypeAssignmentError
- type Location
- type LocationCoverage
- type Metrics
- type Option
- type ParsingCheckingError
- type REPL
- type REPLSuggestion
- type ResolvedLocation
- type Runtime
- type Script
- type ScriptParameterTypeNotStorableError
- type StorageKey
- type ValueDeclaration
- func (v ValueDeclaration) ValueDeclarationArgumentLabels() []string
- func (v ValueDeclaration) ValueDeclarationAvailable(location common.Location) bool
- func (v ValueDeclaration) ValueDeclarationIsConstant() bool
- func (v ValueDeclaration) ValueDeclarationKind() common.DeclarationKind
- func (v ValueDeclaration) ValueDeclarationName() string
- func (v ValueDeclaration) ValueDeclarationPosition() ast.Position
- func (v ValueDeclaration) ValueDeclarationType() sema.Type
- func (v ValueDeclaration) ValueDeclarationValue() interpreter.Value
Constants ¶
const BlockHashLength = 32
Variables ¶
var InvalidLiteralError = fmt.Errorf("invalid literal")
var LiteralExpressionTypeError = fmt.Errorf("input is not a literal")
var UnsupportedLiteralError = fmt.Errorf("unsupported literal")
Functions ¶
func CodeToHashValue ¶ added in v0.2.0
func CodeToHashValue(code []byte) *interpreter.ArrayValue
func ExportType ¶ added in v0.11.0
ExportType converts a runtime type to its corresponding Go representation.
func ExportValue ¶ added in v0.12.0
func ExportValue(value interpreter.Value, inter *interpreter.Interpreter) cadence.Value
ExportValue converts a runtime value to its native Go representation.
func LiteralValue ¶ added in v0.12.0
func NewBlockValue ¶ added in v0.2.0
func NewBlockValue(block Block) interpreter.BlockValue
Types ¶
type BlockHash ¶ added in v0.3.0
type BlockHash [BlockHashLength]byte
type Cache ¶ added in v0.9.3
type Cache map[StorageKey]CacheEntry
type CacheEntry ¶ added in v0.9.3
type CacheEntry struct {
// true indicates that the value definitely must be written, independent of the value.
// false indicates that the value may has to be written if the value is modified.
MustWrite bool
Value interpreter.Value
}
type ComputationLimitExceededError ¶ added in v0.2.0
type ComputationLimitExceededError struct {
Limit uint64
}
func (ComputationLimitExceededError) Error ¶ added in v0.2.0
func (e ComputationLimitExceededError) Error() string
type Context ¶ added in v0.12.0
type Context struct {
Interface Interface
Location Location
PredeclaredValues []ValueDeclaration
// contains filtered or unexported fields
}
type CoverageReport ¶ added in v0.12.0
type CoverageReport struct {
Coverage map[common.LocationID]*LocationCoverage `json:"coverage"`
}
CoverageReport is a collection of coverage per location
func NewCoverageReport ¶ added in v0.12.0
func NewCoverageReport() *CoverageReport
func (*CoverageReport) AddLineHit ¶ added in v0.12.0
func (r *CoverageReport) AddLineHit(location common.Location, line int)
type EmptyRuntimeInterface ¶
type EmptyRuntimeInterface struct{}
func (*EmptyRuntimeInterface) AddAccountKey ¶
func (i *EmptyRuntimeInterface) AddAccountKey(_ Address, _ []byte) error
func (*EmptyRuntimeInterface) CacheProgram ¶ added in v0.2.0
func (i *EmptyRuntimeInterface) CacheProgram(_ Location, _ *ast.Program) error
func (*EmptyRuntimeInterface) CreateAccount ¶
func (i *EmptyRuntimeInterface) CreateAccount(_ Address) (address Address, err error)
func (*EmptyRuntimeInterface) DecodeArgument ¶ added in v0.2.0
func (*EmptyRuntimeInterface) EmitEvent ¶
func (i *EmptyRuntimeInterface) EmitEvent(_ cadence.Event) error
func (*EmptyRuntimeInterface) GenerateUUID ¶
func (i *EmptyRuntimeInterface) GenerateUUID() (uint64, error)
func (*EmptyRuntimeInterface) GetAccountContractCode ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) GetAccountContractCode(_ Address, _ string) (code []byte, err error)
func (*EmptyRuntimeInterface) GetBlockAtHeight ¶ added in v0.3.0
func (i *EmptyRuntimeInterface) GetBlockAtHeight(_ uint64) (block Block, exists bool, err error)
func (*EmptyRuntimeInterface) GetCachedProgram ¶ added in v0.2.0
func (i *EmptyRuntimeInterface) GetCachedProgram(_ Location) (*ast.Program, error)
func (*EmptyRuntimeInterface) GetCode ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) GetCode(_ Location) ([]byte, error)
func (*EmptyRuntimeInterface) GetComputationLimit ¶ added in v0.2.0
func (i *EmptyRuntimeInterface) GetComputationLimit() uint64
func (*EmptyRuntimeInterface) GetCurrentBlockHeight ¶ added in v0.3.0
func (i *EmptyRuntimeInterface) GetCurrentBlockHeight() (uint64, error)
func (*EmptyRuntimeInterface) GetSigningAccounts ¶
func (i *EmptyRuntimeInterface) GetSigningAccounts() ([]Address, error)
func (EmptyRuntimeInterface) GetStorageCapacity ¶ added in v0.10.3
func (i EmptyRuntimeInterface) GetStorageCapacity(_ Address) (uint64, error)
func (EmptyRuntimeInterface) GetStorageUsed ¶ added in v0.10.3
func (i EmptyRuntimeInterface) GetStorageUsed(_ Address) (uint64, error)
func (*EmptyRuntimeInterface) GetValue ¶
func (i *EmptyRuntimeInterface) GetValue(_, _ []byte) (value []byte, err error)
func (*EmptyRuntimeInterface) Hash ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) Hash( _ []byte, _ string, ) ([]byte, error)
func (*EmptyRuntimeInterface) Log ¶
func (i *EmptyRuntimeInterface) Log(_ string) error
func (*EmptyRuntimeInterface) RemoveAccountContractCode ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) RemoveAccountContractCode(_ Address, _ string) (err error)
func (*EmptyRuntimeInterface) RemoveAccountKey ¶
func (i *EmptyRuntimeInterface) RemoveAccountKey(_ Address, _ int) (publicKey []byte, err error)
func (*EmptyRuntimeInterface) ResolveLocation ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) ResolveLocation(identifiers []Identifier, location Location) ([]ResolvedLocation, error)
func (*EmptyRuntimeInterface) SetComputationUsed ¶ added in v0.10.4
func (i *EmptyRuntimeInterface) SetComputationUsed(uint64) error
func (*EmptyRuntimeInterface) SetValue ¶
func (i *EmptyRuntimeInterface) SetValue(_, _, _ []byte) error
func (*EmptyRuntimeInterface) UnsafeRandom ¶ added in v0.5.0
func (i *EmptyRuntimeInterface) UnsafeRandom() (uint64, error)
func (*EmptyRuntimeInterface) UpdateAccountCode ¶
func (i *EmptyRuntimeInterface) UpdateAccountCode(_ Address, _ []byte) error
func (*EmptyRuntimeInterface) UpdateAccountContractCode ¶ added in v0.10.0
func (i *EmptyRuntimeInterface) UpdateAccountContractCode(_ Address, _ string, _ []byte) (err error)
func (*EmptyRuntimeInterface) ValueExists ¶
func (i *EmptyRuntimeInterface) ValueExists(_, _ []byte) (exists bool, err error)
type HighLevelStorage ¶ added in v0.6.0
type HighLevelStorage interface {
Interface
// HighLevelStorageEnabled should return true
// if the functions of HighLevelStorage should be called,
// e.g. SetCadenceValue
HighLevelStorageEnabled() bool
// SetCadenceValue sets a value for the given key in the storage, owned by the given account.
SetCadenceValue(owner Address, key string, value cadence.Value) (err error)
}
type Identifier ¶ added in v0.10.0
type Identifier = ast.Identifier
type ImportResolver ¶
type Interface ¶
type Interface interface {
// ResolveLocation resolves an import location.
ResolveLocation(identifiers []Identifier, location Location) ([]ResolvedLocation, error)
// GetCode returns the code at a given location
GetCode(location Location) ([]byte, error)
// GetCachedProgram attempts to get a parsed program from a cache.
GetCachedProgram(Location) (*ast.Program, error)
// CacheProgram adds a parsed program to a cache.
CacheProgram(Location, *ast.Program) error
// GetValue gets a value for the given key in the storage, owned by the given account.
GetValue(owner, key []byte) (value []byte, err error)
// SetValue sets a value for the given key in the storage, owned by the given account.
SetValue(owner, key, value []byte) (err error)
// CreateAccount creates a new account.
CreateAccount(payer Address) (address Address, err error)
// AddAccountKey appends a key to an account.
AddAccountKey(address Address, publicKey []byte) error
// RemoveAccountKey removes a key from an account by index.
RemoveAccountKey(address Address, index int) (publicKey []byte, err error)
// UpdateAccountContractCode updates the code associated with an account contract.
UpdateAccountContractCode(address Address, name string, code []byte) (err error)
// GetAccountContractCode returns the code associated with an account contract.
GetAccountContractCode(address Address, name string) (code []byte, err error)
// RemoveAccountContractCode removes the code associated with an account contract.
RemoveAccountContractCode(address Address, name string) (err error)
// GetSigningAccounts returns the signing accounts.
GetSigningAccounts() ([]Address, error)
// Log logs a string.
Log(string) error
// EmitEvent is called when an event is emitted by the runtime.
EmitEvent(cadence.Event) error
// ValueExists returns true if the given key exists in the storage, owned by the given account.
ValueExists(owner, key []byte) (exists bool, err error)
// GenerateUUID is called to generate a UUID.
GenerateUUID() (uint64, error)
// GetComputationLimit returns the computation limit. A value <= 0 means there is no limit
GetComputationLimit() uint64
// SetComputationUsed reports the amount of computation used.
SetComputationUsed(used uint64) error
// DecodeArgument decodes a transaction argument against the given type.
DecodeArgument(argument []byte, argumentType cadence.Type) (cadence.Value, error)
// GetCurrentBlockHeight returns the current block height.
GetCurrentBlockHeight() (uint64, error)
// GetBlockAtHeight returns the block at the given height.
GetBlockAtHeight(height uint64) (block Block, exists bool, err error)
// UnsafeRandom returns a random uint64, where the process of random number derivation is not cryptographically
// secure.
UnsafeRandom() (uint64, error)
// VerifySignature returns true if the given signature was produced by signing the given tag + data
// using the given public key, signature algorithm, and hash algorithm.
VerifySignature(
signature []byte,
tag string,
signedData []byte,
publicKey []byte,
signatureAlgorithm string,
hashAlgorithm string,
) (bool, error)
// Hash returns the digest of hashing the given data with using the given hash algorithm
Hash(data []byte, hashAlgorithm string) ([]byte, error)
// GetStorageUsed gets storage used in bytes by the address at the moment of the function call.
GetStorageUsed(address Address) (value uint64, err error)
// GetStorageCapacity gets storage capacity in bytes on the address.
GetStorageCapacity(address Address) (value uint64, err error)
}
type InvalidContractDeploymentError ¶ added in v0.12.1
type InvalidContractDeploymentError struct {
Err error
interpreter.LocationRange
}
InvalidContractDeploymentError
func (*InvalidContractDeploymentError) ChildErrors ¶ added in v0.12.1
func (e *InvalidContractDeploymentError) ChildErrors() []error
func (*InvalidContractDeploymentError) Error ¶ added in v0.12.1
func (e *InvalidContractDeploymentError) Error() string
func (*InvalidContractDeploymentError) Unwrap ¶ added in v0.12.1
func (e *InvalidContractDeploymentError) Unwrap() error
type InvalidContractDeploymentOriginError ¶ added in v0.12.1
type InvalidContractDeploymentOriginError struct {
interpreter.LocationRange
}
InvalidContractDeploymentOriginError
func (*InvalidContractDeploymentOriginError) Error ¶ added in v0.12.1
func (*InvalidContractDeploymentOriginError) Error() string
type InvalidEntryPointArgumentError ¶ added in v0.5.0
func (*InvalidEntryPointArgumentError) Error ¶ added in v0.5.0
func (e *InvalidEntryPointArgumentError) Error() string
func (*InvalidEntryPointArgumentError) Unwrap ¶ added in v0.5.0
func (e *InvalidEntryPointArgumentError) Unwrap() error
type InvalidEntryPointParameterCountError ¶ added in v0.5.0
func (InvalidEntryPointParameterCountError) Error ¶ added in v0.5.0
func (e InvalidEntryPointParameterCountError) Error() string
type InvalidScriptReturnTypeError ¶ added in v0.11.0
InvalidScriptReturnTypeError is an error that is reported for invalid script return types.
For example, the type `Int` is valid, whereas a function type is not, because it cannot be exported/serialized.
func (*InvalidScriptReturnTypeError) Error ¶ added in v0.11.0
func (e *InvalidScriptReturnTypeError) Error() string
type InvalidTransactionAuthorizerCountError ¶ added in v0.2.0
func (InvalidTransactionAuthorizerCountError) Error ¶ added in v0.2.0
func (e InvalidTransactionAuthorizerCountError) Error() string
type InvalidTransactionCountError ¶
type InvalidTransactionCountError struct {
Count int
}
func (InvalidTransactionCountError) Error ¶
func (e InvalidTransactionCountError) Error() string
type InvalidTypeAssignmentError ¶ added in v0.2.0
type InvalidTypeAssignmentError struct {
Value interpreter.Value
Type sema.Type
Err error
}
func (*InvalidTypeAssignmentError) Error ¶ added in v0.2.0
func (e *InvalidTypeAssignmentError) Error() string
func (*InvalidTypeAssignmentError) Unwrap ¶ added in v0.2.0
func (e *InvalidTypeAssignmentError) Unwrap() error
type LocationCoverage ¶ added in v0.12.0
LocationCoverage records coverage information for a location
func NewLocationCoverage ¶ added in v0.12.0
func NewLocationCoverage() *LocationCoverage
func (*LocationCoverage) AddLineHit ¶ added in v0.12.0
func (c *LocationCoverage) AddLineHit(line int)
type ParsingCheckingError ¶ added in v0.9.3
type ParsingCheckingError struct {
Err error
StorageCache Cache
Code []byte
Location common.Location
Options []sema.Option
UseCache bool
Program *ast.Program
Checker *sema.Checker
}
ParsingCheckingError provides extra information about the state of the environment when a parsing or a checking error occurred
func (*ParsingCheckingError) ChildErrors ¶ added in v0.9.3
func (e *ParsingCheckingError) ChildErrors() []error
func (*ParsingCheckingError) Error ¶ added in v0.9.3
func (e *ParsingCheckingError) Error() string
func (*ParsingCheckingError) ImportLocation ¶ added in v0.12.1
func (e *ParsingCheckingError) ImportLocation() common.Location
func (*ParsingCheckingError) Unwrap ¶ added in v0.9.3
func (e *ParsingCheckingError) Unwrap() error
type REPL ¶
type REPL struct {
// contains filtered or unexported fields
}
func (*REPL) Suggestions ¶
func (r *REPL) Suggestions() (result []REPLSuggestion)
type REPLSuggestion ¶ added in v0.2.0
type REPLSuggestion struct {
Name, Description string
}
type ResolvedLocation ¶ added in v0.10.0
type ResolvedLocation = sema.ResolvedLocation
type Runtime ¶
type Runtime interface {
// ExecuteScript executes the given script.
//
// This function returns an error if the program has errors (e.g syntax errors, type errors),
// or if the execution fails.
ExecuteScript(Script, Context) (cadence.Value, error)
// ExecuteTransaction executes the given transaction.
//
// This function returns an error if the program has errors (e.g syntax errors, type errors),
// or if the execution fails.
ExecuteTransaction(Script, Context) error
// ParseAndCheckProgram parses and checks the given code without executing the program.
//
// This function returns an error if the program contains any syntax or semantic errors.
ParseAndCheckProgram(source []byte, context Context) (*sema.Checker, error)
// SetCoverageReport activates reporting coverage in the given report.
// Passing nil disables coverage reporting (default).
//
SetCoverageReport(coverageReport *CoverageReport)
}
Runtime is a runtime capable of executing Cadence.
func NewInterpreterRuntime ¶
NewInterpreterRuntime returns a interpreter-based version of the Flow runtime.
type ScriptParameterTypeNotStorableError ¶ added in v0.8.0
ScriptParameterTypeNotStorableError is an error that is reported for script parameter types that are not storable.
For example, the type `Int` is a storable type, whereas a function type is not.
func (*ScriptParameterTypeNotStorableError) Error ¶ added in v0.8.0
func (e *ScriptParameterTypeNotStorableError) Error() string
type StorageKey ¶ added in v0.9.3
type ValueDeclaration ¶ added in v0.12.0
type ValueDeclaration struct {
Name string
Type sema.Type
Kind common.DeclarationKind
IsConstant bool
ArgumentLabels []string
Available func(common.Location) bool
Value interpreter.Value
}
func (ValueDeclaration) ValueDeclarationArgumentLabels ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationArgumentLabels() []string
func (ValueDeclaration) ValueDeclarationAvailable ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationAvailable(location common.Location) bool
func (ValueDeclaration) ValueDeclarationIsConstant ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationIsConstant() bool
func (ValueDeclaration) ValueDeclarationKind ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationKind() common.DeclarationKind
func (ValueDeclaration) ValueDeclarationName ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationName() string
func (ValueDeclaration) ValueDeclarationPosition ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationPosition() ast.Position
func (ValueDeclaration) ValueDeclarationType ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationType() sema.Type
func (ValueDeclaration) ValueDeclarationValue ¶ added in v0.12.0
func (v ValueDeclaration) ValueDeclarationValue() interpreter.Value
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
check
command
|
|
|
main
command
|
|
|
minifier
command
* Cadence - The resource-oriented smart contract programming language * * Copyright 2019-2020 Dapper Labs, Inc.
|
* Cadence - The resource-oriented smart contract programming language * * Copyright 2019-2020 Dapper Labs, Inc. |
|
parse
command
|
|
|
compiler
|
|
|
wasm
WebAssembly (https://webassembly.org/) is an open standard for portable executable programs.
|
WebAssembly (https://webassembly.org/) is an open standard for portable executable programs. |
|
tests
|
|