Documentation
¶
Index ¶
- Constants
- Variables
- func CodeToHashValue(inter *interpreter.Interpreter, code []byte) *interpreter.ArrayValue
- func DoNotValidatePublicKey(_ *interpreter.Interpreter, _ func() interpreter.LocationRange, ...) error
- func ExportMeteredType(gauge common.MemoryGauge, t sema.Type, results map[sema.TypeID]cadence.Type) cadence.Type
- func ExportType(t sema.Type, results map[sema.TypeID]cadence.Type) cadence.Type
- func ExportValue(value interpreter.Value, inter *interpreter.Interpreter, ...) (cadence.Value, error)
- func ImportType(memoryGauge common.MemoryGauge, t cadence.Type) interpreter.StaticType
- func LiteralValue(inter *interpreter.Interpreter, expression ast.Expression, ty sema.Type) (cadence.Value, error)
- func NewAccountKeyValue(inter *interpreter.Interpreter, ...) interpreter.Value
- func NewBlockValue(inter *interpreter.Interpreter, ...) interpreter.Value
- func NewPublicKeyValue(inter *interpreter.Interpreter, ...) *interpreter.CompositeValue
- func ParseLiteral(literal string, ty sema.Type, inter *interpreter.Interpreter) (cadence.Value, error)
- func ParseLiteralArgumentList(argumentList string, parameterTypes []sema.Type, ...) ([]cadence.Value, error)
- func SortContractUpdates(updates []ContractUpdate)
- type AccountKey
- type Address
- type ArgumentNotImportableError
- type Block
- type BlockHash
- type CallStackLimitExceededError
- type ConformanceMismatchError
- type Context
- type ContractNotFoundError
- type ContractRemovalError
- type ContractUpdate
- type ContractUpdateError
- type ContractUpdateValidator
- type CoverageReport
- type EnumCaseMismatchError
- type Error
- type Executor
- type ExtraneousFieldError
- type FieldMismatchError
- type HashAlgorithm
- type Identifier
- type ImportResolver
- type Interface
- type InvalidContractDeploymentError
- type InvalidContractDeploymentOriginError
- type InvalidDeclarationKindChangeError
- type InvalidEntryPointArgumentError
- type InvalidEntryPointParameterCountError
- type InvalidScriptReturnTypeError
- type InvalidTransactionAuthorizerCountError
- type InvalidTransactionCountError
- type InvalidValueTypeError
- type Location
- type LocationCoverage
- type MalformedValueError
- type Metrics
- type MissingDeclarationError
- type MissingEnumCasesError
- type Option
- type ParsingCheckingError
- type PublicKey
- type REPL
- type REPLSuggestion
- type ResolvedLocation
- type Runtime
- type Script
- type ScriptParameterTypeNotImportableError
- type ScriptParameterTypeNotStorableError
- type SignatureAlgorithm
- type Storage
- type TypeComparator
- func (c *TypeComparator) CheckConstantSizedTypeEquality(expected *ast.ConstantSizedType, found ast.Type) error
- func (c *TypeComparator) CheckDictionaryTypeEquality(expected *ast.DictionaryType, found ast.Type) error
- func (c *TypeComparator) CheckFunctionTypeEquality(expected *ast.FunctionType, found ast.Type) error
- func (c *TypeComparator) CheckInstantiationTypeEquality(expected *ast.InstantiationType, found ast.Type) error
- func (c *TypeComparator) CheckNominalTypeEquality(expected *ast.NominalType, found ast.Type) error
- func (c *TypeComparator) CheckOptionalTypeEquality(expected *ast.OptionalType, found ast.Type) error
- func (c *TypeComparator) CheckReferenceTypeEquality(expected *ast.ReferenceType, found ast.Type) error
- func (c *TypeComparator) CheckRestrictedTypeEquality(expected *ast.RestrictedType, found ast.Type) error
- func (c *TypeComparator) CheckVariableSizedTypeEquality(expected *ast.VariableSizedType, found ast.Type) error
- type TypeMismatchError
- type ValueDeclaration
- func (v ValueDeclaration) ValueDeclarationArgumentLabels() []string
- func (v ValueDeclaration) ValueDeclarationAvailable(location common.Location) bool
- func (v ValueDeclaration) ValueDeclarationDocString() string
- 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.Interpreter) interpreter.Value
Constants ¶
const ( // Supported signing algorithms SignatureAlgorithmUnknown = sema.SignatureAlgorithmUnknown SignatureAlgorithmECDSA_P256 = sema.SignatureAlgorithmECDSA_P256 SignatureAlgorithmECDSA_secp256k1 = sema.SignatureAlgorithmECDSA_secp256k1 SignatureAlgorithmBLS_BLS12_381 = sema.SignatureAlgorithmBLS_BLS12_381 )
const ( // Supported hashing algorithms HashAlgorithmUnknown = sema.HashAlgorithmUnknown HashAlgorithmSHA2_256 = sema.HashAlgorithmSHA2_256 HashAlgorithmSHA2_384 = sema.HashAlgorithmSHA2_384 HashAlgorithmSHA3_256 = sema.HashAlgorithmSHA3_256 HashAlgorithmSHA3_384 = sema.HashAlgorithmSHA3_384 HashAlgorithmKMAC128_BLS_BLS12_381 = sema.HashAlgorithmKMAC128_BLS_BLS12_381 HashAlgorithmKECCAK_256 = sema.HashAlgorithmKECCAK_256 )
const BlockHashLength = 32
const StorageDomainContract = "contract"
Variables ¶
var BlockIDStaticType = interpreter.ConstantSizedStaticType{ Type: interpreter.PrimitiveStaticTypeUInt8, Size: 32, }
var InvalidLiteralError = parser.NewUnpositionedSyntaxError("invalid literal")
var LiteralExpressionTypeError = parser.NewUnpositionedSyntaxError("input is not a literal")
var UnsupportedLiteralError = parser.NewUnpositionedSyntaxError("unsupported literal")
Functions ¶
func CodeToHashValue ¶ added in v0.2.0
func CodeToHashValue(inter *interpreter.Interpreter, code []byte) *interpreter.ArrayValue
func DoNotValidatePublicKey ¶ added in v0.23.0
func DoNotValidatePublicKey( _ *interpreter.Interpreter, _ func() interpreter.LocationRange, _ *interpreter.CompositeValue, ) error
DoNotValidatePublicKey conforms to the method signature for PublicKeyValidationHandlerFunc. It disregards its input and returns `nil` indicating that the public key is valid. It's used when handling public keys from the FVM, where they're already validated.
func ExportMeteredType ¶ added in v0.24.0
func ExportMeteredType( gauge common.MemoryGauge, t sema.Type, results map[sema.TypeID]cadence.Type, ) cadence.Type
ExportMeteredType converts a runtime type to its corresponding Go representation.
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, getLocationRange func() interpreter.LocationRange, ) (cadence.Value, error)
ExportValue converts a runtime value to its native Go representation.
func ImportType ¶ added in v0.24.0
func ImportType(memoryGauge common.MemoryGauge, t cadence.Type) interpreter.StaticType
func LiteralValue ¶ added in v0.12.0
func LiteralValue(inter *interpreter.Interpreter, expression ast.Expression, ty sema.Type) (cadence.Value, error)
func NewAccountKeyValue ¶ added in v0.14.0
func NewAccountKeyValue( inter *interpreter.Interpreter, getLocationRange func() interpreter.LocationRange, accountKey *AccountKey, validatePublicKey interpreter.PublicKeyValidationHandlerFunc, ) interpreter.Value
func NewBlockValue ¶ added in v0.2.0
func NewBlockValue( inter *interpreter.Interpreter, getLocationRange func() interpreter.LocationRange, block Block, ) interpreter.Value
func NewPublicKeyValue ¶ added in v0.14.0
func NewPublicKeyValue( inter *interpreter.Interpreter, getLocationRange func() interpreter.LocationRange, publicKey *PublicKey, validatePublicKey interpreter.PublicKeyValidationHandlerFunc, ) *interpreter.CompositeValue
func ParseLiteral ¶ added in v0.12.0
func ParseLiteral( literal string, ty sema.Type, inter *interpreter.Interpreter, ) ( cadence.Value, error, )
ParseLiteral parses a single literal string, that should have the given type.
Returns an error if the literal string is not a literal (e.g. it does not have valid syntax, or does not parse to a literal).
func ParseLiteralArgumentList ¶ added in v0.12.4
func ParseLiteralArgumentList( argumentList string, parameterTypes []sema.Type, inter *interpreter.Interpreter, ) ( []cadence.Value, error, )
ParseLiteralArgumentList parses an argument list with literals, that should have the given types. Returns an error if the code is not a valid argument list, or the arguments are not literals.
Note: This method is not used directly within Cadence, but used by downstream dependencies such as CLI, playground, etc. Hence, shouldn't be moved to test.
func SortContractUpdates ¶ added in v0.23.0
func SortContractUpdates(updates []ContractUpdate)
Types ¶
type AccountKey ¶ added in v0.14.0
type AccountKey struct {
KeyIndex int
PublicKey *PublicKey
HashAlgo HashAlgorithm
Weight int
IsRevoked bool
}
type ArgumentNotImportableError ¶ added in v0.18.0
type ArgumentNotImportableError struct {
Type interpreter.StaticType
}
ArgumentNotImportableError is an error that is reported for script arguments that belongs to non-importable types.
func (*ArgumentNotImportableError) Error ¶ added in v0.18.0
func (e *ArgumentNotImportableError) Error() string
func (*ArgumentNotImportableError) IsUserError ¶ added in v0.25.0
func (*ArgumentNotImportableError) IsUserError()
type BlockHash ¶ added in v0.3.0
type BlockHash [BlockHashLength]byte
type CallStackLimitExceededError ¶ added in v0.20.0
type CallStackLimitExceededError struct {
Limit uint64
}
func (CallStackLimitExceededError) Error ¶ added in v0.20.0
func (e CallStackLimitExceededError) Error() string
func (CallStackLimitExceededError) IsUserError ¶ added in v0.25.0
func (CallStackLimitExceededError) IsUserError()
type ConformanceMismatchError ¶ added in v0.13.0
ConformanceMismatchError is reported during a contract update, when the enum conformance of the new program does not match the existing one.
func (*ConformanceMismatchError) Error ¶ added in v0.13.0
func (e *ConformanceMismatchError) Error() string
func (*ConformanceMismatchError) IsUserError ¶ added in v0.25.0
func (*ConformanceMismatchError) IsUserError()
type Context ¶ added in v0.12.0
type Context struct {
Interface Interface
Location Location
PredeclaredValues []ValueDeclaration
CheckerOptions []sema.Option
// contains filtered or unexported fields
}
func (*Context) InitializeCodesAndPrograms ¶ added in v0.12.3
func (c *Context) InitializeCodesAndPrograms()
func (Context) SetProgram ¶ added in v0.12.3
type ContractNotFoundError ¶ added in v0.13.0
ContractNotFoundError is reported during a contract update, if no contract can be found in the program.
func (*ContractNotFoundError) Error ¶ added in v0.13.0
func (e *ContractNotFoundError) Error() string
func (*ContractNotFoundError) IsUserError ¶ added in v0.25.0
func (*ContractNotFoundError) IsUserError()
type ContractRemovalError ¶ added in v0.15.0
type ContractRemovalError struct {
Name string
interpreter.LocationRange
}
ContractRemovalError
func (*ContractRemovalError) Error ¶ added in v0.15.0
func (e *ContractRemovalError) Error() string
func (*ContractRemovalError) IsUserError ¶ added in v0.25.0
func (*ContractRemovalError) IsUserError()
type ContractUpdate ¶ added in v0.13.2
type ContractUpdate struct {
Key interpreter.StorageKey
ContractValue *interpreter.CompositeValue
}
type ContractUpdateError ¶ added in v0.13.0
ContractUpdateError is reported upon any invalid update to a contract or contract interface. It contains all the errors reported during the update validation.
func (*ContractUpdateError) ChildErrors ¶ added in v0.13.0
func (e *ContractUpdateError) ChildErrors() []error
func (*ContractUpdateError) Error ¶ added in v0.13.0
func (e *ContractUpdateError) Error() string
func (*ContractUpdateError) ImportLocation ¶ added in v0.13.0
func (e *ContractUpdateError) ImportLocation() common.Location
func (*ContractUpdateError) IsUserError ¶ added in v0.25.0
func (*ContractUpdateError) IsUserError()
type ContractUpdateValidator ¶ added in v0.13.0
type ContractUpdateValidator struct {
TypeComparator
// contains filtered or unexported fields
}
func NewContractUpdateValidator ¶ added in v0.13.0
func NewContractUpdateValidator( location Location, contractName string, oldProgram *ast.Program, newProgram *ast.Program, ) *ContractUpdateValidator
NewContractUpdateValidator initializes and returns a validator, without performing any validation. Invoke the `Validate()` method of the validator returned, to start validating the contract.
func (*ContractUpdateValidator) Validate ¶ added in v0.13.0
func (validator *ContractUpdateValidator) Validate() error
Validate validates the contract update, and returns an error if it is an invalid update.
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 EnumCaseMismatchError ¶ added in v0.15.0
EnumCaseMismatchError is reported during an enum update, when an updated enum case does not match the existing enum case.
func (*EnumCaseMismatchError) Error ¶ added in v0.15.0
func (e *EnumCaseMismatchError) Error() string
func (*EnumCaseMismatchError) IsUserError ¶ added in v0.25.0
func (*EnumCaseMismatchError) IsUserError()
type Error ¶
type Error struct {
Err error
Location common.Location
Codes map[common.Location]string
Programs map[common.Location]*ast.Program
}
Error is the containing type for all errors produced by the runtime.
type Executor ¶ added in v0.25.0
type Executor interface {
// Preprocess prepares the transaction/script for execution.
//
// This function returns an error if the program has errors (e.g., syntax
// errors, type errors).
//
// This method may be called multiple times. Only the first call will
// trigger meaningful work; subsequent calls will return the cached return
// value from the original call (i.e., an Executor implementation must
// guard this method with sync.Once).
Preprocess() error
// Execute executes the transaction/script.
//
// This function returns an error if Preprocess failed or if the execution
// fails.
//
// This method may be called multiple times. Only the first call will
// trigger meaningful work; subsequent calls will return the cached return
// value from the original call (i.e., an Executor implementation must
// guard this method with sync.Once).
//
// Note: Execute will invoke Preprocess to ensure Preprocess was called at
// least once.
Execute() error
// Result returns the transaction/scipt's execution result.
//
// This function returns an error if Preproces or Execute fails. The
// cadence.Value is always nil for transaction.
//
// This method may be called multiple times. Only the first call will
// trigger meaningful work; subsequent calls will return the cached return
// value from the original call (i.e., an Executor implementation must
// guard this method with sync.Once).
//
// Note: Result will invoke Execute to ensure Execute was called at least
// once.
Result() (cadence.Value, error)
}
Executor is a continuation which represents a full unit of transaction/script execution.
The full unit of execution is divided into stages:
- Preprocess() initializes the executor in preparation for the actual transaction execution (e.g., parse / type check the input). Note that the work done by Preprocess() should be embrassingly parallel.
- Execute() performs the actual transaction execution (e.g., run the interpreter to produce the transaction result).
- Result() returns the result of the full unit of execution.
TODO: maybe add Cleanup/Postprocess in the future
type ExtraneousFieldError ¶ added in v0.13.0
ExtraneousFieldError is reported during a contract update, when an updated composite declaration has more fields than the existing declaration.
func (*ExtraneousFieldError) Error ¶ added in v0.13.0
func (e *ExtraneousFieldError) Error() string
func (*ExtraneousFieldError) IsUserError ¶ added in v0.25.0
func (*ExtraneousFieldError) IsUserError()
type FieldMismatchError ¶ added in v0.13.0
FieldMismatchError is reported during a contract update, when a type of a field does not match the existing type of the same field.
func (*FieldMismatchError) Error ¶ added in v0.13.0
func (e *FieldMismatchError) Error() string
func (*FieldMismatchError) IsUserError ¶ added in v0.25.0
func (*FieldMismatchError) IsUserError()
func (*FieldMismatchError) SecondaryError ¶ added in v0.13.0
func (e *FieldMismatchError) SecondaryError() string
type HashAlgorithm ¶ added in v0.14.0
type HashAlgorithm = sema.HashAlgorithm
func NewHashAlgorithmFromValue ¶ added in v0.14.0
func NewHashAlgorithmFromValue( inter *interpreter.Interpreter, getLocationRange func() interpreter.LocationRange, value interpreter.Value, ) HashAlgorithm
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)
// GetProgram returns the program for the given location, if available.
//
// NOTE:
//
// For implementations:
// - During execution, this function MUST always return the *same* program,
// i.e. it may NOT return a different program,
// an elaboration in the program that is not annotating the AST in the program;
// or a program/elaboration and then nothing in a subsequent call.
// - This function MUST also return what was set using SetProgram,
// it may NOT return something different or nothing/nil (!) after SetProgram was called.
// Do NOT implement this as a cache!
//
// For uses:
// - ONLY call this function when a program must be parsed and checked,
// as an optimization to reuse the result of a potential previous parse and check.
// - If GetProgram returns nil, Cadence MUST call SetProgram:
// There's an informal contract between Cadence and the implementer:
// Cadence calls GetProgram to potentially avoid having to parse and check a program.
// If the implementer returns nil from GetProgram,
// it expects that Cadence sets the resulting parsed and checked program with SetProgram.
// - The behaviour after GetProgram returning nil or a program must be always deterministic:
// As SetProgram is called when GetProgram is nil, then SetProgram MUST also be called when
// GetProgram returns a program. This prevents nondeterministic behaviour
//
// Deprecated: This function should be refactored to ensure that SetProgram is always called
//
GetProgram(Location) (*interpreter.Program, error)
// SetProgram sets the program for the given location.
SetProgram(Location, *interpreter.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)
// ValueExists returns true if the given key exists in the storage, owned by the given account.
ValueExists(owner, key []byte) (exists bool, err error)
// AllocateStorageIndex allocates a new storage index under the given account.
AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
// CreateAccount creates a new account.
CreateAccount(payer Address) (address Address, err error)
// AddEncodedAccountKey appends an encoded key to an account.
AddEncodedAccountKey(address Address, publicKey []byte) error
// RevokeEncodedAccountKey removes a key from an account by index, add returns the encoded key.
RevokeEncodedAccountKey(address Address, index int) (publicKey []byte, err error)
// AddAccountKey appends a key to an account.
AddAccountKey(address Address, publicKey *PublicKey, hashAlgo HashAlgorithm, weight int) (*AccountKey, error)
// GetAccountKey retrieves a key from an account by index.
GetAccountKey(address Address, index int) (*AccountKey, error)
// RevokeAccountKey removes a key from an account by index.
RevokeAccountKey(address Address, index int) (*AccountKey, 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)
// ProgramLog logs program logs.
ProgramLog(string) error
// EmitEvent is called when an event is emitted by the runtime.
EmitEvent(cadence.Event) error
// GenerateUUID is called to generate a UUID.
GenerateUUID() (uint64, error)
// MeterComputation is a callback method for metering computation, it returns error
// when computation passes the limit (set by the environment)
MeterComputation(operationType common.ComputationKind, intensity uint) 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 SignatureAlgorithm,
hashAlgorithm HashAlgorithm,
) (bool, error)
// Hash returns the digest of hashing the given data with using the given hash algorithm
Hash(data []byte, tag string, hashAlgorithm HashAlgorithm) ([]byte, error)
// GetAccountBalance gets accounts default flow token balance.
GetAccountBalance(address common.Address) (value uint64, err error)
// GetAccountAvailableBalance gets accounts default flow token balance - balance that is reserved for storage.
GetAccountAvailableBalance(address common.Address) (value uint64, err 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)
// ImplementationDebugLog logs implementation log statements on a debug-level
ImplementationDebugLog(message string) error
// ValidatePublicKey verifies the validity of a public key.
ValidatePublicKey(key *PublicKey) error
// GetAccountContractNames returns the names of all contracts deployed in an account.
GetAccountContractNames(address Address) ([]string, error)
// RecordTrace records a opentelemetry trace.
RecordTrace(operation string, location common.Location, duration time.Duration, attrs []attribute.KeyValue)
// BLSVerifyPOP verifies a proof of possession (PoP) for the receiver public key.
BLSVerifyPOP(pk *PublicKey, s []byte) (bool, error)
// BLSAggregateSignatures aggregate multiple BLS signatures into one.
BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
// BLSAggregatePublicKeys aggregate multiple BLS public keys into one.
BLSAggregatePublicKeys(keys []*PublicKey) (*PublicKey, error)
// ResourceOwnerChanged gets called when a resource's owner changed (if enabled)
ResourceOwnerChanged(
interpreter *interpreter.Interpreter,
resource *interpreter.CompositeValue,
oldOwner common.Address,
newOwner common.Address,
)
// MeterMemory gets called when new memory is allocated or used by the interpreter
MeterMemory(usage common.MemoryUsage) 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) IsUserError ¶ added in v0.25.0
func (*InvalidContractDeploymentError) IsUserError()
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
func (*InvalidContractDeploymentOriginError) IsUserError ¶ added in v0.25.0
func (*InvalidContractDeploymentOriginError) IsUserError()
type InvalidDeclarationKindChangeError ¶ added in v0.13.0
type InvalidDeclarationKindChangeError struct {
Name string
OldKind common.DeclarationKind
NewKind common.DeclarationKind
ast.Range
}
InvalidDeclarationKindChangeError is reported during a contract update, when an attempt is made to convert an existing contract to a contract interface, or vise versa.
func (*InvalidDeclarationKindChangeError) Error ¶ added in v0.13.0
func (e *InvalidDeclarationKindChangeError) Error() string
func (*InvalidDeclarationKindChangeError) IsUserError ¶ added in v0.25.0
func (*InvalidDeclarationKindChangeError) IsUserError()
type InvalidEntryPointArgumentError ¶ added in v0.5.0
InvalidEntryPointArgumentError
func (*InvalidEntryPointArgumentError) Error ¶ added in v0.5.0
func (e *InvalidEntryPointArgumentError) Error() string
func (*InvalidEntryPointArgumentError) IsUserError ¶ added in v0.25.0
func (*InvalidEntryPointArgumentError) IsUserError()
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
func (InvalidEntryPointParameterCountError) IsUserError ¶ added in v0.25.0
func (InvalidEntryPointParameterCountError) IsUserError()
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
func (*InvalidScriptReturnTypeError) IsUserError ¶ added in v0.25.0
func (*InvalidScriptReturnTypeError) IsUserError()
type InvalidTransactionAuthorizerCountError ¶ added in v0.2.0
func (InvalidTransactionAuthorizerCountError) Error ¶ added in v0.2.0
func (e InvalidTransactionAuthorizerCountError) Error() string
func (InvalidTransactionAuthorizerCountError) IsUserError ¶ added in v0.25.0
func (InvalidTransactionAuthorizerCountError) IsUserError()
type InvalidTransactionCountError ¶
type InvalidTransactionCountError struct {
Count int
}
func (InvalidTransactionCountError) Error ¶
func (e InvalidTransactionCountError) Error() string
func (InvalidTransactionCountError) IsUserError ¶ added in v0.25.0
func (InvalidTransactionCountError) IsUserError()
type InvalidValueTypeError ¶ added in v0.15.0
InvalidValueTypeError
func (*InvalidValueTypeError) Error ¶ added in v0.15.0
func (e *InvalidValueTypeError) Error() string
func (*InvalidValueTypeError) IsUserError ¶ added in v0.25.0
func (*InvalidValueTypeError) IsUserError()
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 MalformedValueError ¶ added in v0.15.0
func (*MalformedValueError) Error ¶ added in v0.15.0
func (e *MalformedValueError) Error() string
func (*MalformedValueError) IsUserError ¶ added in v0.25.0
func (*MalformedValueError) IsUserError()
type MissingDeclarationError ¶ added in v0.21.2
type MissingDeclarationError struct {
Name string
Kind common.DeclarationKind
ast.Range
}
MissingDeclarationError is reported during a contract update, if an existing declaration is removed.
func (*MissingDeclarationError) Error ¶ added in v0.21.2
func (e *MissingDeclarationError) Error() string
func (*MissingDeclarationError) IsUserError ¶ added in v0.25.0
func (*MissingDeclarationError) IsUserError()
type MissingEnumCasesError ¶ added in v0.15.0
MissingEnumCasesError is reported during an enum update, if any enum cases are removed from an existing enum.
func (*MissingEnumCasesError) Error ¶ added in v0.15.0
func (e *MissingEnumCasesError) Error() string
func (*MissingEnumCasesError) IsUserError ¶ added in v0.25.0
func (*MissingEnumCasesError) IsUserError()
type Option ¶ added in v0.5.0
type Option func(Runtime)
func WithAtreeValidationEnabled ¶ added in v0.20.0
WithAtreeValidationEnabled returns a runtime option that configures if atree validation is enabled.
func WithContractUpdateValidationEnabled ¶ added in v0.13.2
WithContractUpdateValidationEnabled returns a runtime option that configures if contract update validation is enabled.
func WithInvalidatedResourceValidationEnabled ¶ added in v0.24.0
WithInvalidatedResourceValidationEnabled returns a runtime option that configures if invalidated resource validation is enabled.
func WithResourceOwnerChangeCallbackEnabled ¶ added in v0.24.0
WithResourceOwnerChangeCallbackEnabled returns a runtime option that configures if the resource owner change callback is enabled.
func WithTracingEnabled ¶ added in v0.23.0
WithTracingEnabled returns a runtime option that configures if tracing is enabled.
type ParsingCheckingError ¶ added in v0.9.3
ParsingCheckingError is an error wrapper for a parsing or a checking error at a specific location
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) IsUserError ¶ added in v0.25.0
func (*ParsingCheckingError) IsUserError()
func (*ParsingCheckingError) Unwrap ¶ added in v0.9.3
func (e *ParsingCheckingError) Unwrap() error
type PublicKey ¶ added in v0.14.0
type PublicKey struct {
PublicKey []byte
SignAlgo SignatureAlgorithm
}
func NewPublicKeyFromValue ¶ added in v0.14.0
func NewPublicKeyFromValue( inter *interpreter.Interpreter, getLocationRange func() interpreter.LocationRange, publicKey interpreter.MemberAccessibleValue, ) ( *PublicKey, 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 {
// NewScriptExecutor returns an executor which executes the given script.
NewScriptExecutor(Script, Context) Executor
// 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)
// NewTransactionExecutor returns an executor which executes the given
// transaction.
NewTransactionExecutor(Script, Context) Executor
// 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
// NewContractFunctionExecutor returns an executor which invokes a contract
// function with the given arguments.
NewContractFunctionExecutor(
contractLocation common.AddressLocation,
functionName string,
arguments []cadence.Value,
argumentTypes []sema.Type,
context Context,
) Executor
// InvokeContractFunction invokes a contract function with the given arguments.
//
// This function returns an error if the execution fails.
// If the contract function accepts an AuthAccount as a parameter the corresponding argument can be an interpreter.Address.
// returns a cadence.Value
InvokeContractFunction(
contractLocation common.AddressLocation,
functionName string,
arguments []cadence.Value,
argumentTypes []sema.Type,
context Context,
) (cadence.Value, 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) (*interpreter.Program, error)
// SetCoverageReport activates reporting coverage in the given report.
// Passing nil disables coverage reporting (default).
//
SetCoverageReport(coverageReport *CoverageReport)
// SetContractUpdateValidationEnabled configures if contract update validation is enabled.
//
SetContractUpdateValidationEnabled(enabled bool)
// SetAtreeValidationEnabled configures if atree validation is enabled.
SetAtreeValidationEnabled(enabled bool)
// SetTracingEnabled configures if tracing is enabled.
SetTracingEnabled(enabled bool)
// SetInvalidatedResourceValidationEnabled configures
// if invalidated resource validation is enabled.
SetInvalidatedResourceValidationEnabled(enabled bool)
// SetResourceOwnerChangeHandlerEnabled configures if the resource owner change callback is enabled.
SetResourceOwnerChangeHandlerEnabled(enabled bool)
// ReadStored reads the value stored at the given path
//
ReadStored(address common.Address, path cadence.Path, context Context) (cadence.Value, error)
// ReadLinked dereferences the path and returns the value stored at the target
//
ReadLinked(address common.Address, path cadence.Path, context Context) (cadence.Value, error)
// SetDebugger configures interpreters with the given debugger.
//
SetDebugger(debugger *interpreter.Debugger)
// Storage returns the storage system and an interpreter which can be used for
// accessing values in storage.
//
// NOTE: only use the interpreter for storage operations,
// do *NOT* use the interpreter for any other purposes,
// such as executing a program.
//
Storage(context Context) (*Storage, *interpreter.Interpreter, error)
}
Runtime is a runtime capable of executing Cadence.
func NewInterpreterRuntime ¶
NewInterpreterRuntime returns a interpreter-based version of the Flow runtime.
type ScriptParameterTypeNotImportableError ¶ added in v0.17.0
ScriptParameterTypeNotImportableError is an error that is reported for script parameter types that are not importable.
For example, the type `Int` is an importable type, whereas a function-type is not.
func (*ScriptParameterTypeNotImportableError) Error ¶ added in v0.17.0
func (e *ScriptParameterTypeNotImportableError) Error() string
func (*ScriptParameterTypeNotImportableError) IsUserError ¶ added in v0.25.0
func (*ScriptParameterTypeNotImportableError) IsUserError()
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
func (*ScriptParameterTypeNotStorableError) IsUserError ¶ added in v0.25.0
func (*ScriptParameterTypeNotStorableError) IsUserError()
type SignatureAlgorithm ¶ added in v0.14.0
type SignatureAlgorithm = sema.SignatureAlgorithm
type Storage ¶ added in v0.20.0
type Storage struct {
*atree.PersistentSlabStorage
Ledger atree.Ledger
// contains filtered or unexported fields
}
func NewStorage ¶ added in v0.20.0
func NewStorage(ledger atree.Ledger, memoryGauge common.MemoryGauge) *Storage
func (*Storage) CheckHealth ¶ added in v0.20.0
func (*Storage) Commit ¶ added in v0.20.0
func (s *Storage) Commit(inter *interpreter.Interpreter, commitContractUpdates bool) error
Commit serializes/saves all values in the readCache in storage (through the runtime interface).
func (*Storage) GetStorageMap ¶ added in v0.23.0
func (s *Storage) GetStorageMap( address common.Address, domain string, createIfNotExists bool, ) ( storageMap *interpreter.StorageMap, )
type TypeComparator ¶ added in v0.25.0
type TypeComparator struct {
RootDeclIdentifier *Identifier
}
func (*TypeComparator) CheckConstantSizedTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckConstantSizedTypeEquality(expected *ast.ConstantSizedType, found ast.Type) error
func (*TypeComparator) CheckDictionaryTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckDictionaryTypeEquality(expected *ast.DictionaryType, found ast.Type) error
func (*TypeComparator) CheckFunctionTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckFunctionTypeEquality(expected *ast.FunctionType, found ast.Type) error
func (*TypeComparator) CheckInstantiationTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckInstantiationTypeEquality(expected *ast.InstantiationType, found ast.Type) error
func (*TypeComparator) CheckNominalTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckNominalTypeEquality(expected *ast.NominalType, found ast.Type) error
func (*TypeComparator) CheckOptionalTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckOptionalTypeEquality(expected *ast.OptionalType, found ast.Type) error
func (*TypeComparator) CheckReferenceTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckReferenceTypeEquality(expected *ast.ReferenceType, found ast.Type) error
func (*TypeComparator) CheckRestrictedTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckRestrictedTypeEquality(expected *ast.RestrictedType, found ast.Type) error
func (*TypeComparator) CheckVariableSizedTypeEquality ¶ added in v0.25.0
func (c *TypeComparator) CheckVariableSizedTypeEquality(expected *ast.VariableSizedType, found ast.Type) error
type TypeMismatchError ¶ added in v0.13.0
TypeMismatchError is reported during a contract update, when a type of the new program does not match the existing type.
func (*TypeMismatchError) Error ¶ added in v0.13.0
func (e *TypeMismatchError) Error() string
func (*TypeMismatchError) IsUserError ¶ added in v0.25.0
func (*TypeMismatchError) IsUserError()
type ValueDeclaration ¶ added in v0.12.0
type ValueDeclaration struct {
Name string
Type sema.Type
DocString string
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) ValueDeclarationDocString ¶ added in v0.17.0
func (v ValueDeclaration) ValueDeclarationDocString() string
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.Interpreter) interpreter.Value
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast contains all AST nodes for Cadence.
|
Package ast contains all AST nodes for Cadence. |
|
check
command
|
|
|
compile
command
|
|
|
decode-state-values
command
|
|
|
main
command
|
|
|
minifier
command
* Cadence - The resource-oriented smart contract programming language * * Copyright 2019-2022 Dapper Labs, Inc.
|
* Cadence - The resource-oriented smart contract programming language * * Copyright 2019-2022 Dapper Labs, Inc. |
|
parse
command
|
|
|
list
Package list implements a doubly linked list.
|
Package list implements a doubly linked list. |
|
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. |
|
wasm/gen
command
|
|
|
tests
|
|