@dcl/shop 0.1.0-30027061548.commit-0bc806a → 0.1.0-30043904010.commit-d846220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{Activity-BCuWHO91.js → Activity-CfoMiprq.js} +1 -1
- package/assets/{AnimatedBackground-DC0qsES6.js → AnimatedBackground-CTAvRdMs.js} +3 -3
- package/assets/{Assets-pZ95iGr4.js → Assets-DKNqWFtf.js} +5 -5
- package/assets/{Assets.styles-sDGY0dtk.js → Assets.styles-C6sIyjWO.js} +1 -1
- package/assets/{Authorizations-D6SkMmO6.js → Authorizations-Cfrn9UvQ.js} +1 -1
- package/assets/Cart-hpLb5BKF.js +3 -0
- package/assets/{CircularProgress-DOGiHaMT.js → CircularProgress-AupKGvsC.js} +1 -1
- package/assets/{Collection-DDSnUzQQ.js → Collection-_--unMIu.js} +1 -1
- package/assets/{CollectionCarousel-DzxyaCUo.js → CollectionCarousel-Cv3IS7v1.js} +1 -1
- package/assets/{Creator-D7vQevDn.js → Creator-BLLEhqDI.js} +1 -1
- package/assets/{CssVarsProvider-CADqtr6A.js → CssVarsProvider-C2bobZqX.js} +1 -1
- package/assets/{ExchangeController-Bv8csw6N.js → ExchangeController-DvIeDCUh.js} +1 -1
- package/assets/{GetCredits-Bb1FBUnx.js → GetCredits-CrWYBrln.js} +1 -1
- package/assets/{HelpersUtil-DV71mRBd.js → HelpersUtil-bC5DgR2K.js} +1 -1
- package/assets/ImportListings-wr3inb3D.js +5 -0
- package/assets/ItemDetail-BvNr-Bqr.js +82 -0
- package/assets/{LoadMore-CYDgHq9T.js → LoadMore-DieY8n7S.js} +1 -1
- package/assets/MarketCheckout-DtRw4jJL.js +3 -0
- package/assets/{MyAssets-CJ2H2U_U.js → MyAssets-C6jy4dd6.js} +1 -1
- package/assets/{MyFavorites-k4qOTRob.js → MyFavorites-PW6_jnXn.js} +1 -1
- package/assets/{NotFound-aR1LWKr4.js → NotFound-D9VSYE79.js} +1 -1
- package/assets/{PrimaryListModal-CU6tMA9w.js → PrimaryListModal-C6oCKlmk.js} +1 -1
- package/assets/{StoreSettings-6hNLQCtE.js → StoreSettings-DVbEeImF.js} +1 -1
- package/assets/{Success-Bry0ia79.js → Success-ByU0zgv0.js} +1 -1
- package/assets/{SwapController-DydmZAYL.js → SwapController-D4uDIpKL.js} +1 -1
- package/assets/{Tooltip-BQaA68Ov.js → Tooltip-C07IWHCJ.js} +1 -1
- package/assets/{TradeService-Cfj8wGt2.js → TradeService-ZEtpgAIl.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-Dr_zn2DE.js → W3MFrameProviderSingleton-D1LJTB8Q.js} +3 -3
- package/assets/{WebCryptoP256-BMUdEkV-.js → WebCryptoP256-cR4KAhPY.js} +1 -1
- package/assets/{authorizations-hpO8fum7.js → authorizations-BV0VRJbP.js} +1 -1
- package/assets/{basic-C_Wg1mVs.js → basic-BEKOM15_.js} +1 -1
- package/assets/{biconomy-DmK7CFsI.js → biconomy-Hs2VYfbY.js} +1 -1
- package/assets/buy-BAwpkHiu.js +1 -0
- package/assets/{buy-gasless-B42KlhKm.js → buy-gasless-CBgDMk_P.js} +1 -1
- package/assets/{cart-checkout-dGSJDcok.js → cart-checkout-b6rH0J-R.js} +1 -1
- package/assets/{categories-DYBZdOix.js → categories-B6F31f63.js} +1 -1
- package/assets/{ccip-z11itrqC.js → ccip-BazdBgUW.js} +1 -1
- package/assets/{ccip-BWCHUagC.js → ccip-QXtL5Uvm.js} +1 -1
- package/assets/collection-GFSR-DkZ.js +1 -0
- package/assets/{controller-CXLN2aGp.js → controller-CV-bZG0x.js} +2 -2
- package/assets/{core-Ce5Cv-b6.js → core-DFrvWji_.js} +4 -4
- package/assets/{custom-BCRtfLyJ.js → custom-ugD8uQsl.js} +1 -1
- package/assets/{data-capture-BeQAS4k1.js → data-capture-0PjpdLt0.js} +1 -1
- package/assets/{email-C8h6eN4d.js → email-BtCYSHvy.js} +1 -1
- package/assets/{embedded-wallet-CEhxSKK2.js → embedded-wallet-7Uo9CVv4.js} +1 -1
- package/assets/{emotion-styled.browser.esm-Cv8bwtal.js → emotion-styled.browser.esm-DTAoSEBg.js} +1 -1
- package/assets/{engine-C2jGP36P.js → engine-2nF1fHP_.js} +1 -1
- package/assets/{errors-mn3Jxf9K.js → errors-C3ieTqjz.js} +1 -1
- package/assets/{estimate-l1-fee-DjKIEdlm.js → estimate-l1-fee-p4EH5xmb.js} +1 -1
- package/assets/{execute-hmQGMl_0.js → execute-BxX9DUWM.js} +2 -2
- package/assets/{features-BqKMRUjh.js → features-DIhQ0-RV.js} +1 -1
- package/assets/{fetchTokenMetadata-CN6a-XR3.js → fetchTokenMetadata-BdBaS0bS.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-D5Ve2RAN.js → get-ecosystem-wallet-info-Ixv-HVXj.js} +1 -1
- package/assets/{getBalance-CIHv6Ou3.js → getBalance-CNSH7nNU.js} +1 -1
- package/assets/{getNFT-vEpMPd9f.js → getNFT-C9LYC3Yd.js} +1 -1
- package/assets/{getNFT-BMvLAFAo.js → getNFT-Ck9nGmAZ.js} +1 -1
- package/assets/{getOverlayAlpha-BErwje5c.js → getOverlayAlpha-B3r4B2PY.js} +1 -1
- package/assets/{hashTypedData-Bl2zyfR4.js → hashTypedData-C6uREFRJ.js} +1 -1
- package/assets/{hashTypedData-CK9AJY67.js → hashTypedData-cHIrBNYx.js} +1 -1
- package/assets/{import-C0RJ-3QV.js → import-CAQj-dM2.js} +1 -1
- package/assets/{in-app-CrTDVNmP.js → in-app-DPM7SMxi.js} +1 -1
- package/assets/{in-app-wallet-calls-CJL2Yhit.js → in-app-wallet-calls-DZ-hTUOJ.js} +1 -1
- package/assets/{index-DqCsDhcz.js → index-B293q--y.js} +2 -2
- package/assets/{index-DLupDBmN.js → index-B2UfRPZr.js} +1 -1
- package/assets/{index-Jidvms5_.js → index-BDGft3Ii.js} +1 -1
- package/assets/{index-_0Gh2fQd.js → index-BDaUM5PE.js} +1 -1
- package/assets/{index-DrFNHDAY.js → index-BEbNl7Da.js} +1 -1
- package/assets/{index-CNDhuv5u.js → index-BEu2er-j.js} +1 -1
- package/assets/{index-ecR6a0PC.js → index-BF6btLnK.js} +1 -1
- package/assets/{index-CDnDtRVW.js → index-BKRJ1I2O.js} +1 -1
- package/assets/{index-CHx84JG-.js → index-BKrZ99aa.js} +1 -1
- package/assets/{index-B9np2brO.js → index-BO2IQVQf.js} +1 -1
- package/assets/{index-BxjlshOa.js → index-BOlb7l4z.js} +1 -1
- package/assets/{index-D0QaZmVm.js → index-BRehhwYQ.js} +1 -1
- package/assets/{index-BvBucB_1.js → index-BSsBrgCk.js} +1 -1
- package/assets/{index-D4BBgkBj.js → index-BVKphh6h.js} +1 -1
- package/assets/{index-D4BoTG2q.js → index-B_L_h5GX.js} +1 -1
- package/assets/{index-8Qfr_JFg.js → index-Bi2gh-XF.js} +1 -1
- package/assets/{index-CtHx80Dm.js → index-Bk2mL-N9.js} +1 -1
- package/assets/{index-gYboUjkz.js → index-BkyeX6HG.js} +2 -2
- package/assets/{index-DgRGh3Se.js → index-BmocOmw9.js} +1 -1
- package/assets/{index-B4Ydy88m.js → index-Bxv9Qsyr.js} +1 -1
- package/assets/{index-DSZZP3M1.js → index-C6iFJkiu.js} +1 -1
- package/assets/{index-CgO8zkp_.js → index-CBAMh7K3.js} +1 -1
- package/assets/{index-BJzkeBev.js → index-CC_Y385a.js} +1 -1
- package/assets/{index-C9prV18i.js → index-CDv8dIJ0.js} +1 -1
- package/assets/{index-B6-POQP9.js → index-CUSJUiTt.js} +2 -2
- package/assets/{index-DhNpGvQj.js → index-CcTJSQPG.js} +1 -1
- package/assets/{index-DiJPgqc6.js → index-ChcRkFvT.js} +1 -1
- package/assets/{index-DqJHvdZG.js → index-CkKBRMeq.js} +1 -1
- package/assets/{index-wkOOo2N2.js → index-CltlnEYp.js} +1 -1
- package/assets/{index-Bo4JK0SO.js → index-CqYj0Wnc.js} +9 -9
- package/assets/{index-BuU78HZX.js → index-Cqdfn5Z9.js} +1 -1
- package/assets/{index-D4V_6GDr.js → index-CtDPYY7l.js} +1 -1
- package/assets/{index-Bm6LbtsY.js → index-CuiEOKUP.js} +1 -1
- package/assets/{index-D9_mfIWw.js → index-CzYTv_op.js} +1 -1
- package/assets/{index-WvBe1s5D.js → index-D59_J0ta.js} +1 -1
- package/assets/{index-CIj608oA.js → index-D7VAdjct.js} +3 -3
- package/assets/{index-DS6U_hzC.js → index-DBzJaULm.js} +1 -1
- package/assets/{index-CHm5r9FR.js → index-DQJvIYh3.js} +1 -1
- package/assets/{index-CNt31eC4.js → index-DQKyfE1B.js} +1 -1
- package/assets/{index-BEEx-7Cb.js → index-DYRw2UXa.js} +3 -3
- package/assets/{index-DvyuSmvc.js → index-DfssMaoW.js} +3 -3
- package/assets/{index-BPOntItp.js → index-Drnt_mRw.js} +1 -1
- package/assets/{index-CI4oaJQ1.js → index-Dt8YtPvX.js} +1 -1
- package/assets/{index-C_9tsDV6.js → index-Dwid47sK.js} +1 -1
- package/assets/{index-BOJsU4RS.js → index-DwvpNwX5.js} +1 -1
- package/assets/{index-BWptpE7W.js → index-IFOSUl9_.js} +1 -1
- package/assets/{index-D3cPEHHs.js → index-XI6S8l3U.js} +1 -1
- package/assets/{index-C0gqts19.js → index-_FP-gMqk.js} +1 -1
- package/assets/{index-BZ1eBgTi.js → index-kWgeWchW.js} +1 -1
- package/assets/{index-BJdAzUAS.js → index-oIexitis.js} +1 -1
- package/assets/{index-DD1DsnNQ.js → index-q_nf0XWN.js} +1 -1
- package/assets/{index-DNR5viu3.js → index-vE7g9-sI.js} +1 -1
- package/assets/{index.es-BC7nWxT1.js → index.es-B5VA0C1k.js} +4 -4
- package/assets/{index.es-CrzorCdt.js → index.es-BBXLQWFt.js} +1 -1
- package/assets/{index.es-Dw3YFOSP.js → index.es-jHzdsCzB.js} +1 -1
- package/assets/{localBatchGatewayRequest-Ck-lCdmi.js → localBatchGatewayRequest-C-l-nAWK.js} +1 -1
- package/assets/{mana-rate-DEX36GMf.js → mana-rate-DO_0nFzU.js} +1 -1
- package/assets/{networks-BmZkrHNT.js → networks-yLF4BK8_.js} +1 -1
- package/assets/{onramp-L0tijLX4.js → onramp-CK5JUJHL.js} +1 -1
- package/assets/{openzeppelin-B94tTaUq.js → openzeppelin-DVJ_Rucz.js} +1 -1
- package/assets/{parseNft-ZhDRvC17.js → parseNft-DocYLo3p.js} +2 -2
- package/assets/{parseSignature-C0-YjUv3.js → parseSignature-60gWPJK1.js} +1 -1
- package/assets/{parseSignature-CrlfHyVq.js → parseSignature-Clt_jMmJ.js} +3 -3
- package/assets/{passkeys-BAFD0eYI.js → passkeys-C7NdQhxe.js} +1 -1
- package/assets/{pay-with-exchange-0uwaepTj.js → pay-with-exchange-DAYzEJE4.js} +1 -1
- package/assets/{qr-overlay-BeL8svzB.js → qr-overlay-DRbms5lD.js} +1 -1
- package/assets/{receive-BuQ4aE9M.js → receive-BlKHI8-v.js} +1 -1
- package/assets/{resolveImplementation-CACZz-iG.js → resolveImplementation-BTdoox5Q.js} +1 -1
- package/assets/{rpc-Cho3IzP3.js → rpc-BNYWG8Xk.js} +1 -1
- package/assets/{secp256k1-ByAi0bYq.js → secp256k1-4Hen77iV.js} +1 -1
- package/assets/{secp256k1-BaRufS7t.js → secp256k1-BbSYUPGQ.js} +1 -1
- package/assets/{secp256k1-cytTtQFI.js → secp256k1-DLj5ZhK-.js} +1 -1
- package/assets/{send-IlFqB457.js → send-BLdu8d9Q.js} +1 -1
- package/assets/{send-batch-transaction-S3cea1la.js → send-batch-transaction-BYU5WtyT.js} +1 -1
- package/assets/{send-eip712-transaction-DdFE8Vm4.js → send-eip712-transaction-DYQtgtg3.js} +2 -2
- package/assets/{send-gasless-transaction-pToZW6hi.js → send-gasless-transaction-TCFEHRAI.js} +2 -2
- package/assets/{send-transaction-F1KcPu_J.js → send-transaction-B3lNpkEI.js} +2 -2
- package/assets/{sendRawTransaction-uZR9vCur.js → sendRawTransaction-CoPr2Xby.js} +3 -3
- package/assets/{serializeTransaction-BMOYZaMo.js → serializeTransaction-CqUdvLxB.js} +1 -1
- package/assets/{session-proposal-CqIScmh0.js → session-proposal-Bvv_Koql.js} +1 -1
- package/assets/{session-request-D0gllW0A.js → session-request-BXyQ3aSm.js} +2 -2
- package/assets/{signing-0IyTTeT3.js → signing-Chd49nry.js} +3 -3
- package/assets/{socials-D2Q72wmI.js → socials-BHcznQJ2.js} +1 -1
- package/assets/{swaps-CxPUnJHk.js → swaps-CfF1uSNv.js} +1 -1
- package/assets/{thirdweb-DiHIZ7yC.js → thirdweb-SfIwpr7e.js} +3 -3
- package/assets/{to-serializable-transaction-CL8iMi28.js → to-serializable-transaction-D-H70tOQ.js} +2 -2
- package/assets/{trade-encoding-Cj43JBMI.js → trade-encoding-DML-9EOG.js} +1 -1
- package/assets/{transactionReceipt-DfrbWAQN.js → transactionReceipt-UO6w58Y3.js} +1 -1
- package/assets/{transactions-Bi4jTwRp.js → transactions-_ffVpirS.js} +1 -1
- package/assets/{useCreditPacks-D8mBmgfk.js → useCreditPacks-B_ZTg1et.js} +1 -1
- package/assets/{useInfiniteGrid-D4Svdp0E.js → useInfiniteGrid-C_eF7Ybb.js} +1 -1
- package/assets/useManaRate-BgOOo-HT.js +1 -0
- package/assets/{useStore-BdMUfp98.js → useStore-CGylzs4i.js} +1 -1
- package/assets/{useTheme-DQx1RjYA.js → useTheme-DIH_4JLE.js} +1 -1
- package/assets/useTheme-OORw6PVg.js +1 -0
- package/assets/{verifyHash-DHqwvSkC.js → verifyHash-Ce0mhn6s.js} +1 -1
- package/assets/{w3m-modal-Bh-3dNi_.js → w3m-modal-D-KLVmSF.js} +1 -1
- package/assets/{w3m-modal-CKSu3pIJ.js → w3m-modal-D7EYp_-6.js} +1 -1
- package/assets/{wait-for-tx-receipt-C2LkGeYl.js → wait-for-tx-receipt-CcL7boc8.js} +1 -1
- package/assets/{wallets-DnH_N4dP.js → wallets-RlYlNkFo.js} +5 -5
- package/assets/{web-connector-z6n-Sz_y.js → web-connector-Clsvv5p6.js} +3 -3
- package/assets/{writeContract-nFmdkNCx.js → writeContract-BCrjhXeZ.js} +1 -1
- package/assets/{zoraTestnet-BdF4F4gE.js → zoraTestnet-DSU_Xfmx.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Cart-bD6xEAcM.js +0 -3
- package/assets/ImportListings-6wte21rD.js +0 -5
- package/assets/ItemDetail-evlg6cKI.js +0 -78
- package/assets/MarketCheckout-BAEx1EJy.js +0 -3
- package/assets/buy-U8LmIfWZ.js +0 -1
- package/assets/collection-BwaksfBA.js +0 -1
- package/assets/useManaRate-DSDizyIm.js +0 -1
- package/assets/useTheme-D9lkNeWV.js +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-kWgeWchW.js","assets/react-C51i12iP.js","assets/dcl-schemas-BICTSpB5.js","assets/index-CqYj0Wnc.js","assets/sentry-DKBoGDXH.js","assets/ethers-w5dOkonM.js","assets/intl-CBcMB1D2.js","assets/index-BRRXsajB.css","assets/emotion-styled.browser.esm-DTAoSEBg.js","assets/useTheme-DIH_4JLE.js","assets/CircularProgress-AupKGvsC.js","assets/index-BDGft3Ii.js","assets/useTheme-OORw6PVg.js","assets/CssVarsProvider-C2bobZqX.js","assets/getOverlayAlpha-B3r4B2PY.js","assets/index-DQJvIYh3.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as le,r as d,j as e,d as Ca,a as Aa,L as Sa}from"./react-C51i12iP.js";import{u as ae,a as Ma,b as pe,t,ak as Pa,i as Fa,r as Ea,h as La,c as he,j as V,k as Ae,l as ke,al as Ta,E as ne,C as D,x as re,B as H,e as Ie,q as qa,J as ia,_ as Ce,ap as ra,aO as Ra,aP as Da,aQ as Oa,aR as $a,p as Me,aS as Ba,ad as ye,o as O,G as na,I as B,aT as Ka,aU as Wa,aV as Qa,M as la,aW as za,F as J,s as X,aX as Va,aY as Ua,aZ as Ga,n as He,a_ as Ya,a$ as Ha,b0 as Ja,b1 as Xa,b2 as Za,ae as es,m as as,b3 as ss,b4 as ts,b5 as is,w as rs,b6 as Je,b7 as ns,g as ls,aq as ds,b8 as os,b9 as cs,ar as ms,ba as us,bb as hs,bc as _s}from"./index-CqYj0Wnc.js";import{d as K}from"./dcl-schemas-BICTSpB5.js";import{W as ys,C as ps,t as fs,a as bs,s as xs}from"./CollectionCarousel-Cv3IS7v1.js";import{b as Xe,c as gs}from"./buy-BAwpkHiu.js";import{P as vs,f as js}from"./PrimaryListModal-C6oCKlmk.js";import{b as Ns,w as ws,S as ks,G as Is}from"./buy-gasless-CBgDMk_P.js";import{g as Cs}from"./authorizations-BV0VRJbP.js";import{u as As,M as Ss,c as Ms}from"./useCreditPacks-B_ZTg1et.js";import{R as Ze}from"./resume-buy-Bf0zIH7y.js";import{a as Ps,f as Se,i as Fs}from"./errors-C3ieTqjz.js";import{E as fe}from"./ErrorNotice-C7soUjRV.js";import{l as Es}from"./loader-logo-BzY9EKdC.js";import{C as Ls}from"./CircularProgress-AupKGvsC.js";import{a as Ts,b as qs}from"./trade-encoding-DML-9EOG.js";import{M as da}from"./MarketCheckout-DtRw4jJL.js";import{u as oa}from"./useManaRate-BgOOo-HT.js";import{s as Rs}from"./address-DrURAr9O.js";import{T as ca}from"./Tooltip-C07IWHCJ.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./index-HN6Rk25C.js";import"./mana-rate-DO_0nFzU.js";import"./emotion-CSxEP8yM.js";function ma({item:s,onClose:r,resume:c=!1}){var h,ee;const{session:i}=ae(),{data:y}=Ma(i),l=pe(),f=le(),v=As().packs.slice(0,Ss),[o,b]=d.useState("loading"),[m,N]=d.useState(null),[a,k]=d.useState(""),[E,u]=d.useState(s.priceCredits),[w,x]=d.useState(null),j=d.useRef(null),q=(w==null?void 0:w.credits)??E,M=(y==null?void 0:y.credits)??0;d.useEffect(()=>{let _=!1;if(!i){b("error"),N(t("buyModal.signInToCheckout"));return}const C=I=>{const A=I-((y==null?void 0:y.credits)??0),g=v.find(T=>T.credits>=A)??v[v.length-1];k(g.id),V("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:I,credits_balance:(y==null?void 0:y.credits)??0,shortfall:Math.max(0,A)}),b("nofunds")};return(async()=>{var I,A;try{const g=await Pa(s);if(!g)throw new Error("not for sale");if(Fa(g,i.address))throw new Error("You can't buy your own listing.");const T=Ea((A=(I=g.received)==null?void 0:I[0])==null?void 0:A.amount);if(!Number.isFinite(T)||T<=0)throw new Error("price unavailable");const S=Math.ceil(T/10);if(_)return;if(u(S),y!=null&&y.credits<S){C(S);return}try{const{credit:$,maxCreditedValue:se,usdCents:de}=await La(i.identity,T,g.id);if(_){he(i.identity,[$.id]).catch(()=>{});return}j.current=$.id;const oe=Math.ceil(de/10);u(oe);const U={trade:g,credit:$,maxCreditedValue:se,usdCents:de,credits:oe};x(U),c?W(U):b("ready")}catch($){if(_)return;if(Ps($)){C(S);return}throw $}}catch(g){if(_)return;V(ke(g)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:Ae(g)}),b("error"),N(Se(g,t("buyModal.error.generic"),{sale:!0}))}})(),()=>{_=!0,j.current&&i&&(he(i.identity,[j.current]).catch(()=>{}),j.current=null)}},[]);async function W(_=w){if(!i||!_)return;b("processing"),N(null);let C=!1;try{const I={trade:_.trade,buyer:i.address,signer:i.signer,credits:[_.credit],maxCreditedValue:_.maxCreditedValue};let A;if(Cs())try{A=await Ns(I),await ws(A),C=!0}catch(g){if(g instanceof ks)C=!0;else if(g instanceof Is)A=await Xe(I);else throw g}else A=await Xe(I);j.current=null,V("Shop Completed Purchase",{...Ta([s]),payment_type:"credits",no_crypto_step:C,transaction_hash:A??null}),l.invalidateQueries({queryKey:["usd-balance"]}),l.invalidateQueries({queryKey:["detail-trade"]}),l.invalidateQueries({queryKey:["shop-item"]}),l.invalidateQueries({queryKey:["owned-token",s.contractAddress,s.tokenId]}),l.invalidateQueries({queryKey:["public-token",s.contractAddress,s.tokenId]}),l.invalidateQueries({queryKey:["item-resales",s.contractAddress,s.itemId]}),l.invalidateQueries({queryKey:["shop-items"]}),l.invalidateQueries({queryKey:["catalog-items"]}),l.invalidateQueries({queryKey:["my-assets"]}),l.invalidateQueries({queryKey:["purchases"]}),b("complete")}catch(I){ke(I)||ne(I,{flow:"buy",step:"submit",gasless:C}),he(i.identity,[_.credit.id]).catch(()=>{}),j.current=null,V(ke(I)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:Ae(I)}),l.invalidateQueries({queryKey:["usd-balance"]}),N(Se(I,t("buyModal.error.generic"),{sale:!0})),b("error")}}async function Q(){if(!(!a||!i)){try{sessionStorage.setItem(Ze,JSON.stringify(s))}catch{}w&&he(i.identity,[w.credit.id]).catch(()=>{}),j.current=null,b("loading");try{const _=await Ms(a,{address:i.address,identity:i.identity});if(_.url){window.location.href=_.url;return}f("/credits")}catch(_){ne(_,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(Ze)}catch{}N(t("buyModal.error.creditsCheckout")),b("error")}}}const L=o==="processing",Z=o==="complete"?t("buyModal.titleComplete"):o==="nofunds"?t("buyModal.titleNoFunds"):t("buyModal.titleBuy");return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:s.name}),children:[e.jsx("div",{className:"buy-modal__scrim",onClick:L?void 0:r,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${o==="processing"||o==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:Z}),!L&&e.jsx("button",{className:"buy-modal__x",onClick:r,"aria-label":t("buyModal.close"),children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:o==="nofunds"?t("buyModal.dclBalance"):t("buyModal.myCreditsBalance")}),e.jsx(D,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:re(M)})]})]}),o==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(Ls,{size:44})}),o==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(fe,{message:m}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:r,children:t("buyModal.close")})})]}),o==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsx(ys,{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,q-M)})})," ",t("buyModal.warningToPurchase",{count:1})]})]}),e.jsx(ea,{item:s,priceCredits:q}),e.jsx("div",{className:"buy-modal__packs",children:v.map(_=>{const C=_.credits,I=_.id===a;return e.jsxs("button",{className:`buy-modal__pack${I?" buy-modal__pack--on":""}`,onClick:()=>k(_.id),children:[e.jsx(D,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:re(C)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",_.usd.toFixed(2),")"]})]},_.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(D,{className:"buy-modal__total-ico"}),e.jsx("span",{children:re(((h=v.find(_=>_.id===a))==null?void 0:h.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((ee=v.find(_=>_.id===a))==null?void 0:ee.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:r,children:t("buyModal.cancel")}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:()=>void Q(),children:t("buyModal.buy")})]})]}),o==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(ea,{item:s,priceCredits:q}),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 W(),children:t("buyModal.buy")})})]}),o==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:Es,alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:c?t("buyModal.completingPurchase"):t("buyModal.completingTransaction")}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),o==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:t("getCredits.successTitle")})," ",t("buyModal.successBody")]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>f("/assets?tab=mine"),children:t("buyModal.myAssets")}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:r,children:[t("buyModal.tryInWorld"),e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function ea({item:s,priceCredits:r}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:s.name,children:s.name||t("buyModal.itemFallback")}),s.creator?e.jsx(ps,{address:s.creator,className:"buy-modal__asset-creator"}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(D,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:re(r)})]})]})]})}const Ds=1e3*60*60*24*182;function Os({asset:s,session:r,onClose:c}){const i=pe(),y=le(),[l,f]=d.useState("10"),[v,o]=d.useState(null),[b,m]=d.useState(null),[N,a]=d.useState(!1),[k,E]=d.useState(null);async function u(){m(null);const x=Number(l);if(!Number.isInteger(x)||x<=0){m(t("sellModal.errorWholeNumber"));return}a(!0);try{o(t("sellModal.statusPreparing")),await Ts({signer:r.signer,contractAddress:s.contractAddress,chainId:s.chainId}),o(t("sellModal.statusListing"));const j=await qs({signer:r.signer,nft:{contractAddress:s.contractAddress,tokenId:s.tokenId,network:s.network,chainId:s.chainId},usdPrice:x/10,expiresAtMs:Date.now()+Ds});o(t("sellModal.statusPublishing")),await qa(j,r.identity),o(null),E(x),V("Shop Listed Item",{item_id:s.itemId??s.tokenId??null,contract_address:s.contractAddress,price_credits:x,price_usd:x/10,listing_type:"secondary",is_primary:!1}),ia.success(t("sellModal.toastOnSale",{name:s.name})),i.invalidateQueries({queryKey:["my-assets",r.address]})}catch(j){ne(j,{flow:"list_secondary"}),V("Shop Listing Failed",{listing_type:"secondary",error_code:Ae(j)}),m(Se(j,t("sellModal.errorGeneric"))),o(null)}finally{a(!1)}}function w(){c(),y(`/item/${s.contractAddress}/${s.tokenId}`)}return k!==null?e.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:e.jsxs("div",{className:"modal modal--success",onClick:x=>x.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(D,{className:"ccy-mark"})," ",k]})]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(H,{variant:"ghost",onClick:c,children:t("getCredits.done")}),e.jsx(H,{variant:"purple",onClick:w,children:t("sellModal.viewInShop")})]})]})}):e.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:e.jsxs("div",{className:"modal","data-testid":"modal",onClick:x=>x.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:Ie.name})}),e.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:x=>f(x.target.value),disabled:N})]}),e.jsx("p",{className:"muted small",children:t("sellModal.pricedInWhole",{currency:Ie.name,currencySingular:Ie.nameSingular})}),v?e.jsx("p",{className:"muted",children:v}):null,e.jsx(fe,{message:b}),e.jsxs("div",{className:"modal__actions",children:[e.jsx(H,{variant:"ghost",onClick:c,disabled:N,children:t("sellModal.cancel")}),e.jsx(H,{onClick:()=>void u(),disabled:N,children:N?t("sellModal.listing"):t("sellModal.putOnSale")})]})]})})}const $s=d.lazy(async()=>{const[{EmoteControls:s},{Experimental_CssVarsProvider:r},{light:c}]=await Promise.all([Ce(()=>import("./index-kWgeWchW.js").then(i=>i.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),Ce(()=>import("./index-BDGft3Ii.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),Ce(()=>import("./index-DQJvIYh3.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:i=>e.jsx(r,{theme:c,children:e.jsx(s,{...i})})}});function Bs(s){return e.jsx(d.Suspense,{fallback:null,children:e.jsx($s,{...s})})}function Ks({item:s}){const r=ae(q=>{var M;return(M=q.session)==null?void 0:M.address}),{data:c,isLoading:i}=ra(r),y=r&&c?r:"default",l=s.category==="emote",[f,v]=d.useState("item"),o=!l&&f==="item",b=o||!i,[m,N]=d.useState(!0);d.useEffect(()=>{N(!0)},[s.id,o]);const[a,k]=d.useState(K.PreviewRenderer.UNITY),E=a===K.PreviewRenderer.BABYLON,u=!!r&&!!c,w=u&&Ra(s,Da(c)),x=Oa(s)[0],j=u&&!w&&!l;return e.jsxs(e.Fragment,{children:[b?e.jsx($a,{id:"shop-item-preview",contractAddress:s.contractAddress,tokenId:s.tokenId??void 0,itemId:s.tokenId?void 0:s.itemId??void 0,profile:o?void 0:w?y:"default",bodyShape:o||w?void 0:x,type:l?void 0:o?K.PreviewType.WEARABLE:K.PreviewType.AVATAR,emote:l||o?void 0:K.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:l?1.5:void 0,wheelStart:l?100:void 0,dev:Me.chainId===80002,unity:!0,onRenderer:k,onLoad:()=>N(!1)}):null,!b||m?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":t("itemPreview.loading"),children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,j&&!o?e.jsx("p",{className:"item-preview__note",children:t("itemPreview.shownOnBody",{shape:Ba(x)})}):null,E?l?e.jsx("div",{className:"item-preview__emote-controls","data-testid":"emote-controls",children:e.jsx(Bs,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":t("itemPreview.previewMode"),children:[e.jsxs("button",{type:"button",className:f==="avatar"?"is-active":"","aria-pressed":f==="avatar","aria-label":t("itemPreview.onAvatar"),onClick:()=>v("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:f==="item"?"is-active":"","aria-pressed":f==="item","aria-label":t("itemPreview.item"),onClick:()=>v("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")})]})]}):null]})}const aa=8,Ws=!1;function Qs(s){if(!s)return;const r=s.toLowerCase();return Object.values(K.Rarity).includes(r)?K.Rarity.getMaxSupply(r):void 0}function zs(s){return/^0x[a-fA-F0-9]{40}$/.test(s)?`${s.slice(0,6)}…${s.slice(-4)}`:s}function Vs(s){let r=0;for(let c=0;c<s.length;c++)r=r*31+s.charCodeAt(c)>>>0;return`hsl(${r%360}, 52%, 45%)`}function Us(s,r){var c;return(((c=s==null?void 0:s.trim())==null?void 0:c[0])||r.replace(/^0x/i,"")[0]||"?").toUpperCase()}function Gs(s){return{tradeId:s.tradeId??s.id,listingType:"primary",contractAddress:s.contractAddress,itemId:s.itemId??"",name:s.name,thumbnail:s.thumbnail,rarity:s.rarity,category:s.category,wearableCategory:s.wearableCategory??null,creator:s.creator,manaWei:s.manaWei??"0",available:1,network:s.network,chainId:s.chainId,createdAt:0}}function Ys({r:s,seller:r,issuedId:c,total:i,isOwn:y,isLegacy:l,inCart:f,fallbackImage:v,onAdd:o,onBuyNative:b,onBuyLegacy:m}){var W,Q;const N=le(),{data:a}=ra(r),k=(Q=(W=a==null?void 0:a.avatar)==null?void 0:W.snapshots)==null?void 0:Q.face256,[E,u]=d.useState(!1);d.useEffect(()=>u(!1),[k]);const w=!!k&&!E,x=r?a!=null&&a.name?na(a.name):zs(r):void 0,j=w?e.jsx("img",{className:"resales__ava",src:k,alt:"",loading:"lazy",onError:()=>u(!0)}):r?e.jsx("span",{className:"resales__ava resales__ava--letter",style:{backgroundColor:Vs(r)},"aria-hidden":!0,children:Us(a==null?void 0:a.name,r)}):v?e.jsx("img",{className:"resales__ava",src:v,alt:"","aria-hidden":!0}):e.jsx("span",{className:"resales__ava resales__ava--empty","aria-hidden":!0}),q=e.jsxs("span",{className:"resales__ident",children:[x?e.jsx("span",{className:"resales__name","data-testid":"resale-seller",children:x}):null,c?e.jsxs("span",{className:"resales__serial",children:[t("resales.serialLabel")," ",e.jsxs("span",{className:"resales__issued","data-testid":"resale-issued",children:["#",c]}),i?` ${t("resales.serialOf")} ${i.toLocaleString("en-US")}`:""]}):e.jsx("span",{className:"resales__serial resales__serial--muted",children:t("resales.copy")})]}),M=r?e.jsxs("button",{type:"button",className:"resales__who resales__who--link",onClick:()=>N(`/assets/creator/${r}`),children:[j,q]}):e.jsxs("div",{className:"resales__who",children:[j,q]});return e.jsxs("li",{className:`resales__row${l?" resales__row--legacy":""}`,"data-testid":"resale-row","data-source":s.source,"data-own":y?"true":void 0,children:[M,e.jsxs("div",{className:`resales__price${l?" resales__price--approx":""}`,children:[l?e.jsx("span",{className:"resales__approx","aria-hidden":!0,children:"≈"}):null,e.jsx(D,{className:"resales__diamond"}),e.jsx("span",{className:"resales__price-value",children:re(s.priceCredits)})]}),e.jsx("div",{className:"resales__actions",children:y?e.jsx("span",{className:"chip resales__own-chip","data-testid":"resale-own",children:t("resales.yourListing")}):l?e.jsx("button",{className:"resales__buy",onClick:m,"aria-label":t("assetCard.buyNow"),"data-testid":"resale-buy",children:t("assetCard.buyNow")}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"resales__add",onClick:o,disabled:f,"aria-label":f?t("assetCard.inCart"):t("assetCard.addToCart"),"data-testid":"resale-add",children:[e.jsx(B,{name:"cart-solid",size:16}),e.jsx("span",{children:f?t("assetCard.inCart"):t("assetCard.addToCart")})]}),e.jsx("button",{className:"resales__buy",onClick:b,"aria-label":t("assetCard.buyNow"),"data-testid":"resale-buy",children:t("assetCard.buyNow")})]})})]})}function Hs({item:s}){var Z;const r=s.contractAddress,c=s.itemId,i=pe(),y=ye(h=>h.add),l=ye(h=>h.items),{session:f}=ae(),v=(Z=f==null?void 0:f.address)==null?void 0:Z.toLowerCase(),[o,b]=d.useState(null),[m,N]=d.useState(null),[a,k]=d.useState(aa),E=Qs(s.rarity),{data:u=[],isLoading:w}=O({queryKey:["item-resales",r,c],enabled:!!r&&!!c,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:()=>Ka(r,c)}),x=u.slice(0,a),j=x.filter(h=>!h.seller||!h.issuedId).map(h=>h.tokenId).filter(h=>!!h),{data:q={}}=O({queryKey:["resale-token-info",r,j.join(",")],enabled:!!r&&j.length>0,staleTime:6e4,queryFn:()=>Wa(r,j)}),{data:M=[]}=O({queryKey:["item-classic-orders",r,c],enabled:Ws,queryFn:()=>Qa(r,c)}),W=u.some(h=>h.source==="legacy"),{data:Q}=oa(W);function L(){i.invalidateQueries({queryKey:["item-resales",r,c]})}return w||u.length===0?null:e.jsxs("section",{className:"resales","data-testid":"resales-section",children:[e.jsxs("div",{className:"resales__head",children:[e.jsx("h2",{className:"resales__title",children:t("resales.title")}),e.jsx("p",{className:"resales__subtitle",children:t("resales.subtitle")})]}),u.length>0?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"resales__list",children:x.map(h=>{const ee=h.source==="legacy",_=l.some(S=>S.id===h.id),C=h.tokenId&&q[h.tokenId]||{},I=h.issuedId??C.issuedId,A=h.seller??C.seller,g={...h,name:h.name||s.name,thumbnail:h.thumbnail||s.thumbnail,rarity:h.rarity||s.rarity,category:h.category||s.category,wearableCategory:h.wearableCategory??s.wearableCategory,gender:h.gender??s.gender},T=!!A&&!!v&&A.toLowerCase()===v;return e.jsx(Ys,{r:g,seller:A,issuedId:I,total:E,isOwn:T,isLegacy:ee,inCart:_,fallbackImage:g.thumbnail,onAdd:()=>y(g,"item_detail"),onBuyNative:()=>b(g),onBuyLegacy:()=>N(Gs(g))},h.tradeId??h.id)})}),u.length>a?e.jsx("button",{className:"resales__more",onClick:()=>k(h=>h+aa),"data-testid":"resale-show-more",children:t("resales.showMore")}):null]}):null,null,o?e.jsx(ma,{item:o,onClose:()=>{b(null),L()}}):null,m&&Q?e.jsx(da,{listing:m,rate:Q,onClose:()=>N(null),onSold:()=>{N(null),L()}}):null]})}function ua(){return Me.shopServerUrl||(typeof window<"u"?window.location.origin:"")}async function Js(s,r,c){const i=new URLSearchParams({contractAddress:s,itemId:r}),y=`${ua()}/notify-requests?${i.toString()}`,l=await la(y,{method:"GET",identity:c,metadata:{}});if(!l.ok)throw new Error(`getNotifyRequest ${l.status}`);return l.json()}async function Xs(s,r){const c=`${ua()}/notify-requests`,i=await la(c,{method:"POST",identity:r,metadata:{},headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw new Error(`createNotifyRequest ${i.status}: ${await i.text()}`);await i.json().catch(()=>{})}function sa(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim())}function Zs({item:s}){const r=ae(u=>u.session),c=ae(u=>u.signIn),[i,y]=d.useState(""),[l,f]=d.useState(!1),[v,o]=d.useState(!1),[b,m]=d.useState(null),N=!!r&&!!s.contractAddress&&!!s.itemId,{data:a}=O({queryKey:["notify-request",s.contractAddress,s.itemId,r==null?void 0:r.address],enabled:N,queryFn:()=>Js(s.contractAddress,s.itemId,r.identity)});d.useEffect(()=>{a!=null&&a.email&&y(u=>u||a.email)},[a==null?void 0:a.email]),d.useEffect(()=>{if(!r)return;let u=!1;return za().then(w=>{!u&&w&&y(x=>x||w)}),()=>{u=!0}},[r]);const k=v||!!(a!=null&&a.subscribed);async function E(u){if(u.preventDefault(),!(!r||!s.itemId||!sa(i)||l)){f(!0),m(null);try{await Xs({contractAddress:s.contractAddress,itemId:s.itemId,chainId:s.chainId,email:i.trim()},r.identity),o(!0)}catch(w){ne(w,{flow:"notify-me",contractAddress:s.contractAddress,itemId:s.itemId}),m(t("notifyMe.error"))}finally{f(!1)}}}return r?k?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(B,{name:"check",size:12})}),e.jsx("span",{className:"notify__done-text",children:t("notifyMe.subscribedBody")})]}):e.jsxs("form",{className:"notify",onSubmit:E,"data-testid":"notify",children:[e.jsx("label",{className:"notify__label",htmlFor:"notify-email",children:t("notifyMe.label")}),e.jsxs("div",{className:"notify__row",children:[e.jsx("input",{id:"notify-email",className:"notify__input",type:"email",inputMode:"email",autoComplete:"email",placeholder:t("notifyMe.placeholder"),value:i,onChange:u=>y(u.target.value),"data-testid":"notify-email"}),e.jsx("button",{type:"submit",className:"notify__btn",disabled:!sa(i)||l,"data-testid":"notify-submit",children:l?t("notifyMe.working"):t("notifyMe.cta")})]}),e.jsx(fe,{message:b})]}):e.jsx("div",{className:"notify","data-testid":"notify",children:e.jsx("button",{type:"button",className:"notify__signin",onClick:c,"data-testid":"notify-signin",children:t("notifyMe.signInCta")})})}const et=X.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: ${J.colors.accent};
|
|
14
|
+
font-family: ${J.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 ${J.colors.accent};
|
|
30
|
+
outline-offset: 2px;
|
|
31
|
+
}
|
|
32
|
+
`;function at({item:s}){return e.jsx(ca,{block:!0,content:t("makeOffer.comingSoon"),onShow:()=>V("Shop Make Offer Tooltip Shown",{contractAddress:s.contractAddress,itemId:s.itemId}),children:e.jsxs(et,{type:"button","aria-disabled":!0,onClick:r=>r.preventDefault(),"data-testid":"make-offer",children:[e.jsx(B,{name:"offer",size:20,"aria-hidden":!0}),e.jsx("span",{children:t("makeOffer.cta")})]})})}const st=X(Va)`
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
gap: 1px;
|
|
37
|
+
background: ${J.colors.lineStrong};
|
|
38
|
+
`;function tt({contractAddress:s,name:r,items:c,className:i}){const y=le();if(!s||!r)return null;const l=(c??[]).map(o=>o.thumbnail).filter(o=>!!o).slice(0,4),f=l.slice(0,2),v=l.slice(2,4);return e.jsxs(Ua,{as:"button","data-link":!0,className:i,"data-testid":"creator",onClick:o=>{o.stopPropagation(),y(`/collection/${s}`)},children:[l.length>0?e.jsxs(st,{as:"span","data-avatar":!0,"data-testid":"creator-ava","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${v.length===0?" collection-collage__row--full":""}`,children:f.map((o,b)=>e.jsx("img",{src:o,alt:""},b))}),v.length>0?e.jsx("span",{className:"collection-collage__row",children:v.map((o,b)=>e.jsx("img",{src:o,alt:""},b))}):null]}):null,e.jsx(Ga,{"data-testid":"creator-name",children:na(r)})]})}const it=X(H)`
|
|
39
|
+
margin-top: 6px;
|
|
40
|
+
`,_e=X(H)`
|
|
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
|
+
${J.media.down("lg")} {
|
|
54
|
+
.item-detail__ctas--dual && {
|
|
55
|
+
flex: 1 1 auto;
|
|
56
|
+
width: auto;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,rt=X("div")`
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
gap: 10px;
|
|
63
|
+
width: 100%;
|
|
64
|
+
`,nt=X(H)`
|
|
65
|
+
&& {
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 44px;
|
|
68
|
+
/* Match the primary manage CTA's all-caps treatment (the ghost variant doesn't uppercase on its
|
|
69
|
+
own). CSS-only, so the DOM text stays "Remove from sale" for tests/a11y. */
|
|
70
|
+
text-transform: uppercase;
|
|
71
|
+
letter-spacing: 0.46px;
|
|
72
|
+
}
|
|
73
|
+
`,lt=X("p")`
|
|
74
|
+
margin: 4px 0 0;
|
|
75
|
+
font-size: 13px;
|
|
76
|
+
color: ${J.colors.muted};
|
|
77
|
+
|
|
78
|
+
a {
|
|
79
|
+
color: ${J.colors.accent};
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
`;function dt(s){return Object.values(K.Rarity).includes(s)}function ot(s){return s==="male"?t("itemDetail.genderMale"):s==="female"?t("itemDetail.genderFemale"):s==="unisex"?t("itemDetail.genderUnisex"):null}function ta(s){return s.wearableCategory?s.wearableCategory.replace(/_/g," "):s.category==="emote"?t("itemDetail.categoryEmote"):t("itemDetail.categoryWearable")}function Dt(){var Ye;const{contractAddress:s,tokenId:r}=Ca(),c=Aa(),i=c.state,y=le(),l=!!(i!=null&&i.market),f=(i==null?void 0:i.marketPriceCredits)??null,v=ye(n=>n.add),o=ye(n=>n.items),b=He(n=>n.toggle),{session:m,signIn:N}=ae(),[a,k]=d.useState(()=>i!=null&&i.item?{...i.item,tradeId:i.tradeId??i.item.tradeId}:{id:`${s}-${r}`,name:"",creator:"",contractAddress:s??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:Me.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:r??void 0,tradeId:i==null?void 0:i.tradeId}),[E,u]=d.useState(!1),[w,x]=d.useState(!!(i!=null&&i.resumeBuy));d.useEffect(()=>{i!=null&&i.resumeBuy&&u(!0)},[i==null?void 0:i.resumeBuy]);function j(){if(m){u(!0);return}l||xs({type:"item-buy",path:c.pathname}),N()}const q=d.useRef(!1);d.useEffect(()=>{if(!m||q.current)return;const n=fs("item-buy");!n||n.path!==c.pathname||(q.current=!0,x(!0),u(!0))},[m]);const{data:M=[],isFetched:W}=O({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>ds(a.contractAddress,{first:20}).then(n=>n.items)}),Q=a.available==null&&!a.tokenId,{data:L,isLoading:Z}=O({queryKey:["shop-item",a.contractAddress,r],enabled:!l&&!!a.contractAddress&&!!r&&(!(i!=null&&i.item)||Q),staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:()=>os(a.contractAddress,r)});d.useEffect(()=>{L&&k(n=>n.tradeId?n.available!=null&&n.wearableCategory?n:{...n,available:n.available??L.available,wearableCategory:n.wearableCategory??L.wearableCategory}:{...L})},[L]);const[h,ee]=d.useState(!1),{data:_=""}=O({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>cs(a.contractAddress,a.itemId)}),{data:C}=O({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>ms(a.contractAddress)});d.useEffect(()=>{if(a.name||L||M.length===0)return;const n=r&&M.find(F=>F.tokenId===r||F.itemId===r)||M.find(F=>F.contractAddress===a.contractAddress);n&&k(F=>({...n,tradeId:F.tradeId??n.tradeId}))},[M,L]);const I=d.useMemo(()=>{const n=new Set,F=[];for(const R of M){if(R.id===a.id||a.itemId&&R.itemId===a.itemId||a.tokenId&&R.tokenId===a.tokenId)continue;const ie=`${R.contractAddress}-${R.itemId??R.tokenId??R.id}`;n.has(ie)||(n.add(ie),F.push(R))}return F},[M,a.id,a.itemId,a.tokenId]),{data:A,isLoading:g}=O({queryKey:["detail-trade",a.id,a.tradeId,a.contractAddress,a.itemId],enabled:!!a.contractAddress,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:async()=>{if(a.tradeId)return a.tradeId;if(a.itemId){const n=await us(a.contractAddress,a.itemId);return(n==null?void 0:n.id)??null}return null}}),T=a.tradeId??A??void 0,S=!!T,{data:$}=oa(l),se=d.useMemo(()=>{if(!l||!(i!=null&&i.item))return null;const n=i.item;return n.manaWei?{tradeId:n.tradeId??n.id,listingType:"primary",contractAddress:n.contractAddress,itemId:n.itemId??"",name:n.name,thumbnail:n.thumbnail,rarity:n.rarity,category:n.category,wearableCategory:n.wearableCategory??null,creator:n.creator,manaWei:n.manaWei,available:1,network:n.network,chainId:n.chainId,createdAt:0}:null},[l,i==null?void 0:i.item]),de=l&&f!=null&&!!$&&!!se,oe=Ya({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),U=d.useMemo(()=>({...a,tradeId:T,id:T??a.id}),[a,T]),be=o.some(n=>n.id===U.id),ce=!U.tokenId,ha=((Ye=o.find(n=>n.id===U.id))==null?void 0:Ye.quantity)??0,xe=ce&&typeof a.available=="number"&&ha>=a.available,G=He(n=>!!n.items[a.id]),Pe=d.useRef(null);d.useEffect(()=>{!a.name||g||Pe.current===a.id||(Pe.current=a.id,V("Shop Viewed Item",{...Ha(a),for_sale:S}),Ja(a))},[a.id,a.name,g,S]);const me=`${s}/${r}`,Fe=d.useRef(me);d.useEffect(()=>{Fe.current!==me&&(Fe.current=me,i!=null&&i.item&&k({...i.item,tradeId:i.tradeId??i.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[me]);function _a(){!S||ve||g||!ce&&be||xe||v(U,"item_detail")}const ge=dt(a.rarity)?a.rarity:K.Rarity.COMMON,Ee=ot(a.gender),Le=Xa(a),Te=Za(a.gender),ya=S&&oe,pa=t("itemDetail.moreFromCollection"),ve=es(a,m==null?void 0:m.address),z=pe(),[fa,qe]=d.useState(!1),[ba,Re]=d.useState(!1),[te,ue]=d.useState(null),[xa,De]=d.useState(null),{data:p,isLoading:Oe}=O({queryKey:["owned-token",a.contractAddress,a.tokenId,m==null?void 0:m.address],enabled:!l&&!!(m!=null&&m.address)&&!!a.contractAddress&&!!a.tokenId,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:()=>m?hs(m.address,a.contractAddress,a.tokenId):null});d.useEffect(()=>{p&&k(n=>n.name?n.issuedId?n:{...n,issuedId:p.issuedId}:{id:p.id,name:p.name,creator:"",contractAddress:p.contractAddress,itemId:p.itemId,category:p.category,rarity:p.rarity??"common",network:p.network,chainId:p.chainId,thumbnail:p.image,priceCredits:p.listingPrice??0,gender:null,isSmart:!1,tokenId:p.tokenId,issuedId:p.issuedId,tradeId:p.tradeId})},[p]);const{data:P}=O({queryKey:["public-token",a.contractAddress,a.tokenId],enabled:!l&&!!a.contractAddress&&!!a.tokenId&&!a.name&&!L&&!Oe&&!p,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:()=>_s(a.contractAddress,a.tokenId)});d.useEffect(()=>{P&&k(n=>n.name?n.issuedId?n:{...n,issuedId:P.issuedId}:{id:P.id,name:P.name,creator:"",contractAddress:P.contractAddress,itemId:P.itemId,category:P.category,rarity:P.rarity??"common",network:P.network,chainId:P.chainId,thumbnail:P.image,priceCredits:P.listingPrice??0,gender:null,isSmart:!1,tokenId:P.tokenId,issuedId:P.issuedId,tradeId:P.tradeId})},[P]);const{data:je}=O({queryKey:["publishable-item",a.contractAddress,a.itemId,m==null?void 0:m.address],enabled:ve&&!!m&&!!a.itemId,queryFn:async()=>m?(await js(m.address,m.identity)).find(F=>F.contractAddress.toLowerCase()===a.contractAddress.toLowerCase()&&F.blockchainItemId===a.itemId)??null:null}),Y=!!p,Ne=!l&&(ve||Y),$e=Y?!!(p!=null&&p.isOnSale):S,we=Y?p==null?void 0:p.tradeId:T,Be=Y?!!p:!!je,Ke=Y?(p==null?void 0:p.listingPrice)??0:0;async function We(){await Promise.all([z.invalidateQueries({queryKey:["owned-token",a.contractAddress,a.tokenId]}),z.invalidateQueries({queryKey:["detail-trade"]}),z.invalidateQueries({queryKey:["shop-item"]}),z.invalidateQueries({queryKey:["collection-sale-state"]}),z.invalidateQueries({queryKey:["secondary-sale-state"]}),z.invalidateQueries({queryKey:["my-assets"]}),z.invalidateQueries({queryKey:["publishable-items"]}),z.invalidateQueries({queryKey:["publishable-item",a.contractAddress,a.itemId]}),z.invalidateQueries({queryKey:["item-resales",a.contractAddress,a.itemId]})])}async function Qe(n={}){const F=n.own!==!1;if(!m||!we)return!1;De(null),F&&ue("remove");try{const R=await ls(we);return await gs({trade:R,signer:m.signer}),n.silent||ia.success(t("myAssets.removedFromSale",{name:a.name})),await We(),!0}catch(R){const ie=Fs(R);return ie||ne(R,{flow:"remove-listing",tradeId:we}),De(ie?t("getCredits.errorCanceled"):t("myAssets.removeListingError")),!1}finally{F&&ue(null)}}function ze(){Y?qe(!0):Re(!0)}async function ga(){ue("update");try{await Qe({silent:!0,own:!1})&&ze()}finally{ue(null)}}function Ve(){qe(!1),Re(!1),We()}const Ue=S?g?t("itemDetail.checking"):xe?t("itemDetail.maxInCart"):!ce&&be?t("assetCard.inCart"):t("assetCard.addToCart"):t("itemDetail.notForSale"),va=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!l,ja=!l&&!a.tokenId&&a.available===0,Na=!Ne&&S&&!l,wa=l||!Ne,ka=Z||!!a.contractAddress&&!W||!a.name&&Oe,Ge=!a.name&&!ka,Ia=/^https?:\/\//i.test(a.thumbnail);return as(Ge?{title:t("seo.item.notFoundTitle"),noindex:!0}:a.name?{title:a.name,description:_||t("seo.item.fallbackDescription",{name:a.name,rarity:a.rarity,category:ta(a),creator:Rs(a.creator)}),image:Ia?a.thumbnail:void 0,type:"product"}:{}),Ge?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx(B,{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(it,{variant:"purple",onClick:()=>y("/assets"),children:t("notFound.cta")})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":t("itemDetail.breadcrumbAria"),children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>y("/assets"),children:t("nav.collectibles")}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:a.name||t("itemDetail.itemFallback")})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsxs("div",{className:"item-detail__preview","data-testid":"item-preview",children:[a.name?e.jsx(Ks,{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${G?" is-on":""}`,onClick:()=>b(a),"aria-pressed":G,"aria-label":G?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(B,{name:G?"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${G?" is-on":""}`,onClick:()=>b(a),"aria-pressed":G,"aria-label":G?t("assetCard.removeFromFavorites"):t("assetCard.addToFavorites"),children:e.jsx(B,{name:G?"heart-solid":"heart",size:18})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:is(ge),color:ts(ge)},title:ss(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[Le?e.jsx(B,{name:Le,size:18,color:"var(--text-2)"}):null,ta(a)]}),Ee?e.jsxs("span",{className:"chip item-detail__chip",children:[Te?e.jsx(B,{name:Te,size:18,color:"var(--text-2)"}):null,Ee]}):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:()=>ee(n=>!n),children:h?t("itemDetail.showLess"):t("itemDetail.readMore")}):null]}):null,a.creator||C!=null&&C.name?e.jsxs("div",{className:"item-detail__meta",children:[a.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:t("itemDetail.creator")}),e.jsx(rs,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,C!=null&&C.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:t("itemDetail.collection")}),e.jsx(tt,{contractAddress:a.contractAddress,name:C.name,items:M,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[l||S?e.jsx("div",{className:"item-detail__price-label",children:t("itemDetail.price")}):null,l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:f==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(D,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:f})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:t("assetCard.marketPrice")})]}):S?ya?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(D,{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(D,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),Je(a.compareAtCredits,a.priceCredits)>0?e.jsx("span",{className:"item-detail__sale-badge",children:t("assetCard.saleWithDiscount",{pct:Je(a.compareAtCredits,a.priceCredits)})}):null,e.jsx(ns,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(D,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}):$e&&Ke?e.jsxs("div",{className:"item-detail__price",children:[e.jsx(D,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:Ke})]}):e.jsxs("div",{className:"item-detail__price item-detail__price--none",children:[e.jsx("span",{children:t("itemDetail.notForSale")}),e.jsx(ca,{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(B,{name:"info",size:14})})})]})]}),va?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(),"/",K.Rarity.getMaxSupply(ge).toLocaleString()]})]}):ja?e.jsx("div",{className:"item-detail__stock-col",children:e.jsx("div",{className:"item-detail__stock-value item-detail__stock-value--out","data-testid":"out-of-stock",children:t("itemDetail.outOfStock")})}):null]})}),e.jsx("div",{className:`item-detail__ctas${wa?" item-detail__ctas--buttons":""}${Na?" item-detail__ctas--dual":""}`,children:l?e.jsxs(_e,{variant:"purple",onClick:j,disabled:!de,children:[e.jsx("span",{className:"item-detail__cta-label",children:t("assetCard.buyNow")}),f!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(D,{className:"item-detail__cta-diamond"}),f]}):null]}):Ne?e.jsxs(rt,{"data-testid":"manage-actions",children:[e.jsx(fe,{message:xa}),$e?e.jsxs(e.Fragment,{children:[e.jsx(_e,{variant:"purple",onClick:()=>void ga(),disabled:te!==null||!Be,children:e.jsx("span",{className:"item-detail__cta-label",children:te==="update"?t("itemDetail.manageWorking"):t("itemDetail.manageUpdatePrice")})}),e.jsx(nt,{variant:"ghost",onClick:()=>void Qe(),disabled:te!==null,children:e.jsx("span",{className:"item-detail__cta-label",children:te==="remove"?t("myAssets.removing"):t("itemDetail.manageRemove")})})]}):e.jsx(_e,{variant:"purple",onClick:()=>{Y&&V("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),ze()},disabled:te!==null||!Be,children:e.jsx("span",{className:"item-detail__cta-label",children:t("itemDetail.manageList")})}),e.jsxs(lt,{children:[t("itemDetail.ownItemPrefix")," ",e.jsx(Sa,{to:"/my-assets",children:t("nav.myAssets")}),t("itemDetail.ownItemSuffix")]})]}):S?e.jsxs(e.Fragment,{children:[e.jsxs(_e,{variant:"purple",onClick:j,disabled:g,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(D,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}),e.jsxs("button",{className:"item-detail__addcart",onClick:_a,disabled:g||(ce?xe:be),"aria-label":Ue,children:[e.jsx(B,{name:"cart-solid"}),e.jsx("span",{className:"item-detail__addcart-label",children:Ue})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zs,{item:a}),e.jsx(at,{item:a})]})})]}):e.jsx(ct,{})})]}),a.itemId?e.jsx(Hs,{item:a}):null,e.jsx(bs,{title:pa,items:I,onViewAll:a.contractAddress?()=>y(`/collection/${a.contractAddress}`):void 0}),E&&l&&se&&$?e.jsx(da,{listing:se,rate:$,onClose:()=>u(!1),onSold:()=>u(!1)}):E&&!l?e.jsx(ma,{item:U,resume:w,onClose:()=>{u(!1),x(!1)}}):null,fa&&p&&m?e.jsx(Os,{asset:p,session:m,onClose:Ve}):null,ba&&je&&m?e.jsx(vs,{item:je,session:m,onClose:Ve}):null]})}function ct(){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{Dt as ItemDetail,Dt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as c}from"./react-C51i12iP.js";import{s as u,B as p,t as d}from"./index-
|
|
1
|
+
import{r as l,j as c}from"./react-C51i12iP.js";import{s as u,B as p,t as d}from"./index-CqYj0Wnc.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{u as z,r as h,j as r}from"./react-C51i12iP.js";import{u as O,a as V,b as Y,t,c as y,C as b,f as S,d as H,e as w,g as $,i as D,h as J,j as p,k as M,l as q,s as X,B as Z}from"./index-CqYj0Wnc.js";import{m as j}from"./mana-rate-DO_0nFzU.js";import{b as Q}from"./buy-BAwpkHiu.js";import{b as ee,w as re,S as ae,G as te}from"./buy-gasless-CBgDMk_P.js";import{g as se}from"./authorizations-BV0VRJbP.js";import{i as ie}from"./errors-C3ieTqjz.js";import{E as ce}from"./ErrorNotice-C7soUjRV.js";const F=X(Z)`
|
|
2
|
+
flex: 1;
|
|
3
|
+
`;function K(e){if(ie(e))return t("errors.rejected");const d=(e.message??"").toLowerCase();return d.includes("insufficient")?t("marketCheckout.error.insufficient",{currency:w.name}):d.includes("not found")||d.includes("no active listing")||d.includes("404")?t("marketCheckout.error.soldOrRemoved"):d.includes("your own listing")?t("errors.cantBuyOwn"):t("marketCheckout.error.generic")}function de(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 fe({listing:e,rate:d,onClose:A,onSold:R}){const{session:i}=O(),{data:n,isError:B}=V(i),o=Y(),N=z(),[g,f]=h.useState("confirm"),[C,E]=h.useState(t("marketCheckout.lockingPrice")),[U,v]=h.useState(null),[a,W]=h.useState(null),l=h.useRef(null),G=Math.ceil(j(e.manaWei,d)/10);h.useEffect(()=>{let u=!1;if(!i){f("error"),v(t("buyModal.signInToCheckout"));return}return(async()=>{try{const s=await $(e.tradeId);if(!s)throw new Error("not found");if(D(s,i.address))throw new Error("You can't buy your own listing.");const k=j(e.manaWei,d);if(!Number.isFinite(k)||k<=0)throw new Error("price unavailable");const{credit:m,maxCreditedValue:T,usdCents:P}=await J(i.identity,k,e.tradeId);if(u){y(i.identity,[m.id]).catch(()=>{});return}l.current=m.id,W({trade:s,credit:m,maxCreditedValue:T,usdCents:P,credits:Math.ceil(P/10)}),E("")}catch(s){if(u)return;console.error("[market] authorize failed",s),p(q(s)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:M(s),value_usd:Math.round(j(e.manaWei,d))/100}),f("error"),v(K(s))}})(),()=>{u=!0,l.current&&i&&(y(i.identity,[l.current]).catch(()=>{}),l.current=null)}},[]);const x=!!a&&n!=null&&n.credits<a.credits;async function L(){if(!i||!a)return;if(x){p("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:a.credits,credits_balance:(n==null?void 0:n.credits)??0,shortfall:Math.max(0,a.credits-((n==null?void 0:n.credits)??0))}),y(i.identity,[a.credit.id]).catch(()=>{}),l.current=null,N("/credits");return}f("working"),v(null);let u=!1;try{E(t("marketCheckout.confirming"));const c={trade:a.trade,buyer:i.address,signer:i.signer,credits:[a.credit],maxCreditedValue:a.maxCreditedValue};let s;if(se())try{s=await ee(c),await re(s),u=!0}catch(m){if(m instanceof ae)u=!0;else if(m instanceof te)s=await Q(c);else throw m}else s=await Q(c);l.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:u,transaction_hash:s??null}),o.invalidateQueries({queryKey:["usd-balance"]}),o.invalidateQueries({queryKey:["detail-trade"]}),o.invalidateQueries({queryKey:["shop-item"]}),o.invalidateQueries({queryKey:["item-resales",e.contractAddress,e.itemId]}),o.invalidateQueries({queryKey:["shop-items"]}),o.invalidateQueries({queryKey:["catalog-items"]}),o.invalidateQueries({queryKey:["my-assets"]}),o.invalidateQueries({queryKey:["purchases"]});const k={items:[de(e)],txHash:s};N("/success",{state:k})}catch(c){console.error("[market] buy now failed",c),y(i.identity,[a.credit.id]).catch(()=>{}),l.current=null,p(q(c)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:M(c),value_usd:a.usdCents/100}),o.invalidateQueries({queryKey:["usd-balance"]}),v(K(c)),f("error");const s=(c.message??"").toLowerCase();(s.includes("not found")||s.includes("no active listing")||s.includes("404"))&&R()}}function I(){i&&a&&y(i.identity,[a.credit.id]).catch(()=>{}),l.current=null,A()}const _=g==="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:_?void 0:I,"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(b,{className:"mkt-modal__diamond"}),S(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(b,{className:"mkt-modal__diamond"}),S(G)]}),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(b,{className:"ccy-mark"})," ",H(n,B)]}):null,x?r.jsx("p",{className:"muted mkt-modal__note",children:t("marketCheckout.needMore",{currency:w.name})}):null,C&&g==="working"?r.jsx("p",{className:"muted mkt-modal__note",children:C}):null,r.jsx(ce,{message:U,className:"mkt-modal__note"}),r.jsxs("div",{className:"mkt-modal__actions",children:[r.jsx(F,{variant:"ghost",onClick:I,disabled:_,children:t("buyModal.cancel")}),r.jsx(F,{variant:"purple",onClick:()=>void L(),disabled:_||!a,children:_?t("marketCheckout.buying"):x?t("nav.getCredits",{currency:w.name}):t("marketCheckout.confirmPurchase")})]})]})]})}export{fe as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as Ce,b as Xe,r as d,j as t}from"./react-C51i12iP.js";import{s as i,F as s,I as C,m as et,t as r,u as tt,b as st,G as me,o as O,B as ot,A as D,j as nt,H as rt,g as at,J as it,E as lt,p as Ie,K as ct,L as dt}from"./index-
|
|
1
|
+
import{L as Ce,b as Xe,r as d,j as t}from"./react-C51i12iP.js";import{s as i,F as s,I as C,m as et,t as r,u as tt,b as st,G as me,o as O,B as ot,A as D,j as nt,H as rt,g as at,J as it,E as lt,p as Ie,K as ct,L as dt}from"./index-CqYj0Wnc.js";import{f as mt}from"./import-CAQj-dM2.js";import{P as pt,f as ut}from"./PrimaryListModal-C6oCKlmk.js";import{c as ft}from"./buy-BAwpkHiu.js";import{R as Q,C as xt,a as ht,F as yt,S as U,b as pe}from"./categories-B6F31f63.js";import{L as gt}from"./LoadMore-DieY8n7S.js";import{D as ue,F as fe,R as bt,a as wt,b as St,c as jt,d as $t,S as Ct,e as It,f as kt,g as vt,h as At,i as Et,j as Tt,k as Ft,C as Rt,l as _t,m as Ot,n as Lt,M as Pt}from"./Assets.styles-C6sIyjWO.js";import{u as zt}from"./useInfiniteGrid-C_eF7Ybb.js";import{E as H}from"./ErrorNotice-C7soUjRV.js";import{n as ke}from"./emotion-CSxEP8yM.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./mana-rate-DO_0nFzU.js";import"./index-HN6Rk25C.js";import"./trade-encoding-DML-9EOG.js";import"./authorizations-BV0VRJbP.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./errors-C3ieTqjz.js";import"./Tooltip-C07IWHCJ.js";i.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 4px;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as n,j as s,L as m}from"./react-C51i12iP.js";import{m as c,t,n as l,I as d,A as p,s as v,B as x}from"./index-
|
|
1
|
+
import{r as n,j as s,L as m}from"./react-C51i12iP.js";import{m as c,t,n as l,I as d,A as p,s as v,B as x}from"./index-CqYj0Wnc.js";import{L as h}from"./LoadMore-DieY8n7S.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";const u=v(x)`
|
|
2
2
|
margin-top: 12px;
|
|
3
3
|
`,r=24;function E(){c({title:t("nav.myFavorites"),noindex:!0});const a=l(e=>Object.values(e.items)),[i,o]=n.useState(r);return a.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx(d,{name:"heart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"favorites-empty__title",children:t("myFavorites.emptyTitle")}),s.jsx("p",{className:"muted",children:t("myFavorites.emptyBody")}),s.jsx(u,{as:m,to:"/assets",variant:"purple",children:t("notFound.cta")})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:t("nav.myFavorites")}),s.jsx("span",{className:"favorites__count",children:t("myFavorites.itemCount",{count:a.length})})]}),s.jsx("div",{className:"grid",children:a.slice(0,i).map(e=>s.jsx(p,{item:e},e.id))}),s.jsx(h,{hasNextPage:i<a.length,isFetching:!1,onLoadMore:()=>o(e=>e+r)})]})}export{E as MyFavorites};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-C51i12iP.js";import{m as s,t as o,I as e,B as a}from"./index-
|
|
1
|
+
import{j as t,L as n}from"./react-C51i12iP.js";import{m as s,t as o,I as e,B as a}from"./index-CqYj0Wnc.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";function c(){return s({title:o("seo.notFound.title"),noindex:!0}),t.jsxs("div",{className:"notfound","data-testid":"notfound",children:[t.jsx(e,{name:"cart",className:"notfound__ico"}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(a,{as:n,to:"/assets",variant:"purple",children:o("notFound.cta")})]})}export{c as NotFound,c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as A,M as O,b as U,v as q,t as a,C as B,B as _,e as v,q as F,j as k,J as Q,E as W,k as D}from"./index-
|
|
1
|
+
import{p as A,M as O,b as U,v as q,t as a,C as B,B as _,e as v,q as F,j as k,J as Q,E as W,k as D}from"./index-CqYj0Wnc.js";import{d as w}from"./dcl-schemas-BICTSpB5.js";import{u as G,r as m,j as s}from"./react-C51i12iP.js";import{i as J,e as K,c as H}from"./trade-encoding-DML-9EOG.js";import{f as V}from"./errors-C3ieTqjz.js";import{E as X}from"./ErrorNotice-C7soUjRV.js";const N=()=>`${A.builderServerUrl}/v1`;function P(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function E(e,r){const t=await O(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const n=await t.json();return n.data??n}function Y(e,r){const t=r-e;return t>0?t:0}function z(e){var r,t,n,i,l;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(n=e.data)==null?void 0:n.emote)==null?void 0:i.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function I(e){return`${N()}/storage/contents/${e}`}function f(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?I(t):/^(ba|Qm)/.test(e)?I(e):""}async function Z(e,r){try{const t=await fetch(`${N()}/items/${e}/${r}/contents`);if(!t.ok)return{};const n=await t.json();return n.data??n}catch{return{}}}async function ee(e,r,t){const n=f(e.thumbnail,e.contents)||f("thumbnail.png",e.contents);if(n)return n;if(r&&t){const i=await Z(r,t);return f(e.thumbnail,i)||f("thumbnail.png",i)||f("image.png",i)}return""}async function te(e,r){const t=`${N()}/${e.toLowerCase()}/collections?is_published=true`,n=await E(t,r);return P(n).filter(i=>i.is_published&&!!i.contract_address).map(i=>({id:i.id,name:i.name,contractAddress:i.contract_address.toLowerCase(),isPublished:i.is_published,isApproved:i.is_approved,minters:(i.minters??[]).map(l=>l.toLowerCase())}))}async function se(e,r){const t=`${N()}/collections/${e.id}/items`,n=await E(t,r);return(await Promise.all(P(n).map(async l=>{const b=l.rarity??"common",y=Number(l.total_supply??0)||0;let o;try{o=w.Rarity.getMaxSupply(b)}catch{o=0}const g=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:g,blockchainItemId:p,name:l.name,category:z(l),rarity:b,thumbnail:await ee(l,g,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Y(y,o),minters:e.minters}}))).filter(re)}function re(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function ue(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await se(i,r)}catch{return[]}}))).flat()}const ae=1e3*60*60*24*182;function me({item:e,session:r,onClose:t}){const n=U(),i=G(),[l,b]=m.useState("10"),[y,o]=m.useState(null),[g,p]=m.useState(null),[d,L]=m.useState(!1),[h,j]=m.useState(null),[C,$]=m.useState(null),x=A.chainId,S=q(r.providerType);m.useEffect(()=>{let c=!1;return(async()=>{try{const u=await J({contractAddress:e.contractAddress,chainId:x});c||j(u)}catch{c||j(!1)}})(),()=>{c=!0}},[e.contractAddress,x]);async function M(){p(null);const c=Number(l);if(!Number.isInteger(c)||c<=0){p(a("primaryList.errorWholeNumber"));return}L(!0);try{h||(o(a("primaryList.statusEnabling")),await K({signer:r.signer,contractAddress:e.contractAddress,chainId:x}),j(!0)),o(a("primaryList.statusPublishing"));const u=await H({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:w.Network.MATIC,chainId:x},usdPrice:c/10,uses:e.remainingSupply,expiresAtMs:Date.now()+ae});o(a("primaryList.statusFinishing")),await F(u,r.identity),o(null),$(c),k("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"primary",is_primary:!0}),Q.success(a("primaryList.toastOnSale",{name:e.name})),n.invalidateQueries({queryKey:["publishable-items"]}),n.invalidateQueries({queryKey:["collection-sale-state"]})}catch(u){W(u,{flow:"list_primary"}),k("Shop Listing Failed",{listing_type:"primary",error_code:D(u)}),p(V(u,a("primaryList.errorGeneric"))),o(null)}finally{L(!1)}}function T(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const R=d?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return C!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("primaryList.successTitle")}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("primaryList.listedFor")," ",s.jsxs("strong",{children:[s.jsx(B,{className:"ccy-mark"})," ",C]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(_,{variant:"purple",onClick:T,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("primaryList.publishTitle",{name:e.name})}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"muted small",children:a("primaryList.fromCollection",{collectionName:e.collectionName,count:e.remainingSupply})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("primaryList.priceLabel",{currency:v.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:c=>b(c.target.value),disabled:d})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:v.name,currencySingular:v.nameSingular})}),h===!1&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeConfirm",{collectionName:e.collectionName})}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeManaged",{collectionName:e.collectionName})}):h===!0&&!d?S?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyConfirm")}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyManaged")}):null,y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(X,{message:g}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(_,{variant:"ghost",onClick:t,disabled:d,children:a("primaryList.cancel")}),s.jsx(_,{onClick:()=>void M(),disabled:d||h===null,children:h===null?a("primaryList.checking"):R})]})]})})}export{me as P,ue as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as s,u as se,r as n,L as te}from"./react-C51i12iP.js";import{t as a,F as C,s as _,N as ae,m as ie,u as re,b as ne,I as E,B as F,J as R}from"./index-
|
|
1
|
+
import{j as s,u as se,r as n,L as te}from"./react-C51i12iP.js";import{t as a,F as C,s as _,N as ae,m as ie,u as re,b as ne,I as E,B as F,J as R}from"./index-CqYj0Wnc.js";import{u as oe,d as le,t as ce,L as de,i as B,a as v,s as me}from"./useStore-CGylzs4i.js";import{E as M}from"./ErrorNotice-C7soUjRV.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-30043904010.commit-d846220/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-30043904010.commit-d846220/assets/template-cover-2-Dni9s0i_.jpeg",ge=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ue,"../assets/creator-covers/template-cover-2.jpeg":pe}),h=Object.entries(ge).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>({name:i.split("/").pop(),url:d})),ve=ae`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v,u as k,j as s,N as w,r as p}from"./react-C51i12iP.js";import{u as y,m as b,t as e,v as C,C as f,w as A,x as S,p as g,s as B,B as I,y as L,e as E}from"./index-
|
|
1
|
+
import{a as v,u as k,j as s,N as w,r as p}from"./react-C51i12iP.js";import{u as y,m as b,t as e,v as C,C as f,w as A,x as S,p as g,s as B,B as I,y as L,e as E}from"./index-CqYj0Wnc.js";import{w as T,S as F}from"./buy-gasless-CBgDMk_P.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-w5dOkonM.js";import"./intl-CBcMB1D2.js";import"./authorizations-BV0VRJbP.js";import"./index-HN6Rk25C.js";import"./sendMetaTransaction-CiO3jI6F.js";import"./trade-encoding-DML-9EOG.js";const j=B(I)`
|
|
2
2
|
min-width: 160px;
|
|
3
3
|
text-align: center;
|
|
4
4
|
`,M=c=>new Promise(t=>setTimeout(t,c));function P(c,t){const[a,i]=p.useState(c?"pending":"confirmed"),m=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return p.useEffect(()=>{if(!c)return;let r=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!r;n++)try{await T(c,{timeoutMs:15e3}),h=!0;break}catch(d){if(d instanceof F)continue;r||i("failed");return}if(!r){if(!h){i("timed-out");return}if(!t){i("confirmed");return}i("indexing");for(let n=0;n<40&&!r;n++){if(await L(t.owner,t.contractAddress,t.itemId)){r||i("confirmed");return}await M(3e3)}r||i("timed-out")}})(),()=>{r=!0}},[c,m]),a}const R=g.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",W=g.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function V(){const{state:c}=v(),t=k(),{session:a}=y(),i=c==null?void 0:c.txHash,m=(c==null?void 0:c.items)??[],r=c!=null&&c.creditsAdded&&c.creditsAdded>0?c.creditsAdded:null,l=m[0],h=a!=null&&a.address&&(l!=null&&l.contractAddress)&&(l!=null&&l.itemId)?{owner:a.address,contractAddress:l.contractAddress,itemId:l.itemId}:null,n=P(c!=null&&c.settled?void 0:i,h);b({title:e("seo.success.title"),noindex:!0});const d=m;if(d.length===0)return s.jsx(w,{to:"/assets",replace:!0});const _=d[0],u=!!i&&C(a==null?void 0:a.providerType)?s.jsx("a",{className:"success__receipt",href:`${W}${i}`,target:"_blank",rel:"noreferrer",children:e("success.viewTransaction")}):null;return n!=="confirmed"?s.jsx("div",{className:"success",children:s.jsx("div",{className:"success__status",children:n==="pending"||n==="indexing"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),s.jsx("h1",{className:"success__title",children:n==="indexing"?e("success.finalizing"):e("success.processing")}),s.jsx("p",{className:"success__sub",children:n==="indexing"?s.jsxs(s.Fragment,{children:[e("success.indexingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.indexingAfter")]}):s.jsxs(s.Fragment,{children:[e("success.confirmingBefore")," ",d.length===1?s.jsx("strong",{children:_.name}):e("success.itemCount",{count:d.length})," ",e("success.confirmingAfter")]})}),u?s.jsx("div",{className:"success__links",children:u}):null]}):n==="timed-out"?s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.stillProcessingTitle")}),s.jsxs("p",{className:"success__sub",children:[e("success.timedOutBefore")," ",s.jsx("button",{className:"link",onClick:()=>t("/activity"),children:e("nav.activity")})," ",e("success.timedOutAfter")]}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsxs("div",{className:"success__actions",children:[s.jsx(j,{variant:"purple",onClick:()=>t("/activity"),children:e("success.viewActivity")}),s.jsx(j,{variant:"ghost",onClick:()=>t("/assets"),children:e("success.keepShopping")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"success__title",children:e("success.failedTitle")}),s.jsx("p",{className:"success__sub",children:e("success.failedBody")}),u?s.jsx("div",{className:"success__links",children:u}):null,s.jsx("div",{className:"success__actions",children:s.jsx(j,{variant:"purple",onClick:()=>t("/assets"),children:e("success.backToShop")})})]})})}):s.jsx("div",{className:"success",children:s.jsxs("div",{className:"success-done",children:[s.jsxs("div",{className:"success-banner",role:"status",children:[s.jsx("span",{className:"success-banner__check","aria-hidden":!0,children:s.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[s.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),s.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsxs("p",{className:"success-banner__text",children:[s.jsx("b",{children:e("success.bannerTitle")})," ",e("success.bannerBody")]})]}),s.jsxs("div",{className:"success-list",children:[r?s.jsxs("div",{className:"success-credits","data-testid":"success-credits",children:[s.jsx(f,{className:"success-credits__ico"}),s.jsxs("p",{className:"success-credits__text",children:[s.jsx("span",{className:"success-credits__amount",children:e("getCredits.creditsAmount",{credits:r,currency:E.name})})," ",s.jsx("span",{className:"success-credits__added",children:e("getCredits.creditsAdded")})]})]}):null,d.map((o,N)=>{const x=o.quantity??1;return s.jsxs("div",{className:"success-list__row",children:[N>0?s.jsx("span",{className:"success-list__divider","aria-hidden":!0}):null,s.jsxs("div",{className:"success-row",children:[s.jsxs("div",{className:"success-row__thumb",children:[o.thumbnail?s.jsx("img",{src:o.thumbnail,alt:""}):null,s.jsx("span",{className:"success-row__check","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:s.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),s.jsxs("div",{className:"success-row__info",children:[s.jsxs("div",{className:"success-row__name",title:o.name,children:[o.name||e("buyModal.itemFallback"),x>1?s.jsx("span",{className:"success-row__qty",children:e("cartCheckout.qty",{count:x})}):null]}),o.creator?s.jsx(A,{address:o.creator,className:"success-row__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"success-row__price",children:[s.jsx(f,{className:"success-row__price-ico"}),s.jsx("span",{children:S(o.priceCredits*x)})]})]})]},o.id)})]}),u?s.jsx("div",{className:"success__links success-done__receipt",children:u}):null,s.jsxs("div",{className:"success-ctas",children:[s.jsx("button",{className:"success-cta success-cta--ghost",onClick:()=>t("/my-assets"),children:e("success.myAssets")}),s.jsxs("a",{className:"success-cta success-cta--ruby",href:R,target:"_blank",rel:"noreferrer",children:[e("success.tryInWorld"),s.jsx("span",{className:"success-cta__jump","aria-hidden":!0,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:s.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})})}export{V as Success,V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-Dr_zn2DE.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
1
|
+
import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-D1LJTB8Q.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,j as c}from"./react-C51i12iP.js";import{s as d,F as r}from"./index-
|
|
1
|
+
import{r as e,j as c}from"./react-C51i12iP.js";import{s as d,F as r}from"./index-CqYj0Wnc.js";import{n as x}from"./emotion-CSxEP8yM.js";const h=d("span",x("block"))`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
4
4
|
${({block:t})=>t?"width: 100%;":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-w5dOkonM.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-C51i12iP.js";import{bd as Re}from"./index-
|
|
1
|
+
var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-w5dOkonM.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-C51i12iP.js";import{bd as Re}from"./index-CqYj0Wnc.js";import{a as te,g as re}from"./index-HN6Rk25C.js";import{c as q,e as be}from"./index-BkyeX6HG.js";import{s as Ie}from"./sendMetaTransaction-CiO3jI6F.js";import"./sentry-DKBoGDXH.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new be.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&ⅇ(c.global===c||c.window===c||c.self===c)&&(e=c);var l,b=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class tt{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{tt as TradeService};
|