@unlink-xyz/core 0.1.0 → 0.1.3-canary.01ac52d

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.
Files changed (269) hide show
  1. package/README.md +9 -0
  2. package/dist/account/{zkAccount.d.ts → account.d.ts} +36 -5
  3. package/dist/account/account.d.ts.map +1 -0
  4. package/dist/account/accounts.d.ts +42 -0
  5. package/dist/account/accounts.d.ts.map +1 -0
  6. package/dist/account/seed.d.ts +45 -0
  7. package/dist/account/seed.d.ts.map +1 -0
  8. package/dist/account/serialization.d.ts +6 -0
  9. package/dist/account/serialization.d.ts.map +1 -0
  10. package/dist/browser/index.js +56253 -0
  11. package/dist/browser/index.js.map +1 -0
  12. package/dist/browser/wallet/index.js +55974 -0
  13. package/dist/browser/wallet/index.js.map +1 -0
  14. package/dist/clients/broadcaster.d.ts +8 -2
  15. package/dist/clients/broadcaster.d.ts.map +1 -1
  16. package/dist/clients/http.d.ts +6 -0
  17. package/dist/clients/http.d.ts.map +1 -1
  18. package/dist/clients/indexer.d.ts +16 -0
  19. package/dist/clients/indexer.d.ts.map +1 -1
  20. package/dist/config.d.ts +35 -9
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/constants.d.ts +6 -0
  23. package/dist/constants.d.ts.map +1 -0
  24. package/dist/core.d.ts.map +1 -1
  25. package/dist/crypto/adapters/index.d.ts +17 -0
  26. package/dist/crypto/adapters/index.d.ts.map +1 -0
  27. package/dist/crypto/adapters/polyfills.d.ts +5 -0
  28. package/dist/crypto/adapters/polyfills.d.ts.map +1 -0
  29. package/dist/crypto/encrypt.d.ts +33 -0
  30. package/dist/crypto/encrypt.d.ts.map +1 -0
  31. package/dist/crypto/secure-memory.d.ts +25 -0
  32. package/dist/crypto/secure-memory.d.ts.map +1 -0
  33. package/dist/errors.d.ts +17 -0
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/history/index.d.ts +3 -0
  36. package/dist/history/index.d.ts.map +1 -0
  37. package/dist/history/service.d.ts +46 -0
  38. package/dist/history/service.d.ts.map +1 -0
  39. package/dist/history/types.d.ts +21 -0
  40. package/dist/history/types.d.ts.map +1 -0
  41. package/dist/index.d.ts +16 -5
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +9969 -16
  44. package/dist/index.js.map +1 -0
  45. package/dist/keys/address.d.ts +13 -0
  46. package/dist/keys/address.d.ts.map +1 -0
  47. package/dist/keys/derive.d.ts +37 -0
  48. package/dist/keys/derive.d.ts.map +1 -0
  49. package/dist/keys/hex.d.ts +14 -0
  50. package/dist/keys/hex.d.ts.map +1 -0
  51. package/dist/keys/index.d.ts +5 -0
  52. package/dist/keys/index.d.ts.map +1 -0
  53. package/dist/keys/mnemonic.d.ts +6 -0
  54. package/dist/keys/mnemonic.d.ts.map +1 -0
  55. package/dist/keys.d.ts +5 -1
  56. package/dist/keys.d.ts.map +1 -1
  57. package/dist/prover/config.d.ts +53 -22
  58. package/dist/prover/config.d.ts.map +1 -1
  59. package/dist/prover/integrity.d.ts +20 -0
  60. package/dist/prover/integrity.d.ts.map +1 -0
  61. package/dist/prover/prover.d.ts +16 -20
  62. package/dist/prover/prover.d.ts.map +1 -1
  63. package/dist/prover/registry.d.ts +3 -30
  64. package/dist/prover/registry.d.ts.map +1 -1
  65. package/dist/state/merkle/hydrator.d.ts +21 -19
  66. package/dist/state/merkle/hydrator.d.ts.map +1 -1
  67. package/dist/state/merkle/index.d.ts +2 -2
  68. package/dist/state/merkle/index.d.ts.map +1 -1
  69. package/dist/state/merkle/merkle-tree.d.ts +8 -0
  70. package/dist/state/merkle/merkle-tree.d.ts.map +1 -1
  71. package/dist/state/store/ciphertext-store.d.ts +11 -0
  72. package/dist/state/store/ciphertext-store.d.ts.map +1 -1
  73. package/dist/state/store/history-store.d.ts +24 -0
  74. package/dist/state/store/history-store.d.ts.map +1 -0
  75. package/dist/state/store/index.d.ts +3 -2
  76. package/dist/state/store/index.d.ts.map +1 -1
  77. package/dist/state/store/job-store.d.ts +7 -7
  78. package/dist/state/store/job-store.d.ts.map +1 -1
  79. package/dist/state/store/jobs.d.ts +70 -25
  80. package/dist/state/store/jobs.d.ts.map +1 -1
  81. package/dist/state/store/leaf-store.d.ts +4 -0
  82. package/dist/state/store/leaf-store.d.ts.map +1 -1
  83. package/dist/state/store/note-store.d.ts +7 -7
  84. package/dist/state/store/note-store.d.ts.map +1 -1
  85. package/dist/state/store/nullifier-store.d.ts +9 -0
  86. package/dist/state/store/nullifier-store.d.ts.map +1 -1
  87. package/dist/state/store/records.d.ts +39 -2
  88. package/dist/state/store/records.d.ts.map +1 -1
  89. package/dist/state/store/root-store.d.ts.map +1 -1
  90. package/dist/state/store/store.d.ts +79 -27
  91. package/dist/state/store/store.d.ts.map +1 -1
  92. package/dist/storage/indexeddb.d.ts.map +1 -1
  93. package/dist/storage/memory.d.ts.map +1 -1
  94. package/dist/transactions/adapter.d.ts +31 -0
  95. package/dist/transactions/adapter.d.ts.map +1 -0
  96. package/dist/transactions/deposit.d.ts +12 -17
  97. package/dist/transactions/deposit.d.ts.map +1 -1
  98. package/dist/transactions/index.d.ts +9 -4
  99. package/dist/transactions/index.d.ts.map +1 -1
  100. package/dist/transactions/note-selection.d.ts +17 -0
  101. package/dist/transactions/note-selection.d.ts.map +1 -0
  102. package/dist/transactions/note-sync.d.ts +5 -33
  103. package/dist/transactions/note-sync.d.ts.map +1 -1
  104. package/dist/transactions/reconcile.d.ts +9 -11
  105. package/dist/transactions/reconcile.d.ts.map +1 -1
  106. package/dist/transactions/transact.d.ts +30 -27
  107. package/dist/transactions/transact.d.ts.map +1 -1
  108. package/dist/transactions/transaction-planner.d.ts +34 -0
  109. package/dist/transactions/transaction-planner.d.ts.map +1 -0
  110. package/dist/transactions/transfer-planner.d.ts +37 -0
  111. package/dist/transactions/transfer-planner.d.ts.map +1 -0
  112. package/dist/transactions/types/deposit.d.ts +67 -0
  113. package/dist/transactions/types/deposit.d.ts.map +1 -0
  114. package/dist/transactions/types/domain.d.ts +70 -0
  115. package/dist/transactions/types/domain.d.ts.map +1 -0
  116. package/dist/transactions/types/index.d.ts +18 -0
  117. package/dist/transactions/types/index.d.ts.map +1 -0
  118. package/dist/transactions/types/options.d.ts +54 -0
  119. package/dist/transactions/types/options.d.ts.map +1 -0
  120. package/dist/transactions/types/planning.d.ts +82 -0
  121. package/dist/transactions/types/planning.d.ts.map +1 -0
  122. package/dist/transactions/types/state-stores.d.ts +151 -0
  123. package/dist/transactions/types/state-stores.d.ts.map +1 -0
  124. package/dist/transactions/types/transact.d.ts +83 -0
  125. package/dist/transactions/types/transact.d.ts.map +1 -0
  126. package/dist/transactions/withdrawal-planner.d.ts +58 -0
  127. package/dist/transactions/withdrawal-planner.d.ts.map +1 -0
  128. package/dist/tsconfig.tsbuildinfo +1 -1
  129. package/dist/tsup.browser.config.d.ts +7 -0
  130. package/dist/tsup.browser.config.d.ts.map +1 -0
  131. package/dist/tsup.config.d.ts +8 -0
  132. package/dist/tsup.config.d.ts.map +1 -0
  133. package/dist/types.d.ts +1 -0
  134. package/dist/types.d.ts.map +1 -1
  135. package/dist/utils/amounts.d.ts +26 -0
  136. package/dist/utils/amounts.d.ts.map +1 -0
  137. package/dist/utils/async.d.ts +9 -0
  138. package/dist/utils/async.d.ts.map +1 -1
  139. package/dist/utils/async.js +38 -11
  140. package/dist/utils/async.js.map +1 -0
  141. package/dist/utils/bigint.d.ts +0 -2
  142. package/dist/utils/bigint.d.ts.map +1 -1
  143. package/dist/utils/format.d.ts +25 -0
  144. package/dist/utils/format.d.ts.map +1 -0
  145. package/dist/utils/notes.d.ts +15 -0
  146. package/dist/utils/notes.d.ts.map +1 -0
  147. package/dist/utils/polling.d.ts +5 -0
  148. package/dist/utils/polling.d.ts.map +1 -1
  149. package/dist/utils/random.d.ts +18 -0
  150. package/dist/utils/random.d.ts.map +1 -0
  151. package/dist/utils/signature.d.ts +6 -0
  152. package/dist/utils/signature.d.ts.map +1 -1
  153. package/dist/utils/validators.d.ts +21 -10
  154. package/dist/utils/validators.d.ts.map +1 -1
  155. package/dist/vitest.config.d.ts +3 -0
  156. package/dist/vitest.config.d.ts.map +1 -0
  157. package/dist/wallet/adapter.d.ts +21 -0
  158. package/dist/wallet/adapter.d.ts.map +1 -0
  159. package/dist/wallet/burner/service.d.ts +32 -0
  160. package/dist/wallet/burner/service.d.ts.map +1 -0
  161. package/dist/wallet/burner/types.d.ts +47 -0
  162. package/dist/wallet/burner/types.d.ts.map +1 -0
  163. package/dist/wallet/index.d.ts +20 -0
  164. package/dist/wallet/index.d.ts.map +1 -0
  165. package/dist/wallet/index.js +9712 -0
  166. package/dist/wallet/index.js.map +1 -0
  167. package/dist/wallet/sdk.d.ts +47 -0
  168. package/dist/wallet/sdk.d.ts.map +1 -0
  169. package/dist/wallet/types.d.ts +455 -0
  170. package/dist/wallet/types.d.ts.map +1 -0
  171. package/dist/wallet/unlink-wallet.d.ts +186 -0
  172. package/dist/wallet/unlink-wallet.d.ts.map +1 -0
  173. package/package.json +40 -14
  174. package/dist/account/zkAccount.d.ts.map +0 -1
  175. package/dist/account/zkAccount.js +0 -128
  176. package/dist/clients/broadcaster.js +0 -23
  177. package/dist/clients/http.js +0 -57
  178. package/dist/clients/indexer.js +0 -67
  179. package/dist/config.js +0 -29
  180. package/dist/core.js +0 -12
  181. package/dist/errors.js +0 -18
  182. package/dist/key-derivation/babyjubjub.d.ts +0 -9
  183. package/dist/key-derivation/babyjubjub.d.ts.map +0 -1
  184. package/dist/key-derivation/babyjubjub.js +0 -9
  185. package/dist/key-derivation/bech32.d.ts +0 -22
  186. package/dist/key-derivation/bech32.d.ts.map +0 -1
  187. package/dist/key-derivation/bech32.js +0 -86
  188. package/dist/key-derivation/bip32.d.ts +0 -17
  189. package/dist/key-derivation/bip32.d.ts.map +0 -1
  190. package/dist/key-derivation/bip32.js +0 -41
  191. package/dist/key-derivation/bip39.d.ts +0 -22
  192. package/dist/key-derivation/bip39.d.ts.map +0 -1
  193. package/dist/key-derivation/bip39.js +0 -56
  194. package/dist/key-derivation/bytes.d.ts +0 -19
  195. package/dist/key-derivation/bytes.d.ts.map +0 -1
  196. package/dist/key-derivation/bytes.js +0 -92
  197. package/dist/key-derivation/hash.d.ts +0 -3
  198. package/dist/key-derivation/hash.d.ts.map +0 -1
  199. package/dist/key-derivation/hash.js +0 -10
  200. package/dist/key-derivation/index.d.ts +0 -8
  201. package/dist/key-derivation/index.d.ts.map +0 -1
  202. package/dist/key-derivation/index.js +0 -7
  203. package/dist/key-derivation/wallet-node.d.ts +0 -45
  204. package/dist/key-derivation/wallet-node.d.ts.map +0 -1
  205. package/dist/key-derivation/wallet-node.js +0 -109
  206. package/dist/keys.js +0 -41
  207. package/dist/prover/config.js +0 -80
  208. package/dist/prover/index.js +0 -1
  209. package/dist/prover/prover.js +0 -274
  210. package/dist/prover/registry.js +0 -57
  211. package/dist/schema.js +0 -14
  212. package/dist/state/ciphertext-store.d.ts +0 -12
  213. package/dist/state/ciphertext-store.d.ts.map +0 -1
  214. package/dist/state/ciphertext-store.js +0 -25
  215. package/dist/state/index.js +0 -2
  216. package/dist/state/leaf-store.d.ts +0 -17
  217. package/dist/state/leaf-store.d.ts.map +0 -1
  218. package/dist/state/leaf-store.js +0 -35
  219. package/dist/state/merkle/hydrator.js +0 -36
  220. package/dist/state/merkle/index.js +0 -2
  221. package/dist/state/merkle/merkle-tree.js +0 -104
  222. package/dist/state/merkle-tree.d.ts +0 -34
  223. package/dist/state/merkle-tree.d.ts.map +0 -1
  224. package/dist/state/merkle-tree.js +0 -104
  225. package/dist/state/note-store.d.ts +0 -37
  226. package/dist/state/note-store.d.ts.map +0 -1
  227. package/dist/state/note-store.js +0 -133
  228. package/dist/state/nullifier-store.d.ts +0 -13
  229. package/dist/state/nullifier-store.d.ts.map +0 -1
  230. package/dist/state/nullifier-store.js +0 -21
  231. package/dist/state/records.d.ts +0 -57
  232. package/dist/state/records.d.ts.map +0 -1
  233. package/dist/state/records.js +0 -1
  234. package/dist/state/root-store.d.ts +0 -13
  235. package/dist/state/root-store.d.ts.map +0 -1
  236. package/dist/state/root-store.js +0 -30
  237. package/dist/state/store/ciphertext-store.js +0 -25
  238. package/dist/state/store/index.js +0 -8
  239. package/dist/state/store/job-store.js +0 -118
  240. package/dist/state/store/jobs.js +0 -1
  241. package/dist/state/store/leaf-store.js +0 -35
  242. package/dist/state/store/note-store.js +0 -142
  243. package/dist/state/store/nullifier-store.js +0 -30
  244. package/dist/state/store/records.js +0 -1
  245. package/dist/state/store/root-store.js +0 -30
  246. package/dist/state/store/store.js +0 -22
  247. package/dist/state/store.d.ts +0 -26
  248. package/dist/state/store.d.ts.map +0 -1
  249. package/dist/state/store.js +0 -19
  250. package/dist/storage/index.js +0 -2
  251. package/dist/storage/indexeddb.js +0 -205
  252. package/dist/storage/memory.js +0 -87
  253. package/dist/transactions/deposit.js +0 -173
  254. package/dist/transactions/index.js +0 -4
  255. package/dist/transactions/note-sync.js +0 -320
  256. package/dist/transactions/reconcile.js +0 -39
  257. package/dist/transactions/transact.js +0 -561
  258. package/dist/transactions/types.d.ts +0 -114
  259. package/dist/transactions/types.d.ts.map +0 -1
  260. package/dist/transactions/types.js +0 -1
  261. package/dist/types.js +0 -1
  262. package/dist/utils/bigint.js +0 -29
  263. package/dist/utils/crypto.d.ts +0 -12
  264. package/dist/utils/crypto.d.ts.map +0 -1
  265. package/dist/utils/crypto.js +0 -39
  266. package/dist/utils/json-codec.js +0 -25
  267. package/dist/utils/polling.js +0 -6
  268. package/dist/utils/signature.js +0 -12
  269. package/dist/utils/validators.js +0 -70
