@dcl/shop 0.3.0 → 0.4.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.
- package/_assets/{Activity-CysvRMDH.js → Activity-CSDWiFkq.js} +1 -1
- package/_assets/{AnimatedBackground-1KvWirPP.js → AnimatedBackground-vKrEOHA5.js} +1 -1
- package/_assets/{Assets-CmA7g8ft.js → Assets-Cogahyqe.js} +3 -3
- package/_assets/{Assets.styles-BwMj4485.js → Assets.styles-B2EWL6JB.js} +1 -1
- package/_assets/{Authorizations-CfvVeEJl.js → Authorizations-BrKYlkZG.js} +1 -1
- package/_assets/{Cart-CYHKPPD-.js → Cart-W8w3sCuV.js} +5 -5
- package/_assets/{CircularProgress-oGg4qqHc.js → CircularProgress--GC-6I6k.js} +1 -1
- package/_assets/{Collection-Dmap3sR_.js → Collection-D16pjJSe.js} +1 -1
- package/_assets/{CollectionCarousel-DiADjTg-.js → CollectionCarousel-BeuBL17J.js} +77 -77
- package/_assets/{Creator-DB4BIeTa.js → Creator-BLsHzXRL.js} +1 -1
- package/_assets/{ErrorNotice-CBx78pQu.js → ErrorNotice-Cvc0nTjw.js} +1 -1
- package/_assets/{ExchangeController-DOvKzvyb.js → ExchangeController-DoFEzXko.js} +1 -1
- package/_assets/{GetCredits-Ch_OO41P.js → GetCredits-bxJh6m8F.js} +94 -130
- package/_assets/{HelpersUtil-CFCkU-g3.js → HelpersUtil-BFgierZ-.js} +1 -1
- package/_assets/{ImportListings-BGmtSIDb.js → ImportListings-BwORJ3CC.js} +13 -13
- package/_assets/{ItemDetail-ramYOGDR.js → ItemDetail-PoeIzOPp.js} +194 -194
- package/_assets/{ItemPreview.styles-D8aGYVBK.js → ItemPreview.styles-DtAUND9N.js} +1 -1
- package/_assets/{LoadMore-BSE8BKwI.js → LoadMore-DsWSQHxD.js} +1 -1
- package/_assets/ManaPricingBanner.styles-CF0iOeeS.js +74 -0
- package/_assets/{MenuList-qnDzTtfz.js → MenuList-DNOqfxHx.js} +1 -1
- package/_assets/{MyAssets-CgneL-KA.js → MyAssets-2XwaE-SE.js} +4 -4
- package/_assets/{MyFavorites-DrPT--am.js → MyFavorites-DIi3ztNe.js} +1 -1
- package/_assets/{NotFound-4IJj-QH6.js → NotFound-jHtQUp44.js} +1 -1
- package/_assets/{NotificationsBell-BOg2j5-7.js → NotificationsBell-By0uu4SI.js} +1 -1
- package/_assets/{OutfitDetail-DAfw3jDe.js → OutfitDetail-BQr6vhnT.js} +1 -1
- package/_assets/{OutfitPreview-DMQpfBpS.js → OutfitPreview-D6Z7-XEK.js} +1 -1
- package/_assets/{OutfitStudio-qASOqFO4.js → OutfitStudio-BFWU775v.js} +1 -1
- package/_assets/{StoreSettings-CjbyuHVf.js → StoreSettings-BJTpsKoX.js} +1 -1
- package/_assets/{Success-Ba2GyRY_.js → Success-CIQKaiOo.js} +1 -1
- package/_assets/{SwapController-B823Ep4J.js → SwapController-XcLKHFDT.js} +1 -1
- package/_assets/{Tooltip-2XcUkoOj.js → Tooltip-fS4VCxQs.js} +1 -1
- package/_assets/{TradeService-lYuRlk4v.js → TradeService-BgfeT0JQ.js} +1 -1
- package/_assets/{W3MFrameProviderSingleton-B8ZAc5Tp.js → W3MFrameProviderSingleton-BJE-tnmd.js} +3 -3
- package/_assets/{WebCryptoP256-CrjjL3U7.js → WebCryptoP256-P_MkVOZf.js} +1 -1
- package/_assets/authorizations-Bm65kFBw.js +1 -0
- package/_assets/{basic-3OIT7lDP.js → basic-BzdDurZu.js} +1 -1
- package/_assets/{biconomy-CLvfOfCg.js → biconomy-BHLIxKXm.js} +1 -1
- package/_assets/{browseLayout.styles-DCwE16ZG.js → browseLayout.styles-D_JQHeMK.js} +4 -4
- package/_assets/{builder-CoZ9B86k.js → builder-CPpn-LV6.js} +1 -1
- package/_assets/buy-CfVy6xwA.js +1 -0
- package/_assets/{buy-gasless-uIQiLsX8.js → buy-gasless-DmFIjDH7.js} +1 -1
- package/_assets/categories-D2JgaepG.js +448 -0
- package/_assets/{ccip-C8TW-3ey.js → ccip-BGuL2CTW.js} +1 -1
- package/_assets/{ccip-C4f9EXfY.js → ccip-japHsC-d.js} +1 -1
- package/_assets/{clsx-BsYHeX03.js → clsx-DY37pDvc.js} +1 -1
- package/_assets/{controller-ASkKeRkX.js → controller-CEuTNpMI.js} +2 -2
- package/_assets/{core-X_wu6_Dy.js → core-DFTtNj6Y.js} +4 -4
- package/_assets/{createSvgIcon-D4cpIqvx.js → createSvgIcon-BFo-10ds.js} +3 -3
- package/_assets/{custom-BVAi4D5H.js → custom-DyS8vC8K.js} +1 -1
- package/_assets/{data-capture-C23iRBhs.js → data-capture-CpqP5gpO.js} +1 -1
- package/_assets/{email-CB03fcCQ.js → email-DOkwtMrW.js} +1 -1
- package/_assets/{embedded-wallet-CnMDk9db.js → embedded-wallet-BI0I-FyI.js} +1 -1
- package/_assets/{emotion-styled.browser.esm-CNluusdx.js → emotion-styled.browser.esm-nmKSs9QV.js} +1 -1
- package/_assets/{engine-DaJGLPH7.js → engine-BsCDGGhp.js} +1 -1
- package/_assets/{errors-CJ4NHTPm.js → errors-CVWX9epA.js} +1 -1
- package/_assets/{estimate-l1-fee-DC2eYWPQ.js → estimate-l1-fee-BwVQYvPZ.js} +1 -1
- package/_assets/{execute-vh_I47EG.js → execute-DCjeHtk2.js} +2 -2
- package/_assets/{features-i2gsSk7q.js → features-DmQF08Nd.js} +1 -1
- package/_assets/{fetchTokenMetadata-DpicXKCe.js → fetchTokenMetadata-DtvlyEpN.js} +2 -2
- package/_assets/{field.styles-DPC95Ntd.js → field.styles-ZqzDOrCY.js} +1 -1
- package/_assets/{get-ecosystem-wallet-info-B8_se1pi.js → get-ecosystem-wallet-info-glXHSBBX.js} +1 -1
- package/_assets/{getBalance-Cee2d5fc.js → getBalance-D4uOuyXp.js} +1 -1
- package/_assets/{getNFT-CUD-atXT.js → getNFT-D9u1poHS.js} +1 -1
- package/_assets/{getNFT-BjnrEAq8.js → getNFT-VYQvQv4K.js} +1 -1
- package/_assets/{getThemeProps-B71MHgCC.js → getThemeProps-BOJ8W9dy.js} +1 -1
- package/_assets/{grid.styles-q_RkLJKv.js → grid.styles-C92STzz7.js} +1 -1
- package/_assets/{hashTypedData-Bclxfb96.js → hashTypedData-CU4XEihs.js} +1 -1
- package/_assets/{hashTypedData-CiuZE5MB.js → hashTypedData-Cmk_4l7W.js} +1 -1
- package/_assets/hero-credits-outfits-DeMMQYZj.webp +0 -0
- package/_assets/{in-app-DoTVgkA7.js → in-app-n2C_GYjN.js} +1 -1
- package/_assets/{in-app-wallet-calls-aTpQmtYp.js → in-app-wallet-calls-BH4EHvoE.js} +1 -1
- package/_assets/{index-DJ0Ox_g6.js → index-1DlQc04C.js} +1 -1
- package/_assets/{index-oYINO7Gh.js → index-1E3TZOEp.js} +3 -3
- package/_assets/{index-ZtNObKUx.js → index-3G1ZZRHy.js} +1 -1
- package/_assets/{index-C_quGuYS.js → index-5ZQ75r5A.js} +2 -2
- package/_assets/{index-BOqO3K08.js → index-5oJAYQpS.js} +1 -1
- package/_assets/{index-DnUnGNK1.js → index-8ahFN9pV.js} +1 -1
- package/_assets/{index-BLIOngWK.js → index-9ZSFZyk5.js} +1 -1
- package/_assets/{index-CkdrAVd7.js → index-B-0owZIE.js} +1 -1
- package/_assets/{index-KhxRGpab.js → index-B-2A_xJK.js} +1 -1
- package/_assets/index-B0wrSWVL.js +3467 -0
- package/_assets/{index-DxbeSgwP.js → index-B33pX4sx.js} +1 -1
- package/_assets/{index-CnAxZm7a.js → index-B6HLteu2.js} +1 -1
- package/_assets/{index-C-ZPerkC.js → index-B95j5ECm.js} +1 -1
- package/_assets/{index-D2Hh-irJ.js → index-BAGHoKjd.js} +1 -1
- package/_assets/{index-BdZJNMhf.js → index-BAKuuHpY.js} +1 -1
- package/_assets/{index-Br-QxSL4.js → index-BBLwTza9.js} +1 -1
- package/_assets/{index-CLm5_lcW.js → index-BFbvmloZ.js} +1 -1
- package/_assets/{index-DREmVGyP.js → index-BKB9eVo_.js} +1 -1
- package/_assets/{index-CShk5nTD.js → index-Bdk6ierZ.js} +1 -1
- package/_assets/{index-pDIZRYxP.js → index-BmtMJnoP.js} +2 -2
- package/_assets/{index-DzoYWAIJ.js → index-Bnnl1_Pn.js} +1 -1
- package/_assets/{index-CHLJVbwu.js → index-BpfebiBi.js} +1 -1
- package/_assets/{index-Dqt4TaYh.js → index-BvzZi8lQ.js} +1 -1
- package/_assets/{index-BnVjsoyV.js → index-C1Zza7kR.js} +3 -3
- package/_assets/{index-LbRdNAf3.js → index-C75VmoUV.js} +1 -1
- package/_assets/{index-CiqC5vqm.js → index-CCQWBULG.js} +1 -1
- package/_assets/{index-DAKpmmlR.js → index-CDzrsoju.js} +1 -1
- package/_assets/{index-DpAZRpHS.js → index-CFJ4759x.js} +1 -1
- package/_assets/{index-DmmqNlbI.js → index-CMiDANew.js} +1 -1
- package/_assets/{index-6U0_groo.js → index-CNek90qs.js} +1 -1
- package/_assets/{index-BIMSqj0E.js → index-CS26D5br.js} +1 -1
- package/_assets/index-D-NhBWWr.css +1 -0
- package/_assets/{index-Da9c_8XH.js → index-DCJFwzag.js} +1 -1
- package/_assets/{index-B8WxnCSZ.js → index-DCkPd79h.js} +1 -1
- package/_assets/{index-AvMVq3p5.js → index-DO-41U6s.js} +1 -1
- package/_assets/{index-Zni41xRh.js → index-DU7iVDBh.js} +3 -3
- package/_assets/{index-X-5FVXow.js → index-DUOePrjP.js} +1 -1
- package/_assets/{index-BmR9lQvd.js → index-DWyeO73d.js} +1 -1
- package/_assets/{index-CqqbmEIM.js → index-Das01MWO.js} +2 -2
- package/_assets/{index-CKgjOb17.js → index-DcW0aOo_.js} +1 -1
- package/_assets/{index-D2cHV9P4.js → index-Dg3cba8i.js} +1 -1
- package/_assets/{index-umhEn8if.js → index-DgIUvj1u.js} +1 -1
- package/_assets/{index-B-yk4_og.js → index-Drzr7GIe.js} +1 -1
- package/_assets/{index-DhW6Eiq4.js → index-DuYquyJk.js} +1 -1
- package/_assets/{index-grey-Hql.js → index-Dyb9tM0L.js} +1 -1
- package/_assets/{index-CQd88f4P.js → index-S5ytn1G_.js} +1 -1
- package/_assets/{index-pkIYUyEs.js → index-X1g5-mc1.js} +2 -2
- package/_assets/{index-Bm4qVnUT.js → index-YlEZ0MB-.js} +1 -1
- package/_assets/{index-Dk_Ivei2.js → index-gO1p5U4e.js} +1 -1
- package/_assets/{index-BMHjpFTY.js → index-iVhRHvGC.js} +1 -1
- package/_assets/{index-5tjsFjOD.js → index-lc1BgLRJ.js} +1 -1
- package/_assets/{index-tvenjK5z.js → index-x_f1XpFN.js} +1 -1
- package/_assets/{index.es-C5-qOo53.js → index.es-CYrm9JiK.js} +4 -4
- package/_assets/{index.es-C4q67lvL.js → index.es-D-Hj-yaE.js} +1 -1
- package/_assets/{index.es-gI39JHkd.js → index.es-DlCKcYQh.js} +1 -1
- package/_assets/{localBatchGatewayRequest-CYWicxBl.js → localBatchGatewayRequest-D-M3uJjn.js} +1 -1
- package/_assets/{mana-convert-C239nuRR.js → mana-convert-XtWFaGCt.js} +1 -1
- package/_assets/{mana-rate-CWXyJ6Qt.js → mana-rate-CLS7fjKR.js} +1 -1
- package/_assets/{networks-CdC9lKkb.js → networks-DLkt_HOu.js} +1 -1
- package/_assets/{onramp-B6zv6owZ.js → onramp-B9C9zg8X.js} +1 -1
- package/_assets/{openzeppelin-fBZEbwFp.js → openzeppelin-Czmq9Q8z.js} +1 -1
- package/_assets/{parseNft-Dn6QDQHN.js → parseNft-Df0bG2_u.js} +2 -2
- package/_assets/{parseSignature-DecBV3iH.js → parseSignature-Cu3sQgfL.js} +1 -1
- package/_assets/{parseSignature-DAHrPk4v.js → parseSignature-nbJG9PDg.js} +3 -3
- package/_assets/{passkeys-KiBei2LX.js → passkeys-UkbavCkH.js} +1 -1
- package/_assets/{pay-with-exchange-D9SNWmjx.js → pay-with-exchange-BZkWaWxT.js} +1 -1
- package/_assets/{qr-overlay-2zAa6fld.js → qr-overlay-BE8jnAiO.js} +1 -1
- package/_assets/{receive-ChxNL97S.js → receive-B2e1QRi3.js} +1 -1
- package/_assets/{resolveImplementation-BNaLKkof.js → resolveImplementation-BBe0akeh.js} +1 -1
- package/_assets/{rpc-DBHsoP5N.js → rpc-iEVF2nz4.js} +1 -1
- package/_assets/{secp256k1-C8JTXBnF.js → secp256k1-Ba2kPpNf.js} +1 -1
- package/_assets/{secp256k1-C2pLUi5w.js → secp256k1-ClQ_G_RL.js} +1 -1
- package/_assets/{secp256k1-xOB6yMRi.js → secp256k1-e7mCjC3J.js} +1 -1
- package/_assets/{send-BLmLJ3eA.js → send-BOmHA5ER.js} +1 -1
- package/_assets/{send-batch-transaction-120lF45D.js → send-batch-transaction-C1STwRsa.js} +1 -1
- package/_assets/{send-eip712-transaction-B2w1ZAOY.js → send-eip712-transaction-Dy9FgG1n.js} +2 -2
- package/_assets/{send-gasless-transaction-oH9WEYVY.js → send-gasless-transaction-C66wRlKz.js} +2 -2
- package/_assets/{send-transaction-CLaO8DmY.js → send-transaction-CLuOLZ7t.js} +2 -2
- package/_assets/{sendMetaTransaction-OKd_ifNL.js → sendMetaTransaction-DvDr2bCi.js} +1 -1
- package/_assets/{sendRawTransaction-BP5hNXP6.js → sendRawTransaction-DqkFhazS.js} +3 -3
- package/_assets/{serializeTransaction--Dr7RtAU.js → serializeTransaction-BEOUomEz.js} +1 -1
- package/_assets/{session-proposal-CiYz-jZC.js → session-proposal-UXG0f185.js} +1 -1
- package/_assets/{session-request-Clv9A0oy.js → session-request-DIqK3WRK.js} +2 -2
- package/_assets/{signing-CJ5kWk7o.js → signing-DReJZKDs.js} +3 -3
- package/_assets/{socials-CeLfiCF9.js → socials-CdGrw0ok.js} +1 -1
- package/_assets/{swaps-DkDPQf9R.js → swaps-CycOd3sO.js} +1 -1
- package/_assets/{thirdweb-BcTKOQfU.js → thirdweb-D5w8-dkS.js} +3 -3
- package/_assets/{to-serializable-transaction-CVgEJJoF.js → to-serializable-transaction-C1TwC6Ti.js} +2 -2
- package/_assets/{trade-encoding-COAHYjJi.js → trade-encoding-Mw7kNWLf.js} +1 -1
- package/_assets/{transactionReceipt-dayojTpn.js → transactionReceipt-DyOMk-YN.js} +1 -1
- package/_assets/{transactions-BqxmWzZz.js → transactions-VmU1Fomk.js} +1 -1
- package/_assets/{useCreditPacks-CHpQ4LEN.js → useCreditPacks-D1yz9_D9.js} +1 -1
- package/_assets/{useInfiniteGrid-sc2vmuxU.js → useInfiniteGrid-C-7TbIWI.js} +1 -1
- package/_assets/useManaRate-6JYRR5Sm.js +1 -0
- package/_assets/{useSecondarySales-C8BuUV_s.js → useSecondarySales-BhfHOcZl.js} +1 -1
- package/_assets/{useStore-D3ONm_sP.js → useStore-DCWOq5iS.js} +1 -1
- package/_assets/{useTheme-D8ClSCiJ.js → useTheme-DoVQgCCM.js} +1 -1
- package/_assets/{verifyHash-tNHFcENz.js → verifyHash-B-nszbU3.js} +1 -1
- package/_assets/{w3m-modal-D0qE5VS7.js → w3m-modal-C9EOWDq3.js} +1 -1
- package/_assets/{w3m-modal-BYIDrkH-.js → w3m-modal-y9ZrKukQ.js} +1 -1
- package/_assets/{wait-for-tx-receipt-C3lxZWQH.js → wait-for-tx-receipt-DL1snjgl.js} +1 -1
- package/_assets/{wallets-BlFrUv2a.js → wallets-CExmmU6y.js} +5 -5
- package/_assets/{web-connector-DzEBomI8.js → web-connector-vE0RE6CB.js} +3 -3
- package/_assets/{writeContract-CaaID3Lc.js → writeContract-B0sDSczf.js} +1 -1
- package/_assets/{zoraTestnet-Da9dTQUp.js → zoraTestnet-B_NFi9S-.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/_assets/ManaPricingBanner.styles-bQxgJp4R.js +0 -74
- package/_assets/authorizations-BeJcD0Ty.js +0 -1
- package/_assets/buy-5BIPC7Eq.js +0 -1
- package/_assets/categories-CmiNaFHh.js +0 -427
- package/_assets/hero-fashion-week-B9LOzkde.png +0 -0
- package/_assets/index-9_8O7Lhc.js +0 -3488
- package/_assets/index-BMzstP-8.css +0 -1
- package/_assets/promo-best-rated-emotes-C6kNvB-a.png +0 -0
- package/_assets/promo-week-selected-outfits-BBmkZYZx.png +0 -0
- package/_assets/useManaRate-Ceh_R3VR.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-
|
|
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-B0wrSWVL.js";import{E as H}from"./ErrorNotice-Cvc0nTjw.js";import{O as Pe}from"./OutfitPreview-D6Z7-XEK.js";import{T as Fe,a as O,b as R,c as W}from"./ItemPreview.styles-DtAUND9N.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,4 +1,4 @@
|
|
|
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-
|
|
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-B0wrSWVL.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;
|
|
@@ -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-
|
|
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-B0wrSWVL.js";import{E as D}from"./ErrorNotice-Cvc0nTjw.js";import{L as pe}from"./LoadMore-DsWSQHxD.js";import{u as fe}from"./useInfiniteGrid-C-7TbIWI.js";import{O as he}from"./OutfitPreview-D6Z7-XEK.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-
|
|
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-B0wrSWVL.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-DCWOq5iS.js";import{E as M}from"./ErrorNotice-Cvc0nTjw.js";import{F as w}from"./field.styles-ZqzDOrCY.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.4.0/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.4.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-
|
|
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-B0wrSWVL.js";import{w as G,S as K}from"./buy-gasless-DmFIjDH7.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-Bm65kFBw.js";import"./sendMetaTransaction-DvDr2bCi.js";import"./trade-encoding-Mw7kNWLf.js";const Q=t.div`
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
5
5
|
/**
|
|
@@ -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-B8ZAc5Tp.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-BJE-tnmd.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-
|
|
1
|
+
import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-B0wrSWVL.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{
|
|
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-B0wrSWVL.js";import{c as q,e as Re}from"./index-Das01MWO.js";import{s as Ie}from"./sendMetaTransaction-DvDr2bCi.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"&ⅇ(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};
|