@unionlabs/payments 0.1.0 → 0.2.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 (393) hide show
  1. package/Abi/package.json +6 -0
  2. package/Attestor/package.json +6 -0
  3. package/Constants/package.json +6 -0
  4. package/Domain/package.json +6 -0
  5. package/Error/package.json +6 -0
  6. package/EvmPublicClient/package.json +6 -0
  7. package/EvmWalletClient/package.json +6 -0
  8. package/Payment/package.json +6 -0
  9. package/PaymentError/package.json +6 -0
  10. package/Prover/package.json +6 -0
  11. package/PublicClient/package.json +6 -0
  12. package/README.md +1 -0
  13. package/Schema/package.json +6 -0
  14. package/Utils/package.json +6 -0
  15. package/WalletClient/package.json +6 -0
  16. package/attestation/package.json +6 -0
  17. package/cli/commands/balance/package.json +6 -0
  18. package/cli/commands/deposit/package.json +6 -0
  19. package/cli/commands/export-verifier/package.json +6 -0
  20. package/cli/commands/generate/package.json +6 -0
  21. package/cli/commands/history/package.json +6 -0
  22. package/cli/commands/prove/package.json +6 -0
  23. package/cli/commands/redeem/package.json +6 -0
  24. package/cli/commands/update-client/package.json +6 -0
  25. package/cli/config/package.json +6 -0
  26. package/cli/package.json +6 -0
  27. package/cli/utils/package.json +6 -0
  28. package/constants/ibc-core-registry/package.json +6 -0
  29. package/constants/services/package.json +6 -0
  30. package/constants/z-asset-registry/package.json +6 -0
  31. package/dist/cjs/Abi.js +270 -0
  32. package/dist/cjs/Abi.js.map +1 -0
  33. package/dist/cjs/Attestor.js +76 -0
  34. package/dist/cjs/Attestor.js.map +1 -0
  35. package/dist/cjs/Constants.js +8 -0
  36. package/dist/cjs/Constants.js.map +1 -0
  37. package/dist/cjs/Domain.js +24 -0
  38. package/dist/cjs/Domain.js.map +1 -0
  39. package/dist/cjs/Error.js +100 -0
  40. package/dist/cjs/Error.js.map +1 -0
  41. package/dist/cjs/EvmPublicClient.js +301 -0
  42. package/dist/cjs/EvmPublicClient.js.map +1 -0
  43. package/dist/cjs/EvmWalletClient.js +670 -0
  44. package/dist/cjs/EvmWalletClient.js.map +1 -0
  45. package/dist/cjs/Payment.js +333 -0
  46. package/dist/cjs/Payment.js.map +1 -0
  47. package/dist/cjs/PaymentError.js +32 -0
  48. package/dist/cjs/PaymentError.js.map +1 -0
  49. package/dist/cjs/Prover.js +153 -0
  50. package/dist/cjs/Prover.js.map +1 -0
  51. package/dist/cjs/PublicClient.js +39 -0
  52. package/dist/cjs/PublicClient.js.map +1 -0
  53. package/dist/cjs/Schema.js +38 -0
  54. package/dist/cjs/Schema.js.map +1 -0
  55. package/dist/cjs/Utils.js +33 -0
  56. package/dist/cjs/Utils.js.map +1 -0
  57. package/dist/cjs/WalletClient.js +39 -0
  58. package/dist/cjs/WalletClient.js.map +1 -0
  59. package/dist/cjs/attestation.js +49 -0
  60. package/dist/cjs/attestation.js.map +1 -0
  61. package/dist/cjs/cli/commands/balance.js +60 -0
  62. package/dist/cjs/cli/commands/balance.js.map +1 -0
  63. package/dist/cjs/cli/commands/deposit.js +58 -0
  64. package/dist/cjs/cli/commands/deposit.js.map +1 -0
  65. package/dist/cjs/cli/commands/export-verifier.js +27 -0
  66. package/dist/cjs/cli/commands/export-verifier.js.map +1 -0
  67. package/dist/cjs/cli/commands/generate.js +41 -0
  68. package/dist/cjs/cli/commands/generate.js.map +1 -0
  69. package/dist/cjs/cli/commands/history.js +59 -0
  70. package/dist/cjs/cli/commands/history.js.map +1 -0
  71. package/dist/cjs/cli/commands/prove.js +82 -0
  72. package/dist/cjs/cli/commands/prove.js.map +1 -0
  73. package/dist/cjs/cli/commands/redeem.js +152 -0
  74. package/dist/cjs/cli/commands/redeem.js.map +1 -0
  75. package/dist/cjs/cli/commands/update-client.js +62 -0
  76. package/dist/cjs/cli/commands/update-client.js.map +1 -0
  77. package/dist/cjs/cli/config.js +32 -0
  78. package/dist/cjs/cli/config.js.map +1 -0
  79. package/dist/cjs/cli/utils.js +108 -0
  80. package/dist/cjs/cli/utils.js.map +1 -0
  81. package/dist/cjs/cli.js +24 -0
  82. package/dist/cjs/cli.js.map +1 -0
  83. package/dist/cjs/constants/ibc-core-registry.js +30 -0
  84. package/dist/cjs/constants/ibc-core-registry.js.map +1 -0
  85. package/dist/cjs/constants/services.js +9 -0
  86. package/dist/cjs/constants/services.js.map +1 -0
  87. package/dist/cjs/constants/z-asset-registry.js +32 -0
  88. package/dist/cjs/constants/z-asset-registry.js.map +1 -0
  89. package/dist/cjs/gen/prover_pb.js +81 -0
  90. package/dist/cjs/gen/prover_pb.js.map +1 -0
  91. package/dist/cjs/index.js +32 -0
  92. package/dist/cjs/index.js.map +1 -0
  93. package/dist/cjs/internal/evm.js +191 -0
  94. package/dist/cjs/internal/evm.js.map +1 -0
  95. package/dist/cjs/internal/evmWalletClient.js +6 -0
  96. package/dist/cjs/internal/evmWalletClient.js.map +1 -0
  97. package/dist/cjs/internal/publicClient.js +49 -0
  98. package/dist/cjs/internal/publicClient.js.map +1 -0
  99. package/dist/cjs/internal/walletClient.js +43 -0
  100. package/dist/cjs/internal/walletClient.js.map +1 -0
  101. package/dist/cjs/legacy/client.js +1222 -0
  102. package/dist/cjs/legacy/client.js.map +1 -0
  103. package/dist/cjs/legacy/prover.js +112 -0
  104. package/dist/cjs/legacy/prover.js.map +1 -0
  105. package/dist/cjs/poseidon2.js +226 -0
  106. package/dist/cjs/poseidon2.js.map +1 -0
  107. package/dist/cjs/promises/Attestor.js +23 -0
  108. package/dist/cjs/promises/Attestor.js.map +1 -0
  109. package/dist/cjs/promises/EvmPublicClient.js +34 -0
  110. package/dist/cjs/promises/EvmPublicClient.js.map +1 -0
  111. package/dist/cjs/promises/EvmWalletClient.js +51 -0
  112. package/dist/cjs/promises/EvmWalletClient.js.map +1 -0
  113. package/dist/cjs/promises/Payment.js +22 -0
  114. package/dist/cjs/promises/Payment.js.map +1 -0
  115. package/dist/cjs/promises/Prover.js +26 -0
  116. package/dist/cjs/promises/Prover.js.map +1 -0
  117. package/dist/cjs/promises/PublicClient.js +53 -0
  118. package/dist/cjs/promises/PublicClient.js.map +1 -0
  119. package/dist/cjs/promises/WalletClient.js +44 -0
  120. package/dist/cjs/promises/WalletClient.js.map +1 -0
  121. package/dist/cjs/promises/index.js +22 -0
  122. package/dist/cjs/promises/index.js.map +1 -0
  123. package/dist/cjs/rpc.js +867 -0
  124. package/dist/cjs/rpc.js.map +1 -0
  125. package/dist/cjs/types.js +6 -0
  126. package/dist/cjs/types.js.map +1 -0
  127. package/dist/dts/Abi.d.ts +220 -0
  128. package/dist/dts/Abi.d.ts.map +1 -0
  129. package/dist/dts/Attestor.d.ts +42 -0
  130. package/dist/dts/Attestor.d.ts.map +1 -0
  131. package/dist/dts/Constants.d.ts +3 -0
  132. package/dist/dts/Constants.d.ts.map +1 -0
  133. package/dist/dts/Domain.d.ts +141 -0
  134. package/dist/dts/Domain.d.ts.map +1 -0
  135. package/dist/dts/Error.d.ts +102 -0
  136. package/dist/dts/Error.d.ts.map +1 -0
  137. package/dist/dts/EvmPublicClient.d.ts +61 -0
  138. package/dist/dts/EvmPublicClient.d.ts.map +1 -0
  139. package/dist/dts/EvmWalletClient.d.ts +67 -0
  140. package/dist/dts/EvmWalletClient.d.ts.map +1 -0
  141. package/dist/dts/Payment.d.ts +128 -0
  142. package/dist/dts/Payment.d.ts.map +1 -0
  143. package/dist/dts/PaymentError.d.ts +21 -0
  144. package/dist/dts/PaymentError.d.ts.map +1 -0
  145. package/dist/dts/Prover.d.ts +87 -0
  146. package/dist/dts/Prover.d.ts.map +1 -0
  147. package/dist/dts/PublicClient.d.ts +146 -0
  148. package/dist/dts/PublicClient.d.ts.map +1 -0
  149. package/dist/dts/Schema.d.ts +16 -0
  150. package/dist/dts/Schema.d.ts.map +1 -0
  151. package/dist/dts/Utils.d.ts +11 -0
  152. package/dist/dts/Utils.d.ts.map +1 -0
  153. package/dist/dts/WalletClient.d.ts +123 -0
  154. package/dist/dts/WalletClient.d.ts.map +1 -0
  155. package/dist/dts/attestation.d.ts +13 -0
  156. package/dist/dts/attestation.d.ts.map +1 -0
  157. package/dist/dts/cli/commands/balance.d.ts +3 -0
  158. package/dist/dts/cli/commands/balance.d.ts.map +1 -0
  159. package/dist/dts/cli/commands/deposit.d.ts +3 -0
  160. package/dist/dts/cli/commands/deposit.d.ts.map +1 -0
  161. package/dist/dts/cli/commands/export-verifier.d.ts +3 -0
  162. package/dist/dts/cli/commands/export-verifier.d.ts.map +1 -0
  163. package/dist/dts/cli/commands/generate.d.ts +3 -0
  164. package/dist/dts/cli/commands/generate.d.ts.map +1 -0
  165. package/dist/dts/cli/commands/history.d.ts +3 -0
  166. package/dist/dts/cli/commands/history.d.ts.map +1 -0
  167. package/dist/dts/cli/commands/prove.d.ts +3 -0
  168. package/dist/dts/cli/commands/prove.d.ts.map +1 -0
  169. package/dist/dts/cli/commands/redeem.d.ts +3 -0
  170. package/dist/dts/cli/commands/redeem.d.ts.map +1 -0
  171. package/dist/dts/cli/commands/update-client.d.ts +3 -0
  172. package/dist/dts/cli/commands/update-client.d.ts.map +1 -0
  173. package/dist/dts/cli/config.d.ts +14 -0
  174. package/dist/dts/cli/config.d.ts.map +1 -0
  175. package/dist/dts/cli/utils.d.ts +11 -0
  176. package/dist/dts/cli/utils.d.ts.map +1 -0
  177. package/dist/dts/cli.d.ts +3 -0
  178. package/dist/dts/cli.d.ts.map +1 -0
  179. package/dist/dts/constants/ibc-core-registry.d.ts +11 -0
  180. package/dist/dts/constants/ibc-core-registry.d.ts.map +1 -0
  181. package/dist/dts/constants/services.d.ts +3 -0
  182. package/dist/dts/constants/services.d.ts.map +1 -0
  183. package/dist/dts/constants/z-asset-registry.d.ts +13 -0
  184. package/dist/dts/constants/z-asset-registry.d.ts.map +1 -0
  185. package/dist/dts/gen/prover_pb.d.ts +300 -0
  186. package/dist/dts/gen/prover_pb.d.ts.map +1 -0
  187. package/dist/dts/index.d.ts +21 -0
  188. package/dist/dts/index.d.ts.map +1 -0
  189. package/dist/dts/internal/evm.d.ts +250 -0
  190. package/dist/dts/internal/evm.d.ts.map +1 -0
  191. package/dist/dts/internal/evmWalletClient.d.ts +2 -0
  192. package/dist/dts/internal/evmWalletClient.d.ts.map +1 -0
  193. package/dist/dts/internal/publicClient.d.ts +2 -0
  194. package/dist/dts/internal/publicClient.d.ts.map +1 -0
  195. package/dist/dts/internal/walletClient.d.ts +2 -0
  196. package/dist/dts/internal/walletClient.d.ts.map +1 -0
  197. package/dist/dts/legacy/client.d.ts +313 -0
  198. package/dist/dts/legacy/client.d.ts.map +1 -0
  199. package/dist/dts/legacy/prover.d.ts +30 -0
  200. package/dist/dts/legacy/prover.d.ts.map +1 -0
  201. package/dist/dts/poseidon2.d.ts +18 -0
  202. package/dist/dts/poseidon2.d.ts.map +1 -0
  203. package/dist/dts/promises/Attestor.d.ts +17 -0
  204. package/dist/dts/promises/Attestor.d.ts.map +1 -0
  205. package/dist/dts/promises/EvmPublicClient.d.ts +3709 -0
  206. package/dist/dts/promises/EvmPublicClient.d.ts.map +1 -0
  207. package/dist/dts/promises/EvmWalletClient.d.ts +4502 -0
  208. package/dist/dts/promises/EvmWalletClient.d.ts.map +1 -0
  209. package/dist/dts/promises/Payment.d.ts +33 -0
  210. package/dist/dts/promises/Payment.d.ts.map +1 -0
  211. package/dist/dts/promises/Prover.d.ts +14 -0
  212. package/dist/dts/promises/Prover.d.ts.map +1 -0
  213. package/dist/dts/promises/PublicClient.d.ts +23 -0
  214. package/dist/dts/promises/PublicClient.d.ts.map +1 -0
  215. package/dist/dts/promises/WalletClient.d.ts +57 -0
  216. package/dist/dts/promises/WalletClient.d.ts.map +1 -0
  217. package/dist/dts/promises/index.d.ts +8 -0
  218. package/dist/dts/promises/index.d.ts.map +1 -0
  219. package/dist/dts/rpc.d.ts +148 -0
  220. package/dist/dts/rpc.d.ts.map +1 -0
  221. package/dist/dts/types.d.ts +263 -0
  222. package/dist/dts/types.d.ts.map +1 -0
  223. package/dist/esm/Abi.js +264 -0
  224. package/dist/esm/Abi.js.map +1 -0
  225. package/dist/esm/Attestor.js +68 -0
  226. package/dist/esm/Attestor.js.map +1 -0
  227. package/dist/esm/Constants.js +2 -0
  228. package/dist/esm/Constants.js.map +1 -0
  229. package/dist/esm/Domain.js +17 -0
  230. package/dist/esm/Domain.js.map +1 -0
  231. package/dist/esm/Error.js +89 -0
  232. package/dist/esm/Error.js.map +1 -0
  233. package/dist/esm/EvmPublicClient.js +292 -0
  234. package/dist/esm/EvmPublicClient.js.map +1 -0
  235. package/dist/esm/EvmWalletClient.js +659 -0
  236. package/dist/esm/EvmWalletClient.js.map +1 -0
  237. package/dist/esm/Payment.js +323 -0
  238. package/dist/esm/Payment.js.map +1 -0
  239. package/dist/esm/PaymentError.js +24 -0
  240. package/dist/esm/PaymentError.js.map +1 -0
  241. package/dist/esm/Prover.js +142 -0
  242. package/dist/esm/Prover.js.map +1 -0
  243. package/dist/esm/PublicClient.js +30 -0
  244. package/dist/esm/PublicClient.js.map +1 -0
  245. package/dist/esm/Schema.js +31 -0
  246. package/dist/esm/Schema.js.map +1 -0
  247. package/dist/esm/Utils.js +27 -0
  248. package/dist/esm/Utils.js.map +1 -0
  249. package/dist/esm/WalletClient.js +30 -0
  250. package/dist/esm/WalletClient.js.map +1 -0
  251. package/dist/esm/attestation.js +42 -0
  252. package/dist/esm/attestation.js.map +1 -0
  253. package/dist/esm/cli/commands/balance.js +54 -0
  254. package/dist/esm/cli/commands/balance.js.map +1 -0
  255. package/dist/esm/cli/commands/deposit.js +52 -0
  256. package/dist/esm/cli/commands/deposit.js.map +1 -0
  257. package/dist/esm/cli/commands/export-verifier.js +21 -0
  258. package/dist/esm/cli/commands/export-verifier.js.map +1 -0
  259. package/dist/esm/cli/commands/generate.js +35 -0
  260. package/dist/esm/cli/commands/generate.js.map +1 -0
  261. package/dist/esm/cli/commands/history.js +53 -0
  262. package/dist/esm/cli/commands/history.js.map +1 -0
  263. package/dist/esm/cli/commands/prove.js +76 -0
  264. package/dist/esm/cli/commands/prove.js.map +1 -0
  265. package/dist/esm/cli/commands/redeem.js +146 -0
  266. package/dist/esm/cli/commands/redeem.js.map +1 -0
  267. package/dist/esm/cli/commands/update-client.js +56 -0
  268. package/dist/esm/cli/commands/update-client.js.map +1 -0
  269. package/dist/esm/cli/config.js +26 -0
  270. package/dist/esm/cli/config.js.map +1 -0
  271. package/dist/esm/cli/utils.js +94 -0
  272. package/dist/esm/cli/utils.js.map +1 -0
  273. package/dist/esm/cli.js +22 -0
  274. package/dist/esm/cli.js.map +1 -0
  275. package/dist/esm/constants/ibc-core-registry.js +21 -0
  276. package/dist/esm/constants/ibc-core-registry.js.map +1 -0
  277. package/dist/esm/constants/services.js +3 -0
  278. package/dist/esm/constants/services.js.map +1 -0
  279. package/dist/esm/constants/z-asset-registry.js +23 -0
  280. package/dist/esm/constants/z-asset-registry.js.map +1 -0
  281. package/dist/esm/gen/prover_pb.js +74 -0
  282. package/dist/esm/gen/prover_pb.js.map +1 -0
  283. package/dist/esm/index.js +22 -0
  284. package/dist/esm/index.js.map +1 -0
  285. package/dist/esm/internal/evm.js +169 -0
  286. package/dist/esm/internal/evm.js.map +1 -0
  287. package/dist/esm/internal/evmWalletClient.js +2 -0
  288. package/dist/esm/internal/evmWalletClient.js.map +1 -0
  289. package/dist/esm/internal/publicClient.js +41 -0
  290. package/dist/esm/internal/publicClient.js.map +1 -0
  291. package/dist/esm/internal/walletClient.js +35 -0
  292. package/dist/esm/internal/walletClient.js.map +1 -0
  293. package/dist/esm/legacy/client.js +1212 -0
  294. package/dist/esm/legacy/client.js.map +1 -0
  295. package/dist/esm/legacy/prover.js +105 -0
  296. package/dist/esm/legacy/prover.js.map +1 -0
  297. package/dist/esm/package.json +4 -0
  298. package/dist/esm/poseidon2.js +218 -0
  299. package/dist/esm/poseidon2.js.map +1 -0
  300. package/dist/esm/promises/Attestor.js +14 -0
  301. package/dist/esm/promises/Attestor.js.map +1 -0
  302. package/dist/esm/promises/EvmPublicClient.js +26 -0
  303. package/dist/esm/promises/EvmPublicClient.js.map +1 -0
  304. package/dist/esm/promises/EvmWalletClient.js +43 -0
  305. package/dist/esm/promises/EvmWalletClient.js.map +1 -0
  306. package/dist/esm/promises/Payment.js +13 -0
  307. package/dist/esm/promises/Payment.js.map +1 -0
  308. package/dist/esm/promises/Prover.js +17 -0
  309. package/dist/esm/promises/Prover.js.map +1 -0
  310. package/dist/esm/promises/PublicClient.js +45 -0
  311. package/dist/esm/promises/PublicClient.js.map +1 -0
  312. package/dist/esm/promises/WalletClient.js +36 -0
  313. package/dist/esm/promises/WalletClient.js.map +1 -0
  314. package/dist/esm/promises/index.js +8 -0
  315. package/dist/esm/promises/index.js.map +1 -0
  316. package/dist/esm/rpc.js +850 -0
  317. package/dist/esm/rpc.js.map +1 -0
  318. package/dist/esm/types.js +2 -0
  319. package/dist/esm/types.js.map +1 -0
  320. package/gen/prover_pb/package.json +6 -0
  321. package/index/package.json +6 -0
  322. package/legacy/client/package.json +6 -0
  323. package/legacy/prover/package.json +6 -0
  324. package/package.json +397 -44
  325. package/poseidon2/package.json +6 -0
  326. package/promises/Attestor/package.json +6 -0
  327. package/promises/EvmPublicClient/package.json +6 -0
  328. package/promises/EvmWalletClient/package.json +6 -0
  329. package/promises/Payment/package.json +6 -0
  330. package/promises/Prover/package.json +6 -0
  331. package/promises/PublicClient/package.json +6 -0
  332. package/promises/WalletClient/package.json +6 -0
  333. package/promises/index/package.json +6 -0
  334. package/promises/package.json +6 -0
  335. package/rpc/package.json +6 -0
  336. package/src/Abi.ts +195 -0
  337. package/src/Attestor.ts +113 -0
  338. package/src/Constants.ts +4 -0
  339. package/src/Domain.ts +52 -0
  340. package/src/Error.ts +163 -0
  341. package/src/EvmPublicClient.ts +549 -0
  342. package/src/EvmWalletClient.ts +1034 -0
  343. package/src/Payment.ts +523 -0
  344. package/src/PaymentError.ts +39 -0
  345. package/src/Prover.ts +240 -0
  346. package/src/PublicClient.ts +196 -0
  347. package/src/Schema.ts +36 -0
  348. package/src/Utils.ts +43 -0
  349. package/src/WalletClient.ts +172 -0
  350. package/src/attestation.ts +69 -0
  351. package/src/cli/commands/balance.ts +88 -0
  352. package/src/cli/commands/deposit.ts +104 -0
  353. package/src/cli/commands/export-verifier.ts +28 -0
  354. package/src/cli/commands/generate.ts +86 -0
  355. package/src/cli/commands/history.ts +91 -0
  356. package/src/cli/commands/prove.ts +133 -0
  357. package/src/cli/commands/redeem.ts +277 -0
  358. package/src/cli/commands/update-client.ts +96 -0
  359. package/src/cli/config.ts +55 -0
  360. package/src/cli/utils.ts +136 -0
  361. package/src/cli.ts +31 -0
  362. package/src/constants/ibc-core-registry.ts +44 -0
  363. package/src/constants/services.ts +4 -0
  364. package/src/constants/z-asset-registry.ts +47 -0
  365. package/src/gen/prover_pb.ts +375 -0
  366. package/src/index.ts +23 -0
  367. package/src/internal/evm.ts +361 -0
  368. package/src/internal/evmWalletClient.ts +0 -0
  369. package/src/internal/publicClient.ts +57 -0
  370. package/src/internal/walletClient.ts +50 -0
  371. package/src/legacy/client.ts +1652 -0
  372. package/src/legacy/prover.ts +135 -0
  373. package/src/poseidon2.ts +246 -0
  374. package/src/promises/Attestor.ts +25 -0
  375. package/src/promises/EvmPublicClient.ts +39 -0
  376. package/src/promises/EvmWalletClient.ts +63 -0
  377. package/src/promises/Payment.ts +86 -0
  378. package/src/promises/Prover.ts +26 -0
  379. package/src/promises/PublicClient.ts +47 -0
  380. package/src/promises/WalletClient.ts +38 -0
  381. package/src/promises/index.ts +7 -0
  382. package/src/rpc.ts +994 -0
  383. package/src/types.ts +281 -0
  384. package/types/package.json +6 -0
  385. package/dist/LICENSE +0 -1
  386. package/dist/chunk-37PNLRA6.js +0 -2418
  387. package/dist/cli.cjs +0 -3031
  388. package/dist/cli.js +0 -675
  389. package/dist/index.cjs +0 -2451
  390. package/dist/index.js +0 -1
  391. package/dist/package.json +0 -18
  392. package/dist/payments.d.ts +0 -835
  393. /package/{dist → src}/tsdoc-metadata.json +0 -0
