@dcl/shop 0.4.1-30929389788.commit-742d29e → 0.5.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 (181) hide show
  1. package/_assets/{Activity-Db-W7wkQ.js → Activity-GNtRBDkH.js} +1 -1
  2. package/_assets/{AnimatedBackground-BHa0JOad.js → AnimatedBackground-C4vGO85y.js} +1 -1
  3. package/_assets/{Assets-DScd8AjN.js → Assets-DUB4VCUr.js} +7 -7
  4. package/_assets/{Assets.styles-CC9TEJY8.js → Assets.styles-DIh1hG4_.js} +1 -1
  5. package/_assets/{Authorizations-9juyA8I3.js → Authorizations-gse9z0i5.js} +1 -1
  6. package/_assets/Cart-xOvVoYwp.js +695 -0
  7. package/_assets/{CircularProgress-B2Yj4dgv.js → CircularProgress-BZT_u7sL.js} +1 -1
  8. package/_assets/{Collection-B4RyBoqR.js → Collection-DkMWDyM9.js} +1 -1
  9. package/_assets/{CollectionCarousel-D7ypS3Z2.js → CollectionCarousel-D-7TqEHy.js} +1 -1
  10. package/_assets/{Creator-BkdPFwOV.js → Creator-CIj-i2cJ.js} +1 -1
  11. package/_assets/{ErrorNotice-DSrM0Kf5.js → ErrorNotice-qXSCgBBe.js} +1 -1
  12. package/_assets/{ExchangeController-CZ-pTf_8.js → ExchangeController-CoWk4iJ_.js} +1 -1
  13. package/_assets/{GetCredits-B6T0t3Dq.js → GetCredits-91dR46BQ.js} +1 -1
  14. package/_assets/{HelpersUtil-B3W36CMu.js → HelpersUtil-B_EI8lTR.js} +1 -1
  15. package/_assets/{ImportListings-C-obFZTv.js → ImportListings-DrIx4tN-.js} +28 -17
  16. package/_assets/{ItemDetail-D55mpnrl.js → ItemDetail-DneK31a0.js} +11 -11
  17. package/_assets/{ItemPreview.styles-CL_JxYSc.js → ItemPreview.styles--MP-O7tE.js} +1 -1
  18. package/_assets/{LoadMore-KA3XXjNw.js → LoadMore-CPg41rwp.js} +2 -2
  19. package/_assets/{ManaPricingBanner.styles-CUIN233q.js → ManaPricingBanner.styles-4CDYw79q.js} +1 -1
  20. package/_assets/{MenuList-B06jmSoi.js → MenuList-D5E4Wrvx.js} +1 -1
  21. package/_assets/{MyAssets-majFLeCV.js → MyAssets-C29gKaZs.js} +2 -2
  22. package/_assets/{MyFavorites-Das7b58R.js → MyFavorites-CfsWFXpI.js} +2 -2
  23. package/_assets/{NotFound-C8NgLkkE.js → NotFound-DVmSPOa9.js} +4 -4
  24. package/_assets/{NotificationsBell-C9KiHXIn.js → NotificationsBell-C_HZmA4_.js} +1 -1
  25. package/_assets/{OutfitDetail-BEV5iwUF.js → OutfitDetail-BCkHFvPX.js} +1 -1
  26. package/_assets/{OutfitPreview-BtpC-Cvw.js → OutfitPreview-XyEsGBYa.js} +2 -2
  27. package/_assets/{OutfitStudio-BAwsIcEz.js → OutfitStudio-D6HxPa0M.js} +1 -1
  28. package/_assets/{StoreSettings-Bry12GHk.js → StoreSettings-CmI6OJyt.js} +1 -1
  29. package/_assets/{Success-DQlpklhB.js → Success-CILFVgai.js} +5 -5
  30. package/_assets/{SwapController-DfkePmG2.js → SwapController-BtZYC1DC.js} +1 -1
  31. package/_assets/{Tooltip-DfpTXa5S.js → Tooltip-D-dOz9cj.js} +1 -1
  32. package/_assets/{TradeService-aWHMWz09.js → TradeService-DFGHQuam.js} +1 -1
  33. package/_assets/{W3MFrameProviderSingleton-COoptDqP.js → W3MFrameProviderSingleton-Dd3fipah.js} +3 -3
  34. package/_assets/{WebCryptoP256-6ZQY6RZ0.js → WebCryptoP256-83ZQlmY9.js} +1 -1
  35. package/_assets/{authorizations-CVSgo4HG.js → authorizations-3-Mq1Ehl.js} +1 -1
  36. package/_assets/{basic-Bz0GeBn4.js → basic-BndfWYou.js} +1 -1
  37. package/_assets/{biconomy-C5qeqZr1.js → biconomy-UoaVnBXL.js} +1 -1
  38. package/_assets/{browseLayout.styles-Ti-99uf9.js → browseLayout.styles-C2XsX59Z.js} +1 -1
  39. package/_assets/{builder-BsYNgj_6.js → builder-BCsqID1m.js} +1 -1
  40. package/_assets/buy-Bs_G6nfA.js +1 -0
  41. package/_assets/buy-gasless-Cf6hPQpJ.js +1 -0
  42. package/_assets/{categories-4Q8LpilA.js → categories-CJDomWri.js} +1 -1
  43. package/_assets/{ccip-ngY9Pe3O.js → ccip-DL1ik4S_.js} +1 -1
  44. package/_assets/{ccip-ByGEWKIW.js → ccip-LyTNGN_g.js} +1 -1
  45. package/_assets/{clsx-BqCzxF7Y.js → clsx-CbhzNwHc.js} +1 -1
  46. package/_assets/{controller-BAmFvFDh.js → controller-DI4T8YXU.js} +2 -2
  47. package/_assets/{core-6EsT--jS.js → core-DLkqCpDz.js} +4 -4
  48. package/_assets/{createSvgIcon--jZ8gc0J.js → createSvgIcon-BdIjzl8A.js} +1 -1
  49. package/_assets/{custom-DgKKywa8.js → custom-DjHlYa2L.js} +1 -1
  50. package/_assets/{data-capture-Dh5ES4rT.js → data-capture-CCEqsOVC.js} +1 -1
  51. package/_assets/{email-C6q-B3dn.js → email-MyVfElwc.js} +1 -1
  52. package/_assets/{embedded-wallet-BFiVutTi.js → embedded-wallet-DGKPNmRz.js} +1 -1
  53. package/_assets/{emotion-styled.browser.esm-BbqA95lz.js → emotion-styled.browser.esm-B-KYMSCc.js} +1 -1
  54. package/_assets/{engine-JdtR0nq_.js → engine-P4mrsX3-.js} +1 -1
  55. package/_assets/{errors-B82qLCfF.js → errors-B5G852-H.js} +1 -1
  56. package/_assets/{estimate-l1-fee-DgTq3kmb.js → estimate-l1-fee-CZTQo2Yh.js} +1 -1
  57. package/_assets/{execute-DYEeUtDo.js → execute-CqlntYG8.js} +2 -2
  58. package/_assets/{features-DZn29VrN.js → features-BstqY0d8.js} +1 -1
  59. package/_assets/{fetchTokenMetadata-B2WzuDGz.js → fetchTokenMetadata-wr3bODuw.js} +2 -2
  60. package/_assets/{field.styles-lhxWzP8B.js → field.styles-CeFk4Y5o.js} +1 -1
  61. package/_assets/{get-ecosystem-wallet-info-CrrYWx4r.js → get-ecosystem-wallet-info-BmrdD1ZM.js} +1 -1
  62. package/_assets/{getBalance-DKA5EVIM.js → getBalance-CGp1VbNi.js} +1 -1
  63. package/_assets/{getNFT-DHD0aNcW.js → getNFT-BATtEfMr.js} +1 -1
  64. package/_assets/{getNFT-B0rvj-5L.js → getNFT-Bc7mOqON.js} +1 -1
  65. package/_assets/{getThemeProps-g3WCjxgX.js → getThemeProps-Cj1ePFOP.js} +1 -1
  66. package/_assets/{grid.styles-BtnKEF2E.js → grid.styles-4uR2Oqak.js} +1 -1
  67. package/_assets/{hashTypedData-DTgIOn4m.js → hashTypedData--isNjJrk.js} +1 -1
  68. package/_assets/{hashTypedData-DfVAP7eV.js → hashTypedData-DmaIP4Ta.js} +1 -1
  69. package/_assets/{in-app-D5BjEtTB.js → in-app-DkfGauuN.js} +1 -1
  70. package/_assets/{in-app-wallet-calls-BT8fK-6W.js → in-app-wallet-calls-_oAp4gRk.js} +1 -1
  71. package/_assets/{index-8ozgSdai.js → index-6-oWZZKk.js} +1 -1
  72. package/_assets/{index-E_Sf5YwN.js → index-6TyUCKeH.js} +1 -1
  73. package/_assets/{index-DH_DK-mM.js → index-9uXo0dDW.js} +1 -1
  74. package/_assets/{index-BHY2HyQM.js → index-B08mxqyH.js} +1 -1
  75. package/_assets/{index-sKuG_A-e.js → index-B0XZJoRs.js} +3 -3
  76. package/_assets/{index-CB8W7Wwj.js → index-B3qntzSb.js} +1 -1
  77. package/_assets/{index-BPvkKSW-.js → index-B4VZ6oCr.js} +1 -1
  78. package/_assets/{index-Dvezp6E1.js → index-B9aCuD80.js} +1 -1
  79. package/_assets/{index-orEmQq47.js → index-BF4F4-es.js} +1 -1
  80. package/_assets/{index-4P2nQJyI.js → index-BHPckyG6.js} +1 -1
  81. package/_assets/{index-BLkkARF6.js → index-BQEMTtHk.js} +1 -1
  82. package/_assets/{index-C0ddHSHN.js → index-BQJhzjgB.js} +1 -1
  83. package/_assets/{index-BMTDcpzP.js → index-BYndrnYs.js} +1 -1
  84. package/_assets/{index-DRUTgaLt.js → index-BlqD0sjz.js} +1 -1
  85. package/_assets/{index-CqaRbr-_.js → index-BmlqG1wa.js} +1 -1
  86. package/_assets/{index-BkdomiVc.js → index-Bq3RaeMg.js} +1 -1
  87. package/_assets/{index-B2_ymgJB.js → index-CAtB_PCp.js} +2 -2
  88. package/_assets/{index-C9N9EKtn.js → index-CEec1iYe.js} +82 -73
  89. package/_assets/{index-CTN9ScLd.js → index-CKuDkHtx.js} +1 -1
  90. package/_assets/{index-BqO9dnsd.js → index-CNLdKmSV.js} +1 -1
  91. package/_assets/{index-DikO0beB.js → index-COG_bMzA.js} +1 -1
  92. package/_assets/{index-DKjypZ0d.js → index-CVTYXB-H.js} +1 -1
  93. package/_assets/{index-CHfTJRUt.js → index-CwgAx_D_.js} +1 -1
  94. package/_assets/{index-Bo5hDaOs.js → index-D-cwjSAX.js} +3 -3
  95. package/_assets/{index-C-ftDX-e.js → index-DA6dfZrr.js} +1 -1
  96. package/_assets/{index-DvcsAjCH.js → index-DARDndd8.js} +1 -1
  97. package/_assets/{index-WeqbIhyb.js → index-DA_UmuJW.js} +2 -2
  98. package/_assets/{index-Ds1p7jFw.js → index-DCcvZO5Y.js} +1 -1
  99. package/_assets/{index-Dv4PiFul.js → index-DG2jERXm.js} +1 -1
  100. package/_assets/{index--2K0MJxe.js → index-DI6mFHN_.js} +1 -1
  101. package/_assets/{index-C2AUAE9K.js → index-DMfeEICj.js} +1 -1
  102. package/_assets/{index-DmBpUfbw.js → index-DXe6U5Nd.js} +1 -1
  103. package/_assets/{index-BAhUbAfy.js → index-DYIatsEA.js} +1 -1
  104. package/_assets/{index-7hZlA6Kw.js → index-DYJqGaxj.js} +2 -2
  105. package/_assets/{index-BdudZCLc.js → index-Df_MtlRn.js} +1 -1
  106. package/_assets/{index-D1fC-8ma.js → index-DiwV8Pqc.js} +1 -1
  107. package/_assets/{index-udXxIsrp.js → index-DwhWwt0R.js} +1 -1
  108. package/_assets/{index-DMfRi-zb.js → index-GIpFWU31.js} +1 -1
  109. package/_assets/{index-D2zLCaX2.js → index-Jw4WyTL7.js} +1 -1
  110. package/_assets/{index-Bbcgp2zA.js → index-Rzy39Nn7.js} +1 -1
  111. package/_assets/{index-DF_A0o8O.js → index-TXpJyzEO.js} +1 -1
  112. package/_assets/{index-CMEHJSyR.js → index-TyIfm5pC.js} +1 -1
  113. package/_assets/{index-ekmXkRNM.js → index-UOqdWcGo.js} +1 -1
  114. package/_assets/{index-BM4bIAor.js → index-a7lLIynB.js} +1 -1
  115. package/_assets/{index-3Vz1Ih1G.js → index-bI7YB81Q.js} +1 -1
  116. package/_assets/{index-CCTN9glk.js → index-g7yoq537.js} +1 -1
  117. package/_assets/{index-kn5L_xVv.js → index-hFWlaYZc.js} +1 -1
  118. package/_assets/{index-YCT7FhXc.js → index-hxv9huma.js} +1 -1
  119. package/_assets/{index-C2lAxjqW.js → index-pUOx764A.js} +1 -1
  120. package/_assets/{index-DZmHepqu.js → index-qOIpyDqw.js} +3 -3
  121. package/_assets/{index-BzrS1OGR.js → index-wLhUVrXT.js} +1 -1
  122. package/_assets/{index.es-BARR4Gun.js → index.es-CleSpdBe.js} +1 -1
  123. package/_assets/{index.es-i4xjORFb.js → index.es-DSBJgnik.js} +4 -4
  124. package/_assets/{index.es-BHdSIiaa.js → index.es-DcH5dh4Z.js} +1 -1
  125. package/_assets/{localBatchGatewayRequest-DQfpwJw7.js → localBatchGatewayRequest-BQaanzyf.js} +1 -1
  126. package/_assets/{mana-convert-Ck9I-6Uq.js → mana-convert-gdOzEDdP.js} +1 -1
  127. package/_assets/{mana-rate-QgHuwxlu.js → mana-rate-DFh9C_O1.js} +1 -1
  128. package/_assets/{networks-d64kKiSV.js → networks-DweEIHqd.js} +1 -1
  129. package/_assets/{onramp-BecMqi2K.js → onramp-CQin_sc0.js} +1 -1
  130. package/_assets/{openzeppelin-vjBXjfol.js → openzeppelin-aL0pLCk3.js} +1 -1
  131. package/_assets/{parseNft-Dy7r5wsa.js → parseNft-C3_Nz5T-.js} +2 -2
  132. package/_assets/{parseSignature-BRlMdiGA.js → parseSignature-CaUNRWNX.js} +3 -3
  133. package/_assets/{parseSignature-DksYWj9u.js → parseSignature-DbUWX_0J.js} +1 -1
  134. package/_assets/{passkeys-BRcHxYax.js → passkeys-ErJmNcK7.js} +1 -1
  135. package/_assets/{pay-with-exchange-BXSOiFjm.js → pay-with-exchange-IR4P3LG2.js} +1 -1
  136. package/_assets/{qr-overlay-Cip9DxEt.js → qr-overlay-CdnDwp_H.js} +1 -1
  137. package/_assets/{receive-CMnJaoeU.js → receive-zGMAuzLF.js} +1 -1
  138. package/_assets/{resolveImplementation-TWoeiTet.js → resolveImplementation-DBCwfUsj.js} +1 -1
  139. package/_assets/{rpc-7qzpxegl.js → rpc-DcBDiZd9.js} +1 -1
  140. package/_assets/{secp256k1-B8mez7iu.js → secp256k1-B-E-jiWl.js} +1 -1
  141. package/_assets/{secp256k1-Br3S0CFm.js → secp256k1-Dewsd8iM.js} +1 -1
  142. package/_assets/{secp256k1-DJqg4ZDg.js → secp256k1-Dw0WpBX5.js} +1 -1
  143. package/_assets/{send-CrNMtB2o.js → send-DDT-5Y8C.js} +1 -1
  144. package/_assets/{send-batch-transaction-D373Fu0i.js → send-batch-transaction-BurBPeh7.js} +1 -1
  145. package/_assets/{send-eip712-transaction-CjvjEaqz.js → send-eip712-transaction-D77WUDwd.js} +2 -2
  146. package/_assets/{send-gasless-transaction-D7k7Z4lZ.js → send-gasless-transaction-CIWAOyRc.js} +2 -2
  147. package/_assets/{send-transaction-DuSf0Gpa.js → send-transaction-BXhwaD9S.js} +2 -2
  148. package/_assets/{sendMetaTransaction-ysIA25j6.js → sendMetaTransaction-CrIt0KCG.js} +1 -1
  149. package/_assets/{sendRawTransaction-DMahEMO3.js → sendRawTransaction-DNK5LA13.js} +3 -3
  150. package/_assets/{serializeTransaction-Dy_R0gbR.js → serializeTransaction-D3WekrgC.js} +1 -1
  151. package/_assets/{session-proposal-wFJ_Xq-z.js → session-proposal-BlosSPbJ.js} +1 -1
  152. package/_assets/{session-request-COH-7UzM.js → session-request-C8iYxI6j.js} +2 -2
  153. package/_assets/{signing-Ckuyn_e5.js → signing-Bx48W7O-.js} +3 -3
  154. package/_assets/{socials-FP-fRVu0.js → socials-BSmNv258.js} +1 -1
  155. package/_assets/{swaps-BxewF7TW.js → swaps-DyNopWtM.js} +1 -1
  156. package/_assets/{thirdweb-D8fj1r0r.js → thirdweb-Bc1voIUm.js} +3 -3
  157. package/_assets/{to-serializable-transaction-DfEWI1zg.js → to-serializable-transaction-BXY289Ul.js} +2 -2
  158. package/_assets/{trade-encoding-psxHAKvo.js → trade-encoding-B7y8VfDo.js} +1 -1
  159. package/_assets/{transactionReceipt-DIcbPjA9.js → transactionReceipt-DLzKebEg.js} +1 -1
  160. package/_assets/{transactions-BrwcuhUa.js → transactions-BWXAu1Vp.js} +1 -1
  161. package/_assets/{useCreditPacks-BxjNjEb5.js → useCreditPacks-CYnMKZmp.js} +1 -1
  162. package/_assets/{useInfiniteGrid-By91Vng4.js → useInfiniteGrid-ottWIC3k.js} +1 -1
  163. package/_assets/useManaRate-CPn6JNFj.js +1 -0
  164. package/_assets/{useStore-Bk_iM1_W.js → useStore-DC77ufHd.js} +1 -1
  165. package/_assets/useTheme-BOb3XgSe.js +1 -0
  166. package/_assets/{verifyHash-haNM6fqc.js → verifyHash-B6wVUzvm.js} +1 -1
  167. package/_assets/{w3m-modal-Bp9zdyll.js → w3m-modal-CYIABu52.js} +1 -1
  168. package/_assets/{w3m-modal-BPeZqcW1.js → w3m-modal-D0DQYwij.js} +1 -1
  169. package/_assets/{wait-for-tx-receipt-CGJMUoaQ.js → wait-for-tx-receipt-CzEApn7N.js} +1 -1
  170. package/_assets/{wallets-BI1VVvky.js → wallets-CQPQ_gpR.js} +5 -5
  171. package/_assets/{web-connector-B8j0HFRl.js → web-connector-B5U5FrL8.js} +3 -3
  172. package/_assets/{writeContract-BERJiwjR.js → writeContract-CGlJd1QG.js} +1 -1
  173. package/_assets/{zoraTestnet-8myH3mD_.js → zoraTestnet-pKTbhMUO.js} +1 -1
  174. package/index.html +11 -11
  175. package/package.json +2 -2
  176. package/_assets/Cart-DOsuNsch.js +0 -695
  177. package/_assets/buy-XwnhKGiV.js +0 -1
  178. package/_assets/buy-gasless-DdQlX-69.js +0 -1
  179. package/_assets/useManaRate-CJKClAWL.js +0 -1
  180. package/_assets/useSecondarySales-CjBDIS93.js +0 -1
  181. package/_assets/useTheme-BT599SB4.js +0 -1
