import { Cell } from '@ton/core'; import { PriceLeaf } from './contracts/Phoebe'; export declare class PhoebeMerkleTree { /** Leaf cells indexed by feedId (0..MAX_FEED_COUNT-1). */ readonly leaves: Cell[]; /** * `nodes[level][i]` = cell at depth `level` (0 = leaves, TREE_DEPTH = root). * Internal nodes at level L have indices 0..(MAX_FEED_COUNT >> L)-1. */ private readonly nodes; /** * Construct the tree from exactly MAX_FEED_COUNT leaf cells. Pad with * `placeholderLeafCell()` to fill unused slots — the tree shape is fixed. */ constructor(leaves: Cell[]); /** Convenience: build from PriceLeaf objects. */ static fromLeaves(priceLeaves: PriceLeaf[]): PhoebeMerkleTree; /** * Build a tree from a sparse map of `feedId → PriceLeaf`. Unfilled slots * get a placeholder leaf (zeros). Useful for testing where only a few * feeds are populated. */ static fromSparseLeaves(entries: Map): PhoebeMerkleTree; /** 32-byte representation hash of the tree's root cell. */ root(): Buffer; /** root() as a bigint — the form that goes into PushSnapshot.root and storage.lastRoot. */ rootAsBigint(): bigint; /** * Build a **pruned-branch merkle_proof** for the leaf at `feedId`. The * returned cell is a TVM merkle_proof exotic cell (type 0x03) wrapping * an ordinary path tree whose siblings are pruned-branch exotic cells * (type 0x01) carrying just each sibling subtree's level-0 hash + * depth. * * Wire size: ~417 bytes for a 256-leaf tree (35 B merkle_proof * wrapper + 8 path cells × 2 refs + 8 pruned siblings @ 37 B + 1 leaf * @ 25 B). vs. ~8.5 KB for `fullTreeProof()`. ~20× reduction. * * On-chain verification: `msg.proofRef.loadSpecial()` unwraps the * merkle_proof to the pruned tree; `.hashOfLevel(0)` then returns the * original (un-pruned) tree's hash for the root-binding check. */ proof(feedId: number): Cell; /** * Legacy full-tree proof shape (~8.5 KB for a 256-leaf tree). The * on-chain `verifyAndUnwrapProof` accepts this via the ordinary-cell * path (`isSpecial == 0`), checking `proof.hash() == lastRoot` * directly. Use `proof()` (pruned merkle_proof) for production — it's * ~20× smaller. * * The returned cell is the root of the entire tree, independent of * `feedId` (the on-chain walker descends `feedId` bits at verification * time, NOT at construction time). `feedId` is range-validated here * for API parity with `proof()` but does not influence the returned * cell. */ fullTreeProof(feedId: number): Cell; } /** * Empty leaf for unfilled feedId slots. Encodes a zeroed PriceLeaf so the * cell is a valid (even if semantically meaningless) entry. Consumers should * NOT pull placeholder leaves; the contract returns whatever's there. */ export declare function placeholderLeafCell(feedId: number): Cell;