@midnight/ledger v3.0.2 • Readme | API
@midnight/ledger v3.0.2 / ZswapChainState
Class: ZswapChainState
The on-chain state of Zswap, consisting of a Merkle tree of coin commitments, a set of nullifiers, an index into the Merkle tree, and a set of valid past Merkle tree roots
Constructors
new ZswapChainState()
new ZswapChainState(): ZswapChainState
Returns
Properties
firstFree
readonly firstFree: bigint;
The first free index in the coin commitment tree
Methods
serialize()
serialize(netid): Uint8Array
Parameters
• netid: NetworkId
Returns
Uint8Array
toString()
toString(compact?): string
Parameters
• compact?: boolean
Returns
string
tryApply()
tryApply(offer, whitelist?): [ZswapChainState, Map<string, bigint>]
Try to apply an Offer to the state, returning the updated state and a map on newly inserted coin commitments to their inserted indices.
Parameters
• offer: Offer
• whitelist?: Set
<string
>
A set of contract addresses that are of interest. If set, only these addresses are tracked, and all other information is discarded.
Returns
[ZswapChainState
, Map
<string
, bigint
>]
tryApplyProofErased()
tryApplyProofErased(offer, whitelist?): [ZswapChainState, Map<string, bigint>]
tryApply for ProofErasedOffers
Parameters
• offer: ProofErasedOffer
• whitelist?: Set
<string
>
Returns
[ZswapChainState
, Map
<string
, bigint
>]
deserialize()
static deserialize(raw, netid): ZswapChainState
Parameters
• raw: Uint8Array
• netid: NetworkId
Returns
deserializeFromLedgerState()
static deserializeFromLedgerState(raw, netid): ZswapChainState
Given a whole ledger serialized state, deserialize only the Zswap portion
Parameters
• raw: Uint8Array
• netid: NetworkId