@dcl/shop 1.0.1 → 1.0.2-31053112537.commit-2eeb02b

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 (175) hide show
  1. package/_assets/{Activity-CYc4haGG.js → Activity-CT4EXTT1.js} +3 -3
  2. package/_assets/{AnimatedBackground-DEshz0c2.js → AnimatedBackground-wyzu1j63.js} +2 -2
  3. package/_assets/{Assets-D5sxwFuc.js → Assets-DFjWkvAj.js} +2 -2
  4. package/_assets/{Assets.styles-c5XuGAG4.js → Assets.styles-De3LV6PK.js} +1 -1
  5. package/_assets/{Authorizations-m488Gyk0.js → Authorizations-Erxm3Fyz.js} +1 -1
  6. package/_assets/Cart-DJkaXf-4.js +706 -0
  7. package/_assets/{CircularProgress-CB7Frwx7.js → CircularProgress-CdQvdQq6.js} +1 -1
  8. package/_assets/{Collection-CS-PKjRf.js → Collection-CJV4xLye.js} +1 -1
  9. package/_assets/{CollectionCarousel-DhrBSU2o.js → CollectionCarousel-CvMsq3XH.js} +2 -2
  10. package/_assets/{Confetti-z9mEz7Mo.js → Confetti-BH2iBIUi.js} +1 -1
  11. package/_assets/{Creator-BMYJiMCB.js → Creator-Cyy5FpL2.js} +1 -1
  12. package/_assets/{ErrorNotice-BG4CBNkl.js → ErrorNotice-h0GUcJEu.js} +1 -1
  13. package/_assets/{ExchangeController-CLyfn8FH.js → ExchangeController-B3cP_vUc.js} +1 -1
  14. package/_assets/{Faq-D7gV7iYA.js → Faq-CKehqHI0.js} +1 -1
  15. package/_assets/{GetCredits-CL7K_M9H.js → GetCredits-DdkULwKp.js} +1 -1
  16. package/_assets/{Grow-Ccwk3GHr.js → Grow-BV4Iorxj.js} +1 -1
  17. package/_assets/{HelpersUtil-tyC-vTbQ.js → HelpersUtil-CU-9vHU7.js} +1 -1
  18. package/_assets/{ItemDetail-DwY7HKZL.js → ItemDetail-BAqZB6Be.js} +1 -1
  19. package/_assets/LazyEmoteControls-Dsz7X5iX.js +2 -0
  20. package/_assets/{LoadMore-BLHzgyNQ.js → LoadMore-D4fnHonl.js} +1 -1
  21. package/_assets/{ManaPricingBanner.styles-G4jy5obg.js → ManaPricingBanner.styles-YVCL83wQ.js} +1 -1
  22. package/_assets/{MyAssets-BpBrCfKj.js → MyAssets-DeZdrOao.js} +1 -1
  23. package/_assets/{MyFavorites-eakG4vL0.js → MyFavorites-Jhmw64Z-.js} +1 -1
  24. package/_assets/{NotFound-By_5zIVf.js → NotFound-BV0gWDmk.js} +1 -1
  25. package/_assets/{NotificationsBell-DVM7TZeA.js → NotificationsBell-CbzYe18m.js} +1 -1
  26. package/_assets/{OutfitDetail-CKImDsVr.js → OutfitDetail-mnH36Arv.js} +1 -1
  27. package/_assets/{OutfitPreview-BDsx1Zln.js → OutfitPreview-DEQlnmtN.js} +1 -1
  28. package/_assets/{OutfitStudio-BNP0n5pI.js → OutfitStudio-DlMQxDuE.js} +1 -1
  29. package/_assets/{StoreSettings-CMOSmEWV.js → StoreSettings-DXQD9Iiv.js} +1 -1
  30. package/_assets/{Success-DKTCAGfP.js → Success-Duo1gCiQ.js} +1 -1
  31. package/_assets/{SwapController-B6jVCCgh.js → SwapController-CJtBte7L.js} +1 -1
  32. package/_assets/{Tooltip-CnjWof_H.js → Tooltip-H89dNdoQ.js} +1 -1
  33. package/_assets/{TradeService-DqBS7JER.js → TradeService-BcEoCIV7.js} +1 -1
  34. package/_assets/{W3MFrameProviderSingleton-BNh7T9LS.js → W3MFrameProviderSingleton-CZuJfgAC.js} +3 -3
  35. package/_assets/{WebCryptoP256-DVUZQ3fN.js → WebCryptoP256-BQ90tDtY.js} +1 -1
  36. package/_assets/{authorizations-CE0HtqU4.js → authorizations-GLPsQqiP.js} +1 -1
  37. package/_assets/{basic-sWTPOMIW.js → basic-kk_TRFwe.js} +1 -1
  38. package/_assets/{biconomy-Gn8OlgoU.js → biconomy-D-XcBmzY.js} +1 -1
  39. package/_assets/{builder-DeMyTCI7.js → builder-Dn0-qNG1.js} +1 -1
  40. package/_assets/{buy-BF3MKHeK.js → buy-C36PZNHt.js} +1 -1
  41. package/_assets/{buy-gasless-C6Uiz2ft.js → buy-gasless-cVGUwJcn.js} +1 -1
  42. package/_assets/{categories-e7ryjlpc.js → categories-l2OqZN_F.js} +42 -33
  43. package/_assets/{ccip-C8QxGeVJ.js → ccip-BkPpUcVC.js} +1 -1
  44. package/_assets/{ccip-BGow4NM2.js → ccip-DTvzkPzd.js} +1 -1
  45. package/_assets/{collectionPage.styles-DGJTp7Uw.js → collectionPage.styles-BP7gMOku.js} +5 -5
  46. package/_assets/{controller-Ct0gOkSO.js → controller-Cm3hwM7G.js} +2 -2
  47. package/_assets/{core-BPejI2Uv.js → core-DtQ_ZTXW.js} +4 -4
  48. package/_assets/{createSvgIcon-CfV25Qvu.js → createSvgIcon-DTfKYyFY.js} +1 -1
  49. package/_assets/{custom-CtkIvR1q.js → custom-dDX_uBau.js} +1 -1
  50. package/_assets/{data-capture-ChzQjncq.js → data-capture-BHgEiKBs.js} +1 -1
  51. package/_assets/{email-DTmn4SUk.js → email-D-4NGs1z.js} +1 -1
  52. package/_assets/{embedded-wallet-zOEVMj8r.js → embedded-wallet-BQg7nplX.js} +1 -1
  53. package/_assets/{emotion-styled.browser.esm-ftlGzXhy.js → emotion-styled.browser.esm-DKFf4xqI.js} +1 -1
  54. package/_assets/{engine-C84VS8MU.js → engine-9w9_00su.js} +1 -1
  55. package/_assets/{errors-jURSB57c.js → errors-DAy3n3Fl.js} +1 -1
  56. package/_assets/{estimate-l1-fee-BK9aiTEg.js → estimate-l1-fee-CMUFNeJj.js} +1 -1
  57. package/_assets/{execute-BJdfX8go.js → execute-DmyMuEbq.js} +2 -2
  58. package/_assets/{features-CEPVrrJh.js → features-dYRaytuv.js} +1 -1
  59. package/_assets/{fetchTokenMetadata-Cg8LhGF6.js → fetchTokenMetadata-B7vrevS4.js} +2 -2
  60. package/_assets/{field.styles-BO_2AHCA.js → field.styles-DxW4rsbZ.js} +1 -1
  61. package/_assets/{get-ecosystem-wallet-info-DN7GFeAM.js → get-ecosystem-wallet-info-D-zi5D-3.js} +1 -1
  62. package/_assets/{getBalance-CCluSQca.js → getBalance-03ROSZOz.js} +1 -1
  63. package/_assets/{getNFT-B3tNxOax.js → getNFT-BZ5HS1py.js} +1 -1
  64. package/_assets/{getNFT-C7PC0iJF.js → getNFT-CGrmS4cn.js} +1 -1
  65. package/_assets/{grid.styles-DRngdZfp.js → grid.styles-VdW_5pS8.js} +1 -1
  66. package/_assets/{hashTypedData-ulq3qXHW.js → hashTypedData-D0grmu7Q.js} +1 -1
  67. package/_assets/{hashTypedData-BPxQrISG.js → hashTypedData-DWrpUT7F.js} +1 -1
  68. package/_assets/{in-app-C_sI0Q7l.js → in-app-Fd-r2Pt9.js} +1 -1
  69. package/_assets/{in-app-wallet-calls-ozqkkU0m.js → in-app-wallet-calls-US6STGvk.js} +1 -1
  70. package/_assets/{index-DmouEX3z.js → index-0ctogS4p.js} +1 -1
  71. package/_assets/{index-DmYn7FTm.js → index-3M7Oc88-.js} +1 -1
  72. package/_assets/{index-B4Sh4DUY.js → index-9wBxZvS3.js} +1 -1
  73. package/_assets/{index-D_qvzN-5.js → index-B4OCkrkj.js} +1 -1
  74. package/_assets/{index-C7gyW2pC.js → index-BGWFa_3t.js} +1 -1
  75. package/_assets/{index-DNUmp9qJ.js → index-BLhzIl8l.js} +2 -2
  76. package/_assets/{index-C6jWze3p.js → index-BOqWivx2.js} +1 -1
  77. package/_assets/{index-B4VWghxR.js → index-BXAhg_WL.js} +1 -1
  78. package/_assets/{index-B4ldzGrT.js → index-BfrU5ARr.js} +1 -1
  79. package/_assets/{index-BwpU8az-.js → index-Bw5aGSBt.js} +3 -3
  80. package/_assets/{index-C21U9leN.js → index-C6snVc74.js} +2 -2
  81. package/_assets/{index-B8hnFmS-.js → index-C9g5jnkn.js} +3 -3
  82. package/_assets/{index-BCqRbjcA.js → index-C9qZGyVn.js} +1 -1
  83. package/_assets/{index-BsAc5Nb_.js → index-CBa9KvFL.js} +1 -1
  84. package/_assets/{index-B2h0kzTR.js → index-CHrjSjdy.js} +30 -27
  85. package/_assets/{index-CFj3lX4u.js → index-CTFDcqvg.js} +1 -1
  86. package/_assets/{index-B-0HDufu.js → index-CUnVy-2F.js} +1 -1
  87. package/_assets/{index-DPJNY0Ni.js → index-CYelE7gc.js} +1 -1
  88. package/_assets/{index-DUeFbNWb.js → index-Cji3FYAQ.js} +1 -1
  89. package/_assets/{index-BZo86GEs.js → index-Ck66rPGl.js} +1 -1
  90. package/_assets/{index-BpBLqmY7.js → index-CpgH80QO.js} +307 -307
  91. package/_assets/{index-Ce2J3RrX.js → index-Csv3ZE7U.js} +1 -1
  92. package/_assets/{index-sAHvnz2N.js → index-CvEQ-uxw.js} +1 -1
  93. package/_assets/{index-2bLJt5nu.js → index-CzuJbwKM.js} +1 -1
  94. package/_assets/{index-B1yZmsbg.js → index-D-lui3ze.js} +1 -1
  95. package/_assets/{index-0wuiFD-D.js → index-D6hB217e.js} +1 -1
  96. package/_assets/{index-yJr5AHy6.js → index-D90sT5TF.js} +1 -1
  97. package/_assets/{index-C8N5dIBi.js → index-DCty_Nzt.js} +1 -1
  98. package/_assets/{index-DrdjzH9k.js → index-DGVpcWzu.js} +1 -1
  99. package/_assets/{index-DEpHjDox.js → index-DIEYvaFA.js} +1 -1
  100. package/_assets/{index-YX6Ay2YX.js → index-DM21W4eU.js} +1 -1
  101. package/_assets/{index-DisgA_Kp.js → index-DMqWpF7F.js} +1 -1
  102. package/_assets/{index-C1ABS6aZ.js → index-DR22dJ1f.js} +1 -1
  103. package/_assets/{index-BCbVNwA6.js → index-DXEO_tM8.js} +1 -1
  104. package/_assets/{index-B41s2t0I.js → index-DZE8IM2d.js} +1 -1
  105. package/_assets/{index-BqQA-htt.js → index-D_RGYDYj.js} +1 -1
  106. package/_assets/{index-BwT65Ui0.js → index-Dctqjcot.js} +1 -1
  107. package/_assets/{index-aOhbQl_e.js → index-Desa5DLU.js} +1 -1
  108. package/_assets/{index-js8gBwwu.js → index-DlOXAhkq.js} +1 -1
  109. package/_assets/{index-Bk3FocQt.js → index-DmohqnOc.js} +1 -1
  110. package/_assets/{index-D3CBiscc.js → index-DpfgsZS7.js} +2 -2
  111. package/_assets/{index-G_9AGT2d.js → index-E6MYA_qz.js} +1 -1
  112. package/_assets/{index-Ca2t9jnc.js → index-GGunchuI.js} +1 -1
  113. package/_assets/{index-BQAoWWgI.js → index-WGFd54XN.js} +1 -1
  114. package/_assets/{index-CPVal8wI.js → index-Y3vrFRTZ.js} +1 -1
  115. package/_assets/{index-BG93ruhj.js → index-YtrNc4_U.js} +1 -1
  116. package/_assets/{index-Bfbo1-y3.js → index-_VGZGU-r.js} +3 -3
  117. package/_assets/{index-BQbGdQCn.js → index-b59UUC3O.js} +1 -1
  118. package/_assets/{index-D7sH_woo.js → index-mHYk9Ana.js} +1 -1
  119. package/_assets/{index-BLtmHnvk.js → index-ojnKZ8lo.js} +1 -1
  120. package/_assets/{index-DPh8zvp5.js → index-prmd5qIM.js} +1 -1
  121. package/_assets/{index-Cutc7nXs.js → index-vO2jCoJA.js} +1 -1
  122. package/_assets/{index.es-CAm13D3S.js → index.es-CM-7pdUr.js} +1 -1
  123. package/_assets/{index.es-_sMtTPSc.js → index.es-C_PIRdls.js} +4 -4
  124. package/_assets/{index.es-nXwNgZDa.js → index.es-iNKw5JYV.js} +1 -1
  125. package/_assets/{localBatchGatewayRequest-DldZ90JU.js → localBatchGatewayRequest-CvrWva1S.js} +1 -1
  126. package/_assets/{networks-A_3lFdbQ.js → networks-DxxML95J.js} +1 -1
  127. package/_assets/{onramp-uIn5Hze6.js → onramp-DlmUl4wC.js} +1 -1
  128. package/_assets/{openzeppelin-K0lueS2f.js → openzeppelin-oRjzN4zB.js} +1 -1
  129. package/_assets/{parseNft-B8gQqMLe.js → parseNft-B1VtTOpw.js} +2 -2
  130. package/_assets/{parseSignature-eP7njmVY.js → parseSignature-CiDHU6Nz.js} +1 -1
  131. package/_assets/{parseSignature-DzYQN9v3.js → parseSignature-D_U2MhSK.js} +3 -3
  132. package/_assets/{passkeys-CdjlkSrV.js → passkeys-C4nRLQjw.js} +1 -1
  133. package/_assets/{pay-with-exchange-2kPfthhA.js → pay-with-exchange-DjjSaX9l.js} +1 -1
  134. package/_assets/{qr-overlay-lH0GRusa.js → qr-overlay-D6ySLpj4.js} +1 -1
  135. package/_assets/{receive-D9VTDtK7.js → receive-BmTDhzFh.js} +1 -1
  136. package/_assets/{resolveImplementation-BBpjC548.js → resolveImplementation-C8betaeH.js} +1 -1
  137. package/_assets/{rpc-QKrpJtdm.js → rpc-BIRrsCrS.js} +1 -1
  138. package/_assets/{secp256k1-CYkRl_Jj.js → secp256k1-BKrO94JQ.js} +1 -1
  139. package/_assets/{secp256k1-DhRlT0ib.js → secp256k1-BKzdJAUQ.js} +1 -1
  140. package/_assets/{secp256k1-BC1FlI33.js → secp256k1-ChWI25jO.js} +1 -1
  141. package/_assets/{send-BR0llNO1.js → send-DkppUNQD.js} +1 -1
  142. package/_assets/{send-batch-transaction-BCKT8nBl.js → send-batch-transaction-BT57-cdv.js} +1 -1
  143. package/_assets/{send-eip712-transaction-DJ0zmOUy.js → send-eip712-transaction-DzyYzWbO.js} +2 -2
  144. package/_assets/{send-gasless-transaction-BjdM8j2X.js → send-gasless-transaction-CEY__cC5.js} +2 -2
  145. package/_assets/{send-transaction-C8RVBMn9.js → send-transaction-BUcSoRKJ.js} +2 -2
  146. package/_assets/{sendMetaTransaction-CcYdCbY-.js → sendMetaTransaction-ZsFc6TYS.js} +1 -1
  147. package/_assets/{sendRawTransaction-daS8Cqba.js → sendRawTransaction-RwVbISDi.js} +3 -3
  148. package/_assets/{serializeTransaction-hW8PYHkl.js → serializeTransaction-D7Ih8-j7.js} +1 -1
  149. package/_assets/{session-proposal-CqH6oHj9.js → session-proposal-BDnKkUie.js} +1 -1
  150. package/_assets/{session-request-BWv_wt41.js → session-request-maNMGkDh.js} +2 -2
  151. package/_assets/{signing-BqfCVU3I.js → signing-O4ufWRe8.js} +3 -3
  152. package/_assets/{skeleton.styles-DagyoT5y.js → skeleton.styles-B5G3DoRu.js} +1 -1
  153. package/_assets/{socials-D4goIlBt.js → socials-DgrJfl24.js} +1 -1
  154. package/_assets/{styled-CoVCpn99.js → styled-CzuG2SF7.js} +1 -1
  155. package/_assets/{swaps-GJ4U9DHL.js → swaps-CEuJEeBK.js} +1 -1
  156. package/_assets/{thirdweb-F_-Px602.js → thirdweb-CWMxyfTR.js} +3 -3
  157. package/_assets/{to-serializable-transaction-BkPY6iHK.js → to-serializable-transaction-eILRk2uK.js} +2 -2
  158. package/_assets/{transactionReceipt-iJ97NYxd.js → transactionReceipt-YxHkhYmR.js} +1 -1
  159. package/_assets/{transactions-Cl8fRRc0.js → transactions-DFikge11.js} +1 -1
  160. package/_assets/{useCreditPacks-Dsfos9wm.js → useCreditPacks-CPiiIVbF.js} +1 -1
  161. package/_assets/{useImportable-Bn9l5AUn.js → useImportable-BhPYUErM.js} +1 -1
  162. package/_assets/{useInfiniteGrid-VPnx9W8Q.js → useInfiniteGrid-DmIgZTT1.js} +1 -1
  163. package/_assets/{useTheme-D2_ZQh6-.js → useTheme-DnWPXYyn.js} +1 -1
  164. package/_assets/{verifyHash-DlqrxU4F.js → verifyHash-BCo8j0IO.js} +1 -1
  165. package/_assets/{w3m-modal-DRnBD4CD.js → w3m-modal-D7JdGvOC.js} +1 -1
  166. package/_assets/{w3m-modal-BTAbPei6.js → w3m-modal-Dyp8brdF.js} +1 -1
  167. package/_assets/{wait-for-tx-receipt-CETDDyPM.js → wait-for-tx-receipt-ITlfousv.js} +1 -1
  168. package/_assets/{wallets-91m5q0QW.js → wallets-DoMl3uKp.js} +5 -5
  169. package/_assets/{web-connector-qXgR2Q4O.js → web-connector-uCJIkgMa.js} +3 -3
  170. package/_assets/{writeContract-IIDoxAya.js → writeContract-DMg_Cu_T.js} +1 -1
  171. package/_assets/{zoraTestnet-ev6ZVcwL.js → zoraTestnet-CzhulMA0.js} +1 -1
  172. package/index.html +11 -11
  173. package/package.json +2 -2
  174. package/_assets/Cart-Ctyse8xg.js +0 -707
  175. package/_assets/LazyEmoteControls-BNHGzPTO.js +0 -2
