@dcl/shop 0.1.0-30612955316.commit-0d9b744 → 0.1.0-30633401379.commit-5cd1c31

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 (178) hide show
  1. package/assets/Activity-BHKoZZp5.js +291 -0
  2. package/assets/{AnimatedBackground-DTgtqP8R.js → AnimatedBackground-BlD5oHcR.js} +2 -2
  3. package/assets/{Assets-B9KXwYG0.js → Assets-DUKvbfgo.js} +7 -7
  4. package/assets/{Assets.styles-Dm_MgfhY.js → Assets.styles-BLCNmjO6.js} +1 -1
  5. package/assets/{Authorizations--gatNHIW.js → Authorizations-6n5FWz0U.js} +1 -1
  6. package/assets/Cart-D7ktjzZK.js +695 -0
  7. package/assets/{CircularProgress-BRaMu2HF.js → CircularProgress-CMZVAt1l.js} +1 -1
  8. package/assets/{Collection-BIR5xrVe.js → Collection-CQps3SAa.js} +1 -1
  9. package/assets/{CollectionCarousel-oh8d08gi.js → CollectionCarousel-CrTrsXB-.js} +1 -1
  10. package/assets/{Creator-jKJMNfvf.js → Creator-DeBO0_hP.js} +2 -2
  11. package/assets/{ErrorNotice-C2qBxBzo.js → ErrorNotice-DwhdhAu6.js} +1 -1
  12. package/assets/{ExchangeController-BJ20Rri0.js → ExchangeController-DFaPYxag.js} +1 -1
  13. package/assets/{GetCredits-DWkdHCSk.js → GetCredits-CH0SxGoe.js} +8 -8
  14. package/assets/{HelpersUtil-Bc_-rYa4.js → HelpersUtil-CGxvruiS.js} +1 -1
  15. package/assets/{ImportListings-C61E-WD4.js → ImportListings-D3Q-MYHt.js} +8 -8
  16. package/assets/{ItemDetail-BFNeFxLh.js → ItemDetail-grsXVByw.js} +3 -3
  17. package/assets/{LoadMore-BI2cyij4.js → LoadMore-CVBNO6CV.js} +1 -1
  18. package/assets/{MenuList-CsoSKANx.js → MenuList-D5vC383J.js} +1 -1
  19. package/assets/{MyAssets-B8jlwAvA.js → MyAssets-B4-suVif.js} +1 -1
  20. package/assets/{MyFavorites-B6kCgq1h.js → MyFavorites-rQde9LEq.js} +1 -1
  21. package/assets/{NotFound-CWtlpg63.js → NotFound-CICAlcY2.js} +1 -1
  22. package/assets/{NotificationsBell-wPKuEs_b.js → NotificationsBell-BcUtKYE_.js} +1 -1
  23. package/assets/{StoreSettings-BW2EY9gn.js → StoreSettings-D-p-KMUm.js} +1 -1
  24. package/assets/Success-CKUShs2s.js +276 -0
  25. package/assets/{SwapController-DHr7xvAI.js → SwapController-BqpEkXCy.js} +1 -1
  26. package/assets/{Tooltip-DFmfpHxa.js → Tooltip-v8d4_GhH.js} +1 -1
  27. package/assets/{TradeService-BxS-ssTi.js → TradeService-CMvEMasH.js} +1 -1
  28. package/assets/{W3MFrameProviderSingleton-D3RatyJZ.js → W3MFrameProviderSingleton-MrB8u6EW.js} +3 -3
  29. package/assets/{WebCryptoP256-DLlMYv1t.js → WebCryptoP256-CP0xBKi2.js} +1 -1
  30. package/assets/{authorizations-BrAVsIY_.js → authorizations-uQp0Tner.js} +1 -1
  31. package/assets/{basic-B1iPuZqz.js → basic-B_OSMlWi.js} +1 -1
  32. package/assets/{biconomy-CReC5_o1.js → biconomy-DrNdbDOV.js} +1 -1
  33. package/assets/{browseLayout.styles-Ck-h2OX5.js → browseLayout.styles-B5gAAnD7.js} +5 -5
  34. package/assets/{builder-BW_vsdgs.js → builder-BH8bW8w3.js} +1 -1
  35. package/assets/buy-DI2htlf2.js +1 -0
  36. package/assets/{buy-gasless-DoEdxK3L.js → buy-gasless-D3ucK012.js} +1 -1
  37. package/assets/{categories-P1zgLmzy.js → categories-CUWn-vWY.js} +1 -1
  38. package/assets/{ccip-BHjcKqJV.js → ccip-D4QJIvrM.js} +1 -1
  39. package/assets/{ccip-CZBbVQi3.js → ccip-zHeTh1U3.js} +1 -1
  40. package/assets/{clsx-DhFqZi_3.js → clsx-C78Se7VZ.js} +2 -2
  41. package/assets/{controller-DGy85CgR.js → controller-BICwQmay.js} +2 -2
  42. package/assets/{core-Db5S1VHS.js → core-BpePoapT.js} +4 -4
  43. package/assets/{createSvgIcon-DLpGC0um.js → createSvgIcon-D6bh0MrS.js} +3 -3
  44. package/assets/{custom-ClweN61f.js → custom-DIlU15wg.js} +1 -1
  45. package/assets/{data-capture-z84EsTtU.js → data-capture-DF5W_J8T.js} +1 -1
  46. package/assets/{email-CcLkWyvu.js → email-CLMX01kZ.js} +1 -1
  47. package/assets/{embedded-wallet-COy2jXd-.js → embedded-wallet-CbYQTubx.js} +1 -1
  48. package/assets/{emotion-styled.browser.esm-Bl0xNQms.js → emotion-styled.browser.esm-uimCutsp.js} +1 -1
  49. package/assets/{engine-D5VFTt2U.js → engine-Bobn5NnI.js} +1 -1
  50. package/assets/{errors-D660SWgT.js → errors-BHapDldI.js} +1 -1
  51. package/assets/{estimate-l1-fee-D0AZXU9d.js → estimate-l1-fee-Zo4D8zNV.js} +1 -1
  52. package/assets/{execute-B7xe5F3I.js → execute-B3koRsQT.js} +2 -2
  53. package/assets/{features-CDbo6Rgb.js → features-29eUittk.js} +1 -1
  54. package/assets/{fetchTokenMetadata-CTdt9CEd.js → fetchTokenMetadata-BVVFFsly.js} +2 -2
  55. package/assets/{get-ecosystem-wallet-info-DSZkSx4X.js → get-ecosystem-wallet-info-Fbs6oNmw.js} +1 -1
  56. package/assets/{getBalance-BDX5XOeM.js → getBalance-BynOYuPH.js} +1 -1
  57. package/assets/{getNFT-CVs2H6Tl.js → getNFT-C7BU-05F.js} +1 -1
  58. package/assets/{getNFT-DINbSeyy.js → getNFT-CHPhy1te.js} +1 -1
  59. package/assets/{getThemeProps-CGtqDWEq.js → getThemeProps-BCb3jyqf.js} +1 -1
  60. package/assets/{grid.styles-D4B-EHGj.js → grid.styles-CFlLjGWA.js} +1 -1
  61. package/assets/{hashTypedData-Dz79Rf5q.js → hashTypedData-BmEKHoZL.js} +1 -1
  62. package/assets/{hashTypedData-B7lV4LZj.js → hashTypedData-CixGH523.js} +1 -1
  63. package/assets/{import-DSm0v4af.js → import-xE4hDmDm.js} +1 -1
  64. package/assets/{in-app-C5pWpM6r.js → in-app-BcKmOV8m.js} +1 -1
  65. package/assets/{in-app-wallet-calls-DXx7lWeR.js → in-app-wallet-calls-BI1PaW_x.js} +1 -1
  66. package/assets/{index-ODLNljC7.js → index-9WfG_CLW.js} +1 -1
  67. package/assets/{index-CJgXTNhS.js → index-ASq7s2Iv.js} +2 -2
  68. package/assets/{index-BobbFiKW.js → index-B0eTctvC.js} +1 -1
  69. package/assets/{index-D7R57an8.js → index-B439DG-9.js} +2 -2
  70. package/assets/{index-BZocXWA4.js → index-BAORCNZn.js} +1 -1
  71. package/assets/{index-G1xB9dvf.js → index-BFzvJeyM.js} +1 -1
  72. package/assets/{index-Cl-v7TvL.js → index-BHVh9ZD-.js} +1 -1
  73. package/assets/{index-yJi2QIJf.js → index-BMIuNfCB.js} +252 -252
  74. package/assets/{index-CZTqkynu.js → index-BTOrBWcS.js} +1 -1
  75. package/assets/{index-b_a6Xe2g.js → index-BUo3wAlN.js} +3 -3
  76. package/assets/{index-1koyBXBc.js → index-Bb9TuCMN.js} +1 -1
  77. package/assets/{index-B81PeozV.js → index-BdDw5syJ.js} +1 -1
  78. package/assets/{index-xZ3i_Adn.js → index-Bdx6vg6T.js} +1 -1
  79. package/assets/{index-tdQJ2A6x.js → index-Bler0kM4.js} +1 -1
  80. package/assets/{index-3ZTohoUZ.js → index-C7EZCMfv.js} +1 -1
  81. package/assets/{index-BBkUTtNV.js → index-CG3EVA6i.js} +2 -2
  82. package/assets/{index-P_XHlb3T.js → index-CP0MJS3n.js} +1 -1
  83. package/assets/{index-frQRdZ2q.js → index-CSzz0-yL.js} +1 -1
  84. package/assets/{index-BFSsZJPW.js → index-CY9EBgzo.js} +1 -1
  85. package/assets/{index-DiOmLLPI.js → index-CgOcSf2Q.js} +1 -1
  86. package/assets/{index-CdsKR_zs.js → index-CkfB4xYf.js} +1 -1
  87. package/assets/{index-CZ1tNVf6.js → index-CpKxcKSt.js} +1 -1
  88. package/assets/{index-B8zb5Fyq.js → index-CsCFxm9l.js} +1 -1
  89. package/assets/{index-DZg10nMY.js → index-CugdcJ5p.js} +1 -1
  90. package/assets/{index-gKwUmrp3.js → index-CvuWb2er.js} +1 -1
  91. package/assets/{index-BgoikptS.js → index-D-jdrajA.js} +1 -1
  92. package/assets/{index-DfTLbDYm.js → index-D6z3Iok7.js} +1 -1
  93. package/assets/{index-DQ2sE8uD.js → index-DA1IdQid.js} +1 -1
  94. package/assets/{index-DMjEzVVJ.js → index-DCUYsq3Z.js} +1 -1
  95. package/assets/{index-1c_qW8yi.js → index-DI-G5L8D.js} +1 -1
  96. package/assets/{index-C0LSKXhw.js → index-DJGQazF5.js} +1 -1
  97. package/assets/{index-C0odNd_G.js → index-DNLfbOQJ.js} +1 -1
  98. package/assets/{index-CuPPMOVj.js → index-DfVobYmm.js} +1 -1
  99. package/assets/{index-C-C5pEJc.js → index-DmnyvmGd.js} +1 -1
  100. package/assets/{index-CpqhaC2H.js → index-DpjOr79p.js} +1 -1
  101. package/assets/{index-DjbRx8bI.js → index-DzCJVhsv.js} +1 -1
  102. package/assets/{index-CXntdDwE.js → index-Eco3bQ72.js} +2 -2
  103. package/assets/{index-CwVjvkdk.js → index-FvB9JTSh.js} +1 -1
  104. package/assets/{index-DU8_EWWx.js → index-H02HAhZo.js} +1 -1
  105. package/assets/{index-CzByZQWv.js → index-LL0BV6rh.js} +1 -1
  106. package/assets/{index-CLBmEx6A.js → index-MsJgZMgr.js} +3 -3
  107. package/assets/{index-Dr4K4hFL.js → index-R3pS6x6y.js} +3 -3
  108. package/assets/{index-CX5Ekh69.js → index-dXYc2QRl.js} +1 -1
  109. package/assets/{index-CkBDyoGg.js → index-hwCoxi9L.js} +1 -1
  110. package/assets/{index-BJ-25Q5l.js → index-ldblNYIT.js} +1 -1
  111. package/assets/{index-CbITlqFn.js → index-n-ShiY2h.js} +1 -1
  112. package/assets/{index-DIR4uPmO.js → index-oFYHMIzO.js} +1 -1
  113. package/assets/{index-Cw6mXTIQ.js → index-rFh28dtY.js} +1 -1
  114. package/assets/{index-CKEG3W2m.js → index-wfubccp5.js} +1 -1
  115. package/assets/{index-Dw4Gh8Hk.js → index-wnx7vlu-.js} +2 -2
  116. package/assets/{index-NPIY1Vbs.js → index-xk15qzPN.js} +1 -1
  117. package/assets/{index.es-CdLNKigl.js → index.es-BEVmNmLD.js} +4 -4
  118. package/assets/{index.es-CZz1nBev.js → index.es-BPA6fTzR.js} +1 -1
  119. package/assets/{index.es-CeoIh9-h.js → index.es-BW6RduBG.js} +1 -1
  120. package/assets/{localBatchGatewayRequest-Dbz593U8.js → localBatchGatewayRequest-C2eNLm--.js} +1 -1
  121. package/assets/{mana-convert-DTic_WF4.js → mana-convert-C341n1xm.js} +1 -1
  122. package/assets/{mana-rate-DTd_zYK_.js → mana-rate-BAPBwbaG.js} +1 -1
  123. package/assets/{networks-D-WgnPJO.js → networks-gEGHz8eL.js} +1 -1
  124. package/assets/{onramp-CxZE_awn.js → onramp-DHcILVIp.js} +1 -1
  125. package/assets/{openzeppelin-BicG6fZ-.js → openzeppelin-BvSgRich.js} +1 -1
  126. package/assets/{parseNft-crNNmDcM.js → parseNft-DrAu-xVe.js} +2 -2
  127. package/assets/{parseSignature-xro4_AeM.js → parseSignature--WNVOXAe.js} +3 -3
  128. package/assets/{parseSignature-TUf4MZpE.js → parseSignature-BlmIeeL7.js} +1 -1
  129. package/assets/{passkeys-DlsWo5hj.js → passkeys-BD41PpMD.js} +1 -1
  130. package/assets/{pay-with-exchange-uJFVzJz2.js → pay-with-exchange-DCmtfnr1.js} +1 -1
  131. package/assets/{qr-overlay-D1DRCZeg.js → qr-overlay-DYViFXBB.js} +1 -1
  132. package/assets/{receive-jEtfcBkz.js → receive-LPMbYHZa.js} +1 -1
  133. package/assets/{resolveImplementation-Dfr_x2D4.js → resolveImplementation-CdVPuboc.js} +1 -1
  134. package/assets/{rpc-HxGwRhjl.js → rpc-D2C2velX.js} +1 -1
  135. package/assets/{secp256k1-BeCdbOwL.js → secp256k1-DLPIWcy9.js} +1 -1
  136. package/assets/{secp256k1-Bmo0zLoN.js → secp256k1-DtCfsIY0.js} +1 -1
  137. package/assets/{secp256k1-CPsxfMTn.js → secp256k1-KqMjq-B-.js} +1 -1
  138. package/assets/{send-SCYWhWgO.js → send-BYANl3m1.js} +1 -1
  139. package/assets/{send-batch-transaction-ClJpcx_r.js → send-batch-transaction-BHqPVqqQ.js} +1 -1
  140. package/assets/{send-eip712-transaction-DCKQGfPC.js → send-eip712-transaction-D3zsFnZJ.js} +2 -2
  141. package/assets/{send-gasless-transaction-C6PqTuT4.js → send-gasless-transaction-Db4a0n6K.js} +2 -2
  142. package/assets/{send-transaction-DCRA_QBx.js → send-transaction-0fPTuVE4.js} +2 -2
  143. package/assets/{sendMetaTransaction-BOtIj1YL.js → sendMetaTransaction-DAsHliEn.js} +1 -1
  144. package/assets/{sendRawTransaction-BkrUK6tH.js → sendRawTransaction-B5IMe5Y5.js} +3 -3
  145. package/assets/{serializeTransaction-bVNzq6Wv.js → serializeTransaction-BT9LeH0D.js} +1 -1
  146. package/assets/{session-proposal-BwFRVt7g.js → session-proposal-plO_EjqI.js} +1 -1
  147. package/assets/{session-request-4TbdsxSC.js → session-request-DTauixOT.js} +2 -2
  148. package/assets/{signing-BxAbixw6.js → signing-BKT41maQ.js} +3 -3
  149. package/assets/{socials-B5zVEegD.js → socials-BPcwRKMp.js} +1 -1
  150. package/assets/{swaps-DQ1LcBTU.js → swaps-DddX0hWZ.js} +1 -1
  151. package/assets/{thirdweb-r2nvH1Ph.js → thirdweb-DI1D_9ce.js} +3 -3
  152. package/assets/{to-serializable-transaction-DMc2E6fk.js → to-serializable-transaction-BZX746C8.js} +2 -2
  153. package/assets/trade-encoding-CK5EArKF.js +1 -0
  154. package/assets/{transactionReceipt-DFdTIN3F.js → transactionReceipt-2D5Q3zvv.js} +1 -1
  155. package/assets/{transactions-DnRd57Kk.js → transactions-DtbDwrsO.js} +1 -1
  156. package/assets/useCreditPacks-Dw0jIjQE.js +1 -0
  157. package/assets/{useInfiniteGrid-CDkGdzFf.js → useInfiniteGrid-Xjfvrq_T.js} +1 -1
  158. package/assets/useManaRate-BEVwu7Q9.js +1 -0
  159. package/assets/{useSecondarySales-BLnZD7gi.js → useSecondarySales-bajhgse5.js} +1 -1
  160. package/assets/{useStore-Dt337zVA.js → useStore-CIqjcPjh.js} +1 -1
  161. package/assets/{useTheme-DlRIY8zD.js → useTheme-DVSXpYGO.js} +1 -1
  162. package/assets/{verifyHash-D8nhWUT9.js → verifyHash-DmL5gbPk.js} +1 -1
  163. package/assets/{w3m-modal-Z-IBP9yL.js → w3m-modal-B2N-eyv6.js} +1 -1
  164. package/assets/{w3m-modal-D1mPkWGM.js → w3m-modal-CfZXCvPG.js} +1 -1
  165. package/assets/{wait-for-tx-receipt-8bgpdxSo.js → wait-for-tx-receipt-BEDrW5cD.js} +1 -1
  166. package/assets/{wallets-BTh4qQ9L.js → wallets-DQk0dtw_.js} +5 -5
  167. package/assets/{web-connector-DXtL7d_s.js → web-connector-2N1NjIJ4.js} +3 -3
  168. package/assets/{writeContract-B7vnLdJy.js → writeContract-BZemjhP4.js} +1 -1
  169. package/assets/{zoraTestnet-kFdaoH4G.js → zoraTestnet-BK5x9nJO.js} +1 -1
  170. package/index.html +11 -11
  171. package/package.json +2 -2
  172. package/assets/Activity-BF3WNwMh.js +0 -291
  173. package/assets/Cart-Cs0FD0IN.js +0 -695
  174. package/assets/Success-CTKJzQjE.js +0 -276
  175. package/assets/buy-DLi3_94e.js +0 -1
  176. package/assets/trade-encoding-BFXwI1r3.js +0 -1
  177. package/assets/useCreditPacks-DnQLmQo7.js +0 -1
  178. package/assets/useManaRate-DwO6H8fK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as t,L as le,b as ce,r as l}from"./react-vyZjIDcS.js";import{t as b,s as a,e as s,x as de,B as K,m as pe,n as ue,E as ge,I as N,F as A}from"./index-yJi2QIJf.js";import{u as xe,d as me,t as he,L as fe,i as M,a as f,s as ve}from"./useStore-Dt337zVA.js";import{E as O}from"./ErrorNotice-C2qBxBzo.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const be="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/template-cover-1-BETekfHg.jpeg",we="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/template-cover-2-Dni9s0i_.jpeg",je=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":be,"../assets/creator-covers/template-cover-2.jpeg":we}),v=Object.entries(je).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),{colors:L}=b,j=a.div`
1
+ import{j as t,L as le,b as ce,r as l}from"./react-vyZjIDcS.js";import{t as b,s as a,e as s,x as de,B as K,m as pe,n as ue,E as ge,I as N,F as A}from"./index-BMIuNfCB.js";import{u as xe,d as me,t as he,L as fe,i as M,a as f,s as ve}from"./useStore-CIqjcPjh.js";import{E as O}from"./ErrorNotice-DwhdhAu6.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const be="https://cdn.decentraland.org/@dcl/shop/0.1.0-30633401379.commit-5cd1c31/assets/template-cover-1-BETekfHg.jpeg",we="https://cdn.decentraland.org/@dcl/shop/0.1.0-30633401379.commit-5cd1c31/assets/template-cover-2-Dni9s0i_.jpeg",je=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":be,"../assets/creator-covers/template-cover-2.jpeg":we}),v=Object.entries(je).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),{colors:L}=b,j=a.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 6px;
@@ -0,0 +1,276 @@
1
+ import{a as T,b as E,j as e,N,r as A}from"./react-vyZjIDcS.js";import{t as P,s as t,z as B,G as F,H as M,n as W,m as O,e as n,y as _,h as q,J as H,c as L,B as J,K as U}from"./index-BMIuNfCB.js";import{w as D,S as K}from"./buy-gasless-D3ucK012.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./authorizations-uQp0Tner.js";import"./sendMetaTransaction-DAsHliEn.js";import"./trade-encoding-CK5EArKF.js";const{colors:s,radius:u}=P,g="@media (max-width: 600px)",z=t.div`
2
+ max-width: 895px;
3
+ margin: 0 auto;
4
+ padding: 32px 12px;
5
+ min-height: 72vh;
6
+ `,X=t.div`
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ text-align: center;
11
+ justify-content: center;
12
+ min-height: 60vh;
13
+ `,G=t.span`
14
+ margin: 4px auto 8px;
15
+ width: 40px;
16
+ height: 40px;
17
+ `,v=t.h1`
18
+ font-size: clamp(30px, 4vw, 42px);
19
+ font-weight: 800;
20
+ letter-spacing: -0.02em;
21
+ margin: 20px 0 8px;
22
+ `,k=t.p`
23
+ font-size: 18px;
24
+ color: #4b4b57;
25
+ margin: 0 0 22px;
26
+ `,w=t.div`
27
+ display: flex;
28
+ gap: 18px;
29
+ justify-content: center;
30
+ margin: 0 0 20px;
31
+
32
+ &[data-receipt] {
33
+ justify-content: flex-end;
34
+ margin: 0;
35
+ }
36
+ `,Q=t.a`
37
+ display: inline-block;
38
+ margin: 0;
39
+ color: ${s.accent};
40
+ font-weight: 600;
41
+ font-size: 14px;
42
+ text-decoration: none;
43
+ `,S=t.div`
44
+ display: flex;
45
+ gap: 12px;
46
+ flex-wrap: wrap;
47
+ justify-content: center;
48
+ `,Y=t.div`
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 12px;
52
+ width: 100%;
53
+ `,V=t.div`
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ gap: 16px;
58
+ padding: 24px 16px;
59
+ background: #e0f7e7;
60
+ border: 1px solid #34ce77;
61
+ border-radius: 16px;
62
+ `,Z=t.span`
63
+ flex-shrink: 0;
64
+ width: 60px;
65
+ height: 60px;
66
+ line-height: 0;
67
+ `,ee=t.p`
68
+ flex: 1;
69
+ margin: 0;
70
+ text-align: center;
71
+ font-size: 20px;
72
+ line-height: 1.334;
73
+ color: ${s.text2};
74
+
75
+ & b {
76
+ font-weight: 700;
77
+ }
78
+ `,te=t.div`
79
+ display: flex;
80
+ flex-direction: column;
81
+ padding: 24px;
82
+ background: ${s.white};
83
+ border: 1px solid ${s.gray4};
84
+ border-radius: 16px;
85
+ `,ne=t.div`
86
+ display: flex;
87
+ flex-direction: column;
88
+ `,ie=t.span`
89
+ display: block;
90
+ height: 1px;
91
+ margin: 12px 0;
92
+ background: ${s.gray4};
93
+ `,se=t.div`
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ gap: 8px;
98
+ min-height: 109px;
99
+ margin-bottom: 12px;
100
+ padding: 8px 24px;
101
+ border-radius: ${u.btn};
102
+ background: #f4e9ff;
103
+ color: ${s.text};
104
+ `,re=t(B)`
105
+ width: 30px;
106
+ height: 30px;
107
+ color: ${s.text};
108
+ `,ce=t.p`
109
+ display: inline-flex;
110
+ align-items: baseline;
111
+ gap: 6px;
112
+ margin: 0;
113
+ `,oe=t.span`
114
+ font-size: 24px;
115
+ font-weight: 700;
116
+ text-transform: capitalize;
117
+ `,ae=t.span`
118
+ font-size: 14px;
119
+ font-weight: 400;
120
+ `,de=t.div`
121
+ display: flex;
122
+ align-items: center;
123
+ gap: 12px;
124
+ `,le=t.div`
125
+ position: relative;
126
+ flex-shrink: 0;
127
+ width: 137px;
128
+ height: 137px;
129
+ display: flex;
130
+ align-items: center;
131
+ justify-content: center;
132
+ background: ${s.media};
133
+ border: 0.134px solid ${s.muted2};
134
+ border-radius: ${u.btn};
135
+ overflow: hidden;
136
+
137
+ & img {
138
+ width: 83%;
139
+ height: 83%;
140
+ object-fit: contain;
141
+ filter: drop-shadow(0.56px 2.24px 2.8px rgba(0, 0, 0, 0.1));
142
+ }
143
+
144
+ ${g} {
145
+ width: 96px;
146
+ height: 96px;
147
+ }
148
+ `,xe=t.span`
149
+ position: absolute;
150
+ top: 8px;
151
+ left: 8px;
152
+ width: 20px;
153
+ height: 20px;
154
+ display: flex;
155
+ align-items: center;
156
+ justify-content: center;
157
+ background: ${s.dclRed};
158
+ border-radius: ${u.chip};
159
+ line-height: 0;
160
+ `,pe=t.div`
161
+ flex: 1;
162
+ min-width: 0;
163
+ display: flex;
164
+ flex-direction: column;
165
+ gap: 2px;
166
+ padding: 8px;
167
+ `,he=t.div`
168
+ font-weight: 600;
169
+ font-size: 20px;
170
+ line-height: 1.57;
171
+ color: ${s.text};
172
+ overflow: hidden;
173
+ text-overflow: ellipsis;
174
+ white-space: nowrap;
175
+
176
+ ${g} {
177
+ font-size: 16px;
178
+ }
179
+ `,ue=t.span`
180
+ margin-left: 8px;
181
+ font-weight: 600;
182
+ font-size: 13px;
183
+ color: ${s.muted};
184
+ `,ge=t(F)`
185
+ position: relative;
186
+ z-index: 1;
187
+ color: ${s.muted};
188
+ font-size: 10px;
189
+
190
+ & [data-avatar] {
191
+ display: none;
192
+ }
193
+ `,fe=t.div`
194
+ flex-shrink: 0;
195
+ display: flex;
196
+ align-items: center;
197
+ gap: 4px;
198
+ padding: 8px;
199
+ font-weight: 600;
200
+ font-size: 21px;
201
+ color: ${s.text2};
202
+ white-space: nowrap;
203
+
204
+ ${g} {
205
+ font-size: 18px;
206
+ }
207
+ `,me=t(B)`
208
+ width: 22px;
209
+ height: 22px;
210
+ `,je=t.div`
211
+ display: flex;
212
+ gap: 12px;
213
+ align-items: center;
214
+ justify-content: flex-end;
215
+
216
+ ${g} {
217
+ flex-direction: column-reverse;
218
+ }
219
+ `,I=M`
220
+ flex: 1;
221
+ min-width: 0;
222
+ height: 48px;
223
+ display: inline-flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ gap: 12px;
227
+ padding: 0 24px;
228
+ border-radius: ${u.btn};
229
+ font-weight: 600;
230
+ font-size: 15px;
231
+ letter-spacing: 0.04em;
232
+ text-transform: uppercase;
233
+ text-decoration: none;
234
+ cursor: pointer;
235
+ transition:
236
+ filter 0.15s ease,
237
+ background 0.15s ease;
238
+
239
+ &[data-variant='ghost'] {
240
+ background: transparent;
241
+ border: 2px solid ${s.accent};
242
+ color: ${s.accent};
243
+ }
244
+ &[data-variant='ghost']:hover {
245
+ background: rgba(105, 31, 169, 0.06);
246
+ }
247
+ &[data-variant='ruby'] {
248
+ background: ${s.dclRed};
249
+ border: 0;
250
+ color: ${s.softWhite};
251
+ }
252
+ &[data-variant='ruby']:hover {
253
+ filter: brightness(0.95);
254
+ }
255
+
256
+ ${g} {
257
+ width: 100%;
258
+ flex: none;
259
+ }
260
+ `,we=t.button`
261
+ ${I};
262
+ `,ye=t.a`
263
+ ${I};
264
+ `,be=t.span`
265
+ display: inline-flex;
266
+ align-items: center;
267
+ justify-content: center;
268
+ width: 32px;
269
+ height: 32px;
270
+ border: 2.5px solid rgba(252, 252, 252, 0.5);
271
+ border-radius: ${u.btn};
272
+ line-height: 0;
273
+ `,$=t(J)`
274
+ min-width: 160px;
275
+ text-align: center;
276
+ `,ve=i=>new Promise(r=>setTimeout(r,i));function ke(i,r){const[l,a]=A.useState(i?"pending":"confirmed"),f=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return A.useEffect(()=>{if(!i)return;let d=!1;return(async()=>{let m=!1;for(let c=0;c<20&&!d;c++)try{await D(i,{timeoutMs:15e3}),m=!0;break}catch(p){if(p instanceof K)continue;d||a("failed");return}if(!d){if(!m){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let c=0;c<40&&!d;c++){if(await U(r.owner,r.contractAddress,r.itemId)){d||a("confirmed");return}await ve(3e3)}d||a("timed-out")}})(),()=>{d=!0}},[i,f]),l}const $e=L.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Ce=L.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Fe(){var R;const{state:i}=T(),r=E(),{session:l}=W(),a=i==null?void 0:i.txHash,f=(i==null?void 0:i.items)??[],d=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,x=f[0],m=l!=null&&l.address&&(x!=null&&x.contractAddress)&&(x!=null&&x.itemId)?{owner:l.address,contractAddress:x.contractAddress,itemId:x.itemId}:null,c=ke(i!=null&&i.settled?void 0:a,m);O({title:n("seo.success.title"),noindex:!0});const p=f;if(p.length===0)return e.jsx(N,{to:"/assets",replace:!0});const C=p[0],j=(R=i==null?void 0:i.txHashes)!=null&&R.length?i.txHashes:a?[a]:[],h=j.length>0&&_(l==null?void 0:l.providerType)?j.map((o,y)=>e.jsx(Q,{href:`${Ce}${o}`,target:"_blank",rel:"noreferrer",children:j.length>1?n("success.viewTransactionNumbered",{n:y+1,total:j.length}):n("success.viewTransaction")},o)):null;return c!=="confirmed"?e.jsx(z,{children:e.jsx(X,{children:c==="pending"||c==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"spinner","aria-hidden":!0}),e.jsx(v,{children:c==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(k,{children:c==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",p.length===1?e.jsx("strong",{children:C.name}):n("success.itemCount",{count:p.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",p.length===1?e.jsx("strong",{children:C.name}):n("success.itemCount",{count:p.length})," ",n("success.confirmingAfter")]})}),h?e.jsx(w,{children:h}):null]}):c==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(v,{children:n("success.stillProcessingTitle")}),e.jsxs(k,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>r("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),h?e.jsx(w,{children:h}):null,e.jsxs(S,{children:[e.jsx($,{variant:"purple",onClick:()=>r("/activity"),children:n("success.viewActivity")}),e.jsx($,{variant:"ghost",onClick:()=>r("/assets"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{children:n("success.failedTitle")}),e.jsx(k,{children:n("success.failedBody")}),h?e.jsx(w,{children:h}):null,e.jsx(S,{children:e.jsx($,{variant:"purple",onClick:()=>r("/assets"),children:n("success.backToShop")})})]})})}):e.jsx(z,{children:e.jsxs(Y,{children:[e.jsxs(V,{role:"status",children:[e.jsx(Z,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(ee,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(te,{children:[d?e.jsxs(se,{"data-testid":"success-credits",children:[e.jsx(re,{}),e.jsxs(ce,{children:[e.jsx(oe,{children:n("getCredits.creditsAmount",{credits:d,currency:q.name})})," ",e.jsx(ae,{children:n("getCredits.creditsAdded")})]})]}):null,p.map((o,y)=>{const b=o.quantity??1;return e.jsxs(ne,{children:[y>0?e.jsx(ie,{"aria-hidden":!0}):null,e.jsxs(de,{children:[e.jsxs(le,{children:[o.thumbnail?e.jsx("img",{src:o.thumbnail,alt:""}):null,e.jsx(xe,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(pe,{children:[e.jsxs(he,{title:o.name,children:[o.name||n("buyModal.itemFallback"),b>1?e.jsx(ue,{children:n("cartCheckout.qty",{count:b})}):null]}),o.creator?e.jsx(ge,{address:o.creator,linkToProfile:!0}):null]}),e.jsxs(fe,{children:[e.jsx(me,{}),e.jsx("span",{children:H(o.priceCredits*b)})]})]})]},o.id)})]}),h?e.jsx(w,{"data-receipt":!0,children:h}):null,e.jsxs(je,{children:[e.jsx(we,{"data-variant":"ghost",onClick:()=>r("/my-assets"),children:n("success.myAssets")}),e.jsxs(ye,{"data-variant":"ruby",href:$e,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(be,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})})}export{Fe as Success,Fe as default};
@@ -1 +1 @@
1
- import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-D3RatyJZ.js";import{au as C}from"./NetworkUtil-HlUKXKcF.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
1
+ import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-MrB8u6EW.js";import{au as C}from"./NetworkUtil-HlUKXKcF.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
@@ -1,4 +1,4 @@
1
- import{r as o,j as C,d as T}from"./react-vyZjIDcS.js";import{s as P,t as i}from"./index-yJi2QIJf.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
1
+ import{r as o,j as C,d as T}from"./react-vyZjIDcS.js";import{s as P,t as i}from"./index-BMIuNfCB.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
2
2
  display: ${({block:t})=>t?"flex":"inline-flex"};
3
3
  ${({block:t})=>t?"width: 100%;":""}
4
4
  `,I=P("span",B("placement"))`
@@ -1 +1 @@
1
- var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-CXBJm_wN.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-vyZjIDcS.js";import{bh as be,b as te,a as re}from"./index-yJi2QIJf.js";import{c as q,e as Re}from"./index-D7R57an8.js";import{s as Ie}from"./sendMetaTransaction-BOtIj1YL.js";import"./sentry-B35L1FdR.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new Re.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),R=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(R.populateTransaction):R.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,R=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,b,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(b=w>0?w+1:0;b<o;){for(I=d,f=1,m=T;b>=o&&F("invalid-input"),g=Te(n.charCodeAt(b++)),(g>=T||g>E((R-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(R/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>R-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,b,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=R,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((R-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>R&&F("overflow"),f==a){for(x=o,b=T;I=b<=y?v:b>=y+P?P:b-y,!(x<I);b+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return be.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
1
+ var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-CXBJm_wN.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-vyZjIDcS.js";import{bi as be,b as te,a as re}from"./index-BMIuNfCB.js";import{c as q,e as Re}from"./index-B439DG-9.js";import{s as Ie}from"./sendMetaTransaction-DAsHliEn.js";import"./sentry-B35L1FdR.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new Re.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),R=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(R.populateTransaction):R.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,R=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,b,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(b=w>0?w+1:0;b<o;){for(I=d,f=1,m=T;b>=o&&F("invalid-input"),g=Te(n.charCodeAt(b++)),(g>=T||g>E((R-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(R/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>R-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,b,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=R,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((R-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>R&&F("overflow"),f==a){for(x=o,b=T;I=b<=y?v:b>=y+P?P:b-y,!(x<I);b+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return be.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};