@@ -1,4 +1,4 @@
1
- import{L as w,u as ne,j as e,r as p}from"./react-DehiWSvs.js";import{d as P}from"./dcl-schemas-Dr9BTjb7.js";import{s as t,I as y,t as re,A as oe,D as le,E as de,B as j,F as ce,n as D,G as pe,u as he,m as me,e as s,H as F,J as xe,K as ue,L as ge,M as fe,N as be,O as ve,P as ye,Q as je,R as we,S as ke,V as $e,W as Ie,X as Ce,Y as ze,p as z,Z as Le,$ as Ee,a0 as Te,a1 as Se,a2 as Ae,a3 as Ne}from"./index-C9N9EKtn.js";import{E as H}from"./ErrorNotice-DSrM0Kf5.js";import{O as Pe}from"./OutfitPreview-BtpC-Cvw.js";import{T as Fe,a as O,b as R,c as W}from"./ItemPreview.styles-CL_JxYSc.js";import"./sentry-973sfbO9.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Oe,media:o}=re,V=t.div`
1
+ import{L as w,u as ne,j as e,r as p}from"./react-DehiWSvs.js";import{d as P}from"./dcl-schemas-Dr9BTjb7.js";import{s as t,I as y,t as re,A as oe,D as le,E as de,B as j,F as ce,n as D,G as pe,u as he,m as me,b as s,H as F,J as xe,K as ue,L as ge,M as fe,N as be,O as ve,P as ye,Q as je,R as we,S as ke,V as $e,W as Ie,X as Ce,Y as ze,p as z,Z as Le,$ as Ee,a0 as Te,a1 as Se,a2 as Ae,a3 as Ne}from"./index-CEec1iYe.js";import{E as H}from"./ErrorNotice-qXSCgBBe.js";import{O as Pe}from"./OutfitPreview-XyEsGBYa.js";import{T as Fe,a as O,b as R,c as W}from"./ItemPreview.styles--MP-O7tE.js";import"./sentry-973sfbO9.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Oe,media:o}=re,V=t.div`
2
2
  max-width: 1721px;
