@crossmint/wallets-sdk 1.6.2 → 1.7.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 (281) hide show
  1. package/dist/api/__tests__/constants.d.cts +1 -1
  2. package/dist/api/__tests__/constants.d.ts +1 -1
  3. package/dist/api/__tests__/test-utils.cjs +1 -1
  4. package/dist/api/__tests__/test-utils.d.cts +1 -1
  5. package/dist/api/__tests__/test-utils.d.ts +1 -1
  6. package/dist/api/__tests__/test-utils.js +1 -1
  7. package/dist/api/client.cjs +1 -1
  8. package/dist/api/client.d.cts +1 -1
  9. package/dist/api/client.d.ts +1 -1
  10. package/dist/api/client.js +1 -1
  11. package/dist/api/index.cjs +1 -1
  12. package/dist/api/index.d.cts +1 -1
  13. package/dist/api/index.d.ts +1 -1
  14. package/dist/api/index.js +1 -1
  15. package/dist/api/types.d.cts +1 -1
  16. package/dist/api/types.d.ts +1 -1
  17. package/dist/chains/adapters/evm.cjs +1 -1
  18. package/dist/chains/adapters/evm.d.cts +1 -1
  19. package/dist/chains/adapters/evm.d.ts +1 -1
  20. package/dist/chains/adapters/evm.js +1 -1
  21. package/dist/chains/adapters/solana.cjs +1 -1
  22. package/dist/chains/adapters/solana.d.cts +1 -1
  23. package/dist/chains/adapters/solana.d.ts +1 -1
  24. package/dist/chains/adapters/solana.js +1 -1
  25. package/dist/chains/adapters/stellar.cjs +1 -1
  26. package/dist/chains/adapters/stellar.d.cts +1 -1
  27. package/dist/chains/adapters/stellar.d.ts +1 -1
  28. package/dist/chains/adapters/stellar.js +1 -1
  29. package/dist/chains/chain-adapter.cjs +1 -1
  30. package/dist/chains/chain-adapter.d.cts +1 -1
  31. package/dist/chains/chain-adapter.d.ts +1 -1
  32. package/dist/chains/chain-adapter.js +1 -1
  33. package/dist/chains/chains.cjs +1 -1
  34. package/dist/chains/chains.js +1 -1
  35. package/dist/{chunk-4MMD5K7I.js → chunk-3PDACUM7.js} +1 -1
  36. package/dist/chunk-6CNBIQGF.cjs +1 -0
  37. package/dist/{chunk-RRFUWLFA.cjs → chunk-72MJS3AC.cjs} +1 -1
  38. package/dist/{chunk-KU74JIV5.cjs → chunk-7FQTFYO6.cjs} +1 -1
  39. package/dist/{chunk-6K642Q7K.cjs → chunk-ARN45RZ4.cjs} +1 -1
  40. package/dist/chunk-BBMFGUOH.js +1 -0
  41. package/dist/{chunk-YBPZA7OS.cjs → chunk-BCXIEWZK.cjs} +1 -1
  42. package/dist/{chunk-KB3LRV7O.cjs → chunk-BJZM3EV2.cjs} +1 -1
  43. package/dist/{chunk-XQ4G3OAY.cjs → chunk-BOB3OT66.cjs} +1 -1
  44. package/dist/chunk-BZJ5TU7H.cjs +1 -0
  45. package/dist/{chunk-F7G24ULL.cjs → chunk-CIMSRCXA.cjs} +1 -1
  46. package/dist/{chunk-BXAEGY4R.js → chunk-CISUOQT6.js} +1 -1
  47. package/dist/{chunk-GA6L6LLY.js → chunk-CNXZJOVE.js} +1 -1
  48. package/dist/{chunk-OWDSSX2P.js → chunk-DCKFFFPG.js} +1 -1
  49. package/dist/{chunk-2VVOL5YA.cjs → chunk-DDNFHKJR.cjs} +1 -1
  50. package/dist/{chunk-OMIY25UF.js → chunk-DMNULXGD.js} +1 -1
  51. package/dist/{chunk-NWVX4HDR.js → chunk-EJCR7VKJ.js} +1 -1
  52. package/dist/chunk-EXFV7SBW.cjs +1 -0
  53. package/dist/{chunk-YWFITULD.cjs → chunk-EXY6WMAQ.cjs} +1 -1
  54. package/dist/{chunk-3URL7PDE.cjs → chunk-FO2AO5HQ.cjs} +1 -1
  55. package/dist/chunk-FXMXIAPL.js +1 -0
  56. package/dist/{chunk-HOISPTBK.js → chunk-GCIDUJF2.js} +1 -1
  57. package/dist/{chunk-743T6QIO.cjs → chunk-GIXJ5P3D.cjs} +1 -1
  58. package/dist/{chunk-FU4UIDNT.cjs → chunk-GZSM6NWF.cjs} +1 -1
  59. package/dist/{chunk-NJUHI3JB.cjs → chunk-HIKDNSEI.cjs} +1 -1
  60. package/dist/{chunk-ZFHKZBIF.cjs → chunk-HIWBYW72.cjs} +1 -1
  61. package/dist/{chunk-TBNAORVI.js → chunk-HJNJJGK6.js} +1 -1
  62. package/dist/{chunk-QTTIFAND.cjs → chunk-I3H3U7XW.cjs} +1 -1
  63. package/dist/{chunk-RKUCX4Z4.cjs → chunk-IW4FVUP5.cjs} +2 -2
  64. package/dist/{chunk-ECRMYAAK.cjs → chunk-K4CPNZQP.cjs} +1 -1
  65. package/dist/{chunk-L4KFGW4D.js → chunk-KQOBLF64.js} +1 -1
  66. package/dist/{chunk-GRUUP7GG.cjs → chunk-LSJDT5QL.cjs} +1 -1
  67. package/dist/{chunk-6LX3VLUM.js → chunk-M5A2GB2R.js} +1 -1
  68. package/dist/{chunk-S77GSXV7.cjs → chunk-MYLHEIBD.cjs} +1 -1
  69. package/dist/{chunk-JDQXT4RE.cjs → chunk-MYWEABPN.cjs} +1 -1
  70. package/dist/{chunk-4KOD6QEX.cjs → chunk-N2YQ7SK2.cjs} +1 -1
  71. package/dist/{chunk-PQJKDR32.js → chunk-N6LXJTAC.js} +1 -1
  72. package/dist/{chunk-WXFPGZKE.js → chunk-NFX2WUB6.js} +1 -1
  73. package/dist/{chunk-MPORS4W6.js → chunk-NLMPNCXE.js} +1 -1
  74. package/dist/{chunk-SELBUWOU.js → chunk-OE4UVHAK.js} +1 -1
  75. package/dist/{chunk-RPBBYBNA.js → chunk-OEMMPPUX.js} +1 -1
  76. package/dist/{chunk-GZFWSGHL.cjs → chunk-OI6QI264.cjs} +1 -1
  77. package/dist/{chunk-FBCBJROD.js → chunk-OMTJMVSG.js} +1 -1
  78. package/dist/{chunk-Y5LIA4JH.js → chunk-OTFPEC53.js} +1 -1
  79. package/dist/chunk-PH5XGZFF.cjs +1 -0
  80. package/dist/{chunk-DBMVGHLO.cjs → chunk-Q66YRLSW.cjs} +1 -1
  81. package/dist/{chunk-DBSQTBR2.js → chunk-QJALSMVI.js} +1 -1
  82. package/dist/{chunk-5HBCBS5W.cjs → chunk-QPCZFIUV.cjs} +1 -1
  83. package/dist/{chunk-4VCZ6SJS.js → chunk-R23CUQZX.js} +1 -1
  84. package/dist/{chunk-ZS2PU65K.js → chunk-S7DYRZI2.js} +1 -1
  85. package/dist/{chunk-AA2QXFGF.js → chunk-T6VDXOWC.js} +1 -1
  86. package/dist/{chunk-3DDMAIC4.js → chunk-TSJUK3ED.js} +1 -1
  87. package/dist/{chunk-4A7AWKUP.js → chunk-U37UWZ6M.js} +1 -1
  88. package/dist/{chunk-27L66KDT.cjs → chunk-U6SAS52Q.cjs} +1 -1
  89. package/dist/{chunk-RIYT6WJT.js → chunk-V3BCKXZ6.js} +1 -1
  90. package/dist/{chunk-VEYCF4FT.js → chunk-VBM6V2GS.js} +1 -1
  91. package/dist/chunk-VKXHD6UP.js +1 -0
  92. package/dist/{chunk-X2KTGVIG.js → chunk-WE32RGKM.js} +1 -1
  93. package/dist/chunk-WT45L3WI.cjs +1 -0
  94. package/dist/{chunk-SZKWBEFG.js → chunk-WTIV4TTS.js} +1 -1
  95. package/dist/chunk-XMN42YI5.cjs +1 -0
  96. package/dist/{chunk-DSEXTEKG.cjs → chunk-YEHBDKR3.cjs} +1 -1
  97. package/dist/{chunk-RUL7HCDJ.js → chunk-ZLKQZHEG.js} +1 -1
  98. package/dist/chunk-ZUG5BIGQ.js +1 -0
  99. package/dist/index.cjs +1 -1
  100. package/dist/index.d.cts +1 -1
  101. package/dist/index.d.ts +1 -1
  102. package/dist/index.js +1 -1
  103. package/dist/logger/index.cjs +1 -1
  104. package/dist/logger/index.js +1 -1
  105. package/dist/logger/init.cjs +1 -1
  106. package/dist/logger/init.js +1 -1
  107. package/dist/sdk.cjs +1 -1
  108. package/dist/sdk.d.cts +1 -1
  109. package/dist/sdk.d.ts +1 -1
  110. package/dist/sdk.js +1 -1
  111. package/dist/signers/descriptors/api-key.d.cts +1 -1
  112. package/dist/signers/descriptors/api-key.d.ts +1 -1
  113. package/dist/signers/descriptors/device.d.cts +1 -1
  114. package/dist/signers/descriptors/device.d.ts +1 -1
  115. package/dist/signers/descriptors/email.cjs +1 -1
  116. package/dist/signers/descriptors/email.d.cts +1 -1
  117. package/dist/signers/descriptors/email.d.ts +1 -1
  118. package/dist/signers/descriptors/email.js +1 -1
  119. package/dist/signers/descriptors/external-wallet.d.cts +1 -1
  120. package/dist/signers/descriptors/external-wallet.d.ts +1 -1
  121. package/dist/signers/descriptors/index.cjs +1 -1
  122. package/dist/signers/descriptors/index.d.cts +1 -1
  123. package/dist/signers/descriptors/index.d.ts +1 -1
  124. package/dist/signers/descriptors/index.js +1 -1
  125. package/dist/signers/descriptors/passkey.d.cts +1 -1
  126. package/dist/signers/descriptors/passkey.d.ts +1 -1
  127. package/dist/signers/descriptors/phone.cjs +1 -1
  128. package/dist/signers/descriptors/phone.d.cts +1 -1
  129. package/dist/signers/descriptors/phone.d.ts +1 -1
  130. package/dist/signers/descriptors/phone.js +1 -1
  131. package/dist/signers/descriptors/server.cjs +1 -1
  132. package/dist/signers/descriptors/server.d.cts +1 -1
  133. package/dist/signers/descriptors/server.d.ts +1 -1
  134. package/dist/signers/descriptors/server.js +1 -1
  135. package/dist/signers/descriptors/types.d.cts +2 -1
  136. package/dist/signers/descriptors/types.d.ts +2 -1
  137. package/dist/signers/device.d.cts +1 -1
  138. package/dist/signers/device.d.ts +1 -1
  139. package/dist/signers/evm-api-key.d.cts +1 -1
  140. package/dist/signers/evm-api-key.d.ts +1 -1
  141. package/dist/signers/evm-external-wallet.d.cts +1 -1
  142. package/dist/signers/evm-external-wallet.d.ts +1 -1
  143. package/dist/signers/external-wallet-signer.d.cts +1 -1
  144. package/dist/signers/external-wallet-signer.d.ts +1 -1
  145. package/dist/signers/index.cjs +1 -1
  146. package/dist/signers/index.d.cts +1 -1
  147. package/dist/signers/index.d.ts +1 -1
  148. package/dist/signers/index.js +1 -1
  149. package/dist/signers/non-custodial/index.cjs +1 -1
  150. package/dist/signers/non-custodial/index.d.cts +1 -1
  151. package/dist/signers/non-custodial/index.d.ts +1 -1
  152. package/dist/signers/non-custodial/index.js +1 -1
  153. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  154. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
  155. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
  156. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  157. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  158. package/dist/signers/non-custodial/ncs-signer.d.cts +3 -1
  159. package/dist/signers/non-custodial/ncs-signer.d.ts +3 -1
  160. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  161. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  162. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
  163. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
  164. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  165. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  166. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
  167. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
  168. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  169. package/dist/signers/passkey.d.cts +1 -1
  170. package/dist/signers/passkey.d.ts +1 -1
  171. package/dist/signers/server/assemble-server-signer.cjs +1 -1
  172. package/dist/signers/server/assemble-server-signer.d.cts +1 -1
  173. package/dist/signers/server/assemble-server-signer.d.ts +1 -1
  174. package/dist/signers/server/assemble-server-signer.js +1 -1
  175. package/dist/signers/server/evm-server-signer.d.cts +1 -1
  176. package/dist/signers/server/evm-server-signer.d.ts +1 -1
  177. package/dist/signers/server/helpers/derive-server-signer.cjs +1 -1
  178. package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
  179. package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
  180. package/dist/signers/server/helpers/derive-server-signer.js +1 -1
  181. package/dist/signers/server/helpers/index.cjs +1 -1
  182. package/dist/signers/server/helpers/index.d.cts +1 -1
  183. package/dist/signers/server/helpers/index.d.ts +1 -1
  184. package/dist/signers/server/helpers/index.js +1 -1
  185. package/dist/signers/server/index.cjs +1 -1
  186. package/dist/signers/server/index.d.cts +1 -1
  187. package/dist/signers/server/index.d.ts +1 -1
  188. package/dist/signers/server/index.js +1 -1
  189. package/dist/signers/server/resolver.cjs +1 -1
  190. package/dist/signers/server/resolver.d.cts +1 -1
  191. package/dist/signers/server/resolver.d.ts +1 -1
  192. package/dist/signers/server/resolver.js +1 -1
  193. package/dist/signers/server/solana-server-signer.d.cts +1 -1
  194. package/dist/signers/server/solana-server-signer.d.ts +1 -1
  195. package/dist/signers/server/stellar-server-signer.d.cts +1 -1
  196. package/dist/signers/server/stellar-server-signer.d.ts +1 -1
  197. package/dist/signers/solana-api-key.d.cts +1 -1
  198. package/dist/signers/solana-api-key.d.ts +1 -1
  199. package/dist/signers/solana-external-wallet.d.cts +1 -1
  200. package/dist/signers/solana-external-wallet.d.ts +1 -1
  201. package/dist/signers/stellar-external-wallet.d.cts +1 -1
  202. package/dist/signers/stellar-external-wallet.d.ts +1 -1
  203. package/dist/signers/types.cjs +1 -1
  204. package/dist/signers/types.d.cts +1 -1
  205. package/dist/signers/types.d.ts +1 -1
  206. package/dist/signers/types.js +1 -1
  207. package/dist/{types-CwTucqvZ.d.cts → types-DUaBfLJv.d.cts} +11 -1
  208. package/dist/{types-DUFjqW3o.d.ts → types-DnpNYkDF.d.ts} +11 -1
  209. package/dist/utils/constants.cjs +1 -1
  210. package/dist/utils/constants.js +1 -1
  211. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  212. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  213. package/dist/utils/device-signers/createDeviceSigner.d.cts +1 -1
  214. package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
  215. package/dist/utils/device-signers/index.cjs +1 -1
  216. package/dist/utils/device-signers/index.d.cts +1 -1
  217. package/dist/utils/device-signers/index.d.ts +1 -1
  218. package/dist/utils/device-signers/index.js +1 -1
  219. package/dist/utils/locators.d.cts +1 -1
  220. package/dist/utils/locators.d.ts +1 -1
  221. package/dist/utils/server-signers/createServerSigner.cjs +1 -1
  222. package/dist/utils/server-signers/createServerSigner.js +1 -1
  223. package/dist/utils/server-signers/index.cjs +1 -1
  224. package/dist/utils/server-signers/index.js +1 -1
  225. package/dist/utils/signer-locator.d.cts +1 -1
  226. package/dist/utils/signer-locator.d.ts +1 -1
  227. package/dist/utils/signer-mapping.d.cts +1 -1
  228. package/dist/utils/signer-mapping.d.ts +1 -1
  229. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  230. package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
  231. package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
  232. package/dist/wallets/__tests__/test-helpers.js +1 -1
  233. package/dist/wallets/evm.cjs +1 -1
  234. package/dist/wallets/evm.d.cts +1 -1
  235. package/dist/wallets/evm.d.ts +1 -1
  236. package/dist/wallets/evm.js +1 -1
  237. package/dist/wallets/services/balance-formatter.cjs +1 -1
  238. package/dist/wallets/services/balance-formatter.d.cts +1 -1
  239. package/dist/wallets/services/balance-formatter.d.ts +1 -1
  240. package/dist/wallets/services/balance-formatter.js +1 -1
  241. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  242. package/dist/wallets/services/device-recovery-service.d.cts +1 -1
  243. package/dist/wallets/services/device-recovery-service.d.ts +1 -1
  244. package/dist/wallets/services/device-recovery-service.js +1 -1
  245. package/dist/wallets/services/operation-poller.cjs +1 -1
  246. package/dist/wallets/services/operation-poller.d.cts +1 -1
  247. package/dist/wallets/services/operation-poller.d.ts +1 -1
  248. package/dist/wallets/services/operation-poller.js +1 -1
  249. package/dist/wallets/services/signer-manager.cjs +1 -1
  250. package/dist/wallets/services/signer-manager.d.cts +1 -1
  251. package/dist/wallets/services/signer-manager.d.ts +1 -1
  252. package/dist/wallets/services/signer-manager.js +1 -1
  253. package/dist/wallets/solana.cjs +1 -1
  254. package/dist/wallets/solana.d.cts +1 -1
  255. package/dist/wallets/solana.d.ts +1 -1
  256. package/dist/wallets/solana.js +1 -1
  257. package/dist/wallets/stellar.cjs +1 -1
  258. package/dist/wallets/stellar.d.cts +1 -1
  259. package/dist/wallets/stellar.d.ts +1 -1
  260. package/dist/wallets/stellar.js +1 -1
  261. package/dist/wallets/types.d.cts +1 -1
  262. package/dist/wallets/types.d.ts +1 -1
  263. package/dist/wallets/wallet-factory.cjs +1 -1
  264. package/dist/wallets/wallet-factory.d.cts +1 -1
  265. package/dist/wallets/wallet-factory.d.ts +1 -1
  266. package/dist/wallets/wallet-factory.js +1 -1
  267. package/dist/wallets/wallet.cjs +1 -1
  268. package/dist/wallets/wallet.d.cts +1 -1
  269. package/dist/wallets/wallet.d.ts +1 -1
  270. package/dist/wallets/wallet.js +1 -1
  271. package/package.json +3 -3
  272. package/dist/chunk-4MVRQKTM.js +0 -1
  273. package/dist/chunk-CEFLETL6.cjs +0 -1
  274. package/dist/chunk-F3YH6X3U.js +0 -1
  275. package/dist/chunk-JOSW3TFN.cjs +0 -1
  276. package/dist/chunk-MTRDSEGN.cjs +0 -1
  277. package/dist/chunk-P3CGYHYE.cjs +0 -1
  278. package/dist/chunk-RMDQOS3H.cjs +0 -1
  279. package/dist/chunk-TVGWMSVV.js +0 -1
  280. package/dist/chunk-UQAXOEBL.cjs +0 -1
  281. package/dist/chunk-WGXLV7K7.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkUQAXOEBLcjs = require('./chunk-UQAXOEBL.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkUQAXOEBLcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkJDQXT4REcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkUQAXOEBLcjs.b});if(_chunkJDQXT4REcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkBZJ5TU7Hcjs = require('./chunk-BZJ5TU7H.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkBZJ5TU7Hcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkMYWEABPNcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkBZJ5TU7Hcjs.b});if(_chunkMYWEABPNcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
@@ -1 +1 @@
1
- import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-TGFHY5PL.js";import{a as l}from"./chunk-Y5LIA4JH.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
1
+ import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-TGFHY5PL.js";import{a as l}from"./chunk-OTFPEC53.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-4MVRQKTM.js";import{a as r}from"./chunk-Y5LIA4JH.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-BBMFGUOH.js";import{a as r}from"./chunk-OTFPEC53.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
@@ -1 +1 @@
1
- var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}};function l(e){return e.type==="server"&&!("secret"in e)}function p(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,a as d,l as e,p as f};
1
+ var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}},s=class extends Error{constructor(n="The signer session expired before the code could be verified. A new code has been sent."){super(n),this.name="OnboardingSessionExpiredError"}};function p(e){return e.type==="server"&&!("secret"in e)}function S(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,a as d,s as e,p as f,S as g};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFN64UU7Mcjs = require('./chunk-FN64UU7M.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkJDQXT4REcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkJDQXT4REcjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunk3F4FMM3Rcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkFN64UU7Mcjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFN64UU7Mcjs = require('./chunk-FN64UU7M.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkMYWEABPNcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkMYWEABPNcjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunk3F4FMM3Rcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkFN64UU7Mcjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-6LX3VLUM.js";import{y as u}from"./chunk-TGFHY5PL.js";import{a as t}from"./chunk-Y5LIA4JH.js";import{a as f,c,h as s}from"./chunk-NU7VF7MC.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
1
+ import{a as i}from"./chunk-M5A2GB2R.js";import{y as u}from"./chunk-TGFHY5PL.js";import{a as t}from"./chunk-OTFPEC53.js";import{a as f,c,h as s}from"./chunk-NU7VF7MC.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-TGFHY5PL.js";import{a as E}from"./chunk-Y5LIA4JH.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{ee as a,I as b,C as c,g as d,F as e,te as f};
1
+ import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-TGFHY5PL.js";import{a as E}from"./chunk-OTFPEC53.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{ee as a,I as b,C as c,g as d,F as e,te as f};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIW4FVUP5cjs = require('./chunk-IW4FVUP5.cjs');var _chunkDBWMNPH7cjs = require('./chunk-DBWMNPH7.cjs');var _chunkNML6ZUFMcjs = require('./chunk-NML6ZUFM.cjs');var _chunkPH5XGZFFcjs = require('./chunk-PH5XGZFF.cjs');var _chunkMQE44PARcjs = require('./chunk-MQE44PAR.cjs');var _chunkUWX7ID4Xcjs = require('./chunk-UWX7ID4X.cjs');var _chunkXMN42YI5cjs = require('./chunk-XMN42YI5.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');function u(r){switch(r){case"email":return _chunkPH5XGZFFcjs.a;case"phone":return _chunkXMN42YI5cjs.a;case"passkey":return _chunkUWX7ID4Xcjs.a;case"device":return _chunkNML6ZUFMcjs.a;case"api-key":return _chunkDBWMNPH7cjs.a;case"server":return _chunkIW4FVUP5cjs.a;case"external-wallet":return _chunkMQE44PARcjs.b;default:throw new (0, _chunk3F4FMM3Rcjs.k)(`Unknown signer type: ${r}`)}}exports.a = u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZFWSGHLcjs = require('./chunk-GZFWSGHL.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkGZFWSGHLcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkGZFWSGHLcjs.a.getOptions(e),alias:e.alias,recovery:_chunkGZFWSGHLcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkGZFWSGHLcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkGZFWSGHLcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkGZFWSGHLcjs.a.getInitialSigners(e)},_chunkGZFWSGHLcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunkJDQXT4REcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkJDQXT4REcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkJDQXT4REcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkJDQXT4REcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkJDQXT4REcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkJDQXT4REcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkJDQXT4REcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkJDQXT4REcjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkJDQXT4REcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunk3F4FMM3Rcjs.y)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkJDQXT4REcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkJDQXT4REcjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkOI6QI264cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkOI6QI264cjs.a.getOptions(e),alias:e.alias,recovery:_chunkOI6QI264cjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkOI6QI264cjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkOI6QI264cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkOI6QI264cjs.a.getInitialSigners(e)},_chunkOI6QI264cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunk3F4FMM3Rcjs.y)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkMYWEABPNcjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZFWSGHLcjs = require('./chunk-GZFWSGHL.cjs');var _chunkKB3LRV7Ocjs = require('./chunk-KB3LRV7O.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkGZFWSGHLcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkGZFWSGHLcjs.a.getOptions(e),alias:e.alias,recovery:_chunkGZFWSGHLcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkGZFWSGHLcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkGZFWSGHLcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkGZFWSGHLcjs.a.getInitialSigners(e)},_chunkGZFWSGHLcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkJDQXT4REcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkJDQXT4REcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkJDQXT4REcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkJDQXT4REcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkJDQXT4REcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkJDQXT4REcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkJDQXT4REcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkJDQXT4REcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkJDQXT4REcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkJDQXT4REcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkJDQXT4REcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkJDQXT4REcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkJDQXT4REcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkKB3LRV7Ocjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunkBJZM3EV2cjs = require('./chunk-BJZM3EV2.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkOI6QI264cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkOI6QI264cjs.a.getOptions(e),alias:e.alias,recovery:_chunkOI6QI264cjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkOI6QI264cjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkOI6QI264cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkOI6QI264cjs.a.getInitialSigners(e)},_chunkOI6QI264cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkMYWEABPNcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkMYWEABPNcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkMYWEABPNcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkBJZM3EV2cjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.7.0";var c="WALLETS_SDK",r=t,a=s,d=500;export{c as a,r as b,a as c,d};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-4MMD5K7I.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
1
+ import{a as m}from"./chunk-3PDACUM7.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZFWSGHLcjs = require('./chunk-GZFWSGHL.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkR7S55N7Jcjs = require('./chunk-R7S55N7J.cjs');var _chunkSEXK7X55cjs = require('./chunk-SEXK7X55.cjs');var _chunkDBMVGHLOcjs = require('./chunk-DBMVGHLO.cjs');var _chunkKB3LRV7Ocjs = require('./chunk-KB3LRV7O.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",u= exports.a =class{constructor(r){this.apiClient=r}getWallet(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i,t;if(typeof r=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");i=r,t=e}else{if(this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");t=r,i=this.getWalletLocator(t)}let a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkKB3LRV7Ocjs.f.call(void 0, t.chain,this.apiClient.environment)});_chunkJDQXT4REcjs.a.info("walletFactory.getWallet.start");let n=yield this.apiClient.getWallet(i);if("error"in n)throw _chunkJDQXT4REcjs.a.warn("walletFactory.getWallet.notFound",{error:n.error}),new (0, _chunk3F4FMM3Rcjs.e)(JSON.stringify(n));return _chunkJDQXT4REcjs.a.info("walletFactory.getWallet.success",{address:n.address}),yield this.createWalletInstance(n,a)})}createWallet(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,d,h,C,p,F,P;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},r),{chain:_chunkKB3LRV7Ocjs.f.call(void 0, r.chain,this.apiClient.environment)});if(yield(d=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:d.call(c),_chunkJDQXT4REcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkJDQXT4REcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunk3F4FMM3Rcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let t=((h=e.options)==null?void 0:h.deviceSignerKeyStorage)!=null&&e.chain!=="solana"?this.ensureDeviceSignerInSigners(e):(C=e.signers)!=null?C:[],a=yield this.registerSigners(t,e.chain,(p=e.options)==null?void 0:p.deviceSignerKeyStorage),n;if(e.recovery.type==="passkey"&&e.recovery.id==null)n=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunkDBMVGHLOcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);n={type:"server",address:I}}else n=e.recovery;let s=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:n},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(F=e.owner)!=null?F:void 0,alias:(P=e.alias)!=null?P:void 0});if("error"in s)throw _chunkJDQXT4REcjs.a.error("walletFactory.createWallet.error",{error:s.error}),new (0, _chunk3F4FMM3Rcjs.g)(JSON.stringify(s));return _chunkJDQXT4REcjs.a.info("walletFactory.createWallet.success",{address:s.address}),yield this.createWalletInstance(s,e)})}createWalletInstance(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,C;this.validateExistingWalletConfig(r,e);let i=e,t=r.config.adminSigner,a=((h=i.recovery)==null?void 0:h.type)==="server"||((C=i.recovery)==null?void 0:C.type)==="external-wallet"?i.recovery:t,n=r.config.delegatedSigners,s=n;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=i.signers);let o=t.type==="server"&&"address"in t&&!("secret"in t)?t.address:void 0,c=(n!=null?n:[]).filter(p=>p.type==="server"&&"address"in p&&!("secret"in p)).map(p=>p.address),d=new (0, _chunkGZFWSGHLcjs.a)({chain:e.chain,address:r.address,owner:r.owner,options:e.options,alias:e.alias,recovery:a,apiRecoveryServerSignerAddress:o,apiDelegatedServerSignerAddresses:c,signers:s!=null?s:[]},this.apiClient);return yield d.waitForInit(),d})}getWalletLocator(r){return`me:${this.getChainType(r.chain)}:smart`+(r.alias!=null?`:alias:${r.alias}`:"")}createPasskeySigner(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;if(r.type!=="passkey")throw new Error("Signer is not a passkey");let e=(t=r.name)!=null?t:`Crossmint Wallet ${Date.now()}`,i=r.onCreatePasskey?yield r.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:i.id,name:e,publicKey:{x:i.publicKey.x.toString(),y:i.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(r){var t;let e=(t=r.signers)!=null?t:[];return e.some(a=>a.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(r,e){if(e.owner!=null&&r.owner!=null&&_chunkSEXK7X55cjs.b.call(void 0, e.owner)!==_chunkSEXK7X55cjs.b.call(void 0, r.owner))throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&r.chainType!=="solana"||e.chain!=="solana"&&r.chainType==="solana"||e.chain==="stellar"&&r.chainType!=="stellar"||e.chain!=="stellar"&&r.chainType==="stellar")throw new (0, _chunk3F4FMM3Rcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${r.chainType}.`);if(r.type!=="smart")return;let i=e;if(i.recovery!=null||i.signers!=null){let t=r.config,a=t==null?void 0:t.adminSigner;if(i.recovery!=null&&a!=null){if(i.recovery.type!==a.type)throw new (0, _chunk3F4FMM3Rcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkSEXK7X55cjs.c.call(void 0, i.recovery,a)}let n=i.signers;n!=null&&this.validateSigners(r,n,e.chain)}}validateSigners(r,e,i){let t=r.config,a=t==null?void 0:t.delegatedSigners;if(e.length!==0){if(a==null||a.length===0)throw new (0, _chunk3F4FMM3Rcjs.g)(`${e.length} signer(s) specified, but wallet "${r.address}" has no signers. ${$}`);for(let n of e){let s=a.find(o=>{if(this.isMatchingPasskeySigner(n,o,t)||o.type==="device"&&n.type==="device")return!0;if(n.type==="server"){let{primary:c,legacy:d}=_chunkDBMVGHLOcjs.c.call(void 0, n,i,this.apiClient.projectId,this.apiClient.environment);return o.locator===`server:${c.derivedAddress}`||d!=null&&o.locator===`server:${d.derivedAddress}`}return o.locator===_chunkR7S55N7Jcjs.a.call(void 0, n)});if(s==null){let o=a.map(c=>c.locator).join(", ");throw new (0, _chunk3F4FMM3Rcjs.g)(`Signer '${n.type}' does not exist in wallet "${r.address}". Available signers: ${o}. ${$}`)}_chunkSEXK7X55cjs.c.call(void 0, n,s)}}}isMatchingPasskeySigner(r,e,i){var a,n;let t=((n=(a=i.delegatedSigners)==null?void 0:a.filter(s=>s.type==="passkey").length)!=null?n:0)+(i.adminSigner.type==="passkey"?1:0);if(r.type==="passkey"){if(r.id==null&&t===1)return e.type==="passkey";if(r.id==null&&t>1)throw new (0, _chunk3F4FMM3Rcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(r,e,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;return yield Promise.all((t=r==null?void 0:r.map(a=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(a.type==="passkey")return a.id==null?{signer:yield this.createPasskeySigner(a)}:{signer:a};if(a.type==="device"){if(a.publicKey!=null)return{signer:{type:"device",publicKey:a.publicKey,name:a.name}};if(a.locator!=null)return{signer:a.locator};if(i==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Device signer key storage is required for device signers");let n=yield _chunkGMU3ZYLScjs.a.call(void 0, i);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(a.type==="server"&&e!=null){let{derivedAddress:n}=_chunkDBMVGHLOcjs.b.call(void 0, a,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:_chunkR7S55N7Jcjs.a.call(void 0, a)}})))!=null?t:[])})}getChainType(r){return r==="solana"?"solana":r==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"walletFactory.getWallet",buildContext(r,e){if(typeof e[0]=="string"){let t=e[1];return{walletLocator:e[0],chain:t==null?void 0:t.chain}}let i=e[0];return{chain:i==null?void 0:i.chain}}})],u.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkJDQXT4REcjs.a,methodName:"walletFactory.createWallet",buildContext(r,e){return{chain:e[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkR7S55N7Jcjs = require('./chunk-R7S55N7J.cjs');var _chunkSEXK7X55cjs = require('./chunk-SEXK7X55.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkBJZM3EV2cjs = require('./chunk-BJZM3EV2.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",u= exports.a =class{constructor(r){this.apiClient=r}getWallet(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i,t;if(typeof r=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");i=r,t=e}else{if(this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");t=r,i=this.getWalletLocator(t)}let a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkBJZM3EV2cjs.f.call(void 0, t.chain,this.apiClient.environment)});_chunkMYWEABPNcjs.a.info("walletFactory.getWallet.start");let n=yield this.apiClient.getWallet(i);if("error"in n)throw _chunkMYWEABPNcjs.a.warn("walletFactory.getWallet.notFound",{error:n.error}),new (0, _chunk3F4FMM3Rcjs.e)(JSON.stringify(n));return _chunkMYWEABPNcjs.a.info("walletFactory.getWallet.success",{address:n.address}),yield this.createWalletInstance(n,a)})}createWallet(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,d,h,C,p,F,P;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},r),{chain:_chunkBJZM3EV2cjs.f.call(void 0, r.chain,this.apiClient.environment)});if(yield(d=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:d.call(c),_chunkMYWEABPNcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkMYWEABPNcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunk3F4FMM3Rcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let t=((h=e.options)==null?void 0:h.deviceSignerKeyStorage)!=null&&e.chain!=="solana"?this.ensureDeviceSignerInSigners(e):(C=e.signers)!=null?C:[],a=yield this.registerSigners(t,e.chain,(p=e.options)==null?void 0:p.deviceSignerKeyStorage),n;if(e.recovery.type==="passkey"&&e.recovery.id==null)n=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunkQ66YRLSWcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);n={type:"server",address:I}}else n=e.recovery;let s=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:n},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(F=e.owner)!=null?F:void 0,alias:(P=e.alias)!=null?P:void 0});if("error"in s)throw _chunkMYWEABPNcjs.a.error("walletFactory.createWallet.error",{error:s.error}),new (0, _chunk3F4FMM3Rcjs.g)(JSON.stringify(s));return _chunkMYWEABPNcjs.a.info("walletFactory.createWallet.success",{address:s.address}),yield this.createWalletInstance(s,e)})}createWalletInstance(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,C;this.validateExistingWalletConfig(r,e);let i=e,t=r.config.adminSigner,a=((h=i.recovery)==null?void 0:h.type)==="server"||((C=i.recovery)==null?void 0:C.type)==="external-wallet"?i.recovery:t,n=r.config.delegatedSigners,s=n;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=i.signers);let o=t.type==="server"&&"address"in t&&!("secret"in t)?t.address:void 0,c=(n!=null?n:[]).filter(p=>p.type==="server"&&"address"in p&&!("secret"in p)).map(p=>p.address),d=new (0, _chunkOI6QI264cjs.a)({chain:e.chain,address:r.address,owner:r.owner,options:e.options,alias:e.alias,recovery:a,apiRecoveryServerSignerAddress:o,apiDelegatedServerSignerAddresses:c,signers:s!=null?s:[]},this.apiClient);return yield d.waitForInit(),d})}getWalletLocator(r){return`me:${this.getChainType(r.chain)}:smart`+(r.alias!=null?`:alias:${r.alias}`:"")}createPasskeySigner(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;if(r.type!=="passkey")throw new Error("Signer is not a passkey");let e=(t=r.name)!=null?t:`Crossmint Wallet ${Date.now()}`,i=r.onCreatePasskey?yield r.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:i.id,name:e,publicKey:{x:i.publicKey.x.toString(),y:i.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(r){var t;let e=(t=r.signers)!=null?t:[];return e.some(a=>a.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(r,e){if(e.owner!=null&&r.owner!=null&&_chunkSEXK7X55cjs.b.call(void 0, e.owner)!==_chunkSEXK7X55cjs.b.call(void 0, r.owner))throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&r.chainType!=="solana"||e.chain!=="solana"&&r.chainType==="solana"||e.chain==="stellar"&&r.chainType!=="stellar"||e.chain!=="stellar"&&r.chainType==="stellar")throw new (0, _chunk3F4FMM3Rcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${r.chainType}.`);if(r.type!=="smart")return;let i=e;if(i.recovery!=null||i.signers!=null){let t=r.config,a=t==null?void 0:t.adminSigner;if(i.recovery!=null&&a!=null){if(i.recovery.type!==a.type)throw new (0, _chunk3F4FMM3Rcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkSEXK7X55cjs.c.call(void 0, i.recovery,a)}let n=i.signers;n!=null&&this.validateSigners(r,n,e.chain)}}validateSigners(r,e,i){let t=r.config,a=t==null?void 0:t.delegatedSigners;if(e.length!==0){if(a==null||a.length===0)throw new (0, _chunk3F4FMM3Rcjs.g)(`${e.length} signer(s) specified, but wallet "${r.address}" has no signers. ${$}`);for(let n of e){let s=a.find(o=>{if(this.isMatchingPasskeySigner(n,o,t)||o.type==="device"&&n.type==="device")return!0;if(n.type==="server"){let{primary:c,legacy:d}=_chunkQ66YRLSWcjs.c.call(void 0, n,i,this.apiClient.projectId,this.apiClient.environment);return o.locator===`server:${c.derivedAddress}`||d!=null&&o.locator===`server:${d.derivedAddress}`}return o.locator===_chunkR7S55N7Jcjs.a.call(void 0, n)});if(s==null){let o=a.map(c=>c.locator).join(", ");throw new (0, _chunk3F4FMM3Rcjs.g)(`Signer '${n.type}' does not exist in wallet "${r.address}". Available signers: ${o}. ${$}`)}_chunkSEXK7X55cjs.c.call(void 0, n,s)}}}isMatchingPasskeySigner(r,e,i){var a,n;let t=((n=(a=i.delegatedSigners)==null?void 0:a.filter(s=>s.type==="passkey").length)!=null?n:0)+(i.adminSigner.type==="passkey"?1:0);if(r.type==="passkey"){if(r.id==null&&t===1)return e.type==="passkey";if(r.id==null&&t>1)throw new (0, _chunk3F4FMM3Rcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(r,e,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;return yield Promise.all((t=r==null?void 0:r.map(a=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(a.type==="passkey")return a.id==null?{signer:yield this.createPasskeySigner(a)}:{signer:a};if(a.type==="device"){if(a.publicKey!=null)return{signer:{type:"device",publicKey:a.publicKey,name:a.name}};if(a.locator!=null)return{signer:a.locator};if(i==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Device signer key storage is required for device signers");let n=yield _chunkGMU3ZYLScjs.a.call(void 0, i);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(a.type==="server"&&e!=null){let{derivedAddress:n}=_chunkQ66YRLSWcjs.b.call(void 0, a,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:_chunkR7S55N7Jcjs.a.call(void 0, a)}})))!=null?t:[])})}getChainType(r){return r==="solana"?"solana":r==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"walletFactory.getWallet",buildContext(r,e){if(typeof e[0]=="string"){let t=e[1];return{walletLocator:e[0],chain:t==null?void 0:t.chain}}let i=e[0];return{chain:i==null?void 0:i.chain}}})],u.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"walletFactory.createWallet",buildContext(r,e){return{chain:e[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk743T6QIOcjs = require('./chunk-743T6QIO.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkS77GSXV7cjs = require('./chunk-S77GSXV7.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkJDQXT4REcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkS77GSXV7cjs.a)(e);this.walletFactory=new (0, _chunk743T6QIOcjs.a)(t),_chunkJDQXT4REcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGIXJ5P3Dcjs = require('./chunk-GIXJ5P3D.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkMYLHEIBDcjs = require('./chunk-MYLHEIBD.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkMYWEABPNcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkMYLHEIBDcjs.a)(e);this.walletFactory=new (0, _chunkGIXJ5P3Dcjs.a)(t),_chunkMYWEABPNcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.6.2";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.7.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUQAXOEBLcjs = require('./chunk-UQAXOEBL.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkUQAXOEBLcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkJDQXT4REcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkUQAXOEBLcjs.b});if(_chunkJDQXT4REcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBZJ5TU7Hcjs = require('./chunk-BZJ5TU7H.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkBZJ5TU7Hcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkMYWEABPNcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkBZJ5TU7Hcjs.b});if(_chunkMYWEABPNcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -1 +1 @@
1
- import{c as g}from"./chunk-IUMKG7QD.js";import{j as s}from"./chunk-TGFHY5PL.js";import{a as i}from"./chunk-Y5LIA4JH.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
1
+ import{c as g}from"./chunk-IUMKG7QD.js";import{j as s}from"./chunk-TGFHY5PL.js";import{a as i}from"./chunk-OTFPEC53.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDBMVGHLOcjs = require('./chunk-DBMVGHLO.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var y,c,A,u,f,C,g,t,o,k,w,a,K= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,g,null);_chunkDSIFRRBScjs.e.call(void 0, this,t,null);_chunkDSIFRRBScjs.f.call(void 0, this,y,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,c,r.projectId),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.environment),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.apiRecoveryAddress),_chunkDSIFRRBScjs.f.call(void 0, this,f,r.apiDelegatedAddresses),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.knownOnChainAddresses)}deriveCandidates(r){return _chunkDBMVGHLOcjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,y),_chunkDSIFRRBScjs.d.call(void 0, this,c),_chunkDSIFRRBScjs.d.call(void 0, this,A))}resolveDerivation(r){var l;if(_chunk5HBCBS5Wcjs.e.call(void 0, r)){if(_chunkDSIFRRBScjs.d.call(void 0, this,t)!=null)return _chunkDSIFRRBScjs.d.call(void 0, this,t);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:e,legacy:i}=this.deriveCandidates(r),s=(l=_chunkDSIFRRBScjs.d.call(void 0, this,g))!=null?l:_chunkDSIFRRBScjs.d.call(void 0, this,t);if(s!=null){let p=s.derivedAddress;if(p===e.derivedAddress||i!=null&&p===i.derivedAddress)return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}if(i!=null){if(i.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;if(_chunkDSIFRRBScjs.d.call(void 0, this,C).call(this).includes(i.derivedAddress))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;_chunkLWA3SX6Zcjs.a.call(void 0, i.derivedKeyBytes)}return e}apiLocator(r){let e=this.resolveDerivation(r);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),`server:${e.derivedAddress}`}resolveForUseSigner(r,e,i){let{primary:s,legacy:l}=this.deriveCandidates(r);if(_chunkDSIFRRBScjs.g.call(void 0, this,o,k).call(this,s,l,e)!=null)return{kind:"delegated"};if(i())return _chunkDSIFRRBScjs.g.call(void 0, this,o,w).call(this,s,l),{kind:"recovery"};let p=l!=null?`"server:${s.derivedAddress}" or "server:${l.derivedAddress}"`:`"server:${s.derivedAddress}"`;return _chunkLWA3SX6Zcjs.a.call(void 0, s.derivedKeyBytes,l==null?void 0:l.derivedKeyBytes),{kind:"unregistered",message:`Signer ${p} is not registered in this wallet.`}}keyMaterialForAssembly(r){let e=this.resolveDerivation(r),i=new Uint8Array(e.derivedKeyBytes);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),{derivedKeyBytes:i,derivedAddress:e.derivedAddress}}candidateAddresses(r){if(_chunk5HBCBS5Wcjs.e.call(void 0, r))return[r.address];let{primary:e,legacy:i}=this.deriveCandidates(r),s=[e.derivedAddress];return i!=null&&s.push(i.derivedAddress),_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}resetDelegatedCache(){var r;_chunkLWA3SX6Zcjs.a.call(void 0, (r=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:r.derivedKeyBytes),_chunkDSIFRRBScjs.f.call(void 0, this,g,null)}get hasRecoveryResolution(){return _chunkDSIFRRBScjs.d.call(void 0, this,t)!=null}get resolvedRecoveryAddress(){var r,e;return(e=(r=_chunkDSIFRRBScjs.d.call(void 0, this,t))==null?void 0:r.derivedAddress)!=null?e:null}get apiRecoveryAddress(){return _chunkDSIFRRBScjs.d.call(void 0, this,u)}get apiDelegatedAddresses(){return _chunkDSIFRRBScjs.d.call(void 0, this,f)}};y=new WeakMap,c=new WeakMap,A=new WeakMap,u=new WeakMap,f=new WeakMap,C=new WeakMap,g=new WeakMap,t=new WeakMap,o=new WeakSet,k=function(r,e,i){return i.includes(`server:${r.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r):e!=null&&i.includes(`server:${e.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):null},w=function(r,e){return _chunkDSIFRRBScjs.d.call(void 0, this,u)!=null&&e!=null&&e.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u)?(_chunkDSIFRRBScjs.f.call(void 0, this,t,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):(_chunkDSIFRRBScjs.f.call(void 0, this,t,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r)},a=function(r,e){e!=null&&e!==r&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)};exports.a = K;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var y,c,A,u,f,C,g,t,o,k,w,a,K= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,g,null);_chunkDSIFRRBScjs.e.call(void 0, this,t,null);_chunkDSIFRRBScjs.f.call(void 0, this,y,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,c,r.projectId),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.environment),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.apiRecoveryAddress),_chunkDSIFRRBScjs.f.call(void 0, this,f,r.apiDelegatedAddresses),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.knownOnChainAddresses)}deriveCandidates(r){return _chunkQ66YRLSWcjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,y),_chunkDSIFRRBScjs.d.call(void 0, this,c),_chunkDSIFRRBScjs.d.call(void 0, this,A))}resolveDerivation(r){var l;if(_chunkQPCZFIUVcjs.f.call(void 0, r)){if(_chunkDSIFRRBScjs.d.call(void 0, this,t)!=null)return _chunkDSIFRRBScjs.d.call(void 0, this,t);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:e,legacy:i}=this.deriveCandidates(r),s=(l=_chunkDSIFRRBScjs.d.call(void 0, this,g))!=null?l:_chunkDSIFRRBScjs.d.call(void 0, this,t);if(s!=null){let p=s.derivedAddress;if(p===e.derivedAddress||i!=null&&p===i.derivedAddress)return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}if(i!=null){if(i.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;if(_chunkDSIFRRBScjs.d.call(void 0, this,C).call(this).includes(i.derivedAddress))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;_chunkLWA3SX6Zcjs.a.call(void 0, i.derivedKeyBytes)}return e}apiLocator(r){let e=this.resolveDerivation(r);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),`server:${e.derivedAddress}`}resolveForUseSigner(r,e,i){let{primary:s,legacy:l}=this.deriveCandidates(r);if(_chunkDSIFRRBScjs.g.call(void 0, this,o,k).call(this,s,l,e)!=null)return{kind:"delegated"};if(i())return _chunkDSIFRRBScjs.g.call(void 0, this,o,w).call(this,s,l),{kind:"recovery"};let p=l!=null?`"server:${s.derivedAddress}" or "server:${l.derivedAddress}"`:`"server:${s.derivedAddress}"`;return _chunkLWA3SX6Zcjs.a.call(void 0, s.derivedKeyBytes,l==null?void 0:l.derivedKeyBytes),{kind:"unregistered",message:`Signer ${p} is not registered in this wallet.`}}keyMaterialForAssembly(r){let e=this.resolveDerivation(r),i=new Uint8Array(e.derivedKeyBytes);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),{derivedKeyBytes:i,derivedAddress:e.derivedAddress}}candidateAddresses(r){if(_chunkQPCZFIUVcjs.f.call(void 0, r))return[r.address];let{primary:e,legacy:i}=this.deriveCandidates(r),s=[e.derivedAddress];return i!=null&&s.push(i.derivedAddress),_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}resetDelegatedCache(){var r;_chunkLWA3SX6Zcjs.a.call(void 0, (r=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:r.derivedKeyBytes),_chunkDSIFRRBScjs.f.call(void 0, this,g,null)}get hasRecoveryResolution(){return _chunkDSIFRRBScjs.d.call(void 0, this,t)!=null}get resolvedRecoveryAddress(){var r,e;return(e=(r=_chunkDSIFRRBScjs.d.call(void 0, this,t))==null?void 0:r.derivedAddress)!=null?e:null}get apiRecoveryAddress(){return _chunkDSIFRRBScjs.d.call(void 0, this,u)}get apiDelegatedAddresses(){return _chunkDSIFRRBScjs.d.call(void 0, this,f)}};y=new WeakMap,c=new WeakMap,A=new WeakMap,u=new WeakMap,f=new WeakMap,C=new WeakMap,g=new WeakMap,t=new WeakMap,o=new WeakSet,k=function(r,e,i){return i.includes(`server:${r.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r):e!=null&&i.includes(`server:${e.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):null},w=function(r,e){return _chunkDSIFRRBScjs.d.call(void 0, this,u)!=null&&e!=null&&e.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u)?(_chunkDSIFRRBScjs.f.call(void 0, this,t,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):(_chunkDSIFRRBScjs.f.call(void 0, this,t,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r)},a=function(r,e){e!=null&&e!==r&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)};exports.a = K;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
- Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!_chunk5HBCBS5Wcjs.e.call(void 0, e)||r.serverSigners.hasRecoveryResolution},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};exports.a = C;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
+ Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!_chunkQPCZFIUVcjs.f.call(void 0, e)||r.serverSigners.hasRecoveryResolution},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};exports.a = C;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP3CGYHYEcjs = require('./chunk-P3CGYHYE.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunkP3CGYHYEcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunkP3CGYHYEcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6CNBIQGFcjs = require('./chunk-6CNBIQGF.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunk6CNBIQGFcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunk6CNBIQGFcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-4MVRQKTM.js";import{a as s}from"./chunk-Y5LIA4JH.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
1
+ import{a,b as g}from"./chunk-BBMFGUOH.js";import{a as s}from"./chunk-OTFPEC53.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkNJUHI3JBcjs = require('./chunk-NJUHI3JB.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function N(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w,p;let{timeoutMs:s=6e4,backoffMultiplier:u=1.1,maxBackoffMs:n=2e3}=r!=null?r:{},{initialBackoffMs:o=_chunkNJUHI3JBcjs.d}=r!=null?r:{};_chunkJDQXT4REcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:s});let M=Date.now(),t;do{if(Date.now()-M>s)throw new (0, _chunk3F4FMM3Rcjs.A)("Transaction confirmation timeout");if(t=yield i.getTransaction(a,e),t.error)throw new (0, _chunk3F4FMM3Rcjs.z)(JSON.stringify(t));yield E(o),o=Math.min(o*u,n)}while(t.status==="pending");if(t.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.B)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunk3F4FMM3Rcjs.C)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let A="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(w=t.onChain.txId)!=null?w:A;if(g==null)throw new (0, _chunk3F4FMM3Rcjs.D)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(p=t.onChain.explorerLink)!=null?p:"",transactionId:t.id}})}function O(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:s=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>s)throw new (0, _chunk3F4FMM3Rcjs.w)("Signature confirmation timeout");if(yield new Promise(o=>setTimeout(o,_chunkNJUHI3JBcjs.d)),n=yield i.getSignature(a,e),"error"in n)throw new (0, _chunk3F4FMM3Rcjs.u)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.r)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunk3F4FMM3Rcjs.u)("Signature not available");return{signature:n.outputSignature,signatureId:e}})}function E(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(a=>setTimeout(a,i))})}exports.a = N; exports.b = O;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkHIKDNSEIcjs = require('./chunk-HIKDNSEI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function N(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w,p;let{timeoutMs:s=6e4,backoffMultiplier:u=1.1,maxBackoffMs:n=2e3}=r!=null?r:{},{initialBackoffMs:o=_chunkHIKDNSEIcjs.d}=r!=null?r:{};_chunkMYWEABPNcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:s});let M=Date.now(),t;do{if(Date.now()-M>s)throw new (0, _chunk3F4FMM3Rcjs.A)("Transaction confirmation timeout");if(t=yield i.getTransaction(a,e),t.error)throw new (0, _chunk3F4FMM3Rcjs.z)(JSON.stringify(t));yield E(o),o=Math.min(o*u,n)}while(t.status==="pending");if(t.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.B)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunk3F4FMM3Rcjs.C)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let A="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(w=t.onChain.txId)!=null?w:A;if(g==null)throw new (0, _chunk3F4FMM3Rcjs.D)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(p=t.onChain.explorerLink)!=null?p:"",transactionId:t.id}})}function O(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:s=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>s)throw new (0, _chunk3F4FMM3Rcjs.w)("Signature confirmation timeout");if(yield new Promise(o=>setTimeout(o,_chunkHIKDNSEIcjs.d)),n=yield i.getSignature(a,e),"error"in n)throw new (0, _chunk3F4FMM3Rcjs.u)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.r)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunk3F4FMM3Rcjs.u)("Signature not available");return{signature:n.outputSignature,signatureId:e}})}function E(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(a=>setTimeout(a,i))})}exports.a = N; exports.b = O;
@@ -1 +1 @@
1
- import{a as ie}from"./chunk-HOISPTBK.js";import{a as ae}from"./chunk-PQJKDR32.js";import{a as se,b as oe}from"./chunk-AA2QXFGF.js";import{a as ne}from"./chunk-F3YH6X3U.js";import{a as ee}from"./chunk-FBCBJROD.js";import{a as F}from"./chunk-WXFPGZKE.js";import{a as re,b as te}from"./chunk-XKMIK6EW.js";import{a as k}from"./chunk-GNON524X.js";import{a as Z}from"./chunk-4MVRQKTM.js";import{e as $}from"./chunk-OWDSSX2P.js";import{a as X,b as Y}from"./chunk-4MMD5K7I.js";import{b as Q}from"./chunk-IUMKG7QD.js";import{f as K}from"./chunk-NWVX4HDR.js";import{E as z,d as J,e as _,j as O,l as G,m as U,u as B,v as H,x as j,y as q,z as V}from"./chunk-TGFHY5PL.js";import{a}from"./chunk-Y5LIA4JH.js";import{d as M}from"./chunk-TVGWMSVV.js";import{a as y,b as N,c as R,d as i,e as b,f as m,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var L,c,T,P,l,S,x,I,E,A=class{constructor(e,r){b(this,L);b(this,c);b(this,T);b(this,P);b(this,l);b(this,S);b(this,x,[]);b(this,I);b(this,E,null);let{chain:t,address:n,owner:s,options:h,alias:g,recovery:d,apiRecoveryServerSignerAddress:v,apiDelegatedServerSignerAddresses:p,signers:C,signer:f}=e;m(this,c,r),this.chain=t,this.address=n,this.owner=s,m(this,L,h),this.alias=g;let w=null;v!=null?w=v:d.type==="server"&&$(d)&&(w=d.address),m(this,x,p!=null?p:[]),m(this,T,C!=null?C:[]),m(this,P,new ee({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:w,apiDelegatedAddresses:i(this,x),knownOnChainAddresses:()=>[...i(this,T).filter(u=>u.type==="server"&&$(u)).map(u=>u.address),...i(this,x)]})),m(this,l,new ne({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:d,initialSigners:i(this,T),signers:()=>this.signers(),signer:f})),m(this,S,new ae({chain:t,walletAddress:this.address,options:h,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:u=>this.addSigner(u),approveSignature:u=>this.approveSignatureAndWait(u),approveTransaction:u=>this.approveTransactionAndWait(u)})),m(this,I,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,I)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,T).length===0?i(this,l).recovery:i(this,T).length===1?i(this,T)[0]:null;if(e==null)return;let r=F(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let s=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(s,{isAdminSigner:n}))}catch(s){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,T).length,error:s})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,l).recovery}static getInitialSigners(e){return i(e,T)}static getApiRecoveryServerSignerAddress(e){var r;return(r=i(e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return i(e,x)}get apiClient(){return i(this,c)}get options(){return i(this,L)}get chainAdapter(){return X(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),ie(s,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(N(y({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return o(this,null,function*(){let e=yield i(this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return o(this,null,function*(){let r=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return o(this,null,function*(){let s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new j(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=re(e),g=this.resolveChainForEnvironment(),d=te(r,g);a.info("wallet.send.start",y({recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let v=i(this,l).require(),p;(n==null?void 0:n.signer)==null?p=v.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let C=y({recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,c).send(this.walletLocator,d,C);if("message"in f)throw a.error("wallet.send.error",{error:f}),new q(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let w=yield this.approveTransactionAndWait(f.id);return a.info("wallet.send.success",{transactionId:f.id,hash:w.hash}),w})}approveTransaction(e){return o(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return o(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return o(this,null,function*(){a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=typeof t=="string"?t:k(t),s=yield i(this,l).getSignerState(n);if(s.signer!=null){if(i(this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:F(t.type).addSignerPayload(t,i(this,l).descriptorContext()),g=yield i(this,c).registerSigner(this.walletLocator,y({signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in g)throw a.error("wallet.addSigner.error",{error:g}),g.code===G?new U(g.message):new O(`Failed to register signer: ${JSON.stringify(g.message)}`);let d=Q(g,this.chain);if(d==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let v=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(d,v,r)}))})}completeSignerRegistration(e,r,t){return o(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return y({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return N(y({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=yield i(this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return o(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),F(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=F(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=k(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return o(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return o(this,null,function*(){let t=(yield this.signers()).map(s=>s.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return o(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):k(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return o(this,null,function*(){return i(this,l).signerIsRegistered(e)})}isSignerApproved(e){return o(this,null,function*(){return i(this,l).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return o(this,null,function*(){yield i(this,S).recover()})}signers(){return o(this,null,function*(){var s,h;a.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(!pe(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw a.error("wallet.signers.error",{error:g}),new J(g)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(g=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(g.locator)).signer}catch(d){return null}})))).filter(g=>g!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,l)}preAuthIfNeeded(){return o(this,null,function*(){yield i(this,I),i(this,E)==null&&m(this,E,this.recover());try{yield i(this,E)}finally{m(this,E,null)}let e=i(this,l).require();e instanceof Z&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=F(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=K(this.chain,i(this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return o(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return o(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return o(this,null,function*(){var d,v;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,l).require(),n=yield i(this,c).getSignature(this.walletLocator,e);if("error"in n)throw new B(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],t],g=yield Promise.all(s.map(p=>o(this,null,function*(){let C=h.find(w=>w.locator()===p.signer.locator);if(C==null)throw new O(`Signer ${p.signer.locator} not found in pending approvals`);let f=yield C.signMessage(p.message);return N(y({},f),{signer:C.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return o(this,null,function*(){var d,v,p,C,f;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw new V(JSON.stringify(t));yield(p=(v=(d=i(this,L))==null?void 0:d.callbacks)==null?void 0:v.onTransactionStart)==null?void 0:p.call(v);let n=i(this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let s=(C=t.approvals)==null?void 0:C.pending;if(s==null||s.length===0)return t;let h=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield Promise.all(s.map(w=>o(this,null,function*(){let u=h.find(de=>de.locator()===w.signer.locator);if(u==null)throw new O(`Signer ${w.signer.locator} not found in pending approvals`);let le=u.type==="device",ce=t.chainType==="solana"&&"transaction"in t.onChain&&!le?t.onChain.transaction:w.message,ge=yield u.signTransaction(ce);return N(y({},ge),{signer:u.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return o(this,null,function*(){let t=yield i(this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new H(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield oe(i(this,c),this.walletLocator,e)})}waitForTransaction(h){return o(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=M}={}){return yield se(i(this,c),this.walletLocator,e,{timeoutMs:r,backoffMultiplier:t,maxBackoffMs:n,initialBackoffMs:s})})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,T=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,x=new WeakMap,I=new WeakMap,E=new WeakMap,R([W({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),R([W({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),R([W({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),R([W({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),R([W({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),R([W({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),R([W({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),R([W({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),R([W({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function pe(D){return D.type==="smart"&&Y(D.chainType)}export{A as a};
1
+ import{a as ie}from"./chunk-GCIDUJF2.js";import{a as ae}from"./chunk-N6LXJTAC.js";import{a as se,b as oe}from"./chunk-T6VDXOWC.js";import{a as ne}from"./chunk-ZUG5BIGQ.js";import{a as ee}from"./chunk-OMTJMVSG.js";import{a as F}from"./chunk-NFX2WUB6.js";import{a as k}from"./chunk-GNON524X.js";import{a as re,b as te}from"./chunk-XKMIK6EW.js";import{a as Z}from"./chunk-BBMFGUOH.js";import{f as $}from"./chunk-DCKFFFPG.js";import{a as X,b as Y}from"./chunk-3PDACUM7.js";import{b as Q}from"./chunk-IUMKG7QD.js";import{f as K}from"./chunk-EJCR7VKJ.js";import{E as z,d as J,e as _,j as O,l as G,m as U,u as B,v as H,x as j,y as q,z as V}from"./chunk-TGFHY5PL.js";import{a}from"./chunk-OTFPEC53.js";import{d as M}from"./chunk-FXMXIAPL.js";import{a as y,b as N,c as R,d as i,e as b,f as m,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var L,c,T,P,l,S,x,I,E,A=class{constructor(e,r){b(this,L);b(this,c);b(this,T);b(this,P);b(this,l);b(this,S);b(this,x,[]);b(this,I);b(this,E,null);let{chain:t,address:n,owner:s,options:h,alias:g,recovery:d,apiRecoveryServerSignerAddress:v,apiDelegatedServerSignerAddresses:p,signers:C,signer:f}=e;m(this,c,r),this.chain=t,this.address=n,this.owner=s,m(this,L,h),this.alias=g;let w=null;v!=null?w=v:d.type==="server"&&$(d)&&(w=d.address),m(this,x,p!=null?p:[]),m(this,T,C!=null?C:[]),m(this,P,new ee({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:w,apiDelegatedAddresses:i(this,x),knownOnChainAddresses:()=>[...i(this,T).filter(u=>u.type==="server"&&$(u)).map(u=>u.address),...i(this,x)]})),m(this,l,new ne({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:d,initialSigners:i(this,T),signers:()=>this.signers(),signer:f})),m(this,S,new ae({chain:t,walletAddress:this.address,options:h,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:u=>this.addSigner(u),approveSignature:u=>this.approveSignatureAndWait(u),approveTransaction:u=>this.approveTransactionAndWait(u)})),m(this,I,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,I)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,T).length===0?i(this,l).recovery:i(this,T).length===1?i(this,T)[0]:null;if(e==null)return;let r=F(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let s=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(s,{isAdminSigner:n}))}catch(s){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,T).length,error:s})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,l).recovery}static getInitialSigners(e){return i(e,T)}static getApiRecoveryServerSignerAddress(e){var r;return(r=i(e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return i(e,x)}get apiClient(){return i(this,c)}get options(){return i(this,L)}get chainAdapter(){return X(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),ie(s,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(N(y({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return o(this,null,function*(){let e=yield i(this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return o(this,null,function*(){let r=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return o(this,null,function*(){let s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new j(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=re(e),g=this.resolveChainForEnvironment(),d=te(r,g);a.info("wallet.send.start",y({recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let v=i(this,l).require(),p;(n==null?void 0:n.signer)==null?p=v.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let C=y({recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,c).send(this.walletLocator,d,C);if("message"in f)throw a.error("wallet.send.error",{error:f}),new q(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let w=yield this.approveTransactionAndWait(f.id);return a.info("wallet.send.success",{transactionId:f.id,hash:w.hash}),w})}approveTransaction(e){return o(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return o(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return o(this,null,function*(){a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=typeof t=="string"?t:k(t),s=yield i(this,l).getSignerState(n);if(s.signer!=null){if(i(this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:F(t.type).addSignerPayload(t,i(this,l).descriptorContext()),g=yield i(this,c).registerSigner(this.walletLocator,y({signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in g)throw a.error("wallet.addSigner.error",{error:g}),g.code===G?new U(g.message):new O(`Failed to register signer: ${JSON.stringify(g.message)}`);let d=Q(g,this.chain);if(d==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let v=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(d,v,r)}))})}completeSignerRegistration(e,r,t){return o(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return y({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return N(y({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=yield i(this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return o(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),F(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=F(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=k(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return o(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return o(this,null,function*(){let t=(yield this.signers()).map(s=>s.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return o(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):k(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return o(this,null,function*(){return i(this,l).signerIsRegistered(e)})}isSignerApproved(e){return o(this,null,function*(){return i(this,l).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return o(this,null,function*(){yield i(this,S).recover()})}signers(){return o(this,null,function*(){var s,h;a.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(!pe(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw a.error("wallet.signers.error",{error:g}),new J(g)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(g=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(g.locator)).signer}catch(d){return null}})))).filter(g=>g!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,l)}preAuthIfNeeded(){return o(this,null,function*(){yield i(this,I),i(this,E)==null&&m(this,E,this.recover());try{yield i(this,E)}finally{m(this,E,null)}let e=i(this,l).require();e instanceof Z&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=F(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=K(this.chain,i(this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return o(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return o(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return o(this,null,function*(){var d,v;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,l).require(),n=yield i(this,c).getSignature(this.walletLocator,e);if("error"in n)throw new B(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],t],g=yield Promise.all(s.map(p=>o(this,null,function*(){let C=h.find(w=>w.locator()===p.signer.locator);if(C==null)throw new O(`Signer ${p.signer.locator} not found in pending approvals`);let f=yield C.signMessage(p.message);return N(y({},f),{signer:C.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return o(this,null,function*(){var d,v,p,C,f;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw new V(JSON.stringify(t));yield(p=(v=(d=i(this,L))==null?void 0:d.callbacks)==null?void 0:v.onTransactionStart)==null?void 0:p.call(v);let n=i(this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let s=(C=t.approvals)==null?void 0:C.pending;if(s==null||s.length===0)return t;let h=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield Promise.all(s.map(w=>o(this,null,function*(){let u=h.find(de=>de.locator()===w.signer.locator);if(u==null)throw new O(`Signer ${w.signer.locator} not found in pending approvals`);let le=u.type==="device",ce=t.chainType==="solana"&&"transaction"in t.onChain&&!le?t.onChain.transaction:w.message,ge=yield u.signTransaction(ce);return N(y({},ge),{signer:u.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return o(this,null,function*(){let t=yield i(this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new H(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield oe(i(this,c),this.walletLocator,e)})}waitForTransaction(h){return o(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=M}={}){return yield se(i(this,c),this.walletLocator,e,{timeoutMs:r,backoffMultiplier:t,maxBackoffMs:n,initialBackoffMs:s})})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,T=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,x=new WeakMap,I=new WeakMap,E=new WeakMap,R([W({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),R([W({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),R([W({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),R([W({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),R([W({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),R([W({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),R([W({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),R([W({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),R([W({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function pe(D){return D.type==="smart"&&Y(D.chainType)}export{A as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkNJUHI3JBcjs = require('./chunk-NJUHI3JB.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkNJUHI3JBcjs.c,version:_chunkNJUHI3JBcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkJDQXT4REcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkJDQXT4REcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkJDQXT4REcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkJDQXT4REcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkJDQXT4REcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkJDQXT4REcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkJDQXT4REcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkJDQXT4REcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkJDQXT4REcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunk3F4FMM3Rcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunk3F4FMM3Rcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkHIKDNSEIcjs = require('./chunk-HIKDNSEI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkHIKDNSEIcjs.c,version:_chunkHIKDNSEIcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkMYWEABPNcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkMYWEABPNcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkMYWEABPNcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkMYWEABPNcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkMYWEABPNcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkMYWEABPNcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkMYWEABPNcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunk3F4FMM3Rcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunk3F4FMM3Rcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNJUHI3JBcjs = require('./chunk-NJUHI3JB.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkNJUHI3JBcjs.c,packageVersion:_chunkNJUHI3JBcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHIKDNSEIcjs = require('./chunk-HIKDNSEI.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkHIKDNSEIcjs.c,packageVersion:_chunkHIKDNSEIcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkRMDQOS3Hcjs = require('./chunk-RMDQOS3H.cjs');var _chunk27L66KDTcjs = require('./chunk-27L66KDT.cjs');var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkJDQXT4REcjs = require('./chunk-JDQXT4RE.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var c,w,m,p,u,n,A,C,D,k,b,h,R,M,j,B,T= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,h);_chunkDSIFRRBScjs.e.call(void 0, this,c,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,w,!1);_chunkDSIFRRBScjs.e.call(void 0, this,m);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,n);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,D);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.f.call(void 0, this,m,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,p,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,n,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,D,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,w))return;let t={type:"device"};try{yield this.resolveAvailability(t)}catch(d){_chunkJDQXT4REcjs.a.error("wallet.initDeviceSigner.error",{error:d}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery")return;let l=_chunkRMDQOS3Hcjs.a.call(void 0, t.type).buildInternalConfig(t,_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext()),i=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(l);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(i),_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(i.status)||(_chunkJDQXT4REcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:i.locator(),status:i.status}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;if(_chunkJDQXT4REcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,c)==="resolved"){_chunkJDQXT4REcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,w)){_chunkJDQXT4REcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,R).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");return}if(r!=null&&r.type!=="device"){_chunkJDQXT4REcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}let t=(d=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:d.deviceSignerKeyStorage;if(t==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,c)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let l=yield _chunkDSIFRRBScjs.g.call(void 0, this,h,j).call(this,t);if(l!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,R).call(this,l))){_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(l),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");let s=l.locator().replace("device:","");try{yield t.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),s)}catch(y){_chunkJDQXT4REcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:y})}return}let i=yield _chunkGMU3ZYLScjs.a.call(void 0, t,_chunkDSIFRRBScjs.d.call(void 0, this,p));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,D).call(this,i)}catch(s){if(s instanceof _chunk3F4FMM3Rcjs.m){_chunkJDQXT4REcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:i.locator}),yield t.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),_chunkDSIFRRBScjs.f.call(void 0, this,w,!0),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,h,B).call(this);return}else if(V(s))_chunkJDQXT4REcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:i.locator});else throw s instanceof _chunk5HBCBS5Wcjs.a||s instanceof Error&&s.name==="AuthRejectedError"?(_chunkJDQXT4REcjs.a.info("wallet.recover.device.authRejected",{signerLocator:i.locator}),s):s instanceof _chunk5HBCBS5Wcjs.b||s instanceof Error&&s.name==="OtpValidationError"?(_chunkJDQXT4REcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:i.locator,code:s instanceof _chunk5HBCBS5Wcjs.b?s.code:void 0}),s):(_chunkJDQXT4REcjs.a.error("wallet.recover.device.error",{error:s}),yield t.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),s)}let g=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble({type:"device",locator:i.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)});_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(g),g.type==="device"&&(g.status="success"),_chunkJDQXT4REcjs.a.info("wallet.recover.device.success",{signerLocator:i.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved")})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let t=(d=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:d.deviceSignerKeyStorage;if(t==null)throw new Error("Device signer key storage is required for device signers");let l=yield t.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,p));if(l!=null){r.locator=`device:${l}`,_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,C).call(this)).filter(s=>s.locator.startsWith("device:"));for(let s of g){let y=s.locator.replace("device:","");if(yield t.hasKey(y)){yield t.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),y),r.locator=s.locator,_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery")})}};c=new WeakMap,w=new WeakMap,m=new WeakMap,p=new WeakMap,u=new WeakMap,n=new WeakMap,A=new WeakMap,C=new WeakMap,D=new WeakMap,k=new WeakMap,b=new WeakMap,h=new WeakSet,R=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l;if(_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status))return _chunkJDQXT4REcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).getSignerState(r.locator());return r.status=(l=t.signer)==null?void 0:l.status,t.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,M).call(this,r,t.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status)?(_chunkJDQXT4REcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},M=function(r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var y;let l=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner,i=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery;if(_chunk5HBCBS5Wcjs.e.call(void 0, i)&&!_chunkDSIFRRBScjs.d.call(void 0, this,A).hasRecoveryResolution)throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkRMDQOS3Hcjs.a.call(void 0, i.type),d=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(i.type==="external-wallet"&&!g.canAutoAssemble(i,d))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let s=g.buildInternalConfig(i,d);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(_chunk27L66KDTcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,m),s,(y=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:y.deviceSignerKeyStorage));try{t.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,t.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,b).call(this,t.id)}catch(E){throw _chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(r),E}finally{_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(l)}r.status="success",_chunkJDQXT4REcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},j=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let l=(yield _chunkDSIFRRBScjs.d.call(void 0, this,C).call(this)).filter(i=>i.locator.startsWith("device:"));for(let i of l){let g=i.locator.replace("device:","");try{if(yield r.hasKey(g)){let s=_chunk27L66KDTcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,m),{type:"device",locator:i.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)},r);return _chunkJDQXT4REcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:i.locator}),s}}catch(d){_chunkJDQXT4REcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:i.locator,error:d})}}return null})},B=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery,t=_chunkRMDQOS3Hcjs.a.call(void 0, r.type),l=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(t.canAutoAssemble(r,l))try{let i=t.buildInternalConfig(r,l);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(i,{isAdminSigner:!0}))}catch(i){_chunkJDQXT4REcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:i})}})};function V(P){if(!(P instanceof Error))return!1;let r=P.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkEXFV7SBWcjs = require('./chunk-EXFV7SBW.cjs');var _chunkU6SAS52Qcjs = require('./chunk-U6SAS52Q.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var c,w,m,p,u,n,A,C,D,k,b,h,R,M,j,B,T= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,h);_chunkDSIFRRBScjs.e.call(void 0, this,c,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,w,!1);_chunkDSIFRRBScjs.e.call(void 0, this,m);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,n);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,D);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.f.call(void 0, this,m,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,p,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,n,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,D,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,w))return;let t={type:"device"};try{yield this.resolveAvailability(t)}catch(d){_chunkMYWEABPNcjs.a.error("wallet.initDeviceSigner.error",{error:d}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,c)==="needs-recovery")return;let l=_chunkEXFV7SBWcjs.a.call(void 0, t.type).buildInternalConfig(t,_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext()),i=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(l);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(i),_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(i.status)||(_chunkMYWEABPNcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:i.locator(),status:i.status}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;if(_chunkMYWEABPNcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,c)==="resolved"){_chunkMYWEABPNcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,w)){_chunkMYWEABPNcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,R).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");return}if(r!=null&&r.type!=="device"){_chunkMYWEABPNcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}let t=(d=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:d.deviceSignerKeyStorage;if(t==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,c)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let l=yield _chunkDSIFRRBScjs.g.call(void 0, this,h,j).call(this,t);if(l!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,R).call(this,l))){_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(l),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved");let s=l.locator().replace("device:","");try{yield t.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),s)}catch(y){_chunkMYWEABPNcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:y})}return}let i=yield _chunkGMU3ZYLScjs.a.call(void 0, t,_chunkDSIFRRBScjs.d.call(void 0, this,p));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,D).call(this,i)}catch(s){if(s instanceof _chunk3F4FMM3Rcjs.m){_chunkMYWEABPNcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:i.locator}),yield t.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),_chunkDSIFRRBScjs.f.call(void 0, this,w,!0),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,h,B).call(this);return}else if(V(s))_chunkMYWEABPNcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:i.locator});else throw s instanceof _chunkQPCZFIUVcjs.a||s instanceof Error&&s.name==="AuthRejectedError"?(_chunkMYWEABPNcjs.a.info("wallet.recover.device.authRejected",{signerLocator:i.locator}),s):s instanceof _chunkQPCZFIUVcjs.b||s instanceof Error&&s.name==="OtpValidationError"?(_chunkMYWEABPNcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:i.locator,code:s instanceof _chunkQPCZFIUVcjs.b?s.code:void 0}),s):(_chunkMYWEABPNcjs.a.error("wallet.recover.device.error",{error:s}),yield t.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),s)}let g=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble({type:"device",locator:i.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)});_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(g),g.type==="device"&&(g.status="success"),_chunkMYWEABPNcjs.a.info("wallet.recover.device.success",{signerLocator:i.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,c,"resolved")})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let t=(d=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:d.deviceSignerKeyStorage;if(t==null)throw new Error("Device signer key storage is required for device signers");let l=yield t.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,p));if(l!=null){r.locator=`device:${l}`,_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,C).call(this)).filter(s=>s.locator.startsWith("device:"));for(let s of g){let y=s.locator.replace("device:","");if(yield t.hasKey(y)){yield t.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),y),r.locator=s.locator,_chunkDSIFRRBScjs.f.call(void 0, this,c,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,c,"needs-recovery")})}};c=new WeakMap,w=new WeakMap,m=new WeakMap,p=new WeakMap,u=new WeakMap,n=new WeakMap,A=new WeakMap,C=new WeakMap,D=new WeakMap,k=new WeakMap,b=new WeakMap,h=new WeakSet,R=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l;if(_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status))return _chunkMYWEABPNcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).getSignerState(r.locator());return r.status=(l=t.signer)==null?void 0:l.status,t.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,h,M).call(this,r,t.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status)?(_chunkMYWEABPNcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},M=function(r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var y;let l=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner,i=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery;if(_chunkQPCZFIUVcjs.f.call(void 0, i)&&!_chunkDSIFRRBScjs.d.call(void 0, this,A).hasRecoveryResolution)throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkEXFV7SBWcjs.a.call(void 0, i.type),d=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(i.type==="external-wallet"&&!g.canAutoAssemble(i,d))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let s=g.buildInternalConfig(i,d);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(_chunkU6SAS52Qcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,m),s,(y=_chunkDSIFRRBScjs.d.call(void 0, this,u))==null?void 0:y.deviceSignerKeyStorage));try{t.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,t.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,b).call(this,t.id)}catch(E){throw _chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(r),E}finally{_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(l)}r.status="success",_chunkMYWEABPNcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},j=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let l=(yield _chunkDSIFRRBScjs.d.call(void 0, this,C).call(this)).filter(i=>i.locator.startsWith("device:"));for(let i of l){let g=i.locator.replace("device:","");try{if(yield r.hasKey(g)){let s=_chunkU6SAS52Qcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,m),{type:"device",locator:i.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)},r);return _chunkMYWEABPNcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:i.locator}),s}}catch(d){_chunkMYWEABPNcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:i.locator,error:d})}}return null})},B=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery,t=_chunkEXFV7SBWcjs.a.call(void 0, r.type),l=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(t.canAutoAssemble(r,l))try{let i=t.buildInternalConfig(r,l);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(i,{isAdminSigner:!0}))}catch(i){_chunkMYWEABPNcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:i})}})};function V(P){if(!(P instanceof Error))return!1;let r=P.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = T;