@crossmint/wallets-sdk 1.20.0 → 1.20.1

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 (123) hide show
  1. package/dist/api/__tests__/test-utils.cjs +1 -1
  2. package/dist/api/__tests__/test-utils.js +1 -1
  3. package/dist/api/client.cjs +1 -1
  4. package/dist/api/client.js +1 -1
  5. package/dist/api/index.cjs +1 -1
  6. package/dist/api/index.js +1 -1
  7. package/dist/chains/adapters/evm.cjs +1 -1
  8. package/dist/chains/adapters/evm.js +1 -1
  9. package/dist/chains/adapters/solana.cjs +1 -1
  10. package/dist/chains/adapters/solana.js +1 -1
  11. package/dist/chains/adapters/stellar.cjs +1 -1
  12. package/dist/chains/adapters/stellar.js +1 -1
  13. package/dist/chains/chain-adapter.cjs +1 -1
  14. package/dist/chains/chain-adapter.js +1 -1
  15. package/dist/chains/chains.cjs +1 -1
  16. package/dist/chains/chains.d.cts +2 -2
  17. package/dist/chains/chains.d.ts +2 -2
  18. package/dist/chains/chains.js +1 -1
  19. package/dist/{chunk-N3W3FP2G.js → chunk-2SQXN4JL.js} +1 -1
  20. package/dist/{chunk-LH6A7CFO.cjs → chunk-3GWEE56X.cjs} +1 -1
  21. package/dist/{chunk-75NMYYJY.cjs → chunk-3HUNEWAR.cjs} +1 -1
  22. package/dist/{chunk-OQINX6EJ.js → chunk-3RWQHOBG.js} +1 -1
  23. package/dist/{chunk-W4GCZ4UZ.js → chunk-4VGTYVW7.js} +1 -1
  24. package/dist/{chunk-BQZHLT2Q.js → chunk-6EPYTT7A.js} +1 -1
  25. package/dist/{chunk-ZLR6K3KY.cjs → chunk-754XJCSX.cjs} +1 -1
  26. package/dist/chunk-A4F6GFJC.cjs +1 -0
  27. package/dist/{chunk-GYXKGRZY.js → chunk-AMGE2J7V.js} +1 -1
  28. package/dist/{chunk-H4RL6UJU.js → chunk-AOZ2VVTT.js} +1 -1
  29. package/dist/{chunk-PTGEMNUR.js → chunk-BF5VS7HX.js} +1 -1
  30. package/dist/{chunk-T4FKMQ6Y.js → chunk-C2R47XW6.js} +1 -1
  31. package/dist/{chunk-TJXUJBM7.cjs → chunk-DFJ63LIQ.cjs} +1 -1
  32. package/dist/{chunk-32GROW5L.js → chunk-DVVGWCH7.js} +1 -1
  33. package/dist/{chunk-FS72XBWN.cjs → chunk-ENLWAIYV.cjs} +1 -1
  34. package/dist/{chunk-MZPMVQ5J.js → chunk-GFK67DR4.js} +1 -1
  35. package/dist/{chunk-UNAH34G2.cjs → chunk-H52MPNZP.cjs} +1 -1
  36. package/dist/{chunk-3I2MB7SJ.js → chunk-HODQMDIV.js} +1 -1
  37. package/dist/{chunk-AWIDML36.js → chunk-I3FLN7RY.js} +1 -1
  38. package/dist/{chunk-CPXJHFSR.cjs → chunk-IHIJ7G64.cjs} +1 -1
  39. package/dist/{chunk-BGQ4QX25.cjs → chunk-IYWWY7T5.cjs} +1 -1
  40. package/dist/{chunk-LX55L36L.js → chunk-J7N56JUE.js} +1 -1
  41. package/dist/{chunk-HADAG3ZB.js → chunk-JAP6U3CJ.js} +1 -1
  42. package/dist/{chunk-QUYYIVZB.js → chunk-KNAIS6WY.js} +1 -1
  43. package/dist/{chunk-MPIIBOOK.cjs → chunk-KUT3FS3U.cjs} +1 -1
  44. package/dist/{chunk-U73R5Z3Z.cjs → chunk-LRWKIVXL.cjs} +1 -1
  45. package/dist/chunk-MFQX2HNH.js +1 -0
  46. package/dist/{chunk-5DVT5DB6.cjs → chunk-NBZEWJUH.cjs} +1 -1
  47. package/dist/{chunk-TI6QPYIE.cjs → chunk-NHNNPXP7.cjs} +1 -1
  48. package/dist/chunk-NULQLE3D.js +1 -0
  49. package/dist/{chunk-M2AM4CBT.cjs → chunk-O673DZDX.cjs} +1 -1
  50. package/dist/{chunk-5T2BUXCF.cjs → chunk-OAFFHV5G.cjs} +1 -1
  51. package/dist/{chunk-FXKT7O4T.js → chunk-PEHDJW5W.js} +1 -1
  52. package/dist/{chunk-DNAHI43Y.cjs → chunk-PQ4LAXVO.cjs} +1 -1
  53. package/dist/{chunk-KCO6YNJR.cjs → chunk-QD53EMTK.cjs} +1 -1
  54. package/dist/{chunk-YIUOOMT4.js → chunk-QNNWOOHI.js} +1 -1
  55. package/dist/{chunk-5YNL2XRE.cjs → chunk-R3CAXQLJ.cjs} +1 -1
  56. package/dist/{chunk-QUOYTOHY.js → chunk-RAQFOCJT.js} +1 -1
  57. package/dist/{chunk-FWONJJK4.js → chunk-SGLJQXKH.js} +1 -1
  58. package/dist/{chunk-BSRBEBBA.cjs → chunk-SINS7Z5F.cjs} +1 -1
  59. package/dist/chunk-TISVJEJ4.cjs +1 -0
  60. package/dist/{chunk-FWPLRK7S.cjs → chunk-VRA6S3DJ.cjs} +1 -1
  61. package/dist/{chunk-N4DNCKHY.cjs → chunk-VRO4EPRC.cjs} +1 -1
  62. package/dist/chunk-VUCADC63.cjs +1 -0
  63. package/dist/{chunk-IAPGBR2Z.js → chunk-WQ7JSD6A.js} +1 -1
  64. package/dist/{chunk-IX646CRE.cjs → chunk-WS27JTIY.cjs} +1 -1
  65. package/dist/{chunk-NDTDJCCO.js → chunk-YHPZJA2F.js} +1 -1
  66. package/dist/{chunk-IMJ2V4F4.js → chunk-YNOT3UTT.js} +1 -1
  67. package/dist/chunk-Z4OBKN5C.js +1 -0
  68. package/dist/{chunk-MQEPGBWN.cjs → chunk-Z6CVEP22.cjs} +1 -1
  69. package/dist/index.cjs +1 -1
  70. package/dist/index.js +1 -1
  71. package/dist/logger/index.cjs +1 -1
  72. package/dist/logger/index.js +1 -1
  73. package/dist/logger/init.cjs +1 -1
  74. package/dist/logger/init.js +1 -1
  75. package/dist/sdk.cjs +1 -1
  76. package/dist/sdk.js +1 -1
  77. package/dist/signers/index.cjs +1 -1
  78. package/dist/signers/index.js +1 -1
  79. package/dist/signers/non-custodial/index.cjs +1 -1
  80. package/dist/signers/non-custodial/index.js +1 -1
  81. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  82. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  83. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  85. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  86. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  87. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  88. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  89. package/dist/utils/constants.cjs +1 -1
  90. package/dist/utils/constants.js +1 -1
  91. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  92. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  93. package/dist/utils/device-signers/index.cjs +1 -1
  94. package/dist/utils/device-signers/index.js +1 -1
  95. package/dist/utils/recovery.cjs +1 -1
  96. package/dist/utils/recovery.js +1 -1
  97. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  98. package/dist/wallets/__tests__/test-helpers.js +1 -1
  99. package/dist/wallets/evm.cjs +1 -1
  100. package/dist/wallets/evm.js +1 -1
  101. package/dist/wallets/services/balance-formatter.cjs +1 -1
  102. package/dist/wallets/services/balance-formatter.js +1 -1
  103. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  104. package/dist/wallets/services/device-recovery-service.js +1 -1
  105. package/dist/wallets/services/operation-poller.cjs +1 -1
  106. package/dist/wallets/services/operation-poller.js +1 -1
  107. package/dist/wallets/services/signer-manager.cjs +1 -1
  108. package/dist/wallets/services/signer-manager.js +1 -1
  109. package/dist/wallets/solana.cjs +1 -1
  110. package/dist/wallets/solana.js +1 -1
  111. package/dist/wallets/stellar.cjs +1 -1
  112. package/dist/wallets/stellar.js +1 -1
  113. package/dist/wallets/wallet-factory.cjs +1 -1
  114. package/dist/wallets/wallet-factory.js +1 -1
  115. package/dist/wallets/wallet.cjs +1 -1
  116. package/dist/wallets/wallet.js +1 -1
  117. package/package.json +5 -5
  118. package/dist/chunk-7TVBGFKY.js +0 -1
  119. package/dist/chunk-FY4JJ3QZ.cjs +0 -1
  120. package/dist/chunk-JVBAZHA6.js +0 -1
  121. package/dist/chunk-UV3NUVR3.js +0 -1
  122. package/dist/chunk-X5PKHTFG.cjs +0 -1
  123. package/dist/chunk-XIO3CEXH.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkMPIIBOOKcjs = require('../../chunk-MPIIBOOK.cjs');require('../../chunk-D2S37DJ5.cjs');require('../../chunk-M2AM4CBT.cjs');require('../../chunk-UNAH34G2.cjs');var _chunkDSIFRRBScjs = require('../../chunk-DSIFRRBS.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunkDSIFRRBScjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkMPIIBOOKcjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunkDSIFRRBScjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunkDSIFRRBScjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkMPIIBOOKcjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunkDSIFRRBScjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkKUT3FS3Ucjs = require('../../chunk-KUT3FS3U.cjs');require('../../chunk-D2S37DJ5.cjs');require('../../chunk-O673DZDX.cjs');require('../../chunk-H52MPNZP.cjs');var _chunkDSIFRRBScjs = require('../../chunk-DSIFRRBS.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunkDSIFRRBScjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkKUT3FS3Ucjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunkDSIFRRBScjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunkDSIFRRBScjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkKUT3FS3Ucjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunkDSIFRRBScjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
@@ -1 +1 @@
1
- import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-IAPGBR2Z.js";import"../../chunk-4I3EXM4B.js";import"../../chunk-YIUOOMT4.js";import"../../chunk-7TVBGFKY.js";import{a as p,b as k,h as i}from"../../chunk-NU7VF7MC.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
1
+ import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-WQ7JSD6A.js";import"../../chunk-4I3EXM4B.js";import"../../chunk-QNNWOOHI.js";import"../../chunk-NULQLE3D.js";import{a as p,b as k,h as i}from"../../chunk-NU7VF7MC.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMPIIBOOKcjs = require('../chunk-MPIIBOOK.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-M2AM4CBT.cjs');require('../chunk-UNAH34G2.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkMPIIBOOKcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKUT3FS3Ucjs = require('../chunk-KUT3FS3U.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-O673DZDX.cjs');require('../chunk-H52MPNZP.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkKUT3FS3Ucjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-IAPGBR2Z.js";import"../chunk-4I3EXM4B.js";import"../chunk-YIUOOMT4.js";import"../chunk-7TVBGFKY.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
1
+ import{a}from"../chunk-WQ7JSD6A.js";import"../chunk-4I3EXM4B.js";import"../chunk-QNNWOOHI.js";import"../chunk-NULQLE3D.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkMPIIBOOKcjs = require('../chunk-MPIIBOOK.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-M2AM4CBT.cjs');require('../chunk-UNAH34G2.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkMPIIBOOKcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkKUT3FS3Ucjs = require('../chunk-KUT3FS3U.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-O673DZDX.cjs');require('../chunk-H52MPNZP.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkKUT3FS3Ucjs.a;
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-IAPGBR2Z.js";import"../chunk-KBJA7JDT.js";import"../chunk-4I3EXM4B.js";import"../chunk-YIUOOMT4.js";import"../chunk-7TVBGFKY.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
1
+ import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-WQ7JSD6A.js";import"../chunk-KBJA7JDT.js";import"../chunk-4I3EXM4B.js";import"../chunk-QNNWOOHI.js";import"../chunk-NULQLE3D.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBSRBEBBAcjs = require('../../chunk-BSRBEBBA.cjs');require('../../chunk-JNKTRQPS.cjs');require('../../chunk-D2S37DJ5.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-M2AM4CBT.cjs');require('../../chunk-UNAH34G2.cjs');require('../../chunk-DSIFRRBS.cjs');exports.evmChainAdapter = _chunkBSRBEBBAcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSINS7Z5Fcjs = require('../../chunk-SINS7Z5F.cjs');require('../../chunk-JNKTRQPS.cjs');require('../../chunk-D2S37DJ5.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-O673DZDX.cjs');require('../../chunk-H52MPNZP.cjs');require('../../chunk-DSIFRRBS.cjs');exports.evmChainAdapter = _chunkSINS7Z5Fcjs.a;
@@ -1 +1 @@
1
- import{a}from"../../chunk-OQINX6EJ.js";import"../../chunk-B4GYB3XY.js";import"../../chunk-4I3EXM4B.js";import"../../chunk-455NK5LB.js";import"../../chunk-YIUOOMT4.js";import"../../chunk-7TVBGFKY.js";import"../../chunk-NU7VF7MC.js";export{a as evmChainAdapter};
1
+ import{a}from"../../chunk-3RWQHOBG.js";import"../../chunk-B4GYB3XY.js";import"../../chunk-4I3EXM4B.js";import"../../chunk-455NK5LB.js";import"../../chunk-QNNWOOHI.js";import"../../chunk-NULQLE3D.js";import"../../chunk-NU7VF7MC.js";export{a as evmChainAdapter};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTJXUJBM7cjs = require('../../chunk-TJXUJBM7.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-M2AM4CBT.cjs');require('../../chunk-UNAH34G2.cjs');require('../../chunk-DSIFRRBS.cjs');exports.solanaChainAdapter = _chunkTJXUJBM7cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDFJ63LIQcjs = require('../../chunk-DFJ63LIQ.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-O673DZDX.cjs');require('../../chunk-H52MPNZP.cjs');require('../../chunk-DSIFRRBS.cjs');exports.solanaChainAdapter = _chunkDFJ63LIQcjs.a;
@@ -1 +1 @@
1
- import{a}from"../../chunk-MZPMVQ5J.js";import"../../chunk-455NK5LB.js";import"../../chunk-YIUOOMT4.js";import"../../chunk-7TVBGFKY.js";import"../../chunk-NU7VF7MC.js";export{a as solanaChainAdapter};
1
+ import{a}from"../../chunk-GFK67DR4.js";import"../../chunk-455NK5LB.js";import"../../chunk-QNNWOOHI.js";import"../../chunk-NULQLE3D.js";import"../../chunk-NU7VF7MC.js";export{a as solanaChainAdapter};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIX646CREcjs = require('../../chunk-IX646CRE.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-M2AM4CBT.cjs');require('../../chunk-UNAH34G2.cjs');require('../../chunk-DSIFRRBS.cjs');exports.stellarChainAdapter = _chunkIX646CREcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWS27JTIYcjs = require('../../chunk-WS27JTIY.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-O673DZDX.cjs');require('../../chunk-H52MPNZP.cjs');require('../../chunk-DSIFRRBS.cjs');exports.stellarChainAdapter = _chunkWS27JTIYcjs.a;
@@ -1 +1 @@
1
- import{a}from"../../chunk-FWONJJK4.js";import"../../chunk-455NK5LB.js";import"../../chunk-YIUOOMT4.js";import"../../chunk-7TVBGFKY.js";import"../../chunk-NU7VF7MC.js";export{a as stellarChainAdapter};
1
+ import{a}from"../../chunk-SGLJQXKH.js";import"../../chunk-455NK5LB.js";import"../../chunk-QNNWOOHI.js";import"../../chunk-NULQLE3D.js";import"../../chunk-NU7VF7MC.js";export{a as stellarChainAdapter};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFY4JJ3QZcjs = require('../chunk-FY4JJ3QZ.cjs');require('../chunk-BSRBEBBA.cjs');require('../chunk-TJXUJBM7.cjs');require('../chunk-IX646CRE.cjs');require('../chunk-JNKTRQPS.cjs');require('../chunk-ENU3EKBG.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-M2AM4CBT.cjs');require('../chunk-UNAH34G2.cjs');require('../chunk-DSIFRRBS.cjs');exports.getApprovalAdapter = _chunkFY4JJ3QZcjs.c; exports.getChainAdapter = _chunkFY4JJ3QZcjs.a; exports.isSupportedChainType = _chunkFY4JJ3QZcjs.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVUCADC63cjs = require('../chunk-VUCADC63.cjs');require('../chunk-SINS7Z5F.cjs');require('../chunk-DFJ63LIQ.cjs');require('../chunk-WS27JTIY.cjs');require('../chunk-JNKTRQPS.cjs');require('../chunk-ENU3EKBG.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-O673DZDX.cjs');require('../chunk-H52MPNZP.cjs');require('../chunk-DSIFRRBS.cjs');exports.getApprovalAdapter = _chunkVUCADC63cjs.c; exports.getChainAdapter = _chunkVUCADC63cjs.a; exports.isSupportedChainType = _chunkVUCADC63cjs.b;
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-HADAG3ZB.js";import"../chunk-OQINX6EJ.js";import"../chunk-MZPMVQ5J.js";import"../chunk-FWONJJK4.js";import"../chunk-B4GYB3XY.js";import"../chunk-OQZTL6ZG.js";import"../chunk-4I3EXM4B.js";import"../chunk-455NK5LB.js";import"../chunk-YIUOOMT4.js";import"../chunk-7TVBGFKY.js";import"../chunk-NU7VF7MC.js";export{c as getApprovalAdapter,a as getChainAdapter,b as isSupportedChainType};
1
+ import{a,b,c}from"../chunk-JAP6U3CJ.js";import"../chunk-3RWQHOBG.js";import"../chunk-GFK67DR4.js";import"../chunk-SGLJQXKH.js";import"../chunk-B4GYB3XY.js";import"../chunk-OQZTL6ZG.js";import"../chunk-4I3EXM4B.js";import"../chunk-455NK5LB.js";import"../chunk-QNNWOOHI.js";import"../chunk-NULQLE3D.js";import"../chunk-NU7VF7MC.js";export{c as getApprovalAdapter,a as getChainAdapter,b as isSupportedChainType};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXIO3CEXHcjs = require('../chunk-XIO3CEXH.cjs');require('../chunk-OQFZL5LI.cjs');require('../chunk-AUO6R32H.cjs');require('../chunk-ZPO3XSWU.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-TCDH5Q6Q.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-M2AM4CBT.cjs');require('../chunk-UNAH34G2.cjs');require('../chunk-DSIFRRBS.cjs');exports.isMainnetChain = _chunkXIO3CEXHcjs.c; exports.isTestnetChain = _chunkXIO3CEXHcjs.b; exports.isValidChain = _chunkXIO3CEXHcjs.e; exports.mainnetToTestnet = _chunkXIO3CEXHcjs.d; exports.toViemChain = _chunkXIO3CEXHcjs.a; exports.validateChainForEnvironment = _chunkXIO3CEXHcjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkA4F6GFJCcjs = require('../chunk-A4F6GFJC.cjs');require('../chunk-OQFZL5LI.cjs');require('../chunk-AUO6R32H.cjs');require('../chunk-ZPO3XSWU.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-TCDH5Q6Q.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-D2S37DJ5.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-O673DZDX.cjs');require('../chunk-H52MPNZP.cjs');require('../chunk-DSIFRRBS.cjs');exports.isMainnetChain = _chunkA4F6GFJCcjs.c; exports.isTestnetChain = _chunkA4F6GFJCcjs.b; exports.isValidChain = _chunkA4F6GFJCcjs.e; exports.mainnetToTestnet = _chunkA4F6GFJCcjs.d; exports.toViemChain = _chunkA4F6GFJCcjs.a; exports.validateChainForEnvironment = _chunkA4F6GFJCcjs.f;
@@ -1,8 +1,8 @@
1
1
  import { APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
2
2
  import { Chain as Chain$1 } from 'viem';
3
3
 
4
- declare const TESTNET_AA_CHAINS: readonly ["abstract-testnet", "arbitrum-sepolia", "avalanche-fuji", "base-sepolia", "celo-sepolia", "curtis", "ethereum-sepolia", "flow-testnet", "mantle-sepolia", "optimism-sepolia", "polygon-amoy", "robinhood-chain-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "story-testnet", "zora-sepolia", "arc-testnet", "tempo-testnet"];
5
- declare const PRODUCTION_AA_CHAINS: readonly ["abstract", "apechain", "arbitrum", "arbitrumnova", "arc", "avalanche", "base", "bsc", "celo", "ethereum", "flow", "mantle", "optimism", "polygon", "robinhood-chain", "scroll", "sei-pacific-1", "shape", "story", "tempo", "zora"];
4
+ declare const TESTNET_AA_CHAINS: readonly ["arbitrum-sepolia", "avalanche-fuji", "base-sepolia", "celo-sepolia", "curtis", "ethereum-sepolia", "flow-testnet", "mantle-sepolia", "optimism-sepolia", "polygon-amoy", "robinhood-chain-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "story-testnet", "zora-sepolia", "arc-testnet", "tempo-testnet"];
5
+ declare const PRODUCTION_AA_CHAINS: readonly ["apechain", "arbitrum", "arbitrumnova", "arc", "avalanche", "base", "bsc", "celo", "ethereum", "flow", "mantle", "optimism", "polygon", "robinhood-chain", "scroll", "sei-pacific-1", "shape", "story", "tempo", "zora"];
6
6
  type EVMSmartWalletTestnet = (typeof TESTNET_AA_CHAINS)[number];
7
7
  type EVMSmartWalletMainnet = (typeof PRODUCTION_AA_CHAINS)[number];
8
8
  type EVMSmartWalletChain = EVMSmartWalletTestnet | EVMSmartWalletMainnet;
@@ -1,8 +1,8 @@
1
1
  import { APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
2
2
  import { Chain as Chain$1 } from 'viem';
3
3
 
4
- declare const TESTNET_AA_CHAINS: readonly ["abstract-testnet", "arbitrum-sepolia", "avalanche-fuji", "base-sepolia", "celo-sepolia", "curtis", "ethereum-sepolia", "flow-testnet", "mantle-sepolia", "optimism-sepolia", "polygon-amoy", "robinhood-chain-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "story-testnet", "zora-sepolia", "arc-testnet", "tempo-testnet"];
5
- declare const PRODUCTION_AA_CHAINS: readonly ["abstract", "apechain", "arbitrum", "arbitrumnova", "arc", "avalanche", "base", "bsc", "celo", "ethereum", "flow", "mantle", "optimism", "polygon", "robinhood-chain", "scroll", "sei-pacific-1", "shape", "story", "tempo", "zora"];
4
+ declare const TESTNET_AA_CHAINS: readonly ["arbitrum-sepolia", "avalanche-fuji", "base-sepolia", "celo-sepolia", "curtis", "ethereum-sepolia", "flow-testnet", "mantle-sepolia", "optimism-sepolia", "polygon-amoy", "robinhood-chain-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "story-testnet", "zora-sepolia", "arc-testnet", "tempo-testnet"];
5
+ declare const PRODUCTION_AA_CHAINS: readonly ["apechain", "arbitrum", "arbitrumnova", "arc", "avalanche", "base", "bsc", "celo", "ethereum", "flow", "mantle", "optimism", "polygon", "robinhood-chain", "scroll", "sei-pacific-1", "shape", "story", "tempo", "zora"];
6
6
  type EVMSmartWalletTestnet = (typeof TESTNET_AA_CHAINS)[number];
7
7
  type EVMSmartWalletMainnet = (typeof PRODUCTION_AA_CHAINS)[number];
8
8
  type EVMSmartWalletChain = EVMSmartWalletTestnet | EVMSmartWalletMainnet;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-JVBAZHA6.js";import"../chunk-C6E6WC4P.js";import"../chunk-V5NY4W5H.js";import"../chunk-CGQCRDG7.js";import"../chunk-KKQBZXFE.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-QLOW4D2N.js";import"../chunk-SVIKBM3S.js";import"../chunk-4I3EXM4B.js";import"../chunk-455NK5LB.js";import"../chunk-YIUOOMT4.js";import"../chunk-7TVBGFKY.js";import"../chunk-NU7VF7MC.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
1
+ import{a,b,c,d,e,f}from"../chunk-Z4OBKN5C.js";import"../chunk-C6E6WC4P.js";import"../chunk-V5NY4W5H.js";import"../chunk-CGQCRDG7.js";import"../chunk-KKQBZXFE.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-QLOW4D2N.js";import"../chunk-SVIKBM3S.js";import"../chunk-4I3EXM4B.js";import"../chunk-455NK5LB.js";import"../chunk-QNNWOOHI.js";import"../chunk-NULQLE3D.js";import"../chunk-NU7VF7MC.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-BQZHLT2Q.js";import{a as r}from"./chunk-YIUOOMT4.js";import{h as t}from"./chunk-NU7VF7MC.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let c=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:n,encoding:"base64",authId:this.getAuthId()}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-c}),(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"}}};export{a};
1
+ import{a as s,b as o}from"./chunk-6EPYTT7A.js";import{a as r}from"./chunk-QNNWOOHI.js";import{h as t}from"./chunk-NU7VF7MC.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let c=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:n,encoding:"base64",authId:this.getAuthId()}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-c}),(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"}}};export{a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMQEPGBWNcjs = require('./chunk-MQEPGBWN.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkMQEPGBWNcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkM2AM4CBTcjs.a.info("sign: sending request",{keyType:"secp256k1"});let u=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",authId:this.getAuthId()}},options:_chunkMQEPGBWNcjs.b});if(_chunkM2AM4CBTcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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"}}};exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZ6CVEP22cjs = require('./chunk-Z6CVEP22.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkZ6CVEP22cjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkO673DZDXcjs.a.info("sign: sending request",{keyType:"secp256k1"});let u=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",authId:this.getAuthId()}},options:_chunkZ6CVEP22cjs.b});if(_chunkO673DZDXcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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"}}};exports.a = c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5DVT5DB6cjs = require('./chunk-5DVT5DB6.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunk5DVT5DB6cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk5DVT5DB6cjs.a.getOptions(e),alias:e.alias,recovery:_chunk5DVT5DB6cjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk5DVT5DB6cjs.a.getInitialSigners(e)},_chunk5DVT5DB6cjs.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;_chunkM2AM4CBTcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkM2AM4CBTcjs.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 _chunkM2AM4CBTcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.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 _chunkM2AM4CBTcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkM2AM4CBTcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkM2AM4CBTcjs.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 _chunkM2AM4CBTcjs.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*(){_chunkM2AM4CBTcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkD2S37DJ5cjs.I)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkM2AM4CBTcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkM2AM4CBTcjs.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, _chunkD2S37DJ5cjs.I)(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, _chunkD2S37DJ5cjs.I)(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:_chunkM2AM4CBTcjs.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:_chunkM2AM4CBTcjs.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:_chunkM2AM4CBTcjs.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 _chunkNBZEWJUHcjs = require('./chunk-NBZEWJUH.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkNBZEWJUHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkNBZEWJUHcjs.a.getOptions(e),alias:e.alias,recovery:_chunkNBZEWJUHcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkNBZEWJUHcjs.a.getInitialSigners(e)},_chunkNBZEWJUHcjs.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;_chunkO673DZDXcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkO673DZDXcjs.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 _chunkO673DZDXcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.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 _chunkO673DZDXcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkO673DZDXcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkO673DZDXcjs.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 _chunkO673DZDXcjs.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*(){_chunkO673DZDXcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkD2S37DJ5cjs.I)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkO673DZDXcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkO673DZDXcjs.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, _chunkD2S37DJ5cjs.I)(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, _chunkD2S37DJ5cjs.I)(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:_chunkO673DZDXcjs.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:_chunkO673DZDXcjs.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:_chunkO673DZDXcjs.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
- import{c as g}from"./chunk-B4GYB3XY.js";import{j as d}from"./chunk-4I3EXM4B.js";import{a as i}from"./chunk-YIUOOMT4.js";var m={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var t,a,o,s;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(((a=(t=e.chains)==null?void 0:t[r])==null?void 0:a.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 d(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((s=e.chains)==null?void 0:s[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}},signApproval(e,r,n){return e.signTransaction(n)}};export{m as a};
1
+ import{c as g}from"./chunk-B4GYB3XY.js";import{j as d}from"./chunk-4I3EXM4B.js";import{a as i}from"./chunk-QNNWOOHI.js";var m={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var t,a,o,s;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(((a=(t=e.chains)==null?void 0:t[r])==null?void 0:a.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 d(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((s=e.chains)==null?void 0:s[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}},signApproval(e,r,n){return e.signTransaction(n)}};export{m as a};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-H4RL6UJU.js";import{a as l}from"./chunk-PTGEMNUR.js";import{a as o}from"./chunk-N3W3FP2G.js";import{a as S}from"./chunk-IQARABFX.js";import{a as g}from"./chunk-ECKSTWA3.js";import{a as y}from"./chunk-K7BPGUFU.js";import{a as f}from"./chunk-MN2BGRRJ.js";import{a as C}from"./chunk-FQ5F3VYJ.js";import{a as m}from"./chunk-HAQMNZO5.js";import{a as p}from"./chunk-AI5NDEKL.js";import{a as u}from"./chunk-MLROTECD.js";import{g as i}from"./chunk-4I3EXM4B.js";import{h as t}from"./chunk-NU7VF7MC.js";function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new l(e):r==="stellar"?new o(e):new s(e);case"api-key":return r==="solana"?new u(e):new C(e);case"external-wallet":return r==="solana"?new g(e):r==="stellar"?new y(e):new m(e);case"server":return S(r,e);case"passkey":return new p(e);case"device":if(n==null)throw new i("Device signer key storage is required for device signers");return new f(e,n)}}function k(r,e,n,a){return t(this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}export{c as a,k as b};
1
+ import{a as s}from"./chunk-AOZ2VVTT.js";import{a as l}from"./chunk-BF5VS7HX.js";import{a as o}from"./chunk-2SQXN4JL.js";import{a as S}from"./chunk-IQARABFX.js";import{a as g}from"./chunk-ECKSTWA3.js";import{a as y}from"./chunk-K7BPGUFU.js";import{a as f}from"./chunk-MN2BGRRJ.js";import{a as C}from"./chunk-FQ5F3VYJ.js";import{a as m}from"./chunk-HAQMNZO5.js";import{a as p}from"./chunk-AI5NDEKL.js";import{a as u}from"./chunk-MLROTECD.js";import{g as i}from"./chunk-4I3EXM4B.js";import{h as t}from"./chunk-NU7VF7MC.js";function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new l(e):r==="stellar"?new o(e):new s(e);case"api-key":return r==="solana"?new u(e):new C(e);case"external-wallet":return r==="solana"?new g(e):r==="stellar"?new y(e):new m(e);case"server":return S(r,e);case"passkey":return new p(e);case"device":if(n==null)throw new i("Device signer key storage is required for device signers");return new f(e,n)}}function k(r,e,n,a){return t(this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}export{c as a,k as b};
@@ -1 +1 @@
1
- import{a as p}from"./chunk-IHMMTMFG.js";import{a as b}from"./chunk-PWYCEHYZ.js";import{a as g,b as m,c as u,d as A,e as P,f as T}from"./chunk-43LFPZII.js";import{a as n}from"./chunk-YIUOOMT4.js";import{a as v,c as y,h as s}from"./chunk-NU7VF7MC.js";import{validateAPIKey as O,WithLoggerContext as C}from"@crossmint/common-sdk-base";var w=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return s(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return s(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return s(this,null,function*(){n.info("TEE connection not initialized, initializing now");let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");n.info("TEE connection initialized successfully")})}handleAuthRequired(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);n.info("get-status: sending request");let h=Date.now(),r=yield t.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:i,data:{authId:this.getAuthId()}},options:f}),a=Date.now()-h;if((r==null?void 0:r.status)!=="success"){let o=(r==null?void 0:r.status)==="error"&&r.error||"Failed to retrieve signer status",l=(r==null?void 0:r.status)==="error"?r.code:void 0;throw n.error("get-status: failed",{status:r==null?void 0:r.status,error:(r==null?void 0:r.status)==="error"?r.error:void 0,code:l,durationMs:a}),_(o,l)?new u(o,l):new A(o,l)}if(n.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:a}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;n.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:e,resolve:c,reject:d}=this.createAuthPromise();if(this._authPromise={promise:e,resolve:c,reject:d},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>s(this,null,function*(){n.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new g)})),d(new g)}))}catch(o){n.error("handleAuthRequired error",{error:o}),d(o)}try{yield e}catch(o){throw n.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return s(this,null,function*(){this.getJwtOrThrow(),this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null||i.trim()==="")throw new u(`${this.type} signer requires a valid Crossmint JWT. The user's session is missing or has expired: re-authenticate the user and refresh the JWT before retrying.`,S);return i}getAuthDataOrThrow(){return{jwt:this.getJwtOrThrow(),apiKey:this.config.crossmint.apiKey}}createAuthPromise(){let i,t;return{promise:new Promise((r,a)=>{i=r,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return s(this,null,function*(){var i;try{yield this.startOnboarding()}catch(t){throw t instanceof u&&((i=this._authPromise)==null||i.reject(t)),t}})}startOnboarding(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection(),h=this.getAuthId();n.info("start-onboarding: sending request");let r=Date.now(),a=this.config.type==="phone"?this.config.channel:void 0,e=yield t.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:i,data:v({authId:h},a!=null?{channel:a}:{})},options:f}),c=Date.now()-r;if(this._onboardingConnectionGeneration=t.connectionGeneration,n.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:c}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}if((e==null?void 0:e.status)==="error"){n.error("start-onboarding: failed",{error:e.error,code:e.code});let d=e.error||"Failed to initiate OTP process.";throw _(d,e.code)?new u(d,e.code):new m(d,e.code)}})}getAuthId(){return this.config.type==="email"?this.config.email!=null?`email:${b(this.config.email)}`:this.config.locator:this.config.phone!=null?`phone:${this.config.phone}`:this.config.locator}verifyOtp(i){return s(this,null,function*(){var a;let t;try{let e=yield this.getTEEConnection();n.info("complete-onboarding: sending request");let c=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:this.getAuthDataOrThrow(),data:{onboardingAuthentication:{encryptedOtp:i}}},options:f}),n.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-c})}catch(e){return n.error("complete-onboarding: error",{error:e}),yield this.handleOnboardingVerificationFailure(e)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new g)})),(a=this._authPromise)==null||a.resolve();return}n.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let h=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",r=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new m(h,r))})}handleOnboardingVerificationFailure(i){return s(this,null,function*(){var r,a,e;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){n.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(c){throw(r=this._authPromise)==null||r.reject(c),c}if(!this._needsAuth){(a=this._authPromise)==null||a.resolve();return}throw new T}throw(e=this._authPromise)==null||e.reject(i),i})}_exportPrivateKey(i,t){return s(this,null,function*(){yield this.ensureAuthenticated();let h=this.getJwtOrThrow(),{scheme:r,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",d=>{i.off(c),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let e=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:h,apiKey:this.config.crossmint.apiKey},data:{scheme:r,encoding:a,walletAddress:this.config.address,authId:this.getAuthId()}},options:f});if((e==null?void 0:e.status)==="error")throw n.error("export-signer: failed",{error:e.error,code:e.code}),new P(e.error||"Failed to export private key",e.code)})}};y([C({logger:n,methodName:"handleAuthRequired"})],w.prototype,"handleAuthRequired",1);var f={timeoutMs:3e4},S="jwt-required",q=new Set(["unauthorized","unauthenticated"]);function _(E,i){return i!=null&&q.has(i.toLowerCase())?!0:/\bHTTP 401\b/.test(E)}export{w as a,f as b,S as c};
1
+ import{a as p}from"./chunk-IHMMTMFG.js";import{a as b}from"./chunk-PWYCEHYZ.js";import{a as g,b as m,c as u,d as A,e as P,f as T}from"./chunk-43LFPZII.js";import{a as n}from"./chunk-QNNWOOHI.js";import{a as v,c as y,h as s}from"./chunk-NU7VF7MC.js";import{validateAPIKey as O,WithLoggerContext as C}from"@crossmint/common-sdk-base";var w=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return s(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return s(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return s(this,null,function*(){n.info("TEE connection not initialized, initializing now");let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");n.info("TEE connection initialized successfully")})}handleAuthRequired(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);n.info("get-status: sending request");let h=Date.now(),r=yield t.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:i,data:{authId:this.getAuthId()}},options:f}),a=Date.now()-h;if((r==null?void 0:r.status)!=="success"){let o=(r==null?void 0:r.status)==="error"&&r.error||"Failed to retrieve signer status",l=(r==null?void 0:r.status)==="error"?r.code:void 0;throw n.error("get-status: failed",{status:r==null?void 0:r.status,error:(r==null?void 0:r.status)==="error"?r.error:void 0,code:l,durationMs:a}),_(o,l)?new u(o,l):new A(o,l)}if(n.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:a}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;n.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:e,resolve:c,reject:d}=this.createAuthPromise();if(this._authPromise={promise:e,resolve:c,reject:d},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>s(this,null,function*(){n.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new g)})),d(new g)}))}catch(o){n.error("handleAuthRequired error",{error:o}),d(o)}try{yield e}catch(o){throw n.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return s(this,null,function*(){this.getJwtOrThrow(),this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null||i.trim()==="")throw new u(`${this.type} signer requires a valid Crossmint JWT. The user's session is missing or has expired: re-authenticate the user and refresh the JWT before retrying.`,S);return i}getAuthDataOrThrow(){return{jwt:this.getJwtOrThrow(),apiKey:this.config.crossmint.apiKey}}createAuthPromise(){let i,t;return{promise:new Promise((r,a)=>{i=r,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return s(this,null,function*(){var i;try{yield this.startOnboarding()}catch(t){throw t instanceof u&&((i=this._authPromise)==null||i.reject(t)),t}})}startOnboarding(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection(),h=this.getAuthId();n.info("start-onboarding: sending request");let r=Date.now(),a=this.config.type==="phone"?this.config.channel:void 0,e=yield t.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:i,data:v({authId:h},a!=null?{channel:a}:{})},options:f}),c=Date.now()-r;if(this._onboardingConnectionGeneration=t.connectionGeneration,n.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:c}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}if((e==null?void 0:e.status)==="error"){n.error("start-onboarding: failed",{error:e.error,code:e.code});let d=e.error||"Failed to initiate OTP process.";throw _(d,e.code)?new u(d,e.code):new m(d,e.code)}})}getAuthId(){return this.config.type==="email"?this.config.email!=null?`email:${b(this.config.email)}`:this.config.locator:this.config.phone!=null?`phone:${this.config.phone}`:this.config.locator}verifyOtp(i){return s(this,null,function*(){var a;let t;try{let e=yield this.getTEEConnection();n.info("complete-onboarding: sending request");let c=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:this.getAuthDataOrThrow(),data:{onboardingAuthentication:{encryptedOtp:i}}},options:f}),n.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-c})}catch(e){return n.error("complete-onboarding: error",{error:e}),yield this.handleOnboardingVerificationFailure(e)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new g)})),(a=this._authPromise)==null||a.resolve();return}n.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let h=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",r=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new m(h,r))})}handleOnboardingVerificationFailure(i){return s(this,null,function*(){var r,a,e;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){n.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(c){throw(r=this._authPromise)==null||r.reject(c),c}if(!this._needsAuth){(a=this._authPromise)==null||a.resolve();return}throw new T}throw(e=this._authPromise)==null||e.reject(i),i})}_exportPrivateKey(i,t){return s(this,null,function*(){yield this.ensureAuthenticated();let h=this.getJwtOrThrow(),{scheme:r,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",d=>{i.off(c),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let e=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:h,apiKey:this.config.crossmint.apiKey},data:{scheme:r,encoding:a,walletAddress:this.config.address,authId:this.getAuthId()}},options:f});if((e==null?void 0:e.status)==="error")throw n.error("export-signer: failed",{error:e.error,code:e.code}),new P(e.error||"Failed to export private key",e.code)})}};y([C({logger:n,methodName:"handleAuthRequired"})],w.prototype,"handleAuthRequired",1);var f={timeoutMs:3e4},S="jwt-required",q=new Set(["unauthorized","unauthenticated"]);function _(E,i){return i!=null&&q.has(i.toLowerCase())?!0:/\bHTTP 401\b/.test(E)}export{w as a,f as b,S as c};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkX5PKHTFGcjs = require('./chunk-X5PKHTFG.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkMPIIBOOKcjs = require('./chunk-MPIIBOOK.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var c=class p{constructor(e){_chunkM2AM4CBTcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkMPIIBOOKcjs.a)(e);this.walletFactory=new (0, _chunkX5PKHTFGcjs.a)(t),_chunkM2AM4CBTcjs.a.info("wallets.sdk.initialized")}static from(e){return new p(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,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=t?yield t.createPasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTISVJEJ4cjs = require('./chunk-TISVJEJ4.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkKUT3FS3Ucjs = require('./chunk-KUT3FS3U.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var c=class p{constructor(e){_chunkO673DZDXcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkKUT3FS3Ucjs.a)(e);this.walletFactory=new (0, _chunkTISVJEJ4cjs.a)(t),_chunkO673DZDXcjs.a.info("wallets.sdk.initialized")}static from(e){return new p(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,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=t?yield t.createPasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = c;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOQFZL5LIcjs = require('./chunk-OQFZL5LI.cjs');var _chunkAUO6R32Hcjs = require('./chunk-AUO6R32H.cjs');var _chunkZPO3XSWUcjs = require('./chunk-ZPO3XSWU.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkTCDH5Q6Qcjs = require('./chunk-TCDH5Q6Q.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var g=[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],D=[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.ARC,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.CELO,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function ie(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE:return _chains.avalanche;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI:return _chains.avalancheFuji;case _commonsdkbase.BlockchainIncludingTestnet.CELO:return _chains.celo;case _commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA:return _chunkOQFZL5LIcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN:return _chunkAUO6R32Hcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET:return _chunkZPO3XSWUcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM:return _chains.mainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.ARC:return _chunkTCDH5Q6Qcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS: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 u(t){return g.includes(t)}function c(t){return D.includes(t)}var $={[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE]:_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.CELO]:_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM]:_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN]:_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.ARC]:_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET};function G(t){return $[t]}function Z(t){return t==="solana"||t==="stellar"||u(t)||c(t)}function oe(t,a){if(!Z(t))throw new (0, _chunkD2S37DJ5cjs.c)(`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,i=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(i&&u(r))throw new (0, _chunkD2S37DJ5cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!i&&c(r)){let n=G(r);if(n!=null)return _chunkO673DZDXcjs.a.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;_chunkO673DZDXcjs.a.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}exports.a = ie; exports.b = u; exports.c = c; exports.d = G; exports.e = Z; exports.f = oe;
@@ -1 +1 @@
1
- import{a as O}from"./chunk-HDVUDIDC.js";import{b as K}from"./chunk-RV3Q5EIA.js";import{a as W}from"./chunk-W4GCZ4UZ.js";import{g as x}from"./chunk-43LFPZII.js";import{b as P,c as k}from"./chunk-B4GYB3XY.js";import{o as q,t as $}from"./chunk-4I3EXM4B.js";import{a as L}from"./chunk-YIUOOMT4.js";import{a as T,b as I,d as i,e as l,f as a,g as w,h as d}from"./chunk-NU7VF7MC.js";import{ApiClientError as z}from"@crossmint/common-sdk-base";var g,o,p,u,c,S,m,y,C,R,A,v,E,M,D=class{constructor(e){l(this,v);l(this,g);l(this,o);l(this,p,null);l(this,u);l(this,c);l(this,S);l(this,m);l(this,y);l(this,C);l(this,R);l(this,A);if(a(this,u,e.apiClient),a(this,c,e.options),a(this,S,e.chain),a(this,m,e.walletAddress),a(this,y,e.walletLocator),a(this,C,e.serverSignerResolver),e.recoverySigners.length===0)throw new q("At least one recovery signer is required");a(this,o,[...e.recoverySigners]),a(this,R,e.initialSigners),a(this,A,e.signers),a(this,g,e.signer)}get activeSigner(){return i(this,g)}setActiveSigner(e){a(this,g,e)}get recovery(){return i(this,o)[0]}get recoverySigners(){return[...i(this,o)]}get selectedRecovery(){var e,r;return(r=(e=i(this,p))==null?void 0:e.config)!=null?r:null}selectRecovery(e,r=i(this,o)[e]){w(this,v,E).call(this,e),a(this,p,{index:e,config:r})}descriptorContext(){var e,r,n,s,t,h;return{chain:i(this,S),walletAddress:i(this,m),crossmint:i(this,u).crossmint,clientTEEConnection:(e=i(this,c))==null?void 0:e.clientTEEConnection,resetSignerFrame:(r=i(this,c))==null?void 0:r.resetSignerFrame,onAuthRequired:(s=(n=i(this,c))==null?void 0:n.callbacks)==null?void 0:s.onAuthRequired,deviceSignerKeyStorage:(t=i(this,c))==null?void 0:t.deviceSignerKeyStorage,passkeyProvider:(h=i(this,c))==null?void 0:h.passkeyProvider,serverSigners:i(this,C)}}adoptRecoveryConfig(e,r){w(this,v,E).call(this,e),i(this,o)[e]=r}stripSecretFromRecovery(e,r){w(this,v,E).call(this,e);let n=i(this,o)[e];n.type==="server"&&!x(n)&&(i(this,o)[e]={type:"server",address:r})}addRecoverySigner(e){let r=this.recoveryLocator(e);r!=null&&i(this,o).some(s=>this.recoveryLocator(s)===r)||i(this,o).push(e)}removeRecoverySigner(e){let r=i(this,p),n=r==null?null:i(this,o)[r.index],s=r!=null&&this.recoveryLocator(r.config)===e;if(a(this,o,i(this,o).filter(t=>this.recoveryLocator(t)!==e&&!(s&&t===n))),r!=null){let t=s||n==null?-1:i(this,o).indexOf(n);a(this,p,t===-1?null:I(T({},r),{index:t}))}}assemble(e,r){return d(this,null,function*(){var s,t;let n=W(i(this,S),e,(s=i(this,c))==null?void 0:s.deviceSignerKeyStorage);if(r!=null&&r.isAdminSigner)n.status="active";else{let h=yield this.getSignerState(n.locator());n.status=(t=h.signer)==null?void 0:t.status}return n})}require(){if(i(this,g)==null){if(i(this,R).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let e=this.recovery,r=O(e.type),n=r.signerUnavailableReason();throw n!=null?new Error(n):r.canAutoAssemble(e,this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return i(this,g)}resolveAuthorizingRecovery(){var t,h;let e=this.selectedRecovery;if(e!=null)return{recovery:e,approver:(t=this.recoveryLocator(e))!=null?t:void 0};if(i(this,o).length===1)return{recovery:i(this,o)[0],approver:void 0};let r=i(this,o).map(f=>this.recoveryLocator(f)),n=(h=i(this,g))==null?void 0:h.locator(),s=n==null?-1:r.indexOf(n);if(s===-1){let b=`Call wallet.useRecoveryMethod() with one of them (${r.filter(F=>F!=null).join(", ")}) first.`;throw new $(n==null?`This wallet has multiple recovery methods, so the one authorizing this operation must be selected. ${b}`:`Signer "${n}" is not one of this wallet's recovery methods, and only a recovery method can add or remove signers. ${b}`)}return{recovery:i(this,o)[s],approver:n}}recoveryLocator(e){return e.type==="server"?x(e)?`server:${e.address}`:null:K(e)}withRecoverySigner(e){return d(this,null,function*(){var F;let r=i(this,g),{recovery:n,approver:s}=this.resolveAuthorizingRecovery(),t=n;if(x(t)&&!i(this,C).hasRecoveryResolutionFor(t.address))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useRecoveryMethod({ type: "server", secret: ... }) first with the recovery server secret.');let h=O(t.type),f=this.descriptorContext();if(t.type==="external-wallet"&&!h.canAutoAssemble(t,f))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useRecoveryMethod({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let b=h.buildInternalConfig(t,f);a(this,g,W(i(this,S),b,(F=i(this,c))==null?void 0:F.deviceSignerKeyStorage));try{return yield e(s)}finally{a(this,g,r)}})}getSignerState(e){return d(this,null,function*(){let r=null;try{r=yield i(this,u).getSigner(i(this,y).call(this),e)}catch(s){return L.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:s}),{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return L.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:r}),{response:null,signer:null,pendingOperation:null};let n=P(r,i(this,S));return{response:r,signer:n,pendingOperation:k(r,i(this,S))}})}signerIsRegistered(e){return d(this,null,function*(){return(yield i(this,A).call(this)).some(n=>n.locator===e)})}isSignerApproved(e){return d(this,null,function*(){try{let r=yield w(this,v,M).call(this,e);return this.isApprovedSignerStatus(r==null?void 0:r.status)}catch(r){if(r instanceof z&&r.status===404)return!1;throw L.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:r}),r}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};g=new WeakMap,o=new WeakMap,p=new WeakMap,u=new WeakMap,c=new WeakMap,S=new WeakMap,m=new WeakMap,y=new WeakMap,C=new WeakMap,R=new WeakMap,A=new WeakMap,v=new WeakSet,E=function(e){if(e<0||e>=i(this,o).length)throw new Error(`Recovery signer index ${e} is out of range`)},M=function(e){return d(this,null,function*(){let r=yield i(this,u).getSigner(i(this,y).call(this),e);if(r==null||typeof r!="object"||"error"in r)throw new Error(`Failed to fetch the approval state of signer ${e}`);return P(r,i(this,S))})};export{D as a};
1
+ import{a as O}from"./chunk-HDVUDIDC.js";import{b as K}from"./chunk-RV3Q5EIA.js";import{a as W}from"./chunk-4VGTYVW7.js";import{g as x}from"./chunk-43LFPZII.js";import{b as P,c as k}from"./chunk-B4GYB3XY.js";import{o as q,t as $}from"./chunk-4I3EXM4B.js";import{a as L}from"./chunk-QNNWOOHI.js";import{a as T,b as I,d as i,e as l,f as a,g as w,h as d}from"./chunk-NU7VF7MC.js";import{ApiClientError as z}from"@crossmint/common-sdk-base";var g,o,p,u,c,S,m,y,C,R,A,v,E,M,D=class{constructor(e){l(this,v);l(this,g);l(this,o);l(this,p,null);l(this,u);l(this,c);l(this,S);l(this,m);l(this,y);l(this,C);l(this,R);l(this,A);if(a(this,u,e.apiClient),a(this,c,e.options),a(this,S,e.chain),a(this,m,e.walletAddress),a(this,y,e.walletLocator),a(this,C,e.serverSignerResolver),e.recoverySigners.length===0)throw new q("At least one recovery signer is required");a(this,o,[...e.recoverySigners]),a(this,R,e.initialSigners),a(this,A,e.signers),a(this,g,e.signer)}get activeSigner(){return i(this,g)}setActiveSigner(e){a(this,g,e)}get recovery(){return i(this,o)[0]}get recoverySigners(){return[...i(this,o)]}get selectedRecovery(){var e,r;return(r=(e=i(this,p))==null?void 0:e.config)!=null?r:null}selectRecovery(e,r=i(this,o)[e]){w(this,v,E).call(this,e),a(this,p,{index:e,config:r})}descriptorContext(){var e,r,n,s,t,h;return{chain:i(this,S),walletAddress:i(this,m),crossmint:i(this,u).crossmint,clientTEEConnection:(e=i(this,c))==null?void 0:e.clientTEEConnection,resetSignerFrame:(r=i(this,c))==null?void 0:r.resetSignerFrame,onAuthRequired:(s=(n=i(this,c))==null?void 0:n.callbacks)==null?void 0:s.onAuthRequired,deviceSignerKeyStorage:(t=i(this,c))==null?void 0:t.deviceSignerKeyStorage,passkeyProvider:(h=i(this,c))==null?void 0:h.passkeyProvider,serverSigners:i(this,C)}}adoptRecoveryConfig(e,r){w(this,v,E).call(this,e),i(this,o)[e]=r}stripSecretFromRecovery(e,r){w(this,v,E).call(this,e);let n=i(this,o)[e];n.type==="server"&&!x(n)&&(i(this,o)[e]={type:"server",address:r})}addRecoverySigner(e){let r=this.recoveryLocator(e);r!=null&&i(this,o).some(s=>this.recoveryLocator(s)===r)||i(this,o).push(e)}removeRecoverySigner(e){let r=i(this,p),n=r==null?null:i(this,o)[r.index],s=r!=null&&this.recoveryLocator(r.config)===e;if(a(this,o,i(this,o).filter(t=>this.recoveryLocator(t)!==e&&!(s&&t===n))),r!=null){let t=s||n==null?-1:i(this,o).indexOf(n);a(this,p,t===-1?null:I(T({},r),{index:t}))}}assemble(e,r){return d(this,null,function*(){var s,t;let n=W(i(this,S),e,(s=i(this,c))==null?void 0:s.deviceSignerKeyStorage);if(r!=null&&r.isAdminSigner)n.status="active";else{let h=yield this.getSignerState(n.locator());n.status=(t=h.signer)==null?void 0:t.status}return n})}require(){if(i(this,g)==null){if(i(this,R).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let e=this.recovery,r=O(e.type),n=r.signerUnavailableReason();throw n!=null?new Error(n):r.canAutoAssemble(e,this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return i(this,g)}resolveAuthorizingRecovery(){var t,h;let e=this.selectedRecovery;if(e!=null)return{recovery:e,approver:(t=this.recoveryLocator(e))!=null?t:void 0};if(i(this,o).length===1)return{recovery:i(this,o)[0],approver:void 0};let r=i(this,o).map(f=>this.recoveryLocator(f)),n=(h=i(this,g))==null?void 0:h.locator(),s=n==null?-1:r.indexOf(n);if(s===-1){let b=`Call wallet.useRecoveryMethod() with one of them (${r.filter(F=>F!=null).join(", ")}) first.`;throw new $(n==null?`This wallet has multiple recovery methods, so the one authorizing this operation must be selected. ${b}`:`Signer "${n}" is not one of this wallet's recovery methods, and only a recovery method can add or remove signers. ${b}`)}return{recovery:i(this,o)[s],approver:n}}recoveryLocator(e){return e.type==="server"?x(e)?`server:${e.address}`:null:K(e)}withRecoverySigner(e){return d(this,null,function*(){var F;let r=i(this,g),{recovery:n,approver:s}=this.resolveAuthorizingRecovery(),t=n;if(x(t)&&!i(this,C).hasRecoveryResolutionFor(t.address))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useRecoveryMethod({ type: "server", secret: ... }) first with the recovery server secret.');let h=O(t.type),f=this.descriptorContext();if(t.type==="external-wallet"&&!h.canAutoAssemble(t,f))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useRecoveryMethod({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let b=h.buildInternalConfig(t,f);a(this,g,W(i(this,S),b,(F=i(this,c))==null?void 0:F.deviceSignerKeyStorage));try{return yield e(s)}finally{a(this,g,r)}})}getSignerState(e){return d(this,null,function*(){let r=null;try{r=yield i(this,u).getSigner(i(this,y).call(this),e)}catch(s){return L.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:s}),{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return L.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:r}),{response:null,signer:null,pendingOperation:null};let n=P(r,i(this,S));return{response:r,signer:n,pendingOperation:k(r,i(this,S))}})}signerIsRegistered(e){return d(this,null,function*(){return(yield i(this,A).call(this)).some(n=>n.locator===e)})}isSignerApproved(e){return d(this,null,function*(){try{let r=yield w(this,v,M).call(this,e);return this.isApprovedSignerStatus(r==null?void 0:r.status)}catch(r){if(r instanceof z&&r.status===404)return!1;throw L.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:r}),r}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};g=new WeakMap,o=new WeakMap,p=new WeakMap,u=new WeakMap,c=new WeakMap,S=new WeakMap,m=new WeakMap,y=new WeakMap,C=new WeakMap,R=new WeakMap,A=new WeakMap,v=new WeakSet,E=function(e){if(e<0||e>=i(this,o).length)throw new Error(`Recovery signer index ${e} is out of range`)},M=function(e){return d(this,null,function*(){let r=yield i(this,u).getSigner(i(this,y).call(this),e);if(r==null||typeof r!="object"||"error"in r)throw new Error(`Failed to fetch the approval state of signer ${e}`);return P(r,i(this,S))})};export{D as a};
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-BQZHLT2Q.js";import{a as s}from"./chunk-YIUOOMT4.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as h}from"ox";import{isHex as y,toHex as d}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=y(e)?e:d(e),r=h.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 u=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",authId:this.getAuthId()}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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-6EPYTT7A.js";import{a as s}from"./chunk-QNNWOOHI.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as h}from"ox";import{isHex as y,toHex as d}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=y(e)?e:d(e),r=h.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 u=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",authId:this.getAuthId()}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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
- import{a as s,b as o}from"./chunk-BQZHLT2Q.js";import{a as i}from"./chunk-YIUOOMT4.js";import{h as t}from"./chunk-NU7VF7MC.js";import a from"bs58";var g=class d extends s{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(a.decode(e))})}signTransaction(e){return t(this,null,function*(){return yield this.signMessage(e)})}sign(e){return t(this,null,function*(){var r;yield this.handleAuthRequired();let c=this.getJwtOrThrow();i.info("sign: sending request",{keyType:"ed25519"});let u=Date.now(),n=yield(r=this.config.clientTEEConnection)==null?void 0:r.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(e)),encoding:"base58",authId:this.getAuthId()}},options:o});if(i.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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 payload");return d.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-6EPYTT7A.js";import{a as i}from"./chunk-QNNWOOHI.js";import{h as t}from"./chunk-NU7VF7MC.js";import a from"bs58";var g=class d extends s{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(a.decode(e))})}signTransaction(e){return t(this,null,function*(){return yield this.signMessage(e)})}sign(e){return t(this,null,function*(){var r;yield this.handleAuthRequired();let c=this.getJwtOrThrow();i.info("sign: sending request",{keyType:"ed25519"});let u=Date.now(),n=yield(r=this.config.clientTEEConnection)==null?void 0:r.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(e)),encoding:"base58",authId:this.getAuthId()}},options:o});if(i.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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 payload");return d.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
@@ -1 +1 @@
1
- import{o as r}from"./chunk-4I3EXM4B.js";import{a as o}from"./chunk-YIUOOMT4.js";function i(e){if(e.recoveryMethods!=null&&e.recovery!=null)throw new r("Pass either `recovery` or `recoveryMethods`, not both");if(e.recoveryMethods!=null){if(!Array.isArray(e.recoveryMethods))throw new r("`recoveryMethods` must be an array of recovery methods. To pass a single recovery method, use `recovery`");return e.recoveryMethods}return e.recovery==null?[]:Array.isArray(e.recovery)?(o.warn("wallet.create.recovery.deprecatedListForm",{message:"Passing a list to `recovery` is deprecated. Use `recoveryMethods` instead.",count:e.recovery.length}),e.recovery):[e.recovery]}function s(e){return e.recoveryMethods!=null||Array.isArray(e.recovery)}export{i as a,s as b};
1
+ import{o as r}from"./chunk-4I3EXM4B.js";import{a as o}from"./chunk-QNNWOOHI.js";function i(e){if(e.recoveryMethods!=null&&e.recovery!=null)throw new r("Pass either `recovery` or `recoveryMethods`, not both");if(e.recoveryMethods!=null){if(!Array.isArray(e.recoveryMethods))throw new r("`recoveryMethods` must be an array of recovery methods. To pass a single recovery method, use `recovery`");return e.recoveryMethods}return e.recovery==null?[]:Array.isArray(e.recovery)?(o.warn("wallet.create.recovery.deprecatedListForm",{message:"Passing a list to `recovery` is deprecated. Use `recoveryMethods` instead.",count:e.recovery.length}),e.recovery):[e.recovery]}function s(e){return e.recoveryMethods!=null||Array.isArray(e.recovery)}export{i as a,s as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _ox = require('ox');function d(n){let e=_bs582.default.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var g={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw _chunkM2AM4CBTcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(_ox.Hex.fromBytes(_ox.Base64.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};exports.a = g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _ox = require('ox');function d(n){let e=_bs582.default.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var g={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw _chunkO673DZDXcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(_ox.Hex.fromBytes(_ox.Base64.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};exports.a = g;
@@ -1 +1 @@
1
- import{a as ue}from"./chunk-GYXKGRZY.js";import{a as pe}from"./chunk-QUYYIVZB.js";import{a as ve}from"./chunk-LX55L36L.js";import{a as ye,b as Se}from"./chunk-FXKT7O4T.js";import{a as de}from"./chunk-RFWRLJEX.js";import{a as I}from"./chunk-HDVUDIDC.js";import{a as _,b as q}from"./chunk-RV3Q5EIA.js";import{a as ge,b as he}from"./chunk-VG67JHRI.js";import{a as ce}from"./chunk-BQZHLT2Q.js";import{g as J}from"./chunk-43LFPZII.js";import{a as ae,b as oe,c as le}from"./chunk-HADAG3ZB.js";import{b as se}from"./chunk-B4GYB3XY.js";import{f as ne}from"./chunk-JVBAZHA6.js";import{E as Y,F as Z,H as ee,I as re,J as te,O as ie,R as k,d as B,e as V,j as $,l as z,m as Q,n as K,o as D,u as X}from"./chunk-4I3EXM4B.js";import{a as s}from"./chunk-YIUOOMT4.js";import{a as u,b as N,c as R,d as i,e as P,f as x,g as E,h as l}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as A}from"@crossmint/common-sdk-base";var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w=class{constructor(e,r){P(this,b);P(this,O);P(this,d);P(this,F);P(this,T);P(this,o);P(this,S);P(this,W,[]);P(this,M);P(this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;x(this,d,r),this.chain=t,this.address=n,this.owner=a,x(this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&J(p)).map(p=>p.address);x(this,W,h!=null?h:[]),x(this,F,C!=null?C:[]),x(this,T,new de({chain:t,projectId:i(this,d).projectId,environment:i(this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:i(this,W),knownOnChainAddresses:()=>[...i(this,F).filter(p=>p.type==="server"&&J(p)).map(p=>p.address),...i(this,W)]})),x(this,o,new ue({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,T),recoverySigners:m,initialSigners:i(this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!J(p)&&i(this,o).stripSecretFromRecovery(Ce,i(this,T).resolveRecovery(p))}),x(this,S,new ve({chain:t,walletAddress:this.address,options:c,signerManager:i(this,o),serverSignerResolver:i(this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),x(this,M,this.initDefaultSigner())}get signer(){return i(this,o).activeSigner}waitForInit(){return l(this,null,function*(){yield i(this,M)})}initDefaultSigner(){return l(this,null,function*(){if(i(this,o).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,o).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,F).length===0?i(this,o).recovery:i(this,F).length===1?i(this,F)[0]:null;if(e==null)return;let r=I(e.type),t=i(this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,o).recovery;try{let a=r.buildInternalConfig(e,t);i(this,o).setActiveSigner(yield i(this,o).assemble(a,{isAdminSigner:n}))}catch(a){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,o).recovery.type,signerCount:i(this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return i(e,F)}static getApiRecoveryServerSignerAddresses(e){return i(e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return i(e,W)}get apiClient(){return i(this,d)}get options(){return i(this,O)}get chainAdapter(){return ae(this.chain)}resolveServerSignerApiLocator(e){return i(this,T).apiLocator(e)}get recovery(){return i(this,o).recovery}get recoveryMethods(){return i(this,o).recoverySigners}balances(e){return l(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield i(this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw s.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return s.info("wallet.balances.success"),pe(a,this.chain,t,e)})}stagingFund(e,r){return l(this,null,function*(){s.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 s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}nfts(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,d).getNfts(N(u({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw s.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return l(this,null,function*(){let e=yield i(this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return l(this,null,function*(){let r=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return l(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 l(this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new ee(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=ge(e),g=this.resolveChainForEnvironment(),v=he(r,g);s.info("wallet.send.start",u({recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=i(this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=u({recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,d).send(this.walletLocator,v,C);if("message"in f)throw s.error("wallet.send.error",{error:f}),new re(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return s.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return l(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 l(this,null,function*(){if(s.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 s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.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 l(this,null,function*(){s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){var m;let a=typeof t=="string"?t:q(t),c=yield i(this,o).getSignerState(a);if(c.signer!=null){if(i(this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&s.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),s.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.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 s.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield i(this,d).registerSigner(this.walletLocator,u(u(u({signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw s.error("wallet.addSigner.error",{error:h}),h.code===z?new Q(h.message):new $(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=se(h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return l(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return u({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}case"signature":{let n={signatureId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},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),s.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),s.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else s.info("wallet.addSigner.success");return N(u({},e),{status:"success"})})}removeSigner(e,r){return l(this,null,function*(){let t=this.resolveSignerLocator(e);return s.info("wallet.removeSigner.start",{signerLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeSigner(this.walletLocator,t,u({chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw s.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),s.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported(),s.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),c=yield i(this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw s.error("wallet.addRecoveryMethod.error",{error:c}),new $(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(s.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),i(this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),s.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return s.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw s.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),i(this,o).removeRecoverySigner(t),s.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new X(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:i(this,o).require().locator()}useSigner(e){return l(this,null,function*(){s.info("wallet.useSigner.start"),e.type==="server"&&i(this,T).resetDelegatedCache(),I(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=I(e.type).buildInternalConfig(e,i(this,o).descriptorContext()),n=q(e);i(this,o).setActiveSigner(yield i(this,o).assemble(t,{isAdminSigner:r})),s.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return l(this,null,function*(){s.info("wallet.useRecoveryMethod.start"),I(e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>i(this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new D(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&i(this,o).stripSecretFromRecovery(r,i(this,T).resolveRecovery(e));let t=I(e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;i(this,o).selectRecovery(r,t),s.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:i(this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return l(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 l(this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=i(this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&i(this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_(e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new D('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_(this.recoveryMethods[r]);if(n==null)throw new D('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return N(u({},e),{id:n})}tryAutoSelectPasskey(e){return l(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):q(e)}isPasskeyMissingId(e){return _(e)==null}signerIsRegistered(e){return l(this,null,function*(){return i(this,o).signerIsRegistered(e)})}isSignerApproved(e){return l(this,null,function*(){return i(this,o).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return l(this,null,function*(){yield i(this,S).recover()})}signers(){return l(this,null,function*(){var a,c;s.info("wallet.signers.start");let e=yield i(this,d).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new V(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw s.error("wallet.signers.error",{error:g}),new B(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>l(this,null,function*(){try{return(yield i(this,o).getSignerState(g.locator)).signer}catch(v){return s.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return s.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,o)}preAuthIfNeeded(){return l(this,null,function*(){yield i(this,M),i(this,L)==null&&x(this,L,this.recover());try{yield i(this,L)}finally{x(this,L,null)}let e=i(this,o).require();e instanceof ce&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=I(e.type),t=i(this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&i(this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=ne(this.chain,i(this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return l(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return l(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 l(this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,o).require(),n=yield i(this,d).getSignature(this.walletLocator,e);if("error"in n)throw k(n),new Y(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return l(this,null,function*(){var v,y,h,C,f;let t=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in t)throw k(t),new te(JSON.stringify(t));yield(h=(y=(v=i(this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=i(this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(m,U)=>le(t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return l(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new ie(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return l(this,null,function*(){let t=yield i(this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new Z(JSON.stringify(t));return t})}waitForSignature(e){return l(this,null,function*(){return yield Se(i(this,d),this.walletLocator,e)})}waitForTransaction(n){return l(this,arguments,function*(e,r=6e4,t={}){return yield ye(i(this,d),this.walletLocator,e,u({timeoutMs:r},t))})}sleep(e){return l(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return l(this,null,function*(){let r=yield i(this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&s.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return l(this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield E(this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new $(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new K(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return l(this,null,function*(){return yield Promise.all(e.map(n=>l(this,null,function*(){let a=yield E(this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return N(u({},c),{signer:a.locator()})})))})},R([A({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),R([A({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),R([A({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),R([A({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),R([A({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),R([A({logger:s,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),R([A({logger:s,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),R([A({logger:s,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),R([A({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),R([A({logger:s,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),R([A({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),R([A({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&oe(G.chainType)}export{w as a};
1
+ import{a as ue}from"./chunk-AMGE2J7V.js";import{a as pe}from"./chunk-KNAIS6WY.js";import{a as ve}from"./chunk-J7N56JUE.js";import{a as ye,b as Se}from"./chunk-PEHDJW5W.js";import{a as de}from"./chunk-RFWRLJEX.js";import{a as I}from"./chunk-HDVUDIDC.js";import{a as _,b as q}from"./chunk-RV3Q5EIA.js";import{a as ge,b as he}from"./chunk-VG67JHRI.js";import{f as ne}from"./chunk-Z4OBKN5C.js";import{a as ce}from"./chunk-6EPYTT7A.js";import{g as J}from"./chunk-43LFPZII.js";import{a as ae,b as oe,c as le}from"./chunk-JAP6U3CJ.js";import{b as se}from"./chunk-B4GYB3XY.js";import{E as Y,F as Z,H as ee,I as re,J as te,O as ie,R as k,d as B,e as V,j as $,l as z,m as Q,n as K,o as D,u as X}from"./chunk-4I3EXM4B.js";import{a as s}from"./chunk-QNNWOOHI.js";import{a as u,b as N,c as R,d as i,e as P,f as x,g as E,h as l}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as A}from"@crossmint/common-sdk-base";var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w=class{constructor(e,r){P(this,b);P(this,O);P(this,d);P(this,F);P(this,T);P(this,o);P(this,S);P(this,W,[]);P(this,M);P(this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;x(this,d,r),this.chain=t,this.address=n,this.owner=a,x(this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&J(p)).map(p=>p.address);x(this,W,h!=null?h:[]),x(this,F,C!=null?C:[]),x(this,T,new de({chain:t,projectId:i(this,d).projectId,environment:i(this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:i(this,W),knownOnChainAddresses:()=>[...i(this,F).filter(p=>p.type==="server"&&J(p)).map(p=>p.address),...i(this,W)]})),x(this,o,new ue({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,T),recoverySigners:m,initialSigners:i(this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!J(p)&&i(this,o).stripSecretFromRecovery(Ce,i(this,T).resolveRecovery(p))}),x(this,S,new ve({chain:t,walletAddress:this.address,options:c,signerManager:i(this,o),serverSignerResolver:i(this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),x(this,M,this.initDefaultSigner())}get signer(){return i(this,o).activeSigner}waitForInit(){return l(this,null,function*(){yield i(this,M)})}initDefaultSigner(){return l(this,null,function*(){if(i(this,o).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,o).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,F).length===0?i(this,o).recovery:i(this,F).length===1?i(this,F)[0]:null;if(e==null)return;let r=I(e.type),t=i(this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,o).recovery;try{let a=r.buildInternalConfig(e,t);i(this,o).setActiveSigner(yield i(this,o).assemble(a,{isAdminSigner:n}))}catch(a){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,o).recovery.type,signerCount:i(this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return i(e,F)}static getApiRecoveryServerSignerAddresses(e){return i(e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return i(e,W)}get apiClient(){return i(this,d)}get options(){return i(this,O)}get chainAdapter(){return ae(this.chain)}resolveServerSignerApiLocator(e){return i(this,T).apiLocator(e)}get recovery(){return i(this,o).recovery}get recoveryMethods(){return i(this,o).recoverySigners}balances(e){return l(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield i(this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw s.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return s.info("wallet.balances.success"),pe(a,this.chain,t,e)})}stagingFund(e,r){return l(this,null,function*(){s.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 s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}nfts(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,d).getNfts(N(u({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw s.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return l(this,null,function*(){let e=yield i(this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return l(this,null,function*(){let r=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return l(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 l(this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new ee(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=ge(e),g=this.resolveChainForEnvironment(),v=he(r,g);s.info("wallet.send.start",u({recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=i(this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=u({recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,d).send(this.walletLocator,v,C);if("message"in f)throw s.error("wallet.send.error",{error:f}),new re(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return s.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return l(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 l(this,null,function*(){if(s.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 s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.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 l(this,null,function*(){s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){var m;let a=typeof t=="string"?t:q(t),c=yield i(this,o).getSignerState(a);if(c.signer!=null){if(i(this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&s.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),s.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.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 s.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield i(this,d).registerSigner(this.walletLocator,u(u(u({signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw s.error("wallet.addSigner.error",{error:h}),h.code===z?new Q(h.message):new $(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=se(h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return l(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return u({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}case"signature":{let n={signatureId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},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),s.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),s.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else s.info("wallet.addSigner.success");return N(u({},e),{status:"success"})})}removeSigner(e,r){return l(this,null,function*(){let t=this.resolveSignerLocator(e);return s.info("wallet.removeSigner.start",{signerLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeSigner(this.walletLocator,t,u({chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw s.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),s.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported(),s.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),c=yield i(this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw s.error("wallet.addRecoveryMethod.error",{error:c}),new $(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(s.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),i(this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),s.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return s.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw s.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),i(this,o).removeRecoverySigner(t),s.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new X(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:i(this,o).require().locator()}useSigner(e){return l(this,null,function*(){s.info("wallet.useSigner.start"),e.type==="server"&&i(this,T).resetDelegatedCache(),I(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=I(e.type).buildInternalConfig(e,i(this,o).descriptorContext()),n=q(e);i(this,o).setActiveSigner(yield i(this,o).assemble(t,{isAdminSigner:r})),s.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return l(this,null,function*(){s.info("wallet.useRecoveryMethod.start"),I(e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>i(this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new D(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&i(this,o).stripSecretFromRecovery(r,i(this,T).resolveRecovery(e));let t=I(e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;i(this,o).selectRecovery(r,t),s.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:i(this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return l(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 l(this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=i(this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&i(this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_(e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new D('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_(this.recoveryMethods[r]);if(n==null)throw new D('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return N(u({},e),{id:n})}tryAutoSelectPasskey(e){return l(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):q(e)}isPasskeyMissingId(e){return _(e)==null}signerIsRegistered(e){return l(this,null,function*(){return i(this,o).signerIsRegistered(e)})}isSignerApproved(e){return l(this,null,function*(){return i(this,o).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return l(this,null,function*(){yield i(this,S).recover()})}signers(){return l(this,null,function*(){var a,c;s.info("wallet.signers.start");let e=yield i(this,d).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new V(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw s.error("wallet.signers.error",{error:g}),new B(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>l(this,null,function*(){try{return(yield i(this,o).getSignerState(g.locator)).signer}catch(v){return s.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return s.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,o)}preAuthIfNeeded(){return l(this,null,function*(){yield i(this,M),i(this,L)==null&&x(this,L,this.recover());try{yield i(this,L)}finally{x(this,L,null)}let e=i(this,o).require();e instanceof ce&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=I(e.type),t=i(this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&i(this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=ne(this.chain,i(this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return l(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return l(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 l(this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,o).require(),n=yield i(this,d).getSignature(this.walletLocator,e);if("error"in n)throw k(n),new Y(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return l(this,null,function*(){var v,y,h,C,f;let t=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in t)throw k(t),new te(JSON.stringify(t));yield(h=(y=(v=i(this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=i(this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(m,U)=>le(t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return l(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new ie(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return l(this,null,function*(){let t=yield i(this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new Z(JSON.stringify(t));return t})}waitForSignature(e){return l(this,null,function*(){return yield Se(i(this,d),this.walletLocator,e)})}waitForTransaction(n){return l(this,arguments,function*(e,r=6e4,t={}){return yield ye(i(this,d),this.walletLocator,e,u({timeoutMs:r},t))})}sleep(e){return l(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return l(this,null,function*(){let r=yield i(this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&s.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return l(this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield E(this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new $(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new K(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return l(this,null,function*(){return yield Promise.all(e.map(n=>l(this,null,function*(){let a=yield E(this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return N(u({},c),{signer:a.locator()})})))})},R([A({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),R([A({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),R([A({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),R([A({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),R([A({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),R([A({logger:s,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),R([A({logger:s,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),R([A({logger:s,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),R([A({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),R([A({logger:s,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),R([A({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),R([A({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&oe(G.chainType)}export{w as a};