Documentation ¶
Index ¶
- Constants
- func CodeToHashValue(code []byte) *interpreter.ArrayValue
- func ExportType(t sema.Type, results map[sema.TypeID]cadence.Type) cadence.Type
- func FormatErrorMessage(message string, useColor bool) string
- func PrettyPrintError(err error, filename string, code string, useColor bool) string
- type Address
- type AddressLocation
- type Block
- type BlockHash
- type BlockValue
- func (v BlockValue) Copy() interpreter.Value
- func (BlockValue) DynamicType(*interpreter.Interpreter) interpreter.DynamicType
- func (v BlockValue) GetMember(_ *interpreter.Interpreter, _ interpreter.LocationRange, name string) interpreter.Value
- func (BlockValue) GetOwner() *common.Address
- func (v BlockValue) IDAsByteArray() [stdlib.BlockIDSize]byte
- func (BlockValue) IsModified() bool
- func (BlockValue) IsValue()
- func (v BlockValue) SetMember(_ *interpreter.Interpreter, _ interpreter.LocationRange, _ string, ...)
- func (BlockValue) SetModified(_ bool)
- func (BlockValue) SetOwner(_ *common.Address)
- func (v BlockValue) String() string
- type Cache
- type CacheEntry
- type ComputationLimitExceededError
- 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)
- func (i *EmptyRuntimeInterface) GenerateUUID() uint64
- 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
- func (i *EmptyRuntimeInterface) GetSigningAccounts() []Address
- func (i *EmptyRuntimeInterface) GetValue(_, _ []byte) (value []byte, err error)
- func (i *EmptyRuntimeInterface) Hash(_ []byte, _ string) []byte
- func (i *EmptyRuntimeInterface) Log(_ string)
- 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
- func (i *EmptyRuntimeInterface) SetValue(_, _, _ []byte) error
- func (i *EmptyRuntimeInterface) UnsafeRandom() uint64
- 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
- type Error
- type FileLocation
- type HighLevelStorage
- type Identifier
- type ImportResolver
- type Interface
- type InvalidEntryPointArgumentError
- type InvalidEntryPointParameterCountError
- type InvalidScriptReturnTypeError
- type InvalidTransactionAuthorizerCountError
- type InvalidTransactionCountError
- type InvalidTypeAssignmentError
- type Location
- type LocationID
- type Metrics
- type Option
- type ParsingCheckingError
- type REPL
- type REPLLocation
- type REPLSuggestion
- type ResolvedLocation
- type Runtime
- type ScriptLocation
- type ScriptParameterTypeNotStorableError
- type StorageKey
- type StringLocation
- type TransactionLocation
- type TypeID
Constants ¶
const ( IdentifierLocationPrefix = ast.IdentifierLocationPrefix StringLocationPrefix = ast.StringLocationPrefix AddressLocationPrefix = ast.AddressLocationPrefix TransactionLocationPrefix = "t" ScriptLocationPrefix = "s" )
const BlockHashLength = 32
Variables ¶
This section is empty.
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 FormatErrorMessage ¶
Types ¶
type AddressLocation ¶
type AddressLocation = ast.AddressLocation
type BlockHash ¶ added in v0.3.0
type BlockHash [BlockHashLength]byte
type BlockValue ¶
type BlockValue struct { Height interpreter.UInt64Value View interpreter.UInt64Value ID *interpreter.ArrayValue Timestamp interpreter.Fix64Value }
func NewBlockValue ¶ added in v0.2.0
func NewBlockValue(block Block) BlockValue
func (BlockValue) Copy ¶
func (v BlockValue) Copy() interpreter.Value
func (BlockValue) DynamicType ¶
func (BlockValue) DynamicType(*interpreter.Interpreter) interpreter.DynamicType
func (BlockValue) GetMember ¶
func (v BlockValue) GetMember(_ *interpreter.Interpreter, _ interpreter.LocationRange, name string) interpreter.Value
func (BlockValue) GetOwner ¶
func (BlockValue) GetOwner() *common.Address
func (BlockValue) IDAsByteArray ¶ added in v0.2.0
func (v BlockValue) IDAsByteArray() [stdlib.BlockIDSize]byte
func (BlockValue) IsModified ¶ added in v0.3.0
func (BlockValue) IsModified() bool
func (BlockValue) IsValue ¶
func (BlockValue) IsValue()
func (BlockValue) SetMember ¶
func (v BlockValue) SetMember(_ *interpreter.Interpreter, _ interpreter.LocationRange, _ string, _ interpreter.Value)
func (BlockValue) SetModified ¶ added in v0.3.0
func (BlockValue) SetModified(_ bool)
func (BlockValue) SetOwner ¶
func (BlockValue) SetOwner(_ *common.Address)
func (BlockValue) String ¶
func (v BlockValue) String() string
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 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)
func (*EmptyRuntimeInterface) GenerateUUID ¶
func (i *EmptyRuntimeInterface) GenerateUUID() uint64
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
func (*EmptyRuntimeInterface) GetSigningAccounts ¶
func (i *EmptyRuntimeInterface) GetSigningAccounts() []Address
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
func (*EmptyRuntimeInterface) Log ¶
func (i *EmptyRuntimeInterface) Log(_ string)
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
func (*EmptyRuntimeInterface) SetValue ¶
func (i *EmptyRuntimeInterface) SetValue(_, _, _ []byte) error
func (*EmptyRuntimeInterface) UnsafeRandom ¶ added in v0.5.0
func (i *EmptyRuntimeInterface) UnsafeRandom() uint64
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)
func (*EmptyRuntimeInterface) VerifySignature ¶ added in v0.5.0
type Error ¶
type Error struct {
Err error
}
Error is the containing type for all errors produced by the runtime.
type FileLocation ¶
type FileLocation string
func (FileLocation) ID ¶
func (l FileLocation) ID() ast.LocationID
func (FileLocation) QualifiedIdentifier ¶ added in v0.10.2
func (l FileLocation) QualifiedIdentifier(typeID TypeID) string
func (FileLocation) String ¶
func (l FileLocation) String() string
func (FileLocation) TypeID ¶ added in v0.10.2
func (l FileLocation) TypeID(qualifiedIdentifier string) TypeID
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 Interface ¶
type Interface interface { // ResolveLocation resolves an import location. ResolveLocation(identifiers []Identifier, location Location) []ResolvedLocation // 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 // Log logs a string. Log(string) // EmitEvent is called when an event is emitted by the runtime. EmitEvent(cadence.Event) // 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 // GetComputationLimit returns the computation limit. A value <= 0 means there is no limit GetComputationLimit() uint64 // 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 // 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 // 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 // Hash returns the digest of hashing the given data with using the given hash algorithm Hash(data []byte, hashAlgorithm string) []byte }
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 LocationID ¶
type LocationID = ast.LocationID
type ParsingCheckingError ¶ added in v0.9.3
type ParsingCheckingError struct { Err error StorageCache Cache Code []byte Location 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) 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 REPLLocation ¶
type REPLLocation struct{}
func (REPLLocation) ID ¶
func (l REPLLocation) ID() LocationID
func (REPLLocation) QualifiedIdentifier ¶ added in v0.10.2
func (l REPLLocation) QualifiedIdentifier(typeID TypeID) string
func (REPLLocation) String ¶
func (l REPLLocation) String() string
func (REPLLocation) TypeID ¶ added in v0.10.2
func (l REPLLocation) TypeID(qualifiedIdentifier string) TypeID
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 []byte, arguments [][]byte, runtimeInterface Interface, location Location) (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 []byte, arguments [][]byte, runtimeInterface Interface, location Location) 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(code []byte, runtimeInterface Interface, location Location) (*sema.Checker, error) }
Runtime is a runtime capable of executing Cadence.
func NewInterpreterRuntime ¶
NewInterpreterRuntime returns a interpreter-based version of the Flow runtime.
type ScriptLocation ¶
type ScriptLocation []byte
func (ScriptLocation) ID ¶
func (l ScriptLocation) ID() ast.LocationID
func (ScriptLocation) QualifiedIdentifier ¶ added in v0.10.2
func (l ScriptLocation) QualifiedIdentifier(typeID TypeID) string
func (ScriptLocation) String ¶
func (l ScriptLocation) String() string
func (ScriptLocation) TypeID ¶ added in v0.10.2
func (l ScriptLocation) TypeID(qualifiedIdentifier string) TypeID
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 StringLocation ¶
type StringLocation = ast.StringLocation
type TransactionLocation ¶
type TransactionLocation []byte
func (TransactionLocation) ID ¶
func (l TransactionLocation) ID() ast.LocationID
func (TransactionLocation) QualifiedIdentifier ¶ added in v0.10.2
func (l TransactionLocation) QualifiedIdentifier(typeID TypeID) string
func (TransactionLocation) String ¶
func (l TransactionLocation) String() string
func (TransactionLocation) TypeID ¶ added in v0.10.2
func (l TransactionLocation) TypeID(qualifiedIdentifier string) TypeID