Skip to content

@lelantos-org/sdk / index / TreeStore

Class: TreeStore โ€‹

Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:47

Constructors โ€‹

Constructor โ€‹

ts
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 โ€‹

ParameterType
PPoseidon
fmdFmdClient
treeDepth?number

Returns โ€‹

TreeStore

Methods โ€‹

getPath() โ€‹

ts
getPath(leafIndex): MerkleProof & object;

Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:71

Parameters โ€‹

ParameterType
leafIndexnumber

Returns โ€‹

MerkleProof & object


loadState() โ€‹

ts
loadState(state): void;

Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:63

Parameters โ€‹

ParameterType
stateTreeStoreState

Returns โ€‹

void


root() โ€‹

ts
root(): bigint;

Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:74

Returns โ€‹

bigint


saveState() โ€‹

ts
saveState(): TreeStoreState;

Defined in: @lelantos-org/sdk/dist/wallet/tree-store.d.ts:64

Returns โ€‹

TreeStoreState


sync() โ€‹

ts
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 โ€‹

ParameterType
opts?TreeSyncOpts

Returns โ€‹

Promise<TreeSyncSummary>


verifyRoot() โ€‹

ts
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() โ€‹

ts
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 โ€‹

ParameterType
PPoseidon
fmdFmdClient
persistenceTreePersistence
treeDepth?number

Returns โ€‹

Promise<TreeStore>

Lelantosno cookies ๐Ÿช ยท no tracking ๐Ÿ‘๏ธ ยท no accounts ๐Ÿ‘คwalletexplorer4536080GitHub