@crossmint/wallets-sdk 0.21.0 → 1.0.0-beta.3

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 (402) hide show
  1. package/README.md +6 -6
  2. package/dist/api/__tests__/constants.cjs +1 -31
  3. package/dist/api/__tests__/constants.d.cts +9 -1
  4. package/dist/api/__tests__/constants.d.ts +9 -1
  5. package/dist/api/__tests__/constants.js +1 -31
  6. package/dist/api/__tests__/test-utils.cjs +1 -372
  7. package/dist/api/__tests__/test-utils.d.cts +10 -4
  8. package/dist/api/__tests__/test-utils.d.ts +10 -4
  9. package/dist/api/__tests__/test-utils.js +1 -372
  10. package/dist/api/client.cjs +1 -10
  11. package/dist/api/client.d.cts +14 -6
  12. package/dist/api/client.d.ts +14 -6
  13. package/dist/api/client.js +1 -10
  14. package/dist/api/gen/client.gen.cjs +1 -7
  15. package/dist/api/gen/client.gen.js +1 -7
  16. package/dist/api/gen/index.cjs +1 -79
  17. package/dist/api/gen/index.d.cts +2 -2
  18. package/dist/api/gen/index.d.ts +2 -2
  19. package/dist/api/gen/index.js +1 -79
  20. package/dist/api/gen/sdk.gen.cjs +1 -78
  21. package/dist/api/gen/sdk.gen.d.cts +2 -9
  22. package/dist/api/gen/sdk.gen.d.ts +2 -9
  23. package/dist/api/gen/sdk.gen.js +1 -78
  24. package/dist/api/gen/types.gen.d.cts +593 -92
  25. package/dist/api/gen/types.gen.d.ts +593 -92
  26. package/dist/api/gen/types.gen.js +1 -1
  27. package/dist/api/index.cjs +1 -12
  28. package/dist/api/index.d.cts +7 -1
  29. package/dist/api/index.d.ts +7 -1
  30. package/dist/api/index.js +1 -12
  31. package/dist/api/types.d.cts +11 -55
  32. package/dist/api/types.d.ts +11 -55
  33. package/dist/api/types.js +1 -1
  34. package/dist/chains/chains.cjs +1 -24
  35. package/dist/chains/chains.d.cts +2 -1
  36. package/dist/chains/chains.d.ts +2 -1
  37. package/dist/chains/chains.js +1 -24
  38. package/dist/chains/definitions/arcTestnet.cjs +1 -7
  39. package/dist/chains/definitions/arcTestnet.js +1 -7
  40. package/dist/chains/definitions/story.cjs +1 -7
  41. package/dist/chains/definitions/story.js +1 -7
  42. package/dist/chains/definitions/storyTestnet.cjs +1 -7
  43. package/dist/chains/definitions/storyTestnet.js +1 -7
  44. package/dist/chains/definitions/tempo.cjs +1 -7
  45. package/dist/chains/definitions/tempo.js +1 -7
  46. package/dist/chains/definitions/tempoTestnet.cjs +1 -7
  47. package/dist/chains/definitions/tempoTestnet.js +1 -7
  48. package/dist/chunk-24JKRXBH.js +1 -0
  49. package/dist/chunk-2C3AOHCT.cjs +1 -0
  50. package/dist/chunk-2GKPWQBQ.cjs +1 -0
  51. package/dist/chunk-2JW6HKFK.js +1 -0
  52. package/dist/chunk-2RNAWXXS.js +1 -0
  53. package/dist/chunk-2YLRFJ66.js +1 -0
  54. package/dist/chunk-36OMUNL3.js +1 -0
  55. package/dist/chunk-3OGAQBMG.cjs +1 -0
  56. package/dist/chunk-3VYGTPRF.cjs +1 -0
  57. package/dist/chunk-4ADZVYB5.cjs +1 -0
  58. package/dist/chunk-4GTMI5ZT.js +1 -0
  59. package/dist/chunk-4JWRQRKA.cjs +1 -0
  60. package/dist/chunk-575WRSRN.js +1 -0
  61. package/dist/chunk-576HP23H.cjs +1 -0
  62. package/dist/chunk-5M7IRODB.js +1 -0
  63. package/dist/chunk-5QIW67NU.cjs +1 -0
  64. package/dist/chunk-5X4EOJFG.cjs +1 -0
  65. package/dist/chunk-6EZCCLTK.cjs +1 -0
  66. package/dist/chunk-6FGJ3ICD.js +1 -0
  67. package/dist/chunk-6MGMZ3SI.cjs +1 -0
  68. package/dist/chunk-6TYV7ADO.js +1 -0
  69. package/dist/chunk-7VUOD7EI.cjs +1 -0
  70. package/dist/chunk-A33BEWR7.cjs +1 -0
  71. package/dist/chunk-CUHDOBKN.cjs +1 -0
  72. package/dist/chunk-DIGDDKSF.js +1 -0
  73. package/dist/chunk-E7B6R3GF.cjs +1 -0
  74. package/dist/chunk-EE4ITUGS.js +1 -0
  75. package/dist/chunk-EIHK5TYE.js +1 -0
  76. package/dist/chunk-ENU3EKBG.cjs +1 -0
  77. package/dist/chunk-EXC7TCGL.js +1 -0
  78. package/dist/chunk-F2KLBYRR.cjs +1 -0
  79. package/dist/chunk-FOINTZC5.cjs +1 -0
  80. package/dist/chunk-FT5EVMLB.js +1 -0
  81. package/dist/chunk-G5R6VQGJ.js +1 -0
  82. package/dist/chunk-GEY574TH.cjs +1 -0
  83. package/dist/chunk-GOXB2RBF.js +1 -0
  84. package/dist/chunk-HMELCNK6.js +1 -0
  85. package/dist/chunk-HRUMWG2F.cjs +1 -0
  86. package/dist/chunk-IOSADDL5.js +1 -0
  87. package/dist/chunk-IR5WN6FQ.cjs +1 -0
  88. package/dist/chunk-J33QM2ID.cjs +1 -0
  89. package/dist/chunk-J3R36SGJ.js +1 -0
  90. package/dist/chunk-JBP52JOH.cjs +1 -0
  91. package/dist/chunk-JDDMCB6P.js +1 -0
  92. package/dist/chunk-JDTKL2XR.js +1 -0
  93. package/dist/chunk-JINIR3YK.cjs +1 -0
  94. package/dist/chunk-JJ72GFYU.cjs +1 -0
  95. package/dist/chunk-JJMKQ5PK.cjs +1 -0
  96. package/dist/chunk-K5TQ4QU3.cjs +1 -0
  97. package/dist/chunk-KKQBZXFE.js +1 -0
  98. package/dist/chunk-KUP7H7X2.js +1 -0
  99. package/dist/chunk-LB4V5KKI.js +1 -0
  100. package/dist/chunk-LEALJLNK.js +1 -0
  101. package/dist/chunk-LZNQBJEK.cjs +1 -0
  102. package/dist/chunk-MMFZP54X.js +1 -0
  103. package/dist/chunk-MTK3HWXV.js +1 -0
  104. package/dist/chunk-N5WVT7QE.js +1 -0
  105. package/dist/chunk-NJWSHT2H.cjs +1 -0
  106. package/dist/chunk-NX256LAH.cjs +1 -0
  107. package/dist/chunk-O5D3H7CZ.cjs +1 -0
  108. package/dist/chunk-O6VBO7KG.js +1 -0
  109. package/dist/chunk-OQZTL6ZG.js +1 -0
  110. package/dist/chunk-PDHWPAGW.js +1 -0
  111. package/dist/chunk-PKYRYRX4.js +1 -0
  112. package/dist/chunk-QBS76CBT.cjs +1 -0
  113. package/dist/chunk-QY5OHQW4.cjs +1 -0
  114. package/dist/chunk-RBKG6QLZ.js +1 -0
  115. package/dist/chunk-RC6KDONJ.cjs +1 -0
  116. package/dist/chunk-RR6DWIRN.js +1 -0
  117. package/dist/chunk-RXRRXB74.cjs +1 -0
  118. package/dist/chunk-S3DYQVRD.js +1 -0
  119. package/dist/chunk-SCEPJO4Q.cjs +1 -0
  120. package/dist/chunk-SH7KRBXV.js +1 -0
  121. package/dist/chunk-SMADCELI.js +1 -0
  122. package/dist/chunk-SPTXAOFR.cjs +1 -0
  123. package/dist/chunk-STYSP6KL.cjs +1 -0
  124. package/dist/chunk-SVIKBM3S.js +1 -0
  125. package/dist/chunk-T3U46LK3.cjs +1 -0
  126. package/dist/chunk-TOAFCAVT.js +0 -0
  127. package/dist/chunk-TTSJFEM5.cjs +1 -0
  128. package/dist/chunk-UE3WVHTM.cjs +1 -0
  129. package/dist/chunk-USL4YOIR.cjs +1 -0
  130. package/dist/chunk-VA26VSUQ.cjs +1 -0
  131. package/dist/chunk-VV6374MW.cjs +1 -0
  132. package/dist/chunk-W5EH3HYF.cjs +1 -0
  133. package/dist/chunk-W6V7WGBL.js +1 -0
  134. package/dist/chunk-W7LJS32A.js +1 -0
  135. package/dist/chunk-WBIKVPHW.js +1 -0
  136. package/dist/chunk-WCGUGIGJ.js +1 -0
  137. package/dist/chunk-WP4V3OCS.cjs +1 -0
  138. package/dist/chunk-WT5MDUZY.js +1 -0
  139. package/dist/chunk-XNZLCUTY.js +1 -0
  140. package/dist/chunk-XS5B3TUE.js +1 -0
  141. package/dist/chunk-YGL4ITFK.cjs +1 -0
  142. package/dist/chunk-YIO5XXQ4.js +1 -0
  143. package/dist/chunk-YPHM2V2G.cjs +1 -0
  144. package/dist/chunk-ZE4NT3CJ.js +1 -0
  145. package/dist/chunk-ZIFTCPCX.cjs +1 -0
  146. package/dist/index.cjs +1 -69
  147. package/dist/index.d.cts +9 -7
  148. package/dist/index.d.ts +9 -7
  149. package/dist/index.js +1 -69
  150. package/dist/logger/index.cjs +1 -11
  151. package/dist/logger/index.js +1 -11
  152. package/dist/logger/init.cjs +1 -10
  153. package/dist/logger/init.js +1 -10
  154. package/dist/sdk.cjs +1 -48
  155. package/dist/sdk.d.cts +21 -19
  156. package/dist/sdk.d.ts +21 -19
  157. package/dist/sdk.js +1 -48
  158. package/dist/signers/device.cjs +1 -0
  159. package/dist/signers/device.d.cts +23 -0
  160. package/dist/signers/device.d.ts +23 -0
  161. package/dist/signers/device.js +1 -0
  162. package/dist/signers/evm-api-key.cjs +1 -7
  163. package/dist/signers/evm-api-key.d.cts +7 -3
  164. package/dist/signers/evm-api-key.d.ts +7 -3
  165. package/dist/signers/evm-api-key.js +1 -7
  166. package/dist/signers/evm-external-wallet.cjs +1 -7
  167. package/dist/signers/evm-external-wallet.d.cts +12 -13
  168. package/dist/signers/evm-external-wallet.d.ts +12 -13
  169. package/dist/signers/evm-external-wallet.js +1 -7
  170. package/dist/signers/external-wallet-signer.cjs +1 -0
  171. package/dist/signers/external-wallet-signer.d.cts +28 -0
  172. package/dist/signers/external-wallet-signer.d.ts +28 -0
  173. package/dist/signers/external-wallet-signer.js +1 -0
  174. package/dist/signers/index.cjs +1 -33
  175. package/dist/signers/index.d.cts +6 -2
  176. package/dist/signers/index.d.ts +6 -2
  177. package/dist/signers/index.js +1 -33
  178. package/dist/signers/non-custodial/index.cjs +1 -27
  179. package/dist/signers/non-custodial/index.d.cts +6 -2
  180. package/dist/signers/non-custodial/index.d.ts +6 -2
  181. package/dist/signers/non-custodial/index.js +1 -27
  182. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -13
  183. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +6 -2
  184. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +6 -2
  185. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -13
  186. package/dist/signers/non-custodial/ncs-iframe-manager.cjs +1 -7
  187. package/dist/signers/non-custodial/ncs-iframe-manager.js +1 -7
  188. package/dist/signers/non-custodial/ncs-signer.cjs +1 -14
  189. package/dist/signers/non-custodial/ncs-signer.d.cts +7 -3
  190. package/dist/signers/non-custodial/ncs-signer.d.ts +7 -3
  191. package/dist/signers/non-custodial/ncs-signer.js +1 -14
  192. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -13
  193. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +6 -2
  194. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +6 -2
  195. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -13
  196. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -13
  197. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +6 -2
  198. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +6 -2
  199. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -13
  200. package/dist/signers/passkey.cjs +1 -7
  201. package/dist/signers/passkey.d.cts +7 -3
  202. package/dist/signers/passkey.d.ts +7 -3
  203. package/dist/signers/passkey.js +1 -7
  204. package/dist/signers/server/assemble-server-signer.cjs +1 -14
  205. package/dist/signers/server/assemble-server-signer.d.cts +5 -1
  206. package/dist/signers/server/assemble-server-signer.d.ts +5 -1
  207. package/dist/signers/server/assemble-server-signer.js +1 -14
  208. package/dist/signers/server/evm-server-signer.cjs +1 -7
  209. package/dist/signers/server/evm-server-signer.d.cts +7 -3
  210. package/dist/signers/server/evm-server-signer.d.ts +7 -3
  211. package/dist/signers/server/evm-server-signer.js +1 -7
  212. package/dist/signers/server/helpers/derive-server-signer.cjs +1 -11
  213. package/dist/signers/server/helpers/derive-server-signer.d.cts +5 -1
  214. package/dist/signers/server/helpers/derive-server-signer.d.ts +5 -1
  215. package/dist/signers/server/helpers/derive-server-signer.js +1 -11
  216. package/dist/signers/server/helpers/get-chain-type.cjs +1 -7
  217. package/dist/signers/server/helpers/get-chain-type.js +1 -7
  218. package/dist/signers/server/helpers/index.cjs +1 -15
  219. package/dist/signers/server/helpers/index.d.cts +5 -1
  220. package/dist/signers/server/helpers/index.d.ts +5 -1
  221. package/dist/signers/server/helpers/index.js +1 -15
  222. package/dist/signers/server/index.cjs +1 -29
  223. package/dist/signers/server/index.d.cts +5 -1
  224. package/dist/signers/server/index.d.ts +5 -1
  225. package/dist/signers/server/index.js +1 -29
  226. package/dist/signers/server/solana-server-signer.cjs +1 -7
  227. package/dist/signers/server/solana-server-signer.d.cts +7 -3
  228. package/dist/signers/server/solana-server-signer.d.ts +7 -3
  229. package/dist/signers/server/solana-server-signer.js +1 -7
  230. package/dist/signers/server/stellar-server-signer.cjs +1 -7
  231. package/dist/signers/server/stellar-server-signer.d.cts +7 -3
  232. package/dist/signers/server/stellar-server-signer.d.ts +7 -3
  233. package/dist/signers/server/stellar-server-signer.js +1 -7
  234. package/dist/signers/solana-api-key.cjs +1 -7
  235. package/dist/signers/solana-api-key.d.cts +7 -3
  236. package/dist/signers/solana-api-key.d.ts +7 -3
  237. package/dist/signers/solana-api-key.js +1 -7
  238. package/dist/signers/solana-external-wallet.cjs +1 -8
  239. package/dist/signers/solana-external-wallet.d.cts +9 -10
  240. package/dist/signers/solana-external-wallet.d.ts +9 -10
  241. package/dist/signers/solana-external-wallet.js +1 -8
  242. package/dist/signers/stellar-external-wallet.cjs +1 -7
  243. package/dist/signers/stellar-external-wallet.d.cts +9 -9
  244. package/dist/signers/stellar-external-wallet.d.ts +9 -9
  245. package/dist/signers/stellar-external-wallet.js +1 -7
  246. package/dist/signers/types.cjs +1 -9
  247. package/dist/signers/types.d.cts +10 -102
  248. package/dist/signers/types.d.ts +10 -102
  249. package/dist/signers/types.js +1 -9
  250. package/dist/types/base32.js.d.cjs +1 -0
  251. package/dist/types/base32.js.d.d.cts +4 -0
  252. package/dist/types/base32.js.d.d.ts +4 -0
  253. package/dist/types/base32.js.d.js +0 -0
  254. package/dist/types-BaHy48kd.d.ts +427 -0
  255. package/dist/types-Dz8JNP4U.d.cts +427 -0
  256. package/dist/utils/constants.cjs +1 -13
  257. package/dist/utils/constants.js +1 -13
  258. package/dist/utils/device-signers/DeviceSignerKeyStorage.cjs +1 -0
  259. package/dist/utils/device-signers/DeviceSignerKeyStorage.d.cts +72 -0
  260. package/dist/utils/device-signers/DeviceSignerKeyStorage.d.ts +72 -0
  261. package/dist/utils/device-signers/DeviceSignerKeyStorage.js +1 -0
  262. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -0
  263. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.d.cts +51 -0
  264. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.d.ts +51 -0
  265. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -0
  266. package/dist/utils/device-signers/createDeviceSigner.cjs +1 -0
  267. package/dist/utils/device-signers/createDeviceSigner.d.cts +28 -0
  268. package/dist/utils/device-signers/createDeviceSigner.d.ts +28 -0
  269. package/dist/utils/device-signers/createDeviceSigner.js +1 -0
  270. package/dist/utils/device-signers/index.cjs +1 -0
  271. package/dist/utils/device-signers/index.d.cts +13 -0
  272. package/dist/utils/device-signers/index.d.ts +13 -0
  273. package/dist/utils/device-signers/index.js +1 -0
  274. package/dist/utils/errors.cjs +1 -55
  275. package/dist/utils/errors.d.cts +11 -2
  276. package/dist/utils/errors.d.ts +11 -2
  277. package/dist/utils/errors.js +1 -55
  278. package/dist/utils/server-key-derivation.cjs +1 -9
  279. package/dist/utils/server-key-derivation.js +1 -9
  280. package/dist/utils/signer-locator.cjs +1 -0
  281. package/dist/utils/signer-locator.d.cts +26 -0
  282. package/dist/utils/signer-locator.d.ts +26 -0
  283. package/dist/utils/signer-locator.js +1 -0
  284. package/dist/utils/signer-mapping.cjs +1 -0
  285. package/dist/utils/signer-mapping.d.cts +32 -0
  286. package/dist/utils/signer-mapping.d.ts +32 -0
  287. package/dist/utils/signer-mapping.js +1 -0
  288. package/dist/utils/signer-validation.cjs +1 -10
  289. package/dist/utils/signer-validation.d.cts +6 -4
  290. package/dist/utils/signer-validation.d.ts +6 -4
  291. package/dist/utils/signer-validation.js +1 -10
  292. package/dist/wallets/__tests__/setup.cjs +1 -36
  293. package/dist/wallets/__tests__/setup.js +1 -36
  294. package/dist/wallets/__tests__/test-helpers.cjs +1 -102
  295. package/dist/wallets/__tests__/test-helpers.d.cts +8 -8
  296. package/dist/wallets/__tests__/test-helpers.d.ts +8 -8
  297. package/dist/wallets/__tests__/test-helpers.js +1 -102
  298. package/dist/wallets/evm.cjs +1 -34
  299. package/dist/wallets/evm.d.cts +6 -7
  300. package/dist/wallets/evm.d.ts +6 -7
  301. package/dist/wallets/evm.js +1 -34
  302. package/dist/wallets/solana.cjs +1 -35
  303. package/dist/wallets/solana.d.cts +8 -7
  304. package/dist/wallets/solana.d.ts +8 -7
  305. package/dist/wallets/solana.js +1 -35
  306. package/dist/wallets/stellar.cjs +1 -34
  307. package/dist/wallets/stellar.d.cts +5 -6
  308. package/dist/wallets/stellar.d.ts +5 -6
  309. package/dist/wallets/stellar.js +1 -34
  310. package/dist/wallets/types.d.cts +9 -171
  311. package/dist/wallets/types.d.ts +9 -171
  312. package/dist/wallets/wallet-factory.cjs +1 -42
  313. package/dist/wallets/wallet-factory.d.cts +14 -10
  314. package/dist/wallets/wallet-factory.d.ts +14 -10
  315. package/dist/wallets/wallet-factory.js +1 -42
  316. package/dist/wallets/wallet.cjs +1 -33
  317. package/dist/wallets/wallet.d.cts +132 -34
  318. package/dist/wallets/wallet.d.ts +132 -34
  319. package/dist/wallets/wallet.js +1 -33
  320. package/package.json +9 -5
  321. package/dist/chunk-2I2OFGNL.js +0 -36
  322. package/dist/chunk-2M32LBCA.cjs +0 -52
  323. package/dist/chunk-2PSAUSOG.js +0 -379
  324. package/dist/chunk-2RG6642I.js +0 -39
  325. package/dist/chunk-2T5HHKUI.js +0 -19
  326. package/dist/chunk-3U6UAYOV.js +0 -25
  327. package/dist/chunk-3WZUNLYI.cjs +0 -16
  328. package/dist/chunk-47WKYTRN.js +0 -63
  329. package/dist/chunk-4GFSUI2I.cjs +0 -66
  330. package/dist/chunk-4Z3YDHHG.js +0 -82
  331. package/dist/chunk-4ZWUI6LE.cjs +0 -757
  332. package/dist/chunk-55V4VMTX.cjs +0 -25
  333. package/dist/chunk-65KPNJ77.js +0 -119
  334. package/dist/chunk-7EZDSDKA.cjs +0 -125
  335. package/dist/chunk-7GOUUPS4.js +0 -36
  336. package/dist/chunk-7SUWMK4J.cjs +0 -246
  337. package/dist/chunk-7USEVMTW.cjs +0 -21
  338. package/dist/chunk-7W4HGN3H.cjs +0 -63
  339. package/dist/chunk-ASE2FXWP.js +0 -65
  340. package/dist/chunk-BR4UVMIC.js +0 -332
  341. package/dist/chunk-BUBSPQ7U.cjs +0 -332
  342. package/dist/chunk-CPZQ7BK5.cjs +0 -82
  343. package/dist/chunk-CTOLL4BK.js +0 -29
  344. package/dist/chunk-DDNG224J.cjs +0 -45
  345. package/dist/chunk-EVR4CD53.js +0 -63
  346. package/dist/chunk-F7L2TZ3I.cjs +0 -21
  347. package/dist/chunk-FOOISYCJ.js +0 -66
  348. package/dist/chunk-FZQG6OX2.js +0 -323
  349. package/dist/chunk-G6QJHFSY.cjs +0 -74
  350. package/dist/chunk-GJT2JD3E.js +0 -45
  351. package/dist/chunk-GLUD6EBN.js +0 -16
  352. package/dist/chunk-H6WV5NRT.js +0 -10
  353. package/dist/chunk-HFEF2URB.js +0 -84
  354. package/dist/chunk-HTSQPZHW.cjs +0 -25
  355. package/dist/chunk-HWTWDQYT.cjs +0 -42
  356. package/dist/chunk-HYA3ESUA.js +0 -69
  357. package/dist/chunk-IOMKHF6R.cjs +0 -44
  358. package/dist/chunk-IPO25BCU.js +0 -43
  359. package/dist/chunk-JSWTGW46.cjs +0 -36
  360. package/dist/chunk-JWMQALLN.js +0 -21
  361. package/dist/chunk-K6LSGLG6.js +0 -42
  362. package/dist/chunk-KHY5FXO4.cjs +0 -37
  363. package/dist/chunk-KT3CVXFG.js +0 -9
  364. package/dist/chunk-M47ZHA7Q.js +0 -246
  365. package/dist/chunk-M4HCASMG.cjs +0 -119
  366. package/dist/chunk-M6IPPGXQ.cjs +0 -29
  367. package/dist/chunk-M7OPRXZH.cjs +0 -69
  368. package/dist/chunk-MIKWTXUA.cjs +0 -223
  369. package/dist/chunk-MMISP35W.js +0 -21
  370. package/dist/chunk-MNHK6EQK.cjs +0 -57
  371. package/dist/chunk-NIBKCMQ2.cjs +0 -19
  372. package/dist/chunk-NO2KMGS2.cjs +0 -379
  373. package/dist/chunk-OPKFMXPI.cjs +0 -39
  374. package/dist/chunk-OXB6RTW7.js +0 -125
  375. package/dist/chunk-P4XJHOLW.cjs +0 -253
  376. package/dist/chunk-PIFD6KNH.js +0 -59
  377. package/dist/chunk-PJOJIRTY.js +0 -74
  378. package/dist/chunk-PK7J3Y3L.js +0 -44
  379. package/dist/chunk-Q52MMQSC.js +0 -57
  380. package/dist/chunk-Q5KNPVYI.cjs +0 -59
  381. package/dist/chunk-QQNDLR6E.cjs +0 -323
  382. package/dist/chunk-RBHGZDDX.cjs +0 -58
  383. package/dist/chunk-RHR6P2KP.cjs +0 -15
  384. package/dist/chunk-RUQYXEEG.cjs +0 -10
  385. package/dist/chunk-S2L5Z2ZT.js +0 -37
  386. package/dist/chunk-SGINWAB6.js +0 -155
  387. package/dist/chunk-T5NKL6F4.js +0 -89
  388. package/dist/chunk-U56Z2EOR.cjs +0 -89
  389. package/dist/chunk-UO2J2ZB2.cjs +0 -65
  390. package/dist/chunk-VLZ5ZS5U.js +0 -253
  391. package/dist/chunk-VTF3WCXG.cjs +0 -84
  392. package/dist/chunk-VVPGO564.js +0 -757
  393. package/dist/chunk-WJUPOCKJ.js +0 -15
  394. package/dist/chunk-X4SPF4KJ.js +0 -223
  395. package/dist/chunk-XC2V34TS.cjs +0 -155
  396. package/dist/chunk-XEPUH4XH.js +0 -52
  397. package/dist/chunk-XOCC3MPK.cjs +0 -36
  398. package/dist/chunk-ZBLW42YE.js +0 -25
  399. package/dist/chunk-ZNAGDENG.cjs +0 -43
  400. package/dist/chunk-ZP4ZZCIE.js +0 -58
  401. package/dist/chunk-ZT7EGOCI.cjs +0 -9
  402. package/dist/chunk-ZTEMOYS2.cjs +0 -63
