@cloak.ag/sdk 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -130,12 +130,6 @@ interface CloakConfig {
130
130
  * Optional but recommended for full functionality
131
131
  */
132
132
  cloakKeys?: any;
133
- /**
134
- * Single API base URL for both Indexer and Relay services.
135
- * If provided, it will be used for both services and overrides
136
- * any `indexerUrl` or `relayUrl` values.
137
- */
138
- apiUrl?: string;
139
133
  /** Optional: Proof generation timeout in milliseconds (default: 5 minutes) */
140
134
  proofTimeout?: number;
141
135
  /** Optional: Program ID (defaults to Cloak mainnet program) */
@@ -152,6 +146,23 @@ interface CloakConfig {
152
146
  nullifierShardAddress?: PublicKey;
153
147
  /** Optional: Treasury account address (auto-derived if not provided) */
154
148
  treasuryAddress?: PublicKey;
149
+ /**
150
+ * Enable debug logging with structured output similar to Rust tracing.
151
+ *
152
+ * When enabled, logs SDK operations with timestamps, module paths,
153
+ * and key-value pairs for context:
154
+ *
155
+ * ```
156
+ * 2026-01-23T00:51:46.489000Z INFO cloak::sdk: 📥 Deposit completed signature=42XB... leaf_index=757
157
+ * ```
158
+ *
159
+ * Can also be enabled via environment variable:
160
+ * - `CLOAK_DEBUG=1`
161
+ * - `DEBUG=cloak:*`
162
+ *
163
+ * Default: false
164
+ */
165
+ debug?: boolean;
155
166
  }
156
167
  /**
157
168
  * Deposit progress status
@@ -286,28 +297,6 @@ interface TxStatus {
286
297
  txId?: string;
287
298
  error?: string;
288
299
  }
289
- /**
290
- * Note scanning options
291
- */
292
- interface ScanNotesOptions {
293
- /** Start index for scanning (default: 0) */
294
- startIndex?: number;
295
- /** End index for scanning (default: latest) */
296
- endIndex?: number;
297
- /** Batch size for fetching notes (default: 100) */
298
- batchSize?: number;
299
- /** Progress callback */
300
- onProgress?: (current: number, total: number) => void;
301
- }
302
- /**
303
- * Scanned note result with metadata
304
- */
305
- interface ScannedNote extends CloakNote {
306
- /** When this note was discovered */
307
- scannedAt: number;
308
- /** Whether this note has been spent (nullifier check) */
309
- isSpent?: boolean;
310
- }
311
300
  /**
312
301
  * Swap parameters for token swaps
313
302
  */
@@ -539,9 +528,7 @@ declare class CloakSDK {
539
528
  private keypair?;
540
529
  private wallet?;
541
530
  private cloakKeys?;
542
- private indexer;
543
531
  private relay;
544
- private depositRecovery;
545
532
  private storage;
546
533
  /**
547
534
  * Create a new Cloak SDK client
@@ -573,8 +560,9 @@ declare class CloakSDK {
573
560
  cloakKeys?: CloakKeyPair;
574
561
  storage?: StorageAdapter;
575
562
  programId?: PublicKey;
576
- indexerUrl?: string;
577
563
  relayUrl?: string;
564
+ /** Enable debug logging with structured output */
565
+ debug?: boolean;
578
566
  });
579
567
  /**
580
568
  * Get the public key for deposits (from keypair or wallet)
@@ -773,18 +761,20 @@ declare class CloakSDK {
773
761
  */
774
762
  isWithdrawable(note: CloakNote): boolean;
775
763
  /**
776
- * Get Merkle proof for a leaf index
764
+ * Get Merkle proof for a leaf index directly from on-chain state
777
765
  *
766
+ * @param connection - Solana connection
778
767
  * @param leafIndex - Leaf index in tree
779
- * @returns Merkle proof
768
+ * @returns Merkle proof computed from on-chain data
780
769
  */
