Skip to main content

@midnight-ntwrk/compact-runtime v0.7.0Readme | API


@midnight-ntwrk/compact-runtime v0.7.0 / QueryContext

Class: QueryContext

Provides the information needed to fully process a transaction, including information about the rest of the transaction, and the state of the chain at the time of execution.

Constructors

new QueryContext(state, address)

new QueryContext(state, address): QueryContext

Construct a basic context from a contract's address and current state value

Parameters

state: StateValue

address: string

Returns

QueryContext

Properties

address

readonly address: string;

The address of the contract


block

block: BlockContext;

The block-level information accessible to the contract


comIndicies

readonly comIndicies: Map<string, bigint>;

The commitment indices map accessible to the contract, primarily via qualify


effects

effects: Effects;

The effects that occurred during execution against this context, should match those declared in a Transcript


state

readonly state: StateValue;

The current contract state retained in the context

Methods

insertCommitment()

insertCommitment(comm, index): QueryContext

Register a given coin commitment as being accessible at a specific index, for use when receiving coins in-contract, and needing to record their index to later spend them

Parameters

comm: string

index: bigint

Returns

QueryContext


intoTranscript()

intoTranscript(program, cost_model): [undefined | Transcript<AlignedValue>, undefined | Transcript<AlignedValue>]

Finalizes a sequence of operations against their initial context, resulting in a guaranteed and fallible Transcript, optimally allocated, and heuristically covered for gas fees.

Parameters

program: Op<AlignedValue>[]

cost_model: CostModel

Returns

[undefined | Transcript<AlignedValue>, undefined | Transcript<AlignedValue>]

Deprecated

Please use the ledger's partitionTranscripts instead.


qualify()

Internal

qualify(coin): undefined | Value

Internal counterpart to insertCommitment; upgrades an encoded CoinInfo to an encoded QualifiedCoinInfo using the inserted commitments

Parameters

coin: Value

Returns

undefined | Value


query()

query(
ops,
cost_model,
gas_limit?): QueryResults

Runs a sequence of operations in gather mode, returning the results of the gather.

Parameters

ops: Op<null>[]

cost_model: CostModel

gas_limit?: bigint

Returns

QueryResults


runTranscript()

runTranscript(transcript, cost_model): QueryContext

Runs a transcript in verifying mode against the current query context, outputting a new query context, with the state and effects from after the execution.

Parameters

transcript: Transcript<AlignedValue>

cost_model: CostModel

Returns

QueryContext


toString()

toString(compact?): string

Parameters

compact?: boolean

Returns

string