Documentation
¶
Index ¶
- Constants
- type Account
- type Address
- type Block
- type CadenceRuntime
- type Collection
- type Header
- type Identifier
- type JSRuntime
- func (j *JSRuntime) AccountKeysCount(address common.Address) (uint64, error)
- func (j *JSRuntime) AddAccountKey(address common.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (j *JSRuntime) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
- func (j *JSRuntime) BLSAggregatePublicKeys(publicKeys []*runtime.PublicKey) (*runtime.PublicKey, error)
- func (j *JSRuntime) BLSAggregateSignatures(signatures [][]byte) ([]byte, error)
- func (j *JSRuntime) BLSVerifyPOP(publicKey *runtime.PublicKey, signature []byte) (bool, error)
- func (j *JSRuntime) ComputationUsed() (uint64, error)
- func (j *JSRuntime) CreateAccount(payer common.Address) (address common.Address, err error)
- func (j *JSRuntime) DecodeArgument(argument []byte, argumentType cadence.Type) (cadence.Value, error)
- func (j *JSRuntime) EmitEvent(event cadence.Event) error
- func (j *JSRuntime) GenerateAccountID(address common.Address) (uint64, error)
- func (j *JSRuntime) GenerateUUID() (uint64, error)
- func (j *JSRuntime) GetAccountAvailableBalance(address common.Address) (value uint64, err error)
- func (j *JSRuntime) GetAccountBalance(address common.Address) (value uint64, err error)
- func (j *JSRuntime) GetAccountContractCode(location common.AddressLocation) (code []byte, err error)
- func (j *JSRuntime) GetAccountContractNames(address common.Address) ([]string, error)
- func (j *JSRuntime) GetAccountKey(address common.Address, index int) (*runtime.AccountKey, error)
- func (j *JSRuntime) GetBlockAtHeight(height uint64) (runtime.Block, bool, error)
- func (j *JSRuntime) GetCode(location runtime.Location) ([]byte, error)
- func (j *JSRuntime) GetCurrentBlockHeight() (uint64, error)
- func (j *JSRuntime) GetInterpreterSharedState() *interpreter.SharedState
- func (j *JSRuntime) GetOrLoadProgram(location runtime.Location, load func() (*interpreter.Program, error)) (*interpreter.Program, error)
- func (j *JSRuntime) GetSigningAccounts() ([]common.Address, error)
- func (j *JSRuntime) GetStorageCapacity(address common.Address) (value uint64, err error)
- func (j *JSRuntime) GetStorageUsed(address common.Address) (value uint64, err error)
- func (j *JSRuntime) GetValue(owner, key []byte) (value []byte, err error)
- func (j *JSRuntime) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
- func (j *JSRuntime) ImplementationDebugLog(message string) error
- func (j *JSRuntime) InteractionUsed() (uint64, error)
- func (j *JSRuntime) MemoryUsed() (uint64, error)
- func (j *JSRuntime) MeterComputation(operationType common.ComputationKind, intensity uint) error
- func (j *JSRuntime) MeterMemory(usage common.MemoryUsage) error
- func (j *JSRuntime) ProgramLog(log string) error
- func (j *JSRuntime) ReadRandom(r []byte) error
- func (j *JSRuntime) RecordTrace(operation string, location runtime.Location, duration time.Duration, ...)
- func (j *JSRuntime) RemoveAccountContractCode(location common.AddressLocation) (err error)
- func (j *JSRuntime) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
- func (j *JSRuntime) ResourceOwnerChanged(interpreter *interpreter.Interpreter, resource *interpreter.CompositeValue, ...)
- func (j *JSRuntime) RevokeAccountKey(address common.Address, index int) (*runtime.AccountKey, error)
- func (j *JSRuntime) SetInterpreterSharedState(state *interpreter.SharedState)
- func (j *JSRuntime) SetNetwork(network *Network)
- func (j *JSRuntime) SetValue(owner, key, value []byte) (err error)
- func (j *JSRuntime) UpdateAccountContractCode(location common.AddressLocation, code []byte) (err error)
- func (j *JSRuntime) ValidatePublicKey(key *runtime.PublicKey) error
- func (j *JSRuntime) ValueExists(owner, key []byte) (exists bool, err error)
- func (j *JSRuntime) VerifySignature(signature []byte, tag string, signedData []byte, publicKey []byte, ...) (bool, error)
- type Ledger
- type LedgerChange
- type LedgerKey
- type Network
- type ProposalKey
- type PublicKey
- type Signature
- type Transaction
- type TransactionResult
Constants ¶
const AddressLength uint = 8
const IdentifierLength uint = 32
const PublicKeyLength uint = 65
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Header *Header Collections []*Collection TransactionResults []*TransactionResult }
func GenesisBlock ¶
func GenesisBlock() *Block
type CadenceRuntime ¶
type Collection ¶
type Collection struct {
Transactions []*Transaction
}
type Header ¶
type Header struct { ChainID string ParentID Identifier Height uint64 PayloadHash Identifier Timestamp time.Time View uint64 ParentView uint64 }
func (*Header) ID ¶
func (header *Header) ID() Identifier
type Identifier ¶
type Identifier [IdentifierLength]byte
func (Identifier) Bytes ¶
func (i Identifier) Bytes() []byte
type JSRuntime ¶
type JSRuntime struct {
// contains filtered or unexported fields
}
func NewJSRuntime ¶
func (*JSRuntime) AccountKeysCount ¶
func (*JSRuntime) AddAccountKey ¶
func (j *JSRuntime) AddAccountKey(address common.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int) (*runtime.AccountKey, error)
AddAccountKey appends a key to an account.
func (*JSRuntime) AllocateStorageIndex ¶
func (j *JSRuntime) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
AllocateStorageIndex allocates a new storage index under the given account.
func (*JSRuntime) BLSAggregatePublicKeys ¶
func (j *JSRuntime) BLSAggregatePublicKeys(publicKeys []*runtime.PublicKey) (*runtime.PublicKey, error)
BLSAggregatePublicKeys aggregate multiple BLS public keys into one.
func (*JSRuntime) BLSAggregateSignatures ¶
BLSAggregateSignatures aggregate multiple BLS signatures into one.
func (*JSRuntime) BLSVerifyPOP ¶
BLSVerifyPOP verifies a proof of possession (PoP) for the receiver public key.
func (*JSRuntime) ComputationUsed ¶
ComputationUsed returns the total computation used in the current runtime.
func (*JSRuntime) CreateAccount ¶
CreateAccount creates a new account.
func (*JSRuntime) DecodeArgument ¶
func (j *JSRuntime) DecodeArgument(argument []byte, argumentType cadence.Type) (cadence.Value, error)
DecodeArgument decodes a transaction/script argument against the given type.
func (*JSRuntime) GenerateAccountID ¶
GenerateAccountID generates a new, *non-zero*, unique ID for the given account.
func (*JSRuntime) GenerateUUID ¶
GenerateUUID is called to generate a UUID.
func (*JSRuntime) GetAccountAvailableBalance ¶
GetAccountAvailableBalance gets accounts default flow token balance - balance that is reserved for storage.
func (*JSRuntime) GetAccountBalance ¶
GetAccountBalance gets accounts default flow token balance.
func (*JSRuntime) GetAccountContractCode ¶
func (j *JSRuntime) GetAccountContractCode(location common.AddressLocation) (code []byte, err error)
GetAccountContractCode returns the code associated with an account contract.
func (*JSRuntime) GetAccountContractNames ¶
GetAccountContractNames returns the names of all contracts deployed in an account.
func (*JSRuntime) GetAccountKey ¶
GetAccountKey retrieves a key from an account by index.
func (*JSRuntime) GetBlockAtHeight ¶
GetBlockAtHeight returns the block at the given height.
func (*JSRuntime) GetCurrentBlockHeight ¶
GetCurrentBlockHeight returns the current block height.
func (*JSRuntime) GetInterpreterSharedState ¶
func (j *JSRuntime) GetInterpreterSharedState() *interpreter.SharedState
GetInterpreterSharedState gets the shared state of all interpreters. May return nil if none is available or use is not applicable.
func (*JSRuntime) GetOrLoadProgram ¶
func (j *JSRuntime) GetOrLoadProgram( location runtime.Location, load func() (*interpreter.Program, error), ) (*interpreter.Program, error)
GetOrLoadProgram returns the program for the given location, if available, or sets the program by calling the given load function.
For implementations:
- Perform a lookup for the location and return the program if it exists.
- If the program does not exist, call load, and store the result, *EVEN IF loading failed* (program is nil / error is non-nil)!
- During execution of a high-level program (e.g. script, transaction, etc.), 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 exactly what was previously returned from load, *EVEN IF loading failed* (program is nil / error is non-nil), and it may NOT return something different
- Do NOT implement this as a cache!
func (*JSRuntime) GetSigningAccounts ¶
GetSigningAccounts returns the signing accounts.
func (*JSRuntime) GetStorageCapacity ¶
GetStorageCapacity gets storage capacity in bytes on the address.
func (*JSRuntime) GetStorageUsed ¶
GetStorageUsed gets storage used in bytes by the address at the moment of the function call.
func (*JSRuntime) GetValue ¶
GetValue gets a value for the given key in the storage, owned by the given account.
func (*JSRuntime) Hash ¶
func (j *JSRuntime) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
Hash returns the digest of hashing the given data with using the given hash algorithm
func (*JSRuntime) ImplementationDebugLog ¶
ImplementationDebugLog logs implementation log statements on a debug-level
func (*JSRuntime) InteractionUsed ¶
InteractionUsed returns the total storage interaction used in the current runtime.
func (*JSRuntime) MemoryUsed ¶
MemoryUsed returns the total memory (estimate) used in the current runtime.
func (*JSRuntime) MeterComputation ¶
func (j *JSRuntime) MeterComputation(operationType common.ComputationKind, intensity uint) error
MeterComputation is a callback method for metering computation, it returns error when computation passes the limit (set by the environment)
func (*JSRuntime) MeterMemory ¶
func (j *JSRuntime) MeterMemory(usage common.MemoryUsage) error
func (*JSRuntime) ProgramLog ¶
ProgramLog logs program logs.
func (*JSRuntime) ReadRandom ¶
ReadRandom reads pseudo-random bytes into the input slice, using distributed randomness.
func (*JSRuntime) RecordTrace ¶
func (j *JSRuntime) RecordTrace(operation string, location runtime.Location, duration time.Duration, attrs []attribute.KeyValue)
RecordTrace records an opentelemetry trace.
func (*JSRuntime) RemoveAccountContractCode ¶
func (j *JSRuntime) RemoveAccountContractCode(location common.AddressLocation) (err error)
RemoveAccountContractCode removes the code associated with an account contract.
func (*JSRuntime) ResolveLocation ¶
func (j *JSRuntime) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
ResolveLocation resolves an import location.
func (*JSRuntime) ResourceOwnerChanged ¶
func (j *JSRuntime) ResourceOwnerChanged( interpreter *interpreter.Interpreter, resource *interpreter.CompositeValue, oldOwner common.Address, newOwner common.Address, )
ResourceOwnerChanged gets called when a resource's owner changed (if enabled)
func (*JSRuntime) RevokeAccountKey ¶
func (j *JSRuntime) RevokeAccountKey(address common.Address, index int) (*runtime.AccountKey, error)
RevokeAccountKey removes a key from an account by index.
func (*JSRuntime) SetInterpreterSharedState ¶
func (j *JSRuntime) SetInterpreterSharedState(state *interpreter.SharedState)
SetInterpreterSharedState sets the shared state of all interpreters.
func (*JSRuntime) SetNetwork ¶
func (*JSRuntime) SetValue ¶
SetValue sets a value for the given key in the storage, owned by the given account.
func (*JSRuntime) UpdateAccountContractCode ¶
func (j *JSRuntime) UpdateAccountContractCode(location common.AddressLocation, code []byte) (err error)
UpdateAccountContractCode updates the code associated with an account contract.
func (*JSRuntime) ValidatePublicKey ¶
ValidatePublicKey verifies the validity of a public key.
func (*JSRuntime) ValueExists ¶
ValueExists returns true if the given key exists in the storage, owned by the given account.
func (*JSRuntime) VerifySignature ¶
func (j *JSRuntime) VerifySignature( signature []byte, tag string, signedData []byte, publicKey []byte, signatureAlgorithm runtime.SignatureAlgorithm, hashAlgorithm runtime.HashAlgorithm, ) (bool, 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.
type LedgerChange ¶
type Network ¶
type Network struct { Runtime CadenceRuntime JSRuntime *JSRuntime Blocks []*Block // contains filtered or unexported fields }
func NewNetwork ¶
func (*Network) CommitLedgerChange ¶
func (n *Network) CommitLedgerChange(ledgerChange *LedgerChange)
func (*Network) ExecuteAndCommitBlock ¶
func (n *Network) ExecuteAndCommitBlock()
func (*Network) ExecuteTransaction ¶
func (n *Network) ExecuteTransaction(transaction *Transaction)
type ProposalKey ¶
type PublicKey ¶
type PublicKey [PublicKeyLength]byte
type Transaction ¶
type Transaction struct { ReferenceBlockID Identifier Script []byte Arguments [][]byte GasLimit uint64 ProposalKey ProposalKey Payer Address Authorizers []Address PayloadSignatures []Signature EnvelopeSignatures []Signature TransactionResult TransactionResult }
func (*Transaction) ID ¶
func (transaction *Transaction) ID() Identifier
type TransactionResult ¶
type TransactionResult struct { Status uint64 Error error LedgerChanges []*LedgerChange Events []cadence.Event }