@veilo/sdk-core 0.4.0 → 0.5.0

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 (296) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +286 -1298
  3. package/dist/cjs/accounts/admin.d.ts +84 -0
  4. package/dist/cjs/accounts/admin.js +208 -0
  5. package/dist/cjs/accounts/errors.d.ts +6 -0
  6. package/dist/cjs/accounts/errors.js +98 -0
  7. package/dist/cjs/accounts/index.d.ts +4 -0
  8. package/dist/cjs/accounts/index.js +20 -0
  9. package/dist/cjs/accounts/pdas.d.ts +23 -0
  10. package/dist/cjs/accounts/pdas.js +44 -0
  11. package/dist/cjs/accounts/queries.d.ts +41 -0
  12. package/dist/cjs/accounts/queries.js +95 -0
  13. package/dist/cjs/client.d.ts +2 -407
  14. package/dist/cjs/client.js +6 -938
  15. package/dist/cjs/cloak/client.d.ts +28 -0
  16. package/dist/cjs/cloak/client.js +68 -0
  17. package/dist/cjs/cloak/errors.d.ts +13 -0
  18. package/dist/cjs/cloak/errors.js +25 -0
  19. package/dist/cjs/cloak/helpers.d.ts +6 -0
  20. package/dist/cjs/cloak/helpers.js +35 -0
  21. package/dist/cjs/cloak/index.d.ts +6 -0
  22. package/dist/cjs/cloak/index.js +24 -0
  23. package/dist/cjs/cloak/polling.d.ts +7 -0
  24. package/dist/cjs/cloak/polling.js +66 -0
  25. package/dist/cjs/cloak/transport.d.ts +15 -0
  26. package/dist/cjs/cloak/transport.js +119 -0
  27. package/dist/cjs/cloak/types.d.ts +188 -0
  28. package/dist/cjs/cloak/types.js +5 -0
  29. package/dist/cjs/cloak.d.ts +1 -0
  30. package/dist/cjs/cloak.js +18 -0
  31. package/dist/cjs/compactNote.d.ts +21 -0
  32. package/dist/cjs/compactNote.js +31 -7
  33. package/dist/cjs/index.d.ts +2 -1
  34. package/dist/cjs/index.js +4 -1
  35. package/dist/cjs/notes/encryption.d.ts +41 -0
  36. package/dist/cjs/notes/encryption.js +75 -0
  37. package/dist/cjs/notes/index.d.ts +5 -0
  38. package/dist/cjs/notes/index.js +21 -0
  39. package/dist/cjs/notes/mailbox.d.ts +70 -0
  40. package/dist/cjs/notes/mailbox.js +164 -0
  41. package/dist/cjs/notes/model.d.ts +91 -0
  42. package/dist/cjs/notes/model.js +109 -0
  43. package/dist/cjs/notes/nullifier.d.ts +27 -0
  44. package/dist/cjs/notes/nullifier.js +45 -0
  45. package/dist/cjs/notes/recovery.d.ts +10 -0
  46. package/dist/cjs/notes/recovery.js +31 -0
  47. package/dist/cjs/proof.d.ts +1 -183
  48. package/dist/cjs/proof.js +16 -290
  49. package/dist/cjs/proofs/encoding.d.ts +17 -0
  50. package/dist/cjs/proofs/encoding.js +72 -0
  51. package/dist/cjs/proofs/formatting.d.ts +6 -0
  52. package/dist/cjs/proofs/formatting.js +34 -0
  53. package/dist/cjs/proofs/index.d.ts +5 -0
  54. package/dist/cjs/proofs/index.js +21 -0
  55. package/dist/cjs/proofs/swap.d.ts +87 -0
  56. package/dist/cjs/proofs/swap.js +144 -0
  57. package/dist/cjs/proofs/transaction.d.ts +28 -0
  58. package/dist/cjs/proofs/transaction.js +110 -0
  59. package/dist/cjs/proofs/types.d.ts +70 -0
  60. package/dist/cjs/prover.d.ts +4 -1
  61. package/dist/cjs/prover.js +12 -2
  62. package/dist/cjs/relayer/client.d.ts +61 -0
  63. package/dist/cjs/relayer/client.js +151 -0
  64. package/dist/cjs/relayer/crypto.d.ts +5 -0
  65. package/dist/cjs/relayer/crypto.js +26 -0
  66. package/dist/cjs/relayer/encoding.d.ts +2 -0
  67. package/dist/cjs/relayer/encoding.js +23 -0
  68. package/dist/cjs/relayer/errors.d.ts +7 -0
  69. package/dist/cjs/relayer/errors.js +17 -0
  70. package/dist/cjs/relayer/index.d.ts +3 -0
  71. package/dist/cjs/relayer/index.js +19 -0
  72. package/dist/cjs/relayer/transport.d.ts +17 -0
  73. package/dist/cjs/relayer/transport.js +63 -0
  74. package/dist/{src/relayer.d.ts → cjs/relayer/types.d.ts} +44 -86
  75. package/dist/cjs/relayer/types.js +5 -0
  76. package/dist/cjs/relayer.d.ts +1 -318
  77. package/dist/cjs/relayer.js +15 -254
  78. package/dist/cjs/shield/alt.js +8 -8
  79. package/dist/cjs/shield/errors.js +2 -2
  80. package/dist/cjs/shield/finalize.js +2 -2
  81. package/dist/cjs/shield/ix.d.ts +1 -1
  82. package/dist/cjs/shield/owner.js +9 -8
  83. package/dist/cjs/shield/ports.js +3 -3
  84. package/dist/cjs/shield/preflight.js +3 -3
  85. package/dist/cjs/shield/shield.js +20 -19
  86. package/dist/cjs/shield/types.d.ts +1 -1
  87. package/dist/cjs/transactions/deposit.d.ts +94 -0
  88. package/dist/cjs/transactions/deposit.js +234 -0
  89. package/dist/cjs/transactions/index.d.ts +7 -0
  90. package/dist/cjs/transactions/index.js +26 -0
  91. package/dist/cjs/transactions/swap.d.ts +71 -0
  92. package/dist/cjs/transactions/swap.js +184 -0
  93. package/dist/cjs/transactions/transact.d.ts +34 -0
  94. package/dist/cjs/transactions/transact.js +146 -0
  95. package/dist/cjs/transactions/transfer.d.ts +51 -0
  96. package/dist/cjs/transactions/transfer.js +106 -0
  97. package/dist/cjs/transactions/withdraw.d.ts +52 -0
  98. package/dist/cjs/transactions/withdraw.js +104 -0
  99. package/dist/cjs/utxo.d.ts +1 -235
  100. package/dist/cjs/utxo.js +15 -404
  101. package/dist/esm/accounts/admin.d.ts +84 -0
  102. package/dist/esm/accounts/admin.js +165 -0
  103. package/dist/esm/accounts/errors.d.ts +6 -0
  104. package/dist/esm/accounts/errors.js +95 -0
  105. package/dist/esm/accounts/index.d.ts +4 -0
  106. package/dist/esm/accounts/index.js +4 -0
  107. package/dist/esm/accounts/pdas.d.ts +23 -0
  108. package/dist/esm/accounts/pdas.js +38 -0
  109. package/dist/esm/accounts/queries.d.ts +41 -0
  110. package/dist/esm/accounts/queries.js +88 -0
  111. package/dist/esm/client.d.ts +2 -407
  112. package/dist/esm/client.js +3 -891
  113. package/dist/esm/cloak/client.d.ts +28 -0
  114. package/dist/esm/cloak/client.js +64 -0
  115. package/dist/esm/cloak/errors.d.ts +13 -0
  116. package/dist/esm/cloak/errors.js +21 -0
  117. package/dist/esm/cloak/helpers.d.ts +6 -0
  118. package/dist/esm/cloak/helpers.js +31 -0
  119. package/dist/esm/cloak/index.d.ts +6 -0
  120. package/dist/esm/cloak/index.js +6 -0
  121. package/dist/esm/cloak/polling.d.ts +7 -0
  122. package/dist/esm/cloak/polling.js +63 -0
  123. package/dist/esm/cloak/transport.d.ts +15 -0
  124. package/dist/esm/cloak/transport.js +115 -0
  125. package/dist/esm/cloak/types.d.ts +188 -0
  126. package/dist/esm/cloak/types.js +4 -0
  127. package/dist/esm/cloak.d.ts +1 -0
  128. package/dist/esm/cloak.js +2 -0
  129. package/dist/esm/compactNote.d.ts +21 -0
  130. package/dist/esm/compactNote.js +24 -1
  131. package/dist/esm/index.d.ts +2 -1
  132. package/dist/esm/index.js +3 -1
  133. package/dist/esm/notes/encryption.d.ts +41 -0
  134. package/dist/esm/notes/encryption.js +67 -0
  135. package/dist/esm/notes/index.d.ts +5 -0
  136. package/dist/esm/notes/index.js +5 -0
  137. package/dist/esm/notes/mailbox.d.ts +70 -0
  138. package/dist/esm/notes/mailbox.js +154 -0
  139. package/dist/esm/notes/model.d.ts +91 -0
  140. package/dist/esm/notes/model.js +99 -0
  141. package/dist/esm/notes/nullifier.d.ts +27 -0
  142. package/dist/esm/notes/nullifier.js +40 -0
  143. package/dist/esm/notes/recovery.d.ts +10 -0
  144. package/dist/esm/notes/recovery.js +28 -0
  145. package/dist/esm/proof.d.ts +1 -183
  146. package/dist/esm/proof.js +2 -281
  147. package/dist/esm/proofs/encoding.d.ts +17 -0
  148. package/dist/esm/proofs/encoding.js +68 -0
  149. package/dist/esm/proofs/formatting.d.ts +6 -0
  150. package/dist/esm/proofs/formatting.js +31 -0
  151. package/dist/esm/proofs/index.d.ts +5 -0
  152. package/dist/esm/proofs/index.js +5 -0
  153. package/dist/esm/proofs/swap.d.ts +87 -0
  154. package/dist/esm/proofs/swap.js +138 -0
  155. package/dist/esm/proofs/transaction.d.ts +28 -0
  156. package/dist/esm/proofs/transaction.js +105 -0
  157. package/dist/esm/proofs/types.d.ts +70 -0
  158. package/dist/esm/proofs/types.js +1 -0
  159. package/dist/esm/prover.d.ts +4 -1
  160. package/dist/esm/prover.js +10 -1
  161. package/dist/esm/relayer/client.d.ts +61 -0
  162. package/dist/esm/relayer/client.js +144 -0
  163. package/dist/esm/relayer/crypto.d.ts +5 -0
  164. package/dist/esm/relayer/crypto.js +20 -0
  165. package/dist/esm/relayer/encoding.d.ts +2 -0
  166. package/dist/esm/relayer/encoding.js +19 -0
  167. package/dist/esm/relayer/errors.d.ts +7 -0
  168. package/dist/esm/relayer/errors.js +13 -0
  169. package/dist/esm/relayer/index.d.ts +3 -0
  170. package/dist/esm/relayer/index.js +3 -0
  171. package/dist/esm/relayer/transport.d.ts +17 -0
  172. package/dist/esm/relayer/transport.js +59 -0
  173. package/dist/esm/relayer/types.d.ts +276 -0
  174. package/dist/esm/relayer/types.js +4 -0
  175. package/dist/esm/relayer.d.ts +1 -318
  176. package/dist/esm/relayer.js +2 -249
  177. package/dist/esm/shield/alt.js +1 -1
  178. package/dist/esm/shield/errors.js +1 -1
  179. package/dist/esm/shield/finalize.js +1 -1
  180. package/dist/esm/shield/ix.d.ts +1 -1
  181. package/dist/esm/shield/owner.js +2 -1
  182. package/dist/esm/shield/ports.js +1 -1
  183. package/dist/esm/shield/preflight.js +1 -1
  184. package/dist/esm/shield/shield.js +4 -3
  185. package/dist/esm/shield/types.d.ts +1 -1
  186. package/dist/esm/transactions/deposit.d.ts +94 -0
  187. package/dist/esm/transactions/deposit.js +198 -0
  188. package/dist/esm/transactions/index.d.ts +7 -0
  189. package/dist/esm/transactions/index.js +7 -0
  190. package/dist/esm/transactions/swap.d.ts +71 -0
  191. package/dist/esm/transactions/swap.js +144 -0
  192. package/dist/esm/transactions/transact.d.ts +34 -0
  193. package/dist/esm/transactions/transact.js +110 -0
  194. package/dist/esm/transactions/transfer.d.ts +51 -0
  195. package/dist/esm/transactions/transfer.js +103 -0
  196. package/dist/esm/transactions/withdraw.d.ts +52 -0
  197. package/dist/esm/transactions/withdraw.js +101 -0
  198. package/dist/esm/utxo.d.ts +1 -235
  199. package/dist/esm/utxo.js +2 -382
  200. package/package.json +54 -16
  201. package/SHIELD_INTEGRATION.md +0 -143
  202. package/config.d.ts +0 -2
  203. package/config.js +0 -4
  204. package/dist/src/client.d.ts +0 -407
  205. package/dist/src/client.js +0 -951
  206. package/dist/src/compactNote.d.ts +0 -107
  207. package/dist/src/compactNote.js +0 -167
  208. package/dist/src/config.d.ts +0 -82
  209. package/dist/src/config.js +0 -57
  210. package/dist/src/events.d.ts +0 -77
  211. package/dist/src/events.js +0 -167
  212. package/dist/src/idl/privacy_pool.d.ts +0 -5
  213. package/dist/src/idl/privacy_pool.js +0 -15218
  214. package/dist/src/index.d.ts +0 -16
  215. package/dist/src/index.js +0 -67
  216. package/dist/src/merkle.d.ts +0 -77
  217. package/dist/src/merkle.js +0 -156
  218. package/dist/src/poseidon.d.ts +0 -29
  219. package/dist/src/poseidon.js +0 -100
  220. package/dist/src/program.d.ts +0 -37
  221. package/dist/src/program.js +0 -61
  222. package/dist/src/proof.d.ts +0 -183
  223. package/dist/src/proof.js +0 -292
  224. package/dist/src/prover.d.ts +0 -54
  225. package/dist/src/prover.js +0 -112
  226. package/dist/src/random.d.ts +0 -16
  227. package/dist/src/random.js +0 -28
  228. package/dist/src/relayer.js +0 -257
  229. package/dist/src/retry.d.ts +0 -32
  230. package/dist/src/retry.js +0 -75
  231. package/dist/src/shield/alt.d.ts +0 -87
  232. package/dist/src/shield/alt.js +0 -194
  233. package/dist/src/shield/computeBudget.d.ts +0 -61
  234. package/dist/src/shield/computeBudget.js +0 -64
  235. package/dist/src/shield/errors.d.ts +0 -58
  236. package/dist/src/shield/errors.js +0 -121
  237. package/dist/src/shield/finalize.d.ts +0 -45
  238. package/dist/src/shield/finalize.js +0 -119
  239. package/dist/src/shield/index.d.ts +0 -35
  240. package/dist/src/shield/index.js +0 -68
  241. package/dist/src/shield/ix.d.ts +0 -54
  242. package/dist/src/shield/ix.js +0 -119
  243. package/dist/src/shield/owner.d.ts +0 -36
  244. package/dist/src/shield/owner.js +0 -126
  245. package/dist/src/shield/ports.d.ts +0 -43
  246. package/dist/src/shield/ports.js +0 -153
  247. package/dist/src/shield/preflight.d.ts +0 -30
  248. package/dist/src/shield/preflight.js +0 -154
  249. package/dist/src/shield/shield.d.ts +0 -68
  250. package/dist/src/shield/shield.js +0 -499
  251. package/dist/src/shield/types.d.ts +0 -202
  252. package/dist/src/utxo.d.ts +0 -235
  253. package/dist/src/utxo.js +0 -407
  254. package/dist/tests/compact-note.test.d.ts +0 -1
  255. package/dist/tests/compact-note.test.js +0 -173
  256. package/dist/tests/config.test.d.ts +0 -1
  257. package/dist/tests/config.test.js +0 -102
  258. package/dist/tests/edge-cases.test.d.ts +0 -1
  259. package/dist/tests/edge-cases.test.js +0 -220
  260. package/dist/tests/encryption.test.d.ts +0 -1
  261. package/dist/tests/encryption.test.js +0 -215
  262. package/dist/tests/events.test.d.ts +0 -1
  263. package/dist/tests/events.test.js +0 -78
  264. package/dist/tests/multi-tree.test.d.ts +0 -1
  265. package/dist/tests/multi-tree.test.js +0 -405
  266. package/dist/tests/pda.test.d.ts +0 -1
  267. package/dist/tests/pda.test.js +0 -229
  268. package/dist/tests/poseidon-builder-parity.test.d.ts +0 -1
  269. package/dist/tests/poseidon-builder-parity.test.js +0 -72
  270. package/dist/tests/poseidon.test.d.ts +0 -1
  271. package/dist/tests/poseidon.test.js +0 -142
  272. package/dist/tests/proof.test.d.ts +0 -1
  273. package/dist/tests/proof.test.js +0 -296
  274. package/dist/tests/relayer.test.d.ts +0 -1
  275. package/dist/tests/relayer.test.js +0 -271
  276. package/dist/tests/sdk.integration.test.d.ts +0 -1
  277. package/dist/tests/sdk.integration.test.js +0 -330
  278. package/dist/tests/shield-owner.test.d.ts +0 -1
  279. package/dist/tests/shield-owner.test.js +0 -89
  280. package/dist/tests/shield-preflight.test.d.ts +0 -1
  281. package/dist/tests/shield-preflight.test.js +0 -87
  282. package/dist/tests/shield-realproof.test.d.ts +0 -1
  283. package/dist/tests/shield-realproof.test.js +0 -272
  284. package/dist/tests/shield.test.d.ts +0 -1
  285. package/dist/tests/shield.test.js +0 -403
  286. package/dist/tests/utxo.test.d.ts +0 -1
  287. package/dist/tests/utxo.test.js +0 -140
  288. package/poseidon.d.ts +0 -2
  289. package/poseidon.js +0 -4
  290. package/proof.d.ts +0 -2
  291. package/proof.js +0 -4
  292. package/prover.d.ts +0 -2
  293. package/prover.js +0 -4
  294. package/shield.d.ts +0 -2
  295. package/shield.js +0 -4
  296. /package/dist/{src/shield → cjs/proofs}/types.js +0 -0
