@dcl/shop 0.1.0-29942650568.commit-3cdb6da → 0.1.0-29944279663.commit-001b5a7
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/{AnimatedBackground-CysLhvvU.js → AnimatedBackground-CPcXx1BG.js} +1 -1
- package/assets/{Assets-DsvJ5f0v.js → Assets-AjWSopj2.js} +1 -1
- package/assets/{Assets.styles-CA7lhkqC.js → Assets.styles-BldKbSnl.js} +1 -1
- package/assets/{Authorizations-vnz0r2Ax.js → Authorizations-DN5rReSr.js} +3 -3
- package/assets/Cart-BOomZzFA.js +3 -0
- package/assets/{Cart-Ep_4Wxpy.css → Cart-BqMUti_3.css} +1 -1
- package/assets/{CircularProgress-BoWkcKSM.js → CircularProgress-B7vK7bWC.js} +3 -3
- package/assets/{Collection-DFg8H4cI.js → Collection-Op3SrGcQ.js} +1 -1
- package/assets/CollectionCarousel-C2R0_DIx.js +1 -0
- package/assets/{Creator-DpJL7xsg.js → Creator-BXkmnq6l.js} +1 -1
- package/assets/{CssVarsProvider-CVkDPUQi.js → CssVarsProvider-CbqPuVyv.js} +1 -1
- package/assets/{ExchangeController-XYLG0Onl.js → ExchangeController-CkwXcZrE.js} +1 -1
- package/assets/GetCredits-DyYrVUsB.js +1 -0
- package/assets/{HelpersUtil-CXmyL-9f.js → HelpersUtil-Cd6Cz7k6.js} +1 -1
- package/assets/{ImportListings-DL4qvnkm.js → ImportListings-BqaE2RRj.js} +1 -1
- package/assets/ItemDetail-CXntx0dm.js +78 -0
- package/assets/{LoadMore-DwH_uJJ9.js → LoadMore-wolzH5ER.js} +1 -1
- package/assets/MarketCheckout-D_f5rC4e.js +3 -0
- package/assets/{MyAssets-ChdfSyve.js → MyAssets-CBQJfW0w.js} +1 -1
- package/assets/{MyFavorites-BAgv7K26.js → MyFavorites-DtHDd-wr.js} +1 -1
- package/assets/{MyPurchases-DlfJ7xtX.js → MyPurchases-BBRP2pOD.js} +4 -4
- package/assets/{NotFound-uK-Ostnl.js → NotFound-CJzX5KFi.js} +1 -1
- package/assets/{PrimaryListModal-Bm7Lx1a1.js → PrimaryListModal-Bfe2jEqA.js} +1 -1
- package/assets/{StoreSettings-jeamoHJO.js → StoreSettings-CCjyP-1z.js} +2 -2
- package/assets/Success-DgDiikPg.js +4 -0
- package/assets/{SwapController-B81AJRRn.js → SwapController-CtlOMvk3.js} +1 -1
- package/assets/{Tooltip-CYItdKnL.js → Tooltip-BtGlCRjR.js} +1 -1
- package/assets/{TradeService-BxBTy4_C.js → TradeService-OKrfHBNk.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-WHc1zToo.js → W3MFrameProviderSingleton-BFTt2bWv.js} +3 -3
- package/assets/{WebCryptoP256-BQQeByzz.js → WebCryptoP256-CNNq2h94.js} +1 -1
- package/assets/{authorizations-C600xDT9.js → authorizations-ChRb35xG.js} +1 -1
- package/assets/{basic-CaSER4PW.js → basic-O1kzoE_h.js} +1 -1
- package/assets/{biconomy-nsDuvr1X.js → biconomy-NJyzVP4P.js} +1 -1
- package/assets/{buy-C5J6mAtx.js → buy-CNc4Y8CN.js} +1 -1
- package/assets/{buy-gasless-Sy6Gurph.js → buy-gasless-wrR0AjfW.js} +1 -1
- package/assets/{cart-checkout-BwJruvi6.js → cart-checkout-BAUaf92R.js} +1 -1
- package/assets/{categories-CQMvcQ_A.js → categories-BKqMpg3a.js} +1 -1
- package/assets/{ccip-CVFd9-T6.js → ccip-DzP3mwwB.js} +1 -1
- package/assets/{ccip-C_DKTuDg.js → ccip-S_59ofbi.js} +1 -1
- package/assets/{collection-BButATLz.js → collection-4y6zy3OY.js} +1 -1
- package/assets/{controller-C4IlqRFi.js → controller-CyymDuZ1.js} +2 -2
- package/assets/{core-Bsb1vtZ6.js → core-DpgBxh1f.js} +4 -4
- package/assets/{custom-B2_bVLxh.js → custom-CUYXqRFz.js} +1 -1
- package/assets/{data-capture-CeCg7Ckv.js → data-capture-DEtSxXU7.js} +1 -1
- package/assets/{email-DGWqulOs.js → email-CZBKdtTz.js} +1 -1
- package/assets/{embedded-wallet-BDA__pmu.js → embedded-wallet-DI5q9f92.js} +1 -1
- package/assets/emotion-styled.browser.esm-DSDqSITi.js +1 -0
- package/assets/{engine-COT4y3N6.js → engine-H6XTP7Hg.js} +1 -1
- package/assets/{errors-B2rT3Gvo.js → errors-gKUnErEU.js} +1 -1
- package/assets/{estimate-l1-fee-DSG403IA.js → estimate-l1-fee-CRLseeHD.js} +1 -1
- package/assets/{execute-zpOqUNic.js → execute-DnoTKwUA.js} +2 -2
- package/assets/{features-CMZ-QMXf.js → features-DsCWYm7t.js} +1 -1
- package/assets/{fetchTokenMetadata-CZyR6DMv.js → fetchTokenMetadata-D8xF6Tp2.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-Cll7wRD7.js → get-ecosystem-wallet-info-eeuY73_c.js} +1 -1
- package/assets/{getBalance-BlSTzNnh.js → getBalance-D4FtfBuc.js} +1 -1
- package/assets/{getNFT-bAbPTgKN.js → getNFT-CCUV8jjB.js} +1 -1
- package/assets/{getNFT-yZahXefO.js → getNFT-DsBG7sol.js} +1 -1
- package/assets/{getOverlayAlpha-CH1E19pc.js → getOverlayAlpha-DD0MBenH.js} +1 -1
- package/assets/{hashTypedData-CoI7qham.js → hashTypedData-D4XcfX8m.js} +1 -1
- package/assets/{hashTypedData-BjKHZJt2.js → hashTypedData-DY9RW77q.js} +1 -1
- package/assets/{import-B-7LIWfg.js → import-C4A0dOmT.js} +1 -1
- package/assets/{in-app-DuAkMaop.js → in-app-miryaTIx.js} +1 -1
- package/assets/{in-app-wallet-calls-VVaW7dWC.js → in-app-wallet-calls-BNAeRkM1.js} +1 -1
- package/assets/{index-D4mGcEtB.js → index-5BCUAQ7G.js} +1 -1
- package/assets/{index-CBhum_yI.js → index-B-lOuLL_.js} +1 -1
- package/assets/{index-DuM3vKAV.js → index-B0f3YMv0.js} +1 -1
- package/assets/{index-VrPb_Zz5.js → index-B2KZdX5l.js} +1 -1
- package/assets/{index-Dp2XIou0.js → index-B7Aw3qxP.js} +1 -1
- package/assets/{index-ChF-gCVV.js → index-BHgNE80I.js} +1 -1
- package/assets/{index-D2i7N7FD.js → index-BMxVktKR.js} +1 -1
- package/assets/{index-CyMsSal1.js → index-BPTCeB75.js} +1 -1
- package/assets/{index-Cj8JMZ6F.js → index-BR9EQbWB.js} +1 -1
- package/assets/{index-2LZVA_H9.js → index-BVDwZ7ux.js} +1 -1
- package/assets/{index-uk-CfnlL.js → index-BaEQqKh7.js} +1 -1
- package/assets/{index-C4vAJ3fL.js → index-Bd6HRkkM.js} +1 -1
- package/assets/{index-BCa080Jk.js → index-BeDPwdIU.js} +1 -1
- package/assets/{index-B14E9dDt.js → index-BeF4PcAs.js} +1 -1
- package/assets/{index-ZjDtH0Hr.js → index-Bnxb7s2U.js} +1 -1
- package/assets/index-Bw9Y53F1.css +1 -0
- package/assets/{index-Q9d0V8TZ.js → index-C1yBaAe9.js} +10 -10
- package/assets/{index-DvbuNJKq.js → index-CAtCo41a.js} +1 -1
- package/assets/{index-C2JrnQDe.js → index-CJ72HArz.js} +1 -1
- package/assets/{index-Cok_sFK3.js → index-CKain9CR.js} +1 -1
- package/assets/{index-DIusB22U.js → index-CNUSWwhT.js} +2 -2
- package/assets/{index-BEL4KhCu.js → index-CS_YGkJS.js} +1 -1
- package/assets/{index-CUV4Rf3F.js → index-CUapata6.js} +1 -1
- package/assets/{index-Dfv7PJQh.js → index-CW4WLUXF.js} +1 -1
- package/assets/{index-CiH0W5Hj.js → index-CaKtCSoO.js} +1 -1
- package/assets/{index-CjnhvTx0.js → index-CchI9mHk.js} +1 -1
- package/assets/{index-CRZSv11U.js → index-Cd8SstNC.js} +1 -1
- package/assets/{index-BSSPgvD1.js → index-Cglxr6xq.js} +1 -1
- package/assets/{index-Bzlo07t4.js → index-CitxiVaF.js} +1 -1
- package/assets/{index-DeO2Srep.js → index-CpUzfl0K.js} +2 -2
- package/assets/{index-DIZEbKwM.js → index-CryDMiQl.js} +1 -1
- package/assets/{index-BlnhiyW1.js → index-CvSuJFRB.js} +1 -1
- package/assets/{index-B5bMVqc5.js → index-D-u-hSI3.js} +1 -1
- package/assets/{index-zvLgVYhW.js → index-D15jEYwr.js} +1 -1
- package/assets/{index-DcAG03_T.js → index-D4MR9O_F.js} +1 -1
- package/assets/{index-Bwtbao7B.js → index-DBt6hDgv.js} +1 -1
- package/assets/{index-DJCp8uIp.js → index-DNxKrdux.js} +1 -1
- package/assets/{index-gcnUvFrd.js → index-DSw2AqET.js} +1 -1
- package/assets/{index-BsY45tr2.js → index-DWxI9Hlb.js} +1 -1
- package/assets/{index-DsttSp14.js → index-DXtL9zpK.js} +3 -3
- package/assets/{index-D7J0TuHz.js → index-DbySRbMy.js} +2 -2
- package/assets/{index-BaDAgjcA.js → index-DpDqOxel.js} +1 -1
- package/assets/{index-C0_U8Amn.js → index-DsrJfyy3.js} +1 -1
- package/assets/{index-DmSOW0PY.js → index-G8bd0RHd.js} +1 -1
- package/assets/{index-tAmGgcla.js → index-KOeN6JEM.js} +1 -1
- package/assets/{index-BC--wvbP.js → index-U4GunfhO.js} +1 -1
- package/assets/{index-CzOo8tvO.js → index-ZiBxg6FP.js} +2 -2
- package/assets/{index-CkTptFnK.js → index-dBhDm5QH.js} +2 -2
- package/assets/{index-BmwayVyG.js → index-iruECcYS.js} +3 -3
- package/assets/{index-DxHb67V2.js → index-k4CkTGxw.js} +1 -1
- package/assets/{index-C0utXQ6l.js → index-rbNc96Al.js} +1 -1
- package/assets/{index-CJs5gUNJ.js → index-sXacIDUz.js} +3 -3
- package/assets/{index-ClDUuLhd.js → index-wJEgDopC.js} +1 -1
- package/assets/{index.es-DAd9yxMt.js → index.es-BxcQA2dU.js} +1 -1
- package/assets/{index.es-BzMx-nup.js → index.es-Cl_XwBUi.js} +4 -4
- package/assets/{index.es-fI5nPWfV.js → index.es-DIuzDiOd.js} +1 -1
- package/assets/{localBatchGatewayRequest-BIFDJTSD.js → localBatchGatewayRequest-DInd0cLm.js} +1 -1
- package/assets/{mana-rate-CC-yyhWK.js → mana-rate-CQNKlfL0.js} +1 -1
- package/assets/{networks-DkdE2sZd.js → networks-Cov5QiMG.js} +1 -1
- package/assets/{onramp-C_i59kJR.js → onramp-hb5ff0As.js} +1 -1
- package/assets/{openzeppelin-BMNh5qua.js → openzeppelin-Bjn2nu6_.js} +1 -1
- package/assets/{parseNft-CW-hWGBI.js → parseNft-D9LBoQtO.js} +2 -2
- package/assets/{parseSignature-NZopg6IG.js → parseSignature-L1A1P3GM.js} +1 -1
- package/assets/{parseSignature-C3GhRBL-.js → parseSignature-ePtMgMiu.js} +3 -3
- package/assets/{passkeys-DuQQbJhZ.js → passkeys-DmsGOzkI.js} +1 -1
- package/assets/{pay-with-exchange-DH6Kt6OD.js → pay-with-exchange-AEyKwlqz.js} +1 -1
- package/assets/{qr-overlay-u2BzHEzf.js → qr-overlay-DyUlpaIC.js} +1 -1
- package/assets/{receive-D2V6X2tA.js → receive-DXQR7h-2.js} +1 -1
- package/assets/{resolveImplementation-BsuIKFkz.js → resolveImplementation-BXX46XHe.js} +1 -1
- package/assets/{rpc-BIhelmqB.js → rpc-DpwEotT8.js} +1 -1
- package/assets/{secp256k1-BHmvTUzO.js → secp256k1-CAtCZ-Xr.js} +1 -1
- package/assets/{secp256k1-BtgeD6jy.js → secp256k1-DXm6hl-z.js} +1 -1
- package/assets/{secp256k1-hNsXkUex.js → secp256k1-IsXW7STM.js} +1 -1
- package/assets/{send-DkPpjCf1.js → send-CbWz9hcp.js} +1 -1
- package/assets/{send-batch-transaction-Bt9-Q0FO.js → send-batch-transaction-9mR-y7h4.js} +1 -1
- package/assets/{send-eip712-transaction-CJ8Dr-eb.js → send-eip712-transaction-CM2oNuUv.js} +2 -2
- package/assets/{send-gasless-transaction-D5eQ85CY.js → send-gasless-transaction-Dt3TrVjF.js} +2 -2
- package/assets/{send-transaction-BK1KmPMR.js → send-transaction-BZ4LJjTi.js} +2 -2
- package/assets/{sendRawTransaction-Ddh_tSjE.js → sendRawTransaction--x3C4a4M.js} +3 -3
- package/assets/{serializeTransaction-f04zsBlb.js → serializeTransaction-DkNQBPpa.js} +1 -1
- package/assets/{session-proposal-r1mPrmCX.js → session-proposal-C_7oJg4v.js} +1 -1
- package/assets/{session-request-Cfr7jp2h.js → session-request-BswrUDyz.js} +2 -2
- package/assets/{signing-C-mKTJFW.js → signing-Ci_N7XnZ.js} +3 -3
- package/assets/{socials-pmAt6WyL.js → socials-Cy0uuEjD.js} +1 -1
- package/assets/{swaps-XKJYQXAz.js → swaps-CJefGDGP.js} +1 -1
- package/assets/{thirdweb-B_kKfwse.js → thirdweb-_jeY-8oo.js} +3 -3
- package/assets/{to-serializable-transaction-rhTmQPEU.js → to-serializable-transaction-z3rODop-.js} +2 -2
- package/assets/{trade-encoding-CaZYjVNs.js → trade-encoding-DQ3zNCj8.js} +1 -1
- package/assets/{transactionReceipt-BcU054L-.js → transactionReceipt-CmnDZJIN.js} +1 -1
- package/assets/{transactions-lrp4i700.js → transactions-C19bGnmB.js} +1 -1
- package/assets/useCreditPacks-Caur-2iX.js +1 -0
- package/assets/{useInfiniteGrid-8c-8xSTi.js → useInfiniteGrid-CRDFn4if.js} +1 -1
- package/assets/{useStore-Ccbed9Z-.js → useStore-DjC0Mzyl.js} +1 -1
- package/assets/useTheme-4G-3zKnL.js +1 -0
- package/assets/useTheme-YjNnj0AZ.js +1 -0
- package/assets/{verifyHash-z4q1c5J1.js → verifyHash-C_4O6fWL.js} +1 -1
- package/assets/{w3m-modal-2GWsHPDh.js → w3m-modal-C8bpYQNG.js} +1 -1
- package/assets/{w3m-modal-DUSXSzQv.js → w3m-modal-Ckpscz46.js} +1 -1
- package/assets/{wait-for-tx-receipt-CAc2Bmoi.js → wait-for-tx-receipt-FMU2_8T4.js} +1 -1
- package/assets/{wallets-BD_QGCV9.js → wallets-DdObuep1.js} +5 -5
- package/assets/{web-connector-Da5xZh52.js → web-connector-CnDHaN6b.js} +3 -3
- package/assets/{writeContract-zNHMPW7R.js → writeContract-C9X9RN9V.js} +1 -1
- package/assets/{zoraTestnet-Csb8JMNL.js → zoraTestnet-d3v06Qdp.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Cart-CTQAeaCb.js +0 -3
- package/assets/CollectionCarousel-BgmGp9gP.js +0 -1
- package/assets/GetCredits-C41Akzju.js +0 -1
- package/assets/ItemDetail-8kxMVjol.js +0 -78
- package/assets/MarketCheckout-0NCiBi_9.js +0 -3
- package/assets/Success-IAIc5xBC.js +0 -4
- package/assets/emotion-styled.browser.esm-Of0yAmXP.js +0 -1
- package/assets/index-DYDor-ZM.css +0 -1
- package/assets/useCreditPacks-Be9cG5vr.js +0 -1
- package/assets/useTheme-7-Mr4FFJ.js +0 -1
- package/assets/useTheme-C3YHg0O0.js +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CpUzfl0K.js","assets/react-BrLDncxD.js","assets/dcl-schemas-BICTSpB5.js","assets/index-C1yBaAe9.js","assets/sentry-DYZXk5O5.js","assets/ethers-CLB2z3On.js","assets/intl-CBcMB1D2.js","assets/index-Bw9Y53F1.css","assets/emotion-styled.browser.esm-DSDqSITi.js","assets/useTheme-YjNnj0AZ.js","assets/CircularProgress-B7vK7bWC.js","assets/index-dBhDm5QH.js","assets/useTheme-4G-3zKnL.js","assets/CssVarsProvider-CbqPuVyv.js","assets/getOverlayAlpha-DD0MBenH.js","assets/index-BVDwZ7ux.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as oe,r as d,j as e,d as pa,u as ya,L as fa}from"./react-BrLDncxD.js";import{d as X,n as xa,o as ve,t,ah as ba,i as ga,b as ja,w as va,q as ne,x as D,y as ge,z as fe,ai as Na,E as Z,g as E,j as de,B as z,C as xe,p as wa,J as Je,_ as be,ak as ka,ax as Ia,ay as Ca,az as Sa,aA as Aa,c as Ne,aB as Ma,L as Ye,m as B,aC as Pa,I as T,F as K,s as W,aD as Ea,aE as Fa,aF as La,G as Ta,ae as ze,a as Ke,aG as Da,aH as Ra,aI as qa,aJ as Ba,aK as $a,af as Oa,u as za,aL as Ka,aM as Wa,aN as Va,h as Qa,aO as We,aP as Ua,f as Ga,ao as Ha,aQ as Ja,aR as Ya,ap as Xa,aS as Za,aT as et}from"./index-C1yBaAe9.js";import{d as G}from"./dcl-schemas-BICTSpB5.js";import{b as Ve,c as at}from"./buy-CNc4Y8CN.js";import{P as tt,f as st}from"./PrimaryListModal-Bfe2jEqA.js";import{g as it,b as rt,w as nt,S as lt,G as dt}from"./buy-gasless-wrR0AjfW.js";import{u as ot,M as ct,c as mt}from"./useCreditPacks-Caur-2iX.js";import{W as ut,C as ht,a as _t}from"./CollectionCarousel-C2R0_DIx.js";import{R as Qe}from"./resume-buy-Bf0zIH7y.js";import{a as pt,f as je,i as yt}from"./errors-gKUnErEU.js";import{E as ce}from"./ErrorNotice-BDH9xoG4.js";import{l as ft}from"./loader-logo-BzY9EKdC.js";import{C as xt}from"./CircularProgress-B7vK7bWC.js";import{a as bt,b as gt}from"./trade-encoding-DQ3zNCj8.js";import{u as jt,M as vt}from"./MarketCheckout-D_f5rC4e.js";import{s as Nt}from"./address-DrURAr9O.js";import{T as Xe}from"./Tooltip-BtGlCRjR.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";import"./authorizations-ChRb35xG.js";import"./index-HN6Rk25C.js";import"./mana-rate-CQNKlfL0.js";import"./emotion-CSxEP8yM.js";function wt({item:s,onClose:n,resume:i=!1}){var ae,te;const{session:o}=X(),{data:m}=xa(o),h=ve(),w=oe(),x=ot().packs.slice(0,ct),[c,l]=d.useState("loading"),[a,j]=d.useState(null),[y,N]=d.useState(""),[F,b]=d.useState(s.priceCredits),[f,g]=d.useState(null),I=d.useRef(null),M=(f==null?void 0:f.credits)??F,ee=(m==null?void 0:m.credits)??0;d.useEffect(()=>{let u=!1;if(!o){l("error"),j(t("buyModal.signInToCheckout"));return}const C=_=>{const S=_-((m==null?void 0:m.credits)??0),v=x.find(R=>R.credits>=S)??x[x.length-1];N(v.id),D("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:_,credits_balance:(m==null?void 0:m.credits)??0,shortfall:Math.max(0,S)}),l("nofunds")};return(async()=>{var _,S;try{const v=await ba(s);if(!v)throw new Error("not for sale");if(ga(v,o.address))throw new Error("You can't buy your own listing.");const R=ja((S=(_=v.received)==null?void 0:_[0])==null?void 0:S.amount);if(!Number.isFinite(R)||R<=0)throw new Error("price unavailable");const V=Math.ceil(R/10);if(u)return;if(b(V),m!=null&&m.credits<V){C(V);return}try{const{credit:A,maxCreditedValue:J,usdCents:O}=await va(o.identity,R,v.id);if(u){ne(o.identity,[A.id]).catch(()=>{});return}I.current=A.id;const se=Math.ceil(O/10);b(se);const Q={trade:v,credit:A,maxCreditedValue:J,usdCents:O,credits:se};g(Q),i?H(Q):l("ready")}catch(A){if(u)return;if(pt(A)){C(V);return}throw A}}catch(v){if(u)return;D(fe(v)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:ge(v)}),l("error"),j(je(v,t("buyModal.error.generic"),{sale:!0}))}})(),()=>{u=!0,I.current&&o&&(ne(o.identity,[I.current]).catch(()=>{}),I.current=null)}},[]);async function H(u=f){if(!o||!u)return;l("processing"),j(null);let C=!1;try{const _={trade:u.trade,buyer:o.address,signer:o.signer,credits:[u.credit],maxCreditedValue:u.maxCreditedValue};let S;if(it())try{S=await rt(_),await nt(S),C=!0}catch(v){if(v instanceof lt)C=!0;else if(v instanceof dt)S=await Ve(_);else throw v}else S=await Ve(_);I.current=null,D("Shop Completed Purchase",{...Na([s]),payment_type:"credits",no_crypto_step:C,transaction_hash:S??null}),h.invalidateQueries({queryKey:["usd-balance"]}),l("complete")}catch(_){fe(_)||Z(_,{flow:"buy",step:"submit",gasless:C}),ne(o.identity,[u.credit.id]).catch(()=>{}),I.current=null,D(fe(_)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:ge(_)}),h.invalidateQueries({queryKey:["usd-balance"]}),j(je(_,t("buyModal.error.generic"),{sale:!0})),l("error")}}async function me(){if(!(!y||!o)){try{sessionStorage.setItem(Qe,JSON.stringify(s))}catch{}f&&ne(o.identity,[f.credit.id]).catch(()=>{}),I.current=null,l("loading");try{const u=await mt(y,{address:o.address,identity:o.identity});if(u.url){window.location.href=u.url;return}w("/credits")}catch(u){Z(u,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(Qe)}catch{}j(t("buyModal.error.creditsCheckout")),l("error")}}}const $=c==="processing",L=c==="complete"?t("buyModal.titleComplete"):c==="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:$?void 0:n,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${c==="processing"||c==="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:L}),!$&&e.jsx("button",{className:"buy-modal__x",onClick:n,"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:c==="nofunds"?t("buyModal.dclBalance"):t("buyModal.myCreditsBalance")}),e.jsx(E,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:de(ee)})]})]}),c==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(xt,{size:44})}),c==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(ce,{message:a}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:n,children:t("buyModal.close")})})]}),c==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsx(ut,{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,M-ee)})})," ",t("buyModal.warningToPurchase",{count:1})]})]}),e.jsx(Ue,{item:s,priceCredits:M}),e.jsx("div",{className:"buy-modal__packs",children:x.map(u=>{const C=u.credits,_=u.id===y;return e.jsxs("button",{className:`buy-modal__pack${_?" buy-modal__pack--on":""}`,onClick:()=>N(u.id),children:[e.jsx(E,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:de(C)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",u.usd.toFixed(2),")"]})]},u.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(E,{className:"buy-modal__total-ico"}),e.jsx("span",{children:de(((ae=x.find(u=>u.id===y))==null?void 0:ae.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((te=x.find(u=>u.id===y))==null?void 0:te.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:n,children:t("buyModal.cancel")}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:()=>void me(),children:t("buyModal.buy")})]})]}),c==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(Ue,{item:s,priceCredits:M}),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 H(),children:t("buyModal.buy")})})]}),c==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:ft,alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:i?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"})})]}),c==="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:()=>w("/assets?tab=mine"),children:t("buyModal.myAssets")}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:n,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 Ue({item:s,priceCredits:n}){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(ht,{address:s.creator,className:"buy-modal__asset-creator"}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(E,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:de(n)})]})]})]})}const kt=1e3*60*60*24*182;function It({asset:s,session:n,onClose:i}){const o=ve(),m=oe(),[h,w]=d.useState("10"),[x,c]=d.useState(null),[l,a]=d.useState(null),[j,y]=d.useState(!1),[N,F]=d.useState(null);async function b(){a(null);const g=Number(h);if(!Number.isInteger(g)||g<=0){a(t("sellModal.errorWholeNumber"));return}y(!0);try{c(t("sellModal.statusPreparing")),await bt({signer:n.signer,contractAddress:s.contractAddress,chainId:s.chainId}),c(t("sellModal.statusListing"));const I=await gt({signer:n.signer,nft:{contractAddress:s.contractAddress,tokenId:s.tokenId,network:s.network,chainId:s.chainId},usdPrice:g/10,expiresAtMs:Date.now()+kt});c(t("sellModal.statusPublishing")),await wa(I,n.identity),c(null),F(g),D("Shop Listed Item",{item_id:s.itemId??s.tokenId??null,contract_address:s.contractAddress,price_credits:g,price_usd:g/10,listing_type:"secondary",is_primary:!1}),Je.success(t("sellModal.toastOnSale",{name:s.name})),o.invalidateQueries({queryKey:["my-assets",n.address]})}catch(I){Z(I,{flow:"list_secondary"}),D("Shop Listing Failed",{listing_type:"secondary",error_code:ge(I)}),a(je(I,t("sellModal.errorGeneric"))),c(null)}finally{y(!1)}}function f(){i(),m(`/item/${s.contractAddress}/${s.tokenId}`)}return N!==null?e.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:e.jsxs("div",{className:"modal modal--success",onClick:g=>g.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(E,{className:"ccy-mark"})," ",N]})]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(z,{variant:"ghost",onClick:i,children:t("getCredits.done")}),e.jsx(z,{variant:"purple",onClick:f,children:t("sellModal.viewInShop")})]})]})}):e.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:e.jsxs("div",{className:"modal","data-testid":"modal",onClick:g=>g.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:xe.name})}),e.jsx("input",{type:"number",min:"1",step:"1",value:h,onChange:g=>w(g.target.value),disabled:j})]}),e.jsx("p",{className:"muted small",children:t("sellModal.pricedInWhole",{currency:xe.name,currencySingular:xe.nameSingular})}),x?e.jsx("p",{className:"muted",children:x}):null,e.jsx(ce,{message:l}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(z,{variant:"ghost",onClick:i,disabled:j,children:t("sellModal.cancel")}),e.jsx(z,{onClick:()=>void b(),disabled:j,children:j?t("sellModal.listing"):t("sellModal.putOnSale")})]})]})})}const Ct=d.lazy(async()=>{const[{EmoteControls:s},{Experimental_CssVarsProvider:n},{light:i}]=await Promise.all([be(()=>import("./index-CpUzfl0K.js").then(o=>o.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),be(()=>import("./index-dBhDm5QH.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),be(()=>import("./index-BVDwZ7ux.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:o=>e.jsx(n,{theme:i,children:e.jsx(s,{...o})})}});function St(s){return e.jsx(d.Suspense,{fallback:null,children:e.jsx(Ct,{...s})})}function At({item:s}){const n=X(f=>{var g;return(g=f.session)==null?void 0:g.address}),{data:i,isLoading:o}=ka(n),m=n&&i?n:"default",h=s.category==="emote",[w,x]=d.useState("item"),c=!h&&w==="item",l=c||!o,[a,j]=d.useState(!0);d.useEffect(()=>{j(!0)},[s.id,c]);const y=!!n&&!!i,N=y&&Ia(s,Ca(i)),F=Sa(s)[0],b=y&&!N&&!h;return e.jsxs(e.Fragment,{children:[l?e.jsx(Aa,{id:"shop-item-preview",contractAddress:s.contractAddress,tokenId:s.tokenId??void 0,itemId:s.tokenId?void 0:s.itemId??void 0,profile:c?void 0:N?m:"default",bodyShape:c||N?void 0:F,type:h?void 0:c?G.PreviewType.WEARABLE:G.PreviewType.AVATAR,emote:h||c?void 0:G.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:h?1.5:void 0,wheelStart:h?100:void 0,dev:Ne.chainId===80002,onLoad:()=>j(!1)}):null,!l||a?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,b&&!c?e.jsx("p",{className:"item-preview__note",children:t("itemPreview.shownOnBody",{shape:Ma(F)})}):null,h?e.jsx("div",{className:"item-preview__emote-controls","data-testid":"emote-controls",children:e.jsx(St,{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:w==="avatar"?"is-active":"","aria-pressed":w==="avatar","aria-label":t("itemPreview.onAvatar"),onClick:()=>x("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:w==="item"?"is-active":"","aria-pressed":w==="item","aria-label":t("itemPreview.item"),onClick:()=>x("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")})]})]})]})}function Ze(){return Ne.shopServerUrl||(typeof window<"u"?window.location.origin:"")}async function Mt(s,n,i){const o=new URLSearchParams({contractAddress:s,itemId:n}),m=`${Ze()}/notify-requests?${o.toString()}`,h=await Ye(m,{method:"GET",identity:i,metadata:{}});if(!h.ok)throw new Error(`getNotifyRequest ${h.status}`);return h.json()}async function Pt(s,n){const i=`${Ze()}/notify-requests`,o=await Ye(i,{method:"POST",identity:n,metadata:{},headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw new Error(`createNotifyRequest ${o.status}: ${await o.text()}`);await o.json().catch(()=>{})}function Ge(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim())}function Et({item:s}){const n=X(b=>b.session),i=X(b=>b.signIn),[o,m]=d.useState(""),[h,w]=d.useState(!1),[x,c]=d.useState(!1),[l,a]=d.useState(null),j=!!n&&!!s.contractAddress&&!!s.itemId,{data:y}=B({queryKey:["notify-request",s.contractAddress,s.itemId,n==null?void 0:n.address],enabled:j,queryFn:()=>Mt(s.contractAddress,s.itemId,n.identity)});d.useEffect(()=>{y!=null&&y.email&&m(b=>b||y.email)},[y==null?void 0:y.email]),d.useEffect(()=>{if(!n)return;let b=!1;return Pa().then(f=>{!b&&f&&m(g=>g||f)}),()=>{b=!0}},[n]);const N=x||!!(y!=null&&y.subscribed);async function F(b){if(b.preventDefault(),!(!n||!s.itemId||!Ge(o)||h)){w(!0),a(null);try{await Pt({contractAddress:s.contractAddress,itemId:s.itemId,chainId:s.chainId,email:o.trim()},n.identity),c(!0)}catch(f){Z(f,{flow:"notify-me",contractAddress:s.contractAddress,itemId:s.itemId}),a(t("notifyMe.error"))}finally{w(!1)}}}return n?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(T,{name:"check",size:12})}),e.jsx("span",{className:"notify__done-text",children:t("notifyMe.subscribedBody")})]}):e.jsxs("form",{className:"notify",onSubmit:F,"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:o,onChange:b=>m(b.target.value),"data-testid":"notify-email"}),e.jsx("button",{type:"submit",className:"notify__btn",disabled:!Ge(o)||h,"data-testid":"notify-submit",children:h?t("notifyMe.working"):t("notifyMe.cta")})]}),e.jsx(ce,{message:l})]}):e.jsx("div",{className:"notify","data-testid":"notify",children:e.jsx("button",{type:"button",className:"notify__signin",onClick:i,"data-testid":"notify-signin",children:t("notifyMe.signInCta")})})}const Ft=W.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: ${K.colors.accent};
|
|
14
|
+
font-family: ${K.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 ${K.colors.accent};
|
|
30
|
+
outline-offset: 2px;
|
|
31
|
+
}
|
|
32
|
+
`;function Lt({item:s}){return e.jsx(Xe,{block:!0,content:t("makeOffer.comingSoon"),onShow:()=>D("Shop Make Offer Tooltip Shown",{contractAddress:s.contractAddress,itemId:s.itemId}),children:e.jsxs(Ft,{type:"button","aria-disabled":!0,onClick:n=>n.preventDefault(),"data-testid":"make-offer",children:[e.jsx(T,{name:"offer",size:20,"aria-hidden":!0}),e.jsx("span",{children:t("makeOffer.cta")})]})})}const Tt=W(Ea)`
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
gap: 1px;
|
|
37
|
+
background: ${K.colors.lineStrong};
|
|
38
|
+
`;function Dt({contractAddress:s,name:n,items:i,className:o}){const m=oe();if(!s||!n)return null;const h=(i??[]).map(c=>c.thumbnail).filter(c=>!!c).slice(0,4),w=h.slice(0,2),x=h.slice(2,4);return e.jsxs(Fa,{as:"button","data-link":!0,className:o,"data-testid":"creator",onClick:c=>{c.stopPropagation(),m(`/collection/${s}`)},children:[h.length>0?e.jsxs(Tt,{as:"span","data-avatar":!0,"data-testid":"creator-ava","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${x.length===0?" collection-collage__row--full":""}`,children:w.map((c,l)=>e.jsx("img",{src:c,alt:""},l))}),x.length>0?e.jsx("span",{className:"collection-collage__row",children:x.map((c,l)=>e.jsx("img",{src:c,alt:""},l))}):null]}):null,e.jsx(La,{"data-testid":"creator-name",children:Ta(n)})]})}const Rt=W(z)`
|
|
39
|
+
margin-top: 6px;
|
|
40
|
+
`,le=W(z)`
|
|
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
|
+
${K.media.down("lg")} {
|
|
54
|
+
.item-detail__ctas--dual && {
|
|
55
|
+
flex: 1 1 auto;
|
|
56
|
+
width: auto;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,qt=W("div")`
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
gap: 10px;
|
|
63
|
+
width: 100%;
|
|
64
|
+
`,Bt=W(z)`
|
|
65
|
+
&& {
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 44px;
|
|
68
|
+
}
|
|
69
|
+
`,$t=W("p")`
|
|
70
|
+
margin: 4px 0 0;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
color: ${K.colors.muted};
|
|
73
|
+
|
|
74
|
+
a {
|
|
75
|
+
color: ${K.colors.accent};
|
|
76
|
+
font-weight: 600;
|
|
77
|
+
}
|
|
78
|
+
`;function Ot(s){return Object.values(G.Rarity).includes(s)}function zt(s){return s==="male"?t("itemDetail.genderMale"):s==="female"?t("itemDetail.genderFemale"):s==="unisex"?t("itemDetail.genderUnisex"):null}function He(s){return s.wearableCategory?s.wearableCategory.replace(/_/g," "):s.category==="emote"?t("itemDetail.categoryEmote"):t("itemDetail.categoryWearable")}function ps(){var $e;const{contractAddress:s,tokenId:n}=pa(),{state:i}=ya(),o=oe(),m=!!(i!=null&&i.market),h=(i==null?void 0:i.marketPriceCredits)??null,w=ze(r=>r.add),x=ze(r=>r.items),c=Ke(r=>r.toggle),{session:l}=X(),[a,j]=d.useState(()=>i!=null&&i.item?{...i.item,tradeId:i.tradeId??i.item.tradeId}:{id:`${s}-${n}`,name:"",creator:"",contractAddress:s??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:Ne.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:n??void 0,tradeId:i==null?void 0:i.tradeId}),[y,N]=d.useState(!1),[F,b]=d.useState(!!(i!=null&&i.resumeBuy));d.useEffect(()=>{i!=null&&i.resumeBuy&&N(!0)},[i==null?void 0:i.resumeBuy]);const{data:f=[],isFetched:g}=B({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>Ha(a.contractAddress,{first:20}).then(r=>r.items)}),I=a.available==null&&!a.tokenId,{data:M,isLoading:ee}=B({queryKey:["shop-item",a.contractAddress,n],enabled:!m&&!!a.contractAddress&&!!n&&(!(i!=null&&i.item)||I),queryFn:()=>Ja(a.contractAddress,n)});d.useEffect(()=>{M&&j(r=>r.tradeId?r.available!=null&&r.wearableCategory?r:{...r,available:r.available??M.available,wearableCategory:r.wearableCategory??M.wearableCategory}:{...M})},[M]);const[H,me]=d.useState(!1),{data:$=""}=B({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>Ya(a.contractAddress,a.itemId)}),{data:L}=B({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>Xa(a.contractAddress)});d.useEffect(()=>{if(a.name||M||f.length===0)return;const r=n&&f.find(k=>k.tokenId===n||k.itemId===n)||f.find(k=>k.contractAddress===a.contractAddress);r&&j(k=>({...r,tradeId:k.tradeId??r.tradeId}))},[f,M]);const ae=d.useMemo(()=>{const r=new Set,k=[];for(const P of f){if(P.id===a.id||a.itemId&&P.itemId===a.itemId||a.tokenId&&P.tokenId===a.tokenId)continue;const Oe=`${P.contractAddress}-${P.itemId??P.tokenId??P.id}`;r.has(Oe)||(r.add(Oe),k.push(P))}return k},[f,a.id,a.itemId,a.tokenId]),{data:te,isLoading:u}=B({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 r=await Za(a.contractAddress,a.itemId);return(r==null?void 0:r.id)??null}return null}}),C=a.tradeId??te??void 0,_=!!C,{data:S}=jt(m),v=d.useMemo(()=>{if(!m||!(i!=null&&i.item))return null;const r=i.item;return r.manaWei?{tradeId:r.tradeId??r.id,listingType:"primary",contractAddress:r.contractAddress,itemId:r.itemId??"",name:r.name,thumbnail:r.thumbnail,rarity:r.rarity,category:r.category,wearableCategory:r.wearableCategory??null,creator:r.creator,manaWei:r.manaWei,available:1,network:r.network,chainId:r.chainId,createdAt:0}:null},[m,i==null?void 0:i.item]),R=m&&h!=null&&!!S&&!!v,V=Da({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),A=d.useMemo(()=>({...a,tradeId:C,id:C??a.id}),[a,C]),J=x.some(r=>r.id===A.id),O=!A.tokenId,se=(($e=x.find(r=>r.id===A.id))==null?void 0:$e.quantity)??0,Q=O&&typeof a.available=="number"&&se>=a.available,q=Ke(r=>!!r.items[a.id]),we=d.useRef(null);d.useEffect(()=>{!a.name||u||we.current===a.id||(we.current=a.id,D("Shop Viewed Item",{...Ra(a),for_sale:_}),qa(a))},[a.id,a.name,u,_]);const ie=`${s}/${n}`,ke=d.useRef(ie);d.useEffect(()=>{ke.current!==ie&&(ke.current=ie,i!=null&&i.item&&j({...i.item,tradeId:i.tradeId??i.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[ie]);function ea(){!_||he||u||!O&&J||Q||w(A,"item_detail")}const ue=Ot(a.rarity)?a.rarity:G.Rarity.COMMON,Ie=zt(a.gender),Ce=Ba(a),Se=$a(a.gender),aa=_&&V,ta=t("itemDetail.moreFromCollection"),he=Oa(a,l==null?void 0:l.address),re=ve(),[sa,Ae]=d.useState(!1),[ia,Me]=d.useState(!1),[Y,Pe]=d.useState(!1),[ra,Ee]=d.useState(null),{data:p,isLoading:na}=B({queryKey:["owned-token",a.contractAddress,a.tokenId,l==null?void 0:l.address],enabled:!m&&!!(l!=null&&l.address)&&!!a.contractAddress&&!!a.tokenId,queryFn:()=>l?et(l.address,a.contractAddress,a.tokenId):null});d.useEffect(()=>{p&&j(r=>r.name?r.issuedId?r:{...r,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:_e}=B({queryKey:["publishable-item",a.contractAddress,a.itemId,l==null?void 0:l.address],enabled:he&&!!l&&!!a.itemId,queryFn:async()=>l?(await st(l.address,l.identity)).find(k=>k.contractAddress.toLowerCase()===a.contractAddress.toLowerCase()&&k.blockchainItemId===a.itemId)??null:null}),U=!!p,pe=!m&&(he||U),la=U?!!(p!=null&&p.isOnSale):_,ye=U?p==null?void 0:p.tradeId:C,Fe=U?!!p:!!_e;async function Le(){await Promise.all([re.invalidateQueries({queryKey:["owned-token",a.contractAddress,a.tokenId]}),re.invalidateQueries({queryKey:["detail-trade"]}),re.invalidateQueries({queryKey:["shop-item"]}),re.invalidateQueries({queryKey:["collection-sale-state"]})])}async function Te(r={}){if(!l||!ye)return!1;Ee(null),Pe(!0);try{const k=await Ga(ye);return await at({trade:k,signer:l.signer}),r.silent||Je.success(t("myAssets.removedFromSale",{name:a.name})),await Le(),!0}catch(k){const P=yt(k);return P||Z(k,{flow:"remove-listing",tradeId:ye}),Ee(P?t("getCredits.errorCanceled"):t("myAssets.removeListingError")),!1}finally{Pe(!1)}}function De(){U?Ae(!0):Me(!0)}async function da(){await Te({silent:!0})&&De()}function Re(){Ae(!1),Me(!1),Le()}const qe=_?u?t("itemDetail.checking"):Q?t("itemDetail.maxInCart"):!O&&J?t("assetCard.inCart"):t("assetCard.addToCart"):t("itemDetail.notForSale"),oa=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!m,ca=!m&&!a.tokenId&&a.available===0,ma=!pe&&_&&!m,ua=m||!pe,ha=ee||!!a.contractAddress&&!g||!a.name&&na,Be=!a.name&&!ha,_a=/^https?:\/\//i.test(a.thumbnail);return za(Be?{title:t("seo.item.notFoundTitle"),noindex:!0}:a.name?{title:a.name,description:$||t("seo.item.fallbackDescription",{name:a.name,rarity:a.rarity,category:He(a),creator:Nt(a.creator)}),image:_a?a.thumbnail:void 0,type:"product"}:{}),Be?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx(T,{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(Rt,{variant:"purple",onClick:()=>o("/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:()=>o("/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(At,{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${q?" is-on":""}`,onClick:()=>c(a),"aria-pressed":q,"aria-label":q?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(T,{name:q?"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${q?" is-on":""}`,onClick:()=>c(a),"aria-pressed":q,"aria-label":q?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(T,{name:q?"heart-solid":"heart",size:18})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:Va(ue),color:Wa(ue)},title:Ka(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[Ce?e.jsx(T,{name:Ce,size:18,color:"var(--text-2)"}):null,He(a)]}),Ie?e.jsxs("span",{className:"chip item-detail__chip",children:[Se?e.jsx(T,{name:Se,size:18,color:"var(--text-2)"}):null,Ie]}):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${H?" is-expanded":""}`,children:$}),$.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>me(r=>!r),children:H?t("itemDetail.showLess"):t("itemDetail.readMore")}):null]}):null,a.creator||L!=null&&L.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(Qa,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,L!=null&&L.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(Dt,{contractAddress:a.contractAddress,name:L.name,items:f,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:[m||_?e.jsx("div",{className:"item-detail__price-label",children:t("itemDetail.price")}):null,m?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:h==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(E,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:h})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:t("assetCard.marketPrice")})]}):_?aa?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(E,{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(E,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),We(a.compareAtCredits,a.priceCredits)>0?e.jsx("span",{className:"item-detail__sale-badge",children:t("assetCard.saleWithDiscount",{pct:We(a.compareAtCredits,a.priceCredits)})}):null,e.jsx(Ua,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(E,{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(Xe,{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(T,{name:"info",size:14})})})]})]}),oa?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(),"/",G.Rarity.getMaxSupply(ue).toLocaleString()]})]}):ca?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${ua?" item-detail__ctas--buttons":""}${ma?" item-detail__ctas--dual":""}`,children:m?e.jsxs(le,{variant:"purple",onClick:()=>N(!0),disabled:!R,children:[e.jsx("span",{className:"item-detail__cta-label",children:t("assetCard.buyNow")}),h!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(E,{className:"item-detail__cta-diamond"}),h]}):null]}):pe?e.jsxs(qt,{"data-testid":"manage-actions",children:[e.jsx(ce,{message:ra}),la?e.jsxs(e.Fragment,{children:[e.jsx(le,{variant:"purple",onClick:()=>void da(),disabled:Y||!Fe,children:e.jsx("span",{className:"item-detail__cta-label",children:Y?t("itemDetail.manageWorking"):t("itemDetail.manageUpdatePrice")})}),e.jsx(Bt,{variant:"ghost",onClick:()=>void Te(),disabled:Y,children:Y?t("myAssets.removing"):t("itemDetail.manageRemove")})]}):e.jsx(le,{variant:"purple",onClick:()=>{U&&D("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),De()},disabled:Y||!Fe,children:e.jsx("span",{className:"item-detail__cta-label",children:t("itemDetail.manageList")})}),e.jsxs($t,{children:[t("itemDetail.ownItemPrefix")," ",e.jsx(fa,{to:"/my-assets",children:t("nav.myAssets")}),t("itemDetail.ownItemSuffix")]})]}):_?e.jsxs(e.Fragment,{children:[e.jsxs(le,{variant:"purple",onClick:()=>N(!0),disabled:u,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(E,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}),e.jsxs("button",{className:"item-detail__addcart",onClick:ea,disabled:u||(O?Q:J),"aria-label":qe,children:[e.jsx(T,{name:"cart-solid"}),e.jsx("span",{className:"item-detail__addcart-label",children:qe})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{item:a}),e.jsx(Lt,{item:a})]})})]}):e.jsx(Kt,{})})]}),e.jsx(_t,{title:ta,items:ae,onViewAll:a.contractAddress?()=>o(`/collection/${a.contractAddress}`):void 0}),y&&m&&v&&S?e.jsx(vt,{listing:v,rate:S,onClose:()=>N(!1),onSold:()=>N(!1)}):y&&!m?e.jsx(wt,{item:A,resume:F,onClose:()=>{N(!1),b(!1)}}):null,sa&&p&&l?e.jsx(It,{asset:p,session:l,onClose:Re}):null,ia&&_e&&l?e.jsx(tt,{item:_e,session:l,onClose:Re}):null]})}function Kt(){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{ps as ItemDetail,ps as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as c}from"./react-BrLDncxD.js";import{s as u,B as p,t as d}from"./index-
|
|
1
|
+
import{r as l,j as c}from"./react-BrLDncxD.js";import{s as u,B as p,t as d}from"./index-C1yBaAe9.js";const a=u.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
padding: 28px 0 8px;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{m as O,c as S,d as V,n as Y,o as H,t,q as k,g as x,r as M,v as $,C as j,f as D,i as J,w as X,x as p,y as F,z as R,s as Z,B as ee}from"./index-C1yBaAe9.js";import{r as re,a as b}from"./mana-rate-CQNKlfL0.js";import{a as ae,r as m,j as r}from"./react-BrLDncxD.js";import{b as A}from"./buy-CNc4Y8CN.js";import{g as te,b as se,w as ie,S as ce,G as ne}from"./buy-gasless-wrR0AjfW.js";import{i as de}from"./errors-gKUnErEU.js";import{E as oe}from"./ErrorNotice-BDH9xoG4.js";function pe(e=!0){return O({queryKey:["mana-rate",S.chainId],queryFn:()=>re(S.chainId),enabled:e,staleTime:6e4,refetchInterval:6e4,retry:1})}const B=Z(ee)`
|
|
2
|
+
flex: 1;
|
|
3
|
+
`;function U(e){if(de(e))return t("errors.rejected");const n=(e.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 le(e){return{id:e.tradeId,tradeId:e.tradeId,name:e.name,creator:e.creator,contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,wearableCategory:e.wearableCategory??void 0,rarity:e.rarity,network:e.network,chainId:e.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function Ce({listing:e,rate:n,onClose:q,onSold:W}){const{session:i}=V(),{data:d,isError:T}=Y(i),w=H(),g=ae(),[N,f]=m.useState("confirm"),[C,I]=m.useState(t("marketCheckout.lockingPrice")),[z,_]=m.useState(null),[a,G]=m.useState(null),o=m.useRef(null),L=Math.ceil(b(e.manaWei,n)/10);m.useEffect(()=>{let l=!1;if(!i){f("error"),_(t("buyModal.signInToCheckout"));return}return(async()=>{try{const s=await D(e.tradeId);if(!s)throw new Error("not found");if(J(s,i.address))throw new Error("You can't buy your own listing.");const h=b(e.manaWei,n);if(!Number.isFinite(h)||h<=0)throw new Error("price unavailable");const{credit:u,maxCreditedValue:K,usdCents:P}=await X(i.identity,h,e.tradeId);if(l){k(i.identity,[u.id]).catch(()=>{});return}o.current=u.id,G({trade:s,credit:u,maxCreditedValue:K,usdCents:P,credits:Math.ceil(P/10)}),I("")}catch(s){if(l)return;console.error("[market] authorize failed",s),p(R(s)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:F(s),value_usd:Math.round(b(e.manaWei,n))/100}),f("error"),_(U(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 Q(){if(!i||!a)return;if(v){p("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{I(t("marketCheckout.confirming"));const c={trade:a.trade,buyer:i.address,signer:i.signer,credits:[a.credit],maxCreditedValue:a.maxCreditedValue};let s;if(te())try{s=await se(c),await ie(s),l=!0}catch(u){if(u instanceof ce)l=!0;else if(u instanceof ne)s=await A(c);else throw u}else s=await A(c);o.current=null,p("Shop Completed Purchase",{items:[{item_id:e.itemId??null,contract_address:e.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:[le(e)],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,p(R(c)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:F(c),value_usd:a.usdCents/100}),w.invalidateQueries({queryKey:["usd-balance"]}),_(U(c)),f("error");const s=(c.message??"").toLowerCase();(s.includes("not found")||s.includes("no active listing")||s.includes("404"))&&W()}}function E(){i&&a&&k(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,q()}const y=N==="working";return r.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:e.name}),children:[r.jsx("div",{className:"mkt-modal__scrim",onClick:y?void 0:E,"aria-hidden":!0}),r.jsxs("div",{className:"mkt-modal__card",children:[r.jsxs("div",{className:"mkt-modal__head",children:[r.jsx("div",{className:"mkt-modal__thumb",children:e.thumbnail?r.jsx("img",{src:e.thumbnail,alt:""}):null}),r.jsxs("div",{children:[r.jsx("div",{className:"mkt-modal__name",title:e.name,children:e.name||t("buyModal.itemFallback")}),r.jsx("span",{className:"chip chip--rarity",children:e.rarity})]})]}),r.jsx("div",{className:"mkt-modal__price",children:a?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.finalPrice")}),r.jsxs("div",{className:"mkt-modal__price-value",children:[r.jsx(x,{className:"mkt-modal__diamond"}),M(a.credits)]}),r.jsxs("div",{className:"mkt-modal__price-sub muted",children:[t("marketCheckout.lockedForPurchase")," · $",(a.usdCents/100).toFixed(2)]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.todaysPrice")}),r.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[r.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),r.jsx(x,{className:"mkt-modal__diamond"}),M(L)]}),r.jsx("div",{className:"mkt-modal__price-sub muted",children:C||t("marketCheckout.lockingPrice")})]})}),i?r.jsxs("div",{className:"mkt-modal__balance muted",children:[t("marketCheckout.yourBalance")," ",r.jsx(x,{className:"ccy-mark"})," ",$(d,T)]}):null,v?r.jsx("p",{className:"muted mkt-modal__note",children:t("marketCheckout.needMore",{currency:j.name})}):null,C&&N==="working"?r.jsx("p",{className:"muted mkt-modal__note",children:C}):null,r.jsx(oe,{message:z,className:"mkt-modal__note"}),r.jsxs("div",{className:"mkt-modal__actions",children:[r.jsx(B,{variant:"ghost",onClick:E,disabled:y,children:t("buyModal.cancel")}),r.jsx(B,{variant:"purple",onClick:()=>void Q(),disabled:y||!a,children:y?t("marketCheckout.buying"):v?t("nav.getCredits",{currency:j.name}):t("marketCheckout.confirmPurchase")})]})]})]})}export{Ce as M,pe as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as Se,b as Ye,r as d,j as t}from"./react-BrLDncxD.js";import{s as a,F as s,I as j,u as Je,t as r,d as Ve,o as Ze,G as le,m as M,B as Xe,A as q,x as et,H as tt,f as st,J as ot,E as nt,c as je,K as rt}from"./index-
|
|
1
|
+
import{L as Se,b as Ye,r as d,j as t}from"./react-BrLDncxD.js";import{s as a,F as s,I as j,u as Je,t as r,d as Ve,o as Ze,G as le,m as M,B as Xe,A as q,x as et,H as tt,f as st,J as ot,E as nt,c as je,K as rt}from"./index-C1yBaAe9.js";import{f as at}from"./import-C4A0dOmT.js";import{P as it,f as lt}from"./PrimaryListModal-Bfe2jEqA.js";import{c as ct}from"./buy-CNc4Y8CN.js";import{R as G,C as dt,a as mt,F as pt,S as D,b as ce}from"./categories-BKqMpg3a.js";import{L as ut}from"./LoadMore-wolzH5ER.js";import{D as de,F as me,R as ft,a as xt,b as ht,c as yt,d as gt,S as bt,e as wt,f as St,g as jt,h as $t,i as Ct,j as It,k as kt,C as vt,l as At,m as Et,n as Tt,M as Ft}from"./Assets.styles-BldKbSnl.js";import{u as Rt}from"./useInfiniteGrid-CRDFn4if.js";import{E as U}from"./ErrorNotice-BDH9xoG4.js";import{n as $e}from"./emotion-CSxEP8yM.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";import"./mana-rate-CQNKlfL0.js";import"./index-HN6Rk25C.js";import"./trade-encoding-DQ3zNCj8.js";import"./authorizations-ChRb35xG.js";import"./errors-gKUnErEU.js";import"./Tooltip-BtGlCRjR.js";a.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-BrLDncxD.js";import{u as c,t,a 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-BrLDncxD.js";import{u as c,t,a as l,I as d,A as p,s as v,B as x}from"./index-C1yBaAe9.js";import{L as u}from"./LoadMore-wolzH5ER.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";const h=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(h,{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(u,{hasNextPage:i<a.length,isFetching:!1,onLoadMore:()=>o(e=>e+r)})]})}export{E as MyFavorites};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,
|
|
1
|
+
import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,M as k,u as $,t as d,d as v,I as x,a6 as I,g as j,m as P,a7 as L}from"./index-C1yBaAe9.js";import{L as N}from"./LoadMore-wolzH5ER.js";import{u as E}from"./useInfiniteGrid-CRDFn4if.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";const T=15e3;function C(t,n){return t.txHash&&n.txHash?t.txHash===n.txHash:t.txHash||n.txHash?!1:t.status===n.status&&Math.abs(t.createdAt-n.createdAt)<=T}function D(t){const n=[...t].sort((s,o)=>o.createdAt-s.createdAt),a=[];for(const s of n){const o=a[a.length-1];o&&C(o[o.length-1],s)?o.push(s):a.push([s])}return a.map(s=>{var o;return{id:((o=s.find(c=>c.txHash))==null?void 0:o.txHash)??s[s.length-1].id,createdAt:Math.max(...s.map(c=>c.createdAt)),status:s.some(c=>c.status==="PENDING")?"PENDING":"SETTLED",totalCredits:s.reduce((c,u)=>c+u.credits,0),lines:s}})}function H(t){const n=[],a=new Map;for(const s of t)if(s.tradeId){const o=a.get(s.tradeId);if(o){o.quantity+=1,o.credits+=s.credits;continue}const c={key:s.tradeId,tradeId:s.tradeId,quantity:1,credits:s.credits};a.set(s.tradeId,c),n.push(c)}else n.push({key:s.id,tradeId:null,quantity:1,credits:s.credits});return n}const m=k`
|
|
2
2
|
0% { background-position: 200% 0; }
|
|
3
3
|
100% { background-position: -200% 0; }
|
|
4
4
|
`,z=i.section`
|
|
@@ -15,12 +15,12 @@ import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,N as
|
|
|
15
15
|
`,q=i.span`
|
|
16
16
|
color: ${r.colors.muted};
|
|
17
17
|
font-size: 14px;
|
|
18
|
-
`,
|
|
18
|
+
`,M=i.div`
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-direction: column;
|
|
21
21
|
gap: 16px;
|
|
22
22
|
max-width: 760px;
|
|
23
|
-
`,
|
|
23
|
+
`,F=i.div`
|
|
24
24
|
background: ${r.colors.white};
|
|
25
25
|
border: 1px solid ${r.colors.line};
|
|
26
26
|
border-radius: 16px;
|
|
@@ -197,4 +197,4 @@ import{j as e,L as y}from"./react-BrLDncxD.js";import{s as i,B as w,F as r,N as
|
|
|
197
197
|
margin: 6px 0 0;
|
|
198
198
|
`,te=i(w)`
|
|
199
199
|
margin-top: 12px;
|
|
200
|
-
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(
|
|
200
|
+
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(F,{"data-testid":"purchase-order",children:[e.jsxs(G,{children:[e.jsxs(O,{children:[e.jsx(B,{children:re(t.createdAt)}),e.jsx(R,{children:d("myPurchases.itemCount",{count:a})})]}),e.jsxs(W,{children:[e.jsx(_,{"data-status":t.status,children:t.status==="PENDING"?d("myPurchases.processing"):d("myPurchases.completed")}),e.jsxs(U,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(K,{children:n.map(s=>e.jsx(ie,{item:s},s.key))})]})}function he(){$({title:d("nav.myPurchases"),noindex:!0});const{session:t}=v(),{items:n,isLoading:a,hasNextPage:s,isFetchingNextPage:o,fetchNextPage:c}=E(["purchases",t==null?void 0:t.address],l=>I(t.address,t.identity,{first:se,skip:l}),{enabled:!!t});if(!t)return e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.signInTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.signInBody")})]});const u=D(n.filter(l=>l.status!=="EXPIRED"));return!a&&u.length===0?e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.emptyTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.emptyBody")}),e.jsx(te,{as:y,to:"/assets",variant:"purple",children:d("notFound.cta")})]}):e.jsxs(z,{children:[e.jsxs(A,{children:[e.jsx(S,{children:d("nav.myPurchases")}),a?null:e.jsx(q,{children:d("myPurchases.orderCount",{count:u.length})})]}),e.jsx(M,{children:a?Array.from({length:3}).map((l,p)=>e.jsx(h,{},p)):e.jsxs(e.Fragment,{children:[u.map(l=>e.jsx(oe,{order:l},l.id)),o?e.jsx(h,{}):null]})}),e.jsx(N,{hasNextPage:s,isFetching:o,onLoadMore:()=>void c()})]})}export{he as MyPurchases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-BrLDncxD.js";import{u as s,t as o,I as e,B as a}from"./index-
|
|
1
|
+
import{j as t,L as n}from"./react-BrLDncxD.js";import{u as s,t as o,I as e,B as a}from"./index-C1yBaAe9.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.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{c as A,L as O,o as U,e as B,t as a,
|
|
1
|
+
import{c as A,L as O,o as U,e as B,t as a,g as F,B as _,C as v,p as Q,x as k,J as q,E as W,y as D}from"./index-C1yBaAe9.js";import{d as w}from"./dcl-schemas-BICTSpB5.js";import{a as G,r as m,j as s}from"./react-BrLDncxD.js";import{i as J,e as K,c as H}from"./trade-encoding-DQ3zNCj8.js";import{f as V}from"./errors-gKUnErEU.js";import{E as X}from"./ErrorNotice-BDH9xoG4.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 g=l.rarity??"common",h=Number(l.total_supply??0)||0;let o;try{o=w.Rarity.getMaxSupply(g)}catch{o=0}const b=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:b,blockchainItemId:p,name:l.name,category:z(l),rarity:g,thumbnail:await ee(l,b,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:h,maxSupply:o,remainingSupply:Y(h,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,g]=m.useState("10"),[h,o]=m.useState(null),[b,p]=m.useState(null),[d,L]=m.useState(!1),[y,j]=m.useState(null),[C,$]=m.useState(null),x=A.chainId,S=B(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{y||(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 Q(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"):y===!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(F,{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=>g(c.target.value),disabled:d})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:v.name,currencySingular:v.nameSingular})}),y===!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})}):y===!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,h?s.jsx("p",{className:"muted",children:h}):null,s.jsx(X,{message:b}),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||y===null,children:y===null?a("primaryList.checking"):R})]})]})})}export{me as P,ue as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F as C,s as _,
|
|
1
|
+
import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F as C,s as _,M as ae,u as ie,d as re,o as ne,I as E,B as F,J as M}from"./index-C1yBaAe9.js";import{u as oe,d as le,t as ce,L as de,i as R,a as v,s as me}from"./useStore-DjC0Mzyl.js";import{E as B}from"./ErrorNotice-BDH9xoG4.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-29944279663.commit-001b5a7/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-29944279663.commit-001b5a7/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
|
}
|
|
@@ -50,4 +50,4 @@ import{j as s,a as se,r as n,L as te}from"./react-BrLDncxD.js";import{t as a,F a
|
|
|
50
50
|
align-self: center;
|
|
51
51
|
min-width: 200px;
|
|
52
52
|
margin-top: 8px;
|
|
53
|
-
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:P}=oe(c),[r,m]=n.useState(A),[L,y]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[f,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),y(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=h.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?h.find(l=>f[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,f]);n.useEffect(()=>{o!=null&&o.hash&&h.some(e=>f[e.name]===o.hash)&&N(null)},[f,o]);const I=k!==void 0&&k>O,Y=n.useMemo(()=>de.filter(e=>!
|
|
53
|
+
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:P}=oe(c),[r,m]=n.useState(A),[L,y]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[f,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),y(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=h.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?h.find(l=>f[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,f]);n.useEffect(()=>{o!=null&&o.hash&&h.some(e=>f[e.name]===o.hash)&&N(null)},[f,o]);const I=k!==void 0&&k>O,Y=n.useMemo(()=>de.filter(e=>!R(e,r.links[e])),[r.links]),J=I||Y.length>0,w=n.useMemo(()=>JSON.stringify(r)!==JSON.stringify(L),[r,L]),K=w&&!J&&!g;if(n.useEffect(()=>{if(!w)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[w]),!i)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx(be,{variant:"purple",onClick:d,children:a("storeSettings.signIn")})]});function q(e,t){p(void 0),m(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const G=["image/png","image/jpeg","image/webp"];function Q(e){var H;const t=(H=e.target.files)==null?void 0:H[0];if(!t||!G.includes(t.type))return;p(t.size);const l=`cover/${t.name}`,u=new FileReader;u.onload=()=>{const T=u.result;N({url:T,name:l,hash:""}),m(ee=>({...ee,cover:T,coverName:l,coverHash:""}))},u.readAsDataURL(t)}function U(){o&&(p(void 0),m(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function W(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";m(u=>({...u,links:{...u.links,[e]:l}}))}function X(e){const t=r.links[e];return e==="website"?t:t.replace(v[e],"")}async function Z(){if(!(!c||!i)){$(!0);try{await me(c,r,i.identity),y(r),p(void 0),await j.invalidateQueries({queryKey:["store",c.toLowerCase()]}),M.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{M.error(a("storeSettings.saveError"))}finally{$(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(te,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx(E,{name:"arrow-left"})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx(E,{name:"external-link"})]}):null]}),P?s.jsx(_e,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[h.map(e=>{const t=x===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"data-testid":"cover-picker-tile","data-selected":t,"aria-pressed":t,onClick:()=>q(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${x?"":" is-selected"}`,"data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!x,"aria-pressed":!x,onClick:U,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=z.current)==null?void 0:e.click()},children:[s.jsx(E,{name:"upload"}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:z,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input","data-testid":"cover-picker-input",onChange:Q})]}),I?s.jsx(B,{message:a("storeSettings.sizeError",{max:D(O),current:D(k)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:r.description,rows:4,disabled:g,onChange:e=>m(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:r.links.website,placeholder:v.website,disabled:g,onChange:e=>m(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),R("website",r.links.website)?null:s.jsx(B,{message:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:X(e),disabled:g,onChange:t=>W(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx(F,{variant:"purple",className:"store-settings__save","data-testid":"store-settings-save",onClick:()=>void Z(),disabled:!K,children:g?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ye as StoreSettings,ye as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{u as v,a as k,j as s,N as w,r as p}from"./react-BrLDncxD.js";import{d as y,u as b,t as e,e as C,g as f,h as A,j as S,c as g,s as B,B as I,k as L,C as E}from"./index-C1yBaAe9.js";import{w as T,S as M}from"./buy-gasless-wrR0AjfW.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DYZXk5O5.js";import"./ethers-CLB2z3On.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-DQ3zNCj8.js";import"./authorizations-ChRb35xG.js";import"./index-HN6Rk25C.js";const j=B(I)`
|
|
2
|
+
min-width: 160px;
|
|
3
|
+
text-align: center;
|
|
4
|
+
`,P=c=>new Promise(t=>setTimeout(t,c));function F(c,t){const[a,r]=p.useState(c?"pending":"confirmed"),m=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return p.useEffect(()=>{if(!c)return;let i=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!i;n++)try{await T(c,{timeoutMs:15e3}),h=!0;break}catch(d){if(d instanceof M)continue;i||r("failed");return}if(!i){if(!h){r("timed-out");return}if(!t){r("confirmed");return}r("indexing");for(let n=0;n<40&&!i;n++){if(await L(t.owner,t.contractAddress,t.itemId)){i||r("confirmed");return}await P(3e3)}i||r("timed-out")}})(),()=>{i=!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 Q(){const{state:c}=v(),t=k(),{session:a}=y(),r=c==null?void 0:c.txHash,m=(c==null?void 0:c.items)??[],i=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=F(c!=null&&c.settled?void 0:r,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=!!r&&C(a==null?void 0:a.providerType)?s.jsx("a",{className:"success__receipt",href:`${W}${r}`,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("/my-purchases"),children:e("nav.myPurchases")})," ",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("/my-purchases"),children:e("success.viewMyPurchases")}),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:[i?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:i,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{Q as Success,Q 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-WHc1zToo.js";import{au as C}from"./NetworkUtil-BGlQiKvg.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-BFTt2bWv.js";import{au as C}from"./NetworkUtil-BGlQiKvg.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-BrLDncxD.js";import{s as d,F as r}from"./index-
|
|
1
|
+
import{r as e,j as c}from"./react-BrLDncxD.js";import{s as d,F as r}from"./index-C1yBaAe9.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 Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-CLB2z3On.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BrLDncxD.js";import{b6 as Ne}from"./index-Q9d0V8TZ.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-D7J0TuHz.js";import"./sentry-DYZXk5O5.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|
|
1
|
+
var Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-CLB2z3On.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BrLDncxD.js";import{b6 as Ne}from"./index-C1yBaAe9.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-DbySRbMy.js";import"./sentry-DYZXk5O5.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|