@@ -0,0 +1,277 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { Command } from "commander";
3
+ import type { Chain } from "viem";
4
+ import { createWalletClient, http } from "viem";
5
+ import { privateKeyToAccount } from "viem/accounts";
6
+ import { arbitrum, base, mainnet, optimism, polygon } from "viem/chains";
7
+ import { AttestationClient } from "../../attestation.js";
8
+ import { UnionPrivatePayments } from "../../legacy/client.js";
9
+ import {
10
+ parseProofJson,
11
+ proofJsonToRedeemParams,
12
+ submitRedeem,
13
+ } from "../../rpc.js";
14
+ import type { LightClientData, ProofJSON } from "../../types.js";
15
+ import { loadConfig } from "../config.js";
16
+ import {
17
+ getExplorerUrl,
18
+ parseBeneficiaries,
19
+ parseClientIds,
20
+ validateAddress,
21
+ validateSecret,
22
+ } from "../utils.js";
23
+
24
+ interface ProofFileData {
25
+ proof: ProofJSON;
26
+ metadata: {
27
+ depositAddress: string;
28
+ beneficiary: string;
29
+ value: string;
30
+ nullifier: string;
31
+ lightClients: Array<{
32
+ clientId: number;
33
+ height: string;
34
+ stateRoot: string;
35
+ }>;
36
+ };
37
+ }
38
+
39
+ const CHAIN_MAP: Record<number, Chain> = {
40
+ 1: mainnet,
41
+ 8453: base,
42
+ 42161: arbitrum,
43
+ 10: optimism,
44
+ 137: polygon,
45
+ };
46
+
47
+ export const redeemCommand = new Command("redeem")
48
+ .description(
49
+ "Submit redemption transaction (with existing proof or generate on the fly)",
50
+ )
51
+ .option("--proof <file>", "Path to proof JSON file (from prove command)")
52
+ .option(
53
+ "--secret <hex>",
54
+ "32-byte secret (0x-prefixed hex) - required if no --proof",
55
+ )
56
+ .option(
57
+ "--beneficiaries <addresses>",
58
+ "Comma-separated beneficiary addresses for address derivation",
59
+ )
60
+ .option(
61
+ "--beneficiary <address>",
62
+ "Address to redeem to - required if no --proof",
63
+ )
64
+ .option(
65
+ "--amount <value>",
66
+ "Amount to redeem in smallest units - required if no --proof",
67
+ )
68
+ .option(
69
+ "--client-ids <ids>",
70
+ "Comma-separated light client IDs for anonymity set - required if no --proof",
71
+ )
72
+ .option(
73
+ "--selected-client <id>",
74
+ "Which client ID to use for proof - required if no --proof",
75
+ )
76
+ .option(
77
+ "--private-key <key>",
78
+ "Private key to send transaction (or env SENDER_PRIVATE_KEY)",
79
+ )
80
+ .option(
81
+ "--config <path>",
82
+ "Path to config file",
83
+ "./private-payments.config.json",
84
+ )
85
+ .action(async (options) => {
86
+ try {
87
+ const config = loadConfig(options.config);
88
+ const privateKey = options.privateKey ?? process.env.SENDER_PRIVATE_KEY;
89
+ if (!privateKey) {
90
+ throw new Error(
91
+ "Private key required. Use --private-key or set SENDER_PRIVATE_KEY env var",
92
+ );
93
+ }
94
+
95
+ if (!privateKey.startsWith("0x")) {
96
+ throw new Error("Private key must start with 0x");
97
+ }
98
+
99
+ if (!config.attestorUrl) {
100
+ throw new Error("attestorUrl required in config for redemption");
101
+ }
102
+
103
+ if (!config.attestorApiKey) {
104
+ throw new Error("attestorApiKey required in config for redemption");
105
+ }
106
+
107
+ let proofData: ProofFileData;
108
+
109
+ if (options.proof) {
110
+ // Mode 1: Load existing proof from file
111
+ const proofContent = readFileSync(options.proof, "utf-8");
112
+ proofData = JSON.parse(proofContent) as ProofFileData;
113
+ console.log("Loading proof from:", options.proof);
114
+ } else {
115
+ // Mode 2: Generate proof on the fly
116
+ if (
117
+ !options.secret ||
118
+ !options.beneficiary ||
119
+ !options.amount ||
120
+ !options.clientIds ||
121
+ !options.selectedClient
122
+ ) {
123
+ throw new Error(
124
+ "When not using --proof, you must provide: --secret, --beneficiary, --amount, --client-ids, --selected-client",
125
+ );
126
+ }
127
+
128
+ const secret = validateSecret(options.secret);
129
+ const beneficiaries = parseBeneficiaries(options.beneficiaries);
130
+ const beneficiary = validateAddress(options.beneficiary, "beneficiary");
131
+ const clientIds = parseClientIds(options.clientIds);
132
+ const selectedClientId = parseInt(options.selectedClient, 10);
133
+
134
+ if (isNaN(selectedClientId)) {
135
+ throw new Error("Invalid selected client ID");
136
+ }
137
+
138
+ if (!clientIds.includes(selectedClientId)) {
139
+ throw new Error(
140
+ `Selected client ${selectedClientId} not in client IDs: ${clientIds.join(", ")}`,
141
+ );
142
+ }
143
+
144
+ const client = new UnionPrivatePayments({
145
+ proverUrl: config.proverUrl,
146
+ sourceRpcUrl: config.sourceRpcUrl,
147
+ destinationRpcUrl: config.destinationRpcUrl,
148
+ srcZAssetAddress: config.srcZAssetAddress,
149
+ dstZAssetAddress: config.dstZAssetAddress,
150
+ sourceChainId: BigInt(config.sourceChainId),
151
+ destinationChainId: BigInt(config.destinationChainId),
152
+ });
153
+
154
+ const amount = BigInt(options.amount);
155
+
156
+ console.log("Generating proof...");
157
+ console.log(" Secret:", secret.slice(0, 10) + "...");
158
+ console.log(" Beneficiary:", beneficiary);
159
+ console.log(" Amount:", amount.toString());
160
+ console.log(" Client IDs:", clientIds.join(", "));
161
+ console.log(" Selected Client:", selectedClientId);
162
+
163
+ const result = await client.generateProof(
164
+ secret,
165
+ beneficiaries,
166
+ beneficiary,
167
+ amount,
168
+ clientIds,
169
+ selectedClientId,
170
+ );
171
+
172
+ if (
173
+ !result.proof.success ||
174
+ !result.proof.proofJson ||
175
+ !result.metadata
176
+ ) {
177
+ throw new Error(result.proof.error ?? "Proof generation failed");
178
+ }
179
+
180
+ console.log("Proof generated successfully!");
181
+
182
+ const proofJson = parseProofJson(result.proof.proofJson);
183
+ proofData = {
184
+ proof: proofJson,
185
+ metadata: {
186
+ depositAddress: result.metadata.depositAddress,
187
+ beneficiary: result.metadata.beneficiary,
188
+ value: result.metadata.value.toString(),
189
+ nullifier:
190
+ "0x" + result.metadata.nullifier.toString(16).padStart(64, "0"),
191
+ lightClients: result.metadata.lightClients.map((lc) => ({
192
+ clientId: lc.clientId,
193
+ height: lc.height.toString(),
194
+ stateRoot: lc.stateRoot,
195
+ })),
196
+ },
197
+ };
198
+ }
199
+
200
+ const lightClients: LightClientData[] =
201
+ proofData.metadata.lightClients.map((lc) => ({
202
+ clientId: lc.clientId,
203
+ height: BigInt(lc.height),
204
+ stateRoot: lc.stateRoot as `0x${string}`,
205
+ }));
206
+
207
+ const nullifier = BigInt(proofData.metadata.nullifier);
208
+ const value = BigInt(proofData.metadata.value);
209
+ const beneficiary = proofData.metadata.beneficiary as `0x${string}`;
210
+ const depositAddress = proofData.metadata.depositAddress as `0x${string}`;
211
+
212
+ console.log("");
213
+ console.log("Redemption details:");
214
+ console.log(" Deposit Address:", depositAddress);
215
+ console.log(" Beneficiary:", beneficiary);
216
+ console.log(" Value:", value.toString());
217
+ console.log(" Nullifier:", proofData.metadata.nullifier);
218
+ console.log(" Light Clients:", lightClients.length);
219
+
220
+ console.log("");
221
+ console.log("Requesting attestation...");
222
+ const attestationClient = new AttestationClient(
223
+ config.attestorUrl,
224
+ config.attestorApiKey,
225
+ );
226
+
227
+ const attestation = await attestationClient.getAttestation(
228
+ depositAddress,
229
+ beneficiary,
230
+ );
231
+ console.log(" Attested Message:", attestation.attestedMessage);
232
+ console.log(" Signature:", attestation.signature.slice(0, 20) + "...");
233
+
234
+ const redeemParams = proofJsonToRedeemParams(proofData.proof, {
235
+ lightClients,
236
+ nullifier,
237
+ value,
238
+ beneficiary,
239
+ attestedMessage: attestation.attestedMessage,
240
+ signature: attestation.signature,
241
+ });
242
+
243
+ const chain = CHAIN_MAP[config.destinationChainId];
244
+ if (!chain) {
245
+ throw new Error(
246
+ `Unsupported destination chain ID: ${config.destinationChainId}`,
247
+ );
248
+ }
249
+
250
+ // Create wallet client from private key
251
+ const account = privateKeyToAccount(privateKey as `0x${string}`);
252
+ const walletClient = createWalletClient({
253
+ account,
254
+ chain,
255
+ transport: http(config.destinationRpcUrl),
256
+ });
257
+
258
+ console.log("");
259
+ console.log("Submitting redeem transaction...");
260
+ const txHash = await submitRedeem(
261
+ config.dstZAssetAddress,
262
+ redeemParams,
263
+ walletClient,
264
+ );
265
+
266
+ console.log("");
267
+ console.log("Transaction submitted!");
268
+ console.log("Hash:", txHash);
269
+ console.log(
270
+ "Explorer:",
271
+ getExplorerUrl(config.destinationChainId, txHash),
272
+ );
273
+ } catch (e) {
274
+ console.error("Error:", (e as Error).message);
275
+ process.exit(1);
276
+ }
277
+ });
@@ -0,0 +1,96 @@
1
+ import { Command } from "commander";
2
+ import { type Chain, createPublicClient, createWalletClient, http } from "viem";
3
+ import { privateKeyToAccount } from "viem/accounts";
4
+ import { updateLoopbackClient } from "../../rpc.js";
5
+ import { getExplorerUrl } from "../utils.js";
6
+
7
+ export const updateClientCommand = new Command("update-client")
8
+ .description("Update loopback light client to a specific block height")
9
+ .requiredOption("--rpc <url>", "RPC URL for the chain")
10
+ .requiredOption("--client-id <id>", "Light client ID to update")
11
+ .option(
12
+ "--height <height>",
13
+ "Block height to update to (default: latest)",
14
+ "latest",
15
+ )
16
+ .requiredOption("--ibc-handler <address>", "IBCHandler contract address")
17
+ .option(
18
+ "--private-key <key>",
19
+ "Private key to send transaction (or env SENDER_PRIVATE_KEY)",
20
+ )
21
+ .action(async (options) => {
22
+ try {
23
+ const privateKey = options.privateKey ?? process.env.SENDER_PRIVATE_KEY;
24
+
25
+ if (!privateKey) {
26
+ throw new Error(
27
+ "Private key required. Use --private-key or set SENDER_PRIVATE_KEY env var",
28
+ );
29
+ }
30
+
31
+ if (!privateKey.startsWith("0x")) {
32
+ throw new Error("Private key must start with 0x");
33
+ }
34
+
35
+ const clientId = parseInt(options.clientId, 10);
36
+ if (isNaN(clientId)) {
37
+ throw new Error("Invalid client ID: must be a number");
38
+ }
39
+
40
+ const ibcHandlerAddress = options.ibcHandler as `0x${string}`;
41
+ if (
42
+ !ibcHandlerAddress.startsWith("0x") ||
43
+ ibcHandlerAddress.length !== 42
44
+ ) {
45
+ throw new Error("Invalid IBC handler address");
46
+ }
47
+
48
+ const height: bigint | "latest" =
49
+ options.height === "latest" ? "latest" : BigInt(options.height);
50
+
51
+ // Get chain ID from RPC first
52
+ const publicClient = createPublicClient({
53
+ transport: http(options.rpc),
54
+ });
55
+ const chainId = await publicClient.getChainId();
56
+
57
+ // Create wallet client from private key
58
+ const account = privateKeyToAccount(privateKey as `0x${string}`);
59
+ const walletClient = createWalletClient({
60
+ account,
61
+ chain: { id: chainId } as Chain,
62
+ transport: http(options.rpc),
63
+ });
64
+
65
+ console.log("Updating loopback light client...");
66
+ console.log(" RPC:", options.rpc);
67
+ console.log(" IBC Handler:", ibcHandlerAddress);
68
+ console.log(" Client ID:", clientId);
69
+ console.log(
70
+ " Height:",
71
+ height === "latest" ? "latest" : height.toString(),
72
+ );
73
+ console.log("");
74
+
75
+ const result = await updateLoopbackClient(
76
+ options.rpc,
77
+ ibcHandlerAddress,
78
+ clientId,
79
+ height,
80
+ walletClient,
81
+ );
82
+
83
+ console.log("Light client updated successfully!");
84
+ console.log(" Chain ID:", result.chainId.toString());
85
+ console.log(" Block Number:", result.blockNumber.toString());
86
+ console.log(" State Root:", result.stateRoot);
87
+ console.log(" Transaction:", result.txHash);
88
+ console.log(
89
+ " Explorer:",
90
+ getExplorerUrl(Number(result.chainId), result.txHash),
91
+ );
92
+ } catch (e) {
93
+ console.error("Error:", (e as Error).message);
94
+ process.exit(1);
95
+ }
96
+ });
@@ -0,0 +1,55 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import type { Address } from "viem";
3
+
4
+ export interface CliConfig {
5
+ proverUrl: string;
6
+ sourceRpcUrl: string;
7
+ destinationRpcUrl: string;
8
+ srcZAssetAddress: Address;
9
+ dstZAssetAddress: Address;
10
+ sourceChainId: number;
11
+ destinationChainId: number;
12
+ attestorUrl?: string;
13
+ attestorApiKey?: string;
14
+ }
15
+
16
+ const DEFAULT_CONFIG_PATH = "./private-payments.config.json";
17
+
18
+ export function loadConfig(configPath?: string): CliConfig {
19
+ const path = configPath ?? DEFAULT_CONFIG_PATH;
20
+
21
+ if (!existsSync(path)) {
22
+ throw new Error(
23
+ `Config file not found: ${path}\nCreate a private-payments.config.json file or specify --config <path>`,
24
+ );
25
+ }
26
+
27
+ try {
28
+ const content = readFileSync(path, "utf-8");
29
+ const config = JSON.parse(content) as CliConfig;
30
+
31
+ // Validate required fields
32
+ const required: (keyof CliConfig)[] = [
33
+ "proverUrl",
34
+ "sourceRpcUrl",
35
+ "destinationRpcUrl",
36
+ "srcZAssetAddress",
37
+ "dstZAssetAddress",
38
+ "sourceChainId",
39
+ "destinationChainId",
40
+ ];
41
+
42
+ for (const field of required) {
43
+ if (config[field] === undefined) {
44
+ throw new Error(`Missing required field in config: ${field}`);
45
+ }
46
+ }
47
+
48
+ return config;
49
+ } catch (e) {
50
+ if (e instanceof SyntaxError) {
51
+ throw new Error(`Invalid JSON in config file: ${path}`);
52
+ }
53
+ throw e;
54
+ }
55
+ }
@@ -0,0 +1,136 @@
1
+ import type { Address, Hex } from "viem";
2
+
3
+ const ZERO_ADDRESS: Address = "0x0000000000000000000000000000000000000000";
4
+
5
+ export function parseBeneficiaries(input: string | undefined): Address[] {
6
+ if (!input || input.trim() === "") {
7
+ return [];
8
+ }
9
+
10
+ const addresses = input
11
+ .split(",")
12
+ .map((s) => s.trim().toLowerCase() as Address);
13
+
14
+ if (addresses.length > 4) {
15
+ throw new Error("Maximum 4 beneficiaries allowed");
16
+ }
17
+
18
+ for (const addr of addresses) {
19
+ if (!isValidAddress(addr)) {
20
+ throw new Error(`Invalid address: ${addr}`);
21
+ }
22
+ }
23
+
24
+ return addresses;
25
+ }
26
+
27
+ export function padBeneficiaries(
28
+ beneficiaries: Address[],
29
+ ): [Address, Address, Address, Address] {
30
+ return [
31
+ beneficiaries[0] ?? ZERO_ADDRESS,
32
+ beneficiaries[1] ?? ZERO_ADDRESS,
33
+ beneficiaries[2] ?? ZERO_ADDRESS,
34
+ beneficiaries[3] ?? ZERO_ADDRESS,
35
+ ];
36
+ }
37
+
38
+ export function parseClientIds(input: string): number[] {
39
+ const ids = input.split(",").map((s) => {
40
+ const id = parseInt(s.trim(), 10);
41
+ if (isNaN(id) || id < 0) {
42
+ throw new Error(`Invalid client ID: ${s}`);
43
+ }
44
+ return id;
45
+ });
46
+
47
+ if (ids.length === 0) {
48
+ throw new Error("At least one client ID is required");
49
+ }
50
+
51
+ return ids;
52
+ }
53
+
54
+ export function validateSecret(secret: string): Hex {
55
+ if (!secret.startsWith("0x")) {
56
+ throw new Error("Secret must start with 0x");
57
+ }
58
+
59
+ if (secret.length !== 66) {
60
+ throw new Error("Secret must be 32 bytes (66 characters with 0x prefix)");
61
+ }
62
+
63
+ if (!/^0x[0-9a-fA-F]{64}$/.test(secret)) {
64
+ throw new Error("Secret must be a valid hex string");
65
+ }
66
+
67
+ return secret.toLowerCase() as Hex;
68
+ }
69
+
70
+ export function isValidAddress(address: string): address is Address {
71
+ return /^0x[0-9a-fA-F]{40}$/.test(address);
72
+ }
73
+
74
+ export function validateAddress(address: string, name: string): Address {
75
+ if (!isValidAddress(address)) {
76
+ throw new Error(`Invalid ${name} address: ${address}`);
77
+ }
78
+ return address.toLowerCase() as Address;
79
+ }
80
+
81
+ export function formatAmount(
82
+ amount: bigint,
83
+ decimals: number,
84
+ symbol?: string,
85
+ ): string {
86
+ const divisor = 10n ** BigInt(decimals);
87
+ const whole = amount / divisor;
88
+ const fraction = amount % divisor;
89
+ const fractionStr = fraction.toString().padStart(decimals, "0");
90
+
91
+ const trimmedFraction = fractionStr.replace(/0+$/, "");
92
+ const formatted = trimmedFraction
93
+ ? `${whole}.${trimmedFraction}`
94
+ : whole.toString();
95
+
96
+ return symbol ? `${formatted} ${symbol}` : formatted;
97
+ }
98
+
99
+ export function parseAmount(input: string, decimals: number): bigint {
100
+ const parts = input.split(".");
101
+ if (parts.length > 2) {
102
+ throw new Error(`Invalid amount: ${input}`);
103
+ }
104
+
105
+ const whole = parts[0] ?? "0";
106
+ let fraction = parts[1] ?? "";
107
+
108
+ if (fraction.length > decimals) {
109
+ fraction = fraction.slice(0, decimals);
110
+ } else {
111
+ fraction = fraction.padEnd(decimals, "0");
112
+ }
113
+
114
+ const wholeBigInt = BigInt(whole);
115
+ const fractionBigInt = BigInt(fraction);
116
+ const divisor = 10n ** BigInt(decimals);
117
+
118
+ return wholeBigInt * divisor + fractionBigInt;
119
+ }
120
+
121
+ export function getExplorerUrl(chainId: number, txHash: string): string {
122
+ const explorers: Record<number, string> = {
123
+ 1: "https://etherscan.io",
124
+ 8453: "https://basescan.org",
125
+ 42161: "https://arbiscan.io",
126
+ 10: "https://optimistic.etherscan.io",
127
+ 137: "https://polygonscan.com",
128
+ };
129
+
130
+ const explorer = explorers[chainId];
131
+ if (explorer) {
132
+ return `${explorer}/tx/${txHash}`;
133
+ }
134
+
135
+ return txHash;
136
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+ import { balanceCommand } from "./cli/commands/balance.js";
5
+ import { depositCommand } from "./cli/commands/deposit.js";
6
+ import { exportVerifierCommand } from "./cli/commands/export-verifier.js";
7
+ import { generateCommand } from "./cli/commands/generate.js";
8
+ import { historyCommand } from "./cli/commands/history.js";
9
+ import { proveCommand } from "./cli/commands/prove.js";
10
+ import { redeemCommand } from "./cli/commands/redeem.js";
11
+ import { updateClientCommand } from "./cli/commands/update-client.js";
12
+
13
+ const program = new Command();
14
+
15
+ program
16
+ .name("payments")
17
+ .description(
18
+ "CLI for Union Private Payments - privacy-preserving transfers using ZK proofs",
19
+ )
20
+ .version("0.1.0");
21
+
22
+ program.addCommand(generateCommand);
23
+ program.addCommand(balanceCommand);
24
+ program.addCommand(proveCommand);
25
+ program.addCommand(redeemCommand);
26
+ program.addCommand(updateClientCommand);
27
+ program.addCommand(depositCommand);
28
+ program.addCommand(historyCommand);
29
+ program.addCommand(exportVerifierCommand);
30
+
31
+ program.parse();
@@ -0,0 +1,44 @@
1
+ import { type Brand, Effect, flow, Option } from "effect";
2
+ import * as Domain from "../Domain.js";
3
+ import * as Error from "../Error.js";
4
+
5
+ export type ZAssetAddress = `0x${string}` & Brand.Brand<"ZAssetAddress">;
6
+
7
+ export const IBC_CORE_REGISTRY: {
8
+ [chainId: string]: Domain.IbcHandlerAddress;
9
+ } = {
10
+ "8453": Domain.IbcHandlerAddress(
11
+ "0xee4ea8d358473f0fcebf0329feed95d56e8c04d7",
12
+ ),
13
+ } as const;
14
+
15
+ export function getIbcHandler(
16
+ chainId: bigint,
17
+ ): Option.Option<Domain.IbcHandlerAddress> {
18
+ return Option.fromNullable(IBC_CORE_REGISTRY[`${chainId}`]);
19
+ }
20
+
21
+ export const getIbcHandlerOrError = flow(
22
+ getIbcHandler,
23
+ Effect.mapError(
24
+ (cause) =>
25
+ new Error.SystemError({
26
+ module: "IbcCoreRegistry",
27
+ reason: "InvalidData",
28
+ method: "getIbcHandlerOrError",
29
+ cause,
30
+ }),
31
+ ),
32
+ );
33
+
34
+ export const getIbcHandlerOrThrow = flow(
35
+ getIbcHandler,
36
+ Option.getOrThrowWith(
37
+ () =>
38
+ new Error.SystemError({
39
+ module: "IbcCoreRegistry",
40
+ reason: "InvalidData",
41
+ method: "getIbcHandlerOrError",
42
+ }),
43
+ ),
44
+ );
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_PROVER_URL = "https://prover.payments.union.build";
2
+
3
+ export const DEFAULT_ATTESTOR_URL =
4
+ "https://attestor.payments.union.build/functions/v1/attest";
@@ -0,0 +1,47 @@
1
+ import { Effect, flow, Option } from "effect";
2
+ import type { Erc20Address } from "../Domain.js";
3
+ import * as Domain from "../Domain.js";
4
+ import * as Error from "../Error.js";
5
+
6
+ export const Z_ASSET_REGISTRY: {
7
+ [chainId: string]: {
8
+ [assetAddress: Erc20Address]: Domain.ZAssetAddress;
9
+ };
10
+ } = {
11
+ "8453": {
12
+ [Domain.Erc20Address("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")]:
13
+ Domain.ZAssetAddress("0xF0000101561619d8A61ABd045F47Af4f41Afe62D"),
14
+ },
15
+ } as const;
16
+
17
+ export function getZAsset(
18
+ chainId: bigint,
19
+ assetAddress: Erc20Address,
20
+ ): Option.Option<Domain.ZAssetAddress> {
21
+ return Option.fromNullable(Z_ASSET_REGISTRY[`${chainId}`]?.[assetAddress]);
22
+ }
23
+
24
+ export const getZAssetOrError = flow(
25
+ getZAsset,
26
+ Effect.mapError(
27
+ (cause) =>
28
+ new Error.SystemError({
29
+ method: "approveZAssetToSpendErc20",
30
+ module: "EvmWalletClient",
31
+ reason: "InvalidData",
32
+ cause,
33
+ }),
34
+ ),
35
+ );
36
+
37
+ export const getZAssetOrThrow = flow(
38
+ getZAsset,
39
+ Option.getOrThrowWith(
40
+ () =>
41
+ new Error.SystemError({
42
+ method: "approveZAssetToSpendErc20",
43
+ module: "EvmWalletClient",
44
+ reason: "InvalidData",
45
+ }),
46
+ ),
47
+ );