3
3
  margin: 0 auto;
4
4
  `,Re=t.nav`
@@ -1,6 +1,6 @@
1
- import{r as n,j as r}from"./react-DehiWSvs.js";import{d as p}from"./dcl-schemas-Dr9BTjb7.js";import{s as h,L as P,c as R,a4 as b,e as A}from"./index-C9N9EKtn.js";import{u as O,d as F}from"./disposePreview-DIA1G1eQ.js";const I=h.div`
1
+ import{r as n,j as r}from"./react-DehiWSvs.js";import{d as p}from"./dcl-schemas-Dr9BTjb7.js";import{s as h,L as b,c as P,a4 as R,b as A}from"./index-CEec1iYe.js";import{u as O,d as F}from"./disposePreview-DIA1G1eQ.js";const I=h.div`
2
2
  position: absolute;
3
3
  inset: 0;
4
4
  display: grid;
5
5
  place-items: center;
6
- `;function N({id:u,profile:i,bodyShape:m,urns:e,enabled:c=!0,onRenderer:v,skin:d,hair:l,eyes:f}){const g=P(s=>s.fittingOpen),{ref:w,active:x}=O(),t=c&&e.length>0&&x&&!g,y=e.length>0?e[0].includes(":amoy:"):R.chainId===80002,[E,a]=n.useState(!1),j=e.join(",");n.useEffect(()=>{a(!1)},[j,i,d,l,f]),n.useEffect(()=>{t&&a(!1)},[t]);const o=n.useRef(null);return n.useEffect(()=>{if(t)return()=>{F(o.current),o.current=null}},[t]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:w,"data-preview-viewport":!0,"aria-hidden":!0}),t?r.jsx(b,{id:u,profile:i,bodyShape:m,urns:e,skin:d,hair:l,eyes:f,type:p.PreviewType.AVATAR,emote:p.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,unity:!0,onRenderer:v,onLoad:()=>{var s;a(!0),o.current=((s=document.getElementById(u))==null?void 0:s.contentWindow)??null}},i):null,c&&e.length===0?null:!t||!E?r.jsx(I,{"aria-busy":"true","aria-label":A("spinner.loading"),children:r.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{N as O};
6
+ `;function N({id:u,profile:i,bodyShape:m,urns:e,enabled:c=!0,onRenderer:v,skin:d,hair:l,eyes:f}){const g=b(s=>s.fittingOpen),{ref:w,active:x}=O(),t=c&&e.length>0&&x&&!g,y=e.length>0?e[0].includes(":amoy:"):P.chainId===80002,[E,a]=n.useState(!1),j=e.join(",");n.useEffect(()=>{a(!1)},[j,i,d,l,f]),n.useEffect(()=>{t&&a(!1)},[t]);const o=n.useRef(null);return n.useEffect(()=>{if(t)return()=>{F(o.current),o.current=null}},[t]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:w,"data-preview-viewport":!0,"aria-hidden":!0}),t?r.jsx(R,{id:u,profile:i,bodyShape:m,urns:e,skin:d,hair:l,eyes:f,type:p.PreviewType.AVATAR,emote:p.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,unity:!0,onRenderer:v,onLoad:()=>{var s;a(!0),o.current=((s=document.getElementById(u))==null?void 0:s.contentWindow)??null}},i):null,c&&e.length===0?null:!t||!E?r.jsx(I,{"aria-busy":"true","aria-label":A("spinner.loading"),children:r.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{N as O};
@@ -1,4 +1,4 @@
1
- import{r as u,j as t,L as O,u as qt,b as Gt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as U,aq as Qt,e,p as Y,B as m,a9 as vt,n as G,G as Vt,m as Jt,q as wt,u as $t,J as Xt,P as B,ar as K,as as q,W as Yt,S as Zt,V as te,N as St,X as ee,at as Z,au as ie,av as se,aw as oe,w as F,ax as kt,ay as Tt,az as R,l as tt,aA as et,aB as ae,aC as ne,aD as re,O as de,aE as le,aF as ue,a3 as ce}from"./index-C9N9EKtn.js";import{E as D}from"./ErrorNotice-DSrM0Kf5.js";import{L as pe}from"./LoadMore-KA3XXjNw.js";import{u as fe}from"./useInfiniteGrid-By91Vng4.js";import{O as he}from"./OutfitPreview-BtpC-Cvw.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:x,radius:ot,media:me}=st,xe=o.div`
1
+ import{r as u,j as t,L as O,u as qt,b as Gt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as U,aq as Qt,b as e,p as Y,B as m,a9 as vt,n as G,G as Vt,m as Jt,q as wt,u as $t,J as Xt,P as B,ar as K,as as q,W as Yt,S as Zt,V as te,N as St,X as ee,at as Z,au as ie,av as se,aw as oe,w as F,ax as kt,ay as Tt,az as R,j as tt,aA as et,aB as ae,aC as ne,aD as re,O as de,aE as le,aF as ue,a3 as ce}from"./index-CEec1iYe.js";import{E as D}from"./ErrorNotice-qXSCgBBe.js";import{L as pe}from"./LoadMore-CPg41rwp.js";import{u as fe}from"./useInfiniteGrid-ottWIC3k.js";import{O as he}from"./OutfitPreview-XyEsGBYa.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:x,radius:ot,media:me}=st,xe=o.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -1,4 +1,4 @@
1
- import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t as j,s as a,k as ce,B as q,m as de,n as pe,q as ue,I as z,w as F}from"./index-C9N9EKtn.js";import{u as ge,d as me,t as xe,L as he,i as A,a as f,s as fe}from"./useStore-Bk_iM1_W.js";import{E as M}from"./ErrorNotice-DSrM0Kf5.js";import{F as w}from"./field.styles-lhxWzP8B.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/0.3.1-30929389788.commit-742d29e/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.3.1-30929389788.commit-742d29e/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),je=ce`
1
+ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t as j,s as a,k as ce,B as q,m as de,n as pe,q as ue,I as z,w as F}from"./index-CEec1iYe.js";import{u as ge,d as me,t as xe,L as he,i as A,a as f,s as fe}from"./useStore-DC77ufHd.js";import{E as M}from"./ErrorNotice-qXSCgBBe.js";import{F as w}from"./field.styles-CeFk4Y5o.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/0.5.0/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.5.0/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),je=ce`
2
2
  to {
3
3
  transform: rotate(360deg);
4
4
  }
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/index.es-DQ3AciL_.js","_assets/react-DehiWSvs.js"])))=>i.map(i=>d[i]);
2
- import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,p as _,an as O,a9 as W,n as D,m as q,e as n,o as U,f as V,ao as H,c as B,B as J,ap as X}from"./index-C9N9EKtn.js";import{w as G,S as K}from"./buy-gasless-DdQlX-69.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-CVSgo4HG.js";import"./sendMetaTransaction-ysIA25j6.js";import"./trade-encoding-psxHAKvo.js";const Q=t.div`
2
+ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,p as _,an as O,a9 as W,n as D,m as q,b as n,o as U,d as V,ao as H,c as B,B as J,ap as X}from"./index-CEec1iYe.js";import{w as G,S as K}from"./buy-gasless-Cf6hPQpJ.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-3-Mq1Ehl.js";import"./sendMetaTransaction-CrIt0KCG.js";import"./trade-encoding-B7y8VfDo.js";const Q=t.div`
3
3
  position: fixed;