@@ -1,4 +1,4 @@
1
- import{L as k,d as te,j as e,r as p}from"./react-BYHuwl8r.js";import{s as t,I as j,t as ie,O as se,P as ae,Q as ne,B as w,R as oe,o as B,S as re,v as le,x as de,b as a,U as M,V as F,W as ce,X as pe,Y as he,Z as me,$ as xe,a0 as ue,a1 as ge,a2 as fe,a3 as be,a4 as ve,a5 as ye,a6 as je,a7 as we,a8 as ke,a9 as Ie,aa as $e,z as E,ab as Ce,ac as Ee,ad as ze,ae as Le,af as Oe,ag as Se}from"./index-BpBLqmY7.js";import{E as _}from"./ErrorNotice-BG4CBNkl.js";import{E as Ae}from"./LazyEmoteControls-BNHGzPTO.js";import{O as Fe}from"./OutfitPreview-BDsx1Zln.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:o,radius:Ne,media:d}=ie,H=t.div`
1
+ import{L as k,d as te,j as e,r as p}from"./react-BYHuwl8r.js";import{s as t,I as j,t as ie,O as se,P as ae,Q as ne,B as w,R as oe,o as B,S as re,v as le,x as de,b as a,U as M,V as F,W as ce,X as pe,Y as he,Z as me,$ as xe,a0 as ue,a1 as ge,a2 as fe,a3 as be,a4 as ve,a5 as ye,a6 as je,a7 as we,a8 as ke,a9 as Ie,aa as $e,z as E,ab as Ce,ac as Ee,ad as ze,ae as Le,af as Oe,ag as Se}from"./index-CpgH80QO.js";import{E as _}from"./ErrorNotice-h0GUcJEu.js";import{E as Ae}from"./LazyEmoteControls-Dsz7X5iX.js";import{O as Fe}from"./OutfitPreview-DEQlnmtN.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:o,radius:Ne,media:d}=ie,H=t.div`
2
2
  max-width: 1721px;
