@ocash/sdk 0.1.0 → 0.1.1

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.
@@ -1,8 +1,17 @@
1
1
  import { Address, PublicClient } from 'viem';
2
2
 
3
+ /**
4
+ * Lifecycle states for local operation records.
5
+ */
3
6
  type OperationStatus = 'created' | 'submitted' | 'confirmed' | 'failed';
7
+ /**
8
+ * Built-in operation types with support for custom extensions.
9
+ */
4
10
  type OperationType = 'deposit' | 'transfer' | 'withdraw' | (string & {});
5
11
  type Hex$1 = `0x${string}`;
12
+ /**
13
+ * Query/filter options for listing operations.
14
+ */
6
15
  type ListOperationsQuery = {
7
16
  limit?: number;
8
17
  offset?: number;
@@ -12,6 +21,9 @@ type ListOperationsQuery = {
12
21
  status?: OperationStatus | OperationStatus[];
13
22
  sort?: 'desc' | 'asc';
14
23
  };
24
+ /**
25
+ * Detail payload for deposit operations.
26
+ */
15
27
  type DepositOperationDetail = {
16
28
  token: string;
17
29
  amount: string;
@@ -20,6 +32,9 @@ type DepositOperationDetail = {
20
32
  inputCommitments?: Hex$1[];
21
33
  outputCommitments?: Hex$1[];
22
34
  };
35
+ /**
36
+ * Detail payload for transfer operations.
37
+ */
23
38
  type TransferOperationDetail = {
24
39
  token: string;
25
40
  amount: string;
@@ -32,6 +47,9 @@ type TransferOperationDetail = {
32
47
  inputCommitments?: Hex$1[];
33
48
  outputCommitments?: Hex$1[];
34
49
  };
50
+ /**
51
+ * Detail payload for withdraw operations.
52
+ */
35
53
  type WithdrawOperationDetail = {
36
54
  token: string;
37
55
  amount: string;
@@ -46,12 +64,21 @@ type WithdrawOperationDetail = {
46
64
  inputCommitments?: Hex$1[];
47
65
  outputCommitments?: Hex$1[];
48
66
  };
67
+ /**
68
+ * Mapping of builtin operation types to their detail payloads.
69
+ */
49
70
  type BuiltinOperationDetailByType = {
50
71
  deposit: DepositOperationDetail;
51
72
  transfer: TransferOperationDetail;
52
73
  withdraw: WithdrawOperationDetail;
53
74
  };
75
+ /**
76
+ * Resolve detail shape for a given operation type.
77
+ */
54
78
  type OperationDetailFor<TType extends OperationType> = TType extends keyof BuiltinOperationDetailByType ? BuiltinOperationDetailByType[TType] : Record<string, unknown>;
79
+ /**
80
+ * Stored operation record as persisted by StorageAdapter implementations.
81
+ */
55
82
  type StoredOperation<TDetail = Record<string, unknown>> = {
56
83
  id: string;
57
84
  type: OperationType;
@@ -65,6 +92,9 @@ type StoredOperation<TDetail = Record<string, unknown>> = {
65
92
  detail?: TDetail;
66
93
  error?: string;
67
94
  };
95
+ /**
96
+ * Input shape for creating a new operation record.
97
+ */
68
98
  type OperationCreateInput<TType extends OperationType = OperationType> = Omit<StoredOperation<OperationDetailFor<TType>>, 'id' | 'createdAt' | 'status'> & Partial<Pick<StoredOperation<OperationDetailFor<TType>>, 'createdAt' | 'id' | 'status'>> & {
69
99
  type: TType;
70
100
  };
@@ -81,10 +111,15 @@ type WithdrawOperation = Omit<StoredOperation<WithdrawOperationDetail>, 'type'>
81
111
  detail?: WithdrawOperationDetail;
82
112
  };
83
113
 
114
+ /** Hex-encoded bytes with 0x prefix. */
84
115
  type Hex = `0x${string}`;
116
+ /** Decimal string representing a bigint value. */
85
117
  type BigintLikeString = string;
118
+ /** viem transaction receipt type alias. */
86
119
  type TransactionReceipt = Awaited<ReturnType<PublicClient['waitForTransactionReceipt']>>;
120
+ /** SDK error code namespaces. */
87
121
  type SdkErrorCode = 'CONFIG' | 'ASSETS' | 'STORAGE' | 'SYNC' | 'CRYPTO' | 'MERKLE' | 'WITNESS' | 'PROOF' | 'RELAYER';
122
+ /** Token configuration for a shielded pool. */
88
123
  interface TokenMetadata {
89
124
  id: string;
90
125
  symbol: string;
@@ -97,6 +132,7 @@ interface TokenMetadata {
97
132
  transferMaxAmount?: bigint | string;
98
133
  withdrawMaxAmount?: bigint | string;
99
134
  }
135
+ /** Chain configuration input for SDK initialization. */
100
136
  interface ChainConfigInput {
101
137
  chainId: number;
102
138
  rpcUrl?: string;
@@ -111,15 +147,18 @@ interface ChainConfigInput {
111
147
  */
112
148
  contract?: Address;
113
149
  }
150
+ /** Relayer fee entry for a specific pool. */
114
151
  interface RelayerFeeEntry {
115
152
  token_address: Hex;
116
153
  fee: bigint;
117
154
  }
155
+ /** Relayer fee tables for transfer/withdraw actions. */
118
156
  interface RelayerFeeConfigure {
119
157
  valid_time: number;
120
158
  transfer: Record<string, RelayerFeeEntry>;
121
159
  withdraw: Record<string, RelayerFeeEntry>;
122
160
  }
161
+ /** Relayer configuration fetched from relayer service. */
123
162
  interface RelayerConfig {
124
163
  config: {
125
164
  contract_address: Address;
@@ -132,15 +171,20 @@ interface RelayerConfig {
132
171
  fee_configure: RelayerFeeConfigure;
133
172
  fetched_at?: number;
134
173
  }
174
+ /** Worker configuration for memo decryption. */
135
175
  interface MemoWorkerConfig {
136
176
  workerUrl?: string;
137
177
  concurrency?: number;
138
178
  type?: 'classic' | 'module';
139
179
  }
180
+ /** Asset override entry: URL/path or sharded list. */
140
181
  type AssetOverrideEntry = string | string[];
182
+ /** Map of required runtime assets to URLs/paths. */
141
183
  interface AssetsOverride {
142
184
  [filename: string]: AssetOverrideEntry;
143
185
  }
186
+ /** SDK configuration passed to {@link createSdk}. */
187
+ /** SDK configuration passed to createSdk(). */
144
188
  interface OCashSdkConfig {
145
189
  chains: ChainConfigInput[];
146
190
  assetsOverride?: AssetsOverride;
@@ -176,12 +220,14 @@ interface OCashSdkConfig {
176
220
  };
177
221
  onEvent?: (event: SdkEvent) => void;
178
222
  }
223
+ /** Serialized error payload used in events. */
179
224
  interface SdkErrorPayload {
180
225
  code: SdkErrorCode;
181
226
  message: string;
182
227
  detail?: unknown;
183
228
  cause?: unknown;
184
229
  }
230
+ /** Union of all SDK event payloads. */
185
231
  type SdkEvent = {
186
232
  type: 'core:ready';
187
233
  payload: {
@@ -266,6 +312,7 @@ type SdkEvent = {
266
312
  type: 'error';
267
313
  payload: SdkErrorPayload;
268
314
  };
315
+ /** Record opening used in commitments and memos. */
269
316
  interface CommitmentData {
270
317
  asset_id: bigint;
271
318
  asset_amount: bigint;
@@ -275,11 +322,13 @@ interface CommitmentData {
275
322
  blinding_factor: bigint;
276
323
  is_frozen: boolean;
277
324
  }
325
+ /** Batch decrypt request entry. */
278
326
  interface MemoDecryptRequest {
279
327
  memo: Hex;
280
328
  secretKey: bigint;
281
329
  metadata?: Record<string, unknown>;
282
330
  }
331
+ /** Batch decrypt response entry. */
283
332
  interface MemoDecryptResult {
284
333
  memo: Hex;
285
334
  record: CommitmentData | null;
@@ -288,6 +337,7 @@ interface MemoDecryptResult {
288
337
  message: string;
289
338
  };
290
339
  }
340
+ /** Accumulator membership witness used by circuits. */
291
341
  interface AccMemberWitness {
292
342
  /**
293
343
  * Circuits witness format (matches `circuits/pkg/core/policies/witness_json.go`):
@@ -299,6 +349,7 @@ interface AccMemberWitness {
299
349
  path: Array<Hex | BigintLikeString>;
300
350
  index: number;
301
351
  }
352
+ /** Input secret (keypair + record opening + merkle witness). */
302
353
  interface InputSecret {
303
354
  owner_keypair: {
304
355
  user_pk: {
@@ -317,18 +368,22 @@ interface InputSecret {
317
368
  ro: CommitmentData;
318
369
  acc_member_witness: AccMemberWitness;
319
370
  }
371
+ /** Circuits JSON format for field points. */
320
372
  interface FrPointJson {
321
373
  X: bigint;
322
374
  Y: bigint;
323
375
  }
376
+ /** Circuits JSON format for viewer public key. */
324
377
  interface ViewerPkJson {
325
378
  EncryptionKey: {
326
379
  Key: FrPointJson;
327
380
  };
328
381
  }
382
+ /** Circuits JSON format for freezer public key. */
329
383
  interface FreezerPkJson {
330
384
  Point: FrPointJson;
331
385
  }
386
+ /** Witness input for transfer circuit. */
332
387
  interface TransferWitnessInput {
333
388
  asset_id: string;
334
389
  asset_token_id: string;
@@ -344,6 +399,7 @@ interface TransferWitnessInput {
344
399
  viewing_memo_randomness?: Uint8Array | number[];
345
400
  proof_binding?: string;
346
401
  }
402
+ /** Witness input for withdraw circuit. */
347
403
  interface WithdrawWitnessInput {
348
404
  asset_id: string;
349
405
  asset_token_id: string;
@@ -360,6 +416,7 @@ interface WithdrawWitnessInput {
360
416
  viewing_memo_randomness?: Uint8Array | number[];
361
417
  proof_binding?: string;
362
418
  }
419
+ /** Witness build output with metadata from context. */
363
420
  interface WitnessBuildResult {
364
421
  witness: TransferWitnessInput | WithdrawWitnessInput | Record<string, any>;
365
422
  array_hash_index?: number;
@@ -372,6 +429,7 @@ interface WitnessBuildResult {
372
429
  witness_type?: 'transfer' | 'withdraw';
373
430
  warnings?: string[];
374
431
  }
432
+ /** Context fields attached to witness/proof creation. */
375
433
  interface WitnessContext {
376
434
  array_hash_index?: number;
377
435
  merkle_root_index?: number;
@@ -383,6 +441,7 @@ interface WitnessContext {
383
441
  recipient?: Address;
384
442
  withdraw_amount?: bigint;
385
443
  }
444
+ /** Proof result returned from the prover bridge. */
386
445
  interface ProofResult {
387
446
  proof: [string, string, string, string, string, string, string, string];
388
447
  flatten_input: string[];
@@ -404,9 +463,13 @@ interface ProofResult {
404
463
  } | null;
405
464
  warnings?: string[];
406
465
  }
466
+ /** Extra data payload for transfer proofs (3 memos). */
407
467
  type TransferExtraData = readonly [Hex, Hex, Hex];
468
+ /** Extra data payload for withdraw proofs (1 memo). */
408
469
  type WithdrawExtraData = Hex;
470
+ /** Union of extra data payloads by action. */
409
471
  type WitnessExtraData = TransferExtraData | WithdrawExtraData;
472
+ /** Low-level WASM proof bridge interface. */
410
473
  interface ProofBridge {
411
474
  init(): Promise<void>;
412
475
  initTransfer(): Promise<void>;
@@ -420,11 +483,13 @@ interface ProofBridge {
420
483
  createDummyRecordOpening(): Promise<CommitmentData>;
421
484
  createDummyInputSecret(): Promise<InputSecret>;
422
485
  }
486
+ /** Commitment function overloads by return format. */
423
487
  interface CommitmentFn {
424
488
  (ro: CommitmentData, format: 'hex'): Hex;
425
489
  (ro: CommitmentData, format: 'bigint'): bigint;
426
490
  (ro: CommitmentData, format?: undefined): Hex;
427
491
  }
492
+ /** Sync cursors for memo/nullifier/merkle resources. */
428
493
  interface SyncCursor {
429
494
  memo: number;
430
495
  nullifier: number;
@@ -434,6 +499,7 @@ interface SyncCursor {
434
499
  */
435
500
  merkle: number;
436
501
  }
502
+ /** Per-chain sync status (memo/nullifier/merkle). */
437
503
  interface SyncChainStatus {
438
504
  memo: {
439
505
  status: 'idle' | 'syncing' | 'synced' | 'error';
@@ -453,6 +519,7 @@ interface SyncChainStatus {
453
519
  errorMessage?: string;
454
520
  };
455
521
  }
522
+ /** UTXO list query options. */
456
523
  type ListUtxosQuery = {
457
524
  /** Filter by chain id. */
458
525
  chainId?: number;
@@ -475,6 +542,7 @@ type ListUtxosQuery = {
475
542
  /** Order direction (default: asc). */
476
543
  order?: 'asc' | 'desc';
477
544
  };
545
+ /** Persisted entry memo record (raw EntryService memo). */
478
546
  type EntryMemoRecord = {
479
547
  /** Chain id (scoped). */
480
548
  chainId: number;
@@ -497,6 +565,7 @@ type EntryMemoRecord = {
497
565
  /** Optional created_at from EntryService. */
498
566
  createdAt?: number | null;
499
567
  };
568
+ /** Persisted entry nullifier record (raw EntryService nullifier). */
500
569
  type EntryNullifierRecord = {
501
570
  /** Chain id (scoped). */
502
571
  chainId: number;
@@ -510,6 +579,7 @@ type EntryNullifierRecord = {
510
579
  /** Optional created_at from EntryService. */
511
580
  createdAt?: number | null;
512
581
  };
582
+ /** Query options for entry memos. */
513
583
  type ListEntryMemosQuery = {
514
584
  chainId: number;
515
585
  /** Start cid (inclusive). Defaults to 0. */
@@ -529,6 +599,7 @@ type ListEntryMemosQuery = {
529
599
  /** Filter by createdAt range (inclusive, epoch). */
530
600
  createdAtTo?: number;
531
601
  };
602
+ /** Query options for entry nullifiers. */
532
603
  type ListEntryNullifiersQuery = {
533
604
  chainId: number;
534
605
  /** nid offset (defaults to 0). */
@@ -548,18 +619,22 @@ type ListEntryNullifiersQuery = {
548
619
  /** Filter by createdAt range (inclusive, epoch). */
549
620
  createdAtTo?: number;
550
621
  };
622
+ /** Paged result for entry memos. */
551
623
  type ListEntryMemosResult = {
552
624
  total: number;
553
625
  rows: EntryMemoRecord[];
554
626
  };
627
+ /** Paged result for entry nullifiers. */
555
628
  type ListEntryNullifiersResult = {
556
629
  total: number;
557
630
  rows: EntryNullifierRecord[];
558
631
  };
632
+ /** Paged result for UTXOs. */
559
633
  type ListUtxosResult = {
560
634
  total: number;
561
635
  rows: UtxoRecord[];
562
636
  };
637
+ /** Persisted merkle tree state metadata. */
563
638
  type MerkleTreeState = {
564
639
  /** Chain id (scoped). */
565
640
  chainId: number;
@@ -573,11 +648,13 @@ type MerkleTreeState = {
573
648
  /** Last updated timestamp (ms). */
574
649
  lastUpdated: number;
575
650
  };
651
+ /** Persisted merkle leaf record. */
576
652
  type MerkleLeafRecord = {
577
653
  chainId: number;
578
654
  cid: number;
579
655
  commitment: Hex;
580
656
  };
657
+ /** Persisted merkle node record. */
581
658
  type MerkleNodeRecord = {
582
659
  chainId: number;
583
660
  /**
@@ -590,10 +667,11 @@ type MerkleNodeRecord = {
590
667
  position: number;
591
668
  hash: Hex;
592
669
  };
670
+ /** Storage adapter interface for persistence. */
593
671
  interface StorageAdapter {
594
672
  /**
595
673
  * Initialize adapter state, optionally scoping storage by wallet id.
596
- * Implementations should clear any cached state when `walletId` changes.
674
+ * Implementations should clear wallet-scoped state when `walletId` changes.
597
675
  */
598
676
  init?(options?: {
599
677
  walletId?: string;
@@ -670,14 +748,14 @@ interface StorageAdapter {
670
748
  * Optional entry memo persistence (raw EntryService payloads).
671
749
  * Useful for debugging, rebuilds, and app-like local caches.
672
750
  */
673
- upsertEntryMemos?(memos: EntryMemoRecord[]): Promise<number> | number;
751
+ upsertEntryMemos?(memos: EntryMemoRecord[]): Promise<void> | void;
674
752
  listEntryMemos?(query: ListEntryMemosQuery): Promise<ListEntryMemosResult>;
675
753
  clearEntryMemos?(chainId: number): Promise<void> | void;
676
754
  /**
677
755
  * Optional entry nullifier persistence (raw EntryService payloads).
678
756
  * Useful for debugging and app-like local caches.
679
757
  */
680
- upsertEntryNullifiers?(nullifiers: EntryNullifierRecord[]): Promise<number> | number;
758
+ upsertEntryNullifiers?(nullifiers: EntryNullifierRecord[]): Promise<void> | void;
681
759
  listEntryNullifiers?(query: ListEntryNullifiersQuery): Promise<ListEntryNullifiersResult>;
682
760
  clearEntryNullifiers?(chainId: number): Promise<void> | void;
683
761
  /**
@@ -688,15 +766,26 @@ interface StorageAdapter {
688
766
  setMerkleTree?(chainId: number, tree: MerkleTreeState): Promise<void>;
689
767
  clearMerkleTree?(chainId: number): Promise<void>;
690
768
  }
769
+ /** WASM & circuit initialization. Call `ready()` before any proof operations. */
770
+ /** Core API for WASM initialization and eventing. */
691
771
  interface CoreApi {
772
+ /** Load Go WASM runtime, compile circuits, and initialize proof engine. */
692
773
  ready: (onProgress?: (value: number) => void) => Promise<void>;
774
+ /** Release WASM resources and reset internal state. */
693
775
  reset: () => void;
776
+ /** Subscribe to a specific SDK event type. */
694
777
  on: (type: SdkEvent['type'], handler: (event: SdkEvent) => void) => void;
778
+ /** Unsubscribe from a specific SDK event type. */
695
779
  off: (type: SdkEvent['type'], handler: (event: SdkEvent) => void) => void;
696
780
  }
781
+ /** Cryptographic primitives: Poseidon2 commitments, nullifiers, memo encryption. */
782
+ /** Crypto primitives exposed by the SDK. */
697
783
  interface CryptoApi {
784
+ /** Compute Poseidon2 commitment from record opening data. */
698
785
  commitment: CommitmentFn;
786
+ /** Derive nullifier = Poseidon2(commitment, secret_key, merkle_index). */
699
787
  nullifier: (secretKey: bigint, commitment: Hex, freezerPk?: [bigint, bigint]) => Hex;
788
+ /** Create a record opening with normalized BigInt fields and random blinding factor. */
700
789
  createRecordOpening: (input: {
701
790
  asset_id: bigint | number | string;
702
791
  asset_amount: bigint | number | string;
@@ -725,17 +814,26 @@ interface CryptoApi {
725
814
  serializeBigInt: <T>(value: T) => string;
726
815
  };
727
816
  }
817
+ /** BabyJubjub key derivation and address conversion. Seed must be >= 16 characters. */
818
+ /** Key derivation and address conversion API. */
728
819
  interface KeysApi {
820
+ /** Derive full key pair (secret + public) from seed via HKDF-SHA256. */
729
821
  deriveKeyPair: (seed: string, nonce?: string) => UserKeyPair;
822
+ /** Derive secret key only (includes public key). */
730
823
  getSecretKeyBySeed: (seed: string, nonce?: string) => UserSecretKey;
824
+ /** Derive public key only (no secret key exposure). */
731
825
  getPublicKeyBySeed: (seed: string, nonce?: string) => UserPublicKey;
826
+ /** Compress BabyJubjub public key to 32-byte viewing address (0x...). */
732
827
  userPkToAddress: (userPk: {
733
828
  user_address: [bigint | string, bigint | string];
734
829
  }) => Hex;
830
+ /** Decompress viewing address back to BabyJubjub public key point. */
735
831
  addressToUserPk: (address: Hex) => {
736
832
  user_address: [bigint, bigint];
737
833
  };
738
834
  }
835
+ /** Chain, token, and relayer configuration queries. */
836
+ /** Assets API for chain/token/relayer configuration. */
739
837
  interface AssetsApi {
740
838
  getChains: () => ChainConfigInput[];
741
839
  getChain: (chainId: number) => ChainConfigInput;
@@ -743,20 +841,28 @@ interface AssetsApi {
743
841
  getPoolInfo: (chainId: number, tokenId: string) => TokenMetadata | undefined;
744
842
  getAllowanceTarget: (chainId: number) => Address;
745
843
  appendTokens: (chainId: number, tokens: TokenMetadata[]) => void;
844
+ /** Load chain/token config from a remote JSON URL. */
746
845
  loadFromUrl: (url: string) => Promise<void>;
747
846
  getRelayerConfig: (chainId: number) => RelayerConfig | undefined;
847
+ /** Fetch latest relayer config (fees, limits) from the relayer service. */
748
848
  syncRelayerConfig: (chainId: number) => Promise<RelayerConfig>;
749
849
  syncAllRelayerConfigs: () => Promise<void>;
750
850
  }
851
+ /** Storage API exposure for adapter access. */
751
852
  interface StorageApi {
752
853
  getAdapter: () => StorageAdapter;
753
854
  }
855
+ /** Memo, nullifier, and Merkle tree synchronization from Entry service. */
856
+ /** Sync API for EntryService resources. */
754
857
  interface SyncApi {
858
+ /** Start background polling. Syncs immediately then repeats at `pollMs` interval. */
755
859
  start(options?: {
756
860
  chainIds?: number[];
757
861
  pollMs?: number;
758
862
  }): Promise<void>;
863
+ /** Stop polling and abort any in-flight sync. */
759
864
  stop(): void;
865
+ /** Run a single sync pass. Resolves when all requested resources are synced. */
760
866
  syncOnce(options?: {
761
867
  chainIds?: number[];
762
868
  resources?: Array<'memo' | 'nullifier' | 'merkle'>;
@@ -767,6 +873,7 @@ interface SyncApi {
767
873
  }): Promise<void>;
768
874
  getStatus(): Record<number, SyncChainStatus>;
769
875
  }
876
+ /** Merkle proof response shape from remote service. */
770
877
  interface RemoteMerkleProofResponse {
771
878
  proof: Array<{
772
879
  path: Array<Hex | BigintLikeString>;
@@ -775,6 +882,7 @@ interface RemoteMerkleProofResponse {
775
882
  merkle_root: Hex | BigintLikeString;
776
883
  latest_cid: number;
777
884
  }
885
+ /** Merkle API for proof generation and witness building. */
778
886
  interface MerkleApi {
779
887
  currentMerkleRootIndex: (totalElements: number, tempArraySize?: number) => number;
780
888
  /**
@@ -831,10 +939,16 @@ interface MerkleApi {
831
939
  maxInputs?: number;
832
940
  }) => Promise<InputSecret[]>;
833
941
  }
942
+ /** Wallet open session parameters. */
834
943
  interface WalletSessionInput {
944
+ /**
945
+ * Secret seed for key derivation (min 16 characters).
946
+ * Any passphrase, hex string, or raw bytes — internally run through HKDF-SHA256.
947
+ */
835
948
  seed: string | Uint8Array;
836
949
  accountNonce?: number;
837
950
  }
951
+ /** UTXO record stored in local persistence. */
838
952
  interface UtxoRecord {
839
953
  chainId: number;
840
954
  assetId: string;
@@ -847,19 +961,27 @@ interface UtxoRecord {
847
961
  memo?: Hex;
848
962
  createdAt?: number;
849
963
  }
964
+ /** Wallet session, UTXO queries, and balance. */
965
+ /** Wallet API for UTXO queries and session lifecycle. */
850
966
  interface WalletApi {
967
+ /** Open wallet session: derive keys from seed, initialize storage. */
851
968
  open(session: WalletSessionInput): Promise<void>;
969
+ /** Close session: release keys, flush storage. */
852
970
  close(): Promise<void>;
971
+ /** Query unspent UTXOs with optional filters. */
853
972
  getUtxos(query?: ListUtxosQuery): Promise<ListUtxosResult>;
854
- getBalance(query?: {
855
- chainId?: number;
856
- assetId?: string;
973
+ /** Get total balance (sum of unspent, unfrozen UTXO amounts). */
974
+ getBalance(query: {
975
+ chainId: number;
976
+ assetId: string;
857
977
  }): Promise<bigint>;
978
+ /** Mark UTXOs as spent by their nullifiers. */
858
979
  markSpent(input: {
859
980
  chainId: number;
860
981
  nullifiers: Hex[];
861
982
  }): Promise<void>;
862
983
  }
984
+ /** Planner estimate result for transfer. */
863
985
  type PlannerEstimateTransferResult = {
864
986
  action: 'transfer';
865
987
  chainId: number;
@@ -877,6 +999,7 @@ type PlannerEstimateTransferResult = {
877
999
  maxInputs: number;
878
1000
  };
879
1001
  };
1002
+ /** Planner estimate result for withdraw. */
880
1003
  type PlannerEstimateWithdrawResult = {
881
1004
  action: 'withdraw';
882
1005
  chainId: number;
@@ -894,7 +1017,9 @@ type PlannerEstimateWithdrawResult = {
894
1017
  requiresSingleInput: true;
895
1018
  };
896
1019
  };
1020
+ /** Planner estimate union. */
897
1021
  type PlannerEstimateResult = PlannerEstimateTransferResult | PlannerEstimateWithdrawResult;
1022
+ /** Summary of fees and inputs used by planner. */
898
1023
  type PlannerFeeSummary = {
899
1024
  mergeCount: number;
900
1025
  feeCount: number;
@@ -905,6 +1030,7 @@ type PlannerFeeSummary = {
905
1030
  cost: bigint;
906
1031
  inputCount: number;
907
1032
  };
1033
+ /** Planner max estimate result for transfer/withdraw. */
908
1034
  type PlannerMaxEstimateResult = {
909
1035
  action: 'transfer' | 'withdraw';
910
1036
  chainId: number;
@@ -912,6 +1038,7 @@ type PlannerMaxEstimateResult = {
912
1038
  ok: boolean;
913
1039
  maxSummary: PlannerFeeSummary;
914
1040
  };
1041
+ /** Transfer plan with inputs/outputs and proof binding. */
915
1042
  type TransferPlan = {
916
1043
  action: 'transfer';
917
1044
  chainId: number;
@@ -933,6 +1060,7 @@ type TransferPlan = {
933
1060
  extraData: readonly [Hex, Hex, Hex];
934
1061
  proofBinding: string;
935
1062
  };
1063
+ /** Transfer-merge plan including merge step. */
936
1064
  type TransferMergePlan = {
937
1065
  action: 'transfer-merge';
938
1066
  chainId: number;
@@ -949,6 +1077,7 @@ type TransferMergePlan = {
949
1077
  maxSummary: PlannerFeeSummary;
950
1078
  mergePlan: TransferPlan;
951
1079
  };
1080
+ /** Withdraw plan with input/output and proof binding. */
952
1081
  type WithdrawPlan = {
953
1082
  action: 'withdraw';
954
1083
  chainId: number;
@@ -970,8 +1099,12 @@ type WithdrawPlan = {
970
1099
  proofBinding: string;
971
1100
  recipient: Hex;
972
1101
  };
1102
+ /** Planner plan union. */
973
1103
  type PlannerPlanResult = TransferPlan | TransferMergePlan | WithdrawPlan;
1104
+ /** Coin selection, fee estimation, and transaction planning. */
1105
+ /** Planner API for fee estimation and plan creation. */
974
1106
  interface PlannerApi {
1107
+ /** Estimate fees and check if balance is sufficient for an operation. */
975
1108
  estimate(input: {
976
1109
  chainId: number;
977
1110
  assetId: string;
@@ -979,26 +1112,32 @@ interface PlannerApi {
979
1112
  amount: bigint;
980
1113
  payIncludesFee?: boolean;
981
1114
  }): Promise<PlannerEstimateResult>;
1115
+ /** Calculate the maximum transferable/withdrawable amount after fees. */
982
1116
  estimateMax(input: {
983
1117
  chainId: number;
984
1118
  assetId: string;
985
1119
  action: 'transfer' | 'withdraw';
986
1120
  payIncludesFee?: boolean;
987
1121
  }): Promise<PlannerMaxEstimateResult>;
1122
+ /** Build a full transaction plan (coin selection, outputs, proof binding). */
988
1123
  plan(input: Record<string, unknown>): Promise<PlannerPlanResult>;
989
1124
  }
1125
+ /** zk-SNARK proof generation via Go WASM (Groth16). Requires `core.ready()`. */
1126
+ /** ZKP API for witness/proof generation. */
990
1127
  interface ZkpApi {
991
1128
  createWitnessTransfer: (input: TransferWitnessInput, context?: WitnessContext) => Promise<WitnessBuildResult>;
992
1129
  createWitnessWithdraw: (input: WithdrawWitnessInput, context?: WitnessContext) => Promise<WitnessBuildResult>;
993
1130
  proveTransfer: (witness: TransferWitnessInput | string, context?: WitnessContext) => Promise<ProofResult>;
994
1131
  proveWithdraw: (witness: WithdrawWitnessInput | string, context?: WitnessContext) => Promise<ProofResult>;
995
1132
  }
1133
+ /** Relayer request payload built from proofs. */
996
1134
  interface RelayerRequest {
997
1135
  kind: 'relayer';
998
1136
  method: 'POST';
999
1137
  path: string;
1000
1138
  body: Record<string, unknown>;
1001
1139
  }
1140
+ /** Tx builder API for relayer request construction. */
1002
1141
  interface TxBuilderApi {
1003
1142
  buildTransferCalldata: (input: {
1004
1143
  chainId: number;
@@ -1009,7 +1148,10 @@ interface TxBuilderApi {
1009
1148
  proof: ProofResult;
1010
1149
  }) => Promise<RelayerRequest>;
1011
1150
  }
1151
+ /** End-to-end operation orchestration: plan → Merkle proof → witness → zk-SNARK proof → relayer request. */
1152
+ /** Ops API for end-to-end operations (plan → proof → relayer). */
1012
1153
  interface OpsApi {
1154
+ /** Prepare a private transfer (auto-merges UTXOs if needed when `autoMerge: true`). */
1013
1155
  prepareTransfer(input: {
1014
1156
  chainId: number;
1015
1157
  assetId: string;
@@ -1053,6 +1195,7 @@ interface OpsApi {
1053
1195
  autoMerge?: boolean;
1054
1196
  };
1055
1197
  }>;
1198
+ /** Prepare a withdrawal to an EVM address. Optionally includes gas drop. */
1056
1199
  prepareWithdraw(input: {
1057
1200
  chainId: number;
1058
1201
  assetId: string;
@@ -1073,6 +1216,7 @@ interface OpsApi {
1073
1216
  relayer: Address;
1074
1217
  };
1075
1218
  }>;
1219
+ /** Prepare a deposit: compute commitment, memo, and build contract call requests. */
1076
1220
  prepareDeposit(input: {
1077
1221
  chainId: number;
1078
1222
  assetId: string;
@@ -1108,6 +1252,7 @@ interface OpsApi {
1108
1252
  value: bigint;
1109
1253
  };
1110
1254
  }>;
1255
+ /** Execute deposit on-chain: optionally auto-approve ERC-20 then call deposit(). */
1111
1256
  submitDeposit(input: {
1112
1257
  prepared: Awaited<ReturnType<OpsApi['prepareDeposit']>>;
1113
1258
  walletClient: {
@@ -1147,6 +1292,7 @@ interface OpsApi {
1147
1292
  confirmations?: number;
1148
1293
  operationId?: string;
1149
1294
  }): Promise<TransactionReceipt>;
1295
+ /** Submit prepared transfer/withdraw to relayer and optionally wait for tx confirmation. */
1150
1296
  submitRelayerRequest<T = unknown>(input: {
1151
1297
  prepared: {
1152
1298
  plan: TransferPlan | WithdrawPlan;
@@ -1171,51 +1317,110 @@ interface OpsApi {
1171
1317
  transactionReceipt?: Promise<TransactionReceipt>;
1172
1318
  }>;
1173
1319
  }
1320
+ /**
1321
+ * The SDK instance returned by `createSdk(config)`.
1322
+ *
1323
+ * Lifecycle: `core.ready()` → `wallet.open()` → `sync.syncOnce()` → operations → `wallet.close()`
1324
+ */
1325
+ /** SDK instance returned by createSdk(config). */
1174
1326
  interface OCashSdk {
1327
+ /** WASM & circuit initialization. */
1175
1328
  core: CoreApi;
1329
+ /** Poseidon2 commitments, nullifiers, memo encryption. */
1176
1330
  crypto: CryptoApi;
1331
+ /** BabyJubjub key derivation and address conversion. */
1177
1332
  keys: KeysApi;
1333
+ /** Chain, token, and relayer configuration. */
1178
1334
  assets: AssetsApi;
1335
+ /** Persistence adapter access. */
1179
1336
  storage: StorageApi;
1337
+ /** Memo/nullifier/Merkle sync from Entry service. */
1180
1338
  sync: SyncApi;
1339
+ /** Merkle proofs and membership witnesses. */
1181
1340
  merkle: MerkleApi;
1341
+ /** Wallet session, UTXO queries, balance. */
1182
1342
  wallet: WalletApi;
1343
+ /** Coin selection, fee estimation, transaction planning. */
1183
1344
  planner: PlannerApi;
1345
+ /** zk-SNARK proof generation (Groth16 via Go WASM). */
1184
1346
  zkp: ZkpApi;
1347
+ /** Relayer request payload builder. */
1185
1348
  tx: TxBuilderApi;
1349
+ /** End-to-end operation orchestration. */
1186
1350
  ops: OpsApi;
1187
1351
  }
1352
+ /** User public key. */
1188
1353
  interface UserPublicKey {
1189
1354
  user_pk: {
1190
1355
  user_address: [bigint, bigint];
1191
1356
  };
1192
1357
  }
1358
+ /** User secret key (includes public key). */
1193
1359
  interface UserSecretKey extends UserPublicKey {
1194
1360
  user_sk: {
1195
1361
  address_sk: bigint;
1196
1362
  };
1197
1363
  }
1364
+ /** User key pair alias (secret + public). */
1198
1365
  interface UserKeyPair extends UserSecretKey {
1199
1366
  }
1200
1367
 
1201
- declare const defaultAssetsOverride: AssetsOverride;
1368
+ /**
1369
+ * Default asset overrides for testnet environments.
1370
+ * Assets can be sharded across multiple URLs for large files.
1371
+ */
1372
+ declare const defaultAssetsOverrideTestnet: AssetsOverride;
1373
+ /**
1374
+ * Default asset overrides for mainnet environments.
1375
+ * Assets can be sharded across multiple URLs for large files.
1376
+ */
1377
+ declare const defaultAssetsOverrideMainnet: AssetsOverride;
1202
1378
 
1379
+ /**
1380
+ * Memo helpers for encrypting/decrypting record openings.
1381
+ */
1203
1382
  declare class MemoKit {
1383
+ /**
1384
+ * Encrypt a record opening into a memo payload.
1385
+ * Payload = ephemeral PK (32 bytes) + NaCl secretbox ciphertext.
1386
+ */
1204
1387
  static createMemo(ro: CommitmentData): `0x${string}`;
1388
+ /**
1389
+ * Decrypt a memo with the owner's secret key.
1390
+ * Returns null if decryption fails or payload is invalid.
1391
+ */
1205
1392
  static decryptMemo(secretKey: bigint, encoded: `0x${string}`): CommitmentData | null;
1393
+ /**
1394
+ * Decode memo for owner with transparent fallback.
1395
+ * If isTransparent=true, treat memo as plaintext record opening.
1396
+ */
1206
1397
  static decodeMemoForOwner(input: {
1207
1398
  secretKey: bigint;
1208
1399
  memo: Hex;
1209
1400
  expectedAddress?: Hex | null;
1210
1401
  isTransparent?: boolean;
1211
1402
  }): CommitmentData | null;
1403
+ /**
1404
+ * Expose memo nonce derivation for advanced usage/tests.
1405
+ */
1212
1406
  static memoNonce(ephemeralPublicKey: [bigint, bigint], userPublicKey: [bigint, bigint]): Uint8Array;
1213
1407
  }
1214
1408
 
1409
+ /**
1410
+ * Cryptographic helpers for commitments, nullifiers, and record openings.
1411
+ */
1215
1412
  declare class CryptoToolkit {
1216
1413
  static commitment(record: CommitmentData, format: 'hex'): Hex;
1217
1414
  static commitment(record: CommitmentData, format: 'bigint'): bigint;
1415
+ /**
1416
+ * Compute nullifier for a commitment using secret key and optional freezer PK.
1417
+ * If freezer PK is default (0,1), the secret key is used directly.
1418
+ */
1218
1419
  static nullifier(secretKey: bigint, commitment: `0x${string}`, freezerPk?: [bigint, bigint]): `0x${string}`;
1420
+ /**
1421
+ * Create a record opening with normalized fields and a random blinding factor.
1422
+ * Ensures non-zero commitment when auto-generating the blinding factor.
1423
+ */
1219
1424
  static createRecordOpening(input: {
1220
1425
  asset_id: bigint | number | string;
1221
1426
  asset_amount: bigint | number | string;
@@ -1225,53 +1430,134 @@ declare class CryptoToolkit {
1225
1430
  blinding_factor?: bigint | number | string;
1226
1431
  is_frozen?: boolean;
1227
1432
  }): CommitmentData;
1433
+ /**
1434
+ * Generate randomness for memo encryption (BabyJubjub scalar).
1435
+ */
1228
1436
  static viewingRandomness(): Uint8Array;
1437
+ /**
1438
+ * Compute pool id from token address and policy keys.
1439
+ */
1229
1440
  static poolId(tokenAddress: Hex | bigint | number | string, viewerPk: [bigint, bigint], freezerPk: [bigint, bigint]): bigint;
1230
1441
  }
1231
1442
 
1443
+ /**
1444
+ * Key derivation and address conversion utilities.
1445
+ */
1232
1446
  declare class KeyManager {
1447
+ /**
1448
+ * Derive a full keypair from seed and optional nonce.
1449
+ */
1233
1450
  static deriveKeyPair(seed: string, nonce?: string): UserKeyPair;
1451
+ /**
1452
+ * Derive public key only from seed (no secret exposure).
1453
+ */
1234
1454
  static getPublicKeyBySeed(seed: string, nonce?: string): UserPublicKey;
1455
+ /**
1456
+ * Derive secret key object from seed (includes public key).
1457
+ */
1235
1458
  static getSecretKeyBySeed(seed: string, nonce?: string): UserSecretKey;
1459
+ /**
1460
+ * Compress BabyJubjub public key into an OCash viewing address.
1461
+ */
1236
1462
  static userPkToAddress(userPk: {
1237
1463
  user_address: [bigint | string, bigint | string];
1238
1464
  }): Hex;
1465
+ /**
1466
+ * Decompress an OCash viewing address back to BabyJubjub public key.
1467
+ */
1239
1468
  static addressToUserPk(address: Hex): {
1240
1469
  user_address: [bigint, bigint];
1241
1470
  };
1242
1471
  }
1243
1472
 
1473
+ /**
1474
+ * In-memory ledger registry for chain, token, and relayer configuration.
1475
+ * Acts as the canonical config source for assets APIs.
1476
+ */
1244
1477
  declare class LedgerInfo {
1245
1478
  private readonly chains;
1246
1479
  private readonly relayerManager;
1480
+ /**
1481
+ * Initialize with optional chain configs and prepare relayer manager.
1482
+ */
1247
1483
  constructor(initialChains?: ChainConfigInput[]);
1484
+ /**
1485
+ * Validate and upsert a chain config. Tokens are cloned defensively.
1486
+ */
1248
1487
  private upsertChain;
1488
+ /**
1489
+ * Return all registered chains (deep-cloned token arrays).
1490
+ */
1249
1491
  getChains(): ChainConfigInput[];
1492
+ /**
1493
+ * Lookup a chain by id. Throws if not registered.
1494
+ */
1250
1495
  getChain(chainId: number): ChainConfigInput;
1496
+ /**
1497
+ * Get token list for a chain (cloned).
1498
+ */
1251
1499
  getTokens(chainId: number): TokenMetadata[];
1500
+ /**
1501
+ * Get token metadata for a specific pool id on a chain.
1502
+ */
1252
1503
  getPoolInfo(chainId: number, tokenId: string): TokenMetadata | undefined;
1504
+ /**
1505
+ * Resolve the allowance target address for ERC20 approvals.
1506
+ * Uses ocashContractAddress, falling back to legacy contract field.
1507
+ */
1253
1508
  getAllowanceTarget(chainId: number): Address;
1509
+ /**
1510
+ * Append/merge tokens into an existing chain.
1511
+ * Token ids are treated as unique keys and overwrite duplicates.
1512
+ */
1254
1513
  appendTokens(chainId: number, tokens: TokenMetadata[]): void;
1514
+ /**
1515
+ * Load ledger config from a remote JSON file and refresh relayer configs.
1516
+ */
1255
1517
  loadFromUrl(url: string): Promise<void>;
1518
+ /**
1519
+ * Return cached relayer config (if present and fresh).
1520
+ */
1256
1521
  getRelayerConfig(chainId: number): RelayerConfig | undefined;
1522
+ /**
1523
+ * Fetch and cache relayer config for a single chain.
1524
+ */
1257
1525
  syncRelayerConfig(chainId: number): Promise<RelayerConfig>;
1526
+ /**
1527
+ * Fetch and cache relayer configs for all chains.
1528
+ */
1258
1529
  syncAllRelayerConfigs(): Promise<void>;
1259
1530
  }
1260
1531
 
1532
+ type TokenMetadataInput = Omit<TokenMetadata, 'viewerPk' | 'freezerPk' | 'depositFeeBps' | 'withdrawFeeBps'> & {
1533
+ viewerPk: readonly [string, string] | readonly [bigint, bigint];
1534
+ freezerPk: readonly [string, string] | readonly [bigint, bigint];
1535
+ depositFeeBps?: number | bigint;
1536
+ withdrawFeeBps?: number | bigint;
1537
+ };
1261
1538
  /**
1262
- * Normalize token metadata from app-style or sdk-style shapes.
1263
- *
1264
- * Supported legacy fields (app):
1265
- * - `wrapped_erc20` (instead of `wrappedErc20`)
1266
- * - `viewerPK` / `freezerPK` (instead of `viewerPk` / `freezerPk`)
1267
- * - `depositFeeBPS` / `withdrawFeeBPS` (instead of `depositFeeBps` / `withdrawFeeBps`)
1539
+ * Normalize arbitrary token metadata inputs into strict TokenMetadata.
1540
+ * Ensures valid addresses, PK shapes, and fee/limit fields.
1268
1541
  */
1269
- declare const normalizeTokenMetadata: (input: unknown) => TokenMetadata;
1542
+ declare const normalizeTokenMetadata: (input: TokenMetadataInput) => TokenMetadata;
1270
1543
 
1544
+ /**
1545
+ * Validate token metadata input at runtime. Throws SdkError on mismatch.
1546
+ */
1271
1547
  declare function assertTokenMetadata(value: unknown, name?: string): asserts value is TokenMetadata;
1548
+ /**
1549
+ * Validate a list of tokens.
1550
+ */
1272
1551
  declare function assertTokenList(value: unknown, name?: string): asserts value is TokenMetadata[];
1552
+ /**
1553
+ * Validate a chain config input at runtime. Throws SdkError on mismatch.
1554
+ */
1273
1555
  declare function assertChainConfigInput(value: unknown, name?: string): asserts value is ChainConfigInput;
1274
1556
 
1557
+ /**
1558
+ * Read pool metadata from the OCash contract and return normalized TokenMetadata[].
1559
+ * Optionally includes ERC20 symbol/decimals via a second multicall.
1560
+ */
1275
1561
  declare function fetchPoolTokensFromContract(input: {
1276
1562
  publicClient: PublicClient;
1277
1563
  chainId: number;
@@ -1280,13 +1566,25 @@ declare function fetchPoolTokensFromContract(input: {
1280
1566
  includeErc20Metadata?: boolean;
1281
1567
  }): Promise<TokenMetadata[]>;
1282
1568
 
1569
+ /**
1570
+ * Wrapper around ProofBridge dummy helpers.
1571
+ */
1283
1572
  declare class DummyFactory {
1284
1573
  private readonly bridge;
1285
1574
  constructor(bridge: ProofBridge);
1575
+ /**
1576
+ * Create a dummy record opening via the WASM bridge.
1577
+ */
1286
1578
  createRecordOpening(): Promise<CommitmentData>;
1579
+ /**
1580
+ * Create a dummy input secret via the WASM bridge.
1581
+ */
1287
1582
  createInputSecret(): Promise<InputSecret>;
1288
1583
  }
1289
1584
 
1585
+ /**
1586
+ * Convenience namespace for commonly used utils.
1587
+ */
1290
1588
  declare const Utils: {
1291
1589
  calcDepositFee: (amount: bigint, feeBps?: number) => bigint;
1292
1590
  randomBytes32: () => Uint8Array<ArrayBufferLike>;
@@ -1296,10 +1594,16 @@ declare const Utils: {
1296
1594
 
1297
1595
  declare const BABYJUBJUB_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
1298
1596
 
1597
+ /**
1598
+ * Compute the proof binding for transfer proofs (relayer + extra data).
1599
+ */
1299
1600
  declare function calcTransferProofBinding(input: {
1300
1601
  relayer: string;
1301
1602
  extraData: TransferExtraData;
1302
1603
  }): bigint;
1604
+ /**
1605
+ * Compute the proof binding for withdraw proofs (relayer + recipient + fees).
1606
+ */
1303
1607
  declare function calcWithdrawProofBinding(input: {
1304
1608
  recipient: string;
1305
1609
  amount: bigint;
@@ -1309,22 +1613,32 @@ declare function calcWithdrawProofBinding(input: {
1309
1613
  extraData: Hex;
1310
1614
  }): bigint;
1311
1615
 
1616
+ /**
1617
+ * OCash contract ABI (functions/events/errors) used by the SDK.
1618
+ * This is a trimmed Foundry ABI without internalType/constructor/receive.
1619
+ */
1312
1620
  declare const App_ABI: readonly [{
1313
1621
  readonly type: "function";
1314
- readonly name: "depositRelayerFee";
1622
+ readonly name: "DomainArray";
1315
1623
  readonly inputs: readonly [];
1316
1624
  readonly outputs: readonly [{
1317
1625
  readonly name: "";
1318
- readonly type: "uint128";
1626
+ readonly type: "uint256";
1319
1627
  }];
1320
1628
  readonly stateMutability: "view";
1321
1629
  }, {
1322
1630
  readonly type: "function";
1323
- readonly name: "poolIds";
1324
- readonly inputs: readonly [{
1631
+ readonly name: "DomainMerkle";
1632
+ readonly inputs: readonly [];
1633
+ readonly outputs: readonly [{
1325
1634
  readonly name: "";
1326
1635
  readonly type: "uint256";
1327
1636
  }];
1637
+ readonly stateMutability: "view";
1638
+ }, {
1639
+ readonly type: "function";
1640
+ readonly name: "DomainNullifier";
1641
+ readonly inputs: readonly [];
1328
1642
  readonly outputs: readonly [{
1329
1643
  readonly name: "";
1330
1644
  readonly type: "uint256";
@@ -1332,178 +1646,1150 @@ declare const App_ABI: readonly [{
1332
1646
  readonly stateMutability: "view";
1333
1647
  }, {
1334
1648
  readonly type: "function";
1335
- readonly name: "getPoolInfo";
1336
- readonly inputs: readonly [{
1337
- readonly name: "poolId";
1649
+ readonly name: "DomainPolicy";
1650
+ readonly inputs: readonly [];
1651
+ readonly outputs: readonly [{
1652
+ readonly name: "";
1338
1653
  readonly type: "uint256";
1339
1654
  }];
1655
+ readonly stateMutability: "view";
1656
+ }, {
1657
+ readonly type: "function";
1658
+ readonly name: "DomainRecord";
1659
+ readonly inputs: readonly [];
1340
1660
  readonly outputs: readonly [{
1341
1661
  readonly name: "";
1342
- readonly type: "tuple";
1343
- readonly components: readonly [{
1344
- readonly name: "token";
1345
- readonly type: "address";
1346
- }, {
1347
- readonly name: "depositFeeBPS";
1348
- readonly type: "uint16";
1349
- }, {
1350
- readonly name: "withdrawFeeBPS";
1351
- readonly type: "uint16";
1352
- }, {
1353
- readonly name: "accumulatedFee";
1354
- readonly type: "uint128";
1355
- }, {
1356
- readonly name: "viewerPK";
1357
- readonly type: "uint256[2]";
1358
- }, {
1359
- readonly name: "freezerPK";
1360
- readonly type: "uint256[2]";
1361
- }, {
1362
- readonly name: "transferMaxAmount";
1363
- readonly type: "uint128";
1364
- }, {
1365
- readonly name: "withdrawMaxAmount";
1366
- readonly type: "uint128";
1367
- }];
1662
+ readonly type: "uint256";
1368
1663
  }];
1369
1664
  readonly stateMutability: "view";
1370
1665
  }, {
1371
1666
  readonly type: "function";
1372
- readonly name: "deposit";
1373
- readonly inputs: readonly [{
1374
- readonly name: "poolId";
1375
- readonly type: "uint256";
1376
- }, {
1377
- readonly name: "amount";
1378
- readonly type: "uint128";
1379
- }, {
1380
- readonly name: "userPK";
1381
- readonly type: "uint256[2]";
1382
- }, {
1383
- readonly name: "nonce";
1384
- readonly type: "uint256";
1385
- }, {
1667
+ readonly name: "FREEZE_VERIFIER";
1668
+ readonly inputs: readonly [];
1669
+ readonly outputs: readonly [{
1386
1670
  readonly name: "";
1387
- readonly type: "bytes";
1671
+ readonly type: "address";
1388
1672
  }];
1389
- readonly outputs: readonly [];
1390
- readonly stateMutability: "payable";
1673
+ readonly stateMutability: "view";
1391
1674
  }, {
1392
1675
  readonly type: "function";
1393
- readonly name: "getArray";
1676
+ readonly name: "NATIVE_TOKEN_ADDRESS";
1394
1677
  readonly inputs: readonly [];
1395
1678
  readonly outputs: readonly [{
1396
1679
  readonly name: "";
1397
- readonly type: "uint256[]";
1680
+ readonly type: "address";
1398
1681
  }];
1399
1682
  readonly stateMutability: "view";
1400
1683
  }, {
1401
1684
  readonly type: "function";
1402
- readonly name: "digest";
1685
+ readonly name: "POSEIDON2";
1403
1686
  readonly inputs: readonly [];
1404
1687
  readonly outputs: readonly [{
1405
- readonly name: "merkleTreeRoot";
1406
- readonly type: "uint256";
1407
- }, {
1408
- readonly name: "currentArrayHash";
1409
- readonly type: "uint256";
1688
+ readonly name: "";
1689
+ readonly type: "address";
1410
1690
  }];
1411
1691
  readonly stateMutability: "view";
1412
1692
  }, {
1413
1693
  readonly type: "function";
1414
- readonly name: "totalElements";
1694
+ readonly name: "TRANSFER_VERIFIER";
1415
1695
  readonly inputs: readonly [];
1416
1696
  readonly outputs: readonly [{
1417
1697
  readonly name: "";
1418
- readonly type: "uint256";
1698
+ readonly type: "address";
1419
1699
  }];
1420
1700
  readonly stateMutability: "view";
1421
1701
  }, {
1422
1702
  readonly type: "function";
1423
- readonly name: "merkleRoots";
1703
+ readonly name: "WITHDRAW_VERIFIER";
1704
+ readonly inputs: readonly [];
1705
+ readonly outputs: readonly [{
1706
+ readonly name: "";
1707
+ readonly type: "address";
1708
+ }];
1709
+ readonly stateMutability: "view";
1710
+ }, {
1711
+ readonly type: "function";
1712
+ readonly name: "accumulatedRelayerFees";
1424
1713
  readonly inputs: readonly [{
1425
1714
  readonly name: "";
1426
- readonly type: "uint256";
1715
+ readonly type: "address";
1716
+ }, {
1717
+ readonly name: "";
1718
+ readonly type: "address";
1427
1719
  }];
1428
1720
  readonly outputs: readonly [{
1429
1721
  readonly name: "";
1430
- readonly type: "uint256";
1722
+ readonly type: "uint128";
1431
1723
  }];
1432
1724
  readonly stateMutability: "view";
1433
1725
  }, {
1434
- readonly type: "event";
1435
- readonly name: "ArrayMergedToTree";
1726
+ readonly type: "function";
1727
+ readonly name: "array";
1436
1728
  readonly inputs: readonly [{
1437
- readonly name: "batchIndex";
1438
- readonly type: "uint256";
1439
- readonly indexed: true;
1440
- }, {
1441
- readonly name: "newRoot";
1729
+ readonly name: "";
1442
1730
  readonly type: "uint256";
1443
- readonly indexed: true;
1444
1731
  }];
1445
- readonly anonymous: false;
1446
- }];
1447
-
1448
- declare const ERC20_ABI: readonly [{
1449
- readonly type: "function";
1450
- readonly name: "name";
1451
- readonly inputs: readonly [];
1452
1732
  readonly outputs: readonly [{
1453
1733
  readonly name: "";
1454
- readonly type: "string";
1734
+ readonly type: "uint256";
1455
1735
  }];
1456
1736
  readonly stateMutability: "view";
1457
1737
  }, {
1458
1738
  readonly type: "function";
1459
- readonly name: "symbol";
1460
- readonly inputs: readonly [];
1739
+ readonly name: "arrayHashes";
1740
+ readonly inputs: readonly [{
1741
+ readonly name: "";
1742
+ readonly type: "uint256";
1743
+ }];
1461
1744
  readonly outputs: readonly [{
1462
1745
  readonly name: "";
1463
- readonly type: "string";
1746
+ readonly type: "uint256";
1464
1747
  }];
1465
1748
  readonly stateMutability: "view";
1466
1749
  }, {
1467
1750
  readonly type: "function";
1468
- readonly name: "decimals";
1751
+ readonly name: "arraySize";
1469
1752
  readonly inputs: readonly [];
1470
1753
  readonly outputs: readonly [{
1471
1754
  readonly name: "";
1472
- readonly type: "uint8";
1755
+ readonly type: "uint256";
1473
1756
  }];
1474
1757
  readonly stateMutability: "view";
1475
1758
  }, {
1476
1759
  readonly type: "function";
1477
- readonly name: "allowance";
1760
+ readonly name: "claimProtocolFees";
1478
1761
  readonly inputs: readonly [{
1479
- readonly name: "owner";
1480
- readonly type: "address";
1481
- }, {
1482
- readonly name: "spender";
1483
- readonly type: "address";
1484
- }];
1485
- readonly outputs: readonly [{
1486
- readonly name: "";
1762
+ readonly name: "poolId";
1487
1763
  readonly type: "uint256";
1488
1764
  }];
1489
- readonly stateMutability: "view";
1765
+ readonly outputs: readonly [];
1766
+ readonly stateMutability: "nonpayable";
1490
1767
  }, {
1491
1768
  readonly type: "function";
1492
- readonly name: "approve";
1769
+ readonly name: "claimRelayerFees";
1493
1770
  readonly inputs: readonly [{
1494
- readonly name: "spender";
1771
+ readonly name: "token";
1495
1772
  readonly type: "address";
1496
- }, {
1497
- readonly name: "amount";
1773
+ }];
1774
+ readonly outputs: readonly [];
1775
+ readonly stateMutability: "nonpayable";
1776
+ }, {
1777
+ readonly type: "function";
1778
+ readonly name: "commitments";
1779
+ readonly inputs: readonly [{
1780
+ readonly name: "";
1498
1781
  readonly type: "uint256";
1499
1782
  }];
1500
1783
  readonly outputs: readonly [{
1501
1784
  readonly name: "";
1502
1785
  readonly type: "bool";
1503
1786
  }];
1504
- readonly stateMutability: "nonpayable";
1787
+ readonly stateMutability: "view";
1788
+ }, {
1789
+ readonly type: "function";
1790
+ readonly name: "deposit";
1791
+ readonly inputs: readonly [{
1792
+ readonly name: "poolId";
1793
+ readonly type: "uint256";
1794
+ }, {
1795
+ readonly name: "amount";
1796
+ readonly type: "uint128";
1797
+ }, {
1798
+ readonly name: "userPK";
1799
+ readonly type: "uint256[2]";
1800
+ }, {
1801
+ readonly name: "nonce";
1802
+ readonly type: "uint256";
1803
+ }, {
1804
+ readonly name: "";
1805
+ readonly type: "bytes";
1806
+ }];
1807
+ readonly outputs: readonly [];
1808
+ readonly stateMutability: "payable";
1809
+ }, {
1810
+ readonly type: "function";
1811
+ readonly name: "depositRelayerFee";
1812
+ readonly inputs: readonly [];
1813
+ readonly outputs: readonly [{
1814
+ readonly name: "";
1815
+ readonly type: "uint128";
1816
+ }];
1817
+ readonly stateMutability: "view";
1818
+ }, {
1819
+ readonly type: "function";
1820
+ readonly name: "digest";
1821
+ readonly inputs: readonly [];
1822
+ readonly outputs: readonly [{
1823
+ readonly name: "merkleTreeRoot";
1824
+ readonly type: "uint256";
1825
+ }, {
1826
+ readonly name: "currentArrayHash";
1827
+ readonly type: "uint256";
1828
+ }];
1829
+ readonly stateMutability: "view";
1830
+ }, {
1831
+ readonly type: "function";
1832
+ readonly name: "freeze";
1833
+ readonly inputs: readonly [{
1834
+ readonly name: "poolId";
1835
+ readonly type: "uint256";
1836
+ }, {
1837
+ readonly name: "merkleRootIndex";
1838
+ readonly type: "uint256";
1839
+ }, {
1840
+ readonly name: "arrayHashIndex";
1841
+ readonly type: "uint256";
1842
+ }, {
1843
+ readonly name: "inputNullifiers";
1844
+ readonly type: "uint256[3]";
1845
+ }, {
1846
+ readonly name: "outputs";
1847
+ readonly type: "uint256[3]";
1848
+ }, {
1849
+ readonly name: "proof";
1850
+ readonly type: "uint256[8]";
1851
+ }, {
1852
+ readonly name: "viewerData";
1853
+ readonly type: "uint256[17]";
1854
+ }, {
1855
+ readonly name: "extraData";
1856
+ readonly type: "bytes";
1857
+ }];
1858
+ readonly outputs: readonly [];
1859
+ readonly stateMutability: "nonpayable";
1860
+ }, {
1861
+ readonly type: "function";
1862
+ readonly name: "frontier";
1863
+ readonly inputs: readonly [{
1864
+ readonly name: "";
1865
+ readonly type: "uint256";
1866
+ }];
1867
+ readonly outputs: readonly [{
1868
+ readonly name: "";
1869
+ readonly type: "uint256";
1870
+ }];
1871
+ readonly stateMutability: "view";
1872
+ }, {
1873
+ readonly type: "function";
1874
+ readonly name: "getArray";
1875
+ readonly inputs: readonly [];
1876
+ readonly outputs: readonly [{
1877
+ readonly name: "";
1878
+ readonly type: "uint256[]";
1879
+ }];
1880
+ readonly stateMutability: "view";
1881
+ }, {
1882
+ readonly type: "function";
1883
+ readonly name: "getLastArrayHash";
1884
+ readonly inputs: readonly [];
1885
+ readonly outputs: readonly [{
1886
+ readonly name: "";
1887
+ readonly type: "uint256";
1888
+ }];
1889
+ readonly stateMutability: "view";
1890
+ }, {
1891
+ readonly type: "function";
1892
+ readonly name: "getLastRoot";
1893
+ readonly inputs: readonly [];
1894
+ readonly outputs: readonly [{
1895
+ readonly name: "";
1896
+ readonly type: "uint256";
1897
+ }];
1898
+ readonly stateMutability: "view";
1899
+ }, {
1900
+ readonly type: "function";
1901
+ readonly name: "getPendingDepositsCount";
1902
+ readonly inputs: readonly [];
1903
+ readonly outputs: readonly [{
1904
+ readonly name: "";
1905
+ readonly type: "uint256";
1906
+ }];
1907
+ readonly stateMutability: "view";
1908
+ }, {
1909
+ readonly type: "function";
1910
+ readonly name: "getPoolInfo";
1911
+ readonly inputs: readonly [{
1912
+ readonly name: "poolId";
1913
+ readonly type: "uint256";
1914
+ }];
1915
+ readonly outputs: readonly [{
1916
+ readonly name: "";
1917
+ readonly type: "tuple";
1918
+ readonly components: readonly [{
1919
+ readonly name: "token";
1920
+ readonly type: "address";
1921
+ }, {
1922
+ readonly name: "depositFeeBPS";
1923
+ readonly type: "uint16";
1924
+ }, {
1925
+ readonly name: "withdrawFeeBPS";
1926
+ readonly type: "uint16";
1927
+ }, {
1928
+ readonly name: "accumulatedFee";
1929
+ readonly type: "uint128";
1930
+ }, {
1931
+ readonly name: "viewerPK";
1932
+ readonly type: "uint256[2]";
1933
+ }, {
1934
+ readonly name: "freezerPK";
1935
+ readonly type: "uint256[2]";
1936
+ }, {
1937
+ readonly name: "transferMaxAmount";
1938
+ readonly type: "uint128";
1939
+ }, {
1940
+ readonly name: "withdrawMaxAmount";
1941
+ readonly type: "uint128";
1942
+ }];
1943
+ }];
1944
+ readonly stateMutability: "view";
1945
+ }, {
1946
+ readonly type: "function";
1947
+ readonly name: "initialize";
1948
+ readonly inputs: readonly [{
1949
+ readonly name: "_depositRelayerFee";
1950
+ readonly type: "uint128";
1951
+ }];
1952
+ readonly outputs: readonly [];
1953
+ readonly stateMutability: "nonpayable";
1954
+ }, {
1955
+ readonly type: "function";
1956
+ readonly name: "merkleRoots";
1957
+ readonly inputs: readonly [{
1958
+ readonly name: "";
1959
+ readonly type: "uint256";
1960
+ }];
1961
+ readonly outputs: readonly [{
1962
+ readonly name: "";
1963
+ readonly type: "uint256";
1964
+ }];
1965
+ readonly stateMutability: "view";
1966
+ }, {
1967
+ readonly type: "function";
1968
+ readonly name: "nullifiers";
1969
+ readonly inputs: readonly [{
1970
+ readonly name: "";
1971
+ readonly type: "uint256";
1972
+ }];
1973
+ readonly outputs: readonly [{
1974
+ readonly name: "";
1975
+ readonly type: "bool";
1976
+ }];
1977
+ readonly stateMutability: "view";
1978
+ }, {
1979
+ readonly type: "function";
1980
+ readonly name: "owner";
1981
+ readonly inputs: readonly [];
1982
+ readonly outputs: readonly [{
1983
+ readonly name: "";
1984
+ readonly type: "address";
1985
+ }];
1986
+ readonly stateMutability: "view";
1987
+ }, {
1988
+ readonly type: "function";
1989
+ readonly name: "pendingDepositsProcessed";
1990
+ readonly inputs: readonly [];
1991
+ readonly outputs: readonly [{
1992
+ readonly name: "";
1993
+ readonly type: "uint256";
1994
+ }];
1995
+ readonly stateMutability: "view";
1996
+ }, {
1997
+ readonly type: "function";
1998
+ readonly name: "pendingDepositsQueue";
1999
+ readonly inputs: readonly [{
2000
+ readonly name: "";
2001
+ readonly type: "uint256";
2002
+ }];
2003
+ readonly outputs: readonly [{
2004
+ readonly name: "leaf";
2005
+ readonly type: "uint256";
2006
+ }, {
2007
+ readonly name: "relayerFee";
2008
+ readonly type: "uint128";
2009
+ }];
2010
+ readonly stateMutability: "view";
2011
+ }, {
2012
+ readonly type: "function";
2013
+ readonly name: "poolIds";
2014
+ readonly inputs: readonly [{
2015
+ readonly name: "";
2016
+ readonly type: "uint256";
2017
+ }];
2018
+ readonly outputs: readonly [{
2019
+ readonly name: "";
2020
+ readonly type: "uint256";
2021
+ }];
2022
+ readonly stateMutability: "view";
2023
+ }, {
2024
+ readonly type: "function";
2025
+ readonly name: "pools";
2026
+ readonly inputs: readonly [{
2027
+ readonly name: "";
2028
+ readonly type: "uint256";
2029
+ }];
2030
+ readonly outputs: readonly [{
2031
+ readonly name: "token";
2032
+ readonly type: "address";
2033
+ }, {
2034
+ readonly name: "depositFeeBPS";
2035
+ readonly type: "uint16";
2036
+ }, {
2037
+ readonly name: "withdrawFeeBPS";
2038
+ readonly type: "uint16";
2039
+ }, {
2040
+ readonly name: "accumulatedFee";
2041
+ readonly type: "uint128";
2042
+ }, {
2043
+ readonly name: "transferMaxAmount";
2044
+ readonly type: "uint128";
2045
+ }, {
2046
+ readonly name: "withdrawMaxAmount";
2047
+ readonly type: "uint128";
2048
+ }];
2049
+ readonly stateMutability: "view";
2050
+ }, {
2051
+ readonly type: "function";
2052
+ readonly name: "processPendingDeposits";
2053
+ readonly inputs: readonly [{
2054
+ readonly name: "maxBatchSize";
2055
+ readonly type: "uint256";
2056
+ }, {
2057
+ readonly name: "relayer";
2058
+ readonly type: "address";
2059
+ }];
2060
+ readonly outputs: readonly [];
2061
+ readonly stateMutability: "nonpayable";
2062
+ }, {
2063
+ readonly type: "function";
2064
+ readonly name: "registerPool";
2065
+ readonly inputs: readonly [{
2066
+ readonly name: "token";
2067
+ readonly type: "address";
2068
+ }, {
2069
+ readonly name: "depositFeeBPS";
2070
+ readonly type: "uint16";
2071
+ }, {
2072
+ readonly name: "withdrawFeeBPS";
2073
+ readonly type: "uint16";
2074
+ }, {
2075
+ readonly name: "transferMaxAmount";
2076
+ readonly type: "uint128";
2077
+ }, {
2078
+ readonly name: "withdrawMaxAmount";
2079
+ readonly type: "uint128";
2080
+ }, {
2081
+ readonly name: "viewerPK";
2082
+ readonly type: "uint256[2]";
2083
+ }, {
2084
+ readonly name: "freezerPK";
2085
+ readonly type: "uint256[2]";
2086
+ }];
2087
+ readonly outputs: readonly [{
2088
+ readonly name: "";
2089
+ readonly type: "uint256";
2090
+ }];
2091
+ readonly stateMutability: "nonpayable";
2092
+ }, {
2093
+ readonly type: "function";
2094
+ readonly name: "registerUser";
2095
+ readonly inputs: readonly [{
2096
+ readonly name: "userKey";
2097
+ readonly type: "bytes";
2098
+ }];
2099
+ readonly outputs: readonly [];
2100
+ readonly stateMutability: "nonpayable";
2101
+ }, {
2102
+ readonly type: "function";
2103
+ readonly name: "renounceOwnership";
2104
+ readonly inputs: readonly [];
2105
+ readonly outputs: readonly [];
2106
+ readonly stateMutability: "nonpayable";
2107
+ }, {
2108
+ readonly type: "function";
2109
+ readonly name: "setDepositRelayerFee";
2110
+ readonly inputs: readonly [{
2111
+ readonly name: "_depositRelayerFee";
2112
+ readonly type: "uint128";
2113
+ }];
2114
+ readonly outputs: readonly [];
2115
+ readonly stateMutability: "nonpayable";
2116
+ }, {
2117
+ readonly type: "function";
2118
+ readonly name: "setPoolFees";
2119
+ readonly inputs: readonly [{
2120
+ readonly name: "poolId";
2121
+ readonly type: "uint256";
2122
+ }, {
2123
+ readonly name: "depositFeeBPS";
2124
+ readonly type: "uint16";
2125
+ }, {
2126
+ readonly name: "withdrawFeeBPS";
2127
+ readonly type: "uint16";
2128
+ }];
2129
+ readonly outputs: readonly [];
2130
+ readonly stateMutability: "nonpayable";
2131
+ }, {
2132
+ readonly type: "function";
2133
+ readonly name: "setPoolLimits";
2134
+ readonly inputs: readonly [{
2135
+ readonly name: "poolId";
2136
+ readonly type: "uint256";
2137
+ }, {
2138
+ readonly name: "transferMaxAmount";
2139
+ readonly type: "uint128";
2140
+ }, {
2141
+ readonly name: "withdrawMaxAmount";
2142
+ readonly type: "uint128";
2143
+ }];
2144
+ readonly outputs: readonly [];
2145
+ readonly stateMutability: "nonpayable";
2146
+ }, {
2147
+ readonly type: "function";
2148
+ readonly name: "totalElements";
2149
+ readonly inputs: readonly [];
2150
+ readonly outputs: readonly [{
2151
+ readonly name: "";
2152
+ readonly type: "uint256";
2153
+ }];
2154
+ readonly stateMutability: "view";
2155
+ }, {
2156
+ readonly type: "function";
2157
+ readonly name: "totalElementsInTree";
2158
+ readonly inputs: readonly [];
2159
+ readonly outputs: readonly [{
2160
+ readonly name: "";
2161
+ readonly type: "uint256";
2162
+ }];
2163
+ readonly stateMutability: "view";
2164
+ }, {
2165
+ readonly type: "function";
2166
+ readonly name: "totalPools";
2167
+ readonly inputs: readonly [];
2168
+ readonly outputs: readonly [{
2169
+ readonly name: "";
2170
+ readonly type: "uint256";
2171
+ }];
2172
+ readonly stateMutability: "view";
2173
+ }, {
2174
+ readonly type: "function";
2175
+ readonly name: "transfer";
2176
+ readonly inputs: readonly [{
2177
+ readonly name: "poolId";
2178
+ readonly type: "uint256";
2179
+ }, {
2180
+ readonly name: "merkleRootIndex";
2181
+ readonly type: "uint256";
2182
+ }, {
2183
+ readonly name: "arrayHashIndex";
2184
+ readonly type: "uint256";
2185
+ }, {
2186
+ readonly name: "inputNullifiers";
2187
+ readonly type: "uint256[3]";
2188
+ }, {
2189
+ readonly name: "outputs";
2190
+ readonly type: "uint256[3]";
2191
+ }, {
2192
+ readonly name: "proof";
2193
+ readonly type: "uint256[8]";
2194
+ }, {
2195
+ readonly name: "viewerData";
2196
+ readonly type: "uint256[17]";
2197
+ }, {
2198
+ readonly name: "extraData";
2199
+ readonly type: "bytes";
2200
+ }, {
2201
+ readonly name: "relayer";
2202
+ readonly type: "address";
2203
+ }, {
2204
+ readonly name: "relayerFee";
2205
+ readonly type: "uint128";
2206
+ }];
2207
+ readonly outputs: readonly [];
2208
+ readonly stateMutability: "nonpayable";
2209
+ }, {
2210
+ readonly type: "function";
2211
+ readonly name: "transferOwnership";
2212
+ readonly inputs: readonly [{
2213
+ readonly name: "newOwner";
2214
+ readonly type: "address";
2215
+ }];
2216
+ readonly outputs: readonly [];
2217
+ readonly stateMutability: "nonpayable";
2218
+ }, {
2219
+ readonly type: "function";
2220
+ readonly name: "userKeys";
2221
+ readonly inputs: readonly [{
2222
+ readonly name: "";
2223
+ readonly type: "address";
2224
+ }];
2225
+ readonly outputs: readonly [{
2226
+ readonly name: "";
2227
+ readonly type: "bytes";
2228
+ }];
2229
+ readonly stateMutability: "view";
2230
+ }, {
2231
+ readonly type: "function";
2232
+ readonly name: "withdraw";
2233
+ readonly inputs: readonly [{
2234
+ readonly name: "inp";
2235
+ readonly type: "tuple";
2236
+ readonly components: readonly [{
2237
+ readonly name: "poolId";
2238
+ readonly type: "uint256";
2239
+ }, {
2240
+ readonly name: "merkleRootIndex";
2241
+ readonly type: "uint256";
2242
+ }, {
2243
+ readonly name: "arrayHashIndex";
2244
+ readonly type: "uint256";
2245
+ }, {
2246
+ readonly name: "inputNullifier";
2247
+ readonly type: "uint256";
2248
+ }, {
2249
+ readonly name: "output";
2250
+ readonly type: "uint256";
2251
+ }, {
2252
+ readonly name: "recipient";
2253
+ readonly type: "address";
2254
+ }, {
2255
+ readonly name: "amount";
2256
+ readonly type: "uint128";
2257
+ }, {
2258
+ readonly name: "proof";
2259
+ readonly type: "uint256[8]";
2260
+ }, {
2261
+ readonly name: "viewerData";
2262
+ readonly type: "uint256[7]";
2263
+ }, {
2264
+ readonly name: "extraData";
2265
+ readonly type: "bytes";
2266
+ }, {
2267
+ readonly name: "relayer";
2268
+ readonly type: "address";
2269
+ }, {
2270
+ readonly name: "relayerFee";
2271
+ readonly type: "uint128";
2272
+ }, {
2273
+ readonly name: "gasDropValue";
2274
+ readonly type: "uint128";
2275
+ }];
2276
+ }];
2277
+ readonly outputs: readonly [];
2278
+ readonly stateMutability: "payable";
2279
+ }, {
2280
+ readonly type: "event";
2281
+ readonly name: "ArrayMergedToTree";
2282
+ readonly inputs: readonly [{
2283
+ readonly name: "batchIndex";
2284
+ readonly type: "uint256";
2285
+ readonly indexed: true;
2286
+ }, {
2287
+ readonly name: "newRoot";
2288
+ readonly type: "uint256";
2289
+ readonly indexed: true;
2290
+ }];
2291
+ readonly anonymous: false;
2292
+ }, {
2293
+ readonly type: "event";
2294
+ readonly name: "Deposit";
2295
+ readonly inputs: readonly [{
2296
+ readonly name: "poolId";
2297
+ readonly type: "uint256";
2298
+ readonly indexed: true;
2299
+ }, {
2300
+ readonly name: "from";
2301
+ readonly type: "address";
2302
+ readonly indexed: true;
2303
+ }, {
2304
+ readonly name: "amount";
2305
+ readonly type: "uint128";
2306
+ readonly indexed: false;
2307
+ }, {
2308
+ readonly name: "fee";
2309
+ readonly type: "uint128";
2310
+ readonly indexed: false;
2311
+ }, {
2312
+ readonly name: "userPK";
2313
+ readonly type: "uint256[2]";
2314
+ readonly indexed: false;
2315
+ }, {
2316
+ readonly name: "nonce";
2317
+ readonly type: "uint256";
2318
+ readonly indexed: false;
2319
+ }, {
2320
+ readonly name: "relayerFee";
2321
+ readonly type: "uint128";
2322
+ readonly indexed: false;
2323
+ }];
2324
+ readonly anonymous: false;
2325
+ }, {
2326
+ readonly type: "event";
2327
+ readonly name: "DepositQueued";
2328
+ readonly inputs: readonly [{
2329
+ readonly name: "queueIndex";
2330
+ readonly type: "uint256";
2331
+ readonly indexed: true;
2332
+ }, {
2333
+ readonly name: "leaf";
2334
+ readonly type: "uint256";
2335
+ readonly indexed: true;
2336
+ }, {
2337
+ readonly name: "relayerFee";
2338
+ readonly type: "uint128";
2339
+ readonly indexed: false;
2340
+ }];
2341
+ readonly anonymous: false;
2342
+ }, {
2343
+ readonly type: "event";
2344
+ readonly name: "DepositRelayerFeeUpdated";
2345
+ readonly inputs: readonly [{
2346
+ readonly name: "depositRelayerFee";
2347
+ readonly type: "uint128";
2348
+ readonly indexed: false;
2349
+ }];
2350
+ readonly anonymous: false;
2351
+ }, {
2352
+ readonly type: "event";
2353
+ readonly name: "DepositsProcessed";
2354
+ readonly inputs: readonly [{
2355
+ readonly name: "fromIndex";
2356
+ readonly type: "uint256";
2357
+ readonly indexed: true;
2358
+ }, {
2359
+ readonly name: "toIndex";
2360
+ readonly type: "uint256";
2361
+ readonly indexed: true;
2362
+ }];
2363
+ readonly anonymous: false;
2364
+ }, {
2365
+ readonly type: "event";
2366
+ readonly name: "ElementInserted";
2367
+ readonly inputs: readonly [{
2368
+ readonly name: "element";
2369
+ readonly type: "uint256";
2370
+ readonly indexed: true;
2371
+ }, {
2372
+ readonly name: "globalIndex";
2373
+ readonly type: "uint256";
2374
+ readonly indexed: true;
2375
+ }];
2376
+ readonly anonymous: false;
2377
+ }, {
2378
+ readonly type: "event";
2379
+ readonly name: "Freeze";
2380
+ readonly inputs: readonly [{
2381
+ readonly name: "poolId";
2382
+ readonly type: "uint256";
2383
+ readonly indexed: true;
2384
+ }, {
2385
+ readonly name: "merkleRoot";
2386
+ readonly type: "uint256";
2387
+ readonly indexed: false;
2388
+ }, {
2389
+ readonly name: "arrayHash";
2390
+ readonly type: "uint256";
2391
+ readonly indexed: false;
2392
+ }, {
2393
+ readonly name: "inputs";
2394
+ readonly type: "uint256[3]";
2395
+ readonly indexed: false;
2396
+ }, {
2397
+ readonly name: "outputs";
2398
+ readonly type: "uint256[3]";
2399
+ readonly indexed: false;
2400
+ }];
2401
+ readonly anonymous: false;
2402
+ }, {
2403
+ readonly type: "event";
2404
+ readonly name: "Initialized";
2405
+ readonly inputs: readonly [{
2406
+ readonly name: "version";
2407
+ readonly type: "uint64";
2408
+ readonly indexed: false;
2409
+ }];
2410
+ readonly anonymous: false;
2411
+ }, {
2412
+ readonly type: "event";
2413
+ readonly name: "OwnershipTransferred";
2414
+ readonly inputs: readonly [{
2415
+ readonly name: "previousOwner";
2416
+ readonly type: "address";
2417
+ readonly indexed: true;
2418
+ }, {
2419
+ readonly name: "newOwner";
2420
+ readonly type: "address";
2421
+ readonly indexed: true;
2422
+ }];
2423
+ readonly anonymous: false;
2424
+ }, {
2425
+ readonly type: "event";
2426
+ readonly name: "PoolFeesUpdated";
2427
+ readonly inputs: readonly [{
2428
+ readonly name: "poolId";
2429
+ readonly type: "uint256";
2430
+ readonly indexed: true;
2431
+ }, {
2432
+ readonly name: "depositFeeBPS";
2433
+ readonly type: "uint16";
2434
+ readonly indexed: false;
2435
+ }, {
2436
+ readonly name: "withdrawFeeBPS";
2437
+ readonly type: "uint16";
2438
+ readonly indexed: false;
2439
+ }];
2440
+ readonly anonymous: false;
2441
+ }, {
2442
+ readonly type: "event";
2443
+ readonly name: "PoolLimitsUpdated";
2444
+ readonly inputs: readonly [{
2445
+ readonly name: "poolId";
2446
+ readonly type: "uint256";
2447
+ readonly indexed: true;
2448
+ }, {
2449
+ readonly name: "transferMaxAmount";
2450
+ readonly type: "uint128";
2451
+ readonly indexed: false;
2452
+ }, {
2453
+ readonly name: "withdrawMaxAmount";
2454
+ readonly type: "uint128";
2455
+ readonly indexed: false;
2456
+ }];
2457
+ readonly anonymous: false;
2458
+ }, {
2459
+ readonly type: "event";
2460
+ readonly name: "PoolRegistered";
2461
+ readonly inputs: readonly [{
2462
+ readonly name: "poolId";
2463
+ readonly type: "uint256";
2464
+ readonly indexed: true;
2465
+ }, {
2466
+ readonly name: "token";
2467
+ readonly type: "address";
2468
+ readonly indexed: true;
2469
+ }, {
2470
+ readonly name: "viewerPK";
2471
+ readonly type: "uint256[2]";
2472
+ readonly indexed: false;
2473
+ }, {
2474
+ readonly name: "freezerPK";
2475
+ readonly type: "uint256[2]";
2476
+ readonly indexed: false;
2477
+ }];
2478
+ readonly anonymous: false;
2479
+ }, {
2480
+ readonly type: "event";
2481
+ readonly name: "ProtocolFeesClaimed";
2482
+ readonly inputs: readonly [{
2483
+ readonly name: "poolId";
2484
+ readonly type: "uint256";
2485
+ readonly indexed: true;
2486
+ }, {
2487
+ readonly name: "recipient";
2488
+ readonly type: "address";
2489
+ readonly indexed: true;
2490
+ }, {
2491
+ readonly name: "amount";
2492
+ readonly type: "uint128";
2493
+ readonly indexed: false;
2494
+ }];
2495
+ readonly anonymous: false;
2496
+ }, {
2497
+ readonly type: "event";
2498
+ readonly name: "RelayerFeesClaimed";
2499
+ readonly inputs: readonly [{
2500
+ readonly name: "relayer";
2501
+ readonly type: "address";
2502
+ readonly indexed: true;
2503
+ }, {
2504
+ readonly name: "token";
2505
+ readonly type: "address";
2506
+ readonly indexed: true;
2507
+ }, {
2508
+ readonly name: "amount";
2509
+ readonly type: "uint128";
2510
+ readonly indexed: false;
2511
+ }];
2512
+ readonly anonymous: false;
2513
+ }, {
2514
+ readonly type: "event";
2515
+ readonly name: "Transfer";
2516
+ readonly inputs: readonly [{
2517
+ readonly name: "poolId";
2518
+ readonly type: "uint256";
2519
+ readonly indexed: true;
2520
+ }, {
2521
+ readonly name: "merkleRoot";
2522
+ readonly type: "uint256";
2523
+ readonly indexed: false;
2524
+ }, {
2525
+ readonly name: "arrayHash";
2526
+ readonly type: "uint256";
2527
+ readonly indexed: false;
2528
+ }, {
2529
+ readonly name: "inputs";
2530
+ readonly type: "uint256[3]";
2531
+ readonly indexed: false;
2532
+ }, {
2533
+ readonly name: "outputs";
2534
+ readonly type: "uint256[3]";
2535
+ readonly indexed: false;
2536
+ }, {
2537
+ readonly name: "relayer";
2538
+ readonly type: "address";
2539
+ readonly indexed: true;
2540
+ }, {
2541
+ readonly name: "relayerFee";
2542
+ readonly type: "uint128";
2543
+ readonly indexed: false;
2544
+ }];
2545
+ readonly anonymous: false;
2546
+ }, {
2547
+ readonly type: "event";
2548
+ readonly name: "UserRegistered";
2549
+ readonly inputs: readonly [{
2550
+ readonly name: "user";
2551
+ readonly type: "address";
2552
+ readonly indexed: true;
2553
+ }, {
2554
+ readonly name: "userKey";
2555
+ readonly type: "bytes";
2556
+ readonly indexed: false;
2557
+ }];
2558
+ readonly anonymous: false;
2559
+ }, {
2560
+ readonly type: "event";
2561
+ readonly name: "Withdraw";
2562
+ readonly inputs: readonly [{
2563
+ readonly name: "poolId";
2564
+ readonly type: "uint256";
2565
+ readonly indexed: true;
2566
+ }, {
2567
+ readonly name: "merkleRoot";
2568
+ readonly type: "uint256";
2569
+ readonly indexed: false;
2570
+ }, {
2571
+ readonly name: "arrayHash";
2572
+ readonly type: "uint256";
2573
+ readonly indexed: false;
2574
+ }, {
2575
+ readonly name: "input";
2576
+ readonly type: "uint256";
2577
+ readonly indexed: false;
2578
+ }, {
2579
+ readonly name: "output";
2580
+ readonly type: "uint256";
2581
+ readonly indexed: false;
2582
+ }, {
2583
+ readonly name: "recipient";
2584
+ readonly type: "address";
2585
+ readonly indexed: true;
2586
+ }, {
2587
+ readonly name: "amount";
2588
+ readonly type: "uint128";
2589
+ readonly indexed: false;
2590
+ }, {
2591
+ readonly name: "protocolFee";
2592
+ readonly type: "uint128";
2593
+ readonly indexed: false;
2594
+ }, {
2595
+ readonly name: "relayer";
2596
+ readonly type: "address";
2597
+ readonly indexed: true;
2598
+ }, {
2599
+ readonly name: "relayerFee";
2600
+ readonly type: "uint128";
2601
+ readonly indexed: false;
2602
+ }, {
2603
+ readonly name: "gasDropValue";
2604
+ readonly type: "uint128";
2605
+ readonly indexed: false;
2606
+ }];
2607
+ readonly anonymous: false;
2608
+ }, {
2609
+ readonly type: "error";
2610
+ readonly name: "AddressIsZero";
2611
+ readonly inputs: readonly [];
2612
+ }, {
2613
+ readonly type: "error";
2614
+ readonly name: "DataNotInField";
2615
+ readonly inputs: readonly [{
2616
+ readonly name: "data";
2617
+ readonly type: "uint256";
2618
+ }];
2619
+ }, {
2620
+ readonly type: "error";
2621
+ readonly name: "DuplicateCommitment";
2622
+ readonly inputs: readonly [{
2623
+ readonly name: "commitment";
2624
+ readonly type: "uint256";
2625
+ }];
2626
+ }, {
2627
+ readonly type: "error";
2628
+ readonly name: "ExceedsWithdrawLimit";
2629
+ readonly inputs: readonly [{
2630
+ readonly name: "amount";
2631
+ readonly type: "uint128";
2632
+ }, {
2633
+ readonly name: "maxAmount";
2634
+ readonly type: "uint128";
2635
+ }];
2636
+ }, {
2637
+ readonly type: "error";
2638
+ readonly name: "FailedCall";
2639
+ readonly inputs: readonly [];
2640
+ }, {
2641
+ readonly type: "error";
2642
+ readonly name: "FeeBPSOutOfBounds";
2643
+ readonly inputs: readonly [{
2644
+ readonly name: "feeBPS";
2645
+ readonly type: "uint16";
2646
+ }];
2647
+ }, {
2648
+ readonly type: "error";
2649
+ readonly name: "InsufficientBalance";
2650
+ readonly inputs: readonly [{
2651
+ readonly name: "balance";
2652
+ readonly type: "uint256";
2653
+ }, {
2654
+ readonly name: "needed";
2655
+ readonly type: "uint256";
2656
+ }];
2657
+ }, {
2658
+ readonly type: "error";
2659
+ readonly name: "InvalidArrayHashIndex";
2660
+ readonly inputs: readonly [{
2661
+ readonly name: "provided";
2662
+ readonly type: "uint256";
2663
+ }];
2664
+ }, {
2665
+ readonly type: "error";
2666
+ readonly name: "InvalidBatchSize";
2667
+ readonly inputs: readonly [];
2668
+ }, {
2669
+ readonly type: "error";
2670
+ readonly name: "InvalidETHAmount";
2671
+ readonly inputs: readonly [{
2672
+ readonly name: "expected";
2673
+ readonly type: "uint128";
2674
+ }, {
2675
+ readonly name: "actual";
2676
+ readonly type: "uint256";
2677
+ }];
2678
+ }, {
2679
+ readonly type: "error";
2680
+ readonly name: "InvalidGasDropValue";
2681
+ readonly inputs: readonly [{
2682
+ readonly name: "provided";
2683
+ readonly type: "uint256";
2684
+ }];
2685
+ }, {
2686
+ readonly type: "error";
2687
+ readonly name: "InvalidInitialization";
2688
+ readonly inputs: readonly [];
2689
+ }, {
2690
+ readonly type: "error";
2691
+ readonly name: "InvalidMerkleRootIndex";
2692
+ readonly inputs: readonly [{
2693
+ readonly name: "provided";
2694
+ readonly type: "uint256";
2695
+ }];
2696
+ }, {
2697
+ readonly type: "error";
2698
+ readonly name: "InvalidPoolId";
2699
+ readonly inputs: readonly [{
2700
+ readonly name: "poolId";
2701
+ readonly type: "uint256";
2702
+ }];
2703
+ }, {
2704
+ readonly type: "error";
2705
+ readonly name: "InvalidRelayerFee";
2706
+ readonly inputs: readonly [{
2707
+ readonly name: "provided";
2708
+ readonly type: "uint256";
2709
+ }];
2710
+ }, {
2711
+ readonly type: "error";
2712
+ readonly name: "NoElementsInArray";
2713
+ readonly inputs: readonly [];
2714
+ }, {
2715
+ readonly type: "error";
2716
+ readonly name: "NoPendingDeposits";
2717
+ readonly inputs: readonly [];
2718
+ }, {
2719
+ readonly type: "error";
2720
+ readonly name: "NotInitializing";
2721
+ readonly inputs: readonly [];
2722
+ }, {
2723
+ readonly type: "error";
2724
+ readonly name: "NullifierAlreadyPublished";
2725
+ readonly inputs: readonly [{
2726
+ readonly name: "nullifier";
2727
+ readonly type: "uint256";
2728
+ }];
2729
+ }, {
2730
+ readonly type: "error";
2731
+ readonly name: "NullifierIsZero";
2732
+ readonly inputs: readonly [];
2733
+ }, {
2734
+ readonly type: "error";
2735
+ readonly name: "OutputIsZero";
2736
+ readonly inputs: readonly [];
2737
+ }, {
2738
+ readonly type: "error";
2739
+ readonly name: "OwnableInvalidOwner";
2740
+ readonly inputs: readonly [{
2741
+ readonly name: "owner";
2742
+ readonly type: "address";
2743
+ }];
2744
+ }, {
2745
+ readonly type: "error";
2746
+ readonly name: "OwnableUnauthorizedAccount";
2747
+ readonly inputs: readonly [{
2748
+ readonly name: "account";
2749
+ readonly type: "address";
2750
+ }];
2751
+ }, {
2752
+ readonly type: "error";
2753
+ readonly name: "PoolAlreadyExists";
2754
+ readonly inputs: readonly [{
2755
+ readonly name: "poolId";
2756
+ readonly type: "uint256";
2757
+ }];
2758
+ }, {
2759
+ readonly type: "error";
2760
+ readonly name: "ReentrancyGuardReentrantCall";
2761
+ readonly inputs: readonly [];
2762
+ }, {
2763
+ readonly type: "error";
2764
+ readonly name: "RelayerAddressIsZero";
2765
+ readonly inputs: readonly [];
2766
+ }, {
2767
+ readonly type: "error";
2768
+ readonly name: "SafeERC20FailedOperation";
2769
+ readonly inputs: readonly [{
2770
+ readonly name: "token";
2771
+ readonly type: "address";
2772
+ }];
2773
+ }, {
2774
+ readonly type: "error";
2775
+ readonly name: "TreeIsFull";
2776
+ readonly inputs: readonly [];
2777
+ }, {
2778
+ readonly type: "error";
2779
+ readonly name: "Unauthorized";
2780
+ readonly inputs: readonly [{
2781
+ readonly name: "owner";
2782
+ readonly type: "address";
2783
+ }, {
2784
+ readonly name: "caller";
2785
+ readonly type: "address";
2786
+ }];
1505
2787
  }];
1506
2788
 
2789
+ /**
2790
+ * In-memory StorageAdapter implementation.
2791
+ * Useful for ephemeral sessions or tests (non-persistent).
2792
+ */
1507
2793
  declare class MemoryStore implements StorageAdapter {
1508
2794
  private walletId;
1509
2795
  private readonly cursors;
@@ -1515,106 +2801,274 @@ declare class MemoryStore implements StorageAdapter {
1515
2801
  private readonly entryMemosByChain;
1516
2802
  private readonly entryNullifiersByChain;
1517
2803
  private readonly maxOperations;
2804
+ /**
2805
+ * Create a MemoryStore with an optional maxOperations limit.
2806
+ */
1518
2807
  constructor(options?: {
1519
2808
  maxOperations?: number;
1520
2809
  });
2810
+ /**
2811
+ * Initialize store; clears in-memory state when walletId changes.
2812
+ */
1521
2813
  init(options?: {
1522
2814
  walletId?: string;
1523
2815
  }): void;
2816
+ /**
2817
+ * Close store (no-op for in-memory).
2818
+ */
1524
2819
  close(): void;
2820
+ /**
2821
+ * Enforce maxOperations limit and return number removed.
2822
+ */
1525
2823
  private enforceMaxOperations;
2824
+ /**
2825
+ * Get persisted sync cursor for a chain.
2826
+ */
1526
2827
  getSyncCursor(chainId: number): Promise<SyncCursor | undefined>;
2828
+ /**
2829
+ * Set persisted sync cursor for a chain.
2830
+ */
1527
2831
  setSyncCursor(chainId: number, cursor: SyncCursor): Promise<void>;
2832
+ /**
2833
+ * Upsert UTXOs; preserves spent flag on existing records.
2834
+ */
1528
2835
  upsertUtxos(utxos: UtxoRecord[]): Promise<void>;
2836
+ /**
2837
+ * List UTXOs with query filtering and pagination.
2838
+ */
1529
2839
  listUtxos(query?: ListUtxosQuery): Promise<{
1530
2840
  total: number;
1531
2841
  rows: UtxoRecord[];
1532
2842
  }>;
2843
+ /**
2844
+ * Mark matching UTXOs as spent by nullifier.
2845
+ */
1533
2846
  markSpent(input: {
1534
2847
  chainId: number;
1535
2848
  nullifiers: Hex[];
1536
2849
  }): Promise<number>;
2850
+ /**
2851
+ * Get persisted merkle leaves for a chain.
2852
+ */
1537
2853
  getMerkleLeaves(chainId: number): Promise<Array<{
1538
2854
  cid: number;
1539
2855
  commitment: Hex;
1540
2856
  }> | undefined>;
2857
+ /**
2858
+ * Append contiguous merkle leaves.
2859
+ */
1541
2860
  appendMerkleLeaves(chainId: number, leaves: Array<{
1542
2861
  cid: number;
1543
2862
  commitment: Hex;
1544
2863
  }>): Promise<void>;
2864
+ /**
2865
+ * Clear merkle leaf cache for a chain.
2866
+ */
1545
2867
  clearMerkleLeaves(chainId: number): Promise<void>;
2868
+ /**
2869
+ * Get a single merkle leaf by cid.
2870
+ */
1546
2871
  getMerkleLeaf(chainId: number, cid: number): Promise<MerkleLeafRecord | undefined>;
2872
+ /**
2873
+ * Get a merkle node by id.
2874
+ */
1547
2875
  getMerkleNode(chainId: number, id: string): Promise<MerkleNodeRecord | undefined>;
2876
+ /**
2877
+ * Upsert merkle nodes for a chain.
2878
+ */
1548
2879
  upsertMerkleNodes(chainId: number, nodes: MerkleNodeRecord[]): Promise<void>;
2880
+ /**
2881
+ * Clear merkle nodes for a chain.
2882
+ */
1549
2883
  clearMerkleNodes(chainId: number): Promise<void>;
2884
+ /**
2885
+ * Get persisted merkle tree state.
2886
+ */
1550
2887
  getMerkleTree(chainId: number): Promise<MerkleTreeState | undefined>;
2888
+ /**
2889
+ * Persist merkle tree state.
2890
+ */
1551
2891
  setMerkleTree(chainId: number, tree: MerkleTreeState): Promise<void>;
2892
+ /**
2893
+ * Clear merkle tree state.
2894
+ */
1552
2895
  clearMerkleTree(chainId: number): Promise<void>;
1553
- upsertEntryMemos(memos: EntryMemoRecord[]): Promise<number>;
2896
+ /**
2897
+ * Upsert entry memos (raw EntryService cache).
2898
+ */
2899
+ upsertEntryMemos(memos: EntryMemoRecord[]): Promise<void>;
2900
+ /**
2901
+ * List entry memos with query filtering and pagination.
2902
+ */
1554
2903
  listEntryMemos(query: ListEntryMemosQuery): Promise<{
1555
2904
  total: number;
1556
2905
  rows: EntryMemoRecord[];
1557
2906
  }>;
2907
+ /**
2908
+ * Clear entry memo cache for a chain.
2909
+ */
1558
2910
  clearEntryMemos(chainId: number): Promise<void>;
1559
- upsertEntryNullifiers(nullifiers: EntryNullifierRecord[]): Promise<number>;
2911
+ /**
2912
+ * Upsert entry nullifiers (raw EntryService cache).
2913
+ */
2914
+ upsertEntryNullifiers(nullifiers: EntryNullifierRecord[]): Promise<void>;
2915
+ /**
2916
+ * List entry nullifiers with query filtering and pagination.
2917
+ */
1560
2918
  listEntryNullifiers(query: ListEntryNullifiersQuery): Promise<{
1561
2919
  total: number;
1562
2920
  rows: EntryNullifierRecord[];
1563
2921
  }>;
2922
+ /**
2923
+ * Clear entry nullifier cache for a chain.
2924
+ */
1564
2925
  clearEntryNullifiers(chainId: number): Promise<void>;
2926
+ /**
2927
+ * Create and persist an operation record.
2928
+ */
1565
2929
  createOperation<TType extends OperationType>(input: Omit<StoredOperation<OperationDetailFor<TType>>, 'id' | 'createdAt' | 'status'> & Partial<Pick<StoredOperation<OperationDetailFor<TType>>, 'createdAt' | 'id' | 'status'>> & {
1566
2930
  type: TType;
1567
2931
  }): StoredOperation<OperationDetailFor<TType>> & {
1568
2932
  type: TType;
1569
2933
  };
2934
+ /**
2935
+ * Update an existing operation record.
2936
+ */
1570
2937
  updateOperation(id: string, patch: Partial<StoredOperation>): void;
2938
+ /**
2939
+ * Delete an operation record by id.
2940
+ */
1571
2941
  deleteOperation(id: string): boolean;
2942
+ /**
2943
+ * Clear all operation records.
2944
+ */
1572
2945
  clearOperations(): void;
2946
+ /**
2947
+ * Prune operations to a maximum count (returns number removed).
2948
+ */
1573
2949
  pruneOperations(options?: {
1574
2950
  max?: number;
1575
2951
  }): number;
2952
+ /**
2953
+ * List operations with filtering/pagination.
2954
+ */
1576
2955
  listOperations(input?: number | ListOperationsQuery): StoredOperation[];
1577
2956
  }
1578
2957
 
2958
+ /**
2959
+ * OCash mainnet deployment — ETH (Chain ID 1).
2960
+ * Pools: ETH, USDT, USDC.
2961
+ */
2962
+ declare const ETH_MAINNET: ChainConfigInput;
2963
+ /**
2964
+ * OCash mainnet deployment — BSC (Chain ID 56).
2965
+ * Pools: BNB, USDT (18 decimals), USDC (18 decimals).
2966
+ */
2967
+ declare const BSC_MAINNET: ChainConfigInput;
2968
+ /**
2969
+ * OCash mainnet deployment — Base (Chain ID 8453).
2970
+ * Pools: ETH, USDC.
2971
+ */
2972
+ declare const BASE_MAINNET: ChainConfigInput;
2973
+ /**
2974
+ * OCash testnet deployment — Sepolia (Chain ID 11155111).
2975
+ * Pools: SepoliaETH, tUSDT.
2976
+ */
2977
+ declare const SEPOLIA_TESTNET: ChainConfigInput;
2978
+ /**
2979
+ * OCash testnet deployment — BSC Testnet (Chain ID 97).
2980
+ * Pools: tBNB, tUSDT.
2981
+ */
2982
+ declare const BSC_TESTNET: ChainConfigInput;
2983
+ /** OCash dev deployment — ETH (Chain ID 1). Pools: ETH, USDT, USDC. */
2984
+ declare const ETH_DEV: ChainConfigInput;
2985
+ /** OCash dev deployment — BSC (Chain ID 56). Pools: BNB, USDT, USDC. */
2986
+ declare const BSC_DEV: ChainConfigInput;
2987
+ /** OCash dev deployment — Base (Chain ID 8453). Pools: ETH, USDC. */
2988
+ declare const BASE_DEV: ChainConfigInput;
2989
+ /** OCash dev deployment — Sepolia (Chain ID 11155111). Pools: ETH, tUSDT. */
2990
+ declare const SEPOLIA_DEV: ChainConfigInput;
2991
+ /** OCash dev deployment — BSC Testnet (Chain ID 97). Pools: BNB, tUSDT. */
2992
+ declare const BSC_TESTNET_DEV: ChainConfigInput;
2993
+
1579
2994
  type KeyValueStoreOptions = {
1580
2995
  client: KeyValueClient;
1581
2996
  keyPrefix?: string;
1582
2997
  maxOperations?: number;
1583
2998
  };
2999
+ /**
3000
+ * Generic key-value backed StorageAdapter for Redis/SQLite/etc.
3001
+ */
1584
3002
  declare class KeyValueStore implements StorageAdapter {
1585
3003
  private readonly options;
1586
3004
  private walletId;
1587
- private readonly cursors;
1588
- private readonly utxos;
3005
+ private cursorChains;
3006
+ private utxoRefs;
3007
+ private operationIds;
1589
3008
  private operations;
1590
- private merkleLeaves;
3009
+ private readonly cursorCache;
3010
+ private readonly utxoCache;
3011
+ private readonly operationCache;
3012
+ private merkleLeafCids;
1591
3013
  private merkleTrees;
1592
- private merkleNodes;
1593
- private entryMemos;
1594
- private entryNullifiers;
3014
+ private merkleNodeIds;
3015
+ private entryMemoCids;
3016
+ private entryNullifierNids;
3017
+ private readonly loadedMerkleLeaves;
3018
+ private readonly loadedMerkleTrees;
3019
+ private readonly loadedMerkleNodes;
3020
+ private readonly loadedEntryMemos;
3021
+ private readonly loadedEntryNullifiers;
1595
3022
  private saveChain;
1596
3023
  private readonly maxOperations;
3024
+ private walletMetaLoaded;
1597
3025
  constructor(options: KeyValueStoreOptions);
1598
3026
  init(options?: {
1599
3027
  walletId?: string;
1600
3028
  }): Promise<void>;
1601
3029
  close(): Promise<void>;
1602
- private stateKey;
3030
+ private keyPrefix;
3031
+ private walletBaseKey;
3032
+ private walletMetaKey;
3033
+ private walletCursorKey;
3034
+ private walletUtxoKey;
3035
+ private walletOperationKey;
3036
+ private sharedChainKey;
3037
+ private sharedChainMetaKey;
3038
+ private sharedRecordKey;
3039
+ private parseJson;
3040
+ private parseNumberIndex;
3041
+ private parseStringIndex;
3042
+ private toPersistedUtxo;
3043
+ private fromPersistedUtxo;
3044
+ private resetInMemory;
3045
+ private enqueueWrite;
3046
+ private writeJson;
3047
+ private deleteOrReset;
1603
3048
  private load;
1604
- private save;
3049
+ private ensureWalletMetaLoaded;
3050
+ private normalizeCursor;
3051
+ private readCursor;
3052
+ private readUtxo;
3053
+ private pruneOperationIds;
3054
+ private ensureMerkleLeavesLoaded;
3055
+ private ensureMerkleTreeLoaded;
3056
+ private ensureMerkleNodesLoaded;
3057
+ private ensureEntryMemosLoaded;
3058
+ private ensureEntryNullifiersLoaded;
1605
3059
  getMerkleNode(chainId: number, id: string): Promise<MerkleNodeRecord | undefined>;
1606
3060
  upsertMerkleNodes(chainId: number, nodes: MerkleNodeRecord[]): Promise<void>;
1607
3061
  clearMerkleNodes(chainId: number): Promise<void>;
1608
3062
  getMerkleTree(chainId: number): Promise<MerkleTreeState | undefined>;
1609
3063
  setMerkleTree(chainId: number, tree: MerkleTreeState): Promise<void>;
1610
3064
  clearMerkleTree(chainId: number): Promise<void>;
1611
- upsertEntryMemos(memos: EntryMemoRecord[]): Promise<number>;
3065
+ upsertEntryMemos(memos: EntryMemoRecord[]): Promise<void>;
1612
3066
  listEntryMemos(query: ListEntryMemosQuery): Promise<{
1613
3067
  total: number;
1614
3068
  rows: EntryMemoRecord[];
1615
3069
  }>;
1616
3070
  clearEntryMemos(chainId: number): Promise<void>;
1617
- upsertEntryNullifiers(nullifiers: EntryNullifierRecord[]): Promise<number>;
3071
+ upsertEntryNullifiers(nullifiers: EntryNullifierRecord[]): Promise<void>;
1618
3072
  listEntryNullifiers(query: ListEntryNullifiersQuery): Promise<{
1619
3073
  total: number;
1620
3074
  rows: EntryNullifierRecord[];
@@ -1647,8 +3101,18 @@ declare class KeyValueStore implements StorageAdapter {
1647
3101
  }): Promise<number>;
1648
3102
  createOperation<TType extends OperationType>(input: Omit<StoredOperation<OperationDetailFor<TType>>, 'id' | 'createdAt' | 'status'> & Partial<Pick<StoredOperation<OperationDetailFor<TType>>, 'createdAt' | 'id' | 'status'>> & {
1649
3103
  type: TType;
1650
- }): StoredOperation<OperationDetailFor<TType>> & {
1651
- type: TType;
3104
+ }): {
3105
+ id: string;
3106
+ createdAt: number;
3107
+ status: OperationStatus;
3108
+ type: OperationType & TType;
3109
+ chainId?: number | undefined;
3110
+ tokenId?: string | undefined;
3111
+ requestUrl?: string | undefined;
3112
+ relayerTxHash?: `0x${string}` | undefined;
3113
+ txHash?: `0x${string}` | undefined;
3114
+ detail?: OperationDetailFor<TType> | undefined;
3115
+ error?: string | undefined;
1652
3116
  };
1653
3117
  updateOperation(id: string, patch: Partial<StoredOperation>): void;
1654
3118
  deleteOperation(id: string): boolean;
@@ -1658,20 +3122,33 @@ declare class KeyValueStore implements StorageAdapter {
1658
3122
  }): number;
1659
3123
  listOperations(input?: number | ListOperationsQuery): StoredOperation[];
1660
3124
  }
1661
- type RedisStoreOptions = KeyValueStoreOptions;
1662
- declare class RedisStore extends KeyValueStore {
1663
- constructor(options: RedisStoreOptions);
1664
- }
1665
- type SqliteStoreOptions = KeyValueStoreOptions;
1666
- declare class SqliteStore extends KeyValueStore {
1667
- constructor(options: SqliteStoreOptions);
1668
- }
1669
3125
  interface KeyValueClient {
1670
3126
  get(key: string): Promise<string | null>;
1671
3127
  set(key: string, value: string): Promise<void>;
1672
3128
  del?(key: string): Promise<void>;
1673
3129
  }
1674
3130
 
3131
+ type RedisStoreOptions = KeyValueStoreOptions;
3132
+ /**
3133
+ * Redis-backed store with a default key prefix.
3134
+ */
3135
+ declare class RedisStore extends KeyValueStore {
3136
+ constructor(options: RedisStoreOptions);
3137
+ }
3138
+
3139
+ /**
3140
+ * Create an SDK instance with the given configuration.
3141
+ *
3142
+ * @example
3143
+ * ```ts
3144
+ * const sdk = createSdk({ chains: [...], onEvent: (e) => console.log(e) });
3145
+ * await sdk.core.ready();
3146
+ * await sdk.wallet.open({ seed: 'my-secret-seed' });
3147
+ * ```
3148
+ */
3149
+ /**
3150
+ * SDK factory. Wires together all modules and returns a stable API surface.
3151
+ */
1675
3152
  declare const createSdk: (config: OCashSdkConfig) => OCashSdk;
1676
3153
  declare const OcashSdk: {
1677
3154
  readonly createSdk: (config: OCashSdkConfig) => OCashSdk;
@@ -1689,4 +3166,4 @@ declare const OcashSdk: {
1689
3166
  readonly MemoryStore: typeof MemoryStore;
1690
3167
  };
1691
3168
 
1692
- export { type TransferWitnessInput as $, App_ABI as A, BABYJUBJUB_SCALAR_FIELD as B, type ChainConfigInput as C, type DepositOperation as D, type EntryMemoRecord as E, type OpsApi as F, type PlannerEstimateWithdrawResult as G, type Hex as H, type ProofResult as I, type RedisStoreOptions as J, KeyManager as K, type ListEntryMemosQuery as L, type MerkleNodeRecord as M, type RelayerRequest as N, type OperationType as O, type PlannerEstimateTransferResult as P, type SdkEvent as Q, RedisStore as R, type StorageAdapter as S, SqliteStore as T, type UtxoRecord as U, type SqliteStoreOptions as V, type SyncChainStatus as W, type TokenMetadata as X, type TransactionReceipt as Y, type TransferOperation as Z, type TransferOperationDetail as _, type MerkleTreeState as a, Utils as a0, type WalletSessionInput as a1, type WithdrawOperation as a2, type WithdrawOperationDetail as a3, type WithdrawWitnessInput as a4, type WitnessBuildResult as a5, type WitnessContext as a6, assertChainConfigInput as a7, assertTokenList as a8, assertTokenMetadata as a9, calcTransferProofBinding as aa, calcWithdrawProofBinding as ab, createSdk as ac, OcashSdk as ad, defaultAssetsOverride as ae, fetchPoolTokensFromContract as af, normalizeTokenMetadata as ag, type EntryNullifierRecord as b, type ListEntryNullifiersQuery as c, type SyncCursor as d, type ListUtxosQuery as e, type StoredOperation as f, type OperationDetailFor as g, type ListOperationsQuery as h, type AssetOverrideEntry as i, type AssetsOverride as j, type CommitmentData as k, CryptoToolkit as l, type DepositOperationDetail as m, DummyFactory as n, ERC20_ABI as o, type KeyValueClient as p, KeyValueStore as q, type KeyValueStoreOptions as r, LedgerInfo as s, MemoKit as t, MemoryStore as u, type MerkleLeafRecord as v, type OCashSdk as w, type OCashSdkConfig as x, type OperationCreateInput as y, type OperationStatus as z };
3169
+ export { SEPOLIA_TESTNET as $, App_ABI as A, BABYJUBJUB_SCALAR_FIELD as B, type ChainConfigInput as C, type DepositOperation as D, type EntryMemoRecord as E, LedgerInfo as F, MemoKit as G, type Hex as H, MemoryStore as I, type MerkleLeafRecord as J, KeyManager as K, type ListEntryMemosQuery as L, type MerkleNodeRecord as M, type OCashSdk as N, type OperationType as O, type OCashSdkConfig as P, type OperationCreateInput as Q, type OpsApi as R, type StorageAdapter as S, type PlannerEstimateTransferResult as T, type UtxoRecord as U, type PlannerEstimateWithdrawResult as V, type ProofResult as W, RedisStore as X, type RedisStoreOptions as Y, type RelayerRequest as Z, SEPOLIA_DEV as _, type MerkleTreeState as a, type SdkEvent as a0, type SyncChainStatus as a1, type TokenMetadata as a2, type TransactionReceipt as a3, type TransferOperation as a4, type TransferOperationDetail as a5, type TransferWitnessInput as a6, Utils as a7, type WalletSessionInput as a8, type WithdrawOperation as a9, type WithdrawOperationDetail as aa, type WithdrawWitnessInput as ab, type WitnessBuildResult as ac, type WitnessContext as ad, assertChainConfigInput as ae, assertTokenList as af, assertTokenMetadata as ag, calcTransferProofBinding as ah, calcWithdrawProofBinding as ai, createSdk as aj, OcashSdk as ak, defaultAssetsOverrideMainnet as al, defaultAssetsOverrideTestnet as am, fetchPoolTokensFromContract as an, normalizeTokenMetadata as ao, type EntryNullifierRecord as b, type ListEntryNullifiersQuery as c, type SyncCursor as d, type ListUtxosQuery as e, type StoredOperation as f, type OperationDetailFor as g, type OperationStatus as h, type ListOperationsQuery as i, type AssetOverrideEntry as j, type AssetsOverride as k, BASE_DEV as l, BASE_MAINNET as m, BSC_DEV as n, BSC_MAINNET as o, BSC_TESTNET as p, BSC_TESTNET_DEV as q, type CommitmentData as r, CryptoToolkit as s, type DepositOperationDetail as t, DummyFactory as u, ETH_DEV as v, ETH_MAINNET as w, type KeyValueClient as x, KeyValueStore as y, type KeyValueStoreOptions as z };