4
4
  inset: 0;
5
5
  /**
@@ -43,7 +43,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
43
43
  font-size: 18px;
44
44
  color: #4b4b57;
45
45
  margin: 0 0 22px;
46
- `,y=t.div`
46
+ `,b=t.div`
47
47
  display: flex;
48
48
  gap: 18px;
49
49
  justify-content: center;
@@ -196,12 +196,12 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
196
196
  ${j} {
197
197
  font-size: 16px;
198
198
  }
199
- `,ye=t.span`
199
+ `,be=t.span`
200
200
  margin-left: 8px;
201
201
  font-weight: 600;
202
202
  font-size: 13px;
203
203
  color: ${s.muted};
204
- `,be=t(O)`
204
+ `,ye=t(O)`
205
205
  position: relative;
206
206
  z-index: 1;
207
207
  color: ${s.muted};
@@ -293,4 +293,4 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
293
293
  `,R=t(J)`
294
294
  min-width: 160px;
295
295
  text-align: center;
296
- `;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(v){if(v instanceof K)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let o=0;o<40&&!l;o++){if(await X(r.owner,r.contractAddress,r.itemId)){l||a("confirmed");return}await Se(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[c,x]),i}const Le=B.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Te=B.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ue(){var S;const{state:c,search:r}=P(),i=c??Ae(),a=N(),{session:x}=D(),l=i==null?void 0:i.txHash,b=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=b[0],v=x!=null&&x.address&&(o!=null&&o.contractAddress)&&(o!=null&&o.itemId)?{owner:x.address,contractAddress:o.contractAddress,itemId:o.itemId}:null,u=Ie(i!=null&&i.settled?void 0:l,v);q({title:n("seo.success.title"),noindex:!0});const h=b;if(h.length===0)return e.jsx(M,{to:"/items",replace:!0});const A=h[0],w=(S=i==null?void 0:i.txHashes)!=null&&S.length?i.txHashes:l?[l]:[],p=w.length>0&&U(x==null?void 0:x.providerType)?w.map((d,k)=>e.jsx(ne,{href:`${Te}${d}`,target:"_blank",rel:"noreferrer",children:w.length>1?n("success.viewTransactionNumbered",{n:k+1,total:w.length}):n("success.viewTransaction")},d)):null;return u!=="confirmed"?e.jsx(L,{children:e.jsx(ee,{children:u==="pending"||u==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"spinner","aria-hidden":!0}),e.jsx(C,{children:u==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(z,{children:u==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),p?e.jsx(y,{children:p}):null]}):u==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.stillProcessingTitle")}),e.jsxs(z,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),p?e.jsx(y,{children:p}):null,e.jsxs(T,{children:[e.jsx(R,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(R,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.failedTitle")}),e.jsx(z,{children:n("success.failedBody")}),p?e.jsx(y,{children:p}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(L,{children:[e.jsx(Z,{}),e.jsxs(ie,{children:[e.jsxs(se,{role:"status",children:[e.jsx(re,{"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(oe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(le,{"data-testid":"success-credits",children:[e.jsx(xe,{}),e.jsxs(pe,{children:[e.jsx(he,{children:n("getCredits.creditsAmount",{credits:f,currency:V.name})})," ",e.jsx(ue,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((d,k)=>{const $=d.quantity??1;return e.jsxs(ae,{children:[k>0?e.jsx(de,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(ge,{children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(me,{"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(je,{children:[e.jsxs(we,{title:d.name,children:[d.name||n("buyModal.itemFallback"),$>1?e.jsx(ye,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(be,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(ve,{children:[e.jsx(ke,{}),e.jsx("span",{children:H(d.priceCredits*$)})]})]})]},d.id)})]}),p?e.jsx(y,{"data-receipt":!0,children:p}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-items"),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Le,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"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{Ue as Success,Ue as default};
296
+ `;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(v){if(v instanceof K)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let o=0;o<40&&!l;o++){if(await X(r.owner,r.contractAddress,r.itemId)){l||a("confirmed");return}await Se(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[c,x]),i}const Le=B.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Te=B.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ue(){var S;const{state:c,search:r}=P(),i=c??Ae(),a=N(),{session:x}=D(),l=i==null?void 0:i.txHash,y=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=y[0],v=x!=null&&x.address&&(o!=null&&o.contractAddress)&&(o!=null&&o.itemId)?{owner:x.address,contractAddress:o.contractAddress,itemId:o.itemId}:null,u=Ie(i!=null&&i.settled?void 0:l,v);q({title:n("seo.success.title"),noindex:!0});const h=y;if(h.length===0)return e.jsx(M,{to:"/items",replace:!0});const A=h[0],w=(S=i==null?void 0:i.txHashes)!=null&&S.length?i.txHashes:l?[l]:[],p=w.length>0&&U(x==null?void 0:x.providerType)?w.map((d,k)=>e.jsx(ne,{href:`${Te}${d}`,target:"_blank",rel:"noreferrer",children:w.length>1?n("success.viewTransactionNumbered",{n:k+1,total:w.length}):n("success.viewTransaction")},d)):null;return u!=="confirmed"?e.jsx(L,{children:e.jsx(ee,{children:u==="pending"||u==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"spinner","aria-hidden":!0}),e.jsx(C,{children:u==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(z,{children:u==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),p?e.jsx(b,{children:p}):null]}):u==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.stillProcessingTitle")}),e.jsxs(z,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),p?e.jsx(b,{children:p}):null,e.jsxs(T,{children:[e.jsx(R,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(R,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.failedTitle")}),e.jsx(z,{children:n("success.failedBody")}),p?e.jsx(b,{children:p}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(L,{children:[e.jsx(Z,{}),e.jsxs(ie,{children:[e.jsxs(se,{role:"status",children:[e.jsx(re,{"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(oe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(le,{"data-testid":"success-credits",children:[e.jsx(xe,{}),e.jsxs(pe,{children:[e.jsx(he,{children:n("getCredits.creditsAmount",{credits:f,currency:V.name})})," ",e.jsx(ue,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((d,k)=>{const $=d.quantity??1;return e.jsxs(ae,{children:[k>0?e.jsx(de,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(ge,{children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(me,{"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(je,{children:[e.jsxs(we,{title:d.name,children:[d.name||n("buyModal.itemFallback"),$>1?e.jsx(be,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(ye,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(ve,{children:[e.jsx(ke,{}),e.jsx("span",{children:H(d.priceCredits*$)})]})]})]},d.id)})]}),p?e.jsx(b,{"data-receipt":!0,children:p}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-items"),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Le,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"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{Ue as Success,Ue 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-COoptDqP.js";import{au as C}from"./NetworkUtil-EoWQDMpU.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-Dd3fipah.js";import{au as C}from"./NetworkUtil-EoWQDMpU.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,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-C9N9EKtn.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
1
+ import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-CEec1iYe.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-CtNGBird.js";import{a as Ee,d as B}from"./dcl-schemas-Dr9BTjb7.js";import{c as ee}from"./react-DehiWSvs.js";import{bU as be,b as te,a as re}from"./index-C9N9EKtn.js";import{c as q,e as Re}from"./index-B2_ymgJB.js";import{s as Ie}from"./sendMetaTransaction-ysIA25j6.js";import"./sentry-973sfbO9.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 Ue=()=>Le,ke=()=>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 k=Ce.from(0);try{const _=await v.getGasPrice(),U=await v.estimateGas(T);k=_.mul(U)}catch{}if(!k.isZero()){const _=ke(),U=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(k),userBalance:X(U),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:Ue()});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,k=38,_=700,U=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+k))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=U,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=U,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-CtNGBird.js";import{a as Ee,d as B}from"./dcl-schemas-Dr9BTjb7.js";import{c as ee}from"./react-DehiWSvs.js";import{bU as Re,e as te,g as re}from"./index-CEec1iYe.js";import{c as q,e as be}from"./index-CAtB_PCp.js";import{s as Ie}from"./sendMetaTransaction-CrIt0KCG.js";import"./sentry-973sfbO9.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 be.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 Ue=()=>Le,ke=()=>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),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let k=Ce.from(0);try{const _=await v.getGasPrice(),U=await v.estimateGas(T);k=_.mul(U)}catch{}if(!k.isZero()){const _=ke(),U=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(k),userBalance:X(U),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:Ue()});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,b=2147483647,T=36,v=1,P=26,k=38,_=700,U=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+k))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=U,w,x,R,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(R=w>0?w+1:0;R<o;){for(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-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(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-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,R,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=U,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=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=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 Re.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};