781
- getMerkleProof(leafIndex: number): Promise<MerkleProof>;
770
+ getMerkleProof(connection: Connection, leafIndex: number): Promise<MerkleProof>;
782
771
  /**
783
- * Get current Merkle root
772
+ * Get current Merkle root directly from on-chain state
784
773
  *
785
- * @returns Current root hash
774
+ * @param connection - Solana connection
775
+ * @returns Current root hash from on-chain tree
786
776
  */
787
- getCurrentRoot(): Promise<string>;
777
+ getCurrentRoot(connection: Connection): Promise<string>;
788
778
  /**
789
779
  * Get transaction status from relay service
790
780
  *
@@ -792,47 +782,6 @@ declare class CloakSDK {
792
782
  * @returns Current status
793
783
  */
794
784
  getTransactionStatus(requestId: string): Promise<TxStatus>;
795
- /**
796
- * Recover a deposit that completed on-chain but failed to register
797
- *
798
- * Use this when a deposit transaction succeeded but the browser crashed
799
- * or lost connection before the indexer registration completed.
800
- *
801
- * @param signature - Transaction signature
802
- * @param commitment - Note commitment hash
803
- * @param note - Optional: The full note if available
804
- * @returns Recovery result with updated note
805
- *
806
- * @example
807
- * ```typescript
808
- * const result = await sdk.recoverDeposit({
809
- * signature: "5Kn4...",
810
- * commitment: "abc123...",
811
- * note: myNote // optional if you have it
812
- * });
813
- *
814
- * if (result.success) {
815
- * console.log(`Recovered! Leaf index: ${result.leafIndex}`);
816
- * }
817
- * ```
818
- */
819
- recoverDeposit(options: {
820
- signature: string;
821
- commitment: string;
822
- note?: CloakNote;
823
- onProgress?: (status: string) => void;
824
- }): Promise<{
825
- success: boolean;
826
- leafIndex?: number;
827
- root?: string;
828
- slot?: number;
829
- merkleProof?: {
830
- pathElements: string[];
831
- pathIndices: number[];
832
- };
833
- note?: CloakNote;
834
- error?: string;
835
- }>;
836
785
  /**
837
786
  * Load all notes from storage
838
787
  *
@@ -870,29 +819,6 @@ declare class CloakSDK {
870
819
  * Get the configuration
871
820
  */
872
821
  getConfig(): CloakConfig;
873
- /**
874
- * Scan blockchain for notes belonging to this wallet (v2.0 feature)
875
- *
876
- * Requires Cloak keys to be configured in the SDK.
877
- * Fetches encrypted outputs from the indexer and decrypts notes
878
- * that belong to this wallet.
879
- *
880
- * @param options - Scanning options
881
- * @returns Array of discovered notes with metadata
882
- *
883
- * @example
884
- * ```typescript
885
- * const notes = await sdk.scanNotes({
886
- * onProgress: (current, total) => {
887
- * console.log(`Scanning: ${current}/${total}`);
888
- * }
889
- * });
890
- *
891
- * console.log(`Found ${notes.length} notes!`);
892
- * const totalBalance = notes.reduce((sum, n) => sum + n.amount, 0);
893
- * ```
894
- */
895
- scanNotes(options?: ScanNotesOptions): Promise<ScannedNote[]>;
896
822
  /**
897
823
  * Wrap errors with better categorization and user-friendly messages
898
824
  *
@@ -965,6 +891,7 @@ declare function parseNote(jsonString: string): CloakNote;
965
891
  declare function exportNote(note: CloakNote, pretty?: boolean): string;
966
892
  /**
967
893
  * Check if a note is withdrawable (has been deposited)
894
+ * Note: merkleProof is optional - it may be fetched lazily at withdrawal time
968
895
  */
969
896
  declare function isWithdrawable(note: CloakNote): boolean;