@@ -1,757 +0,0 @@
1
- import {
2
- deriveServerSignerDetails
3
- } from "./chunk-S2L5Z2ZT.js";
4
- import {
5
- NonCustodialSigner
6
- } from "./chunk-FZQG6OX2.js";
7
- import {
8
- validateChainForEnvironment
9
- } from "./chunk-X4SPF4KJ.js";
10
- import {
11
- InvalidSignerError,
12
- SignatureFailedError,
13
- SignatureNotAvailableError,
14
- SigningFailedError,
15
- TransactionAwaitingApprovalError,
16
- TransactionConfirmationTimeoutError,
17
- TransactionFailedError,
18
- TransactionHashNotFoundError,
19
- TransactionNotAvailableError,
20
- TransactionNotCreatedError,
21
- TransactionSendingFailedError,
22
- WalletNotAvailableError,
23
- WalletTypeNotSupportedError
24
- } from "./chunk-SGINWAB6.js";
25
- import {
26
- walletsLogger
27
- } from "./chunk-XEPUH4XH.js";
28
- import {
29
- STATUS_POLLING_INTERVAL_MS
30
- } from "./chunk-GLUD6EBN.js";
31
- import {
32
- __async,
33
- __decorateClass,
34
- __privateAdd,
35
- __privateGet,
36
- __privateSet,
37
- __spreadProps,
38
- __spreadValues
39
- } from "./chunk-ASE2FXWP.js";
40
-
41
- // src/wallets/wallet.ts
42
- import { isValidAddress, WithLoggerContext } from "@crossmint/common-sdk-base";
43
- var _options, _apiClient;
44
- var Wallet = class {
45
- constructor(args, apiClient) {
46
- __privateAdd(this, _options);
47
- __privateAdd(this, _apiClient);
48
- const { chain, address, owner, signer, options, alias } = args;
49
- __privateSet(this, _apiClient, apiClient);
50
- this.chain = chain;
51
- this.address = address;
52
- this.owner = owner;
53
- this.signer = signer;
54
- __privateSet(this, _options, options);
55
- this.alias = alias;
56
- }
57
- static getApiClient(wallet) {
58
- return wallet.apiClient;
59
- }
60
- static getOptions(wallet) {
61
- return wallet.options;
62
- }
63
- get apiClient() {
64
- return __privateGet(this, _apiClient);
65
- }
66
- get options() {
67
- return __privateGet(this, _options);
68
- }
69
- /**
70
- * Get the API client
71
- * @returns The API client
72
- * @experimental This API is experimental and may change in the future
73
- */
74
- experimental_apiClient() {
75
- return __privateGet(this, _apiClient);
76
- }
77
- balances(tokens) {
78
- return __async(this, null, function* () {
79
- walletsLogger.info("wallet.balances.start");
80
- const resolvedChain = this.resolveChainForEnvironment();
81
- let nativeToken;
82
- switch (this.chain) {
83
- case "solana":
84
- nativeToken = "sol";
85
- break;
86
- case "stellar":
87
- nativeToken = "xlm";
88
- break;
89
- default:
90
- nativeToken = "eth";
91
- break;
92
- }
93
- const allTokens = [nativeToken, "usdc", ...tokens != null ? tokens : []];
94
- const response = yield __privateGet(this, _apiClient).getBalance(this.address, {
95
- chains: [resolvedChain],
96
- tokens: allTokens
97
- });
98
- if ("error" in response) {
99
- walletsLogger.error("wallet.balances.error", { error: response });
100
- throw new Error(`Failed to get balances for wallet: ${JSON.stringify(response.message)}`);
101
- }
102
- walletsLogger.info("wallet.balances.success");
103
- return this.transformBalanceResponse(response, nativeToken, tokens);
104
- });
105
- }
106
- stagingFund(amount, chain) {
107
- return __async(this, null, function* () {
108
- walletsLogger.info("wallet.stagingFund.start", {
109
- amount,
110
- chain: chain != null ? chain : this.chain
111
- });
112
- const response = yield this.apiClient.fundWallet(this.address, {
113
- amount,
114
- token: "usdxm",
115
- // Type casting is necessary here due to a type mismatch between our DTO schema and server-side types
116
- // (which only contains 10 testnet chains. Variable in main server is called EvmUsdcEnabledTestnetChains for reference).
117
- chain: chain != null ? chain : this.chain
118
- });
119
- if ("error" in response) {
120
- walletsLogger.error("wallet.stagingFund.error", {
121
- error: response
122
- });
123
- throw new Error(`Failed to fund wallet: ${JSON.stringify(response.message)}`);
124
- }
125
- walletsLogger.info("wallet.stagingFund.success");
126
- return response;
127
- });
128
- }
129
- /**
130
- * Transform the API balance response to the new structure
131
- * @private
132
- */
133
- transformBalanceResponse(apiResponse, nativeTokenSymbol, requestedTokens) {
134
- const transformTokenBalance = (tokenData) => {
135
- var _a, _b, _c, _d, _e;
136
- const chainData = (_a = tokenData.chains) == null ? void 0 : _a[this.chain];
137
- let chainSpecificField = {};
138
- if (this.chain === "solana" && chainData != null && "mintHash" in chainData) {
139
- chainSpecificField = { mintHash: chainData.mintHash };
140
- } else if (this.chain === "stellar" && chainData != null && "contractId" in chainData) {
141
- chainSpecificField = { contractId: chainData.contractId };
142
- } else if (chainData != null && "contractAddress" in chainData) {
143
- chainSpecificField = {
144
- contractAddress: chainData.contractAddress
145
- };
146
- }
147
- return __spreadValues({
148
- symbol: (_b = tokenData.symbol) != null ? _b : "",
149
- name: (_c = tokenData.name) != null ? _c : "",
150
- amount: (_d = tokenData.amount) != null ? _d : "0",
151
- decimals: tokenData.decimals,
152
- rawAmount: (_e = tokenData.rawAmount) != null ? _e : "0"
153
- }, chainSpecificField);
154
- };
155
- const nativeTokenData = apiResponse.find((token) => token.symbol === nativeTokenSymbol);
156
- const usdcData = apiResponse.find((token) => token.symbol === "usdc");
157
- const otherTokens = apiResponse.filter((token) => {
158
- return token.symbol !== nativeTokenSymbol && token.symbol !== "usdc";
159
- });
160
- const createDefaultToken = (symbol) => {
161
- const baseToken = {
162
- symbol,
163
- name: symbol,
164
- amount: "0",
165
- decimals: 0,
166
- rawAmount: "0"
167
- };
168
- let chainSpecificField = {};
169
- if (this.chain === "solana") {
170
- chainSpecificField = { mintHash: void 0 };
171
- } else if (this.chain === "stellar") {
172
- chainSpecificField = { contractId: void 0 };
173
- } else {
174
- chainSpecificField = { contractAddress: void 0 };
175
- }
176
- return __spreadValues(__spreadValues({}, baseToken), chainSpecificField);
177
- };
178
- return {
179
- nativeToken: nativeTokenData != null ? transformTokenBalance(nativeTokenData) : createDefaultToken(nativeTokenSymbol),
180
- usdc: usdcData != null ? transformTokenBalance(usdcData) : createDefaultToken("usdc"),
181
- tokens: otherTokens.map(transformTokenBalance)
182
- };
183
- }
184
- /**
185
- * Get the wallet NFTs
186
- * @param {Object} params - The parameters
187
- * @param {number} params.perPage - The number of NFTs per page
188
- * @param {number} params.page - The page number
189
- * @param {WalletLocator} [params.locator] - The locator
190
- * @returns The NFTs
191
- * @experimental This API is experimental and may change in the future
192
- */
193
- experimental_nfts(params) {
194
- return __async(this, null, function* () {
195
- return yield __privateGet(this, _apiClient).experimental_getNfts(__spreadProps(__spreadValues({}, params), {
196
- chain: this.chain,
197
- address: this.address
198
- }));
199
- });
200
- }
201
- /**
202
- * Get the wallet transactions
203
- * @returns The transactions
204
- * @throws {Error} If the transactions cannot be retrieved
205
- */
206
- experimental_transactions() {
207
- return __async(this, null, function* () {
208
- const response = yield __privateGet(this, _apiClient).getTransactions(this.walletLocator);
209
- if ("error" in response) {
210
- throw new Error(`Failed to get transactions: ${JSON.stringify(response.message)}`);
211
- }
212
- return response;
213
- });
214
- }
215
- /**
216
- * Get a transaction by id
217
- * @returns The transaction
218
- * @throws {Error} If the transaction cannot be retrieved
219
- */
220
- experimental_transaction(transactionId) {
221
- return __async(this, null, function* () {
222
- const response = yield __privateGet(this, _apiClient).getTransaction(this.walletLocator, transactionId);
223
- if ("error" in response) {
224
- throw new Error(`Failed to get transaction: ${JSON.stringify(response.error)}`);
225
- }
226
- return response;
227
- });
228
- }
229
- /**
230
- * Get the wallet activity
231
- * @returns The activity
232
- * @experimental This API is experimental and may change in the future
233
- * @throws {Error} If the activity cannot be retrieved
234
- */
235
- experimental_activity() {
236
- return __async(this, null, function* () {
237
- const resolvedChain = this.resolveChainForEnvironment();
238
- const response = yield this.apiClient.experimental_activity(this.walletLocator, { chain: resolvedChain });
239
- if ("error" in response) {
240
- throw new Error(`Failed to get activity: ${JSON.stringify(response.message)}`);
241
- }
242
- return response;
243
- });
244
- }
245
- send(to, token, amount, options) {
246
- return __async(this, null, function* () {
247
- const resolvedChain = this.resolveChainForEnvironment();
248
- const recipient = toRecipientLocator(to);
249
- const tokenLocator = toTokenLocator(token, resolvedChain);
250
- walletsLogger.info("wallet.send.start", __spreadValues({
251
- recipient,
252
- token: tokenLocator,
253
- amount
254
- }, (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {}));
255
- yield this.preAuthIfNeeded();
256
- let signer;
257
- if ((options == null ? void 0 : options.experimental_signer) != null) {
258
- if (typeof options.experimental_signer === "string") {
259
- signer = options.experimental_signer;
260
- } else {
261
- signer = `server:${deriveServerSignerDetails(options.experimental_signer, this.chain, __privateGet(this, _apiClient).projectId, __privateGet(this, _apiClient).environment).derivedAddress}`;
262
- }
263
- }
264
- const sendParams = __spreadValues(__spreadValues({
265
- recipient,
266
- amount
267
- }, signer != null ? { signer } : {}), (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {});
268
- const transactionCreationResponse = yield __privateGet(this, _apiClient).send(this.walletLocator, tokenLocator, sendParams);
269
- if ("message" in transactionCreationResponse) {
270
- walletsLogger.error("wallet.send.error", {
271
- error: transactionCreationResponse
272
- });
273
- throw new TransactionNotCreatedError(
274
- `Failed to send token: ${JSON.stringify(transactionCreationResponse.message)}`
275
- );
276
- }
277
- if (options == null ? void 0 : options.experimental_prepareOnly) {
278
- walletsLogger.info("wallet.send.prepared", {
279
- transactionId: transactionCreationResponse.id
280
- });
281
- return {
282
- hash: void 0,
283
- explorerLink: void 0,
284
- transactionId: transactionCreationResponse.id
285
- };
286
- }
287
- const result = yield this.approveTransactionAndWait(transactionCreationResponse.id);
288
- walletsLogger.info("wallet.send.success", {
289
- transactionId: transactionCreationResponse.id,
290
- hash: result.hash
291
- });
292
- return result;
293
- });
294
- }
295
- /**
296
- * @deprecated Use `approve` instead.
297
- * Approve a transaction
298
- * @param params - The parameters
299
- * @param params.transactionId - The transaction id
300
- * @param params.options - The options for the transaction
301
- * @param params.options.experimental_approval - The approval
302
- * @param params.options.additionalSigners - The additional signers
303
- * @returns The transaction
304
- */
305
- // TODO: Remove this method in the next major version
306
- approveTransaction(params) {
307
- return __async(this, null, function* () {
308
- console.warn(
309
- "approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."
310
- );
311
- return yield this.approve(params);
312
- });
313
- }
314
- approve(params) {
315
- return __async(this, null, function* () {
316
- walletsLogger.info("wallet.approve.start", {
317
- transactionId: params.transactionId,
318
- signatureId: params.signatureId
319
- });
320
- if (params.transactionId != null) {
321
- const result = yield this.approveTransactionAndWait(
322
- params.transactionId,
323
- params.options
324
- );
325
- walletsLogger.info("wallet.approve.success", {
326
- transactionId: params.transactionId
327
- });
328
- return result;
329
- }
330
- if (params.signatureId != null) {
331
- const result = yield this.approveSignatureAndWait(params.signatureId, params.options);
332
- walletsLogger.info("wallet.approve.success", {
333
- signatureId: params.signatureId
334
- });
335
- return result;
336
- }
337
- walletsLogger.error("wallet.approve.error", {
338
- error: "Either transactionId or signatureId must be provided"
339
- });
340
- throw new Error("Either transactionId or signatureId must be provided");
341
- });
342
- }
343
- addDelegatedSigner(params) {
344
- return __async(this, null, function* () {
345
- var _a, _b, _c;
346
- walletsLogger.info("wallet.addDelegatedSigner.start");
347
- const resolvedSigner = typeof params.signer === "object" && params.signer.type === "server" ? `server:${deriveServerSignerDetails(params.signer, this.chain, __privateGet(this, _apiClient).projectId, __privateGet(this, _apiClient).environment).derivedAddress}` : params.signer;
348
- const response = yield __privateGet(this, _apiClient).registerSigner(this.walletLocator, {
349
- signer: resolvedSigner,
350
- chain: this.chain === "solana" || this.chain === "stellar" ? void 0 : this.chain
351
- });
352
- if ("error" in response) {
353
- walletsLogger.error("wallet.addDelegatedSigner.error", {
354
- error: response
355
- });
356
- throw new Error(`Failed to register signer: ${JSON.stringify(response.message)}`);
357
- }
358
- if (this.chain === "solana" || this.chain === "stellar") {
359
- if (!("transaction" in response) || response.transaction == null) {
360
- walletsLogger.error("wallet.addDelegatedSigner.error", {
361
- error: "Expected transaction in response for Solana/Stellar chain"
362
- });
363
- throw new Error("Expected transaction in response for Solana/Stellar chain");
364
- }
365
- const transactionId = response.transaction.id;
366
- if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
367
- walletsLogger.info("wallet.addDelegatedSigner.prepared", {
368
- transactionId
369
- });
370
- return { transactionId };
371
- }
372
- yield this.approveTransactionAndWait(transactionId);
373
- walletsLogger.info("wallet.addDelegatedSigner.success", {
374
- transactionId
375
- });
376
- return void 0;
377
- }
378
- if (!("chains" in response)) {
379
- walletsLogger.error("wallet.addDelegatedSigner.error", {
380
- error: "Expected chains in response for EVM chain"
381
- });
382
- throw new Error("Expected chains in response for EVM chain");
383
- }
384
- const chainResponse = (_b = response.chains) == null ? void 0 : _b[this.chain];
385
- if ((_c = params.options) == null ? void 0 : _c.experimental_prepareOnly) {
386
- const signatureId = (chainResponse == null ? void 0 : chainResponse.status) !== "success" ? chainResponse == null ? void 0 : chainResponse.id : void 0;
387
- walletsLogger.info("wallet.addDelegatedSigner.prepared", {
388
- signatureId
389
- });
390
- return { signatureId };
391
- }
392
- if ((chainResponse == null ? void 0 : chainResponse.status) === "awaiting-approval") {
393
- yield this.approveSignatureAndWait(chainResponse.id);
394
- walletsLogger.info("wallet.addDelegatedSigner.success", {
395
- signatureId: chainResponse.id
396
- });
397
- return void 0;
398
- }
399
- if ((chainResponse == null ? void 0 : chainResponse.status) === "pending") {
400
- yield this.waitForSignature(chainResponse.id);
401
- walletsLogger.info("wallet.addDelegatedSigner.success", {
402
- signatureId: chainResponse.id
403
- });
404
- return void 0;
405
- }
406
- walletsLogger.info("wallet.addDelegatedSigner.success");
407
- return void 0;
408
- });
409
- }
410
- delegatedSigners() {
411
- return __async(this, null, function* () {
412
- var _a, _b, _c;
413
- walletsLogger.info("wallet.delegatedSigners.start");
414
- const walletResponse = yield __privateGet(this, _apiClient).getWallet(this.walletLocator);
415
- if ("error" in walletResponse) {
416
- walletsLogger.error("wallet.delegatedSigners.error", {
417
- error: walletResponse
418
- });
419
- throw new WalletNotAvailableError(JSON.stringify(walletResponse));
420
- }
421
- if (walletResponse.type !== "smart" || walletResponse.chainType !== "evm" && walletResponse.chainType !== "solana" && walletResponse.chainType !== "stellar") {
422
- walletsLogger.error("wallet.delegatedSigners.error", {
423
- error: `Wallet type ${walletResponse.type} not supported`
424
- });
425
- throw new WalletTypeNotSupportedError(`Wallet type ${walletResponse.type} not supported`);
426
- }
427
- const signers = (_c = (_b = (_a = walletResponse == null ? void 0 : walletResponse.config) == null ? void 0 : _a.delegatedSigners) == null ? void 0 : _b.map((signer) => {
428
- const colonIndex = signer.locator.indexOf(":");
429
- const address = colonIndex >= 0 ? signer.locator.slice(colonIndex + 1) : signer.locator;
430
- return {
431
- signer: `external-wallet:${address}`
432
- };
433
- })) != null ? _c : [];
434
- walletsLogger.info("wallet.delegatedSigners.success", {
435
- count: signers.length
436
- });
437
- return signers;
438
- });
439
- }
440
- get walletLocator() {
441
- if (__privateGet(this, _apiClient).isServerSide) {
442
- return this.address;
443
- } else {
444
- let baseLocator;
445
- switch (this.chain) {
446
- case "stellar":
447
- baseLocator = `me:stellar:smart`;
448
- break;
449
- case "solana":
450
- baseLocator = `me:solana:smart`;
451
- break;
452
- default:
453
- baseLocator = `me:evm:smart`;
454
- break;
455
- }
456
- const aliasLocatorPart = this.alias != null ? `:alias:${this.alias}` : "";
457
- return baseLocator + aliasLocatorPart;
458
- }
459
- }
460
- preAuthIfNeeded() {
461
- return __async(this, null, function* () {
462
- if (this.signer instanceof NonCustodialSigner) {
463
- yield this.signer.ensureAuthenticated();
464
- }
465
- });
466
- }
467
- get isSolanaWallet() {
468
- return this.chain === "solana";
469
- }
470
- resolveChainForEnvironment() {
471
- const resolvedChain = validateChainForEnvironment(this.chain, __privateGet(this, _apiClient).environment);
472
- if (resolvedChain !== this.chain) {
473
- this.chain = resolvedChain;
474
- }
475
- return this.chain;
476
- }
477
- approveTransactionAndWait(transactionId, options) {
478
- return __async(this, null, function* () {
479
- yield this.approveTransactionInternal(transactionId, options);
480
- yield this.sleep(1e3);
481
- return yield this.waitForTransaction(transactionId);
482
- });
483
- }
484
- approveSignatureAndWait(signatureId, options) {
485
- return __async(this, null, function* () {
486
- const signatureResponse = yield this.approveSignatureInternal(signatureId, options);
487
- if (!("error" in signatureResponse) && signatureResponse.status === "success" && signatureResponse.outputSignature != null) {
488
- return {
489
- signature: signatureResponse.outputSignature,
490
- signatureId
491
- };
492
- }
493
- yield this.sleep(1e3);
494
- return yield this.waitForSignature(signatureId);
495
- });
496
- }
497
- approveSignatureInternal(signatureId, options) {
498
- return __async(this, null, function* () {
499
- var _a, _b;
500
- if (this.isSolanaWallet) {
501
- throw new Error("Approving signatures is only supported for EVM smart wallets");
502
- }
503
- const signature = yield __privateGet(this, _apiClient).getSignature(this.walletLocator, signatureId);
504
- if ("error" in signature) {
505
- throw new SignatureNotAvailableError(JSON.stringify(signature));
506
- }
507
- if (this.signer.type === "api-key") {
508
- return signature;
509
- }
510
- if ((options == null ? void 0 : options.experimental_approval) != null) {
511
- const approvals2 = [options.experimental_approval];
512
- return yield this.executeApproveSignatureWithErrorHandling(signatureId, approvals2);
513
- }
514
- const pendingApprovals = (_a = signature.approvals) == null ? void 0 : _a.pending;
515
- if (pendingApprovals == null) {
516
- return signature;
517
- }
518
- const signers = [...(_b = options == null ? void 0 : options.additionalSigners) != null ? _b : [], this.signer];
519
- const approvals = yield Promise.all(
520
- pendingApprovals.map((pendingApproval) => __async(this, null, function* () {
521
- const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
522
- if (signer == null) {
523
- throw new InvalidSignerError(
524
- `Signer ${pendingApproval.signer.locator} not found in pending approvals`
525
- );
526
- }
527
- const signature2 = yield signer.signMessage(pendingApproval.message);
528
- return __spreadProps(__spreadValues({}, signature2), {
529
- signer: signer.locator()
530
- });
531
- }))
532
- );
533
- return yield this.executeApproveSignatureWithErrorHandling(signatureId, approvals);
534
- });
535
- }
536
- approveTransactionInternal(transactionId, options) {
537
- return __async(this, null, function* () {
538
- var _a, _b, _c, _d, _e;
539
- const transaction = yield __privateGet(this, _apiClient).getTransaction(this.walletLocator, transactionId);
540
- if ("error" in transaction) {
541
- throw new TransactionNotAvailableError(JSON.stringify(transaction));
542
- }
543
- yield (_c = (_b = (_a = __privateGet(this, _options)) == null ? void 0 : _a.experimental_callbacks) == null ? void 0 : _b.onTransactionStart) == null ? void 0 : _c.call(_b);
544
- if (this.signer.type === "api-key") {
545
- return transaction;
546
- }
547
- if ((options == null ? void 0 : options.experimental_approval) != null) {
548
- const approvals2 = [options.experimental_approval];
549
- return yield this.executeApproveTransactionWithErrorHandling(transactionId, approvals2);
550
- }
551
- const pendingApprovals = (_d = transaction.approvals) == null ? void 0 : _d.pending;
552
- if (pendingApprovals == null) {
553
- return transaction;
554
- }
555
- const signers = [...(_e = options == null ? void 0 : options.additionalSigners) != null ? _e : [], this.signer];
556
- const approvals = yield Promise.all(
557
- pendingApprovals.map((pendingApproval) => __async(this, null, function* () {
558
- const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
559
- if (signer == null) {
560
- throw new InvalidSignerError(
561
- `Signer ${pendingApproval.signer.locator} not found in pending approvals`
562
- );
563
- }
564
- const transactionToSign = transaction.chainType === "solana" && "transaction" in transaction.onChain ? transaction.onChain.transaction : pendingApproval.message;
565
- const signature = yield signer.signTransaction(transactionToSign);
566
- return __spreadProps(__spreadValues({}, signature), {
567
- signer: signer.locator()
568
- });
569
- }))
570
- );
571
- return yield this.executeApproveTransactionWithErrorHandling(transactionId, approvals);
572
- });
573
- }
574
- executeApproveTransactionWithErrorHandling(transactionId, approvals) {
575
- return __async(this, null, function* () {
576
- walletsLogger.info("wallet.approve: submitting approval to API", { transactionId });
577
- const approvedTransaction = yield __privateGet(this, _apiClient).approveTransaction(this.walletLocator, transactionId, {
578
- approvals
579
- });
580
- if (approvedTransaction.error) {
581
- throw new TransactionFailedError(JSON.stringify(approvedTransaction));
582
- }
583
- return approvedTransaction;
584
- });
585
- }
586
- executeApproveSignatureWithErrorHandling(signatureId, approvals) {
587
- return __async(this, null, function* () {
588
- const approvedSignature = yield __privateGet(this, _apiClient).approveSignature(this.walletLocator, signatureId, {
589
- approvals
590
- });
591
- if (approvedSignature.error) {
592
- throw new SignatureFailedError(JSON.stringify(approvedSignature));
593
- }
594
- return approvedSignature;
595
- });
596
- }
597
- waitForSignature(signatureId) {
598
- return __async(this, null, function* () {
599
- let signatureResponse = null;
600
- do {
601
- yield new Promise((resolve) => setTimeout(resolve, STATUS_POLLING_INTERVAL_MS));
602
- signatureResponse = yield __privateGet(this, _apiClient).getSignature(this.walletLocator, signatureId);
603
- if ("error" in signatureResponse) {
604
- throw new SignatureNotAvailableError(JSON.stringify(signatureResponse));
605
- }
606
- } while (signatureResponse === null || signatureResponse.status === "pending");
607
- if (signatureResponse.status === "failed") {
608
- throw new SigningFailedError("Signature signing failed");
609
- }
610
- if (!signatureResponse.outputSignature) {
611
- throw new SignatureNotAvailableError("Signature not available");
612
- }
613
- return {
614
- signature: signatureResponse.outputSignature,
615
- signatureId
616
- };
617
- });
618
- }
619
- waitForTransaction(_0) {
620
- return __async(this, arguments, function* (transactionId, timeoutMs = 6e4, {
621
- backoffMultiplier = 1.1,
622
- maxBackoffMs = 2e3,
623
- initialBackoffMs = STATUS_POLLING_INTERVAL_MS
624
- } = {}) {
625
- var _a;
626
- walletsLogger.info("wallet.approve: waiting for transaction confirmation", { transactionId, timeoutMs });
627
- const startTime = Date.now();
628
- let transactionResponse;
629
- do {
630
- if (Date.now() - startTime > timeoutMs) {
631
- const error = new TransactionConfirmationTimeoutError("Transaction confirmation timeout");
632
- throw error;
633
- }
634
- transactionResponse = yield __privateGet(this, _apiClient).getTransaction(this.walletLocator, transactionId);
635
- if (transactionResponse.error) {
636
- throw new TransactionNotAvailableError(JSON.stringify(transactionResponse));
637
- }
638
- yield this.sleep(initialBackoffMs);
639
- initialBackoffMs = Math.min(initialBackoffMs * backoffMultiplier, maxBackoffMs);
640
- } while (transactionResponse.status === "pending");
641
- if (transactionResponse.status === "failed") {
642
- const error = new TransactionSendingFailedError(
643
- `Transaction sending failed: ${JSON.stringify(transactionResponse.error)}`
644
- );
645
- throw error;
646
- }
647
- if (transactionResponse.status === "awaiting-approval") {
648
- const error = new TransactionAwaitingApprovalError(
649
- `Transaction is awaiting approval. Please submit required approvals before waiting for completion.`
650
- );
651
- throw error;
652
- }
653
- const transactionHash = transactionResponse.onChain.txId;
654
- if (transactionHash == null) {
655
- const error = new TransactionHashNotFoundError("Transaction hash not found on transaction response");
656
- throw error;
657
- }
658
- return {
659
- hash: transactionHash,
660
- explorerLink: (_a = transactionResponse.onChain.explorerLink) != null ? _a : "",
661
- transactionId: transactionResponse.id
662
- };
663
- });
664
- }
665
- sleep(ms) {
666
- return __async(this, null, function* () {
667
- return new Promise((resolve) => setTimeout(resolve, ms));
668
- });
669
- }
670
- };
671
- _options = new WeakMap();
672
- _apiClient = new WeakMap();
673
- __decorateClass([
674
- WithLoggerContext({
675
- logger: walletsLogger,
676
- methodName: "wallet.balances",
677
- buildContext(thisArg) {
678
- return { chain: thisArg.chain, address: thisArg.address };
679
- }
680
- })
681
- ], Wallet.prototype, "balances", 1);
682
- __decorateClass([
683
- WithLoggerContext({
684
- logger: walletsLogger,
685
- methodName: "wallet.stagingFund",
686
- buildContext(thisArg) {
687
- return { chain: thisArg.chain, address: thisArg.address };
688
- }
689
- })
690
- ], Wallet.prototype, "stagingFund", 1);
691
- __decorateClass([
692
- WithLoggerContext({
693
- logger: walletsLogger,
694
- methodName: "wallet.send",
695
- buildContext(thisArg) {
696
- return { chain: thisArg.chain, address: thisArg.address };
697
- }
698
- })
699
- ], Wallet.prototype, "send", 1);
700
- __decorateClass([
701
- WithLoggerContext({
702
- logger: walletsLogger,
703
- methodName: "wallet.approve",
704
- buildContext(thisArg) {
705
- return { chain: thisArg.chain, address: thisArg.address };
706
- }
707
- })
708
- ], Wallet.prototype, "approve", 1);
709
- __decorateClass([
710
- WithLoggerContext({
711
- logger: walletsLogger,
712
- methodName: "wallet.addDelegatedSigner",
713
- buildContext(thisArg) {
714
- return { chain: thisArg.chain, address: thisArg.address };
715
- }
716
- })
717
- ], Wallet.prototype, "addDelegatedSigner", 1);
718
- __decorateClass([
719
- WithLoggerContext({
720
- logger: walletsLogger,
721
- methodName: "wallet.delegatedSigners",
722
- buildContext(thisArg) {
723
- return { chain: thisArg.chain, address: thisArg.address };
724
- }
725
- })
726
- ], Wallet.prototype, "delegatedSigners", 1);
727
- function toRecipientLocator(to) {
728
- if (typeof to === "string") {
729
- return to;
730
- }
731
- if ("email" in to) {
732
- return `email:${to.email}`;
733
- }
734
- if ("x" in to) {
735
- return `x:${to.x}`;
736
- }
737
- if ("twitter" in to) {
738
- return `twitter:${to.twitter}`;
739
- }
740
- if ("phone" in to) {
741
- return `phoneNumber:${to.phone}`;
742
- }
743
- if ("userId" in to) {
744
- return `userId:${to.userId}`;
745
- }
746
- throw new Error("Invalid recipient locator");
747
- }
748
- function toTokenLocator(token, chain) {
749
- if (isValidAddress(token)) {
750
- return `${chain}:${token}`;
751
- }
752
- return `${chain}:${token.toLowerCase()}`;
753
- }
754
-
755
- export {
756
- Wallet
757
- };