@@ -1,50 +1,95 @@
1
+ import type { HistoryAmount, HistoryKind } from "../../history/types.js";
2
+ import type { SerializedWitness } from "../../transactions/types/domain.js";
1
3
  export type JobStatus = "pending" | "submitted" | "broadcasting" | "succeeded" | "failed" | "dead";
2
- export type PendingJobKind = "deposit" | "transact";
3
- export type PendingJobBase = {
4
+ export type JobKind = "deposit" | "transfer" | "withdraw" | "adapter";
5
+ export type JobRecordBase = {
4
6
  relayId: string;
5
- kind: PendingJobKind;
7
+ kind: JobKind;
6
8
  chainId: number;
9
+ /** Master public key (hex string) for correlating jobs with history/account views. */
10
+ mpk?: string;
7
11
  status: JobStatus;
8
- broadcasterRelayId?: string | null;
9
12
  txHash?: string | null;
10
13
  createdAt: number;
11
14
  lastCheckedAt?: number;
12
15
  timeoutMs: number;
13
16
  error?: string | null;
17
+ /**
18
+ * Optional history preview so UIs can show pending/failed history rows before notes are indexed.
19
+ * Amount deltas follow HistoryAmount semantics (positive receive, negative send).
20
+ */
21
+ historyPreview?: {
22
+ kind: HistoryKind;
23
+ amounts: HistoryAmount[];
24
+ };
25
+ };
26
+ /**
27
+ * Predicted commitment info for deposits.
28
+ */
29
+ export type PredictedCommitment = {
30
+ hex: string;
31
+ token: string;
32
+ amount: string;
33
+ index?: number;
34
+ root?: string;
14
35
  };
15
- export type PendingDepositJob = PendingJobBase & {
36
+ /**
37
+ * Record for tracking deposits
38
+ */
39
+ export type DepositRecord = JobRecordBase & {
16
40
  kind: "deposit";
17
- predictedCommitment: {
18
- hex: string;
19
- index?: number;
20
- root?: string;
21
- };
41
+ /** Predicted commitments for each note */
42
+ predictedCommitments: PredictedCommitment[];
22
43
  };
23
- export type PendingTransactContext = {
44
+ export type TransactContext = {
24
45
  index: number;
25
46
  nullifier: string;
26
- witness: {
27
- root: string;
28
- leaf: string;
29
- pathElements: string[][];
30
- pathIndices: number[];
31
- leafIndex: number;
32
- };
47
+ witness: SerializedWitness;
33
48
  root: string;
34
49
  };
35
- export type PendingTransactOutput = {
50
+ export type TransactOutput = {
36
51
  hex: string;
37
52
  index: number;
38
53
  root?: string;
39
54
  };
40
- export type PendingTransactJob = PendingJobBase & {
41
- kind: "transact";
55
+ /**
56
+ * Individual transaction info within a transact job.
57
+ */
58
+ export type TransactJobTransaction = {
59
+ token: string;
60
+ nullifiers: string[];
61
+ predictedCommitments: Array<{
62
+ hex: string;
63
+ index?: number;
64
+ }>;
65
+ /** For withdrawals: amount and recipient */
66
+ withdrawal?: {
67
+ amount: string;
68
+ recipient: string;
69
+ };
70
+ };
71
+ /** Fields shared by transfer and withdraw records */
72
+ type PoolTransactionFields = {
42
73
  poolAddress: string;
43
74
  calldata: string;
44
- contexts: PendingTransactContext[];
45
- predictedOutputs: PendingTransactOutput[];
46
- expectedRoot?: string;
75
+ /** Individual transactions in the batch */
76
+ transactions: TransactJobTransaction[];
77
+ };
78
+ export type TransferRecord = JobRecordBase & PoolTransactionFields & {
79
+ kind: "transfer";
80
+ };
81
+ export type WithdrawRecord = JobRecordBase & PoolTransactionFields & {
82
+ kind: "withdraw";
83
+ };
84
+ export type AdapterRecord = JobRecordBase & PoolTransactionFields & {
85
+ kind: "adapter";
86
+ adapterAddress: string;
87
+ adapterCalldata: string;
47
88
  };
48
- export type PendingJobRecord = PendingDepositJob | PendingTransactJob;
89
+ /** Union of all pool transaction records */
90
+ export type PoolTransactionRecord = TransferRecord | WithdrawRecord | AdapterRecord;
91
+ /** Union of all job records */
92
+ export type JobRecord = DepositRecord | TransferRecord | WithdrawRecord | AdapterRecord;
49
93
  export declare const DEFAULT_JOB_TIMEOUT_MS: number;
94
+ export {};
50
95
  //# sourceMappingURL=jobs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../../state/store/jobs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,WAAW,GACX,cAAc,GACd,WAAW,GACX,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SA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B,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAElB,+BAA+B;AAC/B,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAElB,eAAO,MAAM,sBAAsB,QAAgB,CAAC"}
@@ -9,6 +9,10 @@ export declare function createLeafStore(storage: Storage): {
9
9
  * Load a leaf commitment by tree index.
10
10
  */
11
11
  getLeaf(chainId: number, index: number): Promise<LeafRecord | null>;
12
+ /**
13
+ * Load all cached leaves for a chain in index order.
14
+ */
15
+ listLeaves(chainId: number): Promise<LeafRecord[]>;
12
16
  /**
13
17
  * Remove all cached leaves for a chain.
14
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"leaf-store.d.ts","sourceRoot":"","sources":["../../../state/store/leaf-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IAE5C;;OAEG;kBACiB,UAAU;IAM9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;IAM5C;;OAEG;yBACwB,MAAM;EASpC"}
1
+ {"version":3,"file":"leaf-store.d.ts","sourceRoot":"","sources":["../../../state/store/leaf-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IAE5C;;OAEG;kBACiB,UAAU;IAM9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;IAI5C;;OAEG;wBACuB,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAQxD;;OAEG;yBACwB,MAAM;EAQpC"}
@@ -4,7 +4,9 @@ export declare const emptyBytes: () => Uint8Array<ArrayBuffer>;
4
4
  export declare function createNoteStore(storage: Storage): {
5
5
  /**
6
6
  * Upsert a note record and maintain the unspent-note index for fast balance queries.
7
- * If the note already exists and is marked as spent, preserve the spentAt field.
7
+ * If the note already exists and is marked as spent, preserve spentAt unless the caller
8
+ * provides an explicit spentAt value (eg. upgrading from a local observation time to an
9
+ * on-chain timestamp from the indexer).
8
10
  */
9
11
  putNote(note: NoteInsert): Promise<void>;
10
12
  /**
@@ -21,18 +23,16 @@ export declare function createNoteStore(storage: Storage): {
21
23
  includeSpent?: boolean;
22
24
  }): Promise<NoteRecord[]>;
23
25
  /**
24
- * Mark a cached note as spent by setting its timestamp and re-indexing metadata.
26
+ * Mark a cached note as spent by setting its timestamp and transaction hash.
25
27
  */
26
- markNoteSpent(chainId: number, index: number, spentAt?: number): Promise<NoteRecord>;
28
+ markNoteSpent(chainId: number, index: number, spentAt?: number, spentTxHash?: string): Promise<NoteRecord>;
27
29
  /**
28
30
  * Drop the spent marker from a cached note, returning it to the unspent index.
29
31
  */
30
32
  markNoteUnspent(chainId: number, index: number): Promise<NoteRecord>;
31
33
  /**
32
- * Aggregate unspent note balances per token for a given master public key.
34
+ * Remove all cached notes and their unspent indices for a chain.
33
35
  */
34
- getZkBalances(mpk: string, options?: {
35
- chainId?: number;
36
- }): Promise<Record<string, bigint>>;
36
+ clearNotes(chainId: number): Promise<void>;
37
37
  };
38
38
  //# sourceMappingURL=note-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"note-store.d.ts","sourceRoot":"","sources":["../../../state/store/note-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAavD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,eAAO,MAAM,UAAU,+BAA0B,CAAC;AAElD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IAyC5C;;;OAGG;kBACiB,UAAU;IAW9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;IAM5C;;OAEG;wBAEQ;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;IAyBH;;OAEG;2BAC0B,MAAM,SAAS,MAAM;IAgBlD;;OAEG;6BAC4B,MAAM,SAAS,MAAM;IAgBpD;;OAEG;uBACsB,MAAM,YAAW;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;EAiBjE"}
1
+ {"version":3,"file":"note-store.d.ts","sourceRoot":"","sources":["../../../state/store/note-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAevD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,eAAO,MAAM,UAAU,+BAA0B,CAAC;AAElD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IA2D5C;;;;;OAKG;kBACiB,UAAU;IAW9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;IAI5C;;OAEG;wBAEQ;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;IAkBH;;OAEG;2BAEQ,MAAM,SACR,MAAM,kCAEC,MAAM;IAiBtB;;OAEG;6BAC4B,MAAM,SAAS,MAAM;IAcpD;;OAEG;wBACuB,MAAM;EAmBnC"}
@@ -13,5 +13,14 @@ export declare function createNullifierStore(storage: Storage): {
13
13
  * Count all nullifiers stored locally for a given chain.
14
14
  */
15
15
  countNullifiers(chainId: number): Promise<number>;
16
+ /**
17
+ * Remove all cached nullifiers for a chain.
18
+ */
19
+ clearNullifiers(chainId: number): Promise<void>;
20
+ /**
21
+ * Remove cached nullifiers whose noteIndex >= fromIndex.
22
+ * Used by partial resync to keep the count-based optimization accurate.
23
+ */
24
+ clearNullifiersFromIndex(chainId: number, fromIndex: number): Promise<void>;
16
25
  };
17
26
  //# sourceMappingURL=nullifier-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nullifier-store.d.ts","sourceRoot":"","sources":["../../../state/store/nullifier-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO;IAEjD;;OAEG;4BAC2B,eAAe;IAS7C;;OAEG;0BACyB,MAAM,SAAS,MAAM;IAKjD;;OAEG;6BAC4B,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;EAO1D"}
1
+ {"version":3,"file":"nullifier-store.d.ts","sourceRoot":"","sources":["../../../state/store/nullifier-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO;IAEjD;;OAEG;4BAC2B,eAAe;IAS7C;;OAEG;0BACyB,MAAM,SAAS,MAAM;IAIjD;;OAEG;6BAC4B,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD;;OAEG;6BAC4B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrD;;;OAGG;sCAEQ,MAAM,aACJ,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;EAmBnB"}
@@ -22,10 +22,33 @@ export type NoteRecord = {
22
22
  random: string;
23
23
  /** Nullifier that will be revealed when the note is spent. */
24
24
  nullifier: string;
25
- /** Optional timestamp when the note was marked as spent. */
25
+ /**
26
+ * Transaction hash that inserted this note commitment on-chain.
27
+ * Derived from the indexer commitment record.
28
+ */
29
+ createdTxHash?: string;
30
+ /**
31
+ * Indexer event type associated with the commitment insertion.
32
+ * Typically "deposit" or "transact" once supported by the indexer.
33
+ */
34
+ createdEventType?: string;
35
+ /** Optional timestamp (ms) when this note was created/observed by the indexer. */
36
+ createdAt?: number;
37
+ /**
38
+ * Optional timestamp (ms) when the note was marked as spent.
39
+ * Prefer an on-chain/indexer-derived time when available; otherwise it may be a local observation time.
40
+ */
41
+ spentAt?: number;
42
+ /** Transaction hash that spent this note (via its nullifier), when known. */
43
+ spentTxHash?: string;
44
+ };
45
+ export type NoteInsert = Omit<NoteRecord, "spentAt"> & {
46
+ /**
47
+ * Optional timestamp (ms) when the note was marked as spent.
48
+ * When omitted, existing spentAt (if any) is preserved by the note store.
49
+ */
26
50
  spentAt?: number;
27
51
  };
28
- export type NoteInsert = Omit<NoteRecord, 'spentAt'>;
29
52
  /**
30
53
  * Details about a nullifier observed on-chain, whether or not we own the note.
31
54
  */
@@ -45,6 +68,20 @@ export type LeafRecord = {
45
68
  index: number;
46
69
  /** Commitment value stored in the tree. */
47
70
  commitment: string;
71
+ /** Transaction hash that created this commitment. */
72
+ txHash?: string;
73
+ /** Event type: "deposit" or "transact". */
74
+ eventType?: string;
75
+ /**
76
+ * Optional adapter event fields persisted for "adapter_deposit" leaves.
77
+ * Keeping these in local state avoids per-leaf indexer fetches during rescans.
78
+ */
79
+ adapterNpk?: string;
80
+ adapterToken?: string;
81
+ adapterAmount?: string;
82
+ adapterRandom?: string;
83
+ /** Unix timestamp (seconds) when indexed. */
84
+ insertedAt?: number;
48
85
  };
49
86
  /**
50
87
  * Historical merkle root snapshot used for proof construction.
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../state/store/records.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC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C;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"root-store.d.ts","sourceRoot":"","sources":["../../../state/store/root-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IAE5C;;OAEG;kBACiB,UAAU;IAU9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;EAQ/C"}
1
+ {"version":3,"file":"root-store.d.ts","sourceRoot":"","sources":["../../../state/store/root-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO;IAE5C;;OAEG;kBACiB,UAAU;IAU9B;;OAEG;qBACoB,MAAM,SAAS,MAAM;EAI/C"}
@@ -1,34 +1,86 @@
1
+ import type { HistoryEntry } from "../../history/types.js";
1
2
  import type { Storage } from "../../types.js";
2
- export declare function createStateStore(storage: Storage): {
3
- putPendingJob(job: import("./jobs.js").PendingJobRecord): Promise<void>;
4
- getPendingJob(relayId: string): Promise<import("./jobs.js").PendingJobRecord | null>;
5
- listPendingJobs(filter?: {
6
- kind?: import("./jobs.js").PendingJobKind;
7
- statuses?: import("./jobs.js").JobStatus[];
8
- }): Promise<import("./jobs.js").PendingJobRecord[]>;
9
- deletePendingJob(relayId: string): Promise<void>;
10
- putCiphertext(chainId: number, index: number, payload: Uint8Array): Promise<void>;
11
- getCiphertext(chainId: number, index: number): Promise<Uint8Array<ArrayBuffer> | null>;
12
- putRoot(root: import("./records.js").RootRecord): Promise<void>;
13
- getRoot(chainId: number, value: string): Promise<import("./records.js").RootRecord | null>;
14
- putLeaf(leaf: import("./records.js").LeafRecord): Promise<void>;
15
- getLeaf(chainId: number, index: number): Promise<import("./records.js").LeafRecord | null>;
16
- clearLeaves(chainId: number): Promise<void>;
17
- putNullifier(nullifier: import("./records.js").NullifierRecord): Promise<void>;
18
- getNullifier(chainId: number, value: string): Promise<import("./records.js").NullifierRecord | null>;
19
- countNullifiers(chainId: number): Promise<number>;
20
- putNote(note: import("./records.js").NoteInsert): Promise<void>;
21
- getNote(chainId: number, index: number): Promise<import("./records.js").NoteRecord | null>;
3
+ import type { JobKind, JobRecord, JobStatus } from "./jobs.js";
4
+ import type { LeafRecord, NoteInsert, NoteRecord, NullifierRecord, RootRecord } from "./records.js";
5
+ export interface StateStore {
6
+ putNote(note: NoteInsert): Promise<void>;
7
+ getNote(chainId: number, index: number): Promise<NoteRecord | null>;
22
8
  listNotes(options?: {
23
9
  chainId?: number;
24
10
  mpk?: string;
25
11
  token?: string;
26
12
  includeSpent?: boolean;
27
- }): Promise<import("./records.js").NoteRecord[]>;
28
- markNoteSpent(chainId: number, index: number, spentAt?: number): Promise<import("./records.js").NoteRecord>;
29
- markNoteUnspent(chainId: number, index: number): Promise<import("./records.js").NoteRecord>;
30
- getZkBalances(mpk: string, options?: {
31
- chainId?: number;
32
- }): Promise<Record<string, bigint>>;
33
- };
13
+ }): Promise<NoteRecord[]>;
14
+ markNoteSpent(chainId: number, index: number, spentAt?: number, spentTxHash?: string): Promise<NoteRecord>;
15
+ markNoteUnspent(chainId: number, index: number): Promise<NoteRecord>;
16
+ clearNotes(chainId: number): Promise<void>;
17
+ putNullifier(nullifier: NullifierRecord): Promise<void>;
18
+ getNullifier(chainId: number, value: string): Promise<NullifierRecord | null>;
19
+ countNullifiers(chainId: number): Promise<number>;
20
+ clearNullifiers(chainId: number): Promise<void>;
21
+ clearNullifiersFromIndex(chainId: number, fromIndex: number): Promise<void>;
22
+ putLeaf(leaf: LeafRecord): Promise<void>;
23
+ getLeaf(chainId: number, index: number): Promise<LeafRecord | null>;
24
+ listLeaves(chainId: number): Promise<LeafRecord[]>;
25
+ clearLeaves(chainId: number): Promise<void>;
26
+ putRoot(root: RootRecord): Promise<void>;
27
+ getRoot(chainId: number, value: string): Promise<RootRecord | null>;
28
+ putCiphertext(chainId: number, index: number, payload: Uint8Array): Promise<void>;
29
+ getCiphertext(chainId: number, index: number): Promise<Uint8Array | null>;
30
+ listCiphertexts(chainId: number): Promise<{
31
+ index: number;
32
+ payload: Uint8Array;
33
+ }[]>;
34
+ clearCiphertexts(chainId: number): Promise<void>;
35
+ putJob(job: JobRecord): Promise<void>;
36
+ getJob(relayId: string): Promise<JobRecord | null>;
37
+ listJobs(filter?: {
38
+ kind?: JobKind;
39
+ statuses?: JobStatus[];
40
+ }): Promise<JobRecord[]>;
41
+ deleteJob(relayId: string): Promise<void>;
42
+ putHistoryEntry(entry: HistoryEntry): Promise<void>;
43
+ hasHistorySnapshot(options: {
44
+ chainId: number;
45
+ mpk: string;
46
+ }): Promise<boolean>;
47
+ listHistoryEntries(options: {
48
+ chainId: number;
49
+ mpk: string;
50
+ }): Promise<HistoryEntry[]>;
51
+ clearHistoryEntries(options: {
52
+ chainId: number;
53
+ mpk: string;
54
+ }): Promise<void>;
55
+ commitHistorySnapshot(options: {
56
+ chainId: number;
57
+ mpk: string;
58
+ }): Promise<void>;
59
+ syncCommitment(params: {
60
+ leaf: LeafRecord;
61
+ ciphertext: {
62
+ chainId: number;
63
+ index: number;
64
+ payload: Uint8Array;
65
+ };
66
+ root: RootRecord;
67
+ note?: NoteRecord;
68
+ }): Promise<void>;
69
+ syncCommitmentBatch(items: Array<{
70
+ leaf: LeafRecord;
71
+ ciphertext: {
72
+ chainId: number;
73
+ index: number;
74
+ payload: Uint8Array;
75
+ };
76
+ root: RootRecord;
77
+ note?: NoteRecord;
78
+ }>): Promise<void>;
79
+ getRescanCursor(chainId: number, mpk: string): Promise<number | null>;
80
+ setRescanCursor(chainId: number, mpk: string, value: number): Promise<void>;
81
+ clearRescanCursors(chainId: number): Promise<void>;
82
+ /** Clear notes, leaves, ciphertexts, and unspent indices for indices >= fromIndex. */
83
+ clearChainDataFromIndex(chainId: number, fromIndex: number): Promise<void>;
84
+ }
85
+ export declare function createStateStore(storage: Storage): StateStore;
34
86
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../state/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO;;;;YAiBg2F,CAAC;gBAAkC,CAAC;;;;;;;;;;;;;;;;eAA5jC,CAAC;WAAqB,CAAC;aAAuB,CAAC;oBAA8B,CAAC;;;;;eAA+qE,CAAC;;EADtnI"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../state/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAW,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAKvD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI/D,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACX,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,UAAU;IAEzB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACpE,SAAS,CAAC,OAAO,CAAC,EAAE;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB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,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD,sFAAsF;IACtF,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CA+M7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../storage/indexeddb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAuC,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAsCF,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAyJ3E"}
1
+ {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../storage/indexeddb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAuC,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAmEF,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAyK3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../storage/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAuC,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3E,wBAAgB,mBAAmB,IAAI,OAAO,CA+D7C"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../storage/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAuC,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3E,wBAAgB,mBAAmB,IAAI,OAAO,CA2E7C"}
@@ -0,0 +1,31 @@
1
+ import type { AdapterExecutionCall, AdapterExecutionReshield } from "./transact.js";
2
+ export type { AdapterExecutionCall, AdapterExecutionReshield, } from "./transact.js";
3
+ export declare const ADAPTER_EXECUTE_ABI: readonly ["function execute(bytes _transactData, (address to, bytes data, uint256 value)[] _calls, (uint256 npk, uint256 random, address token, uint256 minAmount)[] _reshields, address[] _inputTokens, uint256 _nonce, uint256 _deadline)"];
4
+ export type BuildCallParams = {
5
+ to: string;
6
+ abi: string;
7
+ functionName: string;
8
+ args: unknown[];
9
+ value?: bigint;
10
+ };
11
+ export type EncodeAdapterExecuteParams = {
12
+ transactCalldata: string;
13
+ calls: AdapterExecutionCall[];
14
+ reshields: AdapterExecutionReshield[];
15
+ inputTokens: string[];
16
+ nonce: bigint;
17
+ deadline: bigint;
18
+ };
19
+ /**
20
+ * Build a single adapter call from ABI metadata.
21
+ */
22
+ export declare function buildCall(params: BuildCallParams): AdapterExecutionCall;
23
+ /**
24
+ * Build a standard ERC-20 approve call for adapter execution.
25
+ */
26
+ export declare function buildApproveCall(token: string, spender: string, amount: bigint): AdapterExecutionCall;
27
+ /**
28
+ * Encode `UnlinkAdapter.execute(...)` calldata.
29
+ */
30
+ export declare function encodeAdapterExecute(params: EncodeAdapterExecuteParams): string;
31
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../transactions/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,mBAAmB,+OAEtB,CAAC;AAQX,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,SAAS,EAAE,wBAAwB,EAAE,CAAC;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAgDF;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,oBAAoB,CAoCvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,oBAAoB,CAetB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,0BAA0B,GACjC,MAAM,CAuBR"}
@@ -1,18 +1,13 @@
1
- import { FetchLike } from "../clients/http.js";
2
- import { createIndexerClient } from "../clients/indexer.js";
3
- import { LocalMerkleTrees } from "../state/index.js";
4
- import type { DepositRelayResult, DepositRequest, DepositStateStore, DepositSyncResult } from "./types.js";
5
- export declare const DEPOSIT_ABI: readonly ["function deposit(address _depositor, (uint256 npk, uint256 amount, address token)[] notes, (uint256[3] data)[] ciphertexts)"];
6
- type DepositClientOptions = {
7
- merkleTrees?: LocalMerkleTrees;
8
- fetch: FetchLike;
9
- pollIntervalMs?: number;
10
- pollTimeoutMs?: number;
11
- indexerClient?: ReturnType<typeof createIndexerClient>;
12
- };
13
- export declare function createDepositClient(stateStore: DepositStateStore, options: DepositClientOptions): {
14
- request(request: DepositRequest): Promise<DepositRelayResult>;
15
- syncPendingDeposit(relayId: string): Promise<DepositSyncResult>;
16
- };
17
- export {};
1
+ import type { BaseStateStore, DepositParams, DepositRelayResult, DepositSyncResult, ServiceOptions } from "./types/index.js";
2
+ export declare const DEPOSIT_ABI: readonly ["function deposit(address _depositor, (uint256 npk, uint256 amount, address token)[] notes, (uint256 ephemeralKey, uint256[3] data)[] ciphertexts) payable"];
3
+ /**
4
+ * Prepare a deposit: compute commitments, build calldata, and persist pending job.
5
+ * Accepts 1 or more notes in a single transaction.
6
+ */
7
+ export declare function deposit(store: BaseStateStore, req: DepositParams): Promise<DepositRelayResult>;
8
+ /**
9
+ * Wait for all commitments in a deposit to be indexed and update local state.
10
+ * Works for both single and multi-note deposits.
11
+ */
12
+ export declare function syncDeposit(store: BaseStateStore, relayId: string, opts: ServiceOptions): Promise<DepositSyncResult>;
18
13
  //# sourceMappingURL=deposit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../../transactions/deposit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAoB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG9E,OAAO,EAGL,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,WAAW,0IAEd,CAAC;AAGX,KAAK,oBAAoB,GAAG;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACxD,CAAC;AAuBF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,iBAAiB,EAC7B,OAAO,EAAE,oBAAoB;qBAiEJ,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;gCA6BjC,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;EAwExE"}
1
+ {"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../../transactions/deposit.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAEjB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,WAAW,wKAEd,CAAC;AAmEX;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAgD7B;AAkHD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAiD5B"}
@@ -1,7 +1,12 @@
1
- export { createDepositClient } from "./deposit.js";
2
- export { createTransactService } from "./transact.js";
1
+ export { deposit, syncDeposit, DEPOSIT_ABI } from "./deposit.js";
2
+ export { transact, syncTransact, computeBoundParamsHash, computeAdapterDataHash, } from "./transact.js";
3
+ export type { AdapterExecutionCall, AdapterExecutionReshield, } from "./transact.js";
4
+ export { ADAPTER_EXECUTE_ABI, buildApproveCall, buildCall, encodeAdapterExecute, type BuildCallParams, type EncodeAdapterExecuteParams, } from "./adapter.js";
5
+ export { planTransaction } from "./transaction-planner.js";
6
+ export { planWithdrawals, type WithdrawalPlan, type WithdrawalInput, } from "./withdrawal-planner.js";
7
+ export { planTransfers, type TransferInput } from "./transfer-planner.js";
8
+ export { selectNotesForAmount } from "./note-selection.js";
3
9
  export { createJobReconciler } from "./reconcile.js";
4
10
  export { createNoteSyncService } from "./note-sync.js";
5
- export type { NoteSyncStateStore } from "./note-sync.js";
6
- export type { DepositRelayResult, DepositNoteInput, DepositRequest, DepositSyncResult, DepositStateStore, Proof, OutputNoteInput, SpendNoteReference, TransactRelayResult, TransactRequest, TransactSyncResult, TransactStateStore, WithdrawalNoteInput, } from "./types.js";
11
+ export type { BaseStateStore, TransactStateStore, NoteSyncStateStore, PollingOptions, ServiceOptions, NoteSyncOptions, Proof, Ciphertext, NoteInput, WithdrawalNoteInput, SpendNoteReference, SerializedWitness, DepositParams, DepositRelayResult, DepositSyncResult, DepositCommitmentInfo, TransactParams, TransactItem, TransactRelayResult, TransactItemResult, TransactSyncResult, Recipient, PlannedOutput, TransactionPlan, SelectableNote, SelectionOptions, SelectionResult, } from "./types/index.js";
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../transactions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,0BAA0B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,YAAY,EAEV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAGlB,cAAc,EACd,cAAc,EACd,eAAe,EAGf,KAAK,EACL,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAGjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EAGrB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAGlB,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { SelectableNote, SelectionOptions, SelectionResult } from "./types/index.js";
2
+ /**
3
+ * Select notes for a transaction with consolidation-first strategy.
4
+ *
5
+ * Priorities:
6
+ * 1. Consolidation - prefer spending more small notes
7
+ * 2. Minimize change - find combinations with less overshoot
8
+ * 3. Respect maxInputs constraint
9
+ *
10
+ * @param notes - Available unspent notes (caller filters by token)
11
+ * @param totalNeeded - Total amount needed for all recipients
12
+ * @param options - Selection options
13
+ * @returns Selection result with notes and amounts
14
+ * @throws ValidationError if insufficient balance or constraints can't be met
15
+ */
16
+ export declare function selectNotesForAmount<T>(notes: SelectableNote<T>[], totalNeeded: bigint, options?: SelectionOptions): SelectionResult<T>;
17
+ //# sourceMappingURL=note-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"note-selection.d.ts","sourceRoot":"","sources":["../../transactions/note-selection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAyB1B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,EAC1B,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAAC,CAAC,CAAC,CAuEpB"}
@@ -1,46 +1,18 @@
1
- import type { ZkAccount } from "../account/zkAccount.js";
2
- import type { FetchLike } from "../clients/http.js";
3
- import { createIndexerClient } from "../clients/indexer.js";
4
- import { type LeafRecord, type LocalMerkleTrees, type NoteRecord, type RootRecord } from "../state/index.js";
5
- export type NoteSyncStateStore = {
6
- putLeaf(record: LeafRecord): Promise<void>;
7
- getLeaf(chainId: number, index: number): Promise<LeafRecord | null>;
8
- clearLeaves(chainId: number): Promise<void>;
9
- putRoot(record: RootRecord): Promise<void>;
10
- putNote(record: NoteRecord): Promise<void>;
11
- getNote(chainId: number, index: number): Promise<NoteRecord | null>;
12
- markNoteSpent(chainId: number, index: number, spentAt?: number): Promise<NoteRecord>;
13
- putCiphertext(chainId: number, index: number, payload: Uint8Array): Promise<void>;
14
- countNullifiers(chainId: number): Promise<number>;
15
- putNullifier(record: {
16
- chainId: number;
17
- nullifier: string;
18
- noteIndex?: number;
19
- }): Promise<void>;
20
- };
21
- export type NoteSyncOptions = {
22
- merkleTrees?: LocalMerkleTrees;
23
- indexerClient?: ReturnType<typeof createIndexerClient>;
24
- fetch?: FetchLike;
25
- limit?: number;
26
- };
1
+ import type { AccountView } from "../account/account.js";
2
+ import type { NoteSyncOptions, NoteSyncStateStore } from "./types/index.js";
3
+ export type { NoteSyncOptions, NoteSyncStateStore };
27
4
  type ChainSyncStatus = {
28
5
  inFlight: boolean;
29
6
  lastSuccess: number | null;
30
7
  lastError?: string;
31
8
  };
32
9
  export declare function createNoteSyncService(stateStore: NoteSyncStateStore, options?: NoteSyncOptions): {
33
- sync: (chainId: number, account: ZkAccount, opts?: {
34
- start?: number;
35
- forceFullScan?: boolean;
36
- }) => Promise<NoteRecord[]>;
37
- syncChain: (chainId: number, account: ZkAccount, opts?: {
10
+ syncChain: (chainId: number, account: AccountView, opts?: {
38
11
  forceFullResync?: boolean;
39
12
  }) => Promise<void>;
40
- syncChains: (chainIds: number[], account: ZkAccount, opts?: {
13
+ syncChains: (chainIds: number[], account: AccountView, opts?: {
41
14
  forceFullResync?: boolean;
42
15
  }) => Promise<void>;
43
16
  getStatus: () => Map<number, ChainSyncStatus>;
44
17
  };
45
- export {};
46
18
  //# sourceMappingURL=note-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"note-sync.d.ts","sourceRoot":"","sources":["../../transactions/note-sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC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