970
897
  /**
@@ -976,7 +903,7 @@ declare function updateNoteWithDeposit(note: CloakNote, depositInfo: {
976
903
  slot: number;
977
904
  leafIndex: number;
978
905
  root: string;
979
- merkleProof: {
906
+ merkleProof?: {
980
907
  pathElements: string[];
981
908
  pathIndices: number[];
982
909
  };
@@ -1404,6 +1331,22 @@ declare function getAddressExplorerUrl(address: string, network?: Network): stri
1404
1331
  * This is the single source of truth for error codes and messages.
1405
1332
  */
1406
1333
 
1334
+ /**
1335
+ * Error thrown when the Merkle root used in a proof is no longer
1336
+ * in the on-chain root history (stale root).
1337
+ *
1338
+ * This happens when many deposits occur between proof generation and
1339
+ * transaction submission, pushing the proof's root out of history.
1340
+ *
1341
+ * The fix is to regenerate the proof with a fresh Merkle root.
1342
+ */
1343
+ declare class RootNotFoundError extends Error {
1344
+ constructor(message?: string);
1345
+ }
1346
+ /**
1347
+ * Check if an error message indicates a RootNotFound (0x1001) error
1348
+ */
1349
+ declare function isRootNotFoundError(error: unknown): boolean;
1407
1350
  /**
1408
1351
  * Shield Pool Program Error Codes
1409
1352
  *
@@ -1453,125 +1396,71 @@ declare function createCloakError(error: unknown, _context: string): CloakError;
1453
1396
  declare function formatErrorForLogging(error: unknown): string;
1454
1397
 
1455
1398
  /**
1456
- * Response from notes range query
1399
+ * Structured Logger for Cloak SDK
1400
+ *
1401
+ * Provides structured logging similar to Rust tracing format:
1402
+ * 2026-01-23T00:51:46.489317Z INFO cloak::module: 📥 Message key=value
1403
+ *
1404
+ * Enable via:
1405
+ * - SDK config: new CloakSDK({ debug: true })
1406
+ * - Environment: CLOAK_DEBUG=1 or DEBUG=cloak:*
1407
+ */
1408
+ type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR";
1409
+ /**
1410
+ * Enable or disable debug logging globally
1411
+ */
1412
+ declare function setDebugMode(enabled: boolean): void;
1413
+ /**
1414
+ * Check if debug mode is enabled
1457
1415
  */
