@crossmint/wallets-sdk 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) 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/gen/types.gen.d.cts +66 -22
  6. package/dist/api/gen/types.gen.d.ts +66 -22
  7. package/dist/api/index.cjs +1 -1
  8. package/dist/api/index.js +1 -1
  9. package/dist/chains/adapters/evm.cjs +1 -1
  10. package/dist/chains/adapters/evm.js +1 -1
  11. package/dist/chains/adapters/solana.cjs +1 -1
  12. package/dist/chains/adapters/solana.js +1 -1
  13. package/dist/chains/adapters/stellar.cjs +1 -1
  14. package/dist/chains/adapters/stellar.js +1 -1
  15. package/dist/chains/chain-adapter.cjs +1 -1
  16. package/dist/chains/chain-adapter.js +1 -1
  17. package/dist/chains/chains.cjs +1 -1
  18. package/dist/chains/chains.d.cts +2 -2
  19. package/dist/chains/chains.d.ts +2 -2
  20. package/dist/chains/chains.js +1 -1
  21. package/dist/chains/definitions/arc.cjs +1 -0
  22. package/dist/chains/definitions/arc.d.cts +44 -0
  23. package/dist/chains/definitions/arc.d.ts +44 -0
  24. package/dist/chains/definitions/arc.js +1 -0
  25. package/dist/chains/definitions/celoSepolia.cjs +1 -0
  26. package/dist/chains/definitions/celoSepolia.d.cts +44 -0
  27. package/dist/chains/definitions/celoSepolia.d.ts +44 -0
  28. package/dist/chains/definitions/celoSepolia.js +1 -0
  29. package/dist/chains/definitions/robinhoodChain.cjs +1 -0
  30. package/dist/chains/definitions/robinhoodChain.d.cts +44 -0
  31. package/dist/chains/definitions/robinhoodChain.d.ts +44 -0
  32. package/dist/chains/definitions/robinhoodChain.js +1 -0
  33. package/dist/chains/definitions/robinhoodChainTestnet.cjs +1 -0
  34. package/dist/chains/definitions/robinhoodChainTestnet.d.cts +44 -0
  35. package/dist/chains/definitions/robinhoodChainTestnet.d.ts +44 -0
  36. package/dist/chains/definitions/robinhoodChainTestnet.js +1 -0
  37. package/dist/{chunk-I76IKSS4.js → chunk-24CGMAY3.js} +1 -1
  38. package/dist/{chunk-MXY4ZKZJ.cjs → chunk-2G4Y25AJ.cjs} +1 -1
  39. package/dist/{chunk-P22QL24A.js → chunk-4KOHNUNP.js} +1 -1
  40. package/dist/{chunk-N3HRM33G.cjs → chunk-4R2UUYLC.cjs} +1 -1
  41. package/dist/{chunk-CEP5E7JG.cjs → chunk-53VKI7FJ.cjs} +1 -1
  42. package/dist/{chunk-YFRKZGZ4.js → chunk-5IC6BHP5.js} +1 -1
  43. package/dist/{chunk-YJLJ2IHS.cjs → chunk-5L5MJAFS.cjs} +1 -1
  44. package/dist/{chunk-2VMMA4Y6.cjs → chunk-5SREMYFJ.cjs} +1 -1
  45. package/dist/{chunk-6OUANX4J.js → chunk-62EHAJRH.js} +1 -1
  46. package/dist/{chunk-QP5JU7UO.cjs → chunk-62XSK3ZX.cjs} +1 -1
  47. package/dist/{chunk-3L3U3TID.cjs → chunk-63VNTHGQ.cjs} +1 -1
  48. package/dist/{chunk-MFCNJSCL.js → chunk-66IZJXGV.js} +1 -1
  49. package/dist/{chunk-NYGW4HYK.js → chunk-6T4GBLXY.js} +1 -1
  50. package/dist/{chunk-OVUX5RFT.js → chunk-7CUHY3S4.js} +1 -1
  51. package/dist/{chunk-JMVDYHTG.cjs → chunk-7HOXBHKP.cjs} +1 -1
  52. package/dist/{chunk-S6MOVJXB.js → chunk-A7DA5DSE.js} +1 -1
  53. package/dist/chunk-AUO6R32H.cjs +1 -0
  54. package/dist/{chunk-JNGPW247.js → chunk-AZAIXRGS.js} +1 -1
  55. package/dist/chunk-BHHXVRU6.cjs +1 -0
  56. package/dist/{chunk-WEWCIFFY.js → chunk-BHSOWQOR.js} +1 -1
  57. package/dist/{chunk-IZVYNUFO.cjs → chunk-BJC5DQQ3.cjs} +1 -1
  58. package/dist/{chunk-EH75GTUJ.js → chunk-BKN5HSDC.js} +1 -1
  59. package/dist/{chunk-K55HJTOE.js → chunk-BL7A7ROX.js} +1 -1
  60. package/dist/chunk-C6E6WC4P.js +1 -0
  61. package/dist/chunk-CGQCRDG7.js +1 -0
  62. package/dist/{chunk-Q3JQUVKI.js → chunk-CXWFJGKI.js} +1 -1
  63. package/dist/{chunk-VPDZLVMK.cjs → chunk-D2QNNQ26.cjs} +1 -1
  64. package/dist/chunk-D5IIHIEW.cjs +1 -0
  65. package/dist/{chunk-GAACIEE2.cjs → chunk-DB3TFNM2.cjs} +1 -1
  66. package/dist/{chunk-BEGVH4DX.js → chunk-FBOM4U3X.js} +1 -1
  67. package/dist/chunk-FUZ2TPGD.js +1 -0
  68. package/dist/{chunk-W7IPXUD5.cjs → chunk-IU7J7IPE.cjs} +1 -1
  69. package/dist/{chunk-RMILQMLJ.cjs → chunk-JAWHGOGP.cjs} +1 -1
  70. package/dist/{chunk-4IIZO5PI.cjs → chunk-KQFRFHM4.cjs} +1 -1
  71. package/dist/{chunk-4I5SLLAX.cjs → chunk-KVMPBMNG.cjs} +1 -1
  72. package/dist/{chunk-L7RATGRO.js → chunk-LUUUKDHQ.js} +1 -1
  73. package/dist/chunk-NMUHOXYI.js +1 -0
  74. package/dist/{chunk-RNQMEZIV.js → chunk-NQ3PROUV.js} +1 -1
  75. package/dist/chunk-OQFZL5LI.cjs +1 -0
  76. package/dist/{chunk-W4DR7B3L.cjs → chunk-Q6UT242Q.cjs} +1 -1
  77. package/dist/chunk-QLOW4D2N.js +1 -0
  78. package/dist/{chunk-IXNKZURT.js → chunk-QNM7BGTP.js} +1 -1
  79. package/dist/chunk-QYNWUGXV.js +1 -0
  80. package/dist/{chunk-YHCEO3GD.cjs → chunk-SDXHKREB.cjs} +1 -1
  81. package/dist/{chunk-WIAIJCQ2.cjs → chunk-SP5DQZ6D.cjs} +1 -1
  82. package/dist/chunk-TCDH5Q6Q.cjs +1 -0
  83. package/dist/{chunk-GD5GDQXC.js → chunk-UP6VFZQH.js} +1 -1
  84. package/dist/{chunk-O2BU2KJD.cjs → chunk-UX2FEVDY.cjs} +1 -1
  85. package/dist/{chunk-KYR4ZYRD.js → chunk-V3LZ3MNU.js} +1 -1
  86. package/dist/chunk-V5NY4W5H.js +1 -0
  87. package/dist/{chunk-6KW2HYAX.js → chunk-WJDR3MG5.js} +1 -1
  88. package/dist/{chunk-3TPBVNNF.cjs → chunk-XFCHACH7.cjs} +1 -1
  89. package/dist/{chunk-HOQ2JQHJ.cjs → chunk-Y7P2T5BP.cjs} +1 -1
  90. package/dist/{chunk-IX4EJZH5.js → chunk-YFNCXOVW.js} +1 -1
  91. package/dist/{chunk-4MNSKZHW.cjs → chunk-YWN6HKW7.cjs} +1 -1
  92. package/dist/{chunk-BSZJJNA7.js → chunk-Z4ZDZYZ3.js} +1 -1
  93. package/dist/{chunk-3TJEBF5U.cjs → chunk-ZHGXG7JM.cjs} +1 -1
  94. package/dist/chunk-ZPO3XSWU.cjs +1 -0
  95. package/dist/{chunk-GVRXRDGC.js → chunk-ZSFPKH2C.js} +1 -1
  96. package/dist/{chunk-4L7JP2WL.cjs → chunk-ZUG5ROPF.cjs} +1 -1
  97. package/dist/index.cjs +1 -1
  98. package/dist/index.js +1 -1
  99. package/dist/logger/index.cjs +1 -1
  100. package/dist/logger/index.js +1 -1
  101. package/dist/logger/init.cjs +1 -1
  102. package/dist/logger/init.js +1 -1
  103. package/dist/sdk.cjs +1 -1
  104. package/dist/sdk.js +1 -1
  105. package/dist/signers/descriptors/index.cjs +1 -1
  106. package/dist/signers/descriptors/index.js +1 -1
  107. package/dist/signers/index.cjs +1 -1
  108. package/dist/signers/index.js +1 -1
  109. package/dist/signers/non-custodial/index.cjs +1 -1
  110. package/dist/signers/non-custodial/index.js +1 -1
  111. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  112. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  113. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  114. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  115. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  116. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  117. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  118. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  119. package/dist/signers/server/assemble-server-signer.cjs +1 -1
  120. package/dist/signers/server/assemble-server-signer.js +1 -1
  121. package/dist/signers/server/index.cjs +1 -1
  122. package/dist/signers/server/index.js +1 -1
  123. package/dist/signers/server/resolver.cjs +1 -1
  124. package/dist/signers/server/resolver.js +1 -1
  125. package/dist/utils/constants.cjs +1 -1
  126. package/dist/utils/constants.js +1 -1
  127. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  128. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  129. package/dist/utils/device-signers/index.cjs +1 -1
  130. package/dist/utils/device-signers/index.js +1 -1
  131. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  132. package/dist/wallets/__tests__/test-helpers.js +1 -1
  133. package/dist/wallets/evm.cjs +1 -1
  134. package/dist/wallets/evm.js +1 -1
  135. package/dist/wallets/services/balance-formatter.cjs +1 -1
  136. package/dist/wallets/services/balance-formatter.js +1 -1
  137. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  138. package/dist/wallets/services/device-recovery-service.js +1 -1
  139. package/dist/wallets/services/operation-poller.cjs +1 -1
  140. package/dist/wallets/services/operation-poller.js +1 -1
  141. package/dist/wallets/services/signer-manager.cjs +1 -1
  142. package/dist/wallets/services/signer-manager.js +1 -1
  143. package/dist/wallets/solana.cjs +1 -1
  144. package/dist/wallets/solana.js +1 -1
  145. package/dist/wallets/stellar.cjs +1 -1
  146. package/dist/wallets/stellar.js +1 -1
  147. package/dist/wallets/wallet-factory.cjs +1 -1
  148. package/dist/wallets/wallet-factory.js +1 -1
  149. package/dist/wallets/wallet.cjs +1 -1
  150. package/dist/wallets/wallet.js +1 -1
  151. package/package.json +4 -4
  152. package/dist/chunk-BXEH6VXA.js +0 -1
  153. package/dist/chunk-CTCUJBU2.js +0 -1
  154. package/dist/chunk-D6BFMPZA.cjs +0 -1
  155. package/dist/chunk-QU5AAJAW.js +0 -1
  156. package/dist/chunk-ZEGNY3K3.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkW7IPXUD5cjs = require('./chunk-W7IPXUD5.cjs');var _chunkGAACIEE2cjs = require('./chunk-GAACIEE2.cjs');var _chunkIZVYNUFOcjs = require('./chunk-IZVYNUFO.cjs');var _chunkJMVDYHTGcjs = require('./chunk-JMVDYHTG.cjs');var _chunkU5DLRN5Ucjs = require('./chunk-U5DLRN5U.cjs');var _chunk4MNSKZHWcjs = require('./chunk-4MNSKZHW.cjs');var _chunkCZC2MNVKcjs = require('./chunk-CZC2MNVK.cjs');var _chunkR2XC4F3Mcjs = require('./chunk-R2XC4F3M.cjs');var _chunk3TJEBF5Ucjs = require('./chunk-3TJEBF5U.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkD6BFMPZAcjs = require('./chunk-D6BFMPZA.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkZEGNY3K3cjs = require('./chunk-ZEGNY3K3.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var N,p,b,x,l,f,I,O,W,m,ve,fe,U,H,R= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,m);_chunkDSIFRRBScjs.e.call(void 0, this,N);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,x);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,I,[]);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,W,null);let{chain:t,address:n,owner:a,options:c,alias:h,recovery:u,apiRecoveryServerSignerAddresses:S,apiDelegatedServerSignerAddresses:g,signers:C,signer:y}=e;_chunkDSIFRRBScjs.f.call(void 0, this,p,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,N,c),this.alias=h;let w=Array.isArray(u)?u:[u],_=S!=null?S:w.filter(d=>d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)).map(d=>d.address);_chunkDSIFRRBScjs.f.call(void 0, this,I,g!=null?g:[]),_chunkDSIFRRBScjs.f.call(void 0, this,b,C!=null?C:[]),_chunkDSIFRRBScjs.f.call(void 0, this,x,new (0, _chunkU5DLRN5Ucjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,p).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,p).environment,apiRecoveryAddresses:_,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,I),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,b).filter(d=>d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)).map(d=>d.address),..._chunkDSIFRRBScjs.d.call(void 0, this,I)]})),_chunkDSIFRRBScjs.f.call(void 0, this,l,new (0, _chunkJMVDYHTGcjs.a)({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),recoverySigners:w,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,b),signers:()=>this.signers(),signer:y})),w.forEach((d,q)=>{d.type==="server"&&!_chunkQPCZFIUVcjs.f.call(void 0, d)&&_chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(q,_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveRecovery(d))}),_chunkDSIFRRBScjs.f.call(void 0, this,f,new (0, _chunkGAACIEE2cjs.a)({chain:t,walletAddress:this.address,options:c,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,l),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),signers:()=>this.signers(),addSigner:d=>this.addSigner(d),removeSigner:d=>this.removeSigner({type:"device",locator:d}),approveSignature:d=>this.approveSignatureAndWait(d),approveTransaction:d=>this.approveTransactionAndWait(d)})),_chunkDSIFRRBScjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,f).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,f).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,b).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,b).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,b)[0]:null;if(e==null)return;let r=_chunk4MNSKZHWcjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(a,{isAdminSigner:n}))}catch(a){_chunkWIAIJCQ2cjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,b).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,b)}static getApiRecoveryServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,x).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,I)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,p)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,N)}get chainAdapter(){return _chunkD6BFMPZAcjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,x).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recovery}get recoveryMethods(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recoverySigners}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkWIAIJCQ2cjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkWIAIJCQ2cjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkWIAIJCQ2cjs.a.info("wallet.balances.success"),_chunkW7IPXUD5cjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkWIAIJCQ2cjs.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 _chunkWIAIJCQ2cjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkWIAIJCQ2cjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkWIAIJCQ2cjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkVS6I4S7Xcjs.G)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=_chunkR2XC4F3Mcjs.a.call(void 0, e),h=this.resolveChainForEnvironment(),u=_chunkR2XC4F3Mcjs.b.call(void 0, r,h);_chunkWIAIJCQ2cjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,token:u,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let S=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),g;(n==null?void 0:n.signer)==null?g=S.locator():typeof n.signer=="string"?g=n.signer:g=this.resolveServerSignerApiLocator(n.signer);let C=_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,amount:t,signer:g},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).send(this.walletLocator,u,C);if("message"in y)throw _chunkWIAIJCQ2cjs.a.error("wallet.send.error",{error:y}),new (0, _chunkVS6I4S7Xcjs.H)(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkWIAIJCQ2cjs.a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let w=yield this.approveTransactionAndWait(y.id);return _chunkWIAIJCQ2cjs.a.info("wallet.send.success",{transactionId:y.id,hash:w.hash}),w})}approveTransaction(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkWIAIJCQ2cjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkWIAIJCQ2cjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkWIAIJCQ2cjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkWIAIJCQ2cjs.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkWIAIJCQ2cjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w;let a=typeof t=="string"?t:_chunkCZC2MNVKcjs.b.call(void 0, t),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(a);if(c.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkWIAIJCQ2cjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),_chunkWIAIJCQ2cjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return _chunkWIAIJCQ2cjs.a.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let h=typeof t=="string"?t:_chunk4MNSKZHWcjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),S=this.chain!=="solana"&&this.chain!=="stellar"?(w=r==null?void 0:r.deployImmediately)!=null?w:!0:void 0,g=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),S!=null&&{deployImmediately:S}),n!=null&&{approver:n}));if("error"in g)throw _chunkWIAIJCQ2cjs.a.error("wallet.addSigner.error",{error:g}),g.code===_chunkVS6I4S7Xcjs.l?new (0, _chunkVS6I4S7Xcjs.m)(g.message):new (0, _chunkVS6I4S7Xcjs.j)(`Failed to register signer: ${JSON.stringify(g.message)}`);let C=_chunkJNKTRQPScjs.b.call(void 0, g,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let y=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,y,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkWIAIJCQ2cjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkWIAIJCQ2cjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkWIAIJCQ2cjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkWIAIJCQ2cjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkWIAIJCQ2cjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkWIAIJCQ2cjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).removeSigner(this.walletLocator,t,_chunkDSIFRRBScjs.a.call(void 0, {chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw _chunkWIAIJCQ2cjs.a.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkWIAIJCQ2cjs.a.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkWIAIJCQ2cjs.a.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkWIAIJCQ2cjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,x).resetDelegatedCache(),_chunk4MNSKZHWcjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,f).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunk4MNSKZHWcjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),n=_chunkCZC2MNVKcjs.b.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(t,{isAdminSigner:r})),_chunkWIAIJCQ2cjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(n.recoveryIndex,a.address),_chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkCZC2MNVKcjs.b.call(void 0, e)}isPasskeyMissingId(e){return _chunkCZC2MNVKcjs.a.call(void 0, e)==null}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,f).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,f).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,c;_chunkWIAIJCQ2cjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getWallet(this.walletLocator);if("error"in e)throw _chunkWIAIJCQ2cjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkVS6I4S7Xcjs.e)(JSON.stringify(e));if(!ye(e)){let h=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkWIAIJCQ2cjs.a.error("wallet.signers.error",{error:h}),new (0, _chunkVS6I4S7Xcjs.d)(h)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(h=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(h.locator)).signer}catch(u){return _chunkWIAIJCQ2cjs.a.warn("wallet.signers.mapSigner.failed",{locator:h.locator,error:u}),null}})))).filter(h=>h!=null);return _chunkWIAIJCQ2cjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,p).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O),_chunkDSIFRRBScjs.d.call(void 0, this,W)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,W,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,W)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,W,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();e instanceof _chunk3TJEBF5Ucjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=_chunk4MNSKZHWcjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,l).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=_chunkZEGNY3K3cjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,p).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var u,S;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getSignature(this.walletLocator,e);if("error"in n)throw _chunkVS6I4S7Xcjs.Q.call(void 0, n),new (0, _chunkVS6I4S7Xcjs.D)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let g=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,g)}let a=(u=n.approvals)==null?void 0:u.pending;if(a==null||a.length===0)return n;let c=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],t],h=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,m,U).call(this,a),c,(g,C)=>g.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,h)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var u,S,g,C,y;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.I)(JSON.stringify(t));yield(g=(S=(u=_chunkDSIFRRBScjs.d.call(void 0, this,N))==null?void 0:u.callbacks)==null?void 0:S.onTransactionStart)==null?void 0:g.call(S);let n=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],n],h=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,m,U).call(this,a),c,(w,_)=>{let d=w.type==="device",q=t.chainType==="solana"&&"transaction"in t.onChain&&!d?t.onChain.transaction:_.message;return w.signTransaction(q)});return yield this.executeApproveTransactionWithErrorHandling(e,h)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkWIAIJCQ2cjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.N)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.E)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkIZVYNUFOcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,p),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkIZVYNUFOcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,p),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};N=new WeakMap,p=new WeakMap,b=new WeakMap,x=new WeakMap,l=new WeakMap,f=new WeakMap,I=new WeakMap,O=new WeakMap,W=new WeakMap,m=new WeakSet,ve=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,f).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkWIAIJCQ2cjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},fe=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,ve).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkVS6I4S7Xcjs.j)(`Signer ${r} not found in pending approvals`);return t})},U=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkVS6I4S7Xcjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,fe).call(this,r,n.signer.locator),c=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},c),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function ye(J){return J.type==="smart"&&_chunkD6BFMPZAcjs.b.call(void 0, J.chainType)}exports.a = R;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIU7J7IPEcjs = require('./chunk-IU7J7IPE.cjs');var _chunkDB3TFNM2cjs = require('./chunk-DB3TFNM2.cjs');var _chunkBJC5DQQ3cjs = require('./chunk-BJC5DQQ3.cjs');var _chunk7HOXBHKPcjs = require('./chunk-7HOXBHKP.cjs');var _chunkU5DLRN5Ucjs = require('./chunk-U5DLRN5U.cjs');var _chunkYWN6HKW7cjs = require('./chunk-YWN6HKW7.cjs');var _chunkCZC2MNVKcjs = require('./chunk-CZC2MNVK.cjs');var _chunkR2XC4F3Mcjs = require('./chunk-R2XC4F3M.cjs');var _chunkZHGXG7JMcjs = require('./chunk-ZHGXG7JM.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkD5IIHIEWcjs = require('./chunk-D5IIHIEW.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkBHHXVRU6cjs = require('./chunk-BHHXVRU6.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var N,p,b,x,l,f,I,O,W,m,ve,fe,U,H,R= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,m);_chunkDSIFRRBScjs.e.call(void 0, this,N);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,x);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,I,[]);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,W,null);let{chain:t,address:n,owner:a,options:c,alias:h,recovery:u,apiRecoveryServerSignerAddresses:S,apiDelegatedServerSignerAddresses:g,signers:C,signer:y}=e;_chunkDSIFRRBScjs.f.call(void 0, this,p,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,N,c),this.alias=h;let w=Array.isArray(u)?u:[u],_=S!=null?S:w.filter(d=>d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)).map(d=>d.address);_chunkDSIFRRBScjs.f.call(void 0, this,I,g!=null?g:[]),_chunkDSIFRRBScjs.f.call(void 0, this,b,C!=null?C:[]),_chunkDSIFRRBScjs.f.call(void 0, this,x,new (0, _chunkU5DLRN5Ucjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,p).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,p).environment,apiRecoveryAddresses:_,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,I),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,b).filter(d=>d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)).map(d=>d.address),..._chunkDSIFRRBScjs.d.call(void 0, this,I)]})),_chunkDSIFRRBScjs.f.call(void 0, this,l,new (0, _chunk7HOXBHKPcjs.a)({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),recoverySigners:w,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,b),signers:()=>this.signers(),signer:y})),w.forEach((d,q)=>{d.type==="server"&&!_chunkQPCZFIUVcjs.f.call(void 0, d)&&_chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(q,_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveRecovery(d))}),_chunkDSIFRRBScjs.f.call(void 0, this,f,new (0, _chunkDB3TFNM2cjs.a)({chain:t,walletAddress:this.address,options:c,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,l),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),signers:()=>this.signers(),addSigner:d=>this.addSigner(d),removeSigner:d=>this.removeSigner({type:"device",locator:d}),approveSignature:d=>this.approveSignatureAndWait(d),approveTransaction:d=>this.approveTransactionAndWait(d)})),_chunkDSIFRRBScjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,f).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,f).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,b).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,b).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,b)[0]:null;if(e==null)return;let r=_chunkYWN6HKW7cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(a,{isAdminSigner:n}))}catch(a){_chunkSP5DQZ6Dcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,b).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,b)}static getApiRecoveryServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,x).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,I)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,p)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,N)}get chainAdapter(){return _chunkD5IIHIEWcjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,x).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recovery}get recoveryMethods(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recoverySigners}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkSP5DQZ6Dcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkSP5DQZ6Dcjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkSP5DQZ6Dcjs.a.info("wallet.balances.success"),_chunkIU7J7IPEcjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkSP5DQZ6Dcjs.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 _chunkSP5DQZ6Dcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkSP5DQZ6Dcjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkSP5DQZ6Dcjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkVS6I4S7Xcjs.G)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=_chunkR2XC4F3Mcjs.a.call(void 0, e),h=this.resolveChainForEnvironment(),u=_chunkR2XC4F3Mcjs.b.call(void 0, r,h);_chunkSP5DQZ6Dcjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,token:u,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let S=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),g;(n==null?void 0:n.signer)==null?g=S.locator():typeof n.signer=="string"?g=n.signer:g=this.resolveServerSignerApiLocator(n.signer);let C=_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,amount:t,signer:g},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).send(this.walletLocator,u,C);if("message"in y)throw _chunkSP5DQZ6Dcjs.a.error("wallet.send.error",{error:y}),new (0, _chunkVS6I4S7Xcjs.H)(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkSP5DQZ6Dcjs.a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let w=yield this.approveTransactionAndWait(y.id);return _chunkSP5DQZ6Dcjs.a.info("wallet.send.success",{transactionId:y.id,hash:w.hash}),w})}approveTransaction(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkSP5DQZ6Dcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkSP5DQZ6Dcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkSP5DQZ6Dcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkSP5DQZ6Dcjs.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w;let a=typeof t=="string"?t:_chunkCZC2MNVKcjs.b.call(void 0, t),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(a);if(c.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkSP5DQZ6Dcjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),_chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return _chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let h=typeof t=="string"?t:_chunkYWN6HKW7cjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),S=this.chain!=="solana"&&this.chain!=="stellar"?(w=r==null?void 0:r.deployImmediately)!=null?w:!0:void 0,g=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),S!=null&&{deployImmediately:S}),n!=null&&{approver:n}));if("error"in g)throw _chunkSP5DQZ6Dcjs.a.error("wallet.addSigner.error",{error:g}),g.code===_chunkVS6I4S7Xcjs.l?new (0, _chunkVS6I4S7Xcjs.m)(g.message):new (0, _chunkVS6I4S7Xcjs.j)(`Failed to register signer: ${JSON.stringify(g.message)}`);let C=_chunkJNKTRQPScjs.b.call(void 0, g,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let y=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,y,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkSP5DQZ6Dcjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkSP5DQZ6Dcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).removeSigner(this.walletLocator,t,_chunkDSIFRRBScjs.a.call(void 0, {chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw _chunkSP5DQZ6Dcjs.a.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkSP5DQZ6Dcjs.a.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkSP5DQZ6Dcjs.a.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkSP5DQZ6Dcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,x).resetDelegatedCache(),_chunkYWN6HKW7cjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,f).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunkYWN6HKW7cjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),n=_chunkCZC2MNVKcjs.b.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(t,{isAdminSigner:r})),_chunkSP5DQZ6Dcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(n.recoveryIndex,a.address),_chunkDSIFRRBScjs.d.call(void 0, this,f).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkCZC2MNVKcjs.b.call(void 0, e)}isPasskeyMissingId(e){return _chunkCZC2MNVKcjs.a.call(void 0, e)==null}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,f).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,f).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,c;_chunkSP5DQZ6Dcjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getWallet(this.walletLocator);if("error"in e)throw _chunkSP5DQZ6Dcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkVS6I4S7Xcjs.e)(JSON.stringify(e));if(!ye(e)){let h=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkSP5DQZ6Dcjs.a.error("wallet.signers.error",{error:h}),new (0, _chunkVS6I4S7Xcjs.d)(h)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(h=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(h.locator)).signer}catch(u){return _chunkSP5DQZ6Dcjs.a.warn("wallet.signers.mapSigner.failed",{locator:h.locator,error:u}),null}})))).filter(h=>h!=null);return _chunkSP5DQZ6Dcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,p).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O),_chunkDSIFRRBScjs.d.call(void 0, this,W)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,W,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,W)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,W,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();e instanceof _chunkZHGXG7JMcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=_chunkYWN6HKW7cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,l).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=_chunkBHHXVRU6cjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,p).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var u,S;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getSignature(this.walletLocator,e);if("error"in n)throw _chunkVS6I4S7Xcjs.Q.call(void 0, n),new (0, _chunkVS6I4S7Xcjs.D)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let g=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,g)}let a=(u=n.approvals)==null?void 0:u.pending;if(a==null||a.length===0)return n;let c=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],t],h=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,m,U).call(this,a),c,(g,C)=>g.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,h)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var u,S,g,C,y;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.I)(JSON.stringify(t));yield(g=(S=(u=_chunkDSIFRRBScjs.d.call(void 0, this,N))==null?void 0:u.callbacks)==null?void 0:S.onTransactionStart)==null?void 0:g.call(S);let n=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],n],h=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,m,U).call(this,a),c,(w,_)=>{let d=w.type==="device",q=t.chainType==="solana"&&"transaction"in t.onChain&&!d?t.onChain.transaction:_.message;return w.signTransaction(q)});return yield this.executeApproveTransactionWithErrorHandling(e,h)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkSP5DQZ6Dcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.N)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,p).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.E)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkBJC5DQQ3cjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,p),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkBJC5DQQ3cjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,p),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};N=new WeakMap,p=new WeakMap,b=new WeakMap,x=new WeakMap,l=new WeakMap,f=new WeakMap,I=new WeakMap,O=new WeakMap,W=new WeakMap,m=new WeakSet,ve=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,f).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkSP5DQZ6Dcjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},fe=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,ve).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkVS6I4S7Xcjs.j)(`Signer ${r} not found in pending approvals`);return t})},U=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkVS6I4S7Xcjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,m,fe).call(this,r,n.signer.locator),c=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},c),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function ye(J){return J.type==="smart"&&_chunkD5IIHIEWcjs.b.call(void 0, J.chainType)}exports.a = R;
