ZswapChainState
@midnight/zswap v3.0.2 β’ Readme | API
@midnight/zswap 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