1458
- interface NotesRangeResponse {
1459
- notes: string[];
1460
- has_more: boolean;
1461
- total: number;
1462
- start: number;
1463
- end: number;
1416
+ declare function isDebugEnabled(): boolean;
1417
+ /**
1418
+ * Logger interface
1419
+ */
1420
+ interface Logger {
1421
+ debug: (message: string, kvPairs?: Record<string, unknown>) => void;
1422
+ info: (message: string, kvPairs?: Record<string, unknown>) => void;
1423
+ warn: (message: string, kvPairs?: Record<string, unknown>) => void;
1424
+ error: (message: string, kvPairs?: Record<string, unknown>) => void;
1464
1425
  }
1465
1426
  /**
1466
- * Indexer Service Client
1427
+ * Create a logger for a specific module
1428
+ *
1429
+ * @param module - Module name (e.g., "cloak::sdk", "cloak::indexer")
1430
+ * @returns Logger instance with debug, info, warn, error methods
1467
1431
  *
1468
- * Provides access to the Cloak Indexer API for querying the Merkle tree
1469
- * and registering deposits.
1432
+ * @example
1433
+ * ```typescript
1434
+ * const log = createLogger("cloak::deposit");
1435
+ * log.info("Depositing", { amount: 100000000 });
1436
+ * // Output: 2026-01-23T00:51:46.489000Z INFO cloak::deposit: Depositing amount=100000000
1437
+ * ```
1470
1438
  */
1471
- declare class IndexerService {
1472
- private baseUrl;
1473
- /**
1474
- * Create a new Indexer Service client
1475
- *
1476
- * @param baseUrl - Indexer API base URL
1477
- */
1478
- constructor(baseUrl: string);
1479
- /**
1480
- * Get current Merkle root and next available index
1481
- *
1482
- * @returns Current root and next index
1483
- *
1484
- * @example
1485
- * ```typescript
1486
- * const { root, next_index } = await indexer.getMerkleRoot();
1487
- * console.log(`Current root: ${root}, Next index: ${next_index}`);
1488
- * ```
1489
- */
1490
- getMerkleRoot(): Promise<MerkleRootResponse>;
1491
- /**
1492
- * Get Merkle proof for a specific leaf
1493
- *
1494
- * @param leafIndex - Index of the leaf in the tree
1495
- * @returns Merkle proof with path elements and indices
1496
- *
1497
- * @example
1498
- * ```typescript
1499
- * const proof = await indexer.getMerkleProof(42);
1500
- * console.log(`Proof has ${proof.pathElements.length} siblings`);
1501
- * ```
1502
- */
1503
- getMerkleProof(leafIndex: number): Promise<MerkleProof>;
1504
- /**
1505
- * Get notes in a specific range
1506
- *
1507
- * Useful for scanning the tree or fetching notes in batches.
1508
- *
1509
- * @param start - Start index (inclusive)
1510
- * @param end - End index (inclusive)
1511
- * @param limit - Maximum number of notes to return (default: 100)
1512
- * @returns Notes in the range
1513
- *
1514
- * @example
1515
- * ```typescript
1516
- * const { notes, has_more } = await indexer.getNotesRange(0, 99, 100);
1517
- * console.log(`Fetched ${notes.length} notes`);
1518
- * ```
1519
- */
1520
- getNotesRange(start: number, end: number, limit?: number): Promise<NotesRangeResponse>;
1521
- /**
1522
- * Get all notes from the tree
1523
- *
1524
- * Fetches all notes in batches. Use with caution for large trees.
1525
- *
1526
- * @param batchSize - Size of each batch (default: 100)
1527
- * @returns All encrypted notes
1528
- *
1529
- * @example
1530
- * ```typescript
1531
- * const allNotes = await indexer.getAllNotes();
1532
- * console.log(`Total notes: ${allNotes.length}`);
1533
- * ```
1534
- */
1535
- getAllNotes(batchSize?: number): Promise<string[]>;
1536
- /**
1537
- * Submit a deposit to the indexer
1538
- *
1539
- * Registers a new deposit transaction with the indexer, which will
1540
- * return the leaf index and current root.
1541
- *
1542
- * @param params - Deposit parameters
1543
- * @returns Success response with leaf index and root
1544
- *
1545
- * @example
1546
- * ```typescript
1547
- * const result = await indexer.submitDeposit({
1548
- * leafCommit: note.commitment,
1549
- * encryptedOutput: btoa(JSON.stringify(noteData)),
1550
- * txSignature: signature,
1551
- * slot: txSlot
1552
- * });
1553
- * console.log(`Leaf index: ${result.leafIndex}`);
1554
- * ```
1555
- */
1556
- submitDeposit(params: {
1557
- leafCommit: string;
1558
- encryptedOutput: string;
1559
- txSignature: string;
1560
- slot: number;
1561
- }): Promise<{
1562
- success: boolean;
1563
- leafIndex?: number;
1564
- root?: string;
1565
- }>;
1566
- /**
1567
- * Check indexer health
1568
- *
1569
- * @returns Health status
1570
- */
1571
- healthCheck(): Promise<{
1572
- status: string;
1573
- }>;
1574
- }
1439
+ declare function createLogger(module: string): Logger;
1440
+ /**
1441
+ * Measure and return duration of an async operation
1442
+ *
1443
+ * @param _logger - Logger instance (reserved for future debug logging)
1444
+ * @param _operation - Operation name (reserved for future debug logging)
1445
+ * @param fn - Async function to measure
1446
+ * @returns Result and duration in milliseconds
1447
+ */
1448
+ declare function withTiming<T>(_logger: Logger, _operation: string, fn: () => Promise<T>): Promise<{
1449
+ result: T;
1450
+ durationMs: number;
1451
+ }>;
1452
+ /**
1453
+ * Format lamports as SOL with proper decimals
1454
+ */
1455
+ declare function formatSol(lamports: number | bigint): string;
1456
+ /**
1457
+ * Truncate a string (useful for signatures, hashes)
1458
+ */
1459
+ declare function truncate(str: string, len?: number): string;
1460
+ /**
1461
+ * Default SDK logger instance
1462
+ */
1463
+ declare const sdkLogger: Logger;
1575
1464
 
1576
1465
  /**
1577
1466
  * Result from submitting a withdrawal that includes the request ID
@@ -1743,70 +1632,6 @@ declare class RelayService {
1743
1632
  private sleep;
1744
1633
  }
1745
1634
 
1746
- /**
1747
- * Deposit Recovery Service
1748
- *
1749
- * Handles recovery of deposits that completed on-chain but failed
1750
- * to finalize with the indexer (e.g., browser crash, network failure)
1751
- */
1752
-
1753
- interface RecoveryOptions {
1754
- /** Transaction signature to recover */
1755
- signature: string;
1756
- /** Note commitment hash */
1757
- commitment: string;
1758
- /** Optional: The full note if available */
1759
- note?: CloakNote;
1760
- /** Callback for progress updates */
1761
- onProgress?: (status: string) => void;
1762
- }
1763
- interface RecoveryResult {
1764
- success: boolean;
1765
- leafIndex?: number;
1766
- root?: string;
1767
- slot?: number;
1768
- merkleProof?: {
1769
- pathElements: string[];
1770
- pathIndices: number[];
1771
- };
1772
- note?: CloakNote;
1773
- error?: string;
1774
- }
1775
- /**
1776
- * Service for recovering incomplete deposits
1777
- */
1778
- declare class DepositRecoveryService {
1779
- private indexer;
1780
- private apiUrl;
1781
- constructor(indexer: IndexerService, apiUrl: string);
1782
- /**
1783
- * Recover a deposit that completed on-chain but failed to register
1784
- *
1785
- * @param options Recovery options
1786
- * @returns Recovery result with updated note
1787
- */
1788
- recoverDeposit(options: RecoveryOptions): Promise<RecoveryResult>;
1789
- /**
1790
- * Check if a deposit already exists in the indexer
1791
- * Uses the enhanced deposit lookup endpoint with include_proof=true
1792
- *
1793
- * @private
1794
- */
1795
- private checkExistingDeposit;
1796
- /**
1797
- * Recover deposit by transaction signature
1798
- * Uses the indexer's signature lookup endpoint
1799
- */
1800
- recoverBySignature(signature: string): Promise<RecoveryResult>;
1801
- /**
1802
- * Finalize a deposit via server API (alternative recovery method)
1803
- *
1804
- * This method calls a server-side endpoint that can handle
1805
- * the recovery process with elevated permissions.
1806
- */
1807
- finalizeDepositViaServer(signature: string, commitment: string, encryptedOutput?: string): Promise<RecoveryResult>;
1808
- }
1809
-
1810
1635
  /**
1811
1636
  * Encrypted Output Helpers
1812
1637
  *
@@ -1870,7 +1695,7 @@ declare function keypairToAdapter(keypair: Keypair): WalletAdapter;
1870
1695
  * Deposits SOL into the Cloak protocol by creating a commitment.
1871
1696
  *
1872
1697
  * Instruction format:
1873
- * - Byte 0: Discriminant (0x00 for deposit)
1698
+ * - Byte 0: Discriminant (0x01 for Deposit, per ShieldPoolInstruction enum)
1874
1699
  * - Bytes 1-8: Amount (u64, little-endian)
1875
1700
  * - Bytes 9-40: Commitment (32 bytes)
1876
1701
  *
@@ -1928,6 +1753,7 @@ interface ShieldPoolPDAs {
1928
1753
  merkleTree: PublicKey;
1929
1754
  commitments: PublicKey;
1930
1755
  rootsRing: PublicKey;
1756
+ /** @deprecated Use getNullifierPDA() for the new per-nullifier PDA design */
1931
1757
  nullifierShard: PublicKey;
1932
1758
  treasury: PublicKey;
1933
1759
  }