3
3
  margin: 0 auto;
4
4
  `,Te=t.nav`
@@ -1,4 +1,4 @@
1
- import{r,j as n}from"./react-BYHuwl8r.js";import{d as v}from"./dcl-schemas-CmtP3U6y.js";import{s as P,Y as R,ah as F,c as O,ai as S,b as B}from"./index-BpBLqmY7.js";import{d as W}from"./disposePreview-5vjiqVZ0.js";const H=P.div`
1
+ import{r,j as n}from"./react-BYHuwl8r.js";import{d as v}from"./dcl-schemas-CmtP3U6y.js";import{s as P,Y as R,ah as F,c as O,ai as S,b as B}from"./index-CpgH80QO.js";import{d as W}from"./disposePreview-5vjiqVZ0.js";const H=P.div`
2
2
  position: absolute;
3
3
  inset: 0;
4
4
  display: grid;
@@ -1,4 +1,4 @@
1
- import{r as d,j as t,L as A,d as Qt,a as Vt,b as Jt}from"./react-BYHuwl8r.js";import{s as o,t as dt,I as K,aI as Xt,b as e,z as st,B as x,K as kt,o as J,S as Yt,x as Zt,A as Tt,v as Ct,W as te,a0 as N,aJ as Q,aK as ee,aL as ie,aM as V,a5 as se,a6 as oe,a3 as ae,a4 as ne,U as It,a9 as re,aN as ot,aO as de,aP as le,aQ as ue,E as F,aR as Et,aS as Lt,aT as O,F as at,aU as nt,aV as ce,aW as pe,aX as fe,$ as me,aY as he,aZ as xe,ag as ge}from"./index-BpBLqmY7.js";import{E as H}from"./ErrorNotice-BG4CBNkl.js";import{L as be}from"./LoadMore-BLHzgyNQ.js";import{u as ye}from"./useInfiniteGrid-VPnx9W8Q.js";import{O as je}from"./OutfitPreview-BDsx1Zln.js";import{T as ve}from"./skeleton.styles-DagyoT5y.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:h,radius:X,media:we}=dt,$e=o.div`
1
+ import{r as d,j as t,L as A,d as Qt,a as Vt,b as Jt}from"./react-BYHuwl8r.js";import{s as o,t as dt,I as K,aI as Xt,b as e,z as st,B as x,K as kt,o as J,S as Yt,x as Zt,A as Tt,v as Ct,W as te,a0 as N,aJ as Q,aK as ee,aL as ie,aM as V,a5 as se,a6 as oe,a3 as ae,a4 as ne,U as It,a9 as re,aN as ot,aO as de,aP as le,aQ as ue,E as F,aR as Et,aS as Lt,aT as O,F as at,aU as nt,aV as ce,aW as pe,aX as fe,$ as me,aY as he,aZ as xe,ag as ge}from"./index-CpgH80QO.js";import{E as H}from"./ErrorNotice-h0GUcJEu.js";import{L as be}from"./LoadMore-D4fnHonl.js";import{u as ye}from"./useInfiniteGrid-DmIgZTT1.js";import{O as je}from"./OutfitPreview-DEQlnmtN.js";import{T as ve}from"./skeleton.styles-B5G3DoRu.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:h,radius:X,media:we}=dt,$e=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,b as le,r as l}from"./react-BYHuwl8r.js";import{b as s,t as j,s as a,w as ce,B as G,x as de,o as pe,A as ue,bv as ge,bA as me,bB as xe,bC as he,bD as P,I as z,bE as f,bF as fe,E as R}from"./index-BpBLqmY7.js";import{E as D}from"./ErrorNotice-BG4CBNkl.js";import{F as w}from"./field.styles-BO_2AHCA.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/1.0.1/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.0.1/_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,b as le,r as l}from"./react-BYHuwl8r.js";import{b as s,t as j,s as a,w as ce,B as G,x as de,o as pe,A as ue,bv as ge,bA as me,bB as xe,bC as he,bD as P,I as z,bE as f,bF as fe,E as R}from"./index-CpgH80QO.js";import{E as D}from"./ErrorNotice-h0GUcJEu.js";import{F as w}from"./field.styles-DxW4rsbZ.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/1.0.2-31053112537.commit-2eeb02b/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.0.2-31053112537.commit-2eeb02b/_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,4 +1,4 @@
1
- import{a as E,b as F,j as e,N as M,r as S}from"./react-BYHuwl8r.js";import{t as P,s as t,z as B,J as W,K as O,o as _,x as q,b as n,y as J,C as U,L as D,M as H,c as T,B as K,N as X}from"./index-BpBLqmY7.js";import{C as Q}from"./Confetti-z9mEz7Mo.js";import{w as Y,S as G}from"./buy-gasless-C6Uiz2ft.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./authorizations-CE0HtqU4.js";import"./sendMetaTransaction-CcYdCbY-.js";import"./buy-BF3MKHeK.js";const{colors:s,radius:f}=P,m="@media (max-width: 600px)",I=t.div`
1
+ import{a as E,b as F,j as e,N as M,r as S}from"./react-BYHuwl8r.js";import{t as P,s as t,z as B,J as W,K as O,o as _,x as q,b as n,y as J,C as U,L as D,M as H,c as T,B as K,N as X}from"./index-CpgH80QO.js";import{C as Q}from"./Confetti-BH2iBIUi.js";import{w as Y,S as G}from"./buy-gasless-cVGUwJcn.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./authorizations-GLPsQqiP.js";import"./sendMetaTransaction-ZsFc6TYS.js";import"./buy-C36PZNHt.js";const{colors:s,radius:f}=P,m="@media (max-width: 600px)",I=t.div`
2
2
  /* Its own stacking context, above the confetti layer (z-index 0). Needed because z-index is inert without
3
3
  a position, so the content would otherwise sit below the burst regardless of order. */