@@ -1,257 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VeiloRelayerClient = exports.VeiloApiError = void 0;
7
- const tweetnacl_1 = __importDefault(require("tweetnacl"));
8
- const DEFAULT_RELAYER_URL = "https://relayer-server.onrender.com";
9
- // =============================================================================
10
- // Structured Error
11
- // =============================================================================
12
- /** Structured error thrown by VeiloRelayerClient on API failures. */
13
- class VeiloApiError extends Error {
14
- constructor(code, message, status, details) {
15
- super(message);
16
- this.name = "VeiloApiError";
17
- this.code = code;
18
- this.status = status;
19
- this.details = details;
20
- }
21
- }
22
- exports.VeiloApiError = VeiloApiError;
23
- const DEFAULT_RETRY = {
24
- maxRetries: 3,
25
- baseDelayMs: 1000,
26
- retryableStatuses: [429, 502, 503, 504],
27
- };
28
- // =============================================================================
29
- // Base64 helpers (no dependency on tweetnacl-util)
30
- // =============================================================================
31
- function toBase64(bytes) {
32
- if (typeof Buffer !== "undefined") {
33
- return Buffer.from(bytes).toString("base64");
34
- }
35
- return btoa(String.fromCharCode(...bytes));
36
- }
37
- function fromBase64(str) {
38
- if (typeof Buffer !== "undefined") {
39
- return new Uint8Array(Buffer.from(str, "base64"));
40
- }
41
- const binary = atob(str);
42
- const bytes = new Uint8Array(binary.length);
43
- for (let i = 0; i < binary.length; i++)
44
- bytes[i] = binary.charCodeAt(i);
45
- return bytes;
46
- }
47
- // =============================================================================
48
- // Encryption
49
- // =============================================================================
50
- /**
51
- * Encrypt a JSON-serializable payload for the relayer using NaCl box.
52
- * Layout: [ephemeralPubKey (32)] [nonce (24)] [ciphertext (...)]
53
- */
54
- function encryptForRelayer(data, relayerPublicKey) {
55
- const ephemeral = tweetnacl_1.default.box.keyPair();
56
- const message = new TextEncoder().encode(JSON.stringify(data));
57
- const nonce = tweetnacl_1.default.randomBytes(tweetnacl_1.default.box.nonceLength);
58
- const ciphertext = tweetnacl_1.default.box(message, nonce, relayerPublicKey, ephemeral.secretKey);
59
- const payload = new Uint8Array(ephemeral.publicKey.length + nonce.length + ciphertext.length);
60
- payload.set(ephemeral.publicKey, 0);
61
- payload.set(nonce, ephemeral.publicKey.length);
62
- payload.set(ciphertext, ephemeral.publicKey.length + nonce.length);
63
- return toBase64(payload);
64
- }
65
- // =============================================================================
66
- // Relayer Client
67
- // =============================================================================
68
- /**
69
- * HTTP client for the Veilo relayer API.
70
- *
71
- * Handles auth, notes, merkle, and encrypted transact endpoints with
72
- * automatic retry on transient failures and NaCl box payload encryption.
73
- *
74
- * @example
75
- * ```ts
76
- * const client = new VeiloRelayerClient({
77
- * apiKey: "your-api-key",
78
- * relayerPublicKey: "<base64 NaCl public key>",
79
- * });
80
- * const root = await client.getMerkleRoot("So111...");
81
- * ```
82
- */
83
- class VeiloRelayerClient {
84
- constructor(config, retry) {
85
- this.baseUrl = (config.relayerUrl?.trim() || DEFAULT_RELAYER_URL).replace(/\/+$/, "");
86
- this.apiKey = config.apiKey;
87
- this.relayerPubKey = fromBase64(config.relayerPublicKey);
88
- this.authToken = config.authToken;
89
- this.retry = { ...DEFAULT_RETRY, ...retry };
90
- }
91
- /** Update the auth token (e.g. after register/restore). */
92
- setAuthToken(token) {
93
- this.authToken = token;
94
- }
95
- // ---------------------------------------------------------------------------
96
- // Internal helpers
97
- // ---------------------------------------------------------------------------
98
- headers(authenticated) {
99
- const h = {
100
- "Content-Type": "application/json",
101
- };
102
- if (this.apiKey)
103
- h["x-api-key"] = this.apiKey;
104
- if (authenticated && this.authToken) {
105
- h["Authorization"] = `Bearer ${this.authToken}`;
106
- }
107
- return h;
108
- }
109
- async request(method, path, opts = {}) {
110
- const url = `${this.baseUrl}/api${path}`;
111
- const { body, authenticated = false, retryable = true } = opts;
112
- const maxAttempts = retryable ? this.retry.maxRetries + 1 : 1;
113
- let lastError;
114
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
115
- if (attempt > 0) {
116
- const delay = this.retry.baseDelayMs * Math.pow(2, attempt - 1) +
117
- Math.random() * 200;
118
- await new Promise((r) => setTimeout(r, delay));
119
- }
120
- let res;
121
- try {
122
- res = await fetch(url, {
123
- method,
124
- headers: this.headers(authenticated),
125
- body: body != null ? JSON.stringify(body) : undefined,
126
- });
127
- }
128
- catch (err) {
129
- lastError = new VeiloApiError("NETWORK_ERROR", err.message || "Network request failed", 0);
130
- continue;
131
- }
132
- const data = await res.json().catch(() => ({}));
133
- if (res.ok && data.success !== false) {
134
- return data;
135
- }
136
- lastError = new VeiloApiError(data.error || "UNKNOWN", data.message || data.error || `Request failed: ${res.status}`, res.status, data);
137
- // Only retry on transient statuses
138
- if (!this.retry.retryableStatuses.includes(res.status)) {
139
- throw lastError;
140
- }
141
- }
142
- throw lastError;
143
- }
144
- encrypt(data) {
145
- return encryptForRelayer({
146
- ...data,
147
- timestamp: Date.now(),
148
- nonce: toBase64(tweetnacl_1.default.randomBytes(32)),
149
- }, this.relayerPubKey);
150
- }
151
- // ---------------------------------------------------------------------------
152
- // Auth
153
- // ---------------------------------------------------------------------------
154
- /** Request a signature challenge for wallet authentication. */
155
- async getChallenge(walletPublicKey) {
156
- return this.request("POST", "/auth/challenge", {
157
- body: { walletPublicKey },
158
- });
159
- }
160
- /** Register a new account with a signed challenge. Returns a JWT auth token. */
161
- async register(data) {
162
- return this.request("POST", "/auth/register", { body: data });
163
- }
164
- /** Restore an existing account using a signed challenge. Returns a JWT auth token. */
165
- async restore(data) {
166
- return this.request("POST", "/auth/restore", { body: data });
167
- }
168
- /** Check whether a username is available for registration. */
169
- async checkUsername(username) {
170
- return this.request("GET", `/auth/checkUsername?username=${encodeURIComponent(username)}`);
171
- }
172
- /** Look up a user's Veilo public key by username or wallet public key. */
173
- async getVeiloPublicKey(params) {
174
- const query = "username" in params && params.username
175
- ? `username=${encodeURIComponent(params.username)}`
176
- : `publicKey=${encodeURIComponent(params.publicKey)}`;
177
- return this.request("GET", `/auth/veiloPublicKey?${query}`);
178
- }
179
- /**
180
- * Provision (or retrieve) the Veilo spend key paired with a Solana address.
181
- * Public and idempotent; the response contains public key material only.
182
- */
183
- async preRegisterKey(solanaAddress) {
184
- return this.request("POST", "/auth/pre-register-key", {
185
- body: { solanaAddress },
186
- });
187
- }
188
- // ---------------------------------------------------------------------------
189
- // Notes
190
- // ---------------------------------------------------------------------------
191
- /** Save an encrypted note to the relayer's database. */
192
- async saveEncryptedNote(data) {
193
- return this.request("POST", "/notes/save", { body: data });
194
- }
195
- /** Query encrypted notes for the authenticated user. Requires auth token. */
196
- async queryEncryptedNotes(params = {}) {
197
- return this.request("POST", "/notes/query", {
198
- body: params,
199
- authenticated: true,
200
- });
201
- }
202
- /** Delete all stored data for the authenticated user. Requires auth token. */
203
- async deleteUserData() {
204
- return this.request("POST", "/notes/delete", { authenticated: true });
205
- }
206
- // ---------------------------------------------------------------------------
207
- // Merkle
208
- // ---------------------------------------------------------------------------
209
- /** Fetch the current Merkle root for a pool, optionally filtered by mint and tree ID. */
210
- async getMerkleRoot(mintAddress, treeId) {
211
- const params = new URLSearchParams();
212
- if (mintAddress)
213
- params.append("mintAddress", mintAddress);
214
- if (treeId !== undefined)
215
- params.append("treeId", treeId.toString());
216
- const qs = params.toString();
217
- return this.request("GET", `/merkle/root${qs ? `?${qs}` : ""}`);
218
- }
219
- /** Fetch the full Merkle tree (all leaves) for a pool. */
220
- async getMerkleTree(mintAddress, treeId) {
221
- const params = new URLSearchParams();
222
- if (mintAddress)
223
- params.append("mintAddress", mintAddress);
224
- if (treeId !== undefined)
225
- params.append("treeId", treeId.toString());
226
- const qs = params.toString();
227
- return this.request("GET", `/merkle/tree${qs ? `?${qs}` : ""}`);
228
- }
229
- // ---------------------------------------------------------------------------
230
- // Transact (encrypted payloads)
231
- // ---------------------------------------------------------------------------
232
- /** Submit an encrypted withdrawal request to the relayer. Not retried on failure. */
233
- async submitWithdraw(data) {
234
- const encryptedPayload = this.encrypt(data);
235
- return this.request("POST", "/transact/withdra", {
236
- body: { encryptedPayload },
237
- retryable: false,
238
- });
239
- }
240
- /** Submit an encrypted private transfer request. Not retried on failure. */
241
- async submitPrivateTransfer(data) {
242
- const encryptedPayload = this.encrypt(data);
243
- return this.request("POST", "/transact/private-transfer", {
244
- body: { encryptedPayload },
245
- retryable: false,
246
- });
247
- }
248
- /** Submit an encrypted private swap request. Not retried on failure. */
249
- async submitPrivateSwap(data) {
250
- const encryptedPayload = this.encrypt(data);
251
- return this.request("POST", "/transact/private-swap", {
252
- body: { encryptedPayload },
253
- retryable: false,
254
- });
255
- }
256
- }
257
- exports.VeiloRelayerClient = VeiloRelayerClient;
17
+ // Backward-compatible entry point. Relayer responsibilities live in src/relayer.
18
+ __exportStar(require("./relayer/index.js"), exports);
@@ -8,7 +8,7 @@ exports.expectedDepositAltKeys = expectedDepositAltKeys;
8
8
  exports.auditDepositAlt = auditDepositAlt;