@@ -1949,6 +1775,83 @@ interface ShieldPoolPDAs {
1949
1775
  * @param mint - Optional mint address (defaults to 32 zero bytes for native SOL)
1950
1776
  */
1951
1777
  declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): ShieldPoolPDAs;
1778
+ /**
1779
+ * Derive the nullifier PDA for a specific nullifier hash.
1780
+ *
1781
+ * With the new PDA-per-nullifier design, each nullifier has its own PDA
1782
+ * instead of being stored in a shared shard. The PDA is created when
1783
+ * the nullifier is used during withdrawal.
1784
+ *
1785
+ * Seeds: ["nullifier", nullifier_hash]
1786
+ *
1787
+ * @param nullifier - 32-byte nullifier hash
1788
+ * @param programId - Optional program ID (defaults to CLOAK_PROGRAM_ID)
1789
+ * @returns [PublicKey, bump] - The nullifier PDA and its bump seed
1790
+ */
1791
+ declare function getNullifierPDA(nullifier: Uint8Array | Buffer, programId?: PublicKey): [PublicKey, number];
1792
+ /**
1793
+ * Derive the swap state PDA for a given nullifier.
1794
+ *
1795
+ * Seeds: ["swap_state", nullifier_hash]
1796
+ *
1797
+ * @param nullifier - 32-byte nullifier hash
1798
+ * @param programId - Optional program ID (defaults to CLOAK_PROGRAM_ID)
1799
+ * @returns [PublicKey, bump] - The swap state PDA and its bump seed
1800
+ */
1801
+ declare function getSwapStatePDA(nullifier: Uint8Array | Buffer, programId?: PublicKey): [PublicKey, number];
1802
+
1803
+ /**
1804
+ * On-chain Merkle proof computation
1805
+ *
1806
+ * Computes Merkle proofs directly from on-chain tree state,
1807
+ * eliminating the need for an indexer for proof generation.
1808
+ */
1809
+
1810
+ /**
1811
+ * Merkle proof result
1812
+ */
1813
+ interface OnchainMerkleProof {
1814
+ pathElements: string[];
1815
+ pathIndices: number[];
1816
+ root: string;
1817
+ }
1818
+ /**
1819
+ * Read the Merkle tree state from on-chain account
1820
+ */
1821
+ declare function readMerkleTreeState(connection: Connection, merkleTreePDA: PublicKey): Promise<{
1822
+ nextIndex: number;
1823
+ root: string;
1824
+ subtrees: string[];
1825
+ }>;
1826
+ /**
1827
+ * Compute Merkle proof for a leaf at a given index using on-chain state
1828
+ *
1829
+ * This works by:
1830
+ * 1. Reading the subtrees (frontier) from the on-chain account
1831
+ * 2. For each level, determining the sibling:
1832
+ * - If index is odd: sibling is the stored subtree (left sibling)
1833
+ * - If index is even: sibling is either a subsequent subtree or zero value
1834
+ *
1835
+ * Note: This works best for recent leaves where siblings are zero values.
1836
+ * For older leaves with non-zero siblings that aren't stored in subtrees,
1837
+ * an indexer may still be needed.
1838
+ *
1839
+ * @param connection - Solana connection
1840
+ * @param merkleTreePDA - PDA of the merkle tree account
1841
+ * @param leafIndex - Index of the leaf to compute proof for
1842
+ * @returns Merkle proof with path elements and indices
1843
+ */
1844
+ declare function computeProofFromChain(connection: Connection, merkleTreePDA: PublicKey, leafIndex: number): Promise<OnchainMerkleProof>;
1845
+ /**
1846
+ * Compute proof for the most recently inserted leaf
1847
+ *
1848
+ * This is the most reliable case - immediately after your deposit,
1849
+ * all siblings to the right are zero values, and siblings to the left
1850
+ * are stored in the subtrees.
1851
+ */
1852
+ declare function computeProofForLatestDeposit(connection: Connection, merkleTreePDA: PublicKey): Promise<OnchainMerkleProof & {
1853
+ leafIndex: number;
1854
+ }>;
1952
1855
 
