@veilo/sdk-core 0.4.0 → 0.6.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 (481) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +449 -1243
  3. package/accounts.d.ts +2 -0
  4. package/accounts.js +3 -0
  5. package/cloak.d.ts +2 -0
  6. package/cloak.js +3 -0
  7. package/config.d.ts +2 -2
  8. package/config.js +2 -3
  9. package/dist/cjs/accounts/admin.d.ts +84 -0
  10. package/dist/cjs/accounts/admin.js +208 -0
  11. package/dist/cjs/accounts/errors.d.ts +6 -0
  12. package/dist/cjs/accounts/errors.js +98 -0
  13. package/dist/cjs/accounts/index.d.ts +4 -0
  14. package/dist/cjs/accounts/index.js +20 -0
  15. package/dist/cjs/accounts/pdas.d.ts +23 -0
  16. package/dist/cjs/accounts/pdas.js +44 -0
  17. package/dist/cjs/accounts/queries.d.ts +41 -0
  18. package/dist/cjs/accounts/queries.js +95 -0
  19. package/dist/cjs/client.d.ts +2 -407
  20. package/dist/cjs/client.js +6 -938
  21. package/dist/cjs/cloak/client.d.ts +28 -0
  22. package/dist/cjs/cloak/client.js +68 -0
  23. package/dist/cjs/cloak/errors.d.ts +13 -0
  24. package/dist/cjs/cloak/errors.js +25 -0
  25. package/dist/cjs/cloak/helpers.d.ts +6 -0
  26. package/dist/cjs/cloak/helpers.js +35 -0
  27. package/dist/cjs/cloak/index.d.ts +6 -0
  28. package/dist/cjs/cloak/index.js +24 -0
  29. package/dist/cjs/cloak/polling.d.ts +7 -0
  30. package/dist/cjs/cloak/polling.js +66 -0
  31. package/dist/cjs/cloak/transport.d.ts +15 -0
  32. package/dist/cjs/cloak/transport.js +119 -0
  33. package/dist/cjs/cloak/types.d.ts +188 -0
  34. package/dist/cjs/cloak/types.js +5 -0
  35. package/dist/cjs/cloak.d.ts +1 -0
  36. package/dist/cjs/cloak.js +18 -0
  37. package/dist/cjs/compactNote.d.ts +21 -0
  38. package/dist/cjs/compactNote.js +31 -7
  39. package/dist/cjs/events/index.d.ts +6 -0
  40. package/dist/cjs/events/index.js +22 -0
  41. package/dist/cjs/events/parsing.d.ts +25 -0
  42. package/dist/cjs/events/parsing.js +158 -0
  43. package/dist/cjs/events/position.d.ts +26 -0
  44. package/dist/cjs/events/position.js +53 -0
  45. package/dist/cjs/events/recovery.d.ts +87 -0
  46. package/dist/cjs/events/recovery.js +281 -0
  47. package/dist/cjs/events/scanning.d.ts +35 -0
  48. package/dist/cjs/events/scanning.js +98 -0
  49. package/dist/cjs/events/tree.d.ts +27 -0
  50. package/dist/cjs/events/tree.js +63 -0
  51. package/dist/cjs/events/types.d.ts +39 -0
  52. package/dist/cjs/events.d.ts +1 -77
  53. package/dist/cjs/events.js +6 -154
  54. package/dist/cjs/identity/encoding.d.ts +9 -0
  55. package/dist/cjs/identity/encoding.js +85 -0
  56. package/dist/cjs/identity/index.d.ts +4 -0
  57. package/dist/cjs/identity/index.js +20 -0
  58. package/dist/cjs/identity/noteKey.d.ts +33 -0
  59. package/dist/cjs/identity/noteKey.js +97 -0
  60. package/dist/cjs/identity/spending.d.ts +18 -0
  61. package/dist/cjs/identity/spending.js +46 -0
  62. package/dist/cjs/identity/viewKey.d.ts +38 -0
  63. package/dist/cjs/identity/viewKey.js +105 -0
  64. package/dist/cjs/idl/index.d.ts +18 -0
  65. package/dist/cjs/idl/index.js +24 -0
  66. package/dist/cjs/idl/privacy_pool.json +9907 -9907
  67. package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
  68. package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
  69. package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
  70. package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
  71. package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
  72. package/dist/cjs/index.d.ts +9 -3
  73. package/dist/cjs/index.js +15 -2
  74. package/dist/cjs/notes/amount.d.ts +2 -0
  75. package/dist/cjs/notes/amount.js +21 -0
  76. package/dist/cjs/notes/encryption.d.ts +41 -0
  77. package/dist/cjs/notes/encryption.js +75 -0
  78. package/dist/cjs/notes/index.d.ts +8 -0
  79. package/dist/cjs/notes/index.js +24 -0
  80. package/dist/cjs/notes/mailbox.d.ts +70 -0
  81. package/dist/cjs/notes/mailbox.js +164 -0
  82. package/dist/cjs/notes/model.d.ts +91 -0
  83. package/dist/cjs/notes/model.js +109 -0
  84. package/dist/cjs/notes/nullifier.d.ts +27 -0
  85. package/dist/cjs/notes/nullifier.js +45 -0
  86. package/dist/cjs/notes/recovery.d.ts +20 -0
  87. package/dist/cjs/notes/recovery.js +48 -0
  88. package/dist/cjs/notes/selection.d.ts +77 -0
  89. package/dist/cjs/notes/selection.js +193 -0
  90. package/dist/cjs/notes/spent.d.ts +60 -0
  91. package/dist/cjs/notes/spent.js +101 -0
  92. package/dist/cjs/perps/constants.d.ts +16 -0
  93. package/dist/cjs/perps/constants.js +52 -0
  94. package/dist/cjs/perps/index.d.ts +5 -0
  95. package/dist/cjs/perps/index.js +21 -0
  96. package/dist/cjs/perps/keys.d.ts +16 -0
  97. package/dist/cjs/perps/keys.js +43 -0
  98. package/dist/cjs/perps/pdas.d.ts +29 -0
  99. package/dist/cjs/perps/pdas.js +55 -0
  100. package/dist/cjs/perps/relayer.d.ts +9 -0
  101. package/dist/cjs/perps/relayer.js +35 -0
  102. package/dist/cjs/perps/types.d.ts +126 -0
  103. package/dist/cjs/perps/types.js +2 -0
  104. package/dist/cjs/positions/index.d.ts +4 -0
  105. package/dist/cjs/positions/index.js +20 -0
  106. package/dist/cjs/positions/keys.d.ts +29 -0
  107. package/dist/cjs/positions/keys.js +71 -0
  108. package/dist/cjs/positions/pdas.d.ts +15 -0
  109. package/dist/cjs/positions/pdas.js +54 -0
  110. package/dist/cjs/positions/relayer.d.ts +4 -0
  111. package/dist/cjs/positions/relayer.js +15 -0
  112. package/dist/cjs/positions/types.d.ts +97 -0
  113. package/dist/cjs/positions/types.js +2 -0
  114. package/dist/cjs/predictions/client.d.ts +41 -0
  115. package/dist/cjs/predictions/client.js +147 -0
  116. package/dist/cjs/predictions/index.d.ts +5 -0
  117. package/dist/cjs/predictions/index.js +21 -0
  118. package/dist/cjs/predictions/keys.d.ts +14 -0
  119. package/dist/cjs/predictions/keys.js +40 -0
  120. package/dist/cjs/predictions/pdas.d.ts +6 -0
  121. package/dist/cjs/predictions/pdas.js +13 -0
  122. package/dist/cjs/predictions/relayer.d.ts +3 -0
  123. package/dist/cjs/predictions/relayer.js +11 -0
  124. package/dist/cjs/predictions/types.d.ts +178 -0
  125. package/dist/cjs/predictions/types.js +2 -0
  126. package/dist/cjs/program.d.ts +2 -0
  127. package/dist/cjs/program.js +8 -7
  128. package/dist/cjs/proof.d.ts +1 -183
  129. package/dist/cjs/proof.js +16 -290
  130. package/dist/cjs/proofs/encoding.d.ts +17 -0
  131. package/dist/cjs/proofs/encoding.js +72 -0
  132. package/dist/cjs/proofs/formatting.d.ts +6 -0
  133. package/dist/cjs/proofs/formatting.js +34 -0
  134. package/dist/cjs/proofs/index.d.ts +5 -0
  135. package/dist/cjs/proofs/index.js +21 -0
  136. package/dist/cjs/proofs/swap.d.ts +87 -0
  137. package/dist/cjs/proofs/swap.js +144 -0
  138. package/dist/cjs/proofs/transaction.d.ts +28 -0
  139. package/dist/cjs/proofs/transaction.js +110 -0
  140. package/dist/cjs/proofs/types.d.ts +70 -0
  141. package/dist/cjs/proofs/types.js +2 -0
  142. package/dist/cjs/prover.d.ts +30 -4
  143. package/dist/cjs/prover.js +118 -49
  144. package/dist/cjs/relayer/api.d.ts +31 -0
  145. package/dist/cjs/relayer/api.js +86 -0
  146. package/dist/cjs/relayer/client.d.ts +73 -0
  147. package/dist/cjs/relayer/client.js +206 -0
  148. package/dist/cjs/relayer/crypto.d.ts +5 -0
  149. package/dist/cjs/relayer/crypto.js +26 -0
  150. package/dist/cjs/relayer/encoding.d.ts +2 -0
  151. package/dist/cjs/relayer/encoding.js +23 -0
  152. package/dist/cjs/relayer/errors.d.ts +7 -0
  153. package/dist/cjs/relayer/errors.js +17 -0
  154. package/dist/cjs/relayer/index.d.ts +6 -0
  155. package/dist/cjs/relayer/index.js +19 -0
  156. package/dist/cjs/relayer/internal-config.d.ts +36 -0
  157. package/dist/cjs/relayer/internal-config.js +9 -0
  158. package/dist/cjs/relayer/internal.d.ts +6 -0
  159. package/dist/cjs/relayer/internal.js +14 -0
  160. package/dist/cjs/relayer/transport.d.ts +19 -0
  161. package/dist/cjs/relayer/transport.js +68 -0
  162. package/dist/{src/relayer.d.ts → cjs/relayer/types.d.ts} +53 -96
  163. package/dist/cjs/relayer/types.js +5 -0
  164. package/dist/cjs/relayer.d.ts +1 -318
  165. package/dist/cjs/relayer.js +15 -254
  166. package/dist/cjs/shield/alt.js +8 -8
  167. package/dist/cjs/shield/errors.js +2 -2
  168. package/dist/cjs/shield/finalize.js +2 -2
  169. package/dist/cjs/shield/ix.d.ts +1 -1
  170. package/dist/cjs/shield/owner.js +9 -11
  171. package/dist/cjs/shield/ports.js +3 -3
  172. package/dist/cjs/shield/preflight.js +3 -3
  173. package/dist/cjs/shield/shield.js +20 -19
  174. package/dist/cjs/shield/types.d.ts +1 -1
  175. package/dist/cjs/transactions/deposit.d.ts +94 -0
  176. package/dist/cjs/transactions/deposit.js +234 -0
  177. package/dist/cjs/transactions/index.d.ts +7 -0
  178. package/dist/cjs/transactions/index.js +26 -0
  179. package/dist/cjs/transactions/swap.d.ts +71 -0
  180. package/dist/cjs/transactions/swap.js +184 -0
  181. package/dist/cjs/transactions/transact.d.ts +34 -0
  182. package/dist/cjs/transactions/transact.js +146 -0
  183. package/dist/cjs/transactions/transfer.d.ts +51 -0
  184. package/dist/cjs/transactions/transfer.js +106 -0
  185. package/dist/cjs/transactions/withdraw.d.ts +52 -0
  186. package/dist/cjs/transactions/withdraw.js +104 -0
  187. package/dist/cjs/utxo.d.ts +1 -235
  188. package/dist/cjs/utxo.js +15 -404
  189. package/dist/esm/accounts/admin.d.ts +84 -0
  190. package/dist/esm/accounts/admin.js +165 -0
  191. package/dist/esm/accounts/errors.d.ts +6 -0
  192. package/dist/esm/accounts/errors.js +95 -0
  193. package/dist/esm/accounts/index.d.ts +4 -0
  194. package/dist/esm/accounts/index.js +4 -0
  195. package/dist/esm/accounts/pdas.d.ts +23 -0
  196. package/dist/esm/accounts/pdas.js +38 -0
  197. package/dist/esm/accounts/queries.d.ts +41 -0
  198. package/dist/esm/accounts/queries.js +88 -0
  199. package/dist/esm/client.d.ts +2 -407
  200. package/dist/esm/client.js +3 -891
  201. package/dist/esm/cloak/client.d.ts +28 -0
  202. package/dist/esm/cloak/client.js +64 -0
  203. package/dist/esm/cloak/errors.d.ts +13 -0
  204. package/dist/esm/cloak/errors.js +21 -0
  205. package/dist/esm/cloak/helpers.d.ts +6 -0
  206. package/dist/esm/cloak/helpers.js +31 -0
  207. package/dist/esm/cloak/index.d.ts +6 -0
  208. package/dist/esm/cloak/index.js +6 -0
  209. package/dist/esm/cloak/polling.d.ts +7 -0
  210. package/dist/esm/cloak/polling.js +63 -0
  211. package/dist/esm/cloak/transport.d.ts +15 -0
  212. package/dist/esm/cloak/transport.js +115 -0
  213. package/dist/esm/cloak/types.d.ts +188 -0
  214. package/dist/esm/cloak/types.js +4 -0
  215. package/dist/esm/cloak.d.ts +1 -0
  216. package/dist/esm/cloak.js +2 -0
  217. package/dist/esm/compactNote.d.ts +21 -0
  218. package/dist/esm/compactNote.js +24 -1
  219. package/dist/esm/events/index.d.ts +6 -0
  220. package/dist/esm/events/index.js +6 -0
  221. package/dist/esm/events/parsing.d.ts +25 -0
  222. package/dist/esm/events/parsing.js +120 -0
  223. package/dist/esm/events/position.d.ts +26 -0
  224. package/dist/esm/events/position.js +48 -0
  225. package/dist/esm/events/recovery.d.ts +87 -0
  226. package/dist/esm/events/recovery.js +237 -0
  227. package/dist/esm/events/scanning.d.ts +35 -0
  228. package/dist/esm/events/scanning.js +92 -0
  229. package/dist/esm/events/tree.d.ts +27 -0
  230. package/dist/esm/events/tree.js +58 -0
  231. package/dist/esm/events/types.d.ts +39 -0
  232. package/dist/esm/events/types.js +1 -0
  233. package/dist/esm/events.d.ts +1 -77
  234. package/dist/esm/events.js +3 -129
  235. package/dist/esm/identity/encoding.d.ts +9 -0
  236. package/dist/esm/identity/encoding.js +75 -0
  237. package/dist/esm/identity/index.d.ts +4 -0
  238. package/dist/esm/identity/index.js +4 -0
  239. package/dist/esm/identity/noteKey.d.ts +33 -0
  240. package/dist/esm/identity/noteKey.js +91 -0
  241. package/dist/esm/identity/spending.d.ts +18 -0
  242. package/dist/esm/identity/spending.js +35 -0
  243. package/dist/esm/identity/viewKey.d.ts +38 -0
  244. package/dist/esm/identity/viewKey.js +96 -0
  245. package/dist/esm/idl/index.d.ts +18 -0
  246. package/dist/esm/idl/index.js +18 -0
  247. package/dist/esm/idl/privacy_pool.json +9907 -9907
  248. package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
  249. package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
  250. package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
  251. package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
  252. package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
  253. package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
  254. package/dist/esm/index.d.ts +9 -3
  255. package/dist/esm/index.js +10 -3
  256. package/dist/esm/notes/amount.d.ts +2 -0
  257. package/dist/esm/notes/amount.js +18 -0
  258. package/dist/esm/notes/encryption.d.ts +41 -0
  259. package/dist/esm/notes/encryption.js +67 -0
  260. package/dist/esm/notes/index.d.ts +8 -0
  261. package/dist/esm/notes/index.js +8 -0
  262. package/dist/esm/notes/mailbox.d.ts +70 -0
  263. package/dist/esm/notes/mailbox.js +154 -0
  264. package/dist/esm/notes/model.d.ts +91 -0
  265. package/dist/esm/notes/model.js +99 -0
  266. package/dist/esm/notes/nullifier.d.ts +27 -0
  267. package/dist/esm/notes/nullifier.js +40 -0
  268. package/dist/esm/notes/recovery.d.ts +20 -0
  269. package/dist/esm/notes/recovery.js +45 -0
  270. package/dist/esm/notes/selection.d.ts +77 -0
  271. package/dist/esm/notes/selection.js +188 -0
  272. package/dist/esm/notes/spent.d.ts +60 -0
  273. package/dist/esm/notes/spent.js +96 -0
  274. package/dist/esm/perps/constants.d.ts +16 -0
  275. package/dist/esm/perps/constants.js +48 -0
  276. package/dist/esm/perps/index.d.ts +5 -0
  277. package/dist/esm/perps/index.js +5 -0
  278. package/dist/esm/perps/keys.d.ts +16 -0
  279. package/dist/esm/perps/keys.js +35 -0
  280. package/dist/esm/perps/pdas.d.ts +29 -0
  281. package/dist/esm/perps/pdas.js +47 -0
  282. package/dist/esm/perps/relayer.d.ts +9 -0
  283. package/dist/esm/perps/relayer.js +25 -0
  284. package/dist/esm/perps/types.d.ts +126 -0
  285. package/dist/esm/perps/types.js +1 -0
  286. package/dist/esm/positions/index.d.ts +4 -0
  287. package/dist/esm/positions/index.js +4 -0
  288. package/dist/esm/positions/keys.d.ts +29 -0
  289. package/dist/esm/positions/keys.js +65 -0
  290. package/dist/esm/positions/pdas.d.ts +15 -0
  291. package/dist/esm/positions/pdas.js +44 -0
  292. package/dist/esm/positions/relayer.d.ts +4 -0
  293. package/dist/esm/positions/relayer.js +10 -0
  294. package/dist/esm/positions/types.d.ts +97 -0
  295. package/dist/esm/positions/types.js +1 -0
  296. package/dist/esm/predictions/client.d.ts +41 -0
  297. package/dist/esm/predictions/client.js +141 -0
  298. package/dist/esm/predictions/index.d.ts +5 -0
  299. package/dist/esm/predictions/index.js +5 -0
  300. package/dist/esm/predictions/keys.d.ts +14 -0
  301. package/dist/esm/predictions/keys.js +33 -0
  302. package/dist/esm/predictions/pdas.d.ts +6 -0
  303. package/dist/esm/predictions/pdas.js +10 -0
  304. package/dist/esm/predictions/relayer.d.ts +3 -0
  305. package/dist/esm/predictions/relayer.js +7 -0
  306. package/dist/esm/predictions/types.d.ts +178 -0
  307. package/dist/esm/predictions/types.js +1 -0
  308. package/dist/esm/program.d.ts +2 -0
  309. package/dist/esm/program.js +4 -3
  310. package/dist/esm/proof.d.ts +1 -183
  311. package/dist/esm/proof.js +2 -281
  312. package/dist/esm/proofs/encoding.d.ts +17 -0
  313. package/dist/esm/proofs/encoding.js +68 -0
  314. package/dist/esm/proofs/formatting.d.ts +6 -0
  315. package/dist/esm/proofs/formatting.js +31 -0
  316. package/dist/esm/proofs/index.d.ts +5 -0
  317. package/dist/esm/proofs/index.js +5 -0
  318. package/dist/esm/proofs/swap.d.ts +87 -0
  319. package/dist/esm/proofs/swap.js +138 -0
  320. package/dist/esm/proofs/transaction.d.ts +28 -0
  321. package/dist/esm/proofs/transaction.js +105 -0
  322. package/dist/esm/proofs/types.d.ts +70 -0
  323. package/dist/esm/proofs/types.js +1 -0
  324. package/dist/esm/prover.d.ts +30 -4
  325. package/dist/esm/prover.js +115 -15
  326. package/dist/esm/relayer/api.d.ts +31 -0
  327. package/dist/esm/relayer/api.js +55 -0
  328. package/dist/esm/relayer/client.d.ts +73 -0
  329. package/dist/esm/relayer/client.js +199 -0
  330. package/dist/esm/relayer/crypto.d.ts +5 -0
  331. package/dist/esm/relayer/crypto.js +20 -0
  332. package/dist/esm/relayer/encoding.d.ts +2 -0
  333. package/dist/esm/relayer/encoding.js +19 -0
  334. package/dist/esm/relayer/errors.d.ts +7 -0
  335. package/dist/esm/relayer/errors.js +13 -0
  336. package/dist/esm/relayer/index.d.ts +6 -0
  337. package/dist/esm/relayer/index.js +3 -0
  338. package/dist/esm/relayer/internal-config.d.ts +36 -0
  339. package/dist/esm/relayer/internal-config.js +6 -0
  340. package/dist/esm/relayer/internal.d.ts +6 -0
  341. package/dist/esm/relayer/internal.js +10 -0
  342. package/dist/esm/relayer/transport.d.ts +19 -0
  343. package/dist/esm/relayer/transport.js +64 -0
  344. package/dist/esm/relayer/types.d.ts +275 -0
  345. package/dist/esm/relayer/types.js +4 -0
  346. package/dist/esm/relayer.d.ts +1 -318
  347. package/dist/esm/relayer.js +2 -249
  348. package/dist/esm/shield/alt.js +1 -1
  349. package/dist/esm/shield/errors.js +1 -1
  350. package/dist/esm/shield/finalize.js +1 -1
  351. package/dist/esm/shield/ix.d.ts +1 -1
  352. package/dist/esm/shield/owner.js +3 -5
  353. package/dist/esm/shield/ports.js +1 -1
  354. package/dist/esm/shield/preflight.js +1 -1
  355. package/dist/esm/shield/shield.js +4 -3
  356. package/dist/esm/shield/types.d.ts +1 -1
  357. package/dist/esm/transactions/deposit.d.ts +94 -0
  358. package/dist/esm/transactions/deposit.js +198 -0
  359. package/dist/esm/transactions/index.d.ts +7 -0
  360. package/dist/esm/transactions/index.js +7 -0
  361. package/dist/esm/transactions/swap.d.ts +71 -0
  362. package/dist/esm/transactions/swap.js +144 -0
  363. package/dist/esm/transactions/transact.d.ts +34 -0
  364. package/dist/esm/transactions/transact.js +110 -0
  365. package/dist/esm/transactions/transfer.d.ts +51 -0
  366. package/dist/esm/transactions/transfer.js +103 -0
  367. package/dist/esm/transactions/withdraw.d.ts +52 -0
  368. package/dist/esm/transactions/withdraw.js +101 -0
  369. package/dist/esm/utxo.d.ts +1 -235
  370. package/dist/esm/utxo.js +2 -382
  371. package/identity.d.ts +2 -0
  372. package/identity.js +3 -0
  373. package/idl.d.ts +2 -0
  374. package/idl.js +3 -0
  375. package/notes.d.ts +2 -0
  376. package/notes.js +3 -0
  377. package/package.json +131 -11
  378. package/perps.d.ts +2 -0
  379. package/perps.js +3 -0
  380. package/poseidon.d.ts +2 -2
  381. package/poseidon.js +2 -3
  382. package/positions.d.ts +2 -0
  383. package/positions.js +3 -0
  384. package/predictions.d.ts +2 -0
  385. package/predictions.js +3 -0
  386. package/proof.d.ts +2 -2
  387. package/proof.js +2 -3
  388. package/prover.d.ts +2 -2
  389. package/prover.js +2 -3
  390. package/relayer.d.ts +2 -0
  391. package/relayer.js +3 -0
  392. package/shield.d.ts +2 -2
  393. package/shield.js +2 -3
  394. package/transactions.d.ts +2 -0
  395. package/transactions.js +3 -0
  396. package/SHIELD_INTEGRATION.md +0 -143
  397. package/dist/src/client.d.ts +0 -407
  398. package/dist/src/client.js +0 -951
  399. package/dist/src/compactNote.d.ts +0 -107
  400. package/dist/src/compactNote.js +0 -167
  401. package/dist/src/config.d.ts +0 -82
  402. package/dist/src/config.js +0 -57
  403. package/dist/src/events.d.ts +0 -77
  404. package/dist/src/events.js +0 -167
  405. package/dist/src/idl/privacy_pool.js +0 -15218
  406. package/dist/src/index.d.ts +0 -16
  407. package/dist/src/index.js +0 -67
  408. package/dist/src/merkle.d.ts +0 -77
  409. package/dist/src/merkle.js +0 -156
  410. package/dist/src/poseidon.d.ts +0 -29
  411. package/dist/src/poseidon.js +0 -100
  412. package/dist/src/program.d.ts +0 -37
  413. package/dist/src/program.js +0 -61
  414. package/dist/src/proof.d.ts +0 -183
  415. package/dist/src/proof.js +0 -292
  416. package/dist/src/prover.d.ts +0 -54
  417. package/dist/src/prover.js +0 -112
  418. package/dist/src/random.d.ts +0 -16
  419. package/dist/src/random.js +0 -28
  420. package/dist/src/relayer.js +0 -257
  421. package/dist/src/retry.d.ts +0 -32
  422. package/dist/src/retry.js +0 -75
  423. package/dist/src/shield/alt.d.ts +0 -87
  424. package/dist/src/shield/alt.js +0 -194
  425. package/dist/src/shield/computeBudget.d.ts +0 -61
  426. package/dist/src/shield/computeBudget.js +0 -64
  427. package/dist/src/shield/errors.d.ts +0 -58
  428. package/dist/src/shield/errors.js +0 -121
  429. package/dist/src/shield/finalize.d.ts +0 -45
  430. package/dist/src/shield/finalize.js +0 -119
  431. package/dist/src/shield/index.d.ts +0 -35
  432. package/dist/src/shield/index.js +0 -68
  433. package/dist/src/shield/ix.d.ts +0 -54
  434. package/dist/src/shield/ix.js +0 -119
  435. package/dist/src/shield/owner.d.ts +0 -36
  436. package/dist/src/shield/owner.js +0 -126
  437. package/dist/src/shield/ports.d.ts +0 -43
  438. package/dist/src/shield/ports.js +0 -153
  439. package/dist/src/shield/preflight.d.ts +0 -30
  440. package/dist/src/shield/preflight.js +0 -154
  441. package/dist/src/shield/shield.d.ts +0 -68
  442. package/dist/src/shield/shield.js +0 -499
  443. package/dist/src/shield/types.d.ts +0 -202
  444. package/dist/src/utxo.d.ts +0 -235
  445. package/dist/src/utxo.js +0 -407
  446. package/dist/tests/compact-note.test.d.ts +0 -1
  447. package/dist/tests/compact-note.test.js +0 -173
  448. package/dist/tests/config.test.d.ts +0 -1
  449. package/dist/tests/config.test.js +0 -102
  450. package/dist/tests/edge-cases.test.d.ts +0 -1
  451. package/dist/tests/edge-cases.test.js +0 -220
  452. package/dist/tests/encryption.test.d.ts +0 -1
  453. package/dist/tests/encryption.test.js +0 -215
  454. package/dist/tests/events.test.d.ts +0 -1
  455. package/dist/tests/events.test.js +0 -78
  456. package/dist/tests/multi-tree.test.d.ts +0 -1
  457. package/dist/tests/multi-tree.test.js +0 -405
  458. package/dist/tests/pda.test.d.ts +0 -1
  459. package/dist/tests/pda.test.js +0 -229
  460. package/dist/tests/poseidon-builder-parity.test.d.ts +0 -1
  461. package/dist/tests/poseidon-builder-parity.test.js +0 -72
  462. package/dist/tests/poseidon.test.d.ts +0 -1
  463. package/dist/tests/poseidon.test.js +0 -142
  464. package/dist/tests/proof.test.d.ts +0 -1
  465. package/dist/tests/proof.test.js +0 -296
  466. package/dist/tests/relayer.test.d.ts +0 -1
  467. package/dist/tests/relayer.test.js +0 -271
  468. package/dist/tests/sdk.integration.test.d.ts +0 -1
  469. package/dist/tests/sdk.integration.test.js +0 -330
  470. package/dist/tests/shield-owner.test.d.ts +0 -1
  471. package/dist/tests/shield-owner.test.js +0 -89
  472. package/dist/tests/shield-preflight.test.d.ts +0 -1
  473. package/dist/tests/shield-preflight.test.js +0 -87
  474. package/dist/tests/shield-realproof.test.d.ts +0 -1
  475. package/dist/tests/shield-realproof.test.js +0 -272
  476. package/dist/tests/shield.test.d.ts +0 -1
  477. package/dist/tests/shield.test.js +0 -403
  478. package/dist/tests/utxo.test.d.ts +0 -1
  479. package/dist/tests/utxo.test.js +0 -140
  480. /package/dist/{src/shield → cjs/events}/types.js +0 -0
  481. /package/dist/{src/idl/privacy_pool.d.ts → cjs/idl/privacy_pool_legacy.d.ts} +0 -0