9
9
  const web3_js_1 = require("@solana/web3.js");
10
10
  const spl_token_1 = require("@solana/spl-token");
11
- const client_js_1 = require("../client.js");
11
+ const pdas_js_1 = require("../accounts/pdas.js");
12
12
  const program_js_1 = require("../program.js");
13
13
  const config_js_1 = require("../config.js");
14
14
  const errors_js_1 = require("./errors.js");
@@ -107,21 +107,21 @@ function explicitAlt(account) {
107
107
  */
108
108
  function requiredAltKeys(params) {
109
109
  const programId = params.programId ?? program_js_1.PRIVACY_POOL_PROGRAM_ID;
110
- const { config, vault, nullifiers } = (0, client_js_1.getPoolPdas)(programId, params.mint);
110
+ const { config, vault, nullifiers } = (0, pdas_js_1.getPoolPdas)(programId, params.mint);
111
111
  const keys = [
112
112
  { label: "programId", address: programId },
113
113
  { label: "computeBudgetProgram", address: web3_js_1.ComputeBudgetProgram.programId },
114
114
  { label: "systemProgram", address: web3_js_1.SystemProgram.programId },
115
- { label: "globalConfig", address: (0, client_js_1.getGlobalConfigPda)(programId) },
115
+ { label: "globalConfig", address: (0, pdas_js_1.getGlobalConfigPda)(programId) },
116
116
  { label: "config", address: config },
117
117
  { label: "vault", address: vault },
118
118
  { label: "nullifiers", address: nullifiers },
119
- { label: "inputTree(0)", address: (0, client_js_1.getNoteTreePda)(programId, params.mint, 0) },
119
+ { label: "inputTree(0)", address: (0, pdas_js_1.getNoteTreePda)(programId, params.mint, 0) },
120
120
  ];
121
121
  if (params.outputTreeId !== 0) {
122
122
  keys.push({
123
123
  label: `outputTree(${params.outputTreeId})`,
124
- address: (0, client_js_1.getNoteTreePda)(programId, params.mint, params.outputTreeId),
124
+ address: (0, pdas_js_1.getNoteTreePda)(programId, params.mint, params.outputTreeId),
125
125
  });
126
126
  }
127
127
  if (!params.mint.equals(config_js_1.NATIVE_SOL_MINT)) {
@@ -155,16 +155,16 @@ async function expectedDepositAltKeys(params) {
155
155
  { label: "computeBudgetProgram", address: web3_js_1.ComputeBudgetProgram.programId },
156
156
  { label: "systemProgram", address: web3_js_1.SystemProgram.programId },
157
157
  { label: "tokenProgram", address: spl_token_1.TOKEN_PROGRAM_ID },
158
- { label: "globalConfig", address: (0, client_js_1.getGlobalConfigPda)(programId) },
158
+ { label: "globalConfig", address: (0, pdas_js_1.getGlobalConfigPda)(programId) },
159
159
  ];
160
160
  for (const mint of mints) {
161
161
  const label = mint.equals(config_js_1.NATIVE_SOL_MINT) ? "SOL" : mint.toBase58().slice(0, 4);
162
- const { config, vault, nullifiers } = (0, client_js_1.getPoolPdas)(programId, mint);
162
+ const { config, vault, nullifiers } = (0, pdas_js_1.getPoolPdas)(programId, mint);
163
163
  out.push({ label: `${label}.config`, address: config }, { label: `${label}.vault`, address: vault }, { label: `${label}.nullifiers`, address: nullifiers });
164
164
  for (let t = 0; t <= maxTreeId; t++) {
165
165
  out.push({
166
166
  label: `${label}.tree(${t})`,
167
- address: (0, client_js_1.getNoteTreePda)(programId, mint, t),
167
+ address: (0, pdas_js_1.getNoteTreePda)(programId, mint, t),
168
168
  });
169
169
  }
170
170
  if (!mint.equals(config_js_1.NATIVE_SOL_MINT)) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShieldError = void 0;
4
4
  exports.extractProgramCode = extractProgramCode;
5
5
  exports.mapShieldError = mapShieldError;
6
- const client_js_1 = require("../client.js");
6
+ const errors_js_1 = require("../accounts/errors.js");
7
7
  class ShieldError extends Error {
8
8
  constructor(code, message, opts = {}) {
9
9
  super(message);
@@ -52,7 +52,7 @@ function mapShieldError(error) {
52
52
  const err = error;
53
53
  const raw = (err?.message ?? String(err ?? "")).toLowerCase();
54
54
  const programCode = extractProgramCode(err);
55
- const readable = (0, client_js_1.parseOnChainError)(err);
55
+ const readable = (0, errors_js_1.parseOnChainError)(err);
56
56
  if (programCode !== null) {
57
57
  switch (programCode) {
58
58
  case 6000:
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.finalizeShield = finalizeShield;
37
37
  const anchor = __importStar(require("@coral-xyz/anchor"));
38
38
  const program_js_1 = require("../program.js");
39
- const utxo_js_1 = require("../utxo.js");
39
+ const mailbox_js_1 = require("../notes/mailbox.js");
40
40
  const poseidon_js_1 = require("../poseidon.js");
41
41
  const errors_js_1 = require("./errors.js");
42
42
  /**
@@ -101,7 +101,7 @@ async function finalizeShield(params) {
101
101
  // sender→recipient association into the relayer's database AND removing the
102
102
  // note from the chain-recovery feed. For shield-to-someone-else, chain-only
103
103
  // discovery is usually the better default — see the plan's Phase 3 note.
104
- const blob = (0, utxo_js_1.encryptBlindMailboxNote)(owner.noteViewingKey.toBytes(), {
104
+ const blob = (0, mailbox_js_1.encryptBlindMailboxNote)(owner.noteViewingKey.toBytes(), {
105
105
  blinding: (0, poseidon_js_1.bigIntToBytesBE)(note.blinding),
106
106
  leafIndex,
107
107
  commitment: note.commitment,
@@ -1,5 +1,5 @@
1
1
  import { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
- import type { TransactionProofStruct } from "../proof.js";
2
+ import type { TransactionProofStruct } from "../proofs/types.js";
3
3
  /**
4
4
  * `transact` instruction assembly, driven by the IDL rather than by a
5
5
  * hand-written account list.
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveShieldOwner = resolveShieldOwner;
4
4
  exports.unsafeShieldOwner = unsafeShieldOwner;
5
5
  const web3_js_1 = require("@solana/web3.js");
6
- const relayer_js_1 = require("../relayer.js");
7
- const errors_js_1 = require("./errors.js");
6
+ const client_js_1 = require("../relayer/client.js");
7
+ const errors_js_1 = require("../relayer/errors.js");
8
+ const errors_js_2 = require("./errors.js");
8
9
  /**
9
10
  * Owner resolution is a Veilo protocol service, not an integrator-selected
10
11
  * transport. Keep the production endpoint and public encryption key inside the
@@ -16,7 +17,7 @@ const errors_js_1 = require("./errors.js");
16
17
  * inspectable. The two owner endpoints used below are intentionally public and
17
18
  * return public key material only.
18
19
  */
19
- const OWNER_RELAYER = new relayer_js_1.VeiloRelayerClient({
20
+ const OWNER_RELAYER = new client_js_1.VeiloRelayerClient({
20
21
  apiKey: "",
21
22
  relayerPublicKey: "utVxnA7zax09qJCZ7UJsa8PAOoWLRcCwOkdxg/ZGmD4=",
22
23
  });
@@ -54,13 +55,13 @@ async function resolveShieldOwner(target) {
54
55
  // public and idempotent, and returns only the Poseidon spend key; the
55
56
  // address we were given is the matching note-viewing key.
56
57
  if ("publicKey" in target &&
57
- (e?.status === 404 || (e instanceof relayer_js_1.VeiloApiError && e.status === 404))) {
58
+ (e?.status === 404 || (e instanceof errors_js_1.VeiloApiError && e.status === 404))) {
58
59
  const wallet = typeof target.publicKey === "string"
59
60
  ? new web3_js_1.PublicKey(target.publicKey)
60
61
  : target.publicKey;
61
62
  const provisioned = await OWNER_RELAYER.preRegisterKey(wallet.toBase58());
62
63
  if (!provisioned?.veiloPublicKey) {
63
- throw new errors_js_1.ShieldError("UNKNOWN", "The relayer pre-registered the recipient but returned no Veilo public key.", { context: { publicKey: wallet.toBase58(), response: provisioned }, cause: e });
64
+ throw new errors_js_2.ShieldError("UNKNOWN", "The relayer pre-registered the recipient but returned no Veilo public key.", { context: { publicKey: wallet.toBase58(), response: provisioned }, cause: e });
64
65
  }
65
66
  return {
66
67
  veiloPublicKey: BigInt(provisioned.veiloPublicKey),
@@ -75,7 +76,7 @@ async function resolveShieldOwner(target) {
75
76
  if (e?.body?.preRegistered ||
76
77
  e?.details?.preRegistered ||
77
78
  /preregistered/i.test(String(e?.message ?? ""))) {
78
- throw new errors_js_1.ShieldError("UNKNOWN", `"${"username" in target ? target.username : "that account"}" is pre-registered ` +
79
+ throw new errors_js_2.ShieldError("UNKNOWN", `"${"username" in target ? target.username : "that account"}" is pre-registered ` +
79
80
  `and cannot be resolved by username. Resolve it by Solana address instead — ` +
80
81
  `resolveShieldOwner({ publicKey }).`, { context: { preRegistered: true }, cause: e });
81
82
  }
@@ -84,7 +85,7 @@ async function resolveShieldOwner(target) {
84
85
  const veiloPublicKeyRaw = response?.veiloPublicKey;
85
86
  const walletRaw = response?.pubK;
86
87
  if (!veiloPublicKeyRaw || !walletRaw) {
87
- throw new errors_js_1.ShieldError("UNKNOWN", `The relayer did not return both keys for this recipient ` +
88
+ throw new errors_js_2.ShieldError("UNKNOWN", `The relayer did not return both keys for this recipient ` +
88
89
  `(veiloPublicKey=${!!veiloPublicKeyRaw}, pubK=${!!walletRaw}). ` +
89
90
  `Shielding without both would create a note the owner cannot find.`, { context: { response } });
90
91
  }
@@ -93,7 +94,7 @@ async function resolveShieldOwner(target) {
93
94
  !noteViewingKey.equals(typeof target.publicKey === "string"
94
95
  ? new web3_js_1.PublicKey(target.publicKey)
95
96
  : target.publicKey)) {
96
- throw new errors_js_1.ShieldError("UNKNOWN", "The Veilo owner service returned a different wallet than the one requested. " +
97
+ throw new errors_js_2.ShieldError("UNKNOWN", "The Veilo owner service returned a different wallet than the one requested. " +
97
98
  "Shielding was stopped to prevent creating a note for the wrong recipient.", {
98
99
  context: {
99
100
  requested: typeof target.publicKey === "string"
@@ -5,7 +5,7 @@ exports.staticTreeSource = staticTreeSource;
5
5
  exports.memoryCache = memoryCache;
6
6
  exports.noCache = noCache;
7
7
  const program_js_1 = require("../program.js");
8
- const client_js_1 = require("../client.js");
8
+ const pdas_js_1 = require("../accounts/pdas.js");
9
9
  const config_js_1 = require("../config.js");
10
10
  const errors_js_1 = require("./errors.js");
11
11
  /**
@@ -36,7 +36,7 @@ function onChainTreeSource(connection, programId = program_js_1.PRIVACY_POOL_PRO
36
36
  return {
37
37
  async getDepositTarget(mint) {
38
38
  const program = (0, program_js_1.createReadonlyVeiloProgram)(connection);
39
- const { config } = (0, client_js_1.getPoolPdas)(programId, mint);
39
+ const { config } = (0, pdas_js_1.getPoolPdas)(programId, mint);
40
40
  const cfg = await program.account.privacyConfig.fetch(config);
41
41
  const numTrees = Number(cfg.numTrees);
42
42
  if (!Number.isInteger(numTrees) || numTrees <= 0) {
@@ -44,7 +44,7 @@ function onChainTreeSource(connection, programId = program_js_1.PRIVACY_POOL_PRO
44
44
  }
45
45
  // Fetch every tree in one RPC call. The older getBestTreeForDeposit path
46
46
  // fetched them serially, then fetched the chosen trees a second time.
47
- const treePdas = Array.from({ length: numTrees }, (_, treeId) => (0, client_js_1.getNoteTreePda)(programId, mint, treeId));
47
+ const treePdas = Array.from({ length: numTrees }, (_, treeId) => (0, pdas_js_1.getNoteTreePda)(programId, mint, treeId));
48
48
  const infos = await connection.getMultipleAccountsInfo(treePdas, {
49
49
  commitment: "confirmed",
50
50
  });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preflightShield = preflightShield;
4
4
  const spl_token_1 = require("@solana/spl-token");
5
- const client_js_1 = require("../client.js");
5
+ const pdas_js_1 = require("../accounts/pdas.js");
6
6
  const program_js_1 = require("../program.js");
7
7
  const config_js_1 = require("../config.js");
8
8
  const errors_js_1 = require("./errors.js");
@@ -27,7 +27,7 @@ async function preflightShield(params) {
27
27
  // --- Pool state ------------------------------------------------------------
28
28
  if (!options.skipPoolState) {
29
29
  const program = (0, program_js_1.createReadonlyVeiloProgram)(connection);
30
- const { config } = (0, client_js_1.getPoolPdas)(programId, mint);
30
+ const { config } = (0, pdas_js_1.getPoolPdas)(programId, mint);
31
31
  let cfg;
32
32
  try {
33
33
  cfg = await program.account.privacyConfig.fetch(config);
@@ -103,7 +103,7 @@ async function preflightShield(params) {
103
103
  }
104
104
  // The vault's ATA must already exist — the program requires the canonical
105
105
  // one and will not create it.
106
- const { vault } = (0, client_js_1.getPoolPdas)(programId, mint);
106
+ const { vault } = (0, pdas_js_1.getPoolPdas)(programId, mint);
107
107
  const vaultAta = await (0, spl_token_1.getAssociatedTokenAddress)(mint, vault, true);
108
108
  const vaultInfo = await connection.getAccountInfo(vaultAta);
109
109
  if (!vaultInfo) {
@@ -8,14 +8,15 @@ exports.deserializeProofCache = deserializeProofCache;
8
8
  const web3_js_1 = require("@solana/web3.js");
9
9
  const spl_token_1 = require("@solana/spl-token");
10
10
  const program_js_1 = require("../program.js");
11
- const client_js_1 = require("../client.js");
11
+ const pdas_js_1 = require("../accounts/pdas.js");
12
12
  const config_js_1 = require("../config.js");
13
13
  const poseidon_js_1 = require("../poseidon.js");
14
14
  Object.defineProperty(exports, "bytesToBigIntBE", { enumerable: true, get: function () { return poseidon_js_1.bytesToBigIntBE; } });
15
15
  Object.defineProperty(exports, "BN254_FR_MODULUS", { enumerable: true, get: function () { return poseidon_js_1.BN254_FR_MODULUS; } });
16
16
  const merkle_js_1 = require("../merkle.js");
17
- const utxo_js_1 = require("../utxo.js");
18
- const proof_js_1 = require("../proof.js");
17
+ const model_js_1 = require("../notes/model.js");
18
+ const transaction_js_1 = require("../proofs/transaction.js");
19
+ const encoding_js_1 = require("../proofs/encoding.js");
19
20
  const compactNote_js_1 = require("../compactNote.js");
20
21
  const ix_js_1 = require("./ix.js");
21
22
  const alt_js_1 = require("./alt.js");
@@ -114,14 +115,14 @@ async function shield(params) {
114
115
  // --- 3. Outputs ------------------------------------------------------------
115
116
  // Output 0 carries the value and is owned by the recipient. Output 1 is a
116
117
  // zero-value dummy the 2-in-2-out circuit requires.
117
- const outputNote = (0, utxo_js_1.createUTXO)({
118
+ const outputNote = (0, model_js_1.createUTXO)({
118
119
  amount,
119
120
  pubkey: owner.veiloPublicKey,
120
121
  mintAddress: mint,
121
122
  });
122
- const dummyOutput = (0, utxo_js_1.createUTXO)({
123
+ const dummyOutput = (0, model_js_1.createUTXO)({
123
124
  amount: 0n,
124
- pubkey: (0, utxo_js_1.generateKeypair)().publicKey,
125
+ pubkey: (0, model_js_1.generateKeypair)().publicKey,
125
126
  mintAddress: mint,
126
127
  });
127
128
  // --- 4. Dummy inputs -------------------------------------------------------
@@ -130,8 +131,8 @@ async function shield(params) {
130
131
  // blinding randomness; two keys make it structural.
131
132
  const zeroChain = (0, merkle_js_1.poseidonZeroChain)(22).slice(0, 22);
132
133
  const dummyInputs = [
133
- toDummyInput((0, utxo_js_1.createOwnedZeroUTXO)((0, utxo_js_1.generateKeypair)().privateKey, mint), zeroChain),
134
- toDummyInput((0, utxo_js_1.createOwnedZeroUTXO)((0, utxo_js_1.generateKeypair)().privateKey, mint), zeroChain),
134
+ toDummyInput((0, model_js_1.createOwnedZeroUTXO)((0, model_js_1.generateKeypair)().privateKey, mint), zeroChain),
135
+ toDummyInput((0, model_js_1.createOwnedZeroUTXO)((0, model_js_1.generateKeypair)().privateKey, mint), zeroChain),
135
136
  ];
136
137
  // --- 5. ExtData ------------------------------------------------------------
137
138
  // For a deposit these slots carry no payment semantics — no fee is taken and
@@ -144,9 +145,9 @@ async function shield(params) {
144
145
  refund: 0n,
145
146
  claimant: web3_js_1.SystemProgram.programId,
146
147
  };
147
- const extDataHash = (0, proof_js_1.computeExtDataHash)(extData);
148
+ const extDataHash = (0, transaction_js_1.computeExtDataHash)(extData);
148
149
  // --- 6. Prove --------------------------------------------------------------
149
- const circuitInputs = (0, proof_js_1.prepareTransactionInputs)({
150
+ const circuitInputs = (0, transaction_js_1.prepareTransactionInputs)({
150
151
  inputUTXOs: dummyInputs,
151
152
  outputUTXOs: [outputNote, dummyOutput],
152
153
  root: target.inputRoot,
@@ -156,7 +157,7 @@ async function shield(params) {
156
157
  });
157
158
  let proof;
158
159
  try {
159
- proof = (0, proof_js_1.encodeSnarkjsProofToTransactionProof)(await prover(circuitInputs));
160
+ proof = (0, encoding_js_1.encodeSnarkjsProofToTransactionProof)(await prover(circuitInputs));
160
161
  }
161
162
  catch (e) {
162
163
  throw (0, errors_js_1.mapShieldError)(e);
@@ -176,8 +177,8 @@ async function shield(params) {
176
177
  outputTreeId: target.outputTreeId,
177
178
  inputNullifiers: circuitInputs.inputNullifiers,
178
179
  vaultTokenAccount: isToken
179
- ? await (0, spl_token_1.getAssociatedTokenAddress)(mint, (0, client_js_1.getPoolPdas)(programId, mint).vault, true)
180
- : (0, client_js_1.getPoolPdas)(programId, mint).vault,
180
+ ? await (0, spl_token_1.getAssociatedTokenAddress)(mint, (0, pdas_js_1.getPoolPdas)(programId, mint).vault, true)
181
+ : (0, pdas_js_1.getPoolPdas)(programId, mint).vault,
181
182
  isToken,
182
183
  });
183
184
  // --- 9. Cache everything needed to rebuild ---------------------------------
@@ -452,16 +453,16 @@ function toDummyInput(utxo, zeroChain) {
452
453
  }
453
454
  function resolveTransactAccounts(params) {
454
455
  const { programId, mint, signer } = params;
455
- const { config, vault, nullifiers } = (0, client_js_1.getPoolPdas)(programId, mint);
456
+ const { config, vault, nullifiers } = (0, pdas_js_1.getPoolPdas)(programId, mint);
456
457
  return {
457
458
  config,
458
- global_config: (0, client_js_1.getGlobalConfigPda)(programId),
459
+ global_config: (0, pdas_js_1.getGlobalConfigPda)(programId),
459
460
  vault,
460
- input_tree: (0, client_js_1.getNoteTreePda)(programId, mint, params.inputTreeId),
461
- output_tree: (0, client_js_1.getNoteTreePda)(programId, mint, params.outputTreeId),
461
+ input_tree: (0, pdas_js_1.getNoteTreePda)(programId, mint, params.inputTreeId),
462
+ output_tree: (0, pdas_js_1.getNoteTreePda)(programId, mint, params.outputTreeId),
462
463
  nullifiers,
463
- nullifier_marker_0: (0, client_js_1.getNullifierMarkerPda)(programId, mint, params.inputNullifiers[0]),
464
- nullifier_marker_1: (0, client_js_1.getNullifierMarkerPda)(programId, mint, params.inputNullifiers[1]),
464
+ nullifier_marker_0: (0, pdas_js_1.getNullifierMarkerPda)(programId, mint, params.inputNullifiers[0]),
465
+ nullifier_marker_1: (0, pdas_js_1.getNullifierMarkerPda)(programId, mint, params.inputNullifiers[1]),
465
466
  relayer: signer,
466
467
  // For a deposit nothing is withdrawn, so `recipient` is just the signer.
467
468
  // Pointing the unused token slots at accounts already in the transaction
@@ -1,5 +1,5 @@
1
1
  import { AddressLookupTableAccount, Connection, PublicKey, VersionedTransaction } from "@solana/web3.js";
2
- import type { TransactionProofBuilder, TransactionProofStruct } from "../proof.js";
2
+ import type { TransactionProofBuilder, TransactionProofStruct } from "../proofs/types.js";
3
3
  import type { CompactNoteCipher } from "../compactNote.js";
4
4
  /**
5
5
  * Who owns the resulting note. Both halves are required and neither is derived