@lelantos-org/sdk / index / TreeStore
Class: TreeStore โ
Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:47
Constructors โ
Constructor โ
new TreeStore(
P,
fmd,
treeDepth?
): TreeStore;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:60
treeDepth must be the same value the spend path gives the circuit (WalletConfig.treeDepth). A local tree of a different depth produces paths and a root of that depth, the proof is built for another, and nothing errors โ the proof simply fails to verify on chain.
Parameters โ
| Parameter | Type |
|---|---|
P | Poseidon |
fmd | FmdClient |
treeDepth? | number |
Returns โ
TreeStore
Methods โ
getPath() โ
getPath(leafIndex): MerkleProof & object;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:71
Parameters โ
| Parameter | Type |
|---|---|
leafIndex | number |
Returns โ
MerkleProof & object
loadState() โ
loadState(state): void;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:63
Parameters โ
| Parameter | Type |
|---|---|
state | TreeStoreState |
Returns โ
void
root() โ
root(): bigint;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:74
Returns โ
bigint
saveState() โ
saveState(): TreeStoreState;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:64
Returns โ
sync() โ
sync(opts?): Promise<TreeSyncSummary>;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:70
Fetch new chunks since last sync, insert their leaves, then persist. Idempotent โ the tail chunk is re-fetched every sync, so entries already in the tree are dropped by leaf index rather than re-inserted.
Parameters โ
| Parameter | Type |
|---|---|
opts? | TreeSyncOpts |
Returns โ
Promise<TreeSyncSummary>
verifyRoot() โ
verifyRoot(): Promise<boolean>;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:87
Check the locally built root against the one the chain holds.
Worth doing on its own merits โ nothing verified the local tree before โ and it is the guard that makes trusting the server's leafHash sound: a wrong leaf produces a wrong root, and this is where that surfaces, rather than as an unexplained rejected transaction later.
Returns true when they agree. A mismatch is not necessarily an attack: the mirror lags the chain, so a tree synced mid-block legitimately differs. Callers should treat a mismatch as "resync and retry".
Returns โ
Promise<boolean>
withPersistence() โ
static withPersistence(
P,
fmd,
persistence,
treeDepth?
): Promise<TreeStore>;Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:62
Build a TreeStore and restore any previously persisted state.
Parameters โ
| Parameter | Type |
|---|---|
P | Poseidon |
fmd | FmdClient |
persistence | TreePersistence |
treeDepth? | number |
Returns โ
Promise<TreeStore>