@dcl/shop 0.1.0-29934929940.commit-6d4a894 → 0.1.0-29941568358.commit-de47e56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{AnimatedBackground-8hsGcQ0u.js → AnimatedBackground-cMeJUDnS.js} +1 -1
- package/assets/{Assets-zJP2dh8T.js → Assets-D4bmQvg2.js} +11 -11
- package/assets/{Assets.styles-BKTin871.js → Assets.styles-JIZQe0rQ.js} +1 -1
- package/assets/Authorizations-Bxum5Ckz.js +163 -0
- package/assets/Cart-pFVN5ROM.js +3 -0
- package/assets/{CircularProgress-CHG6tLju.js → CircularProgress-DVvK_YYJ.js} +3 -3
- package/assets/{Collection-Do5NXSU2.js → Collection-CCeBHPqN.js} +1 -1
- package/assets/{CollectionCarousel-BaRGhi3w.js → CollectionCarousel-CfEwak3h.js} +1 -1
- package/assets/{ContentClient-BjQkITL0.js → ContentClient-DWUTshFt.js} +1 -1
- package/assets/{Creator-JDFZfL5s.js → Creator-DyLgE_Lq.js} +1 -1
- package/assets/{CssVarsProvider-ClB453yI.js → CssVarsProvider-CaTQjQty.js} +3 -3
- package/assets/{DeploymentBuilder-D-b1kMax.js → DeploymentBuilder-BeZK0qfR.js} +1 -1
- package/assets/{ExchangeController-gNB3kOET.js → ExchangeController-ZePEIh3m.js} +1 -1
- package/assets/{GetCredits--2sG2kUu.js → GetCredits-BcaMNIRG.js} +1 -1
- package/assets/{HelpersUtil-ChCAjTFl.js → HelpersUtil-CRTK_83W.js} +1 -1
- package/assets/{ImportListings-Dx4tRkPi.js → ImportListings-9YfzHduB.js} +2 -2
- package/assets/ItemDetail-BSqp8w-l.js +78 -0
- package/assets/{LoadMore-DEqrabJR.js → LoadMore-BK9c312B.js} +1 -1
- package/assets/{MarketCheckout-BhoJ5oaY.js → MarketCheckout-BxM5rUvM.js} +1 -1
- package/assets/{MyAssets-Dml_XsHc.js → MyAssets-BA5zCiVR.js} +2 -2
- package/assets/{MyFavorites-DCK1vo8d.js → MyFavorites-DWjt5m8Z.js} +1 -1
- package/assets/{MyPurchases-CCC9vTm6.js → MyPurchases--MUfwO_U.js} +5 -5
- package/assets/{NotFound-C9MQxOVj.js → NotFound-DVZ9W5Hr.js} +1 -1
- package/assets/PrimaryListModal-CQHoY5iG.js +1 -0
- package/assets/{StoreSettings-CCWCDTh_.js → StoreSettings-CpeZPPkb.js} +2 -2
- package/assets/{Success-BDwtV9vp.js → Success-CxrAGNmd.js} +3 -3
- package/assets/{SwapController-CUDA5nJJ.js → SwapController-BH4rWo6P.js} +1 -1
- package/assets/{Tooltip-CmUV5INZ.js → Tooltip-zazDSBbm.js} +1 -1
- package/assets/{TradeService-DLK4MfJ6.js → TradeService-IuqYxWb8.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-_Jupf0lQ.js → W3MFrameProviderSingleton-CFGfbV9-.js} +3 -3
- package/assets/{WebCryptoP256-DUqSrnE5.js → WebCryptoP256-ByM1YcL4.js} +1 -1
- package/assets/authorizations-CsduRV0X.js +1 -0
- package/assets/{basic--d_dy4i5.js → basic-BMJtBJ3f.js} +1 -1
- package/assets/{biconomy-B3E5v_ox.js → biconomy-WqxLiteU.js} +1 -1
- package/assets/buy-CN2rC9a0.js +1 -0
- package/assets/buy-gasless-iZXsoGZN.js +1 -0
- package/assets/{cart-checkout-DAncfmAA.js → cart-checkout-CLMqKMCz.js} +1 -1
- package/assets/{categories-BxHDtlRd.js → categories-D7_Qudaw.js} +1 -1
- package/assets/{ccip-DvIxb239.js → ccip-Be5Dn1Zo.js} +1 -1
- package/assets/{ccip-B6LXrSMV.js → ccip-DLXgNS3N.js} +1 -1
- package/assets/collection-DbmjhyjW.js +1 -0
- package/assets/{controller-Bn7Z9_r0.js → controller-CDv5xjYs.js} +2 -2
- package/assets/{core-BBJz894Q.js → core-B1vdvz8J.js} +4 -4
- package/assets/{custom-1kg7ng5l.js → custom-3-JWbHeB.js} +1 -1
- package/assets/{data-capture-ChI8n4xx.js → data-capture-B9u0j-_M.js} +1 -1
- package/assets/{email-CMJpr-fW.js → email-Bu0wLP5a.js} +1 -1
- package/assets/{embedded-wallet-ggb_52HF.js → embedded-wallet-DALUv36Z.js} +1 -1
- package/assets/emotion-styled.browser.esm-rI_2ZiJm.js +1 -0
- package/assets/{engine-D1X0lXh5.js → engine-COZjF6GN.js} +1 -1
- package/assets/{errors-DGvmy-zZ.js → errors-BuvqNt2H.js} +1 -1
- package/assets/{estimate-l1-fee-CIJA48wh.js → estimate-l1-fee-y9SYh7nZ.js} +1 -1
- package/assets/{ethers-CeDRuWE-.js → ethers-Dpp9c5As.js} +1 -1
- package/assets/{execute-CLaVApj9.js → execute-DVE3v1AF.js} +2 -2
- package/assets/{features-DIxQMYhX.js → features-CqkOcXXU.js} +1 -1
- package/assets/{fetchTokenMetadata-DK5hE0wQ.js → fetchTokenMetadata-CZAPbDmS.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-D6mzdR0G.js → get-ecosystem-wallet-info-CSMzgHAT.js} +1 -1
- package/assets/{getBalance-BzFjlu9G.js → getBalance-BawNMn6h.js} +1 -1
- package/assets/{getNFT-C8_Ym6i8.js → getNFT-BnfoPCmO.js} +1 -1
- package/assets/{getNFT-B8L91SOg.js → getNFT-yjjewJwo.js} +1 -1
- package/assets/{getOverlayAlpha-DEiIzOVP.js → getOverlayAlpha-DAstUi74.js} +1 -1
- package/assets/{hashTypedData-30Jlq8db.js → hashTypedData-CKhs32SE.js} +1 -1
- package/assets/{hashTypedData-D6R8yQIx.js → hashTypedData-Cb3dj8Vj.js} +1 -1
- package/assets/import-D2QUSpyp.js +1 -0
- package/assets/{in-app-CUkhWh_L.js → in-app-Dy6198Ub.js} +1 -1
- package/assets/{in-app-wallet-calls-Cxpe1Bwc.js → in-app-wallet-calls-Df8xMcoL.js} +1 -1
- package/assets/{index-BOt9Opm-.js → index-4DPFDe86.js} +1 -1
- package/assets/{index-wFtyEdaH.js → index-85kWMWjg.js} +1 -1
- package/assets/{index-DjwEMK3G.js → index-B0SpA1TA.js} +1 -1
- package/assets/{index-BdwR3G_d.js → index-B4Jw07i3.js} +1 -1
- package/assets/{index-CKovnqJP.js → index-B83hIo9e.js} +1 -1
- package/assets/{index-QETV6gE_.js → index-BCWp_6cV.js} +1 -1
- package/assets/{index-CRFpqXcH.js → index-BDN6djsw.js} +1 -1
- package/assets/{index-B3CMW_Rz.js → index-BItUV6PM.js} +1 -1
- package/assets/{index-B9qeAesl.js → index-BIulqLQL.js} +1 -1
- package/assets/{index-BmdP7fOj.js → index-BPKqBTdV.js} +1 -1
- package/assets/{index-BokebKeP.js → index-BRKyx7oU.js} +2 -2
- package/assets/{index-5irkjtJp.js → index-BRNsIe3m.js} +1 -1
- package/assets/{index-DirIOdjz.js → index-BcuysZka.js} +1 -1
- package/assets/{index-Cx_FuvLh.js → index-BhfJUYAQ.js} +1 -1
- package/assets/{index-Cgap8AUD.js → index-Bi4zgWjQ.js} +2 -2
- package/assets/{index-B3xOzx6X.js → index-BlBcCTXj.js} +1 -1
- package/assets/{index-C50s7O-g.js → index-BmlDboHr.js} +3 -3
- package/assets/{index-DszuXHRO.js → index-BsI3EWcy.js} +1 -1
- package/assets/{index-tRqsza9O.js → index-BzcxFNUz.js} +1 -1
- package/assets/{index-Bf4Q_PCL.js → index-C2-W1jZ1.js} +1 -1
- package/assets/{index-DUZmU_0S.js → index-C2ZtkYpB.js} +2 -2
- package/assets/{index-Dpmkxp94.js → index-CEhWolV_.js} +1 -1
- package/assets/{index-BWGviuYS.js → index-CIHaBruC.js} +1 -1
- package/assets/{index-BVi1IXaN.js → index-CIfdS8Db.js} +1 -1
- package/assets/{index-1gQN_kvx.js → index-CJRmkopy.js} +3 -3
- package/assets/{index-DkYtNpvt.js → index-CNpvozfL.js} +1 -1
- package/assets/{index-Dj-dQr5B.js → index-CPs7rZSr.js} +1 -1
- package/assets/{index-fBrY7bRL.js → index-CRSMETpm.js} +1 -1
- package/assets/{index-DHAMkmn9.js → index-CXgtaw1w.js} +1 -1
- package/assets/{index-DoH_srP9.js → index-CaOpng6c.js} +1 -1
- package/assets/{index-DKroPvyy.js → index-CbxN7Krq.js} +1 -1
- package/assets/{index-OEC5-urT.js → index-Cnmgw5PF.js} +1 -1
- package/assets/{index-CKN3JhVe.js → index-Ct22HWuE.js} +1 -1
- package/assets/{index-Cj2-8UH4.js → index-Cz1Suly9.js} +1 -1
- package/assets/{index-BbFU3LoB.js → index-D0xvd_Dp.js} +2 -2
- package/assets/{index-w1ulQg_8.js → index-D8me2ig5.js} +1 -1
- package/assets/{index-Dl9hHOZJ.js → index-DIGUl9iX.js} +1 -1
- package/assets/{index-DUkzcHbX.js → index-DIpMchso.js} +1 -1
- package/assets/{index-CWbN9Peg.js → index-DP9-yadx.js} +1 -1
- package/assets/{index-CecrsNSC.js → index-DPTvpJzS.js} +1 -1
- package/assets/{index-BEaNsXM-.js → index-DPp2bhUs.js} +1 -1
- package/assets/{index-DtQgf-Kz.js → index-D_Osq35D.js} +1 -1
- package/assets/{index-M9Lpp4iE.js → index-DgYBZU4A.js} +1 -1
- package/assets/{index-CDE1OoEd.js → index-DlvbN_Av.js} +1 -1
- package/assets/{index-CfF05W5R.js → index-DoaLV6gK.js} +1 -1
- package/assets/{index-Csh4ZzC9.js → index-DoxUiIoZ.js} +3 -3
- package/assets/{index-Drt6Trho.js → index-DtYBJNaS.js} +1 -1
- package/assets/{index-ZeJG5A5O.js → index-FFhK2B90.js} +1 -1
- package/assets/{index-ytKJv8_W.js → index-HRvlJsjj.js} +1 -1
- package/assets/{index-BpHVmfrg.js → index-Tfh0IyJl.js} +1 -1
- package/assets/{index-B8IbHKn5.js → index-V0hMC6mZ.js} +28 -28
- package/assets/{index-CAp_8XyK.js → index-V1lpWoC-.js} +1 -1
- package/assets/{index-ChE7SRyt.js → index-cA2ARKGJ.js} +1 -1
- package/assets/{index-MzkyVebZ.js → index-cjI3Jxw7.js} +1 -1
- package/assets/{index-CDcigD9G.js → index-kbFINusp.js} +1 -1
- package/assets/{index-BFk4WfKV.js → index-rFCcyY0H.js} +1 -1
- package/assets/{index-BxGv3iyo.js → index-sN6H-jhd.js} +1 -1
- package/assets/{index-Bl_PDUbW.js → index-uTPBgRyq.js} +3 -3
- package/assets/{index.es-BOjaJD0O.js → index.es-BqAU2pak.js} +4 -4
- package/assets/{index.es-CeNIgyNC.js → index.es-C7FJOZk9.js} +1 -1
- package/assets/{index.es-CnHhHSCq.js → index.es-DLc2fyYi.js} +1 -1
- package/assets/{localBatchGatewayRequest-CnXU2N0v.js → localBatchGatewayRequest-aE453fG9.js} +1 -1
- package/assets/{mana-rate-Z0fOAnP4.js → mana-rate-CFrZfrxV.js} +1 -1
- package/assets/{networks-DRRFntRj.js → networks-DYw-qqg1.js} +1 -1
- package/assets/{onramp-YOrhAP08.js → onramp-Dv5XffT1.js} +1 -1
- package/assets/{openzeppelin-DLbYMZrj.js → openzeppelin-DY9zonpF.js} +1 -1
- package/assets/{parseNft-BAtiT6yX.js → parseNft-BoqFzz1w.js} +2 -2
- package/assets/{parseSignature-z0AWZvnA.js → parseSignature-DLqUl44D.js} +1 -1
- package/assets/{parseSignature-DsA9O_Ak.js → parseSignature-_8ci0C1c.js} +3 -3
- package/assets/{passkeys-BTHsRkfl.js → passkeys-9jKCllXJ.js} +1 -1
- package/assets/{pay-with-exchange-yHyBBgyM.js → pay-with-exchange-q2w3TOV5.js} +1 -1
- package/assets/{qr-overlay-BH--1hn8.js → qr-overlay-kE0-Tb5Q.js} +1 -1
- package/assets/{receive-CjGVww72.js → receive-BlDcpWqy.js} +1 -1
- package/assets/{resolveImplementation-BKCjssN2.js → resolveImplementation-u5UN_seG.js} +1 -1
- package/assets/{rpc-UlD1Yufg.js → rpc-hzBSsIuq.js} +1 -1
- package/assets/{secp256k1-BrTQvA4F.js → secp256k1-CIm5iUJu.js} +1 -1
- package/assets/{secp256k1-BHkDM-tH.js → secp256k1-D_XLFIAD.js} +1 -1
- package/assets/{secp256k1-WljeVDsw.js → secp256k1-DogjvjtS.js} +1 -1
- package/assets/{send-tO6EhaL3.js → send-33Lvo35v.js} +1 -1
- package/assets/{send-batch-transaction-Cc9JRr38.js → send-batch-transaction-DxqLfBgo.js} +1 -1
- package/assets/{send-eip712-transaction-D5PSVDu-.js → send-eip712-transaction-BWi3gkm3.js} +2 -2
- package/assets/{send-gasless-transaction-Dqcv_ITl.js → send-gasless-transaction-CC-pEfDw.js} +2 -2
- package/assets/{send-transaction-cYs7CC0Z.js → send-transaction-DN1HyeTa.js} +2 -2
- package/assets/{sendRawTransaction-CITbtRC7.js → sendRawTransaction-DqtJOwfz.js} +3 -3
- package/assets/{serializeTransaction-Btmy4ifh.js → serializeTransaction-DOUpHqmp.js} +1 -1
- package/assets/{session-proposal-DrRYiiTl.js → session-proposal-BtkIO7cP.js} +1 -1
- package/assets/{session-request-D0sRJfkf.js → session-request-lsymM3l6.js} +2 -2
- package/assets/{signing-pcucBOUB.js → signing-Bskb_x4I.js} +3 -3
- package/assets/{socials-CGjqIEg_.js → socials-BrDjbXdD.js} +1 -1
- package/assets/{swaps-BphZ398u.js → swaps-BcWPrBSV.js} +1 -1
- package/assets/{thirdweb-DUgg8d6T.js → thirdweb-Cpf8EN89.js} +3 -3
- package/assets/{to-serializable-transaction-s-pMi3iV.js → to-serializable-transaction-gyjNAfk6.js} +2 -2
- package/assets/trade-encoding-vTSEXgN1.js +1 -0
- package/assets/{transactionReceipt-B-qhqvkt.js → transactionReceipt-Bum6hzjL.js} +1 -1
- package/assets/{transactions-CSSZ1Uj-.js → transactions-D-Z-vxC7.js} +1 -1
- package/assets/{useCreditPacks-Z0vJvkTc.js → useCreditPacks-BJp5mEnq.js} +1 -1
- package/assets/{useInfiniteGrid-CcAnLcIW.js → useInfiniteGrid-COXciuKu.js} +1 -1
- package/assets/{useStore-DuXZRHKD.js → useStore-cTXMZhwG.js} +2 -2
- package/assets/useTheme-Cv3anIxV.js +1 -0
- package/assets/{useTheme-BaXPBxeY.js → useTheme-DmdtRbZb.js} +1 -1
- package/assets/{verifyHash-CSuvCpxH.js → verifyHash-DOsO5RNA.js} +1 -1
- package/assets/{w3m-modal-Bm4Jot-v.js → w3m-modal-D1Pu_W_3.js} +1 -1
- package/assets/{w3m-modal-BKgYOmDm.js → w3m-modal-oBw-UuhI.js} +1 -1
- package/assets/{wait-for-tx-receipt-CigZhA8t.js → wait-for-tx-receipt-BYt5Gcy_.js} +1 -1
- package/assets/{wallets-DEGbSfsr.js → wallets-uu9PjeR0.js} +5 -5
- package/assets/{web-connector-BVqUWfCL.js → web-connector-Vwf5Urnw.js} +3 -3
- package/assets/{writeContract-CyscURCL.js → writeContract-iaip-T2H.js} +1 -1
- package/assets/{zoraTestnet-DteZMy6Z.js → zoraTestnet-EJHbKpn0.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Cart-KI1ErU7i.js +0 -3
- package/assets/ItemDetail-DqyfPCJF.js +0 -78
- package/assets/PrimaryListModal-5yw3HjxR.js +0 -1
- package/assets/buy-DcrAdUpx.js +0 -1
- package/assets/buy-gasless-b-y-A9B0.js +0 -1
- package/assets/collection-ChguPkSb.js +0 -1
- package/assets/emotion-styled.browser.esm-wTpuh9_1.js +0 -1
- package/assets/import-DwFR83oQ.js +0 -1
- package/assets/useTheme-efxsW9nt.js +0 -1
- package/assets/wallet-kind-D0r-Cmku.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as ve,a as Ze,r as c,j as t}from"./react-BMZSDQJw.js";import{s as a,y as s,I as j,u as Je,t as r,g as Xe,j as et,z as pe,e as K,B as tt,A as N,q as ue,D as st,f as ot,E as nt,x as rt,c as at,F as it}from"./index-
|
|
1
|
+
import{L as ve,a as Ze,r as c,j as t}from"./react-BMZSDQJw.js";import{s as a,y as s,I as j,u as Je,t as r,g as Xe,j as et,z as pe,e as K,B as tt,A as N,q as ue,D as st,f as ot,E as nt,x as rt,c as at,F as it}from"./index-V0hMC6mZ.js";import{f as lt}from"./import-D2QUSpyp.js";import{S as ct,P as dt,f as mt}from"./PrimaryListModal-CQHoY5iG.js";import{c as pt}from"./buy-CN2rC9a0.js";import{R as G,C as ut,a as ft,F as xt,S as D,b as fe}from"./categories-D7_Qudaw.js";import{L as ht}from"./LoadMore-BK9c312B.js";import{D as xe,F as he,R as yt,a as gt,b as bt,c as St,d as wt,S as jt,e as $t,f as Ct,g as It,h as vt,i as kt,j as At,k as Et,C as Tt,l as Ft,m as Rt,n as _t,M as Lt}from"./Assets.styles-JIZQe0rQ.js";import{u as Ot}from"./useInfiniteGrid-COXciuKu.js";import{E as Q}from"./ErrorNotice-DDr3KjIH.js";import{n as ke}from"./emotion-CSxEP8yM.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.js";import"./intl-CBcMB1D2.js";import"./mana-rate-CFrZfrxV.js";import"./index-HN6Rk25C.js";import"./trade-encoding-vTSEXgN1.js";import"./authorizations-CsduRV0X.js";import"./errors-BuvqNt2H.js";import"./Tooltip-zazDSBbm.js";a.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 4px;
|
|
@@ -255,4 +255,4 @@ import{L as ve,a as Ze,r as c,j as t}from"./react-BMZSDQJw.js";import{s as a,y a
|
|
|
255
255
|
color: ${s.colors.accent};
|
|
256
256
|
text-transform: uppercase;
|
|
257
257
|
letter-spacing: 0.046em;
|
|
258
|
-
`,Vt=48,je=[{key:"wearables",labelKey:"myAssets.sectionWearables",category:"wearable"},{key:"emotes",labelKey:"myAssets.sectionEmotes",category:"emote"},{key:"names",labelKey:"myAssets.sectionNames",category:"ens"},{key:"creations",labelKey:"myAssets.sectionCreations"}],U=[{key:"newest",label:"filterBar.sortNewest",server:"newest"},{key:"name",label:"filterBar.sortName",server:"name"},{key:"cheapest",label:"filterBar.sortCheapest",server:"cheapest"}];function $e(o){return o==="wearables"||o==="emotes"}const Ce={wearables:"wearable",emotes:"emote",names:"names",creations:""},Zt={wearable:"wearables",emote:"emotes",names:"names"};function Ie(o){return{id:o.id,name:o.name,creator:"",contractAddress:o.contractAddress,itemId:o.itemId,category:o.category,rarity:o.rarity??"common",network:o.network,chainId:o.chainId,thumbnail:o.image,priceCredits:o.listingPrice??0,gender:null,isSmart:!1,tokenId:o.tokenId,issuedId:o.issuedId}}function Jt(o,T=0){return{id:`${o.contractAddress}-${o.blockchainItemId}`,name:o.name,creator:"",contractAddress:o.contractAddress,itemId:o.blockchainItemId,category:o.category,rarity:o.rarity,network:"MATIC",chainId:at.chainId,thumbnail:o.thumbnail,priceCredits:T,gender:null,isSmart:!1}}function
|
|
258
|
+
`,Vt=48,je=[{key:"wearables",labelKey:"myAssets.sectionWearables",category:"wearable"},{key:"emotes",labelKey:"myAssets.sectionEmotes",category:"emote"},{key:"names",labelKey:"myAssets.sectionNames",category:"ens"},{key:"creations",labelKey:"myAssets.sectionCreations"}],U=[{key:"newest",label:"filterBar.sortNewest",server:"newest"},{key:"name",label:"filterBar.sortName",server:"name"},{key:"cheapest",label:"filterBar.sortCheapest",server:"cheapest"}];function $e(o){return o==="wearables"||o==="emotes"}const Ce={wearables:"wearable",emotes:"emote",names:"names",creations:""},Zt={wearable:"wearables",emote:"emotes",names:"names"};function Ie(o){return{id:o.id,name:o.name,creator:"",contractAddress:o.contractAddress,itemId:o.itemId,category:o.category,rarity:o.rarity??"common",network:o.network,chainId:o.chainId,thumbnail:o.image,priceCredits:o.listingPrice??0,gender:null,isSmart:!1,tokenId:o.tokenId,issuedId:o.issuedId}}function Jt(o,T=0){return{id:`${o.contractAddress}-${o.blockchainItemId}`,name:o.name,creator:"",contractAddress:o.contractAddress,itemId:o.blockchainItemId,category:o.category,rarity:o.rarity,network:"MATIC",chainId:at.chainId,thumbnail:o.thumbnail,priceCredits:T,gender:null,isSmart:!1}}function Ss(){var ce,de;Je({title:r("nav.myAssets"),noindex:!0});const{session:o,error:T,signIn:Ae,restore:H}=Xe(),F=et(),[Ee,Te]=Ze(),W=Ee.get("section"),l=je.some(e=>e.key===W)?W:"wearables",[m,R]=c.useState("all"),[h,_]=c.useState([]),[p,$]=c.useState(null),[S,Fe]=c.useState("newest"),[C,Y]=c.useState(""),[y,Re]=c.useState(""),[I,g]=c.useState(!1),[_e,Le]=c.useState(!0),[Oe,Pe]=c.useState(!1),[V,Z]=c.useState(null),[J,X]=c.useState(null),[ee,te]=c.useState(null),[ze,se]=c.useState(null);c.useEffect(()=>{H()},[H]),c.useEffect(()=>{const e=setTimeout(()=>Re(C.trim()),300);return()=>clearTimeout(e)},[C]),c.useEffect(()=>{if(!I)return;const e=i=>{i.key==="Escape"&&g(!1)};document.addEventListener("keydown",e);const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",e),document.body.style.overflow=n}},[I]);const u=o==null?void 0:o.address,Be=je.find(e=>e.key===l),v=$e(l),oe=(U.find(e=>e.key===S)??U[0]).server,Me=m==="on_sale"?r("filter.onSale"):m==="not_for_sale"?r("filter.notForSale"):"",qe=G.filter(e=>h.includes(e)).map(pe).join(", ");function ne(e){Te(n=>{const i=new URLSearchParams(n);return i.set("section",e),i},{replace:!0}),$(null),$e(e)||_([]),g(!1)}function re(e){_(n=>n.includes(e)?n.filter(i=>i!==e):[...n,e])}function Ke(e){const n=Zt[e];n&&ne(n)}const{items:L,total:Ne,isLoading:O,isPlaceholderData:P,error:Ge,hasNextPage:De,isFetchingNextPage:ae,fetchNextPage:Qe}=Ot(["my-assets",u,l,m,h,p,y,oe],e=>st(u,{category:Be.category,first:Vt,skip:e,search:y||void 0,rarities:v&&h.length?h:void 0,wearableCategories:l==="wearables"&&p?fe[p]:void 0,emoteCategories:l==="emotes"&&p?fe[p]:void 0,onlyOnSale:m==="on_sale"||void 0,sortBy:oe}).then(n=>({items:n.assets,total:n.total})),{enabled:!!u&&l!=="creations"}),z=c.useMemo(()=>m==="not_for_sale"?L.filter(e=>!e.isOnSale):L,[L,m]),{data:k,isLoading:B,isError:Ue}=K({queryKey:["publishable-items",u],queryFn:()=>mt(u,o.identity),enabled:!!o&&l==="creations",retry:!1}),M=c.useMemo(()=>[...new Set((k??[]).map(e=>e.contractAddress))],[k]),{data:A}=K({queryKey:["collection-sale-state",u,M],enabled:M.length>0,queryFn:async()=>{const e=await Promise.all(M.map(async i=>[i,await it(i)])),n={};for(const[i,d]of e)for(const[f,x]of Object.entries(d))n[`${i}-${f}`]=x;return n}}),w=e=>A==null?void 0:A[`${e.contractAddress}-${e.blockchainItemId}`],q=c.useMemo(()=>{let e=k??[];if(m==="on_sale"?e=e.filter(i=>{var d;return(d=w(i))==null?void 0:d.isOnSale}):m==="not_for_sale"&&(e=e.filter(i=>{var d;return!((d=w(i))!=null&&d.isOnSale)})),y){const i=y.toLowerCase();e=e.filter(d=>d.name.toLowerCase().includes(i))}const n=[...e];return S==="name"?n.sort((i,d)=>i.name.localeCompare(d.name)):S==="cheapest"&&n.sort((i,d)=>{var f,x;return(((f=w(i))==null?void 0:f.priceCredits)??0)-(((x=w(d))==null?void 0:x.priceCredits)??0)}),n},[k,A,m,y,S]),{data:b}=K({queryKey:["importable",u],queryFn:()=>lt(u),enabled:!!u}),ie=((b==null?void 0:b.creations.length)??0)+((b==null?void 0:b.owned.length)??0);async function le(e,n,i){if(o){se(null),te(i);try{const d=await ot(e);await pt({trade:d,signer:o.signer}),nt.success(r("myAssets.removedFromSale",{name:n})),await F.invalidateQueries({queryKey:["my-assets",o.address]}),await F.invalidateQueries({queryKey:["collection-sale-state"]}),await F.invalidateQueries({queryKey:["publishable-items"]})}catch(d){const f=d,x=(f.message??"").toLowerCase(),me=f.code===4001||x.includes("reject")||x.includes("denied");me||rt(d,{flow:"remove-listing",tradeId:e}),se(me?r("getCredits.errorCanceled"):r("myAssets.removeListingError"))}finally{te(null)}}}if(!o)return t.jsxs(Nt,{children:[t.jsx(Gt,{children:r("nav.myAssets")}),t.jsx(Dt,{children:r("myAssets.signInPrompt")}),t.jsx(tt,{variant:"purple",onClick:()=>Ae(),children:r("storeSettings.signIn")}),t.jsx(Q,{message:T})]});const He=l==="creations"?B:O||P,We=l==="creations"?q.length:m==="not_for_sale"?z.length:Ne,E=[];if(m!=="all"&&E.push({key:"status",label:m==="on_sale"?r("filter.onSale"):r("filter.notForSale"),onRemove:()=>R("all")}),v)for(const e of G)h.includes(e)&&E.push({key:`rarity-${e}`,label:pe(e),onRemove:()=>re(e)});if(v&&p){const e=(de=(ce=ut.find(n=>n.key===Ce[l]))==null?void 0:ce.subs)==null?void 0:de.find(n=>n.key===p);E.push({key:"sub",label:e?r(e.labelKey):p,onRemove:()=>$(null)})}function Ye(){R("all"),_([]),$(null)}const Ve=t.jsxs(t.Fragment,{children:[t.jsx(ft,{title:r("myAssets.assetsHeading"),category:Ce[l],subCategory:p,onCategory:Ke,onSub:$,onCollections:()=>ne("creations"),collections:l==="creations",extraLabelKey:"myAssets.sectionCreations",hideAll:!0}),v?t.jsxs(t.Fragment,{children:[t.jsx(xe,{}),t.jsx(he,{title:r("assets.rarity"),open:Oe,onToggle:()=>Pe(e=>!e),summary:qe,headerTestId:"sidebar-section-toggle",children:t.jsx(yt,{"data-testid":"rarity-filter",children:G.map(e=>{const n=h.includes(e);return t.jsxs(gt,{type:"button",selected:n,"aria-pressed":n,onClick:()=>re(e),"data-testid":"rarity-filter-check",children:[t.jsx(bt,{color:s.rarities[e],children:n?t.jsx(St,{name:"check","aria-hidden":!0}):null}),t.jsx(wt,{selected:n,children:e})]},e)})})})]}):null,t.jsx(xe,{}),t.jsx(he,{title:r("filter.status"),open:_e,onToggle:()=>Le(e=>!e),summary:Me,children:[["all",r("filter.statusAll")],["on_sale",r("filter.onSale")],["not_for_sale",r("filter.notForSale")]].map(([e,n])=>t.jsxs(jt,{children:[t.jsx($t,{type:"radio",name:"myassets-status",checked:m===e,onChange:()=>R(e)}),t.jsx(Ct,{children:n})]},e))})]});return t.jsxs(It,{"data-testid":"my-assets",children:[I?t.jsx(vt,{onClick:()=>g(!1),"aria-hidden":!0}):null,t.jsxs(kt,{className:I?"is-open":"","data-testid":"my-assets-sidebar",children:[t.jsxs(At,{children:[t.jsx(Et,{children:r("assets.filters")}),t.jsx(Tt,{onClick:()=>g(!1),"aria-label":r("assets.closeFilters"),children:"✕"})]}),t.jsx(Ft,{children:Ve}),t.jsx(Rt,{children:t.jsx(_t,{type:"button",onClick:()=>g(!1),children:r("assets.showItems")})})]}),t.jsxs(Lt,{children:[t.jsxs(Pt,{children:[t.jsx(zt,{name:"search","aria-hidden":!0}),t.jsx(Bt,{type:"search",value:C,placeholder:r("myAssets.searchPlaceholder"),"aria-label":r("myAssets.searchPlaceholder"),onChange:e=>Y(e.target.value)}),C?t.jsx(Mt,{type:"button","aria-label":r("myAssets.clearSearch"),onClick:()=>Y(""),children:t.jsx(qt,{name:"close","aria-hidden":!0})}):null]}),ie>0?t.jsxs(Qt,{to:"/import",children:[t.jsx("span",{"aria-hidden":!0,children:"📦"}),t.jsxs(Ut,{children:[t.jsx(Ht,{children:r("myAssets.importTitle")}),t.jsx(Wt,{children:r("myAssets.importSub",{count:ie})})]}),t.jsx(Yt,{children:r("myAssets.import")})]}):null,t.jsx(xt,{sort:S,onSort:Fe,sortOptions:U,total:We,loading:He,query:y,onOpenFilters:()=>g(!0),chips:E,onClearChips:Ye}),(l==="creations"?Ue:Ge)?t.jsx(Q,{message:r("myAssets.ownedError"),testId:"my-assets-error"}):null,t.jsx(Q,{message:ze}),l==="creations"?t.jsxs(t.Fragment,{children:[t.jsx(ye,{"data-testid":"grid",children:B?t.jsx(D,{count:12}):q.map(e=>{const n=w(e),i=!!(n!=null&&n.isOnSale);return t.jsx(N,{item:Jt(e,(n==null?void 0:n.priceCredits)??0),mode:"manage",listed:i,busy:ee===e.id,onList:()=>{ue("Shop Started Listing",{listing_type:"primary",item_id:e.blockchainItemId}),X(e)},onUnlist:()=>{n!=null&&n.tradeId&&le(n.tradeId,e.name,e.id)}},`${e.contractAddress}-${e.blockchainItemId}`)})}),!B&&q.length===0?t.jsxs(ge,{children:[t.jsx(be,{children:t.jsx(j,{name:"pen",size:30,"aria-hidden":!0})}),t.jsx(Se,{children:r("myAssets.emptyCreationsTitle")}),t.jsx(we,{children:r("myAssets.nothingToPublish")})]}):null]}):t.jsxs(t.Fragment,{children:[t.jsxs(ye,{"data-testid":"grid",children:[O||P?t.jsx(D,{count:12}):z.map(e=>l==="names"?t.jsx(N,{item:{...Ie(e),category:"ens"},mode:"view"},e.id):t.jsx(N,{item:Ie(e),mode:"manage",listed:e.isOnSale,busy:ee===e.id,onList:()=>{ue("Shop Started Listing",{listing_type:"secondary",item_id:e.itemId??e.tokenId??null}),Z(e)},onUnlist:()=>{e.tradeId&&le(e.tradeId,e.name,e.id)}},e.id)),ae?t.jsx(D,{count:6}):null]}),m!=="not_for_sale"?t.jsx(ht,{hasNextPage:De,isFetching:ae,onLoadMore:()=>void Qe()}):null,!O&&!P&&z.length===0?t.jsxs(ge,{children:[t.jsx(be,{children:t.jsx(j,{name:l==="names"?"website":l==="emotes"?"emote-dance":"cat-upper",size:30,"aria-hidden":!0})}),t.jsx(Se,{children:l==="names"?r("myAssets.emptyNamesTitle"):r("myAssets.emptyOwnedTitle")}),t.jsx(we,{children:l==="names"?r("myAssets.namesEmpty"):r("myAssets.ownedEmpty")}),l!=="names"?t.jsx(Kt,{to:"/assets",children:r("myAssets.emptyBrowse")}):null]}):null]})]}),V?t.jsx(ct,{asset:V,session:o,onClose:()=>Z(null)}):null,J?t.jsx(dt,{item:J,session:o,onClose:()=>X(null)}):null]})}export{Ss as MyAssets};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as n,j as s,L as m}from"./react-BMZSDQJw.js";import{u as c,t,a as l,I as d,A as p,s as v,B as x}from"./index-
|
|
1
|
+
import{r as n,j as s,L as m}from"./react-BMZSDQJw.js";import{u as c,t,a as l,I as d,A as p,s as v,B as x}from"./index-V0hMC6mZ.js";import{L as u}from"./LoadMore-BK9c312B.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.js";import"./intl-CBcMB1D2.js";const h=v(x)`
|
|
2
2
|
margin-top: 12px;
|
|
3
3
|
`,r=24;function E(){c({title:t("nav.myFavorites"),noindex:!0});const a=l(e=>Object.values(e.items)),[i,o]=n.useState(r);return a.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx(d,{name:"heart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"favorites-empty__title",children:t("myFavorites.emptyTitle")}),s.jsx("p",{className:"muted",children:t("myFavorites.emptyBody")}),s.jsx(h,{as:m,to:"/assets",variant:"purple",children:t("notFound.cta")})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:t("nav.myFavorites")}),s.jsx("span",{className:"favorites__count",children:t("myFavorites.itemCount",{count:a.length})})]}),s.jsx("div",{className:"grid",children:a.slice(0,i).map(e=>s.jsx(p,{item:e},e.id))}),s.jsx(u,{hasNextPage:i<a.length,isFetching:!1,onLoadMore:()=>o(e=>e+r)})]})}export{E as MyFavorites};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{j as e,L as y}from"./react-BMZSDQJw.js";import{s as i,B as w,y as r,
|
|
1
|
+
import{j as e,L as y}from"./react-BMZSDQJw.js";import{s as i,B as w,y as r,H as k,u as $,t as d,g as v,I as x,a4 as I,l as j,e as P,a5 as L}from"./index-V0hMC6mZ.js";import{L as N}from"./LoadMore-BK9c312B.js";import{u as E}from"./useInfiniteGrid-COXciuKu.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.js";import"./intl-CBcMB1D2.js";const T=15e3;function C(t,n){return t.txHash&&n.txHash?t.txHash===n.txHash:t.txHash||n.txHash?!1:t.status===n.status&&Math.abs(t.createdAt-n.createdAt)<=T}function D(t){const n=[...t].sort((s,o)=>o.createdAt-s.createdAt),a=[];for(const s of n){const o=a[a.length-1];o&&C(o[o.length-1],s)?o.push(s):a.push([s])}return a.map(s=>{var o;return{id:((o=s.find(c=>c.txHash))==null?void 0:o.txHash)??s[s.length-1].id,createdAt:Math.max(...s.map(c=>c.createdAt)),status:s.some(c=>c.status==="PENDING")?"PENDING":"SETTLED",totalCredits:s.reduce((c,u)=>c+u.credits,0),lines:s}})}function H(t){const n=[],a=new Map;for(const s of t)if(s.tradeId){const o=a.get(s.tradeId);if(o){o.quantity+=1,o.credits+=s.credits;continue}const c={key:s.tradeId,tradeId:s.tradeId,quantity:1,credits:s.credits};a.set(s.tradeId,c),n.push(c)}else n.push({key:s.id,tradeId:null,quantity:1,credits:s.credits});return n}const m=k`
|
|
2
2
|
0% { background-position: 200% 0; }
|
|
3
3
|
100% { background-position: -200% 0; }
|
|
4
|
-
`,
|
|
4
|
+
`,z=i.section`
|
|
5
5
|
width: 100%;
|
|
6
6
|
min-width: 0;
|
|
7
|
-
`,
|
|
7
|
+
`,A=i.div`
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: baseline;
|
|
10
10
|
gap: 12px;
|
|
11
11
|
margin-bottom: 20px;
|
|
12
|
-
`,
|
|
12
|
+
`,S=i.h1`
|
|
13
13
|
font-family: ${r.font.sans};
|
|
14
14
|
margin: 0;
|
|
15
15
|
`,q=i.span`
|
|
@@ -197,4 +197,4 @@ import{j as e,L as y}from"./react-BMZSDQJw.js";import{s as i,B as w,y as r,S as
|
|
|
197
197
|
margin: 6px 0 0;
|
|
198
198
|
`,te=i(w)`
|
|
199
199
|
margin-top: 12px;
|
|
200
|
-
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(F,{"data-testid":"purchase-order",children:[e.jsxs(G,{children:[e.jsxs(O,{children:[e.jsx(B,{children:re(t.createdAt)}),e.jsx(R,{children:d("myPurchases.itemCount",{count:a})})]}),e.jsxs(W,{children:[e.jsx(_,{"data-status":t.status,children:t.status==="PENDING"?d("myPurchases.processing"):d("myPurchases.completed")}),e.jsxs(U,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(K,{children:n.map(s=>e.jsx(ie,{item:s},s.key))})]})}function he(){$({title:d("nav.myPurchases"),noindex:!0});const{session:t}=v(),{items:n,isLoading:a,hasNextPage:s,isFetchingNextPage:o,fetchNextPage:c}=E(["purchases",t==null?void 0:t.address],l=>I(t.address,t.identity,{first:se,skip:l}),{enabled:!!t});if(!t)return e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.signInTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.signInBody")})]});const u=D(n.filter(l=>l.status!=="EXPIRED"));return!a&&u.length===0?e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.emptyTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.emptyBody")}),e.jsx(te,{as:y,to:"/assets",variant:"purple",children:d("notFound.cta")})]}):e.jsxs(
|
|
200
|
+
`,ne=b.withComponent(y),se=24;function re(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ie({item:t}){const{data:n,isLoading:a}=P({queryKey:["trade-display",t.tradeId],queryFn:()=>L(t.tradeId),enabled:!!t.tradeId,staleTime:3e5}),s=!!t.tradeId&&a,o=(n==null?void 0:n.name)??d("myPurchases.itemFallback"),c=(n==null?void 0:n.thumbnail)??"",u=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId)??"",l=n!=null&&n.contractAddress&&u?`/item/${n.contractAddress}/${u}`:void 0,p=e.jsxs(e.Fragment,{children:[s?e.jsx(X,{}):e.jsx(Q,{children:c?e.jsx("img",{src:c,alt:o}):e.jsx(x,{name:"cart",size:20})}),e.jsxs(Z,{children:[s?e.jsx(V,{}):e.jsx(J,{title:o,children:o}),t.quantity>1?e.jsx(Y,{children:d("myPurchases.quantity",{count:t.quantity})}):null]}),e.jsxs(ee,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.credits]})]});return l?e.jsx(ne,{to:l,"data-link":"true",children:p}):e.jsx(b,{children:p})}function oe({order:t}){const n=H(t.lines),a=n.reduce((s,o)=>s+o.quantity,0);return e.jsxs(F,{"data-testid":"purchase-order",children:[e.jsxs(G,{children:[e.jsxs(O,{children:[e.jsx(B,{children:re(t.createdAt)}),e.jsx(R,{children:d("myPurchases.itemCount",{count:a})})]}),e.jsxs(W,{children:[e.jsx(_,{"data-status":t.status,children:t.status==="PENDING"?d("myPurchases.processing"):d("myPurchases.completed")}),e.jsxs(U,{children:[e.jsx(j,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(K,{children:n.map(s=>e.jsx(ie,{item:s},s.key))})]})}function he(){$({title:d("nav.myPurchases"),noindex:!0});const{session:t}=v(),{items:n,isLoading:a,hasNextPage:s,isFetchingNextPage:o,fetchNextPage:c}=E(["purchases",t==null?void 0:t.address],l=>I(t.address,t.identity,{first:se,skip:l}),{enabled:!!t});if(!t)return e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.signInTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.signInBody")})]});const u=D(n.filter(l=>l.status!=="EXPIRED"));return!a&&u.length===0?e.jsxs(g,{children:[e.jsx(x,{name:"cart",size:40,color:"var(--muted-2)"}),e.jsx(f,{children:d("myPurchases.emptyTitle")}),e.jsx("p",{className:"muted",children:d("myPurchases.emptyBody")}),e.jsx(te,{as:y,to:"/assets",variant:"purple",children:d("notFound.cta")})]}):e.jsxs(z,{children:[e.jsxs(A,{children:[e.jsx(S,{children:d("nav.myPurchases")}),a?null:e.jsx(q,{children:d("myPurchases.orderCount",{count:u.length})})]}),e.jsx(M,{children:a?Array.from({length:3}).map((l,p)=>e.jsx(h,{},p)):e.jsxs(e.Fragment,{children:[u.map(l=>e.jsx(oe,{order:l},l.id)),o?e.jsx(h,{}):null]})}),e.jsx(N,{hasNextPage:s,isFetching:o,onLoadMore:()=>void c()})]})}export{he as MyPurchases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-BMZSDQJw.js";import{u as s,t as o,I as e,B as a}from"./index-
|
|
1
|
+
import{j as t,L as n}from"./react-BMZSDQJw.js";import{u as s,t as o,I as e,B as a}from"./index-V0hMC6mZ.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as w,a3 as K,j as M,t as a,l as P,B as f,C as j,p as E,q as C,E as $,x as T,r as O,J as H}from"./index-V0hMC6mZ.js";import{d as q}from"./dcl-schemas-BICTSpB5.js";import{u as F,r as m,j as s}from"./react-BMZSDQJw.js";import{a as J,b as X,i as V,e as Y,c as z}from"./trade-encoding-vTSEXgN1.js";import{f as R}from"./errors-BuvqNt2H.js";import{E as U}from"./ErrorNotice-DDr3KjIH.js";const I=()=>`${w.builderServerUrl}/v1`;function B(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 Q(e,r){const t=await K(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const l=await t.json();return l.data??l}function Z(e,r){const t=r-e;return t>0?t:0}function ee(e){var r,t,l,i,n;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(l=e.data)==null?void 0:l.emote)==null?void 0:i.category)??((n=e.data)==null?void 0:n.category)??e.type??"wearable"}function A(e){return`${I()}/storage/contents/${e}`}function S(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?A(t):/^(ba|Qm)/.test(e)?A(e):""}async function se(e,r){try{const t=await fetch(`${I()}/items/${e}/${r}/contents`);if(!t.ok)return{};const l=await t.json();return l.data??l}catch{return{}}}async function ae(e,r,t){const l=S(e.thumbnail,e.contents)||S("thumbnail.png",e.contents);if(l)return l;if(r&&t){const i=await se(r,t);return S(e.thumbnail,i)||S("thumbnail.png",i)||S("image.png",i)}return""}async function te(e,r){const t=`${I()}/${e.toLowerCase()}/collections?is_published=true`,l=await Q(t,r);return B(l).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(n=>n.toLowerCase())}))}async function re(e,r){const t=`${I()}/collections/${e.id}/items`,l=await Q(t,r);return(await Promise.all(B(l).map(async n=>{const x=n.rarity??"common",y=Number(n.total_supply??0)||0;let o;try{o=q.Rarity.getMaxSupply(x)}catch{o=0}const _=(n.contract_address??e.contractAddress).toLowerCase(),p=n.blockchain_item_id??"";return{id:n.id,collectionId:e.id,collectionName:e.name,contractAddress:_,blockchainItemId:p,name:n.name,category:ee(n),rarity:x,thumbnail:await ae(n,_,p),type:n.type??"wearable",isPublished:n.is_published??e.isPublished,isApproved:n.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Z(y,o),minters:e.minters}}))).filter(ie)}function ie(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function he(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await re(i,r)}catch{return[]}}))).flat()}const ne=1e3*60*60*24*182;function ye({asset:e,session:r,onClose:t}){const l=M(),i=F(),[n,x]=m.useState("10"),[y,o]=m.useState(null),[_,p]=m.useState(null),[u,N]=m.useState(!1),[h,v]=m.useState(null);async function k(){p(null);const c=Number(n);if(!Number.isInteger(c)||c<=0){p(a("sellModal.errorWholeNumber"));return}N(!0);try{o(a("sellModal.statusPreparing")),await J({signer:r.signer,contractAddress:e.contractAddress,chainId:e.chainId}),o(a("sellModal.statusListing"));const g=await X({signer:r.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:c/10,expiresAtMs:Date.now()+ne});o(a("sellModal.statusPublishing")),await E(g,r.identity),o(null),v(c),C("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"secondary",is_primary:!1}),$.success(a("sellModal.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["my-assets",r.address]})}catch(g){T(g,{flow:"list_secondary"}),C("Shop Listing Failed",{listing_type:"secondary",error_code:O(g)}),p(R(g,a("sellModal.errorGeneric"))),o(null)}finally{N(!1)}}function L(){t(),i(`/item/${e.contractAddress}/${e.tokenId}`)}return h!==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("sellModal.successTitle")}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("sellModal.listedFor")," ",s.jsxs("strong",{children:[s.jsx(P,{className:"ccy-mark"})," ",h]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:L,children:a("sellModal.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("sellModal.listTitle",{name:e.name})}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("sellModal.priceLabel",{currency:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:c=>x(c.target.value),disabled:u})]}),s.jsx("p",{className:"muted small",children:a("sellModal.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(U,{message:_}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:u,children:a("sellModal.cancel")}),s.jsx(f,{onClick:()=>void k(),disabled:u,children:u?a("sellModal.listing"):a("sellModal.putOnSale")})]})]})})}const le=1e3*60*60*24*182;function ge({item:e,session:r,onClose:t}){const l=M(),i=F(),[n,x]=m.useState("10"),[y,o]=m.useState(null),[_,p]=m.useState(null),[u,N]=m.useState(!1),[h,v]=m.useState(null),[k,L]=m.useState(null),c=w.chainId,g=H(r.providerType);m.useEffect(()=>{let d=!1;return(async()=>{try{const b=await V({contractAddress:e.contractAddress,chainId:c});d||v(b)}catch{d||v(!1)}})(),()=>{d=!0}},[e.contractAddress,c]);async function W(){p(null);const d=Number(n);if(!Number.isInteger(d)||d<=0){p(a("primaryList.errorWholeNumber"));return}N(!0);try{h||(o(a("primaryList.statusEnabling")),await Y({signer:r.signer,contractAddress:e.contractAddress,chainId:c}),v(!0)),o(a("primaryList.statusPublishing"));const b=await z({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:q.Network.MATIC,chainId:c},usdPrice:d/10,uses:e.remainingSupply,expiresAtMs:Date.now()+le});o(a("primaryList.statusFinishing")),await E(b,r.identity),o(null),L(d),C("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:d,price_usd:d/10,listing_type:"primary",is_primary:!0}),$.success(a("primaryList.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["publishable-items"]}),l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){T(b,{flow:"list_primary"}),C("Shop Listing Failed",{listing_type:"primary",error_code:O(b)}),p(R(b,a("primaryList.errorGeneric"))),o(null)}finally{N(!1)}}function D(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const G=u?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return k!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:d=>d.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(P,{className:"ccy-mark"})," ",k]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:D,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:d=>d.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:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:d=>x(d.target.value),disabled:u})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),h===!1&&!u?g?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&&!u?g?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(U,{message:_}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:u,children:a("primaryList.cancel")}),s.jsx(f,{onClick:()=>void W(),disabled:u||h===null,children:h===null?a("primaryList.checking"):G})]})]})})}export{ge as P,ye as S,he as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as s,u as se,r as n,L as te}from"./react-BMZSDQJw.js";import{t as a,y,s as _,
|
|
1
|
+
import{j as s,u as se,r as n,L as te}from"./react-BMZSDQJw.js";import{t as a,y,s as _,H as ae,u as ie,g as re,j as ne,I as E,B as P,E as R}from"./index-V0hMC6mZ.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-cTXMZhwG.js";import{E as M}from"./ErrorNotice-DDr3KjIH.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-29941568358.commit-de47e56/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-29941568358.commit-de47e56/assets/template-cover-2-Dni9s0i_.jpeg",ge=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ue,"../assets/creator-covers/template-cover-2.jpeg":pe}),h=Object.entries(ge).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>({name:i.split("/").pop(),url:d})),ve=ae`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
@@ -50,4 +50,4 @@ import{j as s,u as se,r as n,L as te}from"./react-BMZSDQJw.js";import{t as a,y,s
|
|
|
50
50
|
align-self: center;
|
|
51
51
|
min-width: 200px;
|
|
52
52
|
margin-top: 8px;
|
|
53
|
-
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Le(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:F}=oe(c),[r,m]=n.useState(A),[C,L]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[f,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),L(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=h.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?h.find(l=>f[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,f]);n.useEffect(()=>{o!=null&&o.hash&&h.some(e=>f[e.name]===o.hash)&&N(null)},[f,o]);const
|
|
53
|
+
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Le(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:F}=oe(c),[r,m]=n.useState(A),[C,L]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[f,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),L(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=h.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?h.find(l=>f[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,f]);n.useEffect(()=>{o!=null&&o.hash&&h.some(e=>f[e.name]===o.hash)&&N(null)},[f,o]);const H=k!==void 0&&k>O,Y=n.useMemo(()=>de.filter(e=>!B(e,r.links[e])),[r.links]),K=H||Y.length>0,w=n.useMemo(()=>JSON.stringify(r)!==JSON.stringify(C),[r,C]),q=w&&!K&&!g;if(n.useEffect(()=>{if(!w)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[w]),!i)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx(be,{variant:"purple",onClick:d,children:a("storeSettings.signIn")})]});function G(e,t){p(void 0),m(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const J=["image/png","image/jpeg","image/webp"];function Q(e){var I;const t=(I=e.target.files)==null?void 0:I[0];if(!t||!J.includes(t.type))return;p(t.size);const l=`cover/${t.name}`,u=new FileReader;u.onload=()=>{const T=u.result;N({url:T,name:l,hash:""}),m(ee=>({...ee,cover:T,coverName:l,coverHash:""}))},u.readAsDataURL(t)}function U(){o&&(p(void 0),m(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function W(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";m(u=>({...u,links:{...u.links,[e]:l}}))}function X(e){const t=r.links[e];return e==="website"?t:t.replace(v[e],"")}async function Z(){if(!(!c||!i)){$(!0);try{await me(c,r,i.identity),L(r),p(void 0),await j.invalidateQueries({queryKey:["store",c.toLowerCase()]}),R.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{R.error(a("storeSettings.saveError"))}finally{$(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(te,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx(E,{name:"arrow-left"})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx(E,{name:"external-link"})]}):null]}),F?s.jsx(_e,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[h.map(e=>{const t=x===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"data-testid":"cover-picker-tile","data-selected":t,"aria-pressed":t,onClick:()=>G(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${x?"":" is-selected"}`,"data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!x,"aria-pressed":!x,onClick:U,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=z.current)==null?void 0:e.click()},children:[s.jsx(E,{name:"upload"}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:z,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input","data-testid":"cover-picker-input",onChange:Q})]}),H?s.jsx(M,{message:a("storeSettings.sizeError",{max:D(O),current:D(k)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:r.description,rows:4,disabled:g,onChange:e=>m(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:r.links.website,placeholder:v.website,disabled:g,onChange:e=>m(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),B("website",r.links.website)?null:s.jsx(M,{message:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:X(e),disabled:g,onChange:t=>W(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx(P,{variant:"purple",className:"store-settings__save","data-testid":"store-settings-save",onClick:()=>void Z(),disabled:!q,children:g?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{Le as StoreSettings,Le as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,b as W,u as M,N as L,r as T}from"./react-BMZSDQJw.js";import{s as h,y as N,S,t as s,g as V,
|
|
1
|
+
import{j as e,b as W,u as M,N as L,r as T}from"./react-BMZSDQJw.js";import{s as h,y as N,H as S,t as s,g as V,ac as z,u as U,ad as H,ae as J,af as X,ag as D,ah as G,J as K,ai as E,c as k,B as Y,aj as q}from"./index-V0hMC6mZ.js";import{d as j}from"./dcl-schemas-BICTSpB5.js";import{w as Q,S as Z}from"./buy-gasless-iZXsoGZN.js";import"./sentry-8SzFotJj.js";import"./ethers-Dpp9c5As.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-vTSEXgN1.js";import"./authorizations-CsduRV0X.js";import"./index-HN6Rk25C.js";const C="#2bb673",F=S`
|
|
2
2
|
to {
|
|
3
3
|
stroke-dashoffset: 0;
|
|
4
4
|
}
|
|
@@ -92,7 +92,7 @@ import{j as e,b as W,u as M,N as L,r as T}from"./react-BMZSDQJw.js";import{s as
|
|
|
92
92
|
@media (prefers-reduced-motion: reduce) {
|
|
93
93
|
animation: none;
|
|
94
94
|
}
|
|
95
|
-
`;function ne(){return e.jsxs(te,{role:"img","aria-label":s("successAnimation.label"),"data-testid":"success-anim",children:[e.jsxs(ae,{viewBox:"0 0 120 120",children:[e.jsx(ce,{cx:"60",cy:"60",r:"54"}),e.jsx(re,{d:"M37 61 l16 16 l30 -34"})]}),e.jsx(_,{"data-spark":"1","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"2","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"3","aria-hidden":!0,children:"◈"}),e.jsx(_,{"data-spark":"4","aria-hidden":!0,children:"✦"})]})}const f=h(
|
|
95
|
+
`;function ne(){return e.jsxs(te,{role:"img","aria-label":s("successAnimation.label"),"data-testid":"success-anim",children:[e.jsxs(ae,{viewBox:"0 0 120 120",children:[e.jsx(ce,{cx:"60",cy:"60",r:"54"}),e.jsx(re,{d:"M37 61 l16 16 l30 -34"})]}),e.jsx(_,{"data-spark":"1","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"2","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"3","aria-hidden":!0,children:"◈"}),e.jsx(_,{"data-spark":"4","aria-hidden":!0,children:"✦"})]})}const f=h(Y)`
|
|
96
96
|
min-width: 160px;
|
|
97
97
|
text-align: center;
|
|
98
|
-
`,ie=c=>new Promise(t=>setTimeout(t,c));function oe(c,t){const[a,l]=T.useState(c?"pending":"confirmed"),u=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return T.useEffect(()=>{if(!c)return;let i=!1;return(async()=>{let x=!1;for(let n=0;n<20&&!i;n++)try{await Q(c,{timeoutMs:15e3}),x=!0;break}catch(r){if(r instanceof Z)continue;i||l("failed");return}if(!i){if(!x){l("timed-out");return}if(!t){l("confirmed");return}l("indexing");for(let n=0;n<40&&!i;n++){if(await
|
|
98
|
+
`,ie=c=>new Promise(t=>setTimeout(t,c));function oe(c,t){const[a,l]=T.useState(c?"pending":"confirmed"),u=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return T.useEffect(()=>{if(!c)return;let i=!1;return(async()=>{let x=!1;for(let n=0;n<20&&!i;n++)try{await Q(c,{timeoutMs:15e3}),x=!0;break}catch(r){if(r instanceof Z)continue;i||l("failed");return}if(!i){if(!x){l("timed-out");return}if(!t){l("confirmed");return}l("indexing");for(let n=0;n<40&&!i;n++){if(await q(t.owner,t.contractAddress,t.itemId)){i||l("confirmed");return}await ie(3e3)}i||l("timed-out")}})(),()=>{i=!0}},[c,u]),a}const de=k.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",v=k.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function ve(){const{state:c}=W(),t=M(),{session:a}=V(),{data:l}=z(a==null?void 0:a.address),u=c==null?void 0:c.txHash,i=(c==null?void 0:c.items)??[],d=i[0],x=a!=null&&a.address&&(d!=null&&d.contractAddress)&&(d!=null&&d.itemId)?{owner:a.address,contractAddress:d.contractAddress,itemId:d.itemId}:null,n=oe(u,x);U({title:s("seo.success.title"),noindex:!0});const r=i;if(r.length===0)return e.jsx(L,{to:"/assets",replace:!0});const p=r[0],b=r.filter(o=>o.category!=="emote"),B=r.find(o=>o.category==="emote")??null,A=b.map(H).filter(o=>!!o),y=J(l),R=!!y&&b.every(o=>X(o,y)),O=D(b)??y??G,I=!!(a!=null&&a.address)&&R,$=I?a.address:"default",P=I?void 0:O,m=B??p,w=m.category==="emote",g=!!u&&K(a==null?void 0:a.providerType);return e.jsxs("div",{className:"success",children:[e.jsx("div",{className:"success__preview",children:A.length>0?e.jsx(E,{profile:$,bodyShape:P,urns:A,type:j.PreviewType.AVATAR,emote:j.PreviewEmote.FASHION,background:"ecebed",dev:k.chainId===80002},p.id):e.jsx(E,{contractAddress:m.contractAddress,tokenId:m.tokenId??void 0,itemId:m.tokenId?void 0:m.itemId??void 0,profile:$,bodyShape:w?void 0:P,type:w?void 0:j.PreviewType.AVATAR,emote:w?void 0:j.PreviewEmote.FASHION,background:"ecebed",dev:k.chainId===80002},m.id)}),e.jsx("div",{className:"success__panel",children:n==="pending"||n==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),e.jsx("h1",{className:"success__title",children:n==="indexing"?s("success.finalizing"):s("success.processing")}),e.jsx("p",{className:"success__sub",children:n==="indexing"?e.jsxs(e.Fragment,{children:[s("success.indexingBefore")," ",r.length===1?e.jsx("strong",{children:p.name}):s("success.itemCount",{count:r.length})," ",s("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[s("success.confirmingBefore")," ",r.length===1?e.jsx("strong",{children:p.name}):s("success.itemCount",{count:r.length})," ",s("success.confirmingAfter")]})}),g?e.jsx("div",{className:"success__links",children:e.jsx("a",{className:"success__receipt",href:`${v}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")})}):null]}):n==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:s("success.stillProcessingTitle")}),e.jsxs("p",{className:"success__sub",children:[s("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>t("/my-purchases"),children:s("nav.myPurchases")})," ",s("success.timedOutAfter")]}),e.jsx("div",{className:"success__links",children:g?e.jsx("a",{className:"success__receipt",href:`${v}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null}),e.jsxs("div",{className:"success__actions",children:[e.jsx(f,{variant:"purple",onClick:()=>t("/my-purchases"),children:s("success.viewMyPurchases")}),e.jsx(f,{variant:"ghost",onClick:()=>t("/assets"),children:s("success.keepShopping")})]})]}):n==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:s("success.failedTitle")}),e.jsx("p",{className:"success__sub",children:s("success.failedBody")}),e.jsx("div",{className:"success__links",children:g?e.jsx("a",{className:"success__receipt",href:`${v}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null}),e.jsx("div",{className:"success__actions",children:e.jsx(f,{variant:"purple",onClick:()=>t("/assets"),children:s("success.backToShop")})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{}),e.jsx("h1",{className:"success__title",children:s("success.title")}),r.length===1?e.jsxs("p",{className:"success__sub",children:[e.jsx("strong",{children:p.name})," ",s("success.heroInWardrobe")]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"success__sub",children:s("success.itemsInWardrobe",{count:r.length})}),e.jsx("ul",{className:"success__list",children:r.map(o=>e.jsx("li",{children:o.name},o.id))})]}),e.jsxs("div",{className:"success__links",children:[e.jsx("button",{className:"success__receipt",onClick:()=>t("/my-purchases"),children:s("success.viewOrder")}),g?e.jsx("a",{className:"success__receipt",href:`${v}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null]}),e.jsxs("div",{className:"success__actions",children:[e.jsx(f,{as:"a",href:de,target:"_blank",rel:"noreferrer",variant:"purple",children:s("success.useItInWorld")}),e.jsx(f,{variant:"ghost",onClick:()=>t("/assets"),children:s("success.keepShopping")})]})]})})]})}export{ve as Success,ve 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-_Jupf0lQ.js";import{au as C}from"./NetworkUtil-CM7JZPbs.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-CFGfbV9-.js";import{au as C}from"./NetworkUtil-CM7JZPbs.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-BMZSDQJw.js";import{s as d,y as r}from"./index-
|
|
1
|
+
import{r as e,j as c}from"./react-BMZSDQJw.js";import{s as d,y as r}from"./index-V0hMC6mZ.js";import{n as x}from"./emotion-CSxEP8yM.js";const h=d("span",x("block"))`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
4
4
|
${({block:t})=>t?"width: 100%;":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-CeDRuWE-.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BMZSDQJw.js";import{b8 as Ne}from"./index-B8IbHKn5.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-BokebKeP.js";import"./sentry-8SzFotJj.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|
|
1
|
+
var Ce=Object.defineProperty;var Ie=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Ie(e,typeof t!="symbol"?t+"":t,n);import{W as we,b as oe,C as Se,B as ve,f as ie}from"./ethers-Dpp9c5As.js";import{p as Re,d as X}from"./dcl-schemas-BICTSpB5.js";import{c as ce}from"./react-BMZSDQJw.js";import{b9 as Ne}from"./index-V0hMC6mZ.js";import{O as Oe,M as Pe,D as be,a as ue,g as de}from"./index-HN6Rk25C.js";import{c as K,e as De}from"./index-BRKyx7oU.js";import"./sentry-8SzFotJj.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";const Le="2d0335ab",Ue="0c53c51c",Fe="d8ed1acc",Me=ye("0x");let ke=0;async function je(e){let t=[];try{t=await q(e,"eth_requestAccounts",[])}catch{t=await q(e,"eth_accounts",[])}if(t.length===0)throw new Error("Could not find a valid connected account");return t[0]}async function $e(e,t,n){return q(e,"eth_signTypedData_v4",[t,n])}function He(e,t,n){const r=t.replace("0x",""),s=r.substring(0,64),i=r.substring(64,128),u=Ge(r.substring(128,130)),d=n.replace("0x",""),f=(d.length/2).toString(16),w=Math.ceil(d.length/64);return["0x",Ue,m(e),m("a0"),s,i,m(u),m(f),d.padEnd(64*w,"0")].join("")}function qe(e,t,n){const r=n.replace("0x",""),s=t.replace("0x",""),u=96+32+r.length/2,d=Math.ceil(s.length/64);return["0x",Fe,m(e),m("60"),m(u.toString(16)),m((r.length/2).toString(16)),r,m((s.length/2).toString(16)),s.padEnd(64*d,"0")].join("")}function Ge(e){let t=parseInt(e,16);if(t<27&&(t+=27),t!==27&&t!==28)throw Error(`Invalid signature version "${e}" (parsed: ${t})`);return t.toString(16)}async function Be(e,t,n){const r=m(t),s=await q(e,"eth_call",[{data:`0x${Le}${r}`,to:n},"latest"]);return m(s)}function Ve(e){return typeof e=="number"?`0x${m(e.toString(16))}`:`0x${m(e)}`}function Je(e,t){return q(e,"eth_getCode",[t.toLowerCase(),"latest"])}const We="0xef01";async function Ye(e,t){const n=await Je(e,t);return n.toLowerCase().startsWith(We)?!1:!Ze(n)}function ye(e){if(!/^0x[0-9a-f]*$/gi.test(e))throw new Error(`Not a valid hex string "${e}"`);let t=e.slice(2);for(;t.length<40;)t="0"+t;return"0x"+t}function Ze(e){return ye(e.toLowerCase())===Me}function m(e){return e.toString().replace("0x","").padStart(64,"0")}async function q(e,t,n){let r,s={jsonrpc:"2.0",id:++ke,method:t,params:n};if(e.request!==void 0?r=await e.request(s):e.sendAsync!==void 0?r=await e.sendAsync(s):e.send!==void 0&&(r=await e.send(t,n)),r)return r.result||r;throw new Error(`Could not send the transaction correcty. Either the provider does not support the method "${t}" or is missing a proper send/request.`)}function Xe(){return{serverURL:"https://transactions-api.decentraland.io/v1"}}var k;(function(e){e.UNKNOWN="unknown",e.DAPP_LIMIT_REACHED="dapp_limit_reached",e.USER_LIMIT_REACHED="user_limit_reached",e.API_LIMIT_REACHED="api_limit_reached",e.GAS_LIMIT_REACHED="gas_limit_reached",e.EXPECTATION_FAILED="expectation_failed",e.INVALID_TRANSACTION="invalid_transaction",e.INVALID_SCHEMA="invalid_schema",e.INVALID_CONTRACT_ADDRESS="invalid_contract_address",e.INVALID_ADDRESS="invalid_address",e.SALE_PRICE_TOO_LOW="sale_price_too_low",e.QUOTA_REACHED="quota_reached",e.CONTRACT_ACCOUNT="contract_account",e.HIGH_CONGESTION="high_congestion",e.USER_DENIED="user_denied"})(k||(k={}));class P extends Error{constructor(n,r){super(n);T(this,"code");this.code=r,Object.setPrototypeOf(this,P.prototype)}}async function Ke(e,t,n,r,s={}){const i={...Xe(),...s};if(!r.address.trim())throw new P(`The contract address for ${r.name} is empty. You're probably trying to get a proxy contract. Try adding an address to the result of getContract`,k.INVALID_ADDRESS);try{const u=await je(e);if(await Ye(e,u))throw new P("Contract accounts are not supported",k.CONTRACT_ACCOUNT);const d=r.abi.some(B=>{var V;return B.name==="executeMetaTransaction"&&((V=B.inputs)==null?void 0:V.some(W=>W.name==="_functionData"))}),f=await Be(t,u,r.address),w=Ve(r.chainId),I=Qe(w,r),D=ze(u,f,n,I,d),L=await $e(e,u,JSON.stringify(D)),G=(d?qe:He)(u,L,n),j=await fetch(`${i.serverURL}/transactions`,{headers:{"Content-Type":"application/json"},body:JSON.stringify({transactionData:{from:u,params:[r.address,G]}}),method:"POST"}),N=await j.json();if(N.ok===!1)throw N.message&&N.code?new P(N.message,N.code):new Error(`HTTP Error. Status: ${j.status}.`);return N.txHash}catch(u){const d=u;throw d instanceof P?d:d.message.indexOf("User denied message signature")!==-1?new P(d.message,k.USER_DENIED):(console.warn("An error occurred trying to send the meta transaction. Error:",d.message),new P(d.message,k.UNKNOWN))}}function ze(e,t,n,r,s=!1){return{types:{EIP712Domain:be,MetaTransaction:s?Oe:Pe},domain:r,primaryType:"MetaTransaction",message:{nonce:parseInt(t,16),from:e,...s?{functionData:n}:{functionSignature:n}}}}function Qe(e,t){return{name:t.name,version:t.version,verifyingContract:t.address,salt:e}}async function et(e){const t=await Ee();if(t){const n=await new we(t).getSigner().getChainId();if(e===n)return t}return K.createProvider(Re.ProviderType.NETWORK,e)}async function Ee(){try{return await K.getProvider()}catch{try{const{provider:e}=await K.tryPreviousConnection();return e}catch{return null}}}function le(e){return Math.floor(e/1e3)}function he(e){switch(e.assetType){case X.TradeAssetType.ERC721:return e.tokenId;case X.TradeAssetType.COLLECTION_ITEM:return e.itemId;case X.TradeAssetType.ERC20:return e.amount;default:return console.error("Invalid asset type:",e),""}}function tt(e){var t;return{checks:{uses:e.checks.uses,expiration:le(e.checks.expiration),effective:le(e.checks.effective),salt:oe(e.checks.salt,32),contractSignatureIndex:e.checks.contractSignatureIndex,signerSignatureIndex:e.checks.signerSignatureIndex,allowedRoot:oe(e.checks.allowedRoot,32),externalChecks:(t=e.checks.externalChecks)==null?void 0:t.map(n=>({contractAddress:n.contractAddress,selector:n.selector,value:n.value?n.value:"0x",required:n.required}))},sent:e.sent.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x"})),received:e.received.map(n=>({assetType:n.assetType,contractAddress:n.contractAddress,value:he(n),extra:n.extra?n.extra:"0x",beneficiary:n.beneficiary}))}}function fe(e,t){const n=tt(e);return{signer:e.signer,signature:e.signature,...n,checks:{...n.checks,allowedProof:[]},sent:n.sent.map(r=>({...r,beneficiary:t}))}}async function nt(e){const t=await e.request({method:"eth_chainId",params:[]});let n;return typeof t=="string"?n=parseInt(t,16):n=t,n}async function rt(e){const t=await et(e);return new we(t)}const b=new De.EventEmitter;var C;(function(e){e.ERROR="error",e.SUCCESS="success",e.PROMPT="prompt",e.ACCEPT="accept",e.REJECT="reject"})(C||(C={}));let at="https://transactions-api.decentraland.org/v1";const st=()=>at,ot=()=>new Promise((e,t)=>{const n=()=>{b.removeAllListeners(C.REJECT),e(!0)},r=()=>{b.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};b.addListener(C.ACCEPT,n),b.addListener(C.REJECT,r)});async function pe(...e){const[t,n,...r]=e;try{const s=await Ee();if(!s)throw new Error("Provider not connected");const i=await nt(s),u=await rt(t.chainId),d=new Se(t.address,t.abi,u),f=await(typeof n=="function"?n(d.populateTransaction):d.populateTransaction[n](...r));if(i===t.chainId){const w=u.getSigner();if(s.isMagic||s.isThirdweb){let D=ve.from(0);try{const L=await w.getGasPrice(),U=await w.estimateGas(f);D=L.mul(U)}catch{}if(!D.isZero()){const L=ot(),U=await w.getBalance();b.emit(C.PROMPT,{transactionGasPrice:ie(D),userBalance:ie(U),chainId:t.chainId}),await L}}const I=await w.sendTransaction(f);return b.emit(C.SUCCESS,{txHash:I.hash}),I.hash}else{const w=await Ke(s,u,f.data,t,{serverURL:st()});return b.emit(C.SUCCESS,{txHash:w}),w}}catch(s){const i={type:C.ERROR,error:s};throw b.emit(C.ERROR,i),s}}var H={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var it=H.exports,Te;function ct(){return Te||(Te=1,(function(e,t){(function(n){var r=t&&!t.nodeType&&t,s=e&&!e.nodeType&&e,i=typeof ce=="object"&&ce;(i.global===i||i.window===i||i.self===i)&&(n=i);var u,d=2147483647,f=36,w=1,I=26,D=38,L=700,U=72,G=128,j="-",N=/^xn--/,B=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Y=f-w,S=Math.floor,$=String.fromCharCode,J;function F(a){throw new RangeError(W[a])}function z(a,o){for(var c=a.length,l=[];c--;)l[c]=o(a[c]);return l}function Q(a,o){var c=a.split("@"),l="";c.length>1&&(l=c[0]+"@",a=c[1]),a=a.replace(V,".");var h=a.split("."),y=z(h,o).join(".");return l+y}function ee(a){for(var o=[],c=0,l=a.length,h,y;c<l;)h=a.charCodeAt(c++),h>=55296&&h<=56319&&c<l?(y=a.charCodeAt(c++),(y&64512)==56320?o.push(((h&1023)<<10)+(y&1023)+65536):(o.push(h),c--)):o.push(h);return o}function te(a){return z(a,function(o){var c="";return o>65535&&(o-=65536,c+=$(o>>>10&1023|55296),o=56320|o&1023),c+=$(o),c}).join("")}function _e(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:f}function ne(a,o){return a+22+75*(a<26)-((o!=0)<<5)}function re(a,o,c){var l=0;for(a=c?S(a/L):a>>1,a+=S(a/o);a>Y*I>>1;l+=f)a=S(a/Y);return S(l+(Y+1)*a/(a+D))}function ae(a){var o=[],c=a.length,l,h=0,y=G,p=U,E,A,v,R,g,_,x,O,M;for(E=a.lastIndexOf(j),E<0&&(E=0),A=0;A<E;++A)a.charCodeAt(A)>=128&&F("not-basic"),o.push(a.charCodeAt(A));for(v=E>0?E+1:0;v<c;){for(R=h,g=1,_=f;v>=c&&F("invalid-input"),x=_e(a.charCodeAt(v++)),(x>=f||x>S((d-h)/g))&&F("overflow"),h+=x*g,O=_<=p?w:_>=p+I?I:_-p,!(x<O);_+=f)M=f-O,g>S(d/M)&&F("overflow"),g*=M;l=o.length+1,p=re(h-R,l,R==0),S(h/l)>d-y&&F("overflow"),y+=S(h/l),h%=l,o.splice(h++,0,y)}return te(o)}function se(a){var o,c,l,h,y,p,E,A,v,R,g,_=[],x,O,M,Z;for(a=ee(a),x=a.length,o=G,c=0,y=U,p=0;p<x;++p)g=a[p],g<128&&_.push($(g));for(l=h=_.length,h&&_.push(j);l<x;){for(E=d,p=0;p<x;++p)g=a[p],g>=o&&g<E&&(E=g);for(O=l+1,E-o>S((d-c)/O)&&F("overflow"),c+=(E-o)*O,o=E,p=0;p<x;++p)if(g=a[p],g<o&&++c>d&&F("overflow"),g==o){for(A=c,v=f;R=v<=y?w:v>=y+I?I:v-y,!(A<R);v+=f)Z=A-R,M=f-R,_.push($(ne(R+Z%M,0))),A=S(Z/M);_.push($(ne(A,0))),y=re(c,O,l==h),c=0,++l}++c,++o}return _.join("")}function Ae(a){return Q(a,function(o){return N.test(o)?ae(o.slice(4).toLowerCase()):o})}function xe(a){return Q(a,function(o){return B.test(o)?"xn--"+se(o):o})}if(u={version:"1.4.1",ucs2:{decode:ee,encode:te},decode:ae,encode:se,toASCII:xe,toUnicode:Ae},r&&s)if(e.exports==r)s.exports=u;else for(J in u)u.hasOwnProperty(J)&&(r[J]=u[J]);else n.punycode=u})(it)})(H,H.exports)),H.exports}ct();var me=(function(e){function t(){var r=this||self;return delete e.prototype.__magic__,r}if(typeof globalThis=="object")return globalThis;if(this)return t();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:t});var n=__magic__;return n})(Object),ut=me.URL;me.URLSearchParams;var dt={URL:ut};class ge extends Error{constructor(n,r,s){super(n);T(this,"status");T(this,"data");this.status=r,this.data=s}}const lt=3,ht=1e3,ft=[400,401,403,404,409,422],pt=(globalThis==null?void 0:globalThis.URL)??dt.URL;class Tt{constructor(t,n){T(this,"baseUrl");T(this,"retries");T(this,"retryDelay");T(this,"nonRetryableStatuses");T(this,"identity");T(this,"sleep",t=>new Promise(n=>{setTimeout(n,t)}));T(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);T(this,"rawFetch",(t,n)=>{const r=new pt(t,this.baseUrl),s=(n==null?void 0:n.identity)??this.getIdentity();return Ne.signedFetchFactory()(r.toString(),{...n,identity:s})});T(this,"fetch",async(t,n)=>{for(let r=0;r<=this.retries;r++)try{let s,i;try{s=await this.rawFetch(t,n);const u=await s.text();u.length===0?i={ok:!0,data:null}:i=JSON.parse(u)}catch(u){throw new ge(u.message,void 0,null)}if(!s.ok||i.ok===!1){const u=i.message??i.error;throw new ge(u??`Request failed with status code ${s.status}`,s.status,i.data)}return i.ok===!0?i.data:i}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===r||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=n==null?void 0:n.identity,this.retries=(n==null?void 0:n.retries)??lt,this.retryDelay=(n==null?void 0:n.retryDelay)??ht,this.nonRetryableStatuses=(n==null?void 0:n.nonRetryableStatuses)??ft}}class gt extends Tt{constructor(n,r,s){super(r,s);T(this,"signer");T(this,"addTrade",async n=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(n),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));T(this,"fetchTrade",async n=>this.fetch(`/v1/trades/${n}`,{method:"GET"}));this.signer=n}}class vt{constructor(t,n,r){T(this,"tradesAPI");this.tradesAPI=new gt(t,n,{identity:r,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"accept",[i])}async cancel(t,n){const r=ue(t.contract),s=de(r,t.chainId),i=fe(t,n);return pe(s,"cancelSignature",[i])}}export{vt as TradeService};
|