@dcl/shop 0.1.0-29996672089.commit-ce4d282 → 0.1.0-30015679616.commit-6ed38d1
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-ji9z26-b.js → Activity-CU84JTL9.js} +1 -1
- package/assets/{AnimatedBackground-dlJZeXOs.js → AnimatedBackground-C1yb3yRx.js} +1 -1
- package/assets/{Assets-DHtvK9gi.js → Assets-w-8PFxJU.js} +1 -1
- package/assets/{Assets.styles-DBA9HXW7.js → Assets.styles-C1Y1ZCen.js} +1 -1
- package/assets/{Authorizations-BNMCiOdB.js → Authorizations-DPyL4Pwf.js} +1 -1
- package/assets/{Cart-BlShrWP_.js → Cart-DIv_5vjj.js} +2 -2
- package/assets/{CircularProgress-DvTkhDvC.js → CircularProgress-OD5gaSs9.js} +1 -1
- package/assets/{Collection-DFIFsgYQ.js → Collection-4eeGGy6p.js} +1 -1
- package/assets/{CollectionCarousel-DMwkzkYf.js → CollectionCarousel-BK5-UOoa.js} +1 -1
- package/assets/{CollectionCarousel-BCnK8TgK.css → CollectionCarousel-C8hFnis-.css} +1 -1
- package/assets/{Creator-BzYX40qE.js → Creator-BxxKbkrm.js} +1 -1
- package/assets/{CssVarsProvider-D82yS8Ds.js → CssVarsProvider-DwDwaiXl.js} +1 -1
- package/assets/{ExchangeController-CiGVwKQf.js → ExchangeController-Ce-YvKrg.js} +1 -1
- package/assets/{GetCredits-eVhxGnMo.js → GetCredits-HKQGRif3.js} +1 -1
- package/assets/{HelpersUtil-C32FavmO.js → HelpersUtil-Cl7yYI0y.js} +1 -1
- package/assets/{ImportListings-BiGwtdUn.js → ImportListings-CZ7e-nyf.js} +1 -1
- package/assets/ItemDetail-BF1WOMVU.css +1 -0
- package/assets/ItemDetail-CKSu3u_T.js +78 -0
- package/assets/{LoadMore-BjvEi3Wj.js → LoadMore-PZOUHqu7.js} +1 -1
- package/assets/{MarketCheckout-BB0_ss_n.js → MarketCheckout-BpXa_hJ1.js} +1 -1
- package/assets/{MyAssets-cbSiEx2B.js → MyAssets-Byt4OJv8.js} +1 -1
- package/assets/{MyFavorites-DxWrJSpf.js → MyFavorites-LDc-9tMy.js} +1 -1
- package/assets/{NotFound-Cj4SIl5T.js → NotFound-DzROMpLI.js} +1 -1
- package/assets/{PrimaryListModal-CdZJXblc.js → PrimaryListModal-NLcDjuqy.js} +1 -1
- package/assets/{StoreSettings-LdrMcuVr.js → StoreSettings-DcFPCGuf.js} +1 -1
- package/assets/{Success-BRT1MWds.js → Success-BurccWK5.js} +1 -1
- package/assets/{SwapController-CXQ00xts.js → SwapController-U7Srei6G.js} +1 -1
- package/assets/{Tooltip-BZ57TVaP.js → Tooltip-D7WpGA4F.js} +1 -1
- package/assets/{TradeService-SfkC7zHZ.js → TradeService-jQrSo7Nw.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-B8RM0-JJ.js → W3MFrameProviderSingleton-Cng56IwM.js} +3 -3
- package/assets/{WebCryptoP256-D_33Dvnx.js → WebCryptoP256-BoWVFm46.js} +1 -1
- package/assets/{authorizations-D44lw00X.js → authorizations-HljWnE0x.js} +1 -1
- package/assets/{basic-CtFzqtOx.js → basic-BjeDXEjz.js} +1 -1
- package/assets/{biconomy-BaeM1SCU.js → biconomy-D8Q7ZlMy.js} +1 -1
- package/assets/{buy-Dszi8UeF.js → buy-VyechqN8.js} +1 -1
- package/assets/{buy-gasless-Nfp6cMbQ.js → buy-gasless-jDmWcdID.js} +1 -1
- package/assets/{cart-checkout-Ba3nMBI0.js → cart-checkout-BfdGJfeX.js} +1 -1
- package/assets/{categories-D0iwhqs_.js → categories-DPdI3Qkz.js} +1 -1
- package/assets/{ccip-CaKFUjmD.js → ccip-BjFDGWLb.js} +1 -1
- package/assets/{ccip-DGnj8pvI.js → ccip-DeFaq1d_.js} +1 -1
- package/assets/{collection-DSysxaCY.js → collection-BkRN2zWi.js} +1 -1
- package/assets/{controller-DqW_a2vQ.js → controller-IuRb2Llw.js} +2 -2
- package/assets/{core-BfFj7IDN.js → core-DeIGPMkJ.js} +4 -4
- package/assets/{custom-CyKMgWLF.js → custom-BbPMc21n.js} +1 -1
- package/assets/{data-capture-DyJzM655.js → data-capture-CvSJT0zp.js} +1 -1
- package/assets/{email-B1LVTurO.js → email-DxXvAA1i.js} +1 -1
- package/assets/{embedded-wallet-DbH1O4GQ.js → embedded-wallet-B3Hc_iPo.js} +1 -1
- package/assets/{emotion-styled.browser.esm-CMXzhKww.js → emotion-styled.browser.esm-C93imo1O.js} +1 -1
- package/assets/{engine-BNiIRF8k.js → engine-SdToqEAN.js} +1 -1
- package/assets/{errors-DUo56sGG.js → errors-CVrT6Ui5.js} +1 -1
- package/assets/{estimate-l1-fee-DbEUBk2I.js → estimate-l1-fee-3aQWsG16.js} +1 -1
- package/assets/{execute-CzNqLgfO.js → execute-DcrE0vfx.js} +2 -2
- package/assets/{features-D_R5E38-.js → features-JhzProDi.js} +1 -1
- package/assets/{fetchTokenMetadata-BZsN957Y.js → fetchTokenMetadata-DMoMWhi-.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-BIlu2xkX.js → get-ecosystem-wallet-info-CtRDRJhT.js} +1 -1
- package/assets/{getBalance-BD5xADMR.js → getBalance-BAFGwIUh.js} +1 -1
- package/assets/{getNFT-DjEJIHB0.js → getNFT-DLXTo20b.js} +1 -1
- package/assets/{getNFT-B7e2uNF-.js → getNFT-Df4hxDd_.js} +1 -1
- package/assets/{getOverlayAlpha-Ho14PJoT.js → getOverlayAlpha-RimUmqv9.js} +1 -1
- package/assets/{hashTypedData-CC4Umz6j.js → hashTypedData-DsKWnNMi.js} +1 -1
- package/assets/{hashTypedData-DE2iuKMA.js → hashTypedData-mds2ITqz.js} +1 -1
- package/assets/{import-BPLVQmln.js → import-DFiOfmYU.js} +1 -1
- package/assets/{in-app-qD4m50Nn.js → in-app-B0l0x1SK.js} +1 -1
- package/assets/{in-app-wallet-calls-BcFExuty.js → in-app-wallet-calls-DP53s3Js.js} +1 -1
- package/assets/{index-D_xn82-1.js → index-B6EwdMxc.js} +1 -1
- package/assets/{index-CDkTFenk.js → index-B8Ud1Gn4.js} +2 -2
- package/assets/{index-BAKqn_lj.js → index-B9UnuYAA.js} +2 -2
- package/assets/{index-BuXSM1De.js → index-BAl_lO4N.js} +1 -1
- package/assets/{index-grzzP9n9.js → index-BHC5C2Me.js} +1 -1
- package/assets/{index-BGbFLGJH.js → index-BX1E93lF.js} +1 -1
- package/assets/{index-C8P6BHpY.js → index-BX4iAmCi.js} +3 -3
- package/assets/{index-VUv3xRHQ.js → index-BZHy0WxG.js} +1 -1
- package/assets/{index-DcVvVcVQ.js → index-Bi9_1Wvz.js} +1 -1
- package/assets/{index-D2bdndwX.js → index-BiczzCHY.js} +1 -1
- package/assets/{index-Dg2IevmK.js → index-Blr-MypE.js} +2 -2
- package/assets/{index-D_jFC223.js → index-BtwaECRG.js} +1 -1
- package/assets/{index-ByOIX4VW.js → index-Bueku0qx.js} +1 -1
- package/assets/{index-hmML8Yn6.js → index-BxKobL0r.js} +1 -1
- package/assets/{index-BNa7Mf2M.js → index-C8Sk2VHs.js} +1 -1
- package/assets/{index-CrhtLjWe.js → index-CCAGracH.js} +1 -1
- package/assets/{index-B_AeYsKa.js → index-CHGDme3B.js} +1 -1
- package/assets/{index-BnrQ0KXT.js → index-CNafSlrJ.js} +1 -1
- package/assets/{index-CGNquv7o.js → index-CQjL9b6j.js} +21 -21
- package/assets/{index-2Q-POj3l.js → index-Cbc4iV38.js} +3 -3
- package/assets/{index-z9bgkHOn.js → index-CbipyjF-.js} +1 -1
- package/assets/{index-Dv2SQ_eL.js → index-CgLGJfZ9.js} +1 -1
- package/assets/{index-C4111GJ-.js → index-CoZrrGVN.js} +1 -1
- package/assets/{index-w4_5Aj8T.js → index-CpwxIWZx.js} +1 -1
- package/assets/{index-DUx_udvr.js → index-Cueh9fW3.js} +1 -1
- package/assets/{index-CwKIaxXt.js → index-CvIarX8s.js} +1 -1
- package/assets/{index--PWwvcNI.js → index-D0FPEIJ3.js} +1 -1
- package/assets/{index-CA73t5p4.js → index-D1z7Ji2h.js} +1 -1
- package/assets/{index-DD8leihn.js → index-DI9vAn9A.js} +1 -1
- package/assets/{index-0syK5-Ww.js → index-DLuioJ0v.js} +1 -1
- package/assets/{index-B9U21JU-.js → index-DQviEuA1.js} +1 -1
- package/assets/{index-DWj03ICg.js → index-DSEo43OW.js} +1 -1
- package/assets/{index-OGdy2qbx.js → index-DSXjbhmx.js} +1 -1
- package/assets/{index-Dzj-nA_x.js → index-DURbEdp2.js} +1 -1
- package/assets/{index-Bt55wXtx.js → index-DUcqJFnf.js} +1 -1
- package/assets/{index-hDcHuSsT.js → index-DXNJ6Lvt.js} +1 -1
- package/assets/{index-DxFC7t5T.js → index-DgvHzZWg.js} +1 -1
- package/assets/{index-5RDpMwKv.js → index-DhmFzzvM.js} +1 -1
- package/assets/index-DkHZ6zdu.css +1 -0
- package/assets/{index-CXMHgbT-.js → index-Dpt4Xrxi.js} +1 -1
- package/assets/{index-Cx9QgWtN.js → index-DrmkRk7f.js} +1 -1
- package/assets/{index-Aw0QE_Br.js → index-DxCmy4WK.js} +1 -1
- package/assets/{index-CuA9C-j1.js → index-Ec6QJ8nX.js} +1 -1
- package/assets/{index-Cl3G53Lb.js → index-HaWgKZPK.js} +1 -1
- package/assets/{index-BW1vsFdc.js → index-JEnLANQt.js} +1 -1
- package/assets/{index-BBLW_jFO.js → index-Nvov0ym2.js} +1 -1
- package/assets/{index-CPvKfkxC.js → index-RUgsr-vT.js} +1 -1
- package/assets/{index-CwFsoF5e.js → index-S5h4LrtX.js} +1 -1
- package/assets/{index-I5rJvbQ1.js → index-UmAjwwfj.js} +1 -1
- package/assets/{index-BFydxC8W.js → index-geEoQpgi.js} +1 -1
- package/assets/{index-DVl2fB76.js → index-ieNrDYUU.js} +1 -1
- package/assets/{index-yRQsdAyS.js → index-kNoFdXF9.js} +3 -3
- package/assets/{index-B9n-6xCt.js → index-rd6QWbVV.js} +1 -1
- package/assets/{index.es-CMyspuf3.js → index.es-BBZwypFh.js} +4 -4
- package/assets/{index.es-CMAy1XDw.js → index.es-BEQfrgsH.js} +1 -1
- package/assets/{index.es-DLt1eklQ.js → index.es-BSvxMoWp.js} +1 -1
- package/assets/{localBatchGatewayRequest-Da4arsJr.js → localBatchGatewayRequest-BSe6m7XE.js} +1 -1
- package/assets/{mana-rate-BM11zYcS.js → mana-rate-CqpRH-06.js} +1 -1
- package/assets/{networks-CP5ZxOS7.js → networks-BZi34GRE.js} +1 -1
- package/assets/{onramp-DEaPwD93.js → onramp-D5NUX6XI.js} +1 -1
- package/assets/{openzeppelin-ubglQWTS.js → openzeppelin-BX-Y_c13.js} +1 -1
- package/assets/{parseNft-nhS1PzrY.js → parseNft-D1h5H4JB.js} +2 -2
- package/assets/{parseSignature-DtIw2rXo.js → parseSignature-BdQ9vAsP.js} +3 -3
- package/assets/{parseSignature-DIaDPyGA.js → parseSignature-Cgigxyju.js} +1 -1
- package/assets/{passkeys-l4VrwtfF.js → passkeys-BWQEfy2d.js} +1 -1
- package/assets/{pay-with-exchange-yIOka8rX.js → pay-with-exchange-0evv6ssy.js} +1 -1
- package/assets/{qr-overlay-BC6wsExf.js → qr-overlay-PZKtFEjn.js} +1 -1
- package/assets/{receive-DGr9WBJt.js → receive-COTaZ2BN.js} +1 -1
- package/assets/{resolveImplementation-CgWwbjqg.js → resolveImplementation-CqgdLfeR.js} +1 -1
- package/assets/{rpc-2WnfD84R.js → rpc-DKWWAuQw.js} +1 -1
- package/assets/{secp256k1-C2nawWfp.js → secp256k1-B6DumtZX.js} +1 -1
- package/assets/{secp256k1-BzEjkNEy.js → secp256k1-BjIDOuJ4.js} +1 -1
- package/assets/{secp256k1-C3Ly2cZR.js → secp256k1-C0RJ5GQn.js} +1 -1
- package/assets/{send-DaMmaBKd.js → send-CO1dDKrL.js} +1 -1
- package/assets/{send-batch-transaction-BJnHeeX4.js → send-batch-transaction-rlimxloI.js} +1 -1
- package/assets/{send-eip712-transaction-lGbfEAzA.js → send-eip712-transaction-Bz89Qw7_.js} +2 -2
- package/assets/{send-gasless-transaction-GytT3EN0.js → send-gasless-transaction-AZV2US9k.js} +2 -2
- package/assets/{send-transaction-wju-H3Cn.js → send-transaction-ArBfMlon.js} +2 -2
- package/assets/{sendRawTransaction-B7gRnaFv.js → sendRawTransaction-domnddMI.js} +3 -3
- package/assets/{serializeTransaction-K8-WLWnl.js → serializeTransaction-js0ZYY74.js} +1 -1
- package/assets/{session-proposal-eLNEKDfD.js → session-proposal-SKB_c_al.js} +1 -1
- package/assets/{session-request-D0qpm2ew.js → session-request-BwE5I7i2.js} +2 -2
- package/assets/{signing-gBX9gJ32.js → signing-C-juCIWO.js} +3 -3
- package/assets/{socials-CD_j_07F.js → socials-BkUHCVrl.js} +1 -1
- package/assets/{swaps-Bzm1G8N4.js → swaps-CW9X44BH.js} +1 -1
- package/assets/{thirdweb-DCMx7j1D.js → thirdweb-FCmtuW2J.js} +3 -3
- package/assets/{to-serializable-transaction-BZAI7BsG.js → to-serializable-transaction-C5rB8n0I.js} +2 -2
- package/assets/{trade-encoding-2LKm-Goy.js → trade-encoding-k0j0xnxQ.js} +1 -1
- package/assets/{transactionReceipt-CRyPQK5a.js → transactionReceipt-CFNUsE3Q.js} +1 -1
- package/assets/{transactions-I7lCf2CM.js → transactions-C4R1ppbY.js} +1 -1
- package/assets/{useCreditPacks-DYrmYjK5.js → useCreditPacks-R-gF49Zi.js} +1 -1
- package/assets/{useInfiniteGrid-CDzsfZBu.js → useInfiniteGrid-DrEzQ4kS.js} +1 -1
- package/assets/useManaRate-cQYZGq9S.js +1 -0
- package/assets/{useStore-D1gCXOP_.js → useStore-BebNq11Z.js} +1 -1
- package/assets/{useTheme-CUwz5NUH.js → useTheme-CqBHprKR.js} +1 -1
- package/assets/useTheme-D3IE0Ki7.js +1 -0
- package/assets/{verifyHash-DGsbtWAk.js → verifyHash-DZF-J1Av.js} +1 -1
- package/assets/{w3m-modal-C4axQEqk.js → w3m-modal-C3C2ZZqY.js} +1 -1
- package/assets/{w3m-modal-DJ_LdfUD.js → w3m-modal-C9BIr__u.js} +1 -1
- package/assets/{wait-for-tx-receipt-JPXzoKCu.js → wait-for-tx-receipt-BD2kJKLa.js} +1 -1
- package/assets/{wallets-CkR7yrP_.js → wallets-DymcAu2i.js} +5 -5
- package/assets/{web-connector-HjRYE3VT.js → web-connector-C7r57GGT.js} +3 -3
- package/assets/{writeContract-DSPOgOMV.js → writeContract-BU8f1IJr.js} +1 -1
- package/assets/{zoraTestnet-2TguyOvD.js → zoraTestnet-CPisp7Zv.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/ItemDetail-6dC_vNLF.css +0 -1
- package/assets/ItemDetail-DQOBDAhC.js +0 -78
- package/assets/index-CrKaGnrK.css +0 -1
- package/assets/useManaRate-BEdT5IGm.js +0 -1
- package/assets/useTheme-hvTZJoGa.js +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DURbEdp2.js","assets/react-C51i12iP.js","assets/dcl-schemas-BICTSpB5.js","assets/index-CQjL9b6j.js","assets/sentry-DKBoGDXH.js","assets/ethers-w5dOkonM.js","assets/intl-CBcMB1D2.js","assets/index-DkHZ6zdu.css","assets/emotion-styled.browser.esm-C93imo1O.js","assets/useTheme-CqBHprKR.js","assets/CircularProgress-OD5gaSs9.js","assets/index-BxKobL0r.js","assets/useTheme-D3IE0Ki7.js","assets/CssVarsProvider-DwDwaiXl.js","assets/getOverlayAlpha-RimUmqv9.js","assets/index-UmAjwwfj.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as re,r as d,j as e,d as Ia,a as Ca,L as Aa}from"./react-C51i12iP.js";import{u as ee,a as Sa,b as _e,t,ak as Ma,i as Pa,r as Ea,h as Fa,c as me,j as z,k as Ie,l as Ne,al as La,E as ie,C as q,x as te,B as G,e as ke,q as Ra,J as sa,_ as we,ap as ta,aO as Ta,aP as qa,aQ as $a,aR as Da,p as Ae,aS as Ba,ad as he,o as T,G as ia,I as O,aT as Oa,aU as Ka,aV as Wa,M as ra,aW as za,F as H,s as Y,aX as Va,aY as Ua,aZ as Qa,n as Ge,a_ as Ga,a$ as Ha,b0 as Ya,b1 as Ja,b2 as Xa,ae as Za,m as es,b3 as as,b4 as ss,b5 as ts,w as is,b6 as He,b7 as rs,g as ns,aq as ls,b8 as ds,b9 as os,ar as cs,ba as ms,bb as us,bc as hs}from"./index-CQjL9b6j.js";import{d as Q}from"./dcl-schemas-BICTSpB5.js";import{W as _s,C as ys,t as ps,a as fs,s as bs}from"./CollectionCarousel-BK5-UOoa.js";import{b as Ye,c as xs}from"./buy-VyechqN8.js";import{P as gs,f as js}from"./PrimaryListModal-NLcDjuqy.js";import{b as vs,w as Ns,S as ks,G as ws}from"./buy-gasless-jDmWcdID.js";import{g as Is}from"./authorizations-HljWnE0x.js";import{u as Cs,M as As,c as Ss}from"./useCreditPacks-R-gF49Zi.js";import{R as Je}from"./resume-buy-Bf0zIH7y.js";import{a as Ms,f as Ce,i as Ps}from"./errors-CVrT6Ui5.js";import{E as ye}from"./ErrorNotice-C7soUjRV.js";import{l as Es}from"./loader-logo-BzY9EKdC.js";import{C as Fs}from"./CircularProgress-OD5gaSs9.js";import{a as Ls,b as Rs}from"./trade-encoding-k0j0xnxQ.js";import{M as na}from"./MarketCheckout-BpXa_hJ1.js";import{u as la}from"./useManaRate-cQYZGq9S.js";import{s as Ts}from"./address-DrURAr9O.js";import{T as da}from"./Tooltip-D7WpGA4F.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./index-HN6Rk25C.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./mana-rate-CqpRH-06.js";import"./emotion-CSxEP8yM.js";function oa({item:s,onClose:r,resume:c=!1}){var u,X;const{session:i}=ee(),{data:y}=Sa(i),l=_e(),p=re(),j=Cs().packs.slice(0,As),[o,f]=d.useState("loading"),[m,v]=d.useState(null),[a,N]=d.useState(""),[E,h]=d.useState(s.priceCredits),[w,b]=d.useState(null),k=d.useRef(null),$=(w==null?void 0:w.credits)??E,R=(y==null?void 0:y.credits)??0;d.useEffect(()=>{let _=!1;if(!i){f("error"),v(t("buyModal.signInToCheckout"));return}const C=I=>{const A=I-((y==null?void 0:y.credits)??0),x=j.find(L=>L.credits>=A)??j[j.length-1];N(x.id),z("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:I,credits_balance:(y==null?void 0:y.credits)??0,shortfall:Math.max(0,A)}),f("nofunds")};return(async()=>{var I,A;try{const x=await Ma(s);if(!x)throw new Error("not for sale");if(Pa(x,i.address))throw new Error("You can't buy your own listing.");const L=Ea((A=(I=x.received)==null?void 0:I[0])==null?void 0:A.amount);if(!Number.isFinite(L)||L<=0)throw new Error("price unavailable");const S=Math.ceil(L/10);if(_)return;if(h(S),y!=null&&y.credits<S){C(S);return}try{const{credit:B,maxCreditedValue:ae,usdCents:ne}=await Fa(i.identity,L,x.id);if(_){me(i.identity,[B.id]).catch(()=>{});return}k.current=B.id;const le=Math.ceil(ne/10);h(le);const V={trade:x,credit:B,maxCreditedValue:ae,usdCents:ne,credits:le};b(V),c?K(V):f("ready")}catch(B){if(_)return;if(Ms(B)){C(S);return}throw B}}catch(x){if(_)return;z(Ne(x)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:Ie(x)}),f("error"),v(Ce(x,t("buyModal.error.generic"),{sale:!0}))}})(),()=>{_=!0,k.current&&i&&(me(i.identity,[k.current]).catch(()=>{}),k.current=null)}},[]);async function K(_=w){if(!i||!_)return;f("processing"),v(null);let C=!1;try{const I={trade:_.trade,buyer:i.address,signer:i.signer,credits:[_.credit],maxCreditedValue:_.maxCreditedValue};let A;if(Is())try{A=await vs(I),await Ns(A),C=!0}catch(x){if(x instanceof ks)C=!0;else if(x instanceof ws)A=await Ye(I);else throw x}else A=await Ye(I);k.current=null,z("Shop Completed Purchase",{...La([s]),payment_type:"credits",no_crypto_step:C,transaction_hash:A??null}),l.invalidateQueries({queryKey:["usd-balance"]}),f("complete")}catch(I){Ne(I)||ie(I,{flow:"buy",step:"submit",gasless:C}),me(i.identity,[_.credit.id]).catch(()=>{}),k.current=null,z(Ne(I)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:Ie(I)}),l.invalidateQueries({queryKey:["usd-balance"]}),v(Ce(I,t("buyModal.error.generic"),{sale:!0})),f("error")}}async function W(){if(!(!a||!i)){try{sessionStorage.setItem(Je,JSON.stringify(s))}catch{}w&&me(i.identity,[w.credit.id]).catch(()=>{}),k.current=null,f("loading");try{const _=await Ss(a,{address:i.address,identity:i.identity});if(_.url){window.location.href=_.url;return}p("/credits")}catch(_){ie(_,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(Je)}catch{}v(t("buyModal.error.creditsCheckout")),f("error")}}}const F=o==="processing",J=o==="complete"?t("buyModal.titleComplete"):o==="nofunds"?t("buyModal.titleNoFunds"):t("buyModal.titleBuy");return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:s.name}),children:[e.jsx("div",{className:"buy-modal__scrim",onClick:F?void 0:r,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${o==="processing"||o==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:J}),!F&&e.jsx("button",{className:"buy-modal__x",onClick:r,"aria-label":t("buyModal.close"),children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:o==="nofunds"?t("buyModal.dclBalance"):t("buyModal.myCreditsBalance")}),e.jsx(q,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:te(R)})]})]}),o==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(Fs,{size:44})}),o==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(ye,{message:m}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:r,children:t("buyModal.close")})})]}),o==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsx(_s,{className:"buy-modal__warning-ico"}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:t("buyModal.insufficientFunds")})," ",t("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:t("buyModal.warningCreditsAmount",{count:Math.max(0,$-R)})})," ",t("buyModal.warningToPurchase",{count:1})]})]}),e.jsx(Xe,{item:s,priceCredits:$}),e.jsx("div",{className:"buy-modal__packs",children:j.map(_=>{const C=_.credits,I=_.id===a;return e.jsxs("button",{className:`buy-modal__pack${I?" buy-modal__pack--on":""}`,onClick:()=>N(_.id),children:[e.jsx(q,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:te(C)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",_.usd.toFixed(2),")"]})]},_.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(q,{className:"buy-modal__total-ico"}),e.jsx("span",{children:te(((u=j.find(_=>_.id===a))==null?void 0:u.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((X=j.find(_=>_.id===a))==null?void 0:X.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:r,children:t("buyModal.cancel")}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:()=>void W(),children:t("buyModal.buy")})]})]}),o==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(Xe,{item:s,priceCredits:$}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient buy-modal__btn--full",onClick:()=>void K(),children:t("buyModal.buy")})})]}),o==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:Es,alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:c?t("buyModal.completingPurchase"):t("buyModal.completingTransaction")}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),o==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:t("getCredits.successTitle")})," ",t("buyModal.successBody")]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>p("/assets?tab=mine"),children:t("buyModal.myAssets")}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:r,children:[t("buyModal.tryInWorld"),e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function Xe({item:s,priceCredits:r}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:s.name,children:s.name||t("buyModal.itemFallback")}),s.creator?e.jsx(ys,{address:s.creator,className:"buy-modal__asset-creator"}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(q,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:te(r)})]})]})]})}const qs=1e3*60*60*24*182;function $s({asset:s,session:r,onClose:c}){const i=_e(),y=re(),[l,p]=d.useState("10"),[j,o]=d.useState(null),[f,m]=d.useState(null),[v,a]=d.useState(!1),[N,E]=d.useState(null);async function h(){m(null);const b=Number(l);if(!Number.isInteger(b)||b<=0){m(t("sellModal.errorWholeNumber"));return}a(!0);try{o(t("sellModal.statusPreparing")),await Ls({signer:r.signer,contractAddress:s.contractAddress,chainId:s.chainId}),o(t("sellModal.statusListing"));const k=await Rs({signer:r.signer,nft:{contractAddress:s.contractAddress,tokenId:s.tokenId,network:s.network,chainId:s.chainId},usdPrice:b/10,expiresAtMs:Date.now()+qs});o(t("sellModal.statusPublishing")),await Ra(k,r.identity),o(null),E(b),z("Shop Listed Item",{item_id:s.itemId??s.tokenId??null,contract_address:s.contractAddress,price_credits:b,price_usd:b/10,listing_type:"secondary",is_primary:!1}),sa.success(t("sellModal.toastOnSale",{name:s.name})),i.invalidateQueries({queryKey:["my-assets",r.address]})}catch(k){ie(k,{flow:"list_secondary"}),z("Shop Listing Failed",{listing_type:"secondary",error_code:Ie(k)}),m(Ce(k,t("sellModal.errorGeneric"))),o(null)}finally{a(!1)}}function w(){c(),y(`/item/${s.contractAddress}/${s.tokenId}`)}return N!==null?e.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:e.jsxs("div",{className:"modal modal--success",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:t("sellModal.successTitle")}),s.image?e.jsx("img",{className:"modal__img",src:s.image,alt:s.name}):null,e.jsx("p",{className:"modal-success__name",children:s.name}),e.jsxs("p",{className:"muted small",children:[t("sellModal.listedFor")," ",e.jsxs("strong",{children:[e.jsx(q,{className:"ccy-mark"})," ",N]})]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(G,{variant:"ghost",onClick:c,children:t("getCredits.done")}),e.jsx(G,{variant:"purple",onClick:w,children:t("sellModal.viewInShop")})]})]})}):e.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:e.jsxs("div",{className:"modal","data-testid":"modal",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true",children:[e.jsx("h2",{className:"modal__title",children:t("sellModal.listTitle",{name:s.name})}),s.image?e.jsx("img",{className:"modal__img",src:s.image,alt:s.name}):null,e.jsxs("label",{className:"field",children:[e.jsx("span",{children:t("sellModal.priceLabel",{currency:ke.name})}),e.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:b=>p(b.target.value),disabled:v})]}),e.jsx("p",{className:"muted small",children:t("sellModal.pricedInWhole",{currency:ke.name,currencySingular:ke.nameSingular})}),j?e.jsx("p",{className:"muted",children:j}):null,e.jsx(ye,{message:f}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(G,{variant:"ghost",onClick:c,disabled:v,children:t("sellModal.cancel")}),e.jsx(G,{onClick:()=>void h(),disabled:v,children:v?t("sellModal.listing"):t("sellModal.putOnSale")})]})]})})}const Ds=d.lazy(async()=>{const[{EmoteControls:s},{Experimental_CssVarsProvider:r},{light:c}]=await Promise.all([we(()=>import("./index-DURbEdp2.js").then(i=>i.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),we(()=>import("./index-BxKobL0r.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),we(()=>import("./index-UmAjwwfj.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:i=>e.jsx(r,{theme:c,children:e.jsx(s,{...i})})}});function Bs(s){return e.jsx(d.Suspense,{fallback:null,children:e.jsx(Ds,{...s})})}function Os({item:s}){const r=ee(w=>{var b;return(b=w.session)==null?void 0:b.address}),{data:c,isLoading:i}=ta(r),y=r&&c?r:"default",l=s.category==="emote",[p,j]=d.useState("item"),o=!l&&p==="item",f=o||!i,[m,v]=d.useState(!0);d.useEffect(()=>{v(!0)},[s.id,o]);const a=!!r&&!!c,N=a&&Ta(s,qa(c)),E=$a(s)[0],h=a&&!N&&!l;return e.jsxs(e.Fragment,{children:[f?e.jsx(Da,{id:"shop-item-preview",contractAddress:s.contractAddress,tokenId:s.tokenId??void 0,itemId:s.tokenId?void 0:s.itemId??void 0,profile:o?void 0:N?y:"default",bodyShape:o||N?void 0:E,type:l?void 0:o?Q.PreviewType.WEARABLE:Q.PreviewType.AVATAR,emote:l||o?void 0:Q.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:l?1.5:void 0,wheelStart:l?100:void 0,dev:Ae.chainId===80002,onLoad:()=>v(!1)}):null,!f||m?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":t("itemPreview.loading"),children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,h&&!o?e.jsx("p",{className:"item-preview__note",children:t("itemPreview.shownOnBody",{shape:Ba(E)})}):null,l?e.jsx("div",{className:"item-preview__emote-controls","data-testid":"emote-controls",children:e.jsx(Bs,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":t("itemPreview.previewMode"),children:[e.jsxs("button",{type:"button",className:p==="avatar"?"is-active":"","aria-pressed":p==="avatar","aria-label":t("itemPreview.onAvatar"),onClick:()=>j("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.onAvatar")})]}),e.jsxs("button",{type:"button",className:p==="item"?"is-active":"","aria-pressed":p==="item","aria-label":t("itemPreview.item"),onClick:()=>j("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.item")})]})]})]})}const Ze=8,Ks=!1;function Ws(s){if(!s)return;const r=s.toLowerCase();return Object.values(Q.Rarity).includes(r)?Q.Rarity.getMaxSupply(r):void 0}function zs(s){return/^0x[a-fA-F0-9]{40}$/.test(s)?`${s.slice(0,6)}…${s.slice(-4)}`:s}function Vs(s){let r=0;for(let c=0;c<s.length;c++)r=r*31+s.charCodeAt(c)>>>0;return`hsl(${r%360}, 52%, 45%)`}function Us(s,r){var c;return(((c=s==null?void 0:s.trim())==null?void 0:c[0])||r.replace(/^0x/i,"")[0]||"?").toUpperCase()}function Qs(s){return{tradeId:s.tradeId??s.id,listingType:"primary",contractAddress:s.contractAddress,itemId:s.itemId??"",name:s.name,thumbnail:s.thumbnail,rarity:s.rarity,category:s.category,wearableCategory:s.wearableCategory??null,creator:s.creator,manaWei:s.manaWei??"0",available:1,network:s.network,chainId:s.chainId,createdAt:0}}function Gs({r:s,seller:r,issuedId:c,total:i,isOwn:y,isLegacy:l,inCart:p,fallbackImage:j,onAdd:o,onBuyNative:f,onBuyLegacy:m}){var K,W;const v=re(),{data:a}=ta(r),N=(W=(K=a==null?void 0:a.avatar)==null?void 0:K.snapshots)==null?void 0:W.face256,[E,h]=d.useState(!1);d.useEffect(()=>h(!1),[N]);const w=!!N&&!E,b=r?a!=null&&a.name?ia(a.name):zs(r):void 0,k=w?e.jsx("img",{className:"resales__ava",src:N,alt:"",loading:"lazy",onError:()=>h(!0)}):r?e.jsx("span",{className:"resales__ava resales__ava--letter",style:{backgroundColor:Vs(r)},"aria-hidden":!0,children:Us(a==null?void 0:a.name,r)}):j?e.jsx("img",{className:"resales__ava",src:j,alt:"","aria-hidden":!0}):e.jsx("span",{className:"resales__ava resales__ava--empty","aria-hidden":!0}),$=e.jsxs("span",{className:"resales__ident",children:[b?e.jsx("span",{className:"resales__name","data-testid":"resale-seller",children:b}):null,c?e.jsxs("span",{className:"resales__serial",children:[t("resales.serialLabel")," ",e.jsxs("span",{className:"resales__issued","data-testid":"resale-issued",children:["#",c]}),i?` ${t("resales.serialOf")} ${i.toLocaleString("en-US")}`:""]}):e.jsx("span",{className:"resales__serial resales__serial--muted",children:t("resales.copy")})]}),R=r?e.jsxs("button",{type:"button",className:"resales__who resales__who--link",onClick:()=>v(`/assets/creator/${r}`),children:[k,$]}):e.jsxs("div",{className:"resales__who",children:[k,$]});return e.jsxs("li",{className:`resales__row${l?" resales__row--legacy":""}`,"data-testid":"resale-row","data-source":s.source,"data-own":y?"true":void 0,children:[R,e.jsxs("div",{className:`resales__price${l?" resales__price--approx":""}`,children:[l?e.jsx("span",{className:"resales__approx","aria-hidden":!0,children:"≈"}):null,e.jsx(q,{className:"resales__diamond"}),e.jsx("span",{className:"resales__price-value",children:te(s.priceCredits)})]}),e.jsx("div",{className:"resales__actions",children:y?e.jsx("span",{className:"chip resales__own-chip","data-testid":"resale-own",children:t("resales.yourListing")}):l?e.jsx("button",{className:"resales__buy",onClick:m,"aria-label":t("assetCard.buyNow"),"data-testid":"resale-buy",children:t("assetCard.buyNow")}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"resales__add",onClick:o,disabled:p,"aria-label":p?t("assetCard.inCart"):t("assetCard.addToCart"),"data-testid":"resale-add",children:[e.jsx(O,{name:"cart-solid",size:16}),e.jsx("span",{children:p?t("assetCard.inCart"):t("assetCard.addToCart")})]}),e.jsx("button",{className:"resales__buy",onClick:f,"aria-label":t("assetCard.buyNow"),"data-testid":"resale-buy",children:t("assetCard.buyNow")})]})})]})}function Hs({item:s}){var J;const r=s.contractAddress,c=s.itemId,i=_e(),y=he(u=>u.add),l=he(u=>u.items),{session:p}=ee(),j=(J=p==null?void 0:p.address)==null?void 0:J.toLowerCase(),[o,f]=d.useState(null),[m,v]=d.useState(null),[a,N]=d.useState(Ze),E=Ws(s.rarity),{data:h=[],isLoading:w}=T({queryKey:["item-resales",r,c],enabled:!!r&&!!c,queryFn:()=>Oa(r,c)}),b=h.slice(0,a),k=b.filter(u=>!u.seller||!u.issuedId).map(u=>u.tokenId).filter(u=>!!u),{data:$={}}=T({queryKey:["resale-token-info",r,k.join(",")],enabled:!!r&&k.length>0,staleTime:6e4,queryFn:()=>Ka(r,k)}),{data:R=[]}=T({queryKey:["item-classic-orders",r,c],enabled:Ks,queryFn:()=>Wa(r,c)}),K=h.some(u=>u.source==="legacy"),{data:W}=la(K);function F(){i.invalidateQueries({queryKey:["item-resales",r,c]})}return w||h.length===0?null:e.jsxs("section",{className:"resales","data-testid":"resales-section",children:[e.jsxs("div",{className:"resales__head",children:[e.jsx("h2",{className:"resales__title",children:t("resales.title")}),e.jsx("p",{className:"resales__subtitle",children:t("resales.subtitle")})]}),h.length>0?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"resales__list",children:b.map(u=>{const X=u.source==="legacy",_=l.some(S=>S.id===u.id),C=u.tokenId&&$[u.tokenId]||{},I=u.issuedId??C.issuedId,A=u.seller??C.seller,x={...u,name:u.name||s.name,thumbnail:u.thumbnail||s.thumbnail,rarity:u.rarity||s.rarity,category:u.category||s.category,wearableCategory:u.wearableCategory??s.wearableCategory,gender:u.gender??s.gender},L=!!A&&!!j&&A.toLowerCase()===j;return e.jsx(Gs,{r:x,seller:A,issuedId:I,total:E,isOwn:L,isLegacy:X,inCart:_,fallbackImage:x.thumbnail,onAdd:()=>y(x,"item_detail"),onBuyNative:()=>f(x),onBuyLegacy:()=>v(Qs(x))},u.tradeId??u.id)})}),h.length>a?e.jsx("button",{className:"resales__more",onClick:()=>N(u=>u+Ze),"data-testid":"resale-show-more",children:t("resales.showMore")}):null]}):null,null,o?e.jsx(oa,{item:o,onClose:()=>{f(null),F()}}):null,m&&W?e.jsx(na,{listing:m,rate:W,onClose:()=>v(null),onSold:()=>{v(null),F()}}):null]})}function ca(){return Ae.shopServerUrl||(typeof window<"u"?window.location.origin:"")}async function Ys(s,r,c){const i=new URLSearchParams({contractAddress:s,itemId:r}),y=`${ca()}/notify-requests?${i.toString()}`,l=await ra(y,{method:"GET",identity:c,metadata:{}});if(!l.ok)throw new Error(`getNotifyRequest ${l.status}`);return l.json()}async function Js(s,r){const c=`${ca()}/notify-requests`,i=await ra(c,{method:"POST",identity:r,metadata:{},headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw new Error(`createNotifyRequest ${i.status}: ${await i.text()}`);await i.json().catch(()=>{})}function ea(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim())}function Xs({item:s}){const r=ee(h=>h.session),c=ee(h=>h.signIn),[i,y]=d.useState(""),[l,p]=d.useState(!1),[j,o]=d.useState(!1),[f,m]=d.useState(null),v=!!r&&!!s.contractAddress&&!!s.itemId,{data:a}=T({queryKey:["notify-request",s.contractAddress,s.itemId,r==null?void 0:r.address],enabled:v,queryFn:()=>Ys(s.contractAddress,s.itemId,r.identity)});d.useEffect(()=>{a!=null&&a.email&&y(h=>h||a.email)},[a==null?void 0:a.email]),d.useEffect(()=>{if(!r)return;let h=!1;return za().then(w=>{!h&&w&&y(b=>b||w)}),()=>{h=!0}},[r]);const N=j||!!(a!=null&&a.subscribed);async function E(h){if(h.preventDefault(),!(!r||!s.itemId||!ea(i)||l)){p(!0),m(null);try{await Js({contractAddress:s.contractAddress,itemId:s.itemId,chainId:s.chainId,email:i.trim()},r.identity),o(!0)}catch(w){ie(w,{flow:"notify-me",contractAddress:s.contractAddress,itemId:s.itemId}),m(t("notifyMe.error"))}finally{p(!1)}}}return r?N?e.jsxs("div",{className:"notify notify__done","data-testid":"notify-subscribed",children:[e.jsx("span",{className:"notify__done-check","aria-hidden":!0,children:e.jsx(O,{name:"check",size:12})}),e.jsx("span",{className:"notify__done-text",children:t("notifyMe.subscribedBody")})]}):e.jsxs("form",{className:"notify",onSubmit:E,"data-testid":"notify",children:[e.jsx("label",{className:"notify__label",htmlFor:"notify-email",children:t("notifyMe.label")}),e.jsxs("div",{className:"notify__row",children:[e.jsx("input",{id:"notify-email",className:"notify__input",type:"email",inputMode:"email",autoComplete:"email",placeholder:t("notifyMe.placeholder"),value:i,onChange:h=>y(h.target.value),"data-testid":"notify-email"}),e.jsx("button",{type:"submit",className:"notify__btn",disabled:!ea(i)||l,"data-testid":"notify-submit",children:l?t("notifyMe.working"):t("notifyMe.cta")})]}),e.jsx(ye,{message:f})]}):e.jsx("div",{className:"notify","data-testid":"notify",children:e.jsx("button",{type:"button",className:"notify__signin",onClick:c,"data-testid":"notify-signin",children:t("notifyMe.signInCta")})})}const Zs=Y.button`
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 40px;
|
|
9
|
+
padding: 0 12px;
|
|
10
|
+
border: 2px solid #c640cd;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
background: transparent;
|
|
13
|
+
color: ${H.colors.accent};
|
|
14
|
+
font-family: ${H.font.sans};
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
font-size: 15px;
|
|
17
|
+
line-height: 24px;
|
|
18
|
+
letter-spacing: 0.46px;
|
|
19
|
+
text-transform: uppercase;
|
|
20
|
+
cursor: not-allowed;
|
|
21
|
+
opacity: 0.55;
|
|
22
|
+
transition: opacity 0.15s ease;
|
|
23
|
+
|
|
24
|
+
&:hover,
|
|
25
|
+
&:focus-visible {
|
|
26
|
+
opacity: 0.75;
|
|
27
|
+
}
|
|
28
|
+
&:focus-visible {
|
|
29
|
+
outline: 2px solid ${H.colors.accent};
|
|
30
|
+
outline-offset: 2px;
|
|
31
|
+
}
|
|
32
|
+
`;function et({item:s}){return e.jsx(da,{block:!0,content:t("makeOffer.comingSoon"),onShow:()=>z("Shop Make Offer Tooltip Shown",{contractAddress:s.contractAddress,itemId:s.itemId}),children:e.jsxs(Zs,{type:"button","aria-disabled":!0,onClick:r=>r.preventDefault(),"data-testid":"make-offer",children:[e.jsx(O,{name:"offer",size:20,"aria-hidden":!0}),e.jsx("span",{children:t("makeOffer.cta")})]})})}const at=Y(Va)`
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
gap: 1px;
|
|
37
|
+
background: ${H.colors.lineStrong};
|
|
38
|
+
`;function st({contractAddress:s,name:r,items:c,className:i}){const y=re();if(!s||!r)return null;const l=(c??[]).map(o=>o.thumbnail).filter(o=>!!o).slice(0,4),p=l.slice(0,2),j=l.slice(2,4);return e.jsxs(Ua,{as:"button","data-link":!0,className:i,"data-testid":"creator",onClick:o=>{o.stopPropagation(),y(`/collection/${s}`)},children:[l.length>0?e.jsxs(at,{as:"span","data-avatar":!0,"data-testid":"creator-ava","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${j.length===0?" collection-collage__row--full":""}`,children:p.map((o,f)=>e.jsx("img",{src:o,alt:""},f))}),j.length>0?e.jsx("span",{className:"collection-collage__row",children:j.map((o,f)=>e.jsx("img",{src:o,alt:""},f))}):null]}):null,e.jsx(Qa,{"data-testid":"creator-name",children:ia(r)})]})}const tt=Y(G)`
|
|
39
|
+
margin-top: 6px;
|
|
40
|
+
`,ue=Y(G)`
|
|
41
|
+
&& {
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 48px;
|
|
44
|
+
font-size: 15px;
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
letter-spacing: 0.46px;
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
${H.media.down("lg")} {
|
|
54
|
+
.item-detail__ctas--dual && {
|
|
55
|
+
flex: 1 1 auto;
|
|
56
|
+
width: auto;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,it=Y("div")`
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
gap: 10px;
|
|
63
|
+
width: 100%;
|
|
64
|
+
`,rt=Y(G)`
|
|
65
|
+
&& {
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 44px;
|
|
68
|
+
}
|
|
69
|
+
`,nt=Y("p")`
|
|
70
|
+
margin: 4px 0 0;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
color: ${H.colors.muted};
|
|
73
|
+
|
|
74
|
+
a {
|
|
75
|
+
color: ${H.colors.accent};
|
|
76
|
+
font-weight: 600;
|
|
77
|
+
}
|
|
78
|
+
`;function lt(s){return Object.values(Q.Rarity).includes(s)}function dt(s){return s==="male"?t("itemDetail.genderMale"):s==="female"?t("itemDetail.genderFemale"):s==="unisex"?t("itemDetail.genderUnisex"):null}function aa(s){return s.wearableCategory?s.wearableCategory.replace(/_/g," "):s.category==="emote"?t("itemDetail.categoryEmote"):t("itemDetail.categoryWearable")}function qt(){var Ue;const{contractAddress:s,tokenId:r}=Ia(),c=Ca(),i=c.state,y=re(),l=!!(i!=null&&i.market),p=(i==null?void 0:i.marketPriceCredits)??null,j=he(n=>n.add),o=he(n=>n.items),f=Ge(n=>n.toggle),{session:m,signIn:v}=ee(),[a,N]=d.useState(()=>i!=null&&i.item?{...i.item,tradeId:i.tradeId??i.item.tradeId}:{id:`${s}-${r}`,name:"",creator:"",contractAddress:s??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:Ae.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:r??void 0,tradeId:i==null?void 0:i.tradeId}),[E,h]=d.useState(!1),[w,b]=d.useState(!!(i!=null&&i.resumeBuy));d.useEffect(()=>{i!=null&&i.resumeBuy&&h(!0)},[i==null?void 0:i.resumeBuy]);function k(){if(m){h(!0);return}l||bs({type:"item-buy",path:c.pathname}),v()}const $=d.useRef(!1);d.useEffect(()=>{if(!m||$.current)return;const n=ps("item-buy");!n||n.path!==c.pathname||($.current=!0,b(!0),h(!0))},[m]);const{data:R=[],isFetched:K}=T({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>ls(a.contractAddress,{first:20}).then(n=>n.items)}),W=a.available==null&&!a.tokenId,{data:F,isLoading:J}=T({queryKey:["shop-item",a.contractAddress,r],enabled:!l&&!!a.contractAddress&&!!r&&(!(i!=null&&i.item)||W),queryFn:()=>ds(a.contractAddress,r)});d.useEffect(()=>{F&&N(n=>n.tradeId?n.available!=null&&n.wearableCategory?n:{...n,available:n.available??F.available,wearableCategory:n.wearableCategory??F.wearableCategory}:{...F})},[F]);const[u,X]=d.useState(!1),{data:_=""}=T({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>os(a.contractAddress,a.itemId)}),{data:C}=T({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>cs(a.contractAddress)});d.useEffect(()=>{if(a.name||F||R.length===0)return;const n=r&&R.find(M=>M.tokenId===r||M.itemId===r)||R.find(M=>M.contractAddress===a.contractAddress);n&&N(M=>({...n,tradeId:M.tradeId??n.tradeId}))},[R,F]);const I=d.useMemo(()=>{const n=new Set,M=[];for(const D of R){if(D.id===a.id||a.itemId&&D.itemId===a.itemId||a.tokenId&&D.tokenId===a.tokenId)continue;const Qe=`${D.contractAddress}-${D.itemId??D.tokenId??D.id}`;n.has(Qe)||(n.add(Qe),M.push(D))}return M},[R,a.id,a.itemId,a.tokenId]),{data:A,isLoading:x}=T({queryKey:["detail-trade",a.id,a.tradeId,a.contractAddress,a.itemId],enabled:!!a.contractAddress,queryFn:async()=>{if(a.tradeId)return a.tradeId;if(a.itemId){const n=await ms(a.contractAddress,a.itemId);return(n==null?void 0:n.id)??null}return null}}),L=a.tradeId??A??void 0,S=!!L,{data:B}=la(l),ae=d.useMemo(()=>{if(!l||!(i!=null&&i.item))return null;const n=i.item;return n.manaWei?{tradeId:n.tradeId??n.id,listingType:"primary",contractAddress:n.contractAddress,itemId:n.itemId??"",name:n.name,thumbnail:n.thumbnail,rarity:n.rarity,category:n.category,wearableCategory:n.wearableCategory??null,creator:n.creator,manaWei:n.manaWei,available:1,network:n.network,chainId:n.chainId,createdAt:0}:null},[l,i==null?void 0:i.item]),ne=l&&p!=null&&!!B&&!!ae,le=Ga({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),V=d.useMemo(()=>({...a,tradeId:L,id:L??a.id}),[a,L]),pe=o.some(n=>n.id===V.id),de=!V.tokenId,ma=((Ue=o.find(n=>n.id===V.id))==null?void 0:Ue.quantity)??0,fe=de&&typeof a.available=="number"&&ma>=a.available,U=Ge(n=>!!n.items[a.id]),Se=d.useRef(null);d.useEffect(()=>{!a.name||x||Se.current===a.id||(Se.current=a.id,z("Shop Viewed Item",{...Ha(a),for_sale:S}),Ya(a))},[a.id,a.name,x,S]);const oe=`${s}/${r}`,Me=d.useRef(oe);d.useEffect(()=>{Me.current!==oe&&(Me.current=oe,i!=null&&i.item&&N({...i.item,tradeId:i.tradeId??i.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[oe]);function ua(){!S||xe||x||!de&&pe||fe||j(V,"item_detail")}const be=lt(a.rarity)?a.rarity:Q.Rarity.COMMON,Pe=dt(a.gender),Ee=Ja(a),Fe=Xa(a.gender),ha=S&&le,_a=t("itemDetail.moreFromCollection"),xe=Za(a,m==null?void 0:m.address),ce=_e(),[ya,Le]=d.useState(!1),[pa,Re]=d.useState(!1),[se,Te]=d.useState(!1),[fa,qe]=d.useState(null),{data:g,isLoading:$e}=T({queryKey:["owned-token",a.contractAddress,a.tokenId,m==null?void 0:m.address],enabled:!l&&!!(m!=null&&m.address)&&!!a.contractAddress&&!!a.tokenId,queryFn:()=>m?us(m.address,a.contractAddress,a.tokenId):null});d.useEffect(()=>{g&&N(n=>n.name?n.issuedId?n:{...n,issuedId:g.issuedId}:{id:g.id,name:g.name,creator:"",contractAddress:g.contractAddress,itemId:g.itemId,category:g.category,rarity:g.rarity??"common",network:g.network,chainId:g.chainId,thumbnail:g.image,priceCredits:g.listingPrice??0,gender:null,isSmart:!1,tokenId:g.tokenId,issuedId:g.issuedId,tradeId:g.tradeId})},[g]);const{data:P}=T({queryKey:["public-token",a.contractAddress,a.tokenId],enabled:!l&&!!a.contractAddress&&!!a.tokenId&&!a.name&&!F&&!$e&&!g,queryFn:()=>hs(a.contractAddress,a.tokenId)});d.useEffect(()=>{P&&N(n=>n.name?n.issuedId?n:{...n,issuedId:P.issuedId}:{id:P.id,name:P.name,creator:"",contractAddress:P.contractAddress,itemId:P.itemId,category:P.category,rarity:P.rarity??"common",network:P.network,chainId:P.chainId,thumbnail:P.image,priceCredits:P.listingPrice??0,gender:null,isSmart:!1,tokenId:P.tokenId,issuedId:P.issuedId,tradeId:P.tradeId})},[P]);const{data:ge}=T({queryKey:["publishable-item",a.contractAddress,a.itemId,m==null?void 0:m.address],enabled:xe&&!!m&&!!a.itemId,queryFn:async()=>m?(await js(m.address,m.identity)).find(M=>M.contractAddress.toLowerCase()===a.contractAddress.toLowerCase()&&M.blockchainItemId===a.itemId)??null:null}),Z=!!g,je=!l&&(xe||Z),ba=Z?!!(g!=null&&g.isOnSale):S,ve=Z?g==null?void 0:g.tradeId:L,De=Z?!!g:!!ge;async function Be(){await Promise.all([ce.invalidateQueries({queryKey:["owned-token",a.contractAddress,a.tokenId]}),ce.invalidateQueries({queryKey:["detail-trade"]}),ce.invalidateQueries({queryKey:["shop-item"]}),ce.invalidateQueries({queryKey:["collection-sale-state"]})])}async function Oe(n={}){if(!m||!ve)return!1;qe(null),Te(!0);try{const M=await ns(ve);return await xs({trade:M,signer:m.signer}),n.silent||sa.success(t("myAssets.removedFromSale",{name:a.name})),await Be(),!0}catch(M){const D=Ps(M);return D||ie(M,{flow:"remove-listing",tradeId:ve}),qe(D?t("getCredits.errorCanceled"):t("myAssets.removeListingError")),!1}finally{Te(!1)}}function Ke(){Z?Le(!0):Re(!0)}async function xa(){await Oe({silent:!0})&&Ke()}function We(){Le(!1),Re(!1),Be()}const ze=S?x?t("itemDetail.checking"):fe?t("itemDetail.maxInCart"):!de&&pe?t("assetCard.inCart"):t("assetCard.addToCart"):t("itemDetail.notForSale"),ga=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!l,ja=!l&&!a.tokenId&&a.available===0,va=!je&&S&&!l,Na=l||!je,ka=J||!!a.contractAddress&&!K||!a.name&&$e,Ve=!a.name&&!ka,wa=/^https?:\/\//i.test(a.thumbnail);return es(Ve?{title:t("seo.item.notFoundTitle"),noindex:!0}:a.name?{title:a.name,description:_||t("seo.item.fallbackDescription",{name:a.name,rarity:a.rarity,category:aa(a),creator:Ts(a.creator)}),image:wa?a.thumbnail:void 0,type:"product"}:{}),Ve?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx(O,{name:"cart",className:"item-detail__notfound-ico"}),e.jsx("h1",{className:"item-detail__notfound-title",children:t("itemDetail.notAvailableTitle")}),e.jsx("p",{className:"muted",children:t("itemDetail.notAvailableBody")}),e.jsx(tt,{variant:"purple",onClick:()=>y("/assets"),children:t("notFound.cta")})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":t("itemDetail.breadcrumbAria"),children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>y("/assets"),children:t("nav.collectibles")}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:a.name||t("itemDetail.itemFallback")})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsxs("div",{className:"item-detail__preview","data-testid":"item-preview",children:[a.name?e.jsx(Os,{item:a}):e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":t("itemPreview.loading"),children:e.jsx("span",{className:"skeleton item-preview__skeleton","aria-hidden":!0})}),e.jsx("button",{className:`item-detail__fav item-detail__fav--preview${U?" is-on":""}`,onClick:()=>f(a),"aria-pressed":U,"aria-label":U?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(O,{name:U?"heart-solid":"heart",size:18})})]}),e.jsx("div",{className:"item-detail__info",children:a.name?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:a.name}),e.jsx("button",{className:`item-detail__fav${U?" is-on":""}`,onClick:()=>f(a),"aria-pressed":U,"aria-label":U?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(O,{name:U?"heart-solid":"heart",size:18})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:ts(be),color:ss(be)},title:as(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[Ee?e.jsx(O,{name:Ee,size:18,color:"var(--text-2)"}):null,aa(a)]}),Pe?e.jsxs("span",{className:"chip item-detail__chip",children:[Fe?e.jsx(O,{name:Fe,size:18,color:"var(--text-2)"}):null,Pe]}):null,a.issuedId?e.jsxs("span",{className:"chip item-detail__chip","data-testid":"detail-issued",children:["#",a.issuedId]}):null]}),_?e.jsxs("div",{className:"item-detail__section item-detail__description",children:[e.jsx("div",{className:"item-detail__label",children:t("itemDetail.description")}),e.jsx("p",{className:`item-detail__desc-text${u?" is-expanded":""}`,children:_}),_.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>X(n=>!n),children:u?t("itemDetail.showLess"):t("itemDetail.readMore")}):null]}):null,a.creator||C!=null&&C.name?e.jsxs("div",{className:"item-detail__meta",children:[a.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:t("itemDetail.creator")}),e.jsx(is,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,C!=null&&C.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:t("itemDetail.collection")}),e.jsx(st,{contractAddress:a.contractAddress,name:C.name,items:R,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[l||S?e.jsx("div",{className:"item-detail__price-label",children:t("itemDetail.price")}):null,l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:p==null?e.jsx("span",{className:"item-detail__price-value",children:"—"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"item-detail__approx","aria-hidden":!0,children:"≈"}),e.jsx(q,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:p})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:t("assetCard.marketPrice")})]}):S?ha?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(q,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(q,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),He(a.compareAtCredits,a.priceCredits)>0?e.jsx("span",{className:"item-detail__sale-badge",children:t("assetCard.saleWithDiscount",{pct:He(a.compareAtCredits,a.priceCredits)})}):null,e.jsx(rs,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(q,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}):e.jsxs("div",{className:"item-detail__price item-detail__price--none",children:[e.jsx("span",{children:t("itemDetail.notForSale")}),e.jsx(da,{content:t("itemDetail.notForSaleHint"),children:e.jsx("span",{className:"item-detail__price-info",tabIndex:0,role:"img","aria-label":t("itemDetail.notForSaleHint"),children:e.jsx(O,{name:"info",size:14})})})]})]}),ga?e.jsxs("div",{className:"item-detail__stock-col",children:[e.jsx("div",{className:"item-detail__price-label",children:t("itemDetail.stock")}),e.jsxs("div",{className:"item-detail__stock-value",children:[(a.available??0).toLocaleString(),"/",Q.Rarity.getMaxSupply(be).toLocaleString()]})]}):ja?e.jsx("div",{className:"item-detail__stock-col",children:e.jsx("div",{className:"item-detail__stock-value item-detail__stock-value--out","data-testid":"out-of-stock",children:t("itemDetail.outOfStock")})}):null]})}),e.jsx("div",{className:`item-detail__ctas${Na?" item-detail__ctas--buttons":""}${va?" item-detail__ctas--dual":""}`,children:l?e.jsxs(ue,{variant:"purple",onClick:k,disabled:!ne,children:[e.jsx("span",{className:"item-detail__cta-label",children:t("assetCard.buyNow")}),p!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(q,{className:"item-detail__cta-diamond"}),p]}):null]}):je?e.jsxs(it,{"data-testid":"manage-actions",children:[e.jsx(ye,{message:fa}),ba?e.jsxs(e.Fragment,{children:[e.jsx(ue,{variant:"purple",onClick:()=>void xa(),disabled:se||!De,children:e.jsx("span",{className:"item-detail__cta-label",children:se?t("itemDetail.manageWorking"):t("itemDetail.manageUpdatePrice")})}),e.jsx(rt,{variant:"ghost",onClick:()=>void Oe(),disabled:se,children:se?t("myAssets.removing"):t("itemDetail.manageRemove")})]}):e.jsx(ue,{variant:"purple",onClick:()=>{Z&&z("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),Ke()},disabled:se||!De,children:e.jsx("span",{className:"item-detail__cta-label",children:t("itemDetail.manageList")})}),e.jsxs(nt,{children:[t("itemDetail.ownItemPrefix")," ",e.jsx(Aa,{to:"/my-assets",children:t("nav.myAssets")}),t("itemDetail.ownItemSuffix")]})]}):S?e.jsxs(e.Fragment,{children:[e.jsxs(ue,{variant:"purple",onClick:k,disabled:x,children:[e.jsx("span",{className:"item-detail__cta-label",children:t("assetCard.buyNow")}),e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(q,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}),e.jsxs("button",{className:"item-detail__addcart",onClick:ua,disabled:x||(de?fe:pe),"aria-label":ze,children:[e.jsx(O,{name:"cart-solid"}),e.jsx("span",{className:"item-detail__addcart-label",children:ze})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xs,{item:a}),e.jsx(et,{item:a})]})})]}):e.jsx(ot,{})})]}),a.itemId?e.jsx(Hs,{item:a}):null,e.jsx(fs,{title:_a,items:I,onViewAll:a.contractAddress?()=>y(`/collection/${a.contractAddress}`):void 0}),E&&l&&ae&&B?e.jsx(na,{listing:ae,rate:B,onClose:()=>h(!1),onSold:()=>h(!1)}):E&&!l?e.jsx(oa,{item:V,resume:w,onClose:()=>{h(!1),b(!1)}}):null,ya&&g&&m?e.jsx($s,{asset:g,session:m,onClose:We}):null,pa&&ge&&m?e.jsx(gs,{item:ge,session:m,onClose:We}):null]})}function ot(){return e.jsxs("div",{className:"item-detail__info-skel","aria-hidden":!0,children:[e.jsx("span",{className:"skeleton id-skel__title"}),e.jsxs("div",{className:"id-skel__chips",children:[e.jsx("span",{className:"skeleton id-skel__chip"}),e.jsx("span",{className:"skeleton id-skel__chip"})]}),e.jsx("span",{className:"skeleton id-skel__line"}),e.jsx("span",{className:"skeleton id-skel__line id-skel__line--short"}),e.jsx("hr",{className:"item-detail__divider"}),e.jsx("span",{className:"skeleton id-skel__price"}),e.jsx("span",{className:"skeleton id-skel__btn"})]})}export{qt as ItemDetail,qt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as c}from"./react-C51i12iP.js";import{s as u,B as p,t as d}from"./index-
|
|
1
|
+
import{r as l,j as c}from"./react-C51i12iP.js";import{s as u,B as p,t as d}from"./index-CQjL9b6j.js";const a=u.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
padding: 28px 0 8px;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{u as Q,r as m,j as e}from"./react-C51i12iP.js";import{u as V,a as K,b as Y,t,c as k,C as x,f as I,d as H,e as j,g as $,i as D,h as J,j as y,k as M,l as F,s as X,B as Z}from"./index-
|
|
1
|
+
import{u as Q,r as m,j as e}from"./react-C51i12iP.js";import{u as V,a as K,b as Y,t,c as k,C as x,f as I,d as H,e as j,g as $,i as D,h as J,j as y,k as M,l as F,s as X,B as Z}from"./index-CQjL9b6j.js";import{m as b}from"./mana-rate-CqpRH-06.js";import{b as R}from"./buy-VyechqN8.js";import{b as ee,w as re,S as ae,G as te}from"./buy-gasless-jDmWcdID.js";import{g as se}from"./authorizations-HljWnE0x.js";import{i as ie}from"./errors-CVrT6Ui5.js";import{E as ce}from"./ErrorNotice-C7soUjRV.js";const A=X(Z)`
|
|
2
2
|
flex: 1;
|
|
3
3
|
`;function B(r){if(ie(r))return t("errors.rejected");const n=(r.message??"").toLowerCase();return n.includes("insufficient")?t("marketCheckout.error.insufficient",{currency:j.name}):n.includes("not found")||n.includes("no active listing")||n.includes("404")?t("marketCheckout.error.soldOrRemoved"):n.includes("your own listing")?t("errors.cantBuyOwn"):t("marketCheckout.error.generic")}function ne(r){return{id:r.tradeId,tradeId:r.tradeId,name:r.name,creator:r.creator,contractAddress:r.contractAddress,itemId:r.itemId,category:r.category,wearableCategory:r.wearableCategory??void 0,rarity:r.rarity,network:r.network,chainId:r.chainId,thumbnail:r.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function _e({listing:r,rate:n,onClose:U,onSold:W}){const{session:i}=V(),{data:d,isError:G}=K(i),w=Y(),g=Q(),[N,f]=m.useState("confirm"),[C,E]=m.useState(t("marketCheckout.lockingPrice")),[L,_]=m.useState(null),[a,T]=m.useState(null),o=m.useRef(null),q=Math.ceil(b(r.manaWei,n)/10);m.useEffect(()=>{let l=!1;if(!i){f("error"),_(t("buyModal.signInToCheckout"));return}return(async()=>{try{const s=await $(r.tradeId);if(!s)throw new Error("not found");if(D(s,i.address))throw new Error("You can't buy your own listing.");const h=b(r.manaWei,n);if(!Number.isFinite(h)||h<=0)throw new Error("price unavailable");const{credit:u,maxCreditedValue:O,usdCents:S}=await J(i.identity,h,r.tradeId);if(l){k(i.identity,[u.id]).catch(()=>{});return}o.current=u.id,T({trade:s,credit:u,maxCreditedValue:O,usdCents:S,credits:Math.ceil(S/10)}),E("")}catch(s){if(l)return;console.error("[market] authorize failed",s),y(F(s)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:M(s),value_usd:Math.round(b(r.manaWei,n))/100}),f("error"),_(B(s))}})(),()=>{l=!0,o.current&&i&&(k(i.identity,[o.current]).catch(()=>{}),o.current=null)}},[]);const v=!!a&&d!=null&&d.credits<a.credits;async function z(){if(!i||!a)return;if(v){y("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:a.credits,credits_balance:(d==null?void 0:d.credits)??0,shortfall:Math.max(0,a.credits-((d==null?void 0:d.credits)??0))}),k(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,g("/credits");return}f("working"),_(null);let l=!1;try{E(t("marketCheckout.confirming"));const c={trade:a.trade,buyer:i.address,signer:i.signer,credits:[a.credit],maxCreditedValue:a.maxCreditedValue};let s;if(se())try{s=await ee(c),await re(s),l=!0}catch(u){if(u instanceof ae)l=!0;else if(u instanceof te)s=await R(c);else throw u}else s=await R(c);o.current=null,y("Shop Completed Purchase",{items:[{item_id:r.itemId??null,contract_address:r.contractAddress,token_id:null,price_usd:a.usdCents/100}],value_credits:a.credits,value_usd:a.usdCents/100,purchase_type:"item",is_primary:!0,payment_type:"credits",no_crypto_step:l,transaction_hash:s??null}),w.invalidateQueries({queryKey:["usd-balance"]});const h={items:[ne(r)],txHash:s};g("/success",{state:h})}catch(c){console.error("[market] buy now failed",c),k(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,y(F(c)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:M(c),value_usd:a.usdCents/100}),w.invalidateQueries({queryKey:["usd-balance"]}),_(B(c)),f("error");const s=(c.message??"").toLowerCase();(s.includes("not found")||s.includes("no active listing")||s.includes("404"))&&W()}}function P(){i&&a&&k(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,U()}const p=N==="working";return e.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:r.name}),children:[e.jsx("div",{className:"mkt-modal__scrim",onClick:p?void 0:P,"aria-hidden":!0}),e.jsxs("div",{className:"mkt-modal__card",children:[e.jsxs("div",{className:"mkt-modal__head",children:[e.jsx("div",{className:"mkt-modal__thumb",children:r.thumbnail?e.jsx("img",{src:r.thumbnail,alt:""}):null}),e.jsxs("div",{children:[e.jsx("div",{className:"mkt-modal__name",title:r.name,children:r.name||t("buyModal.itemFallback")}),e.jsx("span",{className:"chip chip--rarity",children:r.rarity})]})]}),e.jsx("div",{className:"mkt-modal__price",children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.finalPrice")}),e.jsxs("div",{className:"mkt-modal__price-value",children:[e.jsx(x,{className:"mkt-modal__diamond"}),I(a.credits)]}),e.jsxs("div",{className:"mkt-modal__price-sub muted",children:[t("marketCheckout.lockedForPurchase")," · $",(a.usdCents/100).toFixed(2)]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.todaysPrice")}),e.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[e.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),e.jsx(x,{className:"mkt-modal__diamond"}),I(q)]}),e.jsx("div",{className:"mkt-modal__price-sub muted",children:C||t("marketCheckout.lockingPrice")})]})}),i?e.jsxs("div",{className:"mkt-modal__balance muted",children:[t("marketCheckout.yourBalance")," ",e.jsx(x,{className:"ccy-mark"})," ",H(d,G)]}):null,v?e.jsx("p",{className:"muted mkt-modal__note",children:t("marketCheckout.needMore",{currency:j.name})}):null,C&&N==="working"?e.jsx("p",{className:"muted mkt-modal__note",children:C}):null,e.jsx(ce,{message:L,className:"mkt-modal__note"}),e.jsxs("div",{className:"mkt-modal__actions",children:[e.jsx(A,{variant:"ghost",onClick:P,disabled:p,children:t("buyModal.cancel")}),e.jsx(A,{variant:"purple",onClick:()=>void z(),disabled:p||!a,children:p?t("marketCheckout.buying"):v?t("nav.getCredits",{currency:j.name}):t("marketCheckout.confirmPurchase")})]})]})]})}export{_e as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as Ce,b as Xe,r as d,j as t}from"./react-C51i12iP.js";import{s as i,F as s,I as C,m as et,t as r,u as tt,b as st,G as me,o as O,B as ot,A as D,j as nt,H as rt,g as at,J as it,E as lt,p as Ie,K as ct,L as dt}from"./index-
|
|
1
|
+
import{L as Ce,b as Xe,r as d,j as t}from"./react-C51i12iP.js";import{s as i,F as s,I as C,m as et,t as r,u as tt,b as st,G as me,o as O,B as ot,A as D,j as nt,H as rt,g as at,J as it,E as lt,p as Ie,K as ct,L as dt}from"./index-CQjL9b6j.js";import{f as mt}from"./import-DFiOfmYU.js";import{P as pt,f as ut}from"./PrimaryListModal-NLcDjuqy.js";import{c as ft}from"./buy-VyechqN8.js";import{R as Q,C as xt,a as ht,F as yt,S as U,b as pe}from"./categories-DPdI3Qkz.js";import{L as gt}from"./LoadMore-PZOUHqu7.js";import{D as ue,F as fe,R as bt,a as wt,b as St,c as jt,d as $t,S as Ct,e as It,f as kt,g as vt,h as At,i as Et,j as Tt,k as Ft,C as Rt,l as _t,m as Ot,n as Lt,M as Pt}from"./Assets.styles-C1Y1ZCen.js";import{u as zt}from"./useInfiniteGrid-DrEzQ4kS.js";import{E as H}from"./ErrorNotice-C7soUjRV.js";import{n as ke}from"./emotion-CSxEP8yM.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./mana-rate-CqpRH-06.js";import"./index-HN6Rk25C.js";import"./trade-encoding-k0j0xnxQ.js";import"./authorizations-HljWnE0x.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./errors-CVrT6Ui5.js";import"./Tooltip-D7WpGA4F.js";i.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 4px;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as n,j as s,L as m}from"./react-C51i12iP.js";import{m as c,t,n as l,I as d,A as p,s as v,B as x}from"./index-
|
|
1
|
+
import{r as n,j as s,L as m}from"./react-C51i12iP.js";import{m as c,t,n as l,I as d,A as p,s as v,B as x}from"./index-CQjL9b6j.js";import{L as h}from"./LoadMore-PZOUHqu7.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";const u=v(x)`
|
|
2
2
|
margin-top: 12px;
|
|
3
3
|
`,r=24;function E(){c({title:t("nav.myFavorites"),noindex:!0});const a=l(e=>Object.values(e.items)),[i,o]=n.useState(r);return a.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx(d,{name:"heart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"favorites-empty__title",children:t("myFavorites.emptyTitle")}),s.jsx("p",{className:"muted",children:t("myFavorites.emptyBody")}),s.jsx(u,{as:m,to:"/assets",variant:"purple",children:t("notFound.cta")})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:t("nav.myFavorites")}),s.jsx("span",{className:"favorites__count",children:t("myFavorites.itemCount",{count:a.length})})]}),s.jsx("div",{className:"grid",children:a.slice(0,i).map(e=>s.jsx(p,{item:e},e.id))}),s.jsx(h,{hasNextPage:i<a.length,isFetching:!1,onLoadMore:()=>o(e=>e+r)})]})}export{E as MyFavorites};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-C51i12iP.js";import{m as s,t as o,I as e,B as a}from"./index-
|
|
1
|
+
import{j as t,L as n}from"./react-C51i12iP.js";import{m as s,t as o,I as e,B as a}from"./index-CQjL9b6j.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";function c(){return s({title:o("seo.notFound.title"),noindex:!0}),t.jsxs("div",{className:"notfound","data-testid":"notfound",children:[t.jsx(e,{name:"cart",className:"notfound__ico"}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(a,{as:n,to:"/assets",variant:"purple",children:o("notFound.cta")})]})}export{c as NotFound,c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as A,M as O,b as U,v as q,t as a,C as B,B as _,e as v,q as F,j as k,J as Q,E as W,k as D}from"./index-
|
|
1
|
+
import{p as A,M as O,b as U,v as q,t as a,C as B,B as _,e as v,q as F,j as k,J as Q,E as W,k as D}from"./index-CQjL9b6j.js";import{d as w}from"./dcl-schemas-BICTSpB5.js";import{u as G,r as m,j as s}from"./react-C51i12iP.js";import{i as J,e as K,c as H}from"./trade-encoding-k0j0xnxQ.js";import{f as V}from"./errors-CVrT6Ui5.js";import{E as X}from"./ErrorNotice-C7soUjRV.js";const N=()=>`${A.builderServerUrl}/v1`;function P(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function E(e,r){const t=await O(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const n=await t.json();return n.data??n}function Y(e,r){const t=r-e;return t>0?t:0}function z(e){var r,t,n,i,l;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(n=e.data)==null?void 0:n.emote)==null?void 0:i.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function I(e){return`${N()}/storage/contents/${e}`}function f(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?I(t):/^(ba|Qm)/.test(e)?I(e):""}async function Z(e,r){try{const t=await fetch(`${N()}/items/${e}/${r}/contents`);if(!t.ok)return{};const n=await t.json();return n.data??n}catch{return{}}}async function ee(e,r,t){const n=f(e.thumbnail,e.contents)||f("thumbnail.png",e.contents);if(n)return n;if(r&&t){const i=await Z(r,t);return f(e.thumbnail,i)||f("thumbnail.png",i)||f("image.png",i)}return""}async function te(e,r){const t=`${N()}/${e.toLowerCase()}/collections?is_published=true`,n=await E(t,r);return P(n).filter(i=>i.is_published&&!!i.contract_address).map(i=>({id:i.id,name:i.name,contractAddress:i.contract_address.toLowerCase(),isPublished:i.is_published,isApproved:i.is_approved,minters:(i.minters??[]).map(l=>l.toLowerCase())}))}async function se(e,r){const t=`${N()}/collections/${e.id}/items`,n=await E(t,r);return(await Promise.all(P(n).map(async l=>{const b=l.rarity??"common",y=Number(l.total_supply??0)||0;let o;try{o=w.Rarity.getMaxSupply(b)}catch{o=0}const g=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:g,blockchainItemId:p,name:l.name,category:z(l),rarity:b,thumbnail:await ee(l,g,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Y(y,o),minters:e.minters}}))).filter(re)}function re(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function ue(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await se(i,r)}catch{return[]}}))).flat()}const ae=1e3*60*60*24*182;function me({item:e,session:r,onClose:t}){const n=U(),i=G(),[l,b]=m.useState("10"),[y,o]=m.useState(null),[g,p]=m.useState(null),[d,L]=m.useState(!1),[h,j]=m.useState(null),[C,$]=m.useState(null),x=A.chainId,S=q(r.providerType);m.useEffect(()=>{let c=!1;return(async()=>{try{const u=await J({contractAddress:e.contractAddress,chainId:x});c||j(u)}catch{c||j(!1)}})(),()=>{c=!0}},[e.contractAddress,x]);async function M(){p(null);const c=Number(l);if(!Number.isInteger(c)||c<=0){p(a("primaryList.errorWholeNumber"));return}L(!0);try{h||(o(a("primaryList.statusEnabling")),await K({signer:r.signer,contractAddress:e.contractAddress,chainId:x}),j(!0)),o(a("primaryList.statusPublishing"));const u=await H({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:w.Network.MATIC,chainId:x},usdPrice:c/10,uses:e.remainingSupply,expiresAtMs:Date.now()+ae});o(a("primaryList.statusFinishing")),await F(u,r.identity),o(null),$(c),k("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"primary",is_primary:!0}),Q.success(a("primaryList.toastOnSale",{name:e.name})),n.invalidateQueries({queryKey:["publishable-items"]}),n.invalidateQueries({queryKey:["collection-sale-state"]})}catch(u){W(u,{flow:"list_primary"}),k("Shop Listing Failed",{listing_type:"primary",error_code:D(u)}),p(V(u,a("primaryList.errorGeneric"))),o(null)}finally{L(!1)}}function T(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const R=d?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return C!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("primaryList.successTitle")}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("primaryList.listedFor")," ",s.jsxs("strong",{children:[s.jsx(B,{className:"ccy-mark"})," ",C]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(_,{variant:"purple",onClick:T,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("primaryList.publishTitle",{name:e.name})}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"muted small",children:a("primaryList.fromCollection",{collectionName:e.collectionName,count:e.remainingSupply})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("primaryList.priceLabel",{currency:v.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:c=>b(c.target.value),disabled:d})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:v.name,currencySingular:v.nameSingular})}),h===!1&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeConfirm",{collectionName:e.collectionName})}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeManaged",{collectionName:e.collectionName})}):h===!0&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyConfirm")}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyManaged")}):null,y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(X,{message:g}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,disabled:d,children:a("primaryList.cancel")}),s.jsx(_,{onClick:()=>void M(),disabled:d||h===null,children:h===null?a("primaryList.checking"):R})]})]})})}export{me as P,ue as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as s,u as se,r as n,L as te}from"./react-C51i12iP.js";import{t as a,F as C,s as _,N as ae,m as ie,u as re,b as ne,I as E,B as F,J as R}from"./index-
|
|
1
|
+
import{j as s,u as se,r as n,L as te}from"./react-C51i12iP.js";import{t as a,F as C,s as _,N as ae,m as ie,u as re,b as ne,I as E,B as F,J as R}from"./index-CQjL9b6j.js";import{u as oe,d as le,t as ce,L as de,i as B,a as v,s as me}from"./useStore-BebNq11Z.js";import{E as M}from"./ErrorNotice-C7soUjRV.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-30015679616.commit-6ed38d1/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-30015679616.commit-6ed38d1/assets/template-cover-2-Dni9s0i_.jpeg",ge=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ue,"../assets/creator-covers/template-cover-2.jpeg":pe}),h=Object.entries(ge).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>({name:i.split("/").pop(),url:d})),ve=ae`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v,u as k,j as s,N as w,r as p}from"./react-C51i12iP.js";import{u as y,m as b,t as e,v as C,C as f,w as A,x as S,p as g,s as B,B as I,y as L,e as E}from"./index-
|
|
1
|
+
import{a as v,u as k,j as s,N as w,r as p}from"./react-C51i12iP.js";import{u as y,m as b,t as e,v as C,C as f,w as A,x as S,p as g,s as B,B as I,y as L,e as E}from"./index-CQjL9b6j.js";import{w as T,S as F}from"./buy-gasless-jDmWcdID.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./authorizations-HljWnE0x.js";import"./index-HN6Rk25C.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./trade-encoding-k0j0xnxQ.js";const j=B(I)`
|
|
2
2
|
min-width: 160px;
|
|
3
3
|
text-align: center;
|
|
4
4
|
`,M=c=>new Promise(t=>setTimeout(t,c));function P(c,t){const[a,i]=p.useState(c?"pending":"confirmed"),m=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return p.useEffect(()=>{if(!c)return;let r=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!r;n++)try{await T(c,{timeoutMs:15e3}),h=!0;break}catch(d){if(d instanceof F)continue;r||i("failed");return}if(!r){if(!h){i("timed-out");return}if(!t){i("confirmed");return}i("indexing");for(let n=0;n<40&&!r;n++){if(await L(t.owner,t.contractAddress,t.itemId)){r||i("confirmed");return}await M(3e3)}r||i("timed-out")}})(),()=>{r=!0}},[c,m]),a}const R=g.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",W=g.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function V(){const{state:c}=v(),t=k(),{session:a}=y(),i=c==null?void 0:c.txHash,m=(c==null?void 0:c.items)??[],r=c!=null&&c.creditsAdded&&c.creditsAdded>0?c.creditsAdded:null,l=m[0],h=a!=null&&a.address&&(l!=null&&l.contractAddress)&&(l!=null&&l.itemId)?{owner:a.address,contractAddress:l.contractAddress,itemId:l.itemId}:null,n=P(c!=null&&c.settled?void 0:i,h);b({title:e("seo.success.title"),noindex:!0});const d=m;if(d.length===0)return s.jsx(w,{to:"/assets",replace:!0});const _=d[0],u=!!i&&C(a==null?void 0:a.providerType)?s.jsx("a",{className:"success__receipt",href:`${W}${i}`,target:"_blank",rel:"noreferrer",children:e("success.viewTransaction")}):null;return n!=="confirmed"?s.jsx("div",{className:"success",children:s.jsx("div",{className:"success__status",children:n==="pending"||n==="indexing"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),s.jsx("h1",{className:"success__title",children:n==="indexing"?e("success.finalizing"):e("success.processing")}),s.jsx("p",{className:"success__sub",children:n==="indexing"?s.jsxs(s.Fragment,{children:[e("success.indexingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.indexingAfter")]}):s.jsxs(s.Fragment,{children:[e("success.confirmingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.confirmingAfter")]})}),u?s.jsx("div",{className:"success__links",children:u}):null]}):n==="timed-out"?s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.stillProcessingTitle")}),s.jsxs("p",{className:"success__sub",children:[e("success.timedOutBefore")," ",s.jsx("button",{className:"link",onClick:()=>t("/activity"),children:e("nav.activity")})," ",e("success.timedOutAfter")]}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsxs("div",{className:"success__actions",children:[s.jsx(j,{variant:"purple",onClick:()=>t("/activity"),children:e("success.viewActivity")}),s.jsx(j,{variant:"ghost",onClick:()=>t("/assets"),children:e("success.keepShopping")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.failedTitle")}),s.jsx("p",{className:"success__sub",children:e("success.failedBody")}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsx("div",{className:"success__actions",children:s.jsx(j,{variant:"purple",onClick:()=>t("/assets"),children:e("success.backToShop")})})]})})}):s.jsx("div",{className:"success",children:s.jsxs("div",{className:"success-done",children:[s.jsxs("div",{className:"success-banner",role:"status",children:[s.jsx("span",{className:"success-banner__check","aria-hidden":!0,children:s.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[s.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),s.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsxs("p",{className:"success-banner__text",children:[s.jsx("b",{children:e("success.bannerTitle")})," ",e("success.bannerBody")]})]}),s.jsxs("div",{className:"success-list",children:[r?s.jsxs("div",{className:"success-credits","data-testid":"success-credits",children:[s.jsx(f,{className:"success-credits__ico"}),s.jsxs("p",{className:"success-credits__text",children:[s.jsx("span",{className:"success-credits__amount",children:e("getCredits.creditsAmount",{credits:r,currency:E.name})})," ",s.jsx("span",{className:"success-credits__added",children:e("getCredits.creditsAdded")})]})]}):null,d.map((o,N)=>{const x=o.quantity??1;return s.jsxs("div",{className:"success-list__row",children:[N>0?s.jsx("span",{className:"success-list__divider","aria-hidden":!0}):null,s.jsxs("div",{className:"success-row",children:[s.jsxs("div",{className:"success-row__thumb",children:[o.thumbnail?s.jsx("img",{src:o.thumbnail,alt:""}):null,s.jsx("span",{className:"success-row__check","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:s.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),s.jsxs("div",{className:"success-row__info",children:[s.jsxs("div",{className:"success-row__name",title:o.name,children:[o.name||e("buyModal.itemFallback"),x>1?s.jsx("span",{className:"success-row__qty",children:e("cartCheckout.qty",{count:x})}):null]}),o.creator?s.jsx(A,{address:o.creator,className:"success-row__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"success-row__price",children:[s.jsx(f,{className:"success-row__price-ico"}),s.jsx("span",{children:S(o.priceCredits*x)})]})]})]},o.id)})]}),u?s.jsx("div",{className:"success__links success-done__receipt",children:u}):null,s.jsxs("div",{className:"success-ctas",children:[s.jsx("button",{className:"success-cta success-cta--ghost",onClick:()=>t("/my-assets"),children:e("success.myAssets")}),s.jsxs("a",{className:"success-cta success-cta--ruby",href:R,target:"_blank",rel:"noreferrer",children:[e("success.tryInWorld"),s.jsx("span",{className:"success-cta__jump","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:s.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})})}export{V as Success,V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-B8RM0-JJ.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.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-Cng56IwM.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.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 e,j as c}from"./react-C51i12iP.js";import{s as d,F as r}from"./index-
|
|
1
|
+
import{r as e,j as c}from"./react-C51i12iP.js";import{s as d,F as r}from"./index-CQjL9b6j.js";import{n as x}from"./emotion-CSxEP8yM.js";const h=d("span",x("block"))`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
4
4
|
${({block:t})=>t?"width: 100%;":""}
|
|
@@ -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-w5dOkonM.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-C51i12iP.js";import{bd as Re}from"./index-
|
|
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-w5dOkonM.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-C51i12iP.js";import{bd as Re}from"./index-CQjL9b6j.js";import{a as te,g as re}from"./index-HN6Rk25C.js";import{c as q,e as be}from"./index-B8Ud1Gn4.js";import{s as Ie}from"./sendMetaTransaction-CiO3jI6F.js";import"./sentry-DKBoGDXH.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new be.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const 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),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&ⅇ(c.global===c||c.window===c||c.self===c)&&(e=c);var l,b=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=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=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class tt{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{tt as TradeService};
|