4
4
  position: relative;
@@ -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-BNh7T9LS.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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-CZuJfgAC.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-BpBLqmY7.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
1
+ import{r as o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-CpgH80QO.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-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.js";import{co as Re,f as te,g as re}from"./index-BpBLqmY7.js";import{c as q,e as Ie}from"./index-D3CBiscc.js";import{s as Pe}from"./sendMetaTransaction-CcYdCbY-.js";import"./sentry-Dx-KuLV3.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function be(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 be(r);return new ue(t)}const S=new Ie.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),I=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(I.populateTransaction):I.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 b=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:b.hash}),b.hash}else{const v=await Pe(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,I=2147483647,T=36,v=1,b=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*b>>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,R,P,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(P=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((I-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+b?b:m-h,!(g<A);m+=T)L=T-A,f>E(I/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-P,u,P==0),E(d/u)>I-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,P,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=I,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((I-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>I&&F("overflow"),f==a){for(x=o,R=T;P=R<=y?v:R>=y+b?b:R-y,!(x<P);R+=T)j=x-P,L=T-P,m.push(O(Y(P+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};
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-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.js";import{co as Re,f as te,g as re}from"./index-CpgH80QO.js";import{c as q,e as Ie}from"./index-DpfgsZS7.js";import{s as Pe}from"./sendMetaTransaction-ZsFc6TYS.js";import"./sentry-Dx-KuLV3.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function be(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 be(r);return new ue(t)}const S=new Ie.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),I=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(I.populateTransaction):I.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 b=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:b.hash}),b.hash}else{const v=await Pe(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,I=2147483647,T=36,v=1,b=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*b>>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,R,P,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(P=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((I-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+b?b:m-h,!(g<A);m+=T)L=T-A,f>E(I/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-P,u,P==0),E(d/u)>I-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,P,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=I,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((I-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>I&&F("overflow"),f==a){for(x=o,R=T;P=R<=y?v:R>=y+b?b:R-y,!(x<P);R+=T)j=x-P,L=T-P,m.push(O(Y(P+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};