@@ -1 +1 @@
1
- import{a as o}from"./chunk-L7RATGRO.js";import{a as W}from"./chunk-BXEH6VXA.js";import{C as f,H as w,y as l}from"./chunk-KOHPRJDP.js";import{a as n}from"./chunk-JNGPW247.js";import{c as u,h as p}from"./chunk-NU7VF7MC.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecoverySigners(e),apiRecoveryServerSignerAddresses:o.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return n.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw n.error("evmWallet.signMessage.error",{error:r}),new f(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return n.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return O({transport:(t=e==null?void 0:e.transport)!=null?t:E(),chain:W(this.chain)})}createTransaction(e,t){return p(this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}export{M as a};
1
+ import{a as o}from"./chunk-LUUUKDHQ.js";import{a as W}from"./chunk-NMUHOXYI.js";import{C as f,H as w,y as l}from"./chunk-KOHPRJDP.js";import{a as n}from"./chunk-AZAIXRGS.js";import{c as u,h as p}from"./chunk-NU7VF7MC.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecoverySigners(e),apiRecoveryServerSignerAddresses:o.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return n.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw n.error("evmWallet.signMessage.error",{error:r}),new f(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return n.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return O({transport:(t=e==null?void 0:e.transport)!=null?t:E(),chain:W(this.chain)})}createTransaction(e,t){return p(this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}export{M as a};
@@ -1 +1 @@
1
- import{c as g}from"./chunk-B4GYB3XY.js";import{j as s}from"./chunk-KOHPRJDP.js";import{a as i}from"./chunk-JNGPW247.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
1
+ import{c as g}from"./chunk-B4GYB3XY.js";import{j as s}from"./chunk-KOHPRJDP.js";import{a as i}from"./chunk-AZAIXRGS.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
@@ -1 +1 @@
1
- import{a as r}from"./chunk-L7RATGRO.js";import{a as h}from"./chunk-7KKHT5PF.js";import{H as S}from"./chunk-KOHPRJDP.js";import{a as t}from"./chunk-JNGPW247.js";import{c as u,h as c}from"./chunk-NU7VF7MC.js";import T from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as m}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecoverySigners(e),apiRecoveryServerSignerAddresses:r.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:r.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:r.getInitialSigners(e)},r.getApiClient(e))}static from(e){if(!y(e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return c(this,null,function*(){var l,p;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new h({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return c(this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=T.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new S(JSON.stringify(i));return i})}};u([m({logger:t,methodName:"solanaWallet.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 r}from"./chunk-LUUUKDHQ.js";import{a as h}from"./chunk-7KKHT5PF.js";import{H as S}from"./chunk-KOHPRJDP.js";import{a as t}from"./chunk-AZAIXRGS.js";import{c as u,h as c}from"./chunk-NU7VF7MC.js";import T from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as m}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecoverySigners(e),apiRecoveryServerSignerAddresses:r.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:r.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:r.getInitialSigners(e)},r.getApiClient(e))}static from(e){if(!y(e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return c(this,null,function*(){var l,p;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new h({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return c(this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=T.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new S(JSON.stringify(i));return i})}};u([m({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;export{f as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4MNSKZHWcjs = require('./chunk-4MNSKZHW.cjs');var _chunkCZC2MNVKcjs = require('./chunk-CZC2MNVK.cjs');var _chunkN3HRM33Gcjs = require('./chunk-N3HRM33G.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var l,s,d,c,h,y,u,C,w,m,S,E,$,D,q= exports.a =class{constructor(e){_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,s);_chunkDSIFRRBScjs.e.call(void 0, this,d);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,h);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,w);_chunkDSIFRRBScjs.e.call(void 0, this,m);if(_chunkDSIFRRBScjs.f.call(void 0, this,d,e.apiClient),_chunkDSIFRRBScjs.f.call(void 0, this,c,e.options),_chunkDSIFRRBScjs.f.call(void 0, this,h,e.chain),_chunkDSIFRRBScjs.f.call(void 0, this,y,e.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,e.walletLocator),_chunkDSIFRRBScjs.f.call(void 0, this,C,e.serverSignerResolver),e.recoverySigners.length===0)throw new (0, _chunkVS6I4S7Xcjs.o)("At least one recovery signer is required");_chunkDSIFRRBScjs.f.call(void 0, this,s,[...e.recoverySigners]),_chunkDSIFRRBScjs.f.call(void 0, this,w,e.initialSigners),_chunkDSIFRRBScjs.f.call(void 0, this,m,e.signers),_chunkDSIFRRBScjs.f.call(void 0, this,l,e.signer)}get activeSigner(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}setActiveSigner(e){_chunkDSIFRRBScjs.f.call(void 0, this,l,e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,s)[0]}get recoverySigners(){return[..._chunkDSIFRRBScjs.d.call(void 0, this,s)]}descriptorContext(){var e,r,n,a,t;return{chain:_chunkDSIFRRBScjs.d.call(void 0, this,h),walletAddress:_chunkDSIFRRBScjs.d.call(void 0, this,y),crossmint:_chunkDSIFRRBScjs.d.call(void 0, this,d).crossmint,clientTEEConnection:(e=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:e.clientTEEConnection,resetSignerFrame:(r=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:r.resetSignerFrame,onAuthRequired:(a=(n=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:n.callbacks)==null?void 0:a.onAuthRequired,deviceSignerKeyStorage:(t=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:t.deviceSignerKeyStorage,serverSigners:_chunkDSIFRRBScjs.d.call(void 0, this,C)}}adoptRecoveryConfig(e,r){_chunkDSIFRRBScjs.g.call(void 0, this,S,E).call(this,e),_chunkDSIFRRBScjs.d.call(void 0, this,s)[e]=r}stripSecretFromRecovery(e,r){_chunkDSIFRRBScjs.g.call(void 0, this,S,E).call(this,e);let n=_chunkDSIFRRBScjs.d.call(void 0, this,s)[e];n.type==="server"&&!_chunkQPCZFIUVcjs.f.call(void 0, n)&&(_chunkDSIFRRBScjs.d.call(void 0, this,s)[e]={type:"server",address:r})}assemble(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,t;let n=_chunkN3HRM33Gcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,h),e,(a=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:a.deviceSignerKeyStorage);if(r!=null&&r.isAdminSigner)n.status="active";else{let p=yield this.getSignerState(n.locator());n.status=(t=p.signer)==null?void 0:t.status}return n})}require(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,w).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let e=this.recovery,r=_chunk4MNSKZHWcjs.a.call(void 0, e.type),n=r.signerUnavailableReason();throw n!=null?new Error(n):r.canAutoAssemble(e,this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return _chunkDSIFRRBScjs.d.call(void 0, this,l)}resolveAuthorizingRecovery(){var a;if(_chunkDSIFRRBScjs.d.call(void 0, this,s).length===1)return{recovery:_chunkDSIFRRBScjs.d.call(void 0, this,s)[0],approver:void 0};let e=_chunkDSIFRRBScjs.d.call(void 0, this,s).map(t=>_chunkDSIFRRBScjs.g.call(void 0, this,S,$).call(this,t)),r=(a=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:a.locator(),n=r==null?-1:e.indexOf(r);if(n===-1){let p=`Call wallet.useSigner() with one of them (${e.filter(R=>R!=null).join(", ")}) first.`;throw new (0, _chunkVS6I4S7Xcjs.s)(r==null?`This wallet has multiple recovery methods, so the one authorizing this operation must be selected. ${p}`:`Signer "${r}" is not one of this wallet's recovery methods, and only a recovery method can add or remove signers. ${p}`)}return{recovery:_chunkDSIFRRBScjs.d.call(void 0, this,s)[n],approver:r}}withRecoverySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var P;let r=_chunkDSIFRRBScjs.d.call(void 0, this,l),{recovery:n,approver:a}=this.resolveAuthorizingRecovery(),t=n;if(_chunkQPCZFIUVcjs.f.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,C).hasRecoveryResolutionFor(t.address))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let p=_chunk4MNSKZHWcjs.a.call(void 0, t.type),R=this.descriptorContext();if(t.type==="external-wallet"&&!p.canAutoAssemble(t,R))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let k=p.buildInternalConfig(t,R);_chunkDSIFRRBScjs.f.call(void 0, this,l,_chunkN3HRM33Gcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,h),k,(P=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:P.deviceSignerKeyStorage));try{return yield e(a)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,l,r)}})}getSignerState(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=null;try{r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSigner(_chunkDSIFRRBScjs.d.call(void 0, this,u).call(this),e)}catch(a){return _chunkWIAIJCQ2cjs.a.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:a}),{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return _chunkWIAIJCQ2cjs.a.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:r}),{response:null,signer:null,pendingOperation:null};let n=_chunkJNKTRQPScjs.b.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h));return{response:r,signer:n,pendingOperation:_chunkJNKTRQPScjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h))}})}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield _chunkDSIFRRBScjs.d.call(void 0, this,m).call(this)).some(n=>n.locator===e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{let r=yield _chunkDSIFRRBScjs.g.call(void 0, this,S,D).call(this,e);return this.isApprovedSignerStatus(r==null?void 0:r.status)}catch(r){if(r instanceof _commonsdkbase.ApiClientError&&r.status===404)return!1;throw _chunkWIAIJCQ2cjs.a.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:r}),r}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};l=new WeakMap,s=new WeakMap,d=new WeakMap,c=new WeakMap,h=new WeakMap,y=new WeakMap,u=new WeakMap,C=new WeakMap,w=new WeakMap,m=new WeakMap,S=new WeakSet,E=function(e){if(e<0||e>=_chunkDSIFRRBScjs.d.call(void 0, this,s).length)throw new Error(`Recovery signer index ${e} is out of range`)},$=function(e){return e.type==="server"?_chunkQPCZFIUVcjs.f.call(void 0, e)?`server:${e.address}`:null:_chunkCZC2MNVKcjs.b.call(void 0, e)},D=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSigner(_chunkDSIFRRBScjs.d.call(void 0, this,u).call(this),e);if(r==null||typeof r!="object"||"error"in r)throw new Error(`Failed to fetch the approval state of signer ${e}`);return _chunkJNKTRQPScjs.b.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h))})};exports.a = q;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWN6HKW7cjs = require('./chunk-YWN6HKW7.cjs');var _chunkCZC2MNVKcjs = require('./chunk-CZC2MNVK.cjs');var _chunk4R2UUYLCcjs = require('./chunk-4R2UUYLC.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var l,s,d,c,h,y,u,C,w,m,S,E,$,D,q= exports.a =class{constructor(e){_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,s);_chunkDSIFRRBScjs.e.call(void 0, this,d);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,h);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,w);_chunkDSIFRRBScjs.e.call(void 0, this,m);if(_chunkDSIFRRBScjs.f.call(void 0, this,d,e.apiClient),_chunkDSIFRRBScjs.f.call(void 0, this,c,e.options),_chunkDSIFRRBScjs.f.call(void 0, this,h,e.chain),_chunkDSIFRRBScjs.f.call(void 0, this,y,e.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,e.walletLocator),_chunkDSIFRRBScjs.f.call(void 0, this,C,e.serverSignerResolver),e.recoverySigners.length===0)throw new (0, _chunkVS6I4S7Xcjs.o)("At least one recovery signer is required");_chunkDSIFRRBScjs.f.call(void 0, this,s,[...e.recoverySigners]),_chunkDSIFRRBScjs.f.call(void 0, this,w,e.initialSigners),_chunkDSIFRRBScjs.f.call(void 0, this,m,e.signers),_chunkDSIFRRBScjs.f.call(void 0, this,l,e.signer)}get activeSigner(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}setActiveSigner(e){_chunkDSIFRRBScjs.f.call(void 0, this,l,e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,s)[0]}get recoverySigners(){return[..._chunkDSIFRRBScjs.d.call(void 0, this,s)]}descriptorContext(){var e,r,n,a,t;return{chain:_chunkDSIFRRBScjs.d.call(void 0, this,h),walletAddress:_chunkDSIFRRBScjs.d.call(void 0, this,y),crossmint:_chunkDSIFRRBScjs.d.call(void 0, this,d).crossmint,clientTEEConnection:(e=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:e.clientTEEConnection,resetSignerFrame:(r=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:r.resetSignerFrame,onAuthRequired:(a=(n=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:n.callbacks)==null?void 0:a.onAuthRequired,deviceSignerKeyStorage:(t=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:t.deviceSignerKeyStorage,serverSigners:_chunkDSIFRRBScjs.d.call(void 0, this,C)}}adoptRecoveryConfig(e,r){_chunkDSIFRRBScjs.g.call(void 0, this,S,E).call(this,e),_chunkDSIFRRBScjs.d.call(void 0, this,s)[e]=r}stripSecretFromRecovery(e,r){_chunkDSIFRRBScjs.g.call(void 0, this,S,E).call(this,e);let n=_chunkDSIFRRBScjs.d.call(void 0, this,s)[e];n.type==="server"&&!_chunkQPCZFIUVcjs.f.call(void 0, n)&&(_chunkDSIFRRBScjs.d.call(void 0, this,s)[e]={type:"server",address:r})}assemble(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,t;let n=_chunk4R2UUYLCcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,h),e,(a=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:a.deviceSignerKeyStorage);if(r!=null&&r.isAdminSigner)n.status="active";else{let p=yield this.getSignerState(n.locator());n.status=(t=p.signer)==null?void 0:t.status}return n})}require(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,w).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let e=this.recovery,r=_chunkYWN6HKW7cjs.a.call(void 0, e.type),n=r.signerUnavailableReason();throw n!=null?new Error(n):r.canAutoAssemble(e,this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return _chunkDSIFRRBScjs.d.call(void 0, this,l)}resolveAuthorizingRecovery(){var a;if(_chunkDSIFRRBScjs.d.call(void 0, this,s).length===1)return{recovery:_chunkDSIFRRBScjs.d.call(void 0, this,s)[0],approver:void 0};let e=_chunkDSIFRRBScjs.d.call(void 0, this,s).map(t=>_chunkDSIFRRBScjs.g.call(void 0, this,S,$).call(this,t)),r=(a=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:a.locator(),n=r==null?-1:e.indexOf(r);if(n===-1){let p=`Call wallet.useSigner() with one of them (${e.filter(R=>R!=null).join(", ")}) first.`;throw new (0, _chunkVS6I4S7Xcjs.s)(r==null?`This wallet has multiple recovery methods, so the one authorizing this operation must be selected. ${p}`:`Signer "${r}" is not one of this wallet's recovery methods, and only a recovery method can add or remove signers. ${p}`)}return{recovery:_chunkDSIFRRBScjs.d.call(void 0, this,s)[n],approver:r}}withRecoverySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var P;let r=_chunkDSIFRRBScjs.d.call(void 0, this,l),{recovery:n,approver:a}=this.resolveAuthorizingRecovery(),t=n;if(_chunkQPCZFIUVcjs.f.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,C).hasRecoveryResolutionFor(t.address))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let p=_chunkYWN6HKW7cjs.a.call(void 0, t.type),R=this.descriptorContext();if(t.type==="external-wallet"&&!p.canAutoAssemble(t,R))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let k=p.buildInternalConfig(t,R);_chunkDSIFRRBScjs.f.call(void 0, this,l,_chunk4R2UUYLCcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,h),k,(P=_chunkDSIFRRBScjs.d.call(void 0, this,c))==null?void 0:P.deviceSignerKeyStorage));try{return yield e(a)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,l,r)}})}getSignerState(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=null;try{r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSigner(_chunkDSIFRRBScjs.d.call(void 0, this,u).call(this),e)}catch(a){return _chunkSP5DQZ6Dcjs.a.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:a}),{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return _chunkSP5DQZ6Dcjs.a.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:r}),{response:null,signer:null,pendingOperation:null};let n=_chunkJNKTRQPScjs.b.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h));return{response:r,signer:n,pendingOperation:_chunkJNKTRQPScjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h))}})}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield _chunkDSIFRRBScjs.d.call(void 0, this,m).call(this)).some(n=>n.locator===e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{let r=yield _chunkDSIFRRBScjs.g.call(void 0, this,S,D).call(this,e);return this.isApprovedSignerStatus(r==null?void 0:r.status)}catch(r){if(r instanceof _commonsdkbase.ApiClientError&&r.status===404)return!1;throw _chunkSP5DQZ6Dcjs.a.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:r}),r}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};l=new WeakMap,s=new WeakMap,d=new WeakMap,c=new WeakMap,h=new WeakMap,y=new WeakMap,u=new WeakMap,C=new WeakMap,w=new WeakMap,m=new WeakMap,S=new WeakSet,E=function(e){if(e<0||e>=_chunkDSIFRRBScjs.d.call(void 0, this,s).length)throw new Error(`Recovery signer index ${e} is out of range`)},$=function(e){return e.type==="server"?_chunkQPCZFIUVcjs.f.call(void 0, e)?`server:${e.address}`:null:_chunkCZC2MNVKcjs.b.call(void 0, e)},D=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSigner(_chunkDSIFRRBScjs.d.call(void 0, this,u).call(this),e);if(r==null||typeof r!="object"||"error"in r)throw new Error(`Failed to fetch the approval state of signer ${e}`);return _chunkJNKTRQPScjs.b.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,h))})};exports.a = q;
@@ -1 +1 @@
1
- import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-JNGPW247.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(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 h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=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 */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
1
+ import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-AZAIXRGS.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(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 h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=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 */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _viem = require('viem');var t=_viem.defineChain.call(void 0, {id:4663,name:"Robinhood Chain",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.mainnet.chain.robinhood.com"]}},blockExplorers:{default:{name:"Robinhood Chain Explorer",url:"https://robinhoodchain.blockscout.com",apiUrl:"https://robinhoodchain.blockscout.com/api"}},testnet:!1});exports.a = t;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-QU5AAJAW.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-FUZ2TPGD.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkAUO6R32Hcjs = require('./chunk-AUO6R32H.cjs');var _chunkZPO3XSWUcjs = require('./chunk-ZPO3XSWU.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkTCDH5Q6Qcjs = require('./chunk-TCDH5Q6Q.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkOQFZL5LIcjs = require('./chunk-OQFZL5LI.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var Z=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],k=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.ARC,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.CELO,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function se(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE:return _chains.avalanche;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI:return _chains.avalancheFuji;case _commonsdkbase.BlockchainIncludingTestnet.CELO:return _chains.celo;case _commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA:return _chunkOQFZL5LIcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN:return _chunkAUO6R32Hcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET:return _chunkZPO3XSWUcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.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.ETHEREUM:return _chains.mainnet;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:return _chunkTCDH5Q6Qcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.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 m(t){return Z.includes(t)}function M(t){return k.includes(t)}var J={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE]:_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.CELO]:_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM]:_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.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.ROBINHOOD_CHAIN]:_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.ARC]:_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET};function q(t){return J[t]}function z(t){return t==="solana"||t==="stellar"||m(t)||M(t)}function Se(t,a){if(!z(t))throw new (0, _chunkVS6I4S7Xcjs.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&&m(r))throw new (0, _chunkVS6I4S7Xcjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&M(r)){let n=q(r);if(n!=null)return _chunkSP5DQZ6Dcjs.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;_chunkSP5DQZ6Dcjs.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 = se; exports.b = m; exports.c = M; exports.d = q; exports.e = z; exports.f = Se;
@@ -1 +1 @@
1
- import{a as m}from"./chunk-6KW2HYAX.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=m(s).balanceTokenFields(n);return u(u(u(u({symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=m(s).emptyBalanceTokenFields();return u(u({},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=C(n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function g(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}export{g as a};
1
+ import{a as m}from"./chunk-WJDR3MG5.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=m(s).balanceTokenFields(n);return u(u(u(u({symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=m(s).emptyBalanceTokenFields();return u(u({},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=C(n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function g(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunk3TPBVNNFcjs = require('./chunk-3TPBVNNF.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function R(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};_chunkWIAIJCQ2cjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new (0, _chunkVS6I4S7Xcjs.J)("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.I)(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new (0, _chunkVS6I4S7Xcjs.K)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunkVS6I4S7Xcjs.L)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new (0, _chunkVS6I4S7Xcjs.M)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function W(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new (0, _chunkVS6I4S7Xcjs.F)("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,_chunk3TPBVNNFcjs.d)),n=yield i.getSignature(o,a),"error"in n)throw _chunkVS6I4S7Xcjs.Q.call(void 0, n),new (0, _chunkVS6I4S7Xcjs.D)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunkVS6I4S7Xcjs.A)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunkVS6I4S7Xcjs.D)("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(o=>setTimeout(o,i))})}exports.a = R; exports.b = W;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkXFCHACH7cjs = require('./chunk-XFCHACH7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function R(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};_chunkSP5DQZ6Dcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new (0, _chunkVS6I4S7Xcjs.J)("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw _chunkVS6I4S7Xcjs.Q.call(void 0, t),new (0, _chunkVS6I4S7Xcjs.I)(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new (0, _chunkVS6I4S7Xcjs.K)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunkVS6I4S7Xcjs.L)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new (0, _chunkVS6I4S7Xcjs.M)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function W(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new (0, _chunkVS6I4S7Xcjs.F)("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,_chunkXFCHACH7cjs.d)),n=yield i.getSignature(o,a),"error"in n)throw _chunkVS6I4S7Xcjs.Q.call(void 0, n),new (0, _chunkVS6I4S7Xcjs.D)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunkVS6I4S7Xcjs.A)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunkVS6I4S7Xcjs.D)("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(o=>setTimeout(o,i))})}exports.a = R; exports.b = W;
@@ -1 +1 @@
1
- import{a as j}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-CTCUJBU2.js";import{a as T,b as M}from"./chunk-6OUANX4J.js";import{a as W,b as E,f as O}from"./chunk-DCKFFFPG.js";import{m as I}from"./chunk-KOHPRJDP.js";import{a as s}from"./chunk-JNGPW247.js";import{d as e,e as d,f as o,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,p);d(this,y);d(this,n);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);o(this,C,r.chain),o(this,p,r.walletAddress),o(this,y,r.options),o(this,n,r.signerManager),o(this,b,r.serverSignerResolver),o(this,A,r.signers),o(this,k,r.addSigner),o(this,L,r.removeSigner),o(this,K,r.approveSignature),o(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&o(this,l,"unknown")}initDeviceSigner(){return f(this,null,function*(){var g;if(((g=e(this,y))==null?void 0:g.deviceSignerKeyStorage)==null||e(this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(S){s.error("wallet.initDeviceSigner.error",{error:S}),o(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let a=R(i.type).buildInternalConfig(i,e(this,n).descriptorContext()),t=yield e(this,n).assemble(a);e(this,n).setActiveSigner(t),e(this,n).isApprovedSignerStatus(t.status)||(s.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),o(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(s.info("wallet.recover.start"),e(this,l)==="resolved"){s.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){s.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),o(this,l,"resolved");return}let r=e(this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,F).call(this,r))){o(this,l,"resolved");return}if(r!=null&&r.type!=="device"){s.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),o(this,l,"unknown");return}let i=(D=e(this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(e(this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let a=yield e(this,A).call(this),t=yield w(this,u,B).call(this,i,a);if(t!=null&&(yield w(this,u,F).call(this,t))){e(this,n).setActiveSigner(t),o(this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,p),c)}catch(z){s.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=w(this,u,V).call(this,g,i),v=yield j(i,e(this,p));try{yield e(this,k).call(this,v)}catch(c){if(c instanceof I){s.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,p)),o(this,m,!0),o(this,l,"resolved"),yield w(this,u,$).call(this);return}else if(G(c))s.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof W||c instanceof Error&&c.name==="AuthRejectedError"?(s.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof E||c instanceof Error&&c.name==="OtpValidationError"?(s.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof E?c.code:void 0}),c):(s.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(e(this,p)),c)}let h=yield e(this,n).assemble({type:"device",locator:v.locator,address:e(this,p)});if(e(this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),s.info("wallet.recover.device.success",{signerLocator:v.locator}),o(this,l,"resolved"),S!=null)try{yield e(this,L).call(this,S),s.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){s.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return f(this,null,function*(){var S;let i=(S=e(this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(e(this,p));if(a!=null){r.locator=`device:${a}`,o(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(e(this,p),h),r.locator=v.locator,o(this,l,"unknown");return}}o(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(a=>(a=e(this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield M(e(this,C),r,e(this,p),i)}catch(g){return s.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return f(this,null,function*(){var a;if(e(this,n).isApprovedSignerStatus(r.status))return s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield w(this,u,q).call(this,r,i.pendingOperation),!0):e(this,n).isApprovedSignerStatus(r.status)?(s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return f(this,null,function*(){var h;let a=e(this,n).activeSigner,t=e(this,n).recovery;if(O(t)&&!e(this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=R(t.type),S=e(this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,S);e(this,n).setActiveSigner(T(e(this,C),v,(h=e(this,y))==null?void 0:h.deviceSignerKeyStorage));try{i.type==="signature"?yield e(this,K).call(this,i.id):yield e(this,P).call(this,i.id)}catch(D){throw e(this,n).setActiveSigner(r),D}finally{e(this,n).activeSigner!==r&&e(this,n).setActiveSigner(a)}r.status="success",s.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return f(this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return s.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return f(this,null,function*(){let r=e(this,n).recovery,i=R(r.type),a=e(this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);e(this,n).setActiveSigner(yield e(this,n).assemble(t,{isAdminSigner:!0}))}catch(t){s.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{N as a};
1
+ import{a as j}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-QYNWUGXV.js";import{a as T,b as M}from"./chunk-62EHAJRH.js";import{a as W,b as E,f as O}from"./chunk-DCKFFFPG.js";import{m as I}from"./chunk-KOHPRJDP.js";import{a as s}from"./chunk-AZAIXRGS.js";import{d as e,e as d,f as o,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,p);d(this,y);d(this,n);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);o(this,C,r.chain),o(this,p,r.walletAddress),o(this,y,r.options),o(this,n,r.signerManager),o(this,b,r.serverSignerResolver),o(this,A,r.signers),o(this,k,r.addSigner),o(this,L,r.removeSigner),o(this,K,r.approveSignature),o(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&o(this,l,"unknown")}initDeviceSigner(){return f(this,null,function*(){var g;if(((g=e(this,y))==null?void 0:g.deviceSignerKeyStorage)==null||e(this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(S){s.error("wallet.initDeviceSigner.error",{error:S}),o(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let a=R(i.type).buildInternalConfig(i,e(this,n).descriptorContext()),t=yield e(this,n).assemble(a);e(this,n).setActiveSigner(t),e(this,n).isApprovedSignerStatus(t.status)||(s.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),o(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(s.info("wallet.recover.start"),e(this,l)==="resolved"){s.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){s.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),o(this,l,"resolved");return}let r=e(this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,F).call(this,r))){o(this,l,"resolved");return}if(r!=null&&r.type!=="device"){s.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),o(this,l,"unknown");return}let i=(D=e(this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(e(this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let a=yield e(this,A).call(this),t=yield w(this,u,B).call(this,i,a);if(t!=null&&(yield w(this,u,F).call(this,t))){e(this,n).setActiveSigner(t),o(this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,p),c)}catch(z){s.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=w(this,u,V).call(this,g,i),v=yield j(i,e(this,p));try{yield e(this,k).call(this,v)}catch(c){if(c instanceof I){s.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,p)),o(this,m,!0),o(this,l,"resolved"),yield w(this,u,$).call(this);return}else if(G(c))s.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof W||c instanceof Error&&c.name==="AuthRejectedError"?(s.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof E||c instanceof Error&&c.name==="OtpValidationError"?(s.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof E?c.code:void 0}),c):(s.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(e(this,p)),c)}let h=yield e(this,n).assemble({type:"device",locator:v.locator,address:e(this,p)});if(e(this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),s.info("wallet.recover.device.success",{signerLocator:v.locator}),o(this,l,"resolved"),S!=null)try{yield e(this,L).call(this,S),s.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){s.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return f(this,null,function*(){var S;let i=(S=e(this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(e(this,p));if(a!=null){r.locator=`device:${a}`,o(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(e(this,p),h),r.locator=v.locator,o(this,l,"unknown");return}}o(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(a=>(a=e(this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield M(e(this,C),r,e(this,p),i)}catch(g){return s.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return f(this,null,function*(){var a;if(e(this,n).isApprovedSignerStatus(r.status))return s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield w(this,u,q).call(this,r,i.pendingOperation),!0):e(this,n).isApprovedSignerStatus(r.status)?(s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return f(this,null,function*(){var h;let a=e(this,n).activeSigner,t=e(this,n).recovery;if(O(t)&&!e(this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=R(t.type),S=e(this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,S);e(this,n).setActiveSigner(T(e(this,C),v,(h=e(this,y))==null?void 0:h.deviceSignerKeyStorage));try{i.type==="signature"?yield e(this,K).call(this,i.id):yield e(this,P).call(this,i.id)}catch(D){throw e(this,n).setActiveSigner(r),D}finally{e(this,n).activeSigner!==r&&e(this,n).setActiveSigner(a)}r.status="success",s.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return f(this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return s.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return f(this,null,function*(){let r=e(this,n).recovery,i=R(r.type),a=e(this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);e(this,n).setActiveSigner(yield e(this,n).assemble(t,{isAdminSigner:!0}))}catch(t){s.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{N as a};
@@ -1 +1 @@
1
- import{a as o}from"./chunk-KOHPRJDP.js";import{a as i}from"./chunk-JNGPW247.js";import{b as c,c as l}from"./chunk-QU5AAJAW.js";import{h as n}from"./chunk-NU7VF7MC.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,ApiClientError as u,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:c}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return n(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;i.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let t=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in t?i.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&i.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return n(this,null,function*(){i.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?i.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&i.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return n(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 n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return n(this,null,function*(){let t=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return t.status===422?this.getSignature(e,s):t.json()})}getSignature(e,s){return n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return n(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 n(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return n(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 n(this,null,function*(){if(this.environment===d.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 n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return n(this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain),r.approver!=null&&a.append("approver",r.approver);let p=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(p,{headers:this.headers})).json()})}getSigner(e,s){return n(this,null,function*(){let r=encodeURIComponent(s),t=yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers});if(!t.ok){let a=null;try{a=yield t.text()}catch(p){}throw new u(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return n(this,null,function*(){i.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let a=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in a?i.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&i.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===g.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{h as a};
1
+ import{a as o}from"./chunk-KOHPRJDP.js";import{a as i}from"./chunk-AZAIXRGS.js";import{b as c,c as l}from"./chunk-FUZ2TPGD.js";import{h as n}from"./chunk-NU7VF7MC.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,ApiClientError as u,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:c}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return n(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;i.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let t=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in t?i.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&i.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return n(this,null,function*(){i.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?i.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&i.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return n(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 n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return n(this,null,function*(){let t=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return t.status===422?this.getSignature(e,s):t.json()})}getSignature(e,s){return n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return n(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 n(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return n(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 n(this,null,function*(){if(this.environment===d.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 n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return n(this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain),r.approver!=null&&a.append("approver",r.approver);let p=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(p,{headers:this.headers})).json()})}getSigner(e,s){return n(this,null,function*(){let r=encodeURIComponent(s),t=yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers});if(!t.ok){let a=null;try{a=yield t.text()}catch(p){}throw new u(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return n(this,null,function*(){i.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let a=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in a?i.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&i.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===g.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{h as a};
@@ -0,0 +1 @@
1
+ import{defineChain as o}from"viem";var c=o({id:11142220,name:"Celo Sepolia",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo-sepolia.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Sepolia Blockscout",url:"https://celo-sepolia.blockscout.com",apiUrl:"https://celo-sepolia.blockscout.com/api"}},testnet:!0});export{c as a};
@@ -0,0 +1 @@
1
+ import{defineChain as t}from"viem";var r=t({id:46630,name:"Robinhood Chain Testnet",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.testnet.chain.robinhood.com"]}},blockExplorers:{default:{name:"Robinhood Chain Testnet Explorer",url:"https://explorer.testnet.chain.robinhood.com",apiUrl:"https://explorer.testnet.chain.robinhood.com/api"}},testnet:!0});export{r as a};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-JNGPW247.js";var s={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw e.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}}};export{s as a};
1
+ import{a as e}from"./chunk-AZAIXRGS.js";var s={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw e.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}}};export{s as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk3L3U3TIDcjs = require('./chunk-3L3U3TID.cjs');var _chunkLXAEBSEYcjs = require('./chunk-LXAEBSEY.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunk3L3U3TIDcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk3L3U3TIDcjs.a.getOptions(e),alias:e.alias,recovery:_chunk3L3U3TIDcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunk3L3U3TIDcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunk3L3U3TIDcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk3L3U3TIDcjs.a.getInitialSigners(e)},_chunk3L3U3TIDcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,p;_chunkWIAIJCQ2cjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunkWIAIJCQ2cjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkLXAEBSEYcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkWIAIJCQ2cjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkVS6I4S7Xcjs.H)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkWIAIJCQ2cjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk63VNTHGQcjs = require('./chunk-63VNTHGQ.cjs');var _chunkLXAEBSEYcjs = require('./chunk-LXAEBSEY.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunk63VNTHGQcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk63VNTHGQcjs.a.getOptions(e),alias:e.alias,recovery:_chunk63VNTHGQcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunk63VNTHGQcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunk63VNTHGQcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk63VNTHGQcjs.a.getInitialSigners(e)},_chunk63VNTHGQcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,p;_chunkSP5DQZ6Dcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunkSP5DQZ6Dcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkLXAEBSEYcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkSP5DQZ6Dcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkVS6I4S7Xcjs.H)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkSP5DQZ6Dcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2G4Y25AJcjs = require('./chunk-2G4Y25AJ.cjs');var _chunk5L5MJAFScjs = require('./chunk-5L5MJAFS.cjs');var _chunkKVMPBMNGcjs = require('./chunk-KVMPBMNG.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var i={evm:_chunk2G4Y25AJcjs.a,solana:_chunk5L5MJAFScjs.a,stellar:_chunkKVMPBMNGcjs.a};function h(e){return i[_chunkENU3EKBGcjs.a.call(void 0, e)]}function g(e){return Object.prototype.hasOwnProperty.call(i,e)}exports.a = h; exports.b = g;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunk4MNSKZHWcjs = require('./chunk-4MNSKZHW.cjs');var _chunkN3HRM33Gcjs = require('./chunk-N3HRM33G.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,n);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,p,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,n,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(S){_chunkWIAIJCQ2cjs.a.error("wallet.initDeviceSigner.error",{error:S}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let a=_chunk4MNSKZHWcjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(a);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(t.status)||(_chunkWIAIJCQ2cjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunkWIAIJCQ2cjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunkWIAIJCQ2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunkWIAIJCQ2cjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,F).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunkWIAIJCQ2cjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,i,a);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,F).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),c)}catch(z){_chunkWIAIJCQ2cjs.a.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=_chunkDSIFRRBScjs.g.call(void 0, this,u,V).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,p));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(c){if(c instanceof _chunkVS6I4S7Xcjs.m){_chunkWIAIJCQ2cjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this);return}else if(G(c))_chunkWIAIJCQ2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof _chunkQPCZFIUVcjs.a||c instanceof Error&&c.name==="AuthRejectedError"?(_chunkWIAIJCQ2cjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof _chunkQPCZFIUVcjs.b||c instanceof Error&&c.name==="OtpValidationError"?(_chunkWIAIJCQ2cjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof _chunkQPCZFIUVcjs.b?c.code:void 0}),c):(_chunkWIAIJCQ2cjs.a.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),c)}let h=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)});if(_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),_chunkWIAIJCQ2cjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),S!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,S),_chunkWIAIJCQ2cjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){_chunkWIAIJCQ2cjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var S;let i=(S=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,p));if(a!=null){r.locator=`device:${a}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),h),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(a=>(a=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunkN3HRM33Gcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,p),i)}catch(g){return _chunkWIAIJCQ2cjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;if(_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status))return _chunkWIAIJCQ2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status)?(_chunkWIAIJCQ2cjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let a=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery;if(_chunkQPCZFIUVcjs.f.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunk4MNSKZHWcjs.a.call(void 0, t.type),S=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,S);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(_chunkN3HRM33Gcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(a)}r.status="success",_chunkWIAIJCQ2cjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunkWIAIJCQ2cjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery,i=_chunk4MNSKZHWcjs.a.call(void 0, r.type),a=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(t,{isAdminSigner:!0}))}catch(t){_chunkWIAIJCQ2cjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = N;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkYWN6HKW7cjs = require('./chunk-YWN6HKW7.cjs');var _chunk4R2UUYLCcjs = require('./chunk-4R2UUYLC.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkVS6I4S7Xcjs = require('./chunk-VS6I4S7X.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,p);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,n);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,p,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,n,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(S){_chunkSP5DQZ6Dcjs.a.error("wallet.initDeviceSigner.error",{error:S}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let a=_chunkYWN6HKW7cjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(a);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(t.status)||(_chunkSP5DQZ6Dcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunkSP5DQZ6Dcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunkSP5DQZ6Dcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunkSP5DQZ6Dcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,F).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunkSP5DQZ6Dcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,i,a);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,F).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),c)}catch(z){_chunkSP5DQZ6Dcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=_chunkDSIFRRBScjs.g.call(void 0, this,u,V).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,p));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(c){if(c instanceof _chunkVS6I4S7Xcjs.m){_chunkSP5DQZ6Dcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this);return}else if(G(c))_chunkSP5DQZ6Dcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof _chunkQPCZFIUVcjs.a||c instanceof Error&&c.name==="AuthRejectedError"?(_chunkSP5DQZ6Dcjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof _chunkQPCZFIUVcjs.b||c instanceof Error&&c.name==="OtpValidationError"?(_chunkSP5DQZ6Dcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof _chunkQPCZFIUVcjs.b?c.code:void 0}),c):(_chunkSP5DQZ6Dcjs.a.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,p)),c)}let h=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,p)});if(_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),_chunkSP5DQZ6Dcjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),S!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,S),_chunkSP5DQZ6Dcjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){_chunkSP5DQZ6Dcjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var S;let i=(S=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,p));if(a!=null){r.locator=`device:${a}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,p),h),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(a=>(a=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunk4R2UUYLCcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,p),i)}catch(g){return _chunkSP5DQZ6Dcjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;if(_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status))return _chunkSP5DQZ6Dcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,n).isApprovedSignerStatus(r.status)?(_chunkSP5DQZ6Dcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let a=_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery;if(_chunkQPCZFIUVcjs.f.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkYWN6HKW7cjs.a.call(void 0, t.type),S=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,S);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(_chunk4R2UUYLCcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,n).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(a)}r.status="success",_chunkSP5DQZ6Dcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunkSP5DQZ6Dcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,n).recovery,i=_chunkYWN6HKW7cjs.a.call(void 0, r.type),a=_chunkDSIFRRBScjs.d.call(void 0, this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);_chunkDSIFRRBScjs.d.call(void 0, this,n).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,n).assemble(t,{isAdminSigner:!0}))}catch(t){_chunkSP5DQZ6Dcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = N;
@@ -1 +1 @@
1
- import{a as g,b as c}from"./chunk-S6MOVJXB.js";import{a as s}from"./chunk-JNGPW247.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import o from"bs58";var d=class y extends g{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(o.decode(e))})}signTransaction(e){return t(this,null,function*(){let i=o.decode(e),r=u.deserialize(i);return yield this.sign(r.message.serialize())})}sign(e){return t(this,null,function*(){var a;yield this.handleAuthRequired();let i=this.getJwtOrThrow();s.info("sign: sending request",{keyType:"ed25519"});let r=Date.now(),n=yield(a=this.config.clientTEEConnection)==null?void 0:a.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:o.encode(new Uint8Array(e)),encoding:"base58"}},options:c});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-r}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign payload");return y.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{d as a};
1
+ import{a as g,b as c}from"./chunk-A7DA5DSE.js";import{a as s}from"./chunk-AZAIXRGS.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import o from"bs58";var d=class y extends g{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(o.decode(e))})}signTransaction(e){return t(this,null,function*(){let i=o.decode(e),r=u.deserialize(i);return yield this.sign(r.message.serialize())})}sign(e){return t(this,null,function*(){var a;yield this.handleAuthRequired();let i=this.getJwtOrThrow();s.info("sign: sending request",{keyType:"ed25519"});let r=Date.now(),n=yield(a=this.config.clientTEEConnection)==null?void 0:a.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:o.encode(new Uint8Array(e)),encoding:"base58"}},options:c});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-r}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign payload");return y.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{d as a};
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.16.0";var c="WALLETS_SDK",r=t,a=s,d=200;export{c as a,r as b,a as c,d};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD6BFMPZAcjs = require('./chunk-D6BFMPZA.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=_chunkD6BFMPZAcjs.a.call(void 0, s).balanceTokenFields(n);return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=_chunkD6BFMPZAcjs.a.call(void 0, s).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=_chunkENU3EKBGcjs.a.call(void 0, n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function T(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD5IIHIEWcjs = require('./chunk-D5IIHIEW.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=_chunkD5IIHIEWcjs.a.call(void 0, s).balanceTokenFields(n);return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=_chunkD5IIHIEWcjs.a.call(void 0, s).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=_chunkENU3EKBGcjs.a.call(void 0, n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function T(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}exports.a = T;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3TJEBF5Ucjs = require('./chunk-3TJEBF5U.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunk3TJEBF5Ucjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkWIAIJCQ2cjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunk3TJEBF5Ucjs.b});if(_chunkWIAIJCQ2cjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZHGXG7JMcjs = require('./chunk-ZHGXG7JM.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkZHGXG7JMcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkSP5DQZ6Dcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkZHGXG7JMcjs.b});if(_chunkSP5DQZ6Dcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk3TJEBF5Ucjs = require('./chunk-3TJEBF5U.cjs');var _chunkWIAIJCQ2cjs = require('./chunk-WIAIJCQ2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var d=class y extends _chunk3TJEBF5Ucjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(_bs582.default.decode(e))})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_bs582.default.decode(e),r=_web3js.VersionedTransaction.deserialize(i);return yield this.sign(r.message.serialize())})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;yield this.handleAuthRequired();let i=this.getJwtOrThrow();_chunkWIAIJCQ2cjs.a.info("sign: sending request",{keyType:"ed25519"});let r=Date.now(),n=yield(a=this.config.clientTEEConnection)==null?void 0:a.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(e)),encoding:"base58"}},options:_chunk3TJEBF5Ucjs.b});if(_chunkWIAIJCQ2cjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-r}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign payload");return y.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkZHGXG7JMcjs = require('./chunk-ZHGXG7JM.cjs');var _chunkSP5DQZ6Dcjs = require('./chunk-SP5DQZ6D.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var d=class y extends _chunkZHGXG7JMcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(_bs582.default.decode(e))})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_bs582.default.decode(e),r=_web3js.VersionedTransaction.deserialize(i);return yield this.sign(r.message.serialize())})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;yield this.handleAuthRequired();let i=this.getJwtOrThrow();_chunkSP5DQZ6Dcjs.a.info("sign: sending request",{keyType:"ed25519"});let r=Date.now(),n=yield(a=this.config.clientTEEConnection)==null?void 0:a.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(e)),encoding:"base58"}},options:_chunkZHGXG7JMcjs.b});if(_chunkSP5DQZ6Dcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-r}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign payload");return y.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = d;