@@ -1,61 +0,0 @@
1
- /**
2
- * Compute budget and transaction size constants for the shield path.
3
- *
4
- * These numbers are empirical and load-bearing. They are constants rather than
5
- * inline literals so a future program change that invalidates them has one
6
- * place to be fixed and one place to be read.
7
- */
8
- /**
9
- * Compute unit limit reserved for a shield.
10
- *
11
- * Measured usage for a deposit is ~377k CU; 700k leaves roughly 2× headroom
12
- * while staying low enough that Phantom's Lighthouse guard still fits its own
13
- * instructions alongside ours.
14
- *
15
- * Do NOT raise this to 1.4M (what the stale `client.ts` `deposit()` reserves).
16
- * An oversized CU reservation is one of the signals that makes Phantom render
17
- * the transaction with a malicious-dApp warning.
18
- *
19
- * Ported from veilo-dapp/features/transactions/handleDeposit.ts:673-681.
20
- */
21
- export declare const SHIELD_COMPUTE_UNIT_LIMIT = 700000;
22
- /** Typical measured usage. If real usage approaches the limit above, revisit both. */
23
- export declare const SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL = 377000;
24
- /** Default priority fee. Set to 0 to omit the instruction entirely (saves ~40 bytes). */
25
- export declare const SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = 50000;
26
- /** Solana's hard cap on a serialized transaction, signatures included. */
27
- export declare const MAX_TRANSACTION_BYTES = 1232;
28
- /** One ed25519 signature: 64 bytes plus the compact-array length prefix. */
29
- export declare const SIGNATURE_BYTES = 65;
30
- /**
31
- * `NullifierMarker::LEN` (privacy-program .../lib.rs:415). Two markers are
32
- * created per transact and paid for by the signer — see the note on sponsorship
33
- * in the module docs of `shield.ts`.
34
- */
35
- export declare const NULLIFIER_MARKER_ACCOUNT_BYTES = 10;
36
- /** Markers created per `transact` — one per circuit input. */
37
- export declare const NULLIFIER_MARKERS_PER_TRANSACT = 2;
38
- /** Default validity window for the on-chain `deadline` argument. */
39
- export declare const DEFAULT_DEADLINE_SECONDS = 3600;
40
- /**
41
- * Serialized size of the `transact` instruction data, for reference:
42
- *
43
- * 8 discriminator
44
- * 32 root
45
- * 2 input_tree_id
46
- * 2 output_tree_id
47
- * 8 public_amount
48
- * 32 ext_data_hash
49
- * 32 mint_address
50
- * 128 2 nullifiers + 2 commitments
51
- * 8 deadline
52
- * 112 ExtData (recipient, relayer, fee, refund, claimant)
53
- * 256 Groth16 proof (a:64, b:128, c:64)
54
- * 227 Option<NoteCiphers> (1 tag + 226)
55
- * ---
56
- * 847
57
- *
58
- * With 16 accounts this cannot fit in a legacy transaction (~1500 bytes), which
59
- * is why the shield path is v0-with-ALT and not optional.
60
- */
61
- export declare const TRANSACT_INSTRUCTION_DATA_BYTES = 847;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- /**
3
- * Compute budget and transaction size constants for the shield path.
4
- *
5
- * These numbers are empirical and load-bearing. They are constants rather than
6
- * inline literals so a future program change that invalidates them has one
7
- * place to be fixed and one place to be read.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TRANSACT_INSTRUCTION_DATA_BYTES = exports.DEFAULT_DEADLINE_SECONDS = exports.NULLIFIER_MARKERS_PER_TRANSACT = exports.NULLIFIER_MARKER_ACCOUNT_BYTES = exports.SIGNATURE_BYTES = exports.MAX_TRANSACTION_BYTES = exports.SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = exports.SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL = exports.SHIELD_COMPUTE_UNIT_LIMIT = void 0;
11
- /**
12
- * Compute unit limit reserved for a shield.
13
- *
14
- * Measured usage for a deposit is ~377k CU; 700k leaves roughly 2× headroom
15
- * while staying low enough that Phantom's Lighthouse guard still fits its own
16
- * instructions alongside ours.
17
- *
18
- * Do NOT raise this to 1.4M (what the stale `client.ts` `deposit()` reserves).
19
- * An oversized CU reservation is one of the signals that makes Phantom render
20
- * the transaction with a malicious-dApp warning.
21
- *
22
- * Ported from veilo-dapp/features/transactions/handleDeposit.ts:673-681.
23
- */
24
- exports.SHIELD_COMPUTE_UNIT_LIMIT = 700000;
25
- /** Typical measured usage. If real usage approaches the limit above, revisit both. */
26
- exports.SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL = 377000;
27
- /** Default priority fee. Set to 0 to omit the instruction entirely (saves ~40 bytes). */
28
- exports.SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = 50000;
29
- /** Solana's hard cap on a serialized transaction, signatures included. */
30
- exports.MAX_TRANSACTION_BYTES = 1232;
31
- /** One ed25519 signature: 64 bytes plus the compact-array length prefix. */
32
- exports.SIGNATURE_BYTES = 65;
33
- /**
34
- * `NullifierMarker::LEN` (privacy-program .../lib.rs:415). Two markers are
35
- * created per transact and paid for by the signer — see the note on sponsorship
36
- * in the module docs of `shield.ts`.
37
- */
38
- exports.NULLIFIER_MARKER_ACCOUNT_BYTES = 10;
39
- /** Markers created per `transact` — one per circuit input. */
40
- exports.NULLIFIER_MARKERS_PER_TRANSACT = 2;
41
- /** Default validity window for the on-chain `deadline` argument. */
42
- exports.DEFAULT_DEADLINE_SECONDS = 3600;
43
- /**
44
- * Serialized size of the `transact` instruction data, for reference:
45
- *
46
- * 8 discriminator
47
- * 32 root
48
- * 2 input_tree_id
49
- * 2 output_tree_id
50
- * 8 public_amount
51
- * 32 ext_data_hash
52
- * 32 mint_address
53
- * 128 2 nullifiers + 2 commitments
54
- * 8 deadline
55
- * 112 ExtData (recipient, relayer, fee, refund, claimant)
56
- * 256 Groth16 proof (a:64, b:128, c:64)
57
- * 227 Option<NoteCiphers> (1 tag + 226)
58
- * ---
59
- * 847
60
- *
61
- * With 16 accounts this cannot fit in a legacy transaction (~1500 bytes), which
62
- * is why the shield path is v0-with-ALT and not optional.
63
- */
64
- exports.TRANSACT_INSTRUCTION_DATA_BYTES = 847;
@@ -1,58 +0,0 @@
1
- import { TransactionInstruction } from "@solana/web3.js";
2
- /**
3
- * Error taxonomy for the shield path.
4
- *
5
- * `parseOnChainError` already turns program codes into readable sentences. What
6
- * it does not give you is a *decision*: can this be retried, and how? That is
7
- * what integrators actually need, because the three retry classes have wildly
8
- * different costs:
9
- *
10
- * - `rebuild` — reuse the proof, new blockhash. Milliseconds.
11
- * - `reshield` — the proof is stale, prove again. 10–30 seconds.
12
- * - `none` — retrying cannot help; something must change first.
13
- */
14
- export type ShieldRetryClass = "rebuild" | "reshield" | "none";
15
- export type ShieldErrorCode = "POOL_NOT_FOUND" | "POOL_PAUSED" | "AMOUNT_BELOW_MINIMUM" | "AMOUNT_ABOVE_MAXIMUM" | "TREE_FULL" | "INSUFFICIENT_SOL" | "INSUFFICIENT_TOKEN_BALANCE" | "TOKEN_ACCOUNT_MISSING" | "TOKEN_ACCOUNT_WRONG_MINT" | "TOKEN_ACCOUNT_WRONG_OWNER" | "TOKEN_ACCOUNT_DELEGATED" | "TOKEN_ACCOUNT_FROZEN" | "VAULT_ATA_MISSING" | "ALT_NOT_FOUND" | "ALT_INCOMPLETE" | "TX_TOO_LARGE" | "OWNER_INVARIANT_UNACKNOWLEDGED" | "UNRESOLVED_ACCOUNT" | "BLOCKHASH_EXPIRED" | "DEADLINE_EXPIRED" | "ROOT_STALE" | "NULLIFIER_COLLISION" | "COMPUTE_BUDGET_EXCEEDED" | "PROOF_REJECTED" | "UNKNOWN";
16
- export type ShieldErrorRemedy = {
17
- /** Human-readable description of what would fix this. */
18
- description: string;
19
- /** Instructions that, once executed, clear the condition. */
20
- instructions: TransactionInstruction[];
21
- };
22
- export declare class ShieldError extends Error {
23
- readonly code: ShieldErrorCode;
24
- /** Program error code (6000–6060) when this was derived from a chain error. */
25
- readonly programCode?: number;
26
- /** Whether and how a retry can succeed. */
27
- readonly retryable: ShieldRetryClass;
28
- /** Machine-readable detail: which account, what value, what was expected. */
29
- readonly context?: Record<string, unknown>;
30
- /** Present when the condition is fixable by executing instructions first. */
31
- readonly remedy?: ShieldErrorRemedy;
32
- readonly cause?: unknown;
33
- constructor(code: ShieldErrorCode, message: string, opts?: {
34
- programCode?: number;
35
- retryable?: ShieldRetryClass;
36
- context?: Record<string, unknown>;
37
- remedy?: ShieldErrorRemedy;
38
- cause?: unknown;
39
- });
40
- }
41
- /** Extract a privacy_pool program error code from an arbitrary thrown value. */
42
- export declare function extractProgramCode(error: any): number | null;
43
- /**
44
- * Map a submission failure onto the taxonomy.
45
- *
46
- * Two mappings here are not obvious and are worth stating plainly:
47
- *
48
- * **Nullifier collision means "already landed", not "already spent."** The
49
- * marker PDAs are `init`, not `init_if_needed`, so a second submission of the
50
- * same shield fails at account resolution. For a deposit the nullifiers derive
51
- * from freshly generated random keys, so a genuine collision is impossible —
52
- * in practice this only ever means the first attempt succeeded. Telling a user
53
- * their funds were "already spent" here would be alarming and wrong.
54
- *
55
- * **`UnknownRoot` is recoverable but not by `rebuild()`.** The proof commits to
56
- * the root, so a stale root needs a fresh proof, not a fresh blockhash.
57
- */
58
- export declare function mapShieldError(error: unknown): ShieldError;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShieldError = void 0;
4
- exports.extractProgramCode = extractProgramCode;
5
- exports.mapShieldError = mapShieldError;
6
- const client_js_1 = require("../client.js");
7
- class ShieldError extends Error {
8
- constructor(code, message, opts = {}) {
9
- super(message);
10
- this.name = "ShieldError";
11
- this.code = code;
12
- this.programCode = opts.programCode;
13
- this.retryable = opts.retryable ?? "none";
14
- this.context = opts.context;
15
- this.remedy = opts.remedy;
16
- this.cause = opts.cause;
17
- }
18
- }
19
- exports.ShieldError = ShieldError;
20
- /** Extract a privacy_pool program error code from an arbitrary thrown value. */
21
- function extractProgramCode(error) {
22
- const raw = (error?.message ?? error?.toString() ?? "").toLowerCase();
23
- const hex = raw.match(/custom program error:\s*0x([0-9a-f]+)/);
24
- if (hex)
25
- return parseInt(hex[1], 16);
26
- const num = raw.match(/error number:\s*(\d+)/);
27
- if (num)
28
- return parseInt(num[1], 10);
29
- if (typeof error?.error?.errorCode?.number === "number") {
30
- return error.error.errorCode.number;
31
- }
32
- return null;
33
- }
34
- /**
35
- * Map a submission failure onto the taxonomy.
36
- *
37
- * Two mappings here are not obvious and are worth stating plainly:
38
- *
39
- * **Nullifier collision means "already landed", not "already spent."** The
40
- * marker PDAs are `init`, not `init_if_needed`, so a second submission of the
41
- * same shield fails at account resolution. For a deposit the nullifiers derive
42
- * from freshly generated random keys, so a genuine collision is impossible —
43
- * in practice this only ever means the first attempt succeeded. Telling a user
44
- * their funds were "already spent" here would be alarming and wrong.
45
- *
46
- * **`UnknownRoot` is recoverable but not by `rebuild()`.** The proof commits to
47
- * the root, so a stale root needs a fresh proof, not a fresh blockhash.
48
- */
49
- function mapShieldError(error) {
50
- if (error instanceof ShieldError)
51
- return error;
52
- const err = error;
53
- const raw = (err?.message ?? String(err ?? "")).toLowerCase();
54
- const programCode = extractProgramCode(err);
55
- const readable = (0, client_js_1.parseOnChainError)(err);
56
- if (programCode !== null) {
57
- switch (programCode) {
58
- case 6000:
59
- return new ShieldError("POOL_PAUSED", readable, { programCode, cause: err });
60
- case 6007:
61
- return new ShieldError("ROOT_STALE", "The Merkle root this shield was proven against is no longer in the on-chain " +
62
- "history. Build a new shield — the proof cannot be reused.", { programCode, retryable: "reshield", cause: err });
63
- case 6012:
64
- return new ShieldError("PROOF_REJECTED", readable, { programCode, cause: err });
65
- case 6013:
66
- return new ShieldError("TREE_FULL", readable, {
67
- programCode,
68
- retryable: "reshield",
69
- cause: err,
70
- });
71
- case 6017:
72
- return new ShieldError("TOKEN_ACCOUNT_WRONG_MINT", readable, {
73
- programCode,
74
- cause: err,
75
- });
76
- case 6029:
77
- return new ShieldError("TOKEN_ACCOUNT_DELEGATED", "The source token account has an active delegate. Revoke it, then shield again.", { programCode, cause: err });
78
- case 6033:
79
- return new ShieldError("TOKEN_ACCOUNT_WRONG_OWNER", "The source token account is not owned by the signing wallet.", { programCode, cause: err });
80
- case 6035:
81
- return new ShieldError("AMOUNT_BELOW_MINIMUM", readable, { programCode, cause: err });
82
- case 6036:
83
- return new ShieldError("AMOUNT_ABOVE_MAXIMUM", readable, { programCode, cause: err });
84
- case 6050:
85
- return new ShieldError("VAULT_ATA_MISSING", readable, { programCode, cause: err });
86
- case 6005:
87
- case 6046:
88
- case 6052:
89
- return new ShieldError("NULLIFIER_COLLISION", ALREADY_SHIELDED_MESSAGE, {
90
- programCode,
91
- cause: err,
92
- });
93
- case 6060:
94
- return new ShieldError("DEADLINE_EXPIRED", "The shield's deadline passed before it landed. Rebuild it — the proof is still valid.", { programCode, retryable: "rebuild", cause: err });
95
- default:
96
- return new ShieldError("UNKNOWN", readable, { programCode, cause: err });
97
- }
98
- }
99
- // Non-program failures.
100
- if (raw.includes("block height exceeded") ||
101
- raw.includes("blockhash not found") ||
102
- err?.name === "TransactionExpiredBlockheightExceededError") {
103
- return new ShieldError("BLOCKHASH_EXPIRED", "The blockhash expired before the shield landed. Rebuild it — the proof is still valid.", { retryable: "rebuild", cause: err });
104
- }
105
- if (raw.includes("already in use")) {
106
- return new ShieldError("NULLIFIER_COLLISION", ALREADY_SHIELDED_MESSAGE, { cause: err });
107
- }
108
- if (raw.includes("exceeded cus") ||
109
- raw.includes("computational budget exceeded") ||
110
- raw.includes("exceeded compute")) {
111
- return new ShieldError("COMPUTE_BUDGET_EXCEEDED", `The shield exceeded its compute budget. Real usage has grown past the reserved ` +
112
- `limit — SHIELD_COMPUTE_UNIT_LIMIT needs revisiting.`, { cause: err });
113
- }
114
- if (raw.includes("too large") || raw.includes("transaction too large")) {
115
- return new ShieldError("TX_TOO_LARGE", readable, { cause: err });
116
- }
117
- return new ShieldError("UNKNOWN", readable, { cause: err });
118
- }
119
- const ALREADY_SHIELDED_MESSAGE = "This shield has already been submitted — check the transaction signature before " +
120
- "retrying. (The nullifier markers already exist on-chain, which for a deposit means " +
121
- "the original transaction landed; it does not mean the funds were spent.)";
@@ -1,45 +0,0 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
2
- import type { ShieldNote, ShieldOwner } from "./types.js";
3
- /**
4
- * Read the authoritative leaf index for a landed shield, and produce the
5
- * mailbox blob for optional relayer delivery.
6
- *
7
- * ## Why this is a separate step
8
- *
9
- * Every existing deposit implementation records `tree.nextIndex` read *before*
10
- * submission as the note's leaf index. Under concurrent deposits into the same
11
- * tree that value is wrong, and it is wrong permanently — the stored index is
12
- * what a later withdrawal builds its Merkle path from, so the note becomes
13
- * unspendable through the normal path.
14
- *
15
- * That race is rare for a single wallet and constant for an SDK: a platform
16
- * batching shields for many users will hit it routinely. So `shield()` reports
17
- * only a `predictedLeafIndex`, and the real one is read here from the
18
- * transaction's own `CommitmentEvent` after it confirms.
19
- *
20
- * ## What is optional
21
- *
22
- * Everything, strictly. The note is recoverable from chain data alone via the
23
- * on-chain compact cipher, so a caller that skips finalization has not lost the
24
- * funds — only the fast path to finding them. Persist nothing that depends on a
25
- * leaf index without calling this first.
26
- */
27
- export declare function finalizeShield(params: {
28
- connection: Connection;
29
- signature: string;
30
- note: ShieldNote;
31
- owner: ShieldOwner;
32
- programId?: PublicKey;
33
- /** Defaults to "confirmed". Use "finalized" if the index will be persisted. */
34
- commitment?: "confirmed" | "finalized";
35
- }): Promise<{
36
- leafIndex: number;
37
- newRoot: Uint8Array;
38
- treeId: number;
39
- slot: number;
40
- /** Encrypted note blob, ready for POST /notes/save if the caller wants mailbox delivery. */
41
- blob: {
42
- ephemeralPublicKey: Uint8Array;
43
- encryptedBlob: string;
44
- };
45
- }>;
@@ -1,119 +0,0 @@
1
- "use strict";
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.finalizeShield = finalizeShield;
37
- const anchor = __importStar(require("@coral-xyz/anchor"));
38
- const program_js_1 = require("../program.js");
39
- const utxo_js_1 = require("../utxo.js");
40
- const poseidon_js_1 = require("../poseidon.js");
41
- const errors_js_1 = require("./errors.js");
42
- /**
43
- * Read the authoritative leaf index for a landed shield, and produce the
44
- * mailbox blob for optional relayer delivery.
45
- *
46
- * ## Why this is a separate step
47
- *
48
- * Every existing deposit implementation records `tree.nextIndex` read *before*
49
- * submission as the note's leaf index. Under concurrent deposits into the same
50
- * tree that value is wrong, and it is wrong permanently — the stored index is
51
- * what a later withdrawal builds its Merkle path from, so the note becomes
52
- * unspendable through the normal path.
53
- *
54
- * That race is rare for a single wallet and constant for an SDK: a platform
55
- * batching shields for many users will hit it routinely. So `shield()` reports
56
- * only a `predictedLeafIndex`, and the real one is read here from the
57
- * transaction's own `CommitmentEvent` after it confirms.
58
- *
59
- * ## What is optional
60
- *
61
- * Everything, strictly. The note is recoverable from chain data alone via the
62
- * on-chain compact cipher, so a caller that skips finalization has not lost the
63
- * funds — only the fast path to finding them. Persist nothing that depends on a
64
- * leaf index without calling this first.
65
- */
66
- async function finalizeShield(params) {
67
- const { connection, signature, note, owner, programId = program_js_1.PRIVACY_POOL_PROGRAM_ID, commitment = "confirmed", } = params;
68
- const tx = await connection.getTransaction(signature, {
69
- commitment: commitment === "finalized" ? "finalized" : "confirmed",
70
- maxSupportedTransactionVersion: 0,
71
- });
72
- if (!tx) {
73
- throw new errors_js_1.ShieldError("UNKNOWN", `Transaction ${signature} not found at ${commitment} commitment. ` +
74
- `If it was just submitted, wait for confirmation and retry.`, { context: { signature } });
75
- }
76
- if (tx.meta?.err) {
77
- throw new errors_js_1.ShieldError("UNKNOWN", `Transaction ${signature} failed on-chain; there is no note to finalize.`, { context: { signature, err: tx.meta.err } });
78
- }
79
- const parser = new anchor.EventParser(programId, new anchor.BorshCoder(program_js_1.PRIVACY_POOL_IDL));
80
- const wantCommitment = Buffer.from(note.commitment).toString("hex");
81
- let match = null;
82
- for (const event of parser.parseLogs(tx.meta?.logMessages ?? [])) {
83
- if (event.name !== "CommitmentEvent" && event.name !== "commitmentEvent")
84
- continue;
85
- const data = event.data;
86
- const emitted = Buffer.from(data.commitment).toString("hex");
87
- if (emitted === wantCommitment) {
88
- match = data;
89
- break;
90
- }
91
- }
92
- if (!match) {
93
- throw new errors_js_1.ShieldError("UNKNOWN", `Transaction ${signature} landed but emitted no CommitmentEvent for this note's ` +
94
- `commitment. The note may belong to a different transaction.`, { context: { signature, commitment: wantCommitment } });
95
- }
96
- const leafIndex = Number(match.leafIndex ?? match.leaf_index);
97
- const treeId = Number(match.treeId ?? match.tree_id ?? note.treeId);
98
- const newRoot = new Uint8Array(match.newRoot ?? match.new_root);
99
- // Mailbox copy. Sending this to the relayer with a `recipientWalletPublicKey`
100
- // buys instant delivery and a push notification, at the cost of writing the
101
- // sender→recipient association into the relayer's database AND removing the
102
- // note from the chain-recovery feed. For shield-to-someone-else, chain-only
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(), {
105
- blinding: (0, poseidon_js_1.bigIntToBytesBE)(note.blinding),
106
- leafIndex,
107
- commitment: note.commitment,
108
- amount: note.amount,
109
- mintAddress: note.mint.toBase58(),
110
- treeId,
111
- });
112
- return {
113
- leafIndex,
114
- newRoot,
115
- treeId,
116
- slot: tx.slot,
117
- blob,
118
- };
119
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * Wallet-agnostic shielding.
3
- *
4
- * `shield()` builds an unsigned transaction that deposits public funds into the
5
- * privacy pool, creating a note owned by an arbitrary recipient. Any external
6
- * wallet — a browser extension, or a third-party platform's managed wallet —
7
- * signs and submits it. The SDK never touches a secret key.
8
- *
9
- * ```ts
10
- * const owner = await resolveShieldOwner({ username: "alice" });
11
- * const { transaction, note, proofCache } = await shield({
12
- * connection, amount, mint, owner,
13
- * signer: { publicKey: wallet.publicKey },
14
- * prover: createTransactionProver(artifacts),
15
- * });
16
- *
17
- * const signed = await wallet.signTransaction(transaction);
18
- * const sig = await connection.sendRawTransaction(signed.serialize());
19
- * ```
20
- *
21
- * On blockhash expiry, `rebuild(result, { connection })` re-assembles with a
22
- * fresh blockhash and deadline without re-proving.
23
- */
24
- export { shield, rebuild, serializeProofCache, deserializeProofCache } from "./shield.js";
25
- export { resolveShieldOwner, unsafeShieldOwner } from "./owner.js";
26
- export { finalizeShield } from "./finalize.js";
27
- export { preflightShield } from "./preflight.js";
28
- export { buildTransactInstruction, TRANSACT_ACCOUNT_NAMES } from "./ix.js";
29
- export type { TransactAccounts, TransactArgs } from "./ix.js";
30
- export { sharedDepositAlt, explicitAlt, auditDepositAlt, expectedDepositAltKeys, requiredAltKeys, SHARED_DEPOSIT_ALT, SHARED_ALT_MINTS, } from "./alt.js";
31
- export { onChainTreeSource, staticTreeSource, memoryCache, noCache } from "./ports.js";
32
- export { ShieldError, mapShieldError, extractProgramCode, } from "./errors.js";
33
- export type { ShieldErrorCode, ShieldRetryClass, ShieldErrorRemedy } from "./errors.js";
34
- export { SHIELD_COMPUTE_UNIT_LIMIT, SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS, SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL, MAX_TRANSACTION_BYTES, SIGNATURE_BYTES, TRANSACT_INSTRUCTION_DATA_BYTES, NULLIFIER_MARKER_ACCOUNT_BYTES, NULLIFIER_MARKERS_PER_TRANSACT, DEFAULT_DEADLINE_SECONDS, } from "./computeBudget.js";
35
- export type { ShieldOwner, ShieldSigner, ShieldParams, ShieldResult, ShieldNote, ShieldProofCache, ShieldQuote, TreeSource, AltSource, ShieldCachePort, DepositTarget, PreflightOptions, } from "./types.js";
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /**
3
- * Wallet-agnostic shielding.
4
- *
5
- * `shield()` builds an unsigned transaction that deposits public funds into the
6
- * privacy pool, creating a note owned by an arbitrary recipient. Any external
7
- * wallet — a browser extension, or a third-party platform's managed wallet —
8
- * signs and submits it. The SDK never touches a secret key.
9
- *
10
- * ```ts
11
- * const owner = await resolveShieldOwner({ username: "alice" });
12
- * const { transaction, note, proofCache } = await shield({
13
- * connection, amount, mint, owner,
14
- * signer: { publicKey: wallet.publicKey },
15
- * prover: createTransactionProver(artifacts),
16
- * });
17
- *
18
- * const signed = await wallet.signTransaction(transaction);
19
- * const sig = await connection.sendRawTransaction(signed.serialize());
20
- * ```
21
- *
22
- * On blockhash expiry, `rebuild(result, { connection })` re-assembles with a
23
- * fresh blockhash and deadline without re-proving.
24
- */
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.DEFAULT_DEADLINE_SECONDS = exports.NULLIFIER_MARKERS_PER_TRANSACT = exports.NULLIFIER_MARKER_ACCOUNT_BYTES = exports.TRANSACT_INSTRUCTION_DATA_BYTES = exports.SIGNATURE_BYTES = exports.MAX_TRANSACTION_BYTES = exports.SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL = exports.SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = exports.SHIELD_COMPUTE_UNIT_LIMIT = exports.extractProgramCode = exports.mapShieldError = exports.ShieldError = exports.noCache = exports.memoryCache = exports.staticTreeSource = exports.onChainTreeSource = exports.SHARED_ALT_MINTS = exports.SHARED_DEPOSIT_ALT = exports.requiredAltKeys = exports.expectedDepositAltKeys = exports.auditDepositAlt = exports.explicitAlt = exports.sharedDepositAlt = exports.TRANSACT_ACCOUNT_NAMES = exports.buildTransactInstruction = exports.preflightShield = exports.finalizeShield = exports.unsafeShieldOwner = exports.resolveShieldOwner = exports.deserializeProofCache = exports.serializeProofCache = exports.rebuild = exports.shield = void 0;
27
- var shield_js_1 = require("./shield.js");
28
- Object.defineProperty(exports, "shield", { enumerable: true, get: function () { return shield_js_1.shield; } });
29
- Object.defineProperty(exports, "rebuild", { enumerable: true, get: function () { return shield_js_1.rebuild; } });
30
- Object.defineProperty(exports, "serializeProofCache", { enumerable: true, get: function () { return shield_js_1.serializeProofCache; } });
31
- Object.defineProperty(exports, "deserializeProofCache", { enumerable: true, get: function () { return shield_js_1.deserializeProofCache; } });
32
- var owner_js_1 = require("./owner.js");
33
- Object.defineProperty(exports, "resolveShieldOwner", { enumerable: true, get: function () { return owner_js_1.resolveShieldOwner; } });
34
- Object.defineProperty(exports, "unsafeShieldOwner", { enumerable: true, get: function () { return owner_js_1.unsafeShieldOwner; } });
35
- var finalize_js_1 = require("./finalize.js");
36
- Object.defineProperty(exports, "finalizeShield", { enumerable: true, get: function () { return finalize_js_1.finalizeShield; } });
37
- var preflight_js_1 = require("./preflight.js");
38
- Object.defineProperty(exports, "preflightShield", { enumerable: true, get: function () { return preflight_js_1.preflightShield; } });
39
- var ix_js_1 = require("./ix.js");
40
- Object.defineProperty(exports, "buildTransactInstruction", { enumerable: true, get: function () { return ix_js_1.buildTransactInstruction; } });
41
- Object.defineProperty(exports, "TRANSACT_ACCOUNT_NAMES", { enumerable: true, get: function () { return ix_js_1.TRANSACT_ACCOUNT_NAMES; } });
42
- var alt_js_1 = require("./alt.js");
43
- Object.defineProperty(exports, "sharedDepositAlt", { enumerable: true, get: function () { return alt_js_1.sharedDepositAlt; } });
44
- Object.defineProperty(exports, "explicitAlt", { enumerable: true, get: function () { return alt_js_1.explicitAlt; } });
45
- Object.defineProperty(exports, "auditDepositAlt", { enumerable: true, get: function () { return alt_js_1.auditDepositAlt; } });
46
- Object.defineProperty(exports, "expectedDepositAltKeys", { enumerable: true, get: function () { return alt_js_1.expectedDepositAltKeys; } });
47
- Object.defineProperty(exports, "requiredAltKeys", { enumerable: true, get: function () { return alt_js_1.requiredAltKeys; } });
48
- Object.defineProperty(exports, "SHARED_DEPOSIT_ALT", { enumerable: true, get: function () { return alt_js_1.SHARED_DEPOSIT_ALT; } });
49
- Object.defineProperty(exports, "SHARED_ALT_MINTS", { enumerable: true, get: function () { return alt_js_1.SHARED_ALT_MINTS; } });
50
- var ports_js_1 = require("./ports.js");
51
- Object.defineProperty(exports, "onChainTreeSource", { enumerable: true, get: function () { return ports_js_1.onChainTreeSource; } });
52
- Object.defineProperty(exports, "staticTreeSource", { enumerable: true, get: function () { return ports_js_1.staticTreeSource; } });
53
- Object.defineProperty(exports, "memoryCache", { enumerable: true, get: function () { return ports_js_1.memoryCache; } });
54
- Object.defineProperty(exports, "noCache", { enumerable: true, get: function () { return ports_js_1.noCache; } });
55
- var errors_js_1 = require("./errors.js");
56
- Object.defineProperty(exports, "ShieldError", { enumerable: true, get: function () { return errors_js_1.ShieldError; } });
57
- Object.defineProperty(exports, "mapShieldError", { enumerable: true, get: function () { return errors_js_1.mapShieldError; } });
58
- Object.defineProperty(exports, "extractProgramCode", { enumerable: true, get: function () { return errors_js_1.extractProgramCode; } });
59
- var computeBudget_js_1 = require("./computeBudget.js");
60
- Object.defineProperty(exports, "SHIELD_COMPUTE_UNIT_LIMIT", { enumerable: true, get: function () { return computeBudget_js_1.SHIELD_COMPUTE_UNIT_LIMIT; } });
61
- Object.defineProperty(exports, "SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS", { enumerable: true, get: function () { return computeBudget_js_1.SHIELD_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS; } });
62
- Object.defineProperty(exports, "SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL", { enumerable: true, get: function () { return computeBudget_js_1.SHIELD_COMPUTE_UNITS_MEASURED_TYPICAL; } });
63
- Object.defineProperty(exports, "MAX_TRANSACTION_BYTES", { enumerable: true, get: function () { return computeBudget_js_1.MAX_TRANSACTION_BYTES; } });
64
- Object.defineProperty(exports, "SIGNATURE_BYTES", { enumerable: true, get: function () { return computeBudget_js_1.SIGNATURE_BYTES; } });
65
- Object.defineProperty(exports, "TRANSACT_INSTRUCTION_DATA_BYTES", { enumerable: true, get: function () { return computeBudget_js_1.TRANSACT_INSTRUCTION_DATA_BYTES; } });
66
- Object.defineProperty(exports, "NULLIFIER_MARKER_ACCOUNT_BYTES", { enumerable: true, get: function () { return computeBudget_js_1.NULLIFIER_MARKER_ACCOUNT_BYTES; } });
67
- Object.defineProperty(exports, "NULLIFIER_MARKERS_PER_TRANSACT", { enumerable: true, get: function () { return computeBudget_js_1.NULLIFIER_MARKERS_PER_TRANSACT; } });
68
- Object.defineProperty(exports, "DEFAULT_DEADLINE_SECONDS", { enumerable: true, get: function () { return computeBudget_js_1.DEFAULT_DEADLINE_SECONDS; } });
@@ -1,54 +0,0 @@
1
- import { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
- import type { TransactionProofStruct } from "../proof.js";
3
- /**
4
- * `transact` instruction assembly, driven by the IDL rather than by a
5
- * hand-written account list.
6
- *
7
- * Every existing deposit implementation spells out all sixteen accounts by hand
8
- * in an `accountsStrict({...})` literal. That works until the IDL changes, at
9
- * which point a silently misordered or missing account produces a runtime
10
- * failure that is very hard to trace. Here the account list and the ordering
11
- * come from the IDL itself, and an unresolved name throws at build time.
12
- *
13
- * Building the instruction directly also means no Anchor `Provider` and no
14
- * `Wallet` — which is the whole point of a wallet-agnostic shield.
15
- */
16
- /** Account names the IDL declares for `transact`, in order. */
17
- export type TransactAccounts = Record<string, PublicKey>;
18
- export type TransactArgs = {
19
- root: Uint8Array;
20
- inputTreeId: number;
21
- outputTreeId: number;
22
- publicAmount: bigint;
23
- extDataHash: Uint8Array;
24
- mintAddress: PublicKey;
25
- inputNullifiers: [Uint8Array, Uint8Array];
26
- outputCommitments: [Uint8Array, Uint8Array];
27
- deadline: bigint;
28
- extData: {
29
- recipient: PublicKey;
30
- relayer: PublicKey;
31
- fee: bigint;
32
- refund: bigint;
33
- claimant: PublicKey;
34
- };
35
- proof: TransactionProofStruct;
36
- noteCiphers: {
37
- note0EphemeralKey: Uint8Array;
38
- note0Encrypted: Uint8Array;
39
- note0ViewTag: number;
40
- note1EphemeralKey: Uint8Array;
41
- note1Encrypted: Uint8Array;
42
- note1ViewTag: number;
43
- } | null;
44
- };
45
- /** Account names in IDL order. Exported so callers can see what must be resolved. */
46
- export declare const TRANSACT_ACCOUNT_NAMES: string[];
47
- /**
48
- * Build the `transact` instruction.
49
- *
50
- * @throws ShieldError('UNRESOLVED_ACCOUNT') if the IDL declares an account the
51
- * caller did not supply — a loud failure is the point, because the
52
- * alternative is a misordered account list that fails opaquely on-chain.
53
- */
54
- export declare function buildTransactInstruction(accounts: TransactAccounts, args: TransactArgs, programId?: PublicKey): TransactionInstruction;