1953
1856
  /**
1954
1857
  * Direct Circom WASM Proof Generation
@@ -1960,6 +1863,11 @@ declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): Shi
1960
1863
  * as it doesn't require a backend prover service.
1961
1864
  */
1962
1865
 
1866
+ /**
1867
+ * Default URL for fetching circuit artifacts
1868
+ * These are served from the Cloak web app at https://cloak.ag
1869
+ */
1870
+ declare const DEFAULT_CIRCUITS_URL = "https://www.cloak.ag/circuits";
1963
1871
  interface WithdrawRegularInputs {
1964
1872
  root: bigint;
1965
1873
  nullifier: bigint;
@@ -2020,6 +1928,23 @@ declare function generateWithdrawRegularProof(inputs: WithdrawRegularInputs, cir
2020
1928
  * @param circuitsPath - Path or URL to circuits directory. In browser, use URL like '/circuits' or full URL.
2021
1929
  */
2022
1930
  declare function generateWithdrawSwapProof(inputs: WithdrawSwapInputs, circuitsPath: string): Promise<ProofResult>;
1931
+ /**
1932
+ * Check if circuits are available at the given path or URL
1933
+ * Supports both local file paths and remote URLs
1934
+ *
1935
+ * Note: For remote URLs, this returns true without checking (snarkjs will handle loading).
1936
+ * For local paths, it checks if the files exist on disk.
1937
+ */
1938
+ declare function areCircuitsAvailable(circuitsPath: string): Promise<boolean>;
1939
+ /**
1940
+ * Get default circuits path or URL
1941
+ *
1942
+ * Priority:
1943
+ * 1. CIRCUITS_PATH environment variable (if set)
1944
+ * 2. Local file paths (if available)
1945
+ * 3. Default remote URL (https://cloak.ag/circuits)
1946
+ */
1947
+ declare function getDefaultCircuitsPath(): Promise<string>;
2023
1948
  /**
2024
1949
  * Expected circuit hashes for verification
2025
1950
  * These are computed from the verification key files to ensure circuits match on-chain vkeys
@@ -2198,4 +2123,4 @@ declare function cleanupStalePendingOperations(maxAgeMs?: number): {
2198
2123
 
2199
2124
  declare const VERSION = "1.0.0";
2200
2125
 
2201
- export { CLOAK_PROGRAM_ID, type CircuitVerificationResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, CloakSDK, type DepositInstructionParams, type DepositOptions, DepositRecoveryService, type DepositResult, type DepositStatus, EXPECTED_CIRCUIT_HASHES, type EncryptedNote, type ErrorCategory, FIXED_FEE_LAMPORTS, type Groth16Proof, IndexerService, LAMPORTS_PER_SOL, LocalStorageAdapter, type MasterKey, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, type Network, type NoteData, type NotesRangeResponse, type PendingDeposit, type PendingWithdrawal, type ProofResult, type RecoveryOptions, type RecoveryResult, RelayService, type ScanNotesOptions, type ScannedNote, ShieldPoolErrors, type ShieldPoolPDAs, type SpendKey, type StorageAdapter, type SwapOptions, type SwapParams, type SwapResult, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, VARIABLE_FEE_RATE, VERSION, type ViewKey, type WalletAdapter, type WithdrawOptions, type WithdrawRegularInputs, type WithdrawSubmissionResult, type WithdrawSwapInputs, bigintToBytes32, buildPublicInputsBytes, bytesToHex, calculateFee, calculateRelayFee, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, computeCommitment, computeMerkleRoot, computeNullifier, computeNullifierAsync, computeNullifierSync, computeOutputsHash, computeOutputsHashAsync, computeOutputsHashSync, computeSwapOutputsHash, computeSwapOutputsHashAsync, computeSwapOutputsHashSync, copyNoteToClipboard, createCloakError, createDepositInstruction, deriveSpendKey, deriveViewKey, detectNetworkFromRpcUrl, downloadNote, encodeNoteSimple, encryptNoteForRecipient, exportKeys, exportNote, exportWalletKeys, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, formatAmount, formatErrorForLogging, generateCloakKeys, generateCommitment, generateCommitmentAsync, generateMasterSeed, generateNote, generateNoteFromWallet, generateWithdrawRegularProof, generateWithdrawSwapProof, getAddressExplorerUrl, getDistributableAmount, getExplorerUrl, getPendingOperationsSummary, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getViewKey, hasPendingOperations, hexToBigint, hexToBytes, importKeys, importWalletKeys, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawable, keypairToAdapter, loadPendingDeposits, loadPendingWithdrawals, parseAmount, parseError, parseNote, parseTransactionError, poseidonHash, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToLimbs, randomBytes, removePendingDeposit, removePendingWithdrawal, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, sendTransaction, serializeNote, signTransaction, splitTo2Limbs, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, validateDepositParams, validateNote, validateOutputsSum, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity };
2126
+ export { CLOAK_PROGRAM_ID, type CircuitVerificationResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, CloakSDK, DEFAULT_CIRCUITS_URL, type DepositInstructionParams, type DepositOptions, type DepositResult, type DepositStatus, EXPECTED_CIRCUIT_HASHES, type EncryptedNote, type ErrorCategory, FIXED_FEE_LAMPORTS, type Groth16Proof, LAMPORTS_PER_SOL, LocalStorageAdapter, type LogLevel, type Logger, type MasterKey, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, type Network, type NoteData, type OnchainMerkleProof, type PendingDeposit, type PendingWithdrawal, type ProofResult, RelayService, RootNotFoundError, ShieldPoolErrors, type ShieldPoolPDAs, type SpendKey, type StorageAdapter, type SwapOptions, type SwapParams, type SwapResult, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, VARIABLE_FEE_RATE, VERSION, type ViewKey, type WalletAdapter, type WithdrawOptions, type WithdrawRegularInputs, type WithdrawSubmissionResult, type WithdrawSwapInputs, areCircuitsAvailable, bigintToBytes32, buildPublicInputsBytes, bytesToHex, calculateFee, calculateRelayFee, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, computeCommitment, computeMerkleRoot, computeNullifier, computeNullifierAsync, computeNullifierSync, computeOutputsHash, computeOutputsHashAsync, computeOutputsHashSync, computeProofForLatestDeposit, computeProofFromChain, computeSwapOutputsHash, computeSwapOutputsHashAsync, computeSwapOutputsHashSync, copyNoteToClipboard, createCloakError, createDepositInstruction, createLogger, deriveSpendKey, deriveViewKey, detectNetworkFromRpcUrl, downloadNote, encodeNoteSimple, encryptNoteForRecipient, exportKeys, exportNote, exportWalletKeys, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, formatAmount, formatErrorForLogging, formatSol, generateCloakKeys, generateCommitment, generateCommitmentAsync, generateMasterSeed, generateNote, generateNoteFromWallet, generateWithdrawRegularProof, generateWithdrawSwapProof, getAddressExplorerUrl, getDefaultCircuitsPath, getDistributableAmount, getExplorerUrl, getNullifierPDA, getPendingOperationsSummary, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint, hexToBytes, importKeys, importWalletKeys, isDebugEnabled, isRootNotFoundError, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawable, keypairToAdapter, loadPendingDeposits, loadPendingWithdrawals, parseAmount, parseError, parseNote, parseTransactionError, poseidonHash, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToLimbs, randomBytes, readMerkleTreeState, removePendingDeposit, removePendingWithdrawal, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, sdkLogger, sendTransaction, serializeNote, setDebugMode, signTransaction, splitTo2Limbs, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, validateDepositParams, validateNote, validateOutputsSum, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, withTiming };