@crossmint/wallets-sdk 1.0.0-beta.7 → 1.0.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 (81) 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/chains.cjs +1 -1
  8. package/dist/chains/chains.js +1 -1
  9. package/dist/{chunk-HQVHXT3U.js → chunk-2IMANHYJ.js} +1 -1
  10. package/dist/{chunk-JMCNCVQN.cjs → chunk-2O4B6RLQ.cjs} +1 -1
  11. package/dist/{chunk-2XOKOXIL.cjs → chunk-3ZJ2NA6W.cjs} +1 -1
  12. package/dist/{chunk-MKKB6W5V.js → chunk-4D662ZGC.js} +1 -1
  13. package/dist/{chunk-5Z6QHCTT.cjs → chunk-4NS5CXOG.cjs} +2 -2
  14. package/dist/{chunk-V5A3FGH2.cjs → chunk-6S3ILDIR.cjs} +1 -1
  15. package/dist/{chunk-JJKL6FU2.cjs → chunk-DK7IEP4I.cjs} +1 -1
  16. package/dist/chunk-E65D5XWN.js +1 -0
  17. package/dist/{chunk-P3ZA2ACP.cjs → chunk-EXS5WGZO.cjs} +1 -1
  18. package/dist/{chunk-FNWSI6UN.js → chunk-FWTYIH3S.js} +1 -1
  19. package/dist/{chunk-RKMOWHVB.cjs → chunk-JYIA4X2R.cjs} +1 -1
  20. package/dist/{chunk-3AJ7OWQE.cjs → chunk-L4VOHSRP.cjs} +1 -1
  21. package/dist/{chunk-2AKP3GZ7.js → chunk-LXLDXNTT.js} +1 -1
  22. package/dist/{chunk-LECLHOLK.cjs → chunk-M5JPPZKX.cjs} +1 -1
  23. package/dist/{chunk-Z5BYVIWY.js → chunk-MDHY42QE.js} +1 -1
  24. package/dist/{chunk-5QKUXVP3.js → chunk-MKQDODKI.js} +1 -1
  25. package/dist/{chunk-D3CCPMC3.js → chunk-MMWM4VZB.js} +1 -1
  26. package/dist/{chunk-SG4NRUNV.js → chunk-MO5OIRRN.js} +1 -1
  27. package/dist/{chunk-VDT2DSTW.cjs → chunk-MWA2XXJM.cjs} +1 -1
  28. package/dist/{chunk-LLQEZP55.js → chunk-N7TIQVRW.js} +1 -1
  29. package/dist/{chunk-CKZPF7KE.cjs → chunk-OJNZEJKP.cjs} +1 -1
  30. package/dist/{chunk-OYPXGE5H.js → chunk-OJUTGJJV.js} +1 -1
  31. package/dist/{chunk-2UJBCUG2.cjs → chunk-PQTGZOIH.cjs} +1 -1
  32. package/dist/{chunk-BP3WBO3W.cjs → chunk-PXUDJFUQ.cjs} +1 -1
  33. package/dist/{chunk-2X65YHU4.js → chunk-SSCPHOS2.js} +1 -1
  34. package/dist/{chunk-NR4PS5NF.cjs → chunk-UNTAJ7NG.cjs} +1 -1
  35. package/dist/{chunk-SAXV4RQK.js → chunk-UQLQFGZH.js} +1 -1
  36. package/dist/chunk-VIWV4DQC.cjs +1 -0
  37. package/dist/{chunk-A4ENPOX6.js → chunk-WEV53SFU.js} +1 -1
  38. package/dist/{chunk-Y2OIXWOS.js → chunk-YKULFPTG.js} +1 -1
  39. package/dist/{chunk-7O3CV5HX.cjs → chunk-ZLITPB7O.cjs} +1 -1
  40. package/dist/{chunk-MTKY5MIE.js → chunk-ZXF23FGY.js} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +1 -1
  43. package/dist/logger/index.cjs +1 -1
  44. package/dist/logger/index.js +1 -1
  45. package/dist/logger/init.cjs +1 -1
  46. package/dist/logger/init.js +1 -1
  47. package/dist/sdk.cjs +1 -1
  48. package/dist/sdk.js +1 -1
  49. package/dist/signers/index.cjs +1 -1
  50. package/dist/signers/index.js +1 -1
  51. package/dist/signers/non-custodial/index.cjs +1 -1
  52. package/dist/signers/non-custodial/index.js +1 -1
  53. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  54. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  55. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  56. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  57. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  58. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  59. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  60. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  61. package/dist/utils/constants.cjs +1 -1
  62. package/dist/utils/constants.js +1 -1
  63. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  64. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  65. package/dist/utils/device-signers/index.cjs +1 -1
  66. package/dist/utils/device-signers/index.js +1 -1
  67. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  68. package/dist/wallets/__tests__/test-helpers.js +1 -1
  69. package/dist/wallets/evm.cjs +1 -1
  70. package/dist/wallets/evm.js +1 -1
  71. package/dist/wallets/solana.cjs +1 -1
  72. package/dist/wallets/solana.js +1 -1
  73. package/dist/wallets/stellar.cjs +1 -1
  74. package/dist/wallets/stellar.js +1 -1
  75. package/dist/wallets/wallet-factory.cjs +1 -1
  76. package/dist/wallets/wallet-factory.js +1 -1
  77. package/dist/wallets/wallet.cjs +1 -1
  78. package/dist/wallets/wallet.js +1 -1
  79. package/package.json +3 -3
  80. package/dist/chunk-CV5GT7CP.cjs +0 -1
  81. package/dist/chunk-J7C3SSSQ.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkJJKL6FU2cjs = require('../../chunk-JJKL6FU2.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-V5A3FGH2.cjs');require('../../chunk-CV5GT7CP.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({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=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkJJKL6FU2cjs.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)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(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)=>_chunk2GKPWQBQcjs.g.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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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={})=>_chunk2GKPWQBQcjs.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={})=>_chunk2GKPWQBQcjs.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkJJKL6FU2cjs.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 _chunk2GKPWQBQcjs.g.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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(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)=>_chunk2GKPWQBQcjs.g.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(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(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")=>_chunk2GKPWQBQcjs.g.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 = P; exports.createMockResponse = b; 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 = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; 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 _chunkDK7IEP4Icjs = require('../../chunk-DK7IEP4I.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-6S3ILDIR.cjs');require('../../chunk-VIWV4DQC.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({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=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkDK7IEP4Icjs.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)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(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)=>_chunk2GKPWQBQcjs.g.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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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)=>_chunk2GKPWQBQcjs.g.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={})=>_chunk2GKPWQBQcjs.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={})=>_chunk2GKPWQBQcjs.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkDK7IEP4Icjs.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 _chunk2GKPWQBQcjs.g.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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(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)=>_chunk2GKPWQBQcjs.g.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(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(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")=>_chunk2GKPWQBQcjs.g.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 = P; exports.createMockResponse = b; 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 = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; 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 E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-HQVHXT3U.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-2X65YHU4.js";import"../../chunk-J7C3SSSQ.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({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(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(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:M.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(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(u(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=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h 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 E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-2IMANHYJ.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-SSCPHOS2.js";import"../../chunk-E65D5XWN.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({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(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(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:M.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(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(u(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=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h 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 _chunkJJKL6FU2cjs = require('../chunk-JJKL6FU2.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkJJKL6FU2cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDK7IEP4Icjs = require('../chunk-DK7IEP4I.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-6S3ILDIR.cjs');require('../chunk-VIWV4DQC.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkDK7IEP4Icjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-HQVHXT3U.js";import"../chunk-EXC7TCGL.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import{a}from"../chunk-2IMANHYJ.js";import"../chunk-EXC7TCGL.js";import"../chunk-SSCPHOS2.js";import"../chunk-E65D5XWN.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkJJKL6FU2cjs = require('../chunk-JJKL6FU2.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkJJKL6FU2cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkDK7IEP4Icjs = require('../chunk-DK7IEP4I.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-6S3ILDIR.cjs');require('../chunk-VIWV4DQC.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkDK7IEP4Icjs.a;
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-HQVHXT3U.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-2IMANHYJ.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-SSCPHOS2.js";import"../chunk-E65D5XWN.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJMCNCVQNcjs = require('../chunk-JMCNCVQN.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkJMCNCVQNcjs.c; exports.isTestnetChain = _chunkJMCNCVQNcjs.b; exports.isValidChain = _chunkJMCNCVQNcjs.e; exports.mainnetToTestnet = _chunkJMCNCVQNcjs.d; exports.toViemChain = _chunkJMCNCVQNcjs.a; exports.validateChainForEnvironment = _chunkJMCNCVQNcjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2O4B6RLQcjs = require('../chunk-2O4B6RLQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-6S3ILDIR.cjs');require('../chunk-VIWV4DQC.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunk2O4B6RLQcjs.c; exports.isTestnetChain = _chunk2O4B6RLQcjs.b; exports.isValidChain = _chunk2O4B6RLQcjs.e; exports.mainnetToTestnet = _chunk2O4B6RLQcjs.d; exports.toViemChain = _chunk2O4B6RLQcjs.a; exports.validateChainForEnvironment = _chunk2O4B6RLQcjs.f;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-A4ENPOX6.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.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-WEV53SFU.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-SSCPHOS2.js";import"../chunk-E65D5XWN.js";import"../chunk-J3R36SGJ.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 o}from"./chunk-EXC7TCGL.js";import{a as n}from"./chunk-2X65YHU4.js";import{b as p,c as l}from"./chunk-J7C3SSSQ.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as h,APIKeyUsageOrigin as d,CrossmintApiClient as g}from"@crossmint/common-sdk-base";var c=class extends g{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;n.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?n.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&n.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return t(this,null,function*(){n.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?n.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&n.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===h.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){n.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?n.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&n.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===d.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{c as a};
1
+ import{a as o}from"./chunk-EXC7TCGL.js";import{a as n}from"./chunk-SSCPHOS2.js";import{b as p,c as l}from"./chunk-E65D5XWN.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as h,APIKeyUsageOrigin as d,CrossmintApiClient as g}from"@crossmint/common-sdk-base";var c=class extends g{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;n.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?n.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&n.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return t(this,null,function*(){n.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?n.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&n.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===h.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){n.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?n.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&n.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===d.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(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.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;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.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;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.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET: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:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_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.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.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,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunkV5A3FGH2cjs.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;_chunkV5A3FGH2cjs.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 = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(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.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;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.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;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.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET: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:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_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.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.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,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunk6S3ILDIRcjs.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;_chunk6S3ILDIRcjs.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 = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var b={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkV5A3FGH2cjs.a.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield _ox.WebAuthnP256.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield _ox.WebAuthnP256.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var b={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunk6S3ILDIRcjs.a.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield _ox.WebAuthnP256.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield _ox.WebAuthnP256.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-2AKP3GZ7.js";import{b as u}from"./chunk-RBSMBO4T.js";import{t as h}from"./chunk-EXC7TCGL.js";import{a as s}from"./chunk-2X65YHU4.js";import{c as p,g as l}from"./chunk-J3R36SGJ.js";import{isValidStellarAddress as m,WithLoggerContext as y}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!m(e.address))throw new Error("Wallet is not a Stellar wallet");return new o(e)}sendTransaction(e){return l(this,null,function*(){var a;s.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=yield this.createTransaction(e);if((a=e.options)!=null&&a.prepareOnly)return s.info("stellarWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let n={},r=yield this.approveTransactionAndWait(t.id,n);return s.info("stellarWallet.sendTransaction.success",{transactionId:t.id,hash:r.hash}),r})}createTransaction(e){return l(this,null,function*(){let{contractId:t,options:n}=e,r;(n==null?void 0:n.signer)==null?r=this.requireSigner().locator():typeof n.signer=="string"?r=n.signer:r=`server:${u(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a;if("transaction"in e)a={type:"serialized-transaction",serializedTransaction:e.transaction,contractId:t};else{let{method:T,memo:d,args:g}=e;a={type:"contract-call",contractId:t,method:T,memo:d!=null?{type:"text",value:d}:void 0,args:g}}let c=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:a,signer:r}});if("error"in c)throw new h(JSON.stringify(c));return c})}};p([y({logger:s,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;export{f as a};
1
+ import{a as i}from"./chunk-LXLDXNTT.js";import{b as u}from"./chunk-RBSMBO4T.js";import{t as h}from"./chunk-EXC7TCGL.js";import{a as s}from"./chunk-SSCPHOS2.js";import{c as p,g as l}from"./chunk-J3R36SGJ.js";import{isValidStellarAddress as m,WithLoggerContext as y}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!m(e.address))throw new Error("Wallet is not a Stellar wallet");return new o(e)}sendTransaction(e){return l(this,null,function*(){var a;s.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=yield this.createTransaction(e);if((a=e.options)!=null&&a.prepareOnly)return s.info("stellarWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let n={},r=yield this.approveTransactionAndWait(t.id,n);return s.info("stellarWallet.sendTransaction.success",{transactionId:t.id,hash:r.hash}),r})}createTransaction(e){return l(this,null,function*(){let{contractId:t,options:n}=e,r;(n==null?void 0:n.signer)==null?r=this.requireSigner().locator():typeof n.signer=="string"?r=n.signer:r=`server:${u(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a;if("transaction"in e)a={type:"serialized-transaction",serializedTransaction:e.transaction,contractId:t};else{let{method:T,memo:d,args:g}=e;a={type:"contract-call",contractId:t,method:T,memo:d!=null?{type:"text",value:d}:void 0,args:g}}let c=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:a,signer:r}});if("error"in c)throw new h(JSON.stringify(c));return c})}};p([y({logger:s,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;export{f as a};
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkD6SLJ5C2cjs = require('./chunk-D6SLJ5C2.cjs');var _chunkNR4PS5NFcjs = require('./chunk-NR4PS5NF.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkP3ZA2ACPcjs = require('./chunk-P3ZA2ACP.cjs');var _chunkJMCNCVQNcjs = require('./chunk-JMCNCVQN.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunkCV5GT7CPcjs = require('./chunk-CV5GT7CP.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f,m,g,b,k,T,N,O,R,A= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,f);_chunk2GKPWQBQcjs.e.call(void 0, this,m);_chunk2GKPWQBQcjs.e.call(void 0, this,g);_chunk2GKPWQBQcjs.e.call(void 0, this,b);_chunk2GKPWQBQcjs.e.call(void 0, this,k);_chunk2GKPWQBQcjs.e.call(void 0, this,T,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,N,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,O);_chunk2GKPWQBQcjs.e.call(void 0, this,R,null);let{chain:t,address:i,owner:c,options:p,alias:h,recovery:l,signers:a,signer:o}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,g,r),this.chain=t,this.address=i,this.owner=c,_chunk2GKPWQBQcjs.f.call(void 0, this,m,p),this.alias=h,_chunk2GKPWQBQcjs.f.call(void 0, this,b,l),_chunk2GKPWQBQcjs.f.call(void 0, this,k,a!=null?a:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,f,o),_chunk2GKPWQBQcjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let e=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:i.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(c){_chunkV5A3FGH2cjs.a.error("wallet.initDeviceSigner.error",{error:c}),_chunk2GKPWQBQcjs.f.call(void 0, this,T,!0);return}let t=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null&&(yield this.initDeviceSigner(),!(_chunk2GKPWQBQcjs.d.call(void 0, this,f)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,T))))try{if(_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===0){let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(e))}else if(_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===1){let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,k)[0]);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(e))}}catch(e){_chunkV5A3FGH2cjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,b).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,k).length,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,b)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,k)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,g)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,m)}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,b)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let i=[t,"usdc",...e!=null?e:[]],c=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getBalance(this.address,{chains:[r],tokens:i});if("error"in c)throw _chunkV5A3FGH2cjs.a.error("wallet.balances.error",{error:c}),new Error(`Failed to get balances for wallet: ${JSON.stringify(c.message)}`);return _chunkV5A3FGH2cjs.a.info("wallet.balances.success"),this.transformBalanceResponse(c,t,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunkV5A3FGH2cjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkV5A3FGH2cjs.a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let i=a=>{var S,v,F,$,D;let o=(S=a.chains)==null?void 0:S[this.chain],u={};return this.chain==="solana"&&o!=null&&"mintHash"in o?u={mintHash:o.mintHash}:this.chain==="stellar"&&o!=null&&"contractId"in o?u={contractId:o.contractId}:o!=null&&"contractAddress"in o&&(u={contractAddress:o.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(v=a.symbol)!=null?v:"",name:(F=a.name)!=null?F:"",amount:($=a.amount)!=null?$:"0",decimals:a.decimals,rawAmount:(D=a.rawAmount)!=null?D:"0"},u)},c=e.find(a=>a.symbol===r),p=e.find(a=>a.symbol==="usdc"),h=e.filter(a=>{var o;return a.symbol!==r&&a.symbol!=="usdc"&&(t==null||t.includes((o=a.symbol)!=null?o:""))}),l=a=>{let o={symbol:a,name:a,amount:"0",decimals:0,rawAmount:"0"},u={};return this.chain==="solana"?u={mintHash:void 0}:this.chain==="stellar"?u={contractId:void 0}:u={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),u)};return{nativeToken:c!=null?i(c):l(r),usdc:p!=null?i(p):l("usdc"),tokens:h.map(i)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getNfts(_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{chain:this.chain,address:this.address}))})}transactions(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e==null?void 0:e.tokens,status:e==null?void 0:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let c=this.resolveChainForEnvironment(),p=ce(e),h=de(r,c),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkT3U46LK3cjs.s)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);_chunkV5A3FGH2cjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,token:h,amount:t},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{})),yield this.preAuthIfNeeded();let a=this.requireSigner(),o;(i==null?void 0:i.signer)==null?o=a.locator():typeof i.signer=="string"?o=i.signer:o=`server:${_chunk3VSFHDFHcjs.b.call(void 0, i.signer,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress}`;let u=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,amount:t,signer:o},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{}),S=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).send(this.walletLocator,h,u);if("message"in S)throw _chunkV5A3FGH2cjs.a.error("wallet.send.error",{error:S}),new (0, _chunkT3U46LK3cjs.t)(`Failed to send token: ${JSON.stringify(S.message)}`);if((i==null?void 0:i.prepareOnly)===!0)return _chunkV5A3FGH2cjs.a.info("wallet.send.prepared",{transactionId:S.id}),{hash:void 0,explorerLink:void 0,transactionId:S.id};let v=yield this.approveTransactionAndWait(S.id);return _chunkV5A3FGH2cjs.a.info("wallet.send.success",{transactionId:S.id,hash:v.hash}),v})}approveTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.requireSigner(),_chunkV5A3FGH2cjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkV5A3FGH2cjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkV5A3FGH2cjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkV5A3FGH2cjs.a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p,h;_chunkV5A3FGH2cjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress}`:e,i=this.signer,c=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,_chunkNR4PS5NFcjs.a.call(void 0, this.chain,c,(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.deviceSignerKeyStorage));try{let l=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:_chunkNX256LAHcjs.a.call(void 0, t),a=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).registerSigner(this.walletLocator,{signer:l,chain:this.chain==="solana"||this.chain==="stellar"?void 0:this.chain});if("error"in a)throw _chunkV5A3FGH2cjs.a.error("wallet.addSigner.error",{error:a}),new Error(`Failed to register signer: ${JSON.stringify(a.message)}`);let o=_chunkD6SLJ5C2cjs.b.call(void 0, a,this.chain);if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in a)||a.transaction==null)throw _chunkV5A3FGH2cjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");let u=a.transaction.id;if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);return r!=null&&r.prepareOnly?(_chunkV5A3FGH2cjs.a.info("wallet.addSigner.prepared",{transactionId:u}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{transactionId:u})):(yield this.approveTransactionAndWait(u),_chunkV5A3FGH2cjs.a.info("wallet.addSigner.success",{transactionId:u}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{status:"success"}))}else{if(!("chains"in a))throw _chunkV5A3FGH2cjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");let u=(h=a.chains)==null?void 0:h[this.chain];if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let S=_chunkD6SLJ5C2cjs.c.call(void 0, a,this.chain);if(r!=null&&r.prepareOnly){let v=(S==null?void 0:S.type)==="signature"?S.id:void 0;return _chunkV5A3FGH2cjs.a.info("wallet.addSigner.prepared",{signatureId:v}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{signatureId:v})}if((S==null?void 0:S.type)==="signature")yield this.approveSignatureAndWait(S.id),_chunkV5A3FGH2cjs.a.info("wallet.addSigner.success",{signatureId:S.id});else{if((u==null?void 0:u.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);_chunkV5A3FGH2cjs.a.info("wallet.addSigner.success")}return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{status:"success"})}}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,f,i)}})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(r)),_chunkV5A3FGH2cjs.a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(i=>i.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){if(e.type==="server"){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return`server:${r}`}return _chunkNX256LAHcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;return((t=(yield this.getSignerState(e)).signer)==null?void 0:t.status)==="success"})}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,T)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p,h,l,a;if(_chunkV5A3FGH2cjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null&&(yield this.initDeviceSigner()),((p=_chunk2GKPWQBQcjs.d.call(void 0, this,f))==null?void 0:p.type)!=="device"){_chunkV5A3FGH2cjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,N)){_chunkV5A3FGH2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=_chunk2GKPWQBQcjs.d.call(void 0, this,f),r=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,N,!0)};if(e.status==="success"){_chunkV5A3FGH2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let t=yield this.getSignerState(e.locator());if(e.status=(h=t.signer)==null?void 0:h.status,t.pendingOperation!=null){let o=_chunk2GKPWQBQcjs.d.call(void 0, this,f),u=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,_chunkNR4PS5NFcjs.a.call(void 0, this.chain,u,(l=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:l.deviceSignerKeyStorage));try{t.pendingOperation.type==="signature"?yield this.approveSignatureAndWait(t.pendingOperation.id):yield this.approveTransactionAndWait(t.pendingOperation.id)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,f,o)}e.status="success",_chunkV5A3FGH2cjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0}),r();return}if(e.status==="success"){_chunkV5A3FGH2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let i=(a=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:a.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required to recover a device signer");let c=yield _chunkYHV3672Rcjs.a.call(void 0, i,this.address);try{yield this.addSigner(c)}catch(o){throw _chunkV5A3FGH2cjs.a.error("wallet.recover.device.error",{error:o}),yield i.deleteKey(this.address),o}_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner({type:"device",locator:c.locator,address:this.address},i)),_chunkV5A3FGH2cjs.a.info("wallet.recover.device.success",{signerLocator:c.locator}),r()})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var c,p;_chunkV5A3FGH2cjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getWallet(this.walletLocator);if("error"in e)throw _chunkV5A3FGH2cjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkV5A3FGH2cjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkT3U46LK3cjs.d)(`Wallet type ${e.type} not supported`);let r=(p=(c=e==null?void 0:e.config)==null?void 0:c.delegatedSigners)!=null?p:[],i=(yield Promise.all(r.map(h=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(h.locator)).signer}catch(l){return null}})))).filter(h=>h!=null);return _chunkV5A3FGH2cjs.a.info("wallet.signers.success",{count:i.length}),i})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,g).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,k).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):_chunk2GKPWQBQcjs.d.call(void 0, this,b).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkD6SLJ5C2cjs = require('./chunk-D6SLJ5C2.cjs');var _chunkUNTAJ7NGcjs = require('./chunk-UNTAJ7NG.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkEXS5WGZOcjs = require('./chunk-EXS5WGZO.cjs');var _chunk2O4B6RLQcjs = require('./chunk-2O4B6RLQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunkVIWV4DQCcjs = require('./chunk-VIWV4DQC.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f,m,g,b,k,T,N,O,R,A= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,f);_chunk2GKPWQBQcjs.e.call(void 0, this,m);_chunk2GKPWQBQcjs.e.call(void 0, this,g);_chunk2GKPWQBQcjs.e.call(void 0, this,b);_chunk2GKPWQBQcjs.e.call(void 0, this,k);_chunk2GKPWQBQcjs.e.call(void 0, this,T,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,N,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,O);_chunk2GKPWQBQcjs.e.call(void 0, this,R,null);let{chain:t,address:i,owner:c,options:p,alias:h,recovery:l,signers:a,signer:o}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,g,r),this.chain=t,this.address=i,this.owner=c,_chunk2GKPWQBQcjs.f.call(void 0, this,m,p),this.alias=h,_chunk2GKPWQBQcjs.f.call(void 0, this,b,l),_chunk2GKPWQBQcjs.f.call(void 0, this,k,a!=null?a:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,f,o),_chunk2GKPWQBQcjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let e=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:i.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(c){_chunk6S3ILDIRcjs.a.error("wallet.initDeviceSigner.error",{error:c}),_chunk2GKPWQBQcjs.f.call(void 0, this,T,!0);return}let t=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null&&(yield this.initDeviceSigner(),!(_chunk2GKPWQBQcjs.d.call(void 0, this,f)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,T))))try{if(_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===0){let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(e))}else if(_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===1){let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,k)[0]);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(e))}}catch(e){_chunk6S3ILDIRcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,b).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,k).length,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,b)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,k)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,g)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,m)}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,b)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let i=[t,"usdc",...e!=null?e:[]],c=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getBalance(this.address,{chains:[r],tokens:i});if("error"in c)throw _chunk6S3ILDIRcjs.a.error("wallet.balances.error",{error:c}),new Error(`Failed to get balances for wallet: ${JSON.stringify(c.message)}`);return _chunk6S3ILDIRcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(c,t,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunk6S3ILDIRcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunk6S3ILDIRcjs.a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let i=a=>{var S,v,F,$,D;let o=(S=a.chains)==null?void 0:S[this.chain],u={};return this.chain==="solana"&&o!=null&&"mintHash"in o?u={mintHash:o.mintHash}:this.chain==="stellar"&&o!=null&&"contractId"in o?u={contractId:o.contractId}:o!=null&&"contractAddress"in o&&(u={contractAddress:o.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(v=a.symbol)!=null?v:"",name:(F=a.name)!=null?F:"",amount:($=a.amount)!=null?$:"0",decimals:a.decimals,rawAmount:(D=a.rawAmount)!=null?D:"0"},u)},c=e.find(a=>a.symbol===r),p=e.find(a=>a.symbol==="usdc"),h=e.filter(a=>{var o;return a.symbol!==r&&a.symbol!=="usdc"&&(t==null||t.includes((o=a.symbol)!=null?o:""))}),l=a=>{let o={symbol:a,name:a,amount:"0",decimals:0,rawAmount:"0"},u={};return this.chain==="solana"?u={mintHash:void 0}:this.chain==="stellar"?u={contractId:void 0}:u={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),u)};return{nativeToken:c!=null?i(c):l(r),usdc:p!=null?i(p):l("usdc"),tokens:h.map(i)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getNfts(_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{chain:this.chain,address:this.address}))})}transactions(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e==null?void 0:e.tokens,status:e==null?void 0:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let c=this.resolveChainForEnvironment(),p=ce(e),h=de(r,c),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkT3U46LK3cjs.s)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);_chunk6S3ILDIRcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,token:h,amount:t},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{})),yield this.preAuthIfNeeded();let a=this.requireSigner(),o;(i==null?void 0:i.signer)==null?o=a.locator():typeof i.signer=="string"?o=i.signer:o=`server:${_chunk3VSFHDFHcjs.b.call(void 0, i.signer,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress}`;let u=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,amount:t,signer:o},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{}),S=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).send(this.walletLocator,h,u);if("message"in S)throw _chunk6S3ILDIRcjs.a.error("wallet.send.error",{error:S}),new (0, _chunkT3U46LK3cjs.t)(`Failed to send token: ${JSON.stringify(S.message)}`);if((i==null?void 0:i.prepareOnly)===!0)return _chunk6S3ILDIRcjs.a.info("wallet.send.prepared",{transactionId:S.id}),{hash:void 0,explorerLink:void 0,transactionId:S.id};let v=yield this.approveTransactionAndWait(S.id);return _chunk6S3ILDIRcjs.a.info("wallet.send.success",{transactionId:S.id,hash:v.hash}),v})}approveTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.requireSigner(),_chunk6S3ILDIRcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunk6S3ILDIRcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunk6S3ILDIRcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunk6S3ILDIRcjs.a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p,h;_chunk6S3ILDIRcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress}`:e,i=this.signer,c=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,_chunkUNTAJ7NGcjs.a.call(void 0, this.chain,c,(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.deviceSignerKeyStorage));try{let l=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:_chunkNX256LAHcjs.a.call(void 0, t),a=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).registerSigner(this.walletLocator,{signer:l,chain:this.chain==="solana"||this.chain==="stellar"?void 0:this.chain});if("error"in a)throw _chunk6S3ILDIRcjs.a.error("wallet.addSigner.error",{error:a}),new Error(`Failed to register signer: ${JSON.stringify(a.message)}`);let o=_chunkD6SLJ5C2cjs.b.call(void 0, a,this.chain);if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in a)||a.transaction==null)throw _chunk6S3ILDIRcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");let u=a.transaction.id;if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);return r!=null&&r.prepareOnly?(_chunk6S3ILDIRcjs.a.info("wallet.addSigner.prepared",{transactionId:u}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{transactionId:u})):(yield this.approveTransactionAndWait(u),_chunk6S3ILDIRcjs.a.info("wallet.addSigner.success",{transactionId:u}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{status:"success"}))}else{if(!("chains"in a))throw _chunk6S3ILDIRcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");let u=(h=a.chains)==null?void 0:h[this.chain];if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let S=_chunkD6SLJ5C2cjs.c.call(void 0, a,this.chain);if(r!=null&&r.prepareOnly){let v=(S==null?void 0:S.type)==="signature"?S.id:void 0;return _chunk6S3ILDIRcjs.a.info("wallet.addSigner.prepared",{signatureId:v}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{signatureId:v})}if((S==null?void 0:S.type)==="signature")yield this.approveSignatureAndWait(S.id),_chunk6S3ILDIRcjs.a.info("wallet.addSigner.success",{signatureId:S.id});else{if((u==null?void 0:u.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);_chunk6S3ILDIRcjs.a.info("wallet.addSigner.success")}return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},o),{status:"success"})}}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,f,i)}})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner(r)),_chunk6S3ILDIRcjs.a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(i=>i.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){if(e.type==="server"){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return`server:${r}`}return _chunkNX256LAHcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;return((t=(yield this.getSignerState(e)).signer)==null?void 0:t.status)==="success"})}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,T)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p,h,l,a;if(_chunk6S3ILDIRcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null&&(yield this.initDeviceSigner()),((p=_chunk2GKPWQBQcjs.d.call(void 0, this,f))==null?void 0:p.type)!=="device"){_chunk6S3ILDIRcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,N)){_chunk6S3ILDIRcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=_chunk2GKPWQBQcjs.d.call(void 0, this,f),r=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,T,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,N,!0)};if(e.status==="success"){_chunk6S3ILDIRcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let t=yield this.getSignerState(e.locator());if(e.status=(h=t.signer)==null?void 0:h.status,t.pendingOperation!=null){let o=_chunk2GKPWQBQcjs.d.call(void 0, this,f),u=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,b));_chunk2GKPWQBQcjs.f.call(void 0, this,f,_chunkUNTAJ7NGcjs.a.call(void 0, this.chain,u,(l=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:l.deviceSignerKeyStorage));try{t.pendingOperation.type==="signature"?yield this.approveSignatureAndWait(t.pendingOperation.id):yield this.approveTransactionAndWait(t.pendingOperation.id)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,f,o)}e.status="success",_chunk6S3ILDIRcjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0}),r();return}if(e.status==="success"){_chunk6S3ILDIRcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let i=(a=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:a.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required to recover a device signer");let c=yield _chunkYHV3672Rcjs.a.call(void 0, i,this.address);try{yield this.addSigner(c)}catch(o){throw _chunk6S3ILDIRcjs.a.error("wallet.recover.device.error",{error:o}),yield i.deleteKey(this.address),o}_chunk2GKPWQBQcjs.f.call(void 0, this,f,yield this.assembleFullSigner({type:"device",locator:c.locator,address:this.address},i)),_chunk6S3ILDIRcjs.a.info("wallet.recover.device.success",{signerLocator:c.locator}),r()})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var c,p;_chunk6S3ILDIRcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getWallet(this.walletLocator);if("error"in e)throw _chunk6S3ILDIRcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunk6S3ILDIRcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkT3U46LK3cjs.d)(`Wallet type ${e.type} not supported`);let r=(p=(c=e==null?void 0:e.config)==null?void 0:c.delegatedSigners)!=null?p:[],i=(yield Promise.all(r.map(h=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(h.locator)).signer}catch(l){return null}})))).filter(h=>h!=null);return _chunk6S3ILDIRcjs.a.info("wallet.signers.success",{count:i.length}),i})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,g).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,k).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):_chunk2GKPWQBQcjs.d.call(void 0, this,b).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
2
  Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):_chunk2GKPWQBQcjs.d.call(void 0, this,b).type==="external-wallet"?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
- Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,O),_chunk2GKPWQBQcjs.d.call(void 0, this,R)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,R,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,R)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,R,null)}let e=this.requireSigner();e instanceof _chunkP3ZA2ACPcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,b);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress,i=_chunk3VSFHDFHcjs.b.call(void 0, r,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress;return t===i}return _chunkNX256LAHcjs.a.call(void 0, e)===_chunkNX256LAHcjs.a.call(void 0, r)}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p;let r=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let c=(yield this.signers()).filter(h=>h.locator.startsWith("device:"));for(let h of c){let l=h.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=h.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,T,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,N,!1)})}assembleFullSigner(i){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(t=>(t=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:t.deviceSignerKeyStorage)()){var h;let c=_chunkNR4PS5NFcjs.a.call(void 0, this.chain,e,r),p=yield this.getSignerState(c.locator());return c.status=(h=p.signer)==null?void 0:h.status,c})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSigner(this.walletLocator,e)}catch(i){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=_chunkD6SLJ5C2cjs.b.call(void 0, r,this.chain);return{response:r,signer:t,pendingOperation:_chunkD6SLJ5C2cjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,t,i,c,p,h;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,g).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:r.clientTEEConnection,onAuthRequired:(i=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:t.callbacks)==null?void 0:i.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,g).crossmint,clientTEEConnection:(c=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:c.clientTEEConnection,onAuthRequired:(h=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.callbacks)==null?void 0:h.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:a}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${a}`,address:a}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkJMCNCVQNcjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,a;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSignature(this.walletLocator,e);if("error"in i)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(i));if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let o=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,o)}let c=(l=i.approvals)==null?void 0:l.pending;if(c==null)return i;let p=[...(a=r==null?void 0:r.additionalSigners)!=null?a:[],t],h=yield Promise.all(c.map(o=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let u=p.find(v=>v.locator()===o.signer.locator);if(u==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${o.signer.locator} not found in pending approvals`);let S=yield u.signMessage(o.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},S),{signer:u.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,h)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,a,o,u,S;let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e);if("error"in t)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(t));yield(o=(a=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:l.callbacks)==null?void 0:a.onTransactionStart)==null?void 0:o.call(a);let i=this.requireSigner();if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let v=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,v)}let c=(u=t.approvals)==null?void 0:u.pending;if(c==null)return t;let p=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],i],h=yield Promise.all(c.map(v=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let F=p.find(le=>le.locator()===v.signer.locator);if(F==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${v.signer.locator} not found in pending approvals`);let $=F.type==="device",D=t.chainType==="solana"&&"transaction"in t.onChain&&!$?t.onChain.transaction:v.message,oe=yield F.signTransaction(D);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},oe),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,h)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.z)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.r)(JSON.stringify(t));return t})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,_chunkCV5GT7CPcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkT3U46LK3cjs.n)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkT3U46LK3cjs.q)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(p){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:i=2e3,initialBackoffMs:c=_chunkCV5GT7CPcjs.d}={}){var u,S;_chunkV5A3FGH2cjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let h=Date.now(),l;do{if(Date.now()-h>r)throw new (0, _chunkT3U46LK3cjs.v)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(l));yield this.sleep(c),c=Math.min(c*t,i)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkT3U46LK3cjs.w)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkT3U46LK3cjs.x)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let a="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,o=(u=l.onChain.txId)!=null?u:a;if(o==null)throw new (0, _chunkT3U46LK3cjs.y)("Transaction hash not found on transaction response");return{hash:o,explorerLink:(S=l.onChain.explorerLink)!=null?S:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};f=new WeakMap,m=new WeakMap,g=new WeakMap,b=new WeakMap,k=new WeakMap,T=new WeakMap,N=new WeakMap,O=new WeakMap,R=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function ce(y){if(typeof y=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, y))throw new (0, _chunkT3U46LK3cjs.B)(`Invalid recipient address: "${y}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return y}if("email"in y)return`email:${y.email}`;if("x"in y)return`x:${y.x}`;if("twitter"in y)return`twitter:${y.twitter}`;if("phone"in y)return`phoneNumber:${y.phone}`;if("userId"in y)return`userId:${y.userId}`;throw new Error("Invalid recipient locator")}function de(y,e){return _commonsdkbase.isValidAddress.call(void 0, y)?`${e}:${y}`:`${e}:${y.toLowerCase()}`}exports.a = A;
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,O),_chunk2GKPWQBQcjs.d.call(void 0, this,R)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,R,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,R)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,R,null)}let e=this.requireSigner();e instanceof _chunkEXS5WGZOcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,b);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress,i=_chunk3VSFHDFHcjs.b.call(void 0, r,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment).derivedAddress;return t===i}return _chunkNX256LAHcjs.a.call(void 0, e)===_chunkNX256LAHcjs.a.call(void 0, r)}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p;let r=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let c=(yield this.signers()).filter(h=>h.locator.startsWith("device:"));for(let h of c){let l=h.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=h.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,T,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,N,!1)})}assembleFullSigner(i){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(t=>(t=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:t.deviceSignerKeyStorage)()){var h;let c=_chunkUNTAJ7NGcjs.a.call(void 0, this.chain,e,r),p=yield this.getSignerState(c.locator());return c.status=(h=p.signer)==null?void 0:h.status,c})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSigner(this.walletLocator,e)}catch(i){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=_chunkD6SLJ5C2cjs.b.call(void 0, r,this.chain);return{response:r,signer:t,pendingOperation:_chunkD6SLJ5C2cjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,t,i,c,p,h;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,g).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:r.clientTEEConnection,onAuthRequired:(i=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:t.callbacks)==null?void 0:i.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,g).crossmint,clientTEEConnection:(c=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:c.clientTEEConnection,onAuthRequired:(h=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:p.callbacks)==null?void 0:h.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:a}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${a}`,address:a}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunk2O4B6RLQcjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,g).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,a;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSignature(this.walletLocator,e);if("error"in i)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(i));if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let o=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,o)}let c=(l=i.approvals)==null?void 0:l.pending;if(c==null)return i;let p=[...(a=r==null?void 0:r.additionalSigners)!=null?a:[],t],h=yield Promise.all(c.map(o=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let u=p.find(v=>v.locator()===o.signer.locator);if(u==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${o.signer.locator} not found in pending approvals`);let S=yield u.signMessage(o.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},S),{signer:u.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,h)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,a,o,u,S;let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e);if("error"in t)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(t));yield(o=(a=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,m))==null?void 0:l.callbacks)==null?void 0:a.onTransactionStart)==null?void 0:o.call(a);let i=this.requireSigner();if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let v=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,v)}let c=(u=t.approvals)==null?void 0:u.pending;if(c==null)return t;let p=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],i],h=yield Promise.all(c.map(v=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let F=p.find(le=>le.locator()===v.signer.locator);if(F==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${v.signer.locator} not found in pending approvals`);let $=F.type==="device",D=t.chainType==="solana"&&"transaction"in t.onChain&&!$?t.onChain.transaction:v.message,oe=yield F.signTransaction(D);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},oe),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,h)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.z)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.r)(JSON.stringify(t));return t})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,_chunkVIWV4DQCcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkT3U46LK3cjs.n)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkT3U46LK3cjs.q)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(p){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:i=2e3,initialBackoffMs:c=_chunkVIWV4DQCcjs.d}={}){var u,S;_chunk6S3ILDIRcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let h=Date.now(),l;do{if(Date.now()-h>r)throw new (0, _chunkT3U46LK3cjs.v)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,g).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(l));yield this.sleep(c),c=Math.min(c*t,i)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkT3U46LK3cjs.w)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkT3U46LK3cjs.x)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let a="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,o=(u=l.onChain.txId)!=null?u:a;if(o==null)throw new (0, _chunkT3U46LK3cjs.y)("Transaction hash not found on transaction response");return{hash:o,explorerLink:(S=l.onChain.explorerLink)!=null?S:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};f=new WeakMap,m=new WeakMap,g=new WeakMap,b=new WeakMap,k=new WeakMap,T=new WeakMap,N=new WeakMap,O=new WeakMap,R=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function ce(y){if(typeof y=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, y))throw new (0, _chunkT3U46LK3cjs.B)(`Invalid recipient address: "${y}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return y}if("email"in y)return`email:${y.email}`;if("x"in y)return`x:${y.x}`;if("twitter"in y)return`twitter:${y.twitter}`;if("phone"in y)return`phoneNumber:${y.phone}`;if("userId"in y)return`userId:${y.userId}`;throw new Error("Invalid recipient locator")}function de(y,e){return _commonsdkbase.isValidAddress.call(void 0, y)?`${e}:${y}`:`${e}:${y.toLowerCase()}`}exports.a = A;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCV5GT7CPcjs = require('./chunk-CV5GT7CP.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkCV5GT7CPcjs.c,packageVersion:_chunkCV5GT7CPcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVIWV4DQCcjs = require('./chunk-VIWV4DQC.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkVIWV4DQCcjs.c,packageVersion:_chunkVIWV4DQCcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunkCV5GT7CPcjs = require('./chunk-CV5GT7CP.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkCV5GT7CPcjs.c,version:_chunkCV5GT7CPcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkV5A3FGH2cjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?_chunkV5A3FGH2cjs.a.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&_chunkV5A3FGH2cjs.a.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkV5A3FGH2cjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkV5A3FGH2cjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkV5A3FGH2cjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkV5A3FGH2cjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunkVIWV4DQCcjs = require('./chunk-VIWV4DQC.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkVIWV4DQCcjs.c,version:_chunkVIWV4DQCcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunk6S3ILDIRcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?_chunk6S3ILDIRcjs.a.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&_chunk6S3ILDIRcjs.a.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunk6S3ILDIRcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunk6S3ILDIRcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunk6S3ILDIRcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunk6S3ILDIRcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = c;
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.0.1";var c="WALLETS_SDK",r=t,a=s,d=500;export{c as a,r as b,a as c,d};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunk5QIW67NUcjs = require('./chunk-5QIW67NU.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.info("TEE connection not initialized, initializing now");let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkV5A3FGH2cjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let r=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 */ }`);_chunkV5A3FGH2cjs.a.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),i=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw _chunkV5A3FGH2cjs.a.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:i}),new Error(n==null?void 0:n.error);if(_chunkV5A3FGH2cjs.a.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:i}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkV5A3FGH2cjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkV5A3FGH2cjs.a.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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunk5QIW67NUcjs.a)})),c(new _chunk5QIW67NUcjs.a)}))}catch(e){_chunkV5A3FGH2cjs.a.error("handleAuthRequired error",{error:e}),c(e)}try{yield s}catch(e){throw _chunkV5A3FGH2cjs.a.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((i,s)=>{r=i,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();_chunkV5A3FGH2cjs.a.info("start-onboarding: sending request");let n=Date.now(),i=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(_chunkV5A3FGH2cjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:s}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}(i==null?void 0:i.status)==="error"&&(_chunkV5A3FGH2cjs.a.error("start-onboarding: failed",{error:i.error}),(c=this._authPromise)==null||c.reject(new Error(i.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,h,c,u;let t;try{let e=yield this.getTEEConnection();_chunkV5A3FGH2cjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:r}}},options:d}),_chunkV5A3FGH2cjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw _chunkV5A3FGH2cjs.a.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(e),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 _chunk5QIW67NUcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunkV5A3FGH2cjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",i=new Error(n);throw(u=this._authPromise)==null||u.reject(i),i})}_exportPrivateKey(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:i}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:i}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunk5QIW67NUcjs = require('./chunk-5QIW67NU.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.info("TEE connection not initialized, initializing now");let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunk6S3ILDIRcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let r=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 */ }`);_chunk6S3ILDIRcjs.a.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),i=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw _chunk6S3ILDIRcjs.a.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:i}),new Error(n==null?void 0:n.error);if(_chunk6S3ILDIRcjs.a.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:i}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunk6S3ILDIRcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6S3ILDIRcjs.a.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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunk5QIW67NUcjs.a)})),c(new _chunk5QIW67NUcjs.a)}))}catch(e){_chunk6S3ILDIRcjs.a.error("handleAuthRequired error",{error:e}),c(e)}try{yield s}catch(e){throw _chunk6S3ILDIRcjs.a.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((i,s)=>{r=i,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();_chunk6S3ILDIRcjs.a.info("start-onboarding: sending request");let n=Date.now(),i=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(_chunk6S3ILDIRcjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:s}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}(i==null?void 0:i.status)==="error"&&(_chunk6S3ILDIRcjs.a.error("start-onboarding: failed",{error:i.error}),(c=this._authPromise)==null||c.reject(new Error(i.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,h,c,u;let t;try{let e=yield this.getTEEConnection();_chunk6S3ILDIRcjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:r}}},options:d}),_chunk6S3ILDIRcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw _chunk6S3ILDIRcjs.a.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(e),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 _chunk5QIW67NUcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunk6S3ILDIRcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",i=new Error(n);throw(u=this._authPromise)==null||u.reject(i),i})}_exportPrivateKey(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:i}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:i}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-SG4NRUNV.js";import{a as r}from"./chunk-2X65YHU4.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-MO5OIRRN.js";import{a as r}from"./chunk-SSCPHOS2.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5Z6QHCTTcjs = require('./chunk-5Z6QHCTT.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkJMCNCVQNcjs = require('./chunk-JMCNCVQN.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var d=class d extends _chunk5Z6QHCTTcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk5Z6QHCTTcjs.a.getOptions(e),alias:e.alias,recovery:_chunk5Z6QHCTTcjs.a.getRecovery(e),signer:e.signer,signers:_chunk5Z6QHCTTcjs.a.getInitialSigners(e)},_chunk5Z6QHCTTcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new d(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkV5A3FGH2cjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkV5A3FGH2cjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunkV5A3FGH2cjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkV5A3FGH2cjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw _chunkV5A3FGH2cjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkV5A3FGH2cjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkV5A3FGH2cjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var I;_chunkV5A3FGH2cjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:c,chain:m}=e;if(!t||!a||!c||!m)throw _chunkV5A3FGH2cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data");let{name:T,version:f,chainId:y,verifyingContract:v,salt:D}=t;if(!T||!f||!y||!v)throw _chunkV5A3FGH2cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data domain");let s=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:T,version:f,chainId:Number(y),verifyingContract:v,salt:D},message:a,primaryType:i,types:c},signer:n.locator(),chain:m}});if("error"in s)throw _chunkV5A3FGH2cjs.a.error("evmWallet.signTypedData.error",{error:s}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(s));if((I=e.options)!=null&&I.prepareOnly)return _chunkV5A3FGH2cjs.a.info("evmWallet.signTypedData.prepared",{signatureId:s.id}),{signature:void 0,signatureId:s.id};let M=yield this.approveSignatureAndWait(s.id);return _chunkV5A3FGH2cjs.a.info("evmWallet.signTypedData.success",{signatureId:s.id}),M})}getViemClient(e){var n;return _viem.createPublicClient.call(void 0, {transport:(n=e==null?void 0:e.transport)!=null?n:_viem.http.call(void 0, ),chain:_chunkJMCNCVQNcjs.a.call(void 0, this.chain)})}createTransaction(e,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,c;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(c=(i=e.value)==null?void 0:i.toString())!=null?c:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkV5A3FGH2cjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signTypedData",1);var W=d;exports.a = W;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4NS5CXOGcjs = require('./chunk-4NS5CXOG.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk2O4B6RLQcjs = require('./chunk-2O4B6RLQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var d=class d extends _chunk4NS5CXOGcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk4NS5CXOGcjs.a.getOptions(e),alias:e.alias,recovery:_chunk4NS5CXOGcjs.a.getRecovery(e),signer:e.signer,signers:_chunk4NS5CXOGcjs.a.getInitialSigners(e)},_chunk4NS5CXOGcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new d(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunk6S3ILDIRcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunk6S3ILDIRcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunk6S3ILDIRcjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunk6S3ILDIRcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw _chunk6S3ILDIRcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunk6S3ILDIRcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunk6S3ILDIRcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var I;_chunk6S3ILDIRcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:c,chain:m}=e;if(!t||!a||!c||!m)throw _chunk6S3ILDIRcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data");let{name:T,version:f,chainId:y,verifyingContract:v,salt:D}=t;if(!T||!f||!y||!v)throw _chunk6S3ILDIRcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data domain");let s=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:T,version:f,chainId:Number(y),verifyingContract:v,salt:D},message:a,primaryType:i,types:c},signer:n.locator(),chain:m}});if("error"in s)throw _chunk6S3ILDIRcjs.a.error("evmWallet.signTypedData.error",{error:s}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(s));if((I=e.options)!=null&&I.prepareOnly)return _chunk6S3ILDIRcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:s.id}),{signature:void 0,signatureId:s.id};let M=yield this.approveSignatureAndWait(s.id);return _chunk6S3ILDIRcjs.a.info("evmWallet.signTypedData.success",{signatureId:s.id}),M})}getViemClient(e){var n;return _viem.createPublicClient.call(void 0, {transport:(n=e==null?void 0:e.transport)!=null?n:_viem.http.call(void 0, ),chain:_chunk2O4B6RLQcjs.a.call(void 0, this.chain)})}createTransaction(e,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,c;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(c=(i=e.value)==null?void 0:i.toString())!=null?c:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6S3ILDIRcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signTypedData",1);var W=d;exports.a = W;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkP3ZA2ACPcjs = require('./chunk-P3ZA2ACP.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkP3ZA2ACPcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkV5A3FGH2cjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkP3ZA2ACPcjs.b});if(_chunkV5A3FGH2cjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkEXS5WGZOcjs = require('./chunk-EXS5WGZO.cjs');var _chunk6S3ILDIRcjs = require('./chunk-6S3ILDIR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkEXS5WGZOcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunk6S3ILDIRcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkEXS5WGZOcjs.b});if(_chunk6S3ILDIRcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;