@midnight/ledger v2.0.8 • Readme | API
@midnight/ledger v2.0.8 / LedgerState
Class: LedgerState
The state of the Midnight ledger
Constructors
new LedgerState(zswap)
new LedgerState(zswap): LedgerState
Intializes from a Zswap state, with an empty contract set
Parameters
• zswap: ZswapChainState
Returns
Properties
zswap
readonly zswap: ZswapChainState;
The Zswap part of the ledger state
Methods
index()
index(address): undefined | ContractState
Indexes into the contract state map with a given contract address
Parameters
• address: string
Returns
undefined
| ContractState
serialize()
serialize(): Uint8Array
Returns
Uint8Array
toString()
toString(compact?): string
Parameters
• compact?: boolean
Returns
string
tryApply()
tryApply(
transaction,
guaranteed,
whitelist?): LedgerState
Applies a ProofErasedTransaction
Parameters
• transaction: ProofErasedTransaction
• guaranteed: boolean
If set to true
, executes the guaranteed execution
stage. If set to false
, executes the fallible execution stage
• whitelist?: Set
<string
>
A set of contracts of interest. If set, only tracks updates related to these contracts
Returns
Throws
If the transaction fails this execution stage
updateIndex()
updateIndex(address, context): LedgerState
Sets the state of a given contract address from a QueryContext
Parameters
• address: string
• context: QueryContext
Returns
blank()
static blank(): LedgerState
A fully blank state
Returns
deserialize()
static deserialize(raw): LedgerState
Parameters
• raw: Uint8Array