import { Connection, PublicKey } from "@solana/web3.js"; import type { ShieldNote, ShieldOwner } from "./types.js"; /** * Read the authoritative leaf index for a landed shield, and produce the * mailbox blob for optional relayer delivery. * * ## Why this is a separate step * * Every existing deposit implementation records `tree.nextIndex` read *before* * submission as the note's leaf index. Under concurrent deposits into the same * tree that value is wrong, and it is wrong permanently — the stored index is * what a later withdrawal builds its Merkle path from, so the note becomes * unspendable through the normal path. * * That race is rare for a single wallet and constant for an SDK: a platform * batching shields for many users will hit it routinely. So `shield()` reports * only a `predictedLeafIndex`, and the real one is read here from the * transaction's own `CommitmentEvent` after it confirms. * * ## What is optional * * Everything, strictly. The note is recoverable from chain data alone via the * on-chain compact cipher, so a caller that skips finalization has not lost the * funds — only the fast path to finding them. Persist nothing that depends on a * leaf index without calling this first. */ export declare function finalizeShield(params: { connection: Connection; signature: string; note: ShieldNote; owner: ShieldOwner; programId?: PublicKey; /** Defaults to "confirmed". Use "finalized" if the index will be persisted. */ commitment?: "confirmed" | "finalized"; }): Promise<{ leafIndex: number; newRoot: Uint8Array; treeId: number; slot: number; /** Encrypted note blob, ready for POST /notes/save if the caller wants mailbox delivery. */ blob: { ephemeralPublicKey: Uint8Array; encryptedBlob: string; }; }>;