@dcl/shop 0.1.0-29571500722.commit-8ea45d8 → 0.1.0-29584116670.commit-7b991d9
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-Y-secaKv.js → AnimatedBackground-B9Pw1kge.js} +3 -3
- package/assets/Assets-FsQDhPLn.js +1 -0
- package/assets/Cart-BezIJz77.js +1 -0
- package/assets/Cart-C612IvK3.css +1 -0
- package/assets/{CircularProgress-DF1tx4Pz.js → CircularProgress-BGTYLSVF.js} +5 -5
- package/assets/Collection-X9hhX-Rz.js +1 -0
- package/assets/{ConstantsUtil-BTo1-KgH.js → ConstantsUtil-BL7ODi4n.js} +1 -1
- package/assets/{ContentClient-DahG0FsN.js → ContentClient-XY1tEPuy.js} +1 -1
- package/assets/Creator-DK5t63LO.js +1 -0
- package/assets/CssVarsProvider-CxQAolcH.js +24 -0
- package/assets/{DeploymentBuilder-DCLyMp7S.js → DeploymentBuilder-C9YxIsXI.js} +1 -1
- package/assets/{ExchangeController-5UZnaMYm.js → ExchangeController-BPeo8fj3.js} +1 -1
- package/assets/GetCredits-X4PI-ku7.js +1 -0
- package/assets/{HelpersUtil-DsOycveq.js → HelpersUtil-DUakraTi.js} +1 -1
- package/assets/{ImportListings-Ry47KtP_.js → ImportListings-8eKbca2b.js} +1 -1
- package/assets/ItemDetail-C31uL9qN.css +1 -0
- package/assets/ItemDetail-CreYcWa4.js +2 -0
- package/assets/{LoadMore-DsKzH4Rv.js → LoadMore-Borbhtjd.js} +1 -1
- package/assets/MyAssets-C9v-DUMQ.js +1 -0
- package/assets/{MyFavorites-BfWQjhlL.js → MyFavorites-Di5_hT1d.js} +1 -1
- package/assets/{MyPurchases-DbU97xcR.js → MyPurchases-qrWgZ9ZY.js} +1 -1
- package/assets/{NetworkUtil-DInevqnn.js → NetworkUtil-bxmjbsdp.js} +1 -1
- package/assets/NotFound-Co_hmXY9.js +1 -0
- package/assets/{StoreSettings-C-yDm4Ah.js → StoreSettings-Cle2P_Dp.js} +1 -1
- package/assets/Success-CdecfFR-.js +1 -0
- package/assets/{SwapController-Bau8y3ss.js → SwapController-D31BIXvU.js} +1 -1
- package/assets/{TradeService-sWmitO7N.js → TradeService-VoevqRD7.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-BrDTQqcr.js → W3MFrameProviderSingleton-C3ngIw23.js} +3 -3
- package/assets/{WebCryptoP256-Clorun9S.js → WebCryptoP256-DKJaSk24.js} +1 -1
- package/assets/{basic-Co2ks3tP.js → basic-ZT38cLV3.js} +1 -1
- package/assets/{biconomy-DAm_-Hm_.js → biconomy-A8N4_tES.js} +1 -1
- package/assets/{browser-9oFjBwrz.js → browser-7Z6Tx7yC.js} +1 -1
- package/assets/{browser-ponyfill-DMgE6PM5.js → browser-ponyfill-C_hn4Jen.js} +1 -1
- package/assets/browser-ponyfill-iWQHRc9C.js +1 -0
- package/assets/{buy-y9zg-9gr.js → buy-DCyi2TCj.js} +1 -1
- package/assets/{buy-gasless-B4g8GiJr.js → buy-gasless-CgSRLXqb.js} +1 -1
- package/assets/cart-checkout-Bl-9Rmuy.js +1 -0
- package/assets/categories-CAhRovwN.js +1 -0
- package/assets/categories-CBvVTfQE.css +1 -0
- package/assets/{ccip-i7tJF0Hj.js → ccip-C3eSvUSX.js} +1 -1
- package/assets/{ccip-B8JdVFq5.js → ccip-f8kMMqoC.js} +1 -1
- package/assets/{chains-BQ5Swd2q.js → chains-D4mXFh-0.js} +1 -1
- package/assets/collection-mQvOrKnG.js +1 -0
- package/assets/colors-LINLm1ux.js +1 -0
- package/assets/{common-CBPtpBt7.js → common-Bq3lgphe.js} +1 -1
- package/assets/{controller-BVAEs_Ol.js → controller-Bo7JkTt3.js} +2 -2
- package/assets/{core-DXAXZQxt.js → core-DSbh2F_2.js} +4 -4
- package/assets/{custom-C00ZS-dv.js → custom-DCy5VCfZ.js} +1 -1
- package/assets/{data-capture-BfGns_F9.js → data-capture-CaGo1PxF.js} +1 -1
- package/assets/{decimals-7LZbjdh-.js → decimals-4fS10X_L.js} +1 -1
- package/assets/decimals-DY9F9u4r.js +1 -0
- package/assets/{detectExtension-C_qqqhXd.js → detectExtension-BE4V-7e-.js} +1 -1
- package/assets/{email-10XDB7Ed.js → email-BGxNiLrQ.js} +1 -1
- package/assets/{embedded-wallet-Coq3FP2j.js → embedded-wallet-DfdKfc0a.js} +1 -1
- package/assets/emotion-styled.browser.esm-C2X3f31i.js +1 -0
- package/assets/{engine-DNO34GZS.js → engine-BaNurLKk.js} +1 -1
- package/assets/{estimate-l1-fee-ttG5TVsi.js → estimate-l1-fee-CDwQNanq.js} +1 -1
- package/assets/eth_estimateGas-DJGaFjHN.js +1 -0
- package/assets/{eth_getStorageAt-ZjeD4sfh.js → eth_getStorageAt-B2TJaBLZ.js} +1 -1
- package/assets/eth_getTransactionCount-DH8Lt3om.js +1 -0
- package/assets/{ethereum-CD3dxaW_.js → ethereum-dj4CvyL9.js} +1 -1
- package/assets/{ethers-DwWf2RqE.js → ethers-BZNCwGB1.js} +1 -1
- package/assets/{extractIPFS-CFw95IDm.js → extractIPFS-MFYkzgfw.js} +1 -1
- package/assets/{features-BBwkLwo8.js → features-BVZ7jwMo.js} +1 -1
- package/assets/{fetchTokenMetadata-BbJeox1b.js → fetchTokenMetadata-Df-8ebIh.js} +2 -2
- package/assets/{fortmatic-DhmlcDbL.js → fortmatic-udOxQk4J.js} +1 -1
- package/assets/get-ecosystem-wallet-info-BYGhhdDR.js +1 -0
- package/assets/{getBalance-BVXxyvdU.js → getBalance-CiOU_KSA.js} +2 -2
- package/assets/{getInstalledModules-92CJz4J0.js → getInstalledModules-CK2r6Us9.js} +1 -1
- package/assets/{getNFT-By7tEt1z.js → getNFT-CsrwIavu.js} +1 -1
- package/assets/{getNFT-6Z-JCPcj.js → getNFT-uxrgnO16.js} +2 -2
- package/assets/getOverlayAlpha-DIkhrJTf.js +1 -0
- package/assets/{hashTypedData-78L5umOY.js → hashTypedData-BeKO9Gph.js} +1 -1
- package/assets/{hashTypedData-UUOD4hvk.js → hashTypedData-D7G_pwf8.js} +1 -1
- package/assets/{import-BCIlZ3yx.js → import-w6IYTyx9.js} +1 -1
- package/assets/{in-app-wallet-calls-Dx8qnM7-.js → in-app-wallet-calls-BmNgoKoi.js} +1 -1
- package/assets/{index-DsVVBfxP.js → index-0_Q-5Yph.js} +1 -1
- package/assets/{index-DkjQWYoB.js → index-7ugDLFZa.js} +2 -2
- package/assets/{index-DhedohT0.js → index-B2VBWa02.js} +1 -1
- package/assets/{index-CPYtbWCQ.js → index-B54Zm0IT.js} +1 -1
- package/assets/index-BMwA__hl.js +1 -0
- package/assets/{index-DNGhO1UM.js → index-BY0majDU.js} +1 -1
- package/assets/{index-DIYL1_Ov.js → index-BkvyQrui.js} +1 -1
- package/assets/{index-C3xlbPh_.js → index-BnfRTjdt.js} +2 -2
- package/assets/{index-B0PF-s9M.js → index-Bp3ufdYu.js} +1 -1
- package/assets/index-BsYYLNpm.js +1 -0
- package/assets/{index-P4QO1O0D.js → index-BxwA4vLu.js} +1 -1
- package/assets/{index-BsFR4koq.js → index-ByU7K3c5.js} +1 -1
- package/assets/{index-CeR8VFbd.js → index-C0cRipMv.js} +1 -1
- package/assets/{index-Bsx6GubH.js → index-C0w8Y7Pr.js} +1 -1
- package/assets/{index-CjpJ162L.js → index-C1wLfrk8.js} +1 -1
- package/assets/{index-DjVz63Zr.js → index-C7pz3G7b.js} +1 -1
- package/assets/{index-C4JAp-Oa.js → index-CBmf80G9.js} +3 -3
- package/assets/{index-BYRbnzmu.js → index-CPz55u4g.js} +1 -1
- package/assets/{index-ZvQFinLo.js → index-C_QZ68es.js} +1 -1
- package/assets/{index-BlNwDD1i.js → index-Ci9R2pAr.js} +1 -1
- package/assets/{index-ClxTTupQ.js → index-CiID_KCu.js} +1 -1
- package/assets/index-CiMPT_Ro.js +1 -0
- package/assets/{index-Dp3Py-Ws.js → index-Cq0eRfqs.js} +1 -1
- package/assets/{index-CGbJjZCV.js → index-Csqh-gdI.js} +1 -1
- package/assets/{index-B7PXWLXB.js → index-CzJC68I6.js} +1 -1
- package/assets/{index-CBWS4Ml_.js → index-D-2T01Jr.js} +1 -1
- package/assets/{index-CC32N6uw.js → index-D2PwoM0f.js} +1 -1
- package/assets/index-D2idpE6X.css +1 -0
- package/assets/{index-94XD4C5w.js → index-D32umKam.js} +1 -1
- package/assets/{index-C1wVfhuw.js → index-D5kLlKQU.js} +1 -1
- package/assets/{index-C_x2eFau.js → index-D8CfAsn6.js} +3 -3
- package/assets/index-DEFc7rHy.js +74 -0
- package/assets/{index-BsVbqXUp.js → index-DF7PMIfD.js} +3 -3
- package/assets/{index-D7Fx-Qac.js → index-DHF4L8Ec.js} +1 -1
- package/assets/{index-DHM1o-4K.js → index-DJd0Ttfu.js} +1 -1
- package/assets/{index-BlFZSvWx.js → index-DQ2RZxO2.js} +1 -1
- package/assets/{index-Bvx0NOxN.js → index-DWYIiSc1.js} +1 -1
- package/assets/{index-DKP6gkl4.js → index-DZeAExGv.js} +1 -1
- package/assets/{index-CApcD-t8.js → index-DitpCD_h.js} +1 -1
- package/assets/{index-DFGIa8d3.js → index-DjnVWlwG.js} +1 -1
- package/assets/{index-BVRx9Ot1.js → index-Dk1_26DS.js} +1 -1
- package/assets/{index-DUc6Q2Iz.js → index-DpbmEoKi.js} +1 -1
- package/assets/{index-Ds-AFLHc.js → index-Ds4wBJ9D.js} +1 -1
- package/assets/{index-CAMCLJ-3.js → index-DvCjqrZB.js} +1 -1
- package/assets/{index-DN8pYCNl.js → index-DxQ4Zi7k.js} +1 -1
- package/assets/{index-BBZ21lbu.js → index-Dxs_0mDk.js} +1 -1
- package/assets/{index-Dfn1y1uF.js → index-DzzaizOc.js} +1 -1
- package/assets/{index-Ct0w7Ogt.js → index-E-7ReSrK.js} +1 -1
- package/assets/index-FLQXl_Se.js +2 -0
- package/assets/{index-DaDHmqAS.js → index-HirbVXiG.js} +2 -2
- package/assets/{index-DLXELZQv.js → index-NtR9tB0O.js} +1 -1
- package/assets/{index-CIx1sZmW.js → index-OBTfAbI2.js} +1 -1
- package/assets/{index-DPyb1X7J.js → index-VtK5IfsQ.js} +1 -1
- package/assets/index-W4B_IWIP.js +103 -0
- package/assets/{index-D8XPW5rW.js → index-Z5yFLCBO.js} +1 -1
- package/assets/{index-DhQcB2cI.js → index-ZLecI7pg.js} +1 -1
- package/assets/{index-By6STTNb.js → index-_MXYcG3h.js} +1 -1
- package/assets/{index-D-BMnyQb.js → index-aZDU5Fi_.js} +1 -1
- package/assets/{index-lt7oq_YM.js → index-fQoyXaDm.js} +1 -1
- package/assets/{index-DNT62M3w.js → index-ge5YPyFz.js} +1 -1
- package/assets/{index-KYyY5J5u.js → index-goOeCklY.js} +1 -1
- package/assets/{index-CJD-gYKv.js → index-kaNpKyjd.js} +1 -1
- package/assets/{index-6jN-_TNa.js → index-kcVdtF2N.js} +1 -1
- package/assets/{index-DcmcHRml.js → index-mpn87Y1d.js} +1 -1
- package/assets/{index-BAoHOXze.js → index-o7U3KUfn.js} +2 -2
- package/assets/{index.es-EcAKXlCW.js → index.es-C2HPR15G.js} +4 -4
- package/assets/{index.es-CNLSXMT-.js → index.es-CJCMJluv.js} +1 -1
- package/assets/{index.es-DGT1W3bC.js → index.es-KdBFnvI-.js} +1 -1
- package/assets/{localBatchGatewayRequest-CUupTU5s.js → localBatchGatewayRequest-o3WN89Be.js} +1 -1
- package/assets/{mana-rate-TrkgOUFu.js → mana-rate-brJZyjav.js} +1 -1
- package/assets/{native-B49T_qnV.js → native-BS4RJIkv.js} +1 -1
- package/assets/network-DkheBt26.js +1 -0
- package/assets/{networks-BEAzlz87.js → networks-DhDaelkG.js} +1 -1
- package/assets/{onramp-BHjPyFrf.js → onramp-DPhEOHlt.js} +1 -1
- package/assets/{openzeppelin-BqEz23oI.js → openzeppelin-BlzaCD2g.js} +1 -1
- package/assets/{ownerOf-D2Ruvcgr.js → ownerOf-FaMMoQLm.js} +1 -1
- package/assets/{parseNft-C4rXbAm3.js → parseNft-D4_DbJgc.js} +2 -2
- package/assets/{parseSignature-B6_wXS1t.js → parseSignature-CP7LKJ4p.js} +1 -1
- package/assets/{parseSignature-1_3SuD3y.js → parseSignature-lw07DHDL.js} +3 -3
- package/assets/{pay-with-exchange-AvS-iWv3.js → pay-with-exchange-CBQcsvWb.js} +1 -1
- package/assets/payments-DJNklmWA.js +1 -0
- package/assets/{qr-overlay-Di1sYsV2.js → qr-overlay-BhLZ2pHm.js} +3 -3
- package/assets/{react-C51i12iP.js → react-BMZSDQJw.js} +1 -1
- package/assets/{receive-CGzdSteR.js → receive-BOuIH1ov.js} +1 -1
- package/assets/{resolveImplementation-CaXsKbDx.js → resolveImplementation-CedBj6Km.js} +1 -1
- package/assets/resume-buy-Bf0zIH7y.js +1 -0
- package/assets/{rpc-DG-6qjB5.js → rpc-SuxnpJNf.js} +1 -1
- package/assets/{secp256k1-ChfveZcd.js → secp256k1-Bp72qBlb.js} +1 -1
- package/assets/{secp256k1-B9CXpvLY.js → secp256k1-DGcDefMZ.js} +1 -1
- package/assets/{secp256k1-DWucSlB-.js → secp256k1-DUCs4Szw.js} +1 -1
- package/assets/{send-D5cFILBF.js → send-Cc73qyEa.js} +1 -1
- package/assets/{send-batch-transaction-B3lTEUOF.js → send-batch-transaction-CqMxMLal.js} +1 -1
- package/assets/{send-eip712-transaction-ByX_--Vb.js → send-eip712-transaction-Ba7gc6Na.js} +2 -2
- package/assets/{send-gasless-transaction-sFztvg-i.js → send-gasless-transaction-Bkq9RgVC.js} +2 -2
- package/assets/{sendRawTransaction-CR5Mmi6b.js → sendRawTransaction-jimkH_Vk.js} +3 -3
- package/assets/{serializeTransaction-D79jfd3_.js → serializeTransaction-B4_qo8zw.js} +1 -1
- package/assets/{session-proposal-Cwo9ltsm.js → session-proposal-OqodD00Z.js} +1 -1
- package/assets/{session-request-l_FrHUZo.js → session-request-X9CJVkkE.js} +2 -2
- package/assets/{sha256-B1PPmRn9.js → sha256-BbyKZ-d_.js} +1 -1
- package/assets/{signing-Sn5rFCHS.js → signing-CyLHhd-P.js} +5 -5
- package/assets/{socials-CqUkp7RR.js → socials-LFY_yxPF.js} +1 -1
- package/assets/{swaps-hvkTELkc.js → swaps-BdY-zWwk.js} +1 -1
- package/assets/{thirdweb-Bfq5h25u.js → thirdweb-BR0EhpSm.js} +3 -3
- package/assets/{totalSupply-yip6OCLy.js → totalSupply-B_MUJcfB.js} +1 -1
- package/assets/{trade-encoding-42N07h92.js → trade-encoding-BOT9-UWu.js} +1 -1
- package/assets/{transactionReceipt-DADNrKU6.js → transactionReceipt-D4B3HzeC.js} +1 -1
- package/assets/{transactions-DQBiQzWz.js → transactions-B6cGdLdV.js} +1 -1
- package/assets/{useInfiniteGrid-CjcJxtXA.js → useInfiniteGrid-BK47MfTg.js} +1 -1
- package/assets/{useStore-zhFVY9fU.js → useStore-CgLb6TAk.js} +2 -2
- package/assets/useTheme-0gLXH6kA.js +1 -0
- package/assets/useTheme-BSc7aqCZ.js +1 -0
- package/assets/{utils-rl7KiNyp.js → utils-DAnGDyuB.js} +1 -1
- package/assets/{verifyHash-CNDR4v8f.js → verifyHash-CnPKc_YI.js} +1 -1
- package/assets/{w3m-modal-Clo6bKVE.js → w3m-modal-DPallRNX.js} +1 -1
- package/assets/{w3m-modal-GMd0MTV7.js → w3m-modal-N4vv62zw.js} +1 -1
- package/assets/{wait-for-tx-receipt-uU57b-HM.js → wait-for-tx-receipt-D4Q553BP.js} +1 -1
- package/assets/{wallet-kind-PnN45EW0.js → wallet-kind-Bio8Yuti.js} +1 -1
- package/assets/{wallets-CgInyYuE.js → wallets-D-H2dLAA.js} +6 -6
- package/assets/{web-connector-DitPEy2c.js → web-connector-BhqHMVXD.js} +3 -3
- package/assets/{writeContract-CzZHvjcP.js → writeContract-sZ9-DuTE.js} +1 -1
- package/assets/{zora-sepolia-Cmu9LYjr.js → zora-sepolia-Jfao6Y6c.js} +1 -1
- package/assets/{zoraTestnet-l_-faq0L.js → zoraTestnet-UB0HXnxi.js} +1 -1
- package/index.html +8 -8
- package/package.json +2 -2
- package/assets/Assets-sWyggSzY.js +0 -1
- package/assets/Cart-DVt0m7-J.js +0 -1
- package/assets/Collection-D-dr6oYY.js +0 -1
- package/assets/Creator-DpZ1qFEV.js +0 -1
- package/assets/GetCredits-B-2Nu_Cx.js +0 -1
- package/assets/ItemDetail--AzXh8S2.css +0 -1
- package/assets/ItemDetail-CblzRtB5.js +0 -2
- package/assets/MyAssets-26oYZL-x.js +0 -1
- package/assets/NotFound-CWys1EXA.js +0 -1
- package/assets/Success-CW65bxXN.js +0 -1
- package/assets/browser-ponyfill-Djb5Py6a.js +0 -1
- package/assets/categories-DbX2Gw4H.js +0 -1
- package/assets/categories-FoGfjyVm.css +0 -1
- package/assets/collection-CS59m6GL.js +0 -1
- package/assets/decimals-CeoXdXWM.js +0 -1
- package/assets/emotion-styled.browser.esm-Col8rSBp.js +0 -1
- package/assets/eth_estimateGas-BiFrKNU-.js +0 -1
- package/assets/eth_getTransactionCount-BjHbR3QT.js +0 -1
- package/assets/get-ecosystem-wallet-info-BotVMG7h.js +0 -1
- package/assets/index-B4tMFfvy.js +0 -74
- package/assets/index-BcX-FSIU.css +0 -1
- package/assets/index-C1u3RQ96.js +0 -103
- package/assets/index-DH3Yzbz3.js +0 -1
- package/assets/index-QnApYtWL.js +0 -1
- package/assets/network-44dqSlR2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-
|
|
1
|
+
import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-C3ngIw23.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-CBmf80G9.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=L(C),m={state:e,subscribe(t){return I(e,()=>t(e))},subscribeKey(t,n){return N(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>x.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=U.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&k.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as K,a as q,r as n,j as e}from"./react-BMZSDQJw.js";import{a as Q,h as z,t as p,i,j as $,k as G,C as k,l as F}from"./index-W4B_IWIP.js";import{R as Y}from"./resume-buy-Bf0zIH7y.js";import{R as J}from"./cart-checkout-Bl-9Rmuy.js";import{p as L,c as O,i as H,C as W}from"./payments-DJNklmWA.js";import{C as I}from"./CircularProgress-BGTYLSVF.js";import"./ethers-BZNCwGB1.js";const f=H()?"mock":"stripe";function A(c){const s=c;if((s==null?void 0:s.name)==="AbortError")return"You cancelled the request.";const o=((s==null?void 0:s.message)??"").toLowerCase();return o.includes("sign in")?`Sign in to get ${i.name}.`:o.includes("timed out")?`This is taking longer than usual — your ${i.name} will appear shortly.`:"Couldn't complete your purchase — please try again."}function le(){const c=K(),{session:s,signIn:o}=Q(),_=z(),[u,x]=q(),[h,l]=n.useState("select"),[a,S]=n.useState(null),[j,w]=n.useState(null),[T,P]=n.useState(null),[M,g]=n.useState(null),[U,N]=n.useState(!1),C=n.useRef(null);n.useEffect(()=>()=>{var t;return(t=C.current)==null?void 0:t.abort()},[]);const E=n.useCallback(()=>{x(t=>{const r=new URLSearchParams(t);return r.delete("order"),r.delete("canceled"),r},{replace:!0})},[x]),b=n.useCallback(async t=>{l("processing");const r=new AbortController;C.current=r;try{const m=await L(t,{signal:r.signal,address:s==null?void 0:s.address,identity:s==null?void 0:s.identity});if(m.status==="credited"){P(m.creditsGranted??(a==null?void 0:a.credits)??0),l("success"),p("Shop Completed Buy Credits",{order_id:t,pack_usd:(a==null?void 0:a.usd)??null,credits:m.creditsGranted??(a==null?void 0:a.credits)??0,provider:f}),_.invalidateQueries({queryKey:["usd-balance"]});try{if(sessionStorage.getItem(J)){c("/cart",{state:{resumeCheckout:!0}});return}}catch{}try{const R=sessionStorage.getItem(Y);if(R){sessionStorage.removeItem(Y);const d=JSON.parse(R),B=(d==null?void 0:d.tokenId)??(d==null?void 0:d.itemId);if(d!=null&&d.contractAddress&&B){c(`/item/${d.contractAddress}/${B}`,{state:{item:d,resumeBuy:!0}});return}}}catch{}}else m.status==="pending"?(p("Shop Buy Credits Pending",{step:"grant",pack_usd:(a==null?void 0:a.usd)??null}),_.invalidateQueries({queryKey:["usd-balance"]}),l("pending")):(p("Shop Buy Credits Failed",{step:"grant",error_code:"grant_failed",pack_usd:(a==null?void 0:a.usd)??null}),g(m.error??`Couldn't add your ${i.name} — please try again.`),l("error"))}catch(m){$(m,{flow:"get_credits",step:"grant",order_id:t}),p("Shop Buy Credits Failed",{step:"grant",error_code:G(m),pack_usd:(a==null?void 0:a.usd)??null}),g(A(m)),l("error")}},[a,s,_]),V=n.useCallback(async t=>{if(!s){o();return}g(null),N(!1),S(t),l("paying"),p("Shop Started Buy Credits",{pack_usd:t.usd,credits:t.credits,provider:f});try{const r=await O(t.id,{address:s.address,identity:s.identity});if(r.mock)w(r);else if(r.url)p("Shop Redirected To Stripe",{order_id:r.orderId,pack_usd:t.usd,credits:t.credits}),window.location.href=r.url;else throw new Error("Checkout did not return a redirect url")}catch(r){$(r,{flow:"get_credits",step:"checkout",provider:f}),p("Shop Buy Credits Failed",{step:"checkout",error_code:G(r),pack_usd:t.usd}),g(A(r)),l("error")}},[s,o]),D=n.useCallback(()=>{j&&b(j.orderId)},[j,b]),v=n.useRef(!1);n.useEffect(()=>{if(v.current)return;const t=u.get("order");if(u.get("canceled")!=null){v.current=!0,p("Shop Buy Credits Cancelled",{order_id:t,provider:f}),E(),N(!0),l("select");return}t&&(l("processing"),s&&(v.current=!0,E(),b(t)))},[u,s]);function y(){var t;(t=C.current)==null||t.abort(),l("select"),S(null),w(null),P(null),g(null),N(!1)}return e.jsxs("div",{className:"getcredits",children:[e.jsxs("header",{className:"getcredits__head",children:[e.jsxs("h1",{className:"getcredits__title",children:["Get ",i.name]}),e.jsxs("p",{className:"muted",children:["Add ",i.name," to your account to shop. Pay with any card."]})]}),s?e.jsxs(e.Fragment,{children:[h==="select"&&e.jsxs(e.Fragment,{children:[U&&e.jsx("p",{className:"getcredits__note muted",role:"status",children:"Payment canceled — no charge was made. Pick a pack whenever you’re ready."}),e.jsx(X,{onSelect:t=>void V(t)})]}),h==="paying"&&a&&e.jsx(Z,{pack:a,checkout:j,onPaid:D,onCancel:y}),h==="processing"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(I,{size:40}),e.jsxs("p",{className:"getcredits__status-title",children:["Adding your ",i.name,"…"]}),e.jsx("p",{className:"muted",children:"Payment received. Just a moment while we top up your balance."})]}),h==="success"&&e.jsxs("div",{className:"getcredits__status getcredits__status--ok",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"getcredits__confetti","aria-hidden":!0,children:"🎉"}),e.jsx("p",{className:"getcredits__status-title",children:"You’re all set!"}),e.jsxs("p",{className:"muted",children:[e.jsxs("strong",{children:[e.jsx(k,{className:"ccy-mark"})," ",T]})," ",i.name," added to your account."]}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>c("/cart"),children:"Back to cart"}),e.jsxs("button",{className:"btn btn--ghost",onClick:y,children:["Get more ",i.name]})]})]}),h==="pending"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Your ",i.name," are on the way"]}),e.jsx("p",{className:"muted",children:"Your payment went through. It’s taking a little longer than usual to confirm — your balance will update automatically as soon as it lands, no need to pay again."}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>c("/cart"),children:"Back to cart"}),e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"})]})]}),h==="error"&&e.jsxs("div",{className:"getcredits__status getcredits__status--err",role:"alert",children:[e.jsx("p",{className:"getcredits__status-title",children:"Something went wrong"}),e.jsx("p",{className:"error",children:M}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn",onClick:y,children:"Try again"})})]})]}):e.jsxs("div",{className:"getcredits__status",role:"status",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Sign in to get ",i.name]}),e.jsxs("p",{className:"muted",children:["Connect your account to buy ",i.name," and start shopping."]}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn btn--purple",onClick:o,children:"Sign in"})})]})]})}function X({onSelect:c}){return e.jsx("div",{className:"packs",children:W.map(s=>e.jsxs("button",{type:"button",className:`pack${s.bestValue?" pack--best":""}`,onClick:()=>c(s),"aria-label":`Get ${F(s.credits)} for $${s.usd}`,children:[s.bestValue&&e.jsx("span",{className:"pack__ribbon",children:"Best value"}),e.jsxs("span",{className:"pack__credits",children:[e.jsx(k,{className:"pack__credits-ico"}),s.credits]}),e.jsx("span",{className:"pack__label",children:i.name}),e.jsxs("span",{className:"pack__price",children:["$",s.usd]}),e.jsxs("span",{className:"pack__cta",children:["Get ",i.name]})]},s.id))})}function Z({pack:c,checkout:s,onPaid:o,onCancel:_}){return e.jsxs("div",{className:"pay",children:[e.jsxs("div",{className:"pay__summary",children:[e.jsx("button",{className:"link",onClick:_,children:"← Choose a different pack"}),e.jsxs("div",{className:"pay__summary-row",children:[e.jsx("span",{children:"You’ll get"}),e.jsxs("strong",{children:[e.jsx(k,{className:"ccy-mark"})," ",F(c.credits)]})]}),e.jsxs("div",{className:"pay__summary-row pay__summary-row--total",children:[e.jsx("span",{children:"You pay"}),e.jsxs("strong",{children:["$",c.usd]})]})]}),e.jsx("div",{className:"pay__form",children:s!=null&&s.mock?e.jsx(ee,{onPaid:o,amountUsd:c.usd}):e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(I,{size:32}),e.jsx("p",{className:"muted",children:"Getting the payment form ready…"})]})})]})}function ee({onPaid:c,amountUsd:s}){const[o,_]=n.useState("4242 4242 4242 4242"),[u,x]=n.useState(!1);function h(){x(!0),setTimeout(()=>c(),700)}return e.jsxs("div",{className:"card-form","aria-label":"Payment details",children:[e.jsx("p",{className:"muted small card-form__note",children:"Demo mode — no real charge is made."}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Card number"}),e.jsx("input",{value:o,onChange:l=>_(l.target.value),disabled:u,inputMode:"numeric"})]}),e.jsxs("div",{className:"card-form__row",children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Expiry"}),e.jsx("input",{defaultValue:"12 / 34",disabled:u})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"CVC"}),e.jsx("input",{defaultValue:"123",disabled:u,inputMode:"numeric"})]})]}),e.jsx("button",{className:"btn btn--purple card-form__pay",onClick:h,disabled:u,children:u?"Processing…":`Pay $${s}`})]})}export{le as GetCredits,le as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-
|
|
1
|
+
import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-DHF4L8Ec.js";import{d as g,r as v}from"./index-CBmf80G9.js";import{C as c}from"./ConstantsUtil-BL7ODi4n.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-C3ngIw23.js";import{au as y}from"./NetworkUtil-bxmjbsdp.js";const b=g`
|
|
2
2
|
:host {
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as E,r as h,j as e,L as A}from"./react-C51i12iP.js";import{s as C,C as I,v as Q,i as L,a as R,n as F,b as K,ae as P}from"./index-C1u3RQ96.js";import{i as W,R as Y,f as G}from"./import-BCIlZ3yx.js";import{s as O}from"./wallet-kind-PnN45EW0.js";import"./ethers-DwWf2RqE.js";import"./buy-y9zg-9gr.js";import"./trade-encoding-42N07h92.js";import"./index-DNT62M3w.js";import"./mana-rate-TrkgOUFu.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,r)=>r===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,l=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",l>0?` ${l} ${l===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${l===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),l>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,l)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[l]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[l]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[l]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[l]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[l]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[l]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function se(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const r={...t};for(const s of g)r[s.oldTradeId]==null&&(r[s.oldTradeId]=s.suggestedCredits);return r})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,l=g.filter(t=>y(t.oldTradeId)),a=l.reduce((t,r)=>t+i(r),0);function m(t,r){const s=r.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(r=>({item:r,priceCredits:Math.max(1,i(r))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,r)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},r))}):U.map(t=>{const r=(c==null?void 0:c[t.key])??[];return r.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:r.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[l.length," item",l.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:l.length===0,onClick:()=>f(o(l)),children:["List all (",l.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{se as ImportListings};
|
|
1
|
+
import{u as E,r as h,j as e,L as A}from"./react-BMZSDQJw.js";import{i as C,C as I,t as Q,j as L,a as R,h as F,b as K,ad as P}from"./index-W4B_IWIP.js";import{i as W,R as Y,f as G}from"./import-w6IYTyx9.js";import{s as O}from"./wallet-kind-Bio8Yuti.js";import"./ethers-BZNCwGB1.js";import"./buy-DCyi2TCj.js";import"./trade-encoding-BOT9-UWu.js";import"./index-ge5YPyFz.js";import"./mana-rate-brJZyjav.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,r)=>r===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,l=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",l>0?` ${l} ${l===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${l===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),l>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,l)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[l]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[l]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[l]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[l]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[l]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[l]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function se(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const r={...t};for(const s of g)r[s.oldTradeId]==null&&(r[s.oldTradeId]=s.suggestedCredits);return r})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,l=g.filter(t=>y(t.oldTradeId)),a=l.reduce((t,r)=>t+i(r),0);function m(t,r){const s=r.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(r=>({item:r,priceCredits:Math.max(1,i(r))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,r)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},r))}):U.map(t=>{const r=(c==null?void 0:c[t.key])??[];return r.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:r.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[l.length," item",l.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:l.length===0,onClick:()=>f(o(l)),children:["List all (",l.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{se as ImportListings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.item-detail{max-width:1721px;margin:0 auto}.item-detail__crumbs{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted);margin-bottom:24px}.item-detail__crumb-link{background:none;border:0;padding:0;font:inherit;color:var(--muted)}.item-detail__crumb-link:hover{color:var(--text)}.item-detail__crumb-sep{color:var(--muted-2)}.item-detail__crumb-current{color:var(--text);font-weight:600}.item-detail__main{display:grid;grid-template-columns:minmax(0,1045fr) minmax(0,514fr);gap:48px;align-items:start;max-width:1607px;margin:0 auto}@media(max-width:900px){.item-detail__main{grid-template-columns:1fr;gap:24px;max-width:none}}.item-detail__preview{position:relative;aspect-ratio:1045 / 752;border-radius:16px;overflow:hidden;background:var(--media)}@media(max-width:900px){.item-detail__preview{aspect-ratio:1 / 1}}.item-detail__preview iframe,.item-detail__preview>*{width:100%;height:100%;border:0;display:block}.item-detail__preview>.item-preview__toggle{position:absolute;top:16px;left:16px;z-index:2;width:auto;height:auto;display:inline-flex;gap:2px;padding:3px;background:#ffffffeb;border:1px solid var(--line);border-radius:999px;box-shadow:0 1px 4px #0000001f}.item-preview__toggle button{border:0;background:none;cursor:pointer;padding:6px 16px;border-radius:999px;font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);transition:background .12s ease,color .12s ease}.item-preview__toggle button.is-active{background:var(--text);color:#fff}.item-preview__toggle button:not(.is-active):hover{color:var(--text)}.item-detail__preview>.item-preview__emote-controls{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:2;width:min(360px,88%);height:auto;display:flex;align-items:center;background:#fffffff0;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);border:1px solid var(--line);border-radius:var(--radius-pill);padding:6px 12px;box-shadow:0 2px 10px #1615181f}.item-preview__emote-controls .MuiBox-root{position:static;width:100%;margin:0;padding:0;display:flex;align-items:center;gap:10px}.item-preview__emote-controls .MuiButtonBase-root{min-width:0;padding:0;margin:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:none!important;box-shadow:none!important;color:var(--muted);flex:0 0 auto;transition:background .12s ease,color .12s ease}.item-preview__emote-controls .MuiButtonBase-root .MuiSvgIcon-root{font-size:20px;margin:0}.item-preview__emote-controls .MuiBox-root>.MuiButtonBase-root:first-child{width:34px;height:34px;background:var(--accent)!important;color:#fff}.item-preview__emote-controls .MuiBox-root>.MuiButtonBase-root:first-child:hover{background:var(--text)!important}.item-preview__emote-controls .MuiBox-root>input+.MuiButtonBase-root{width:30px;height:30px;color:var(--muted)}.item-preview__emote-controls .MuiBox-root>input+.MuiButtonBase-root:hover{background:var(--media)!important;color:var(--text)}.item-preview__emote-controls input[type=range]{flex:1 1 auto;width:auto;min-width:0;height:4px;margin:0;padding:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.item-preview__emote-controls input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:999px;background:var(--line-strong)}.item-preview__emote-controls input[type=range]::-moz-range-track{height:4px;border-radius:999px;background:var(--line-strong)}.item-preview__emote-controls input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:13px;height:13px;margin-top:-4.5px;border-radius:50%;background:var(--accent);border:2px solid #fff;box-shadow:0 1px 3px #1615184d;cursor:pointer}.item-preview__emote-controls input[type=range]::-moz-range-thumb{width:13px;height:13px;border-radius:50%;background:var(--accent);border:2px solid #fff;box-shadow:0 1px 3px #1615184d;cursor:pointer}.item-preview__emote-controls input[type=range]:focus-visible{outline:none}.item-preview__emote-controls input[type=range]:focus-visible::-webkit-slider-thumb{outline:2px solid var(--accent);outline-offset:2px}.item-detail__preview>.item-preview__note{position:absolute;bottom:14px;left:50%;transform:translate(-50%);z-index:2;width:auto;height:auto;max-width:88%;margin:0;text-align:center;background:#161518c7;color:#fff;font-size:12px;font-weight:500;padding:6px 12px;border-radius:999px}.item-detail__preview>.item-preview__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;display:flex;align-items:center;justify-content:center;width:100%;height:100%;background:transparent}.item-preview__spinner{width:34px;height:34px;border-radius:50%;border:3px solid var(--line);border-top-color:var(--accent);animation:item-preview-spin .8s linear infinite}@keyframes item-preview-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.item-preview__spinner{animation-duration:2.4s}}.item-detail__info{display:flex;flex-direction:column;gap:0}.item-detail__info-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.item-detail__title{font-size:28px;font-weight:600;line-height:34px;color:var(--text-2)}.item-detail__fav{flex:none;width:40px;height:40px;border-radius:50%;border:0;background:var(--media);display:grid;place-items:center;color:var(--text-2);cursor:pointer;transition:color .12s ease,background .12s ease}.item-detail__fav:hover{background:var(--line)}.item-detail__fav.is-on{color:var(--dcl-red)}.item-detail__fav .ico-heart{width:18px;height:18px}.item-detail__label{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:500;text-transform:uppercase;letter-spacing:0;color:var(--muted)}.item-detail__chips{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:12px}.item-detail__chips .chip{height:24px;padding:0 8px;gap:3px;font-size:13px;font-weight:500;border-radius:4px;letter-spacing:.02em;text-transform:uppercase}.item-detail__chip{background:var(--chip);color:var(--text-2)}.item-detail__chip-ico{width:18px;height:18px;color:var(--text-2)}.item-detail__section{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.item-detail__description{margin-top:15px;gap:11px}.item-detail__desc-text{margin:0;color:var(--text-2);font-size:14px;line-height:30px;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;overflow:hidden}.item-detail__desc-text.is-expanded{-webkit-line-clamp:unset;overflow:visible}.item-detail__desc-toggle{font-size:13px;align-self:flex-start}.item-detail__meta{display:flex;justify-content:space-between;gap:16px;margin-top:32px}.item-detail__meta-col{display:flex;flex-direction:column;gap:15px;min-width:0}.item-detail__meta-col--collection{align-items:flex-start}.item-detail__creator.creator{color:var(--accent);font-size:14px;gap:12px}.item-detail__creator .creator__ava{width:48px;height:48px}.item-detail__creator .creator__ava--letter{font-size:18px}.item-detail__creator .creator__name{color:var(--accent);font-weight:500;text-decoration:underline}.item-detail__creator.creator--link:hover .creator__name{color:var(--brand-violet)}.item-detail__divider{border:0;border-top:1px solid #cfcdd4;margin:24px 0 0;width:100%}.item-detail__price-block{margin-top:16px}.item-detail__price-row{display:flex;align-items:flex-start;gap:16px;width:100%}.item-detail__price-col{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:8px}.item-detail__stock-col{flex:0 0 auto;display:flex;flex-direction:column;align-items:flex-end;gap:8px;text-align:right}.item-detail__stock-value{font-size:18px;font-weight:500;line-height:1;color:var(--text-2)}.item-detail__price-label{font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:0;color:#5e5b67}.item-detail__price{display:flex;align-items:center;gap:10px;font-weight:700;color:var(--text)}.item-detail__diamond{width:30px;height:30px;color:var(--brand-violet)}.item-detail__price-value{font-size:30px;line-height:1}.item-detail__price--none{font-size:18px;color:var(--muted)}.item-detail__price--sale{flex-wrap:wrap;gap:10px 14px}.item-detail__price--sale .item-detail__price,.item-detail__price--sale .item-detail__price-value,.item-detail__price--sale .item-detail__diamond{color:var(--dcl-red)}.item-detail__price-was{display:inline-flex;align-items:center;gap:6px;color:var(--muted);text-decoration:line-through;font-weight:600;font-size:20px}.item-detail__diamond--was{width:18px;height:18px;color:var(--muted)}.item-detail__sale-badge{display:inline-flex;align-items:center;background:var(--dcl-red);color:#fff;font-weight:800;font-size:13px;letter-spacing:.03em;text-transform:uppercase;border-radius:6px;padding:4px 10px}.item-detail__countdown{display:inline-flex;align-items:center;gap:5px;background:var(--rarity-bg);color:var(--accent);font-size:13px;font-weight:700;border-radius:6px;padding:4px 10px;white-space:nowrap}.item-detail__countdown .sale-countdown__ico{width:14px;height:14px}.item-detail__ctas{display:flex;flex-direction:column;gap:12px;margin-top:20px}.item-detail__cta{width:100%;height:48px;border-radius:8px;font-size:15px;font-weight:600;letter-spacing:.46px;display:flex;align-items:center;justify-content:center;gap:8px}.item-detail__cta-price{display:none;align-items:center;gap:6px}.item-detail__cta-diamond{width:20px;height:20px;color:#fff}.item-detail__addcart{width:100%;height:48px;display:flex;align-items:center;justify-content:center;gap:8px;background:var(--black-btn);color:var(--soft-white);border:0;border-radius:8px;font-weight:600;font-size:15px;text-transform:uppercase;letter-spacing:.46px;cursor:pointer;transition:filter .15s ease}.item-detail__addcart:hover:not(:disabled){filter:brightness(1.35)}.item-detail__addcart:disabled{opacity:.55;cursor:default}.item-detail__addcart-ico{width:20px;height:20px}.item-detail__status{margin:0;font-size:13px}.item-detail__own-note{margin:0;font-size:14px}.item-detail__own-note a{color:var(--accent);font-weight:600}@media(max-width:900px){.item-detail__title{font-size:20px;line-height:24px}.item-detail__info-head{order:0}.item-detail__chips{order:1;margin-top:10px}.item-detail__meta{order:2;margin-top:20px}.item-detail__description{order:3;margin-top:20px}.item-detail__divider{order:4;margin-top:20px}.item-detail__price-block{order:5;margin-top:16px}.item-detail__ctas{order:6}.item-detail__status{order:7}.item-detail{padding-bottom:88px}.item-detail__ctas--buttons{position:fixed;left:0;right:0;bottom:0;z-index:40;margin-top:0;padding:12px 16px calc(12px + env(safe-area-inset-bottom));background:var(--soft-white);box-shadow:0 -4px 16px #1615181f}.item-detail__ctas--dual{flex-direction:row;align-items:stretch;gap:12px}.item-detail__ctas--dual .item-detail__cta{flex:1 1 auto;width:auto}.item-detail__ctas--dual .item-detail__cta-price{display:inline-flex}.item-detail__ctas--dual .item-detail__addcart{flex:0 0 auto;width:56px;padding:0}.item-detail__ctas--dual .item-detail__addcart-label{display:none}.item-detail__ctas--dual .item-detail__addcart-ico{margin:0}}.collection-carousel{margin-top:64px}.collection-carousel__head{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.collection-carousel__title{font-size:22px;font-weight:700;color:var(--text)}.collection-carousel__viewall{display:inline-flex;align-items:center;gap:4px;background:none;border:0;padding:0;color:var(--accent);font-weight:700;font-size:13px;letter-spacing:.046em;text-transform:uppercase;cursor:pointer;white-space:nowrap}.collection-carousel__viewall:hover{text-decoration:underline}.collection-carousel__viewall-ico{width:16px;height:16px;transform:rotate(-90deg)}.collection-carousel__viewport{position:relative}.collection-carousel__arrow{position:absolute;top:112px;transform:translateY(-50%);z-index:5;width:53px;height:53px;padding:0;border:0;background:transparent;cursor:pointer;filter:drop-shadow(0 2px 6px rgba(0,0,0,.18));transition:transform .15s ease,filter .15s ease,opacity .15s ease}.collection-carousel__arrow img{display:block;width:100%;height:100%}.collection-carousel__arrow--left{left:-40px}.collection-carousel__arrow--right{right:-40px}.collection-carousel__arrow--left img{transform:scaleX(-1)}.collection-carousel__arrow:hover:not(:disabled){transform:translateY(-50%) scale(1.07)}.collection-carousel__arrow:disabled{opacity:0;pointer-events:none}@media(prefers-reduced-motion:reduce){.collection-carousel__arrow{transition:none}}@media(max-width:900px){.collection-carousel__arrow{display:none}}.collection-carousel__track{display:flex;gap:16px;overflow-x:auto;padding:12px 10px;margin:0 -10px;scroll-snap-type:x proximity;scrollbar-width:none}.collection-carousel__track::-webkit-scrollbar{display:none}.collection-carousel__track>.card{flex:0 0 281px;scroll-snap-align:start}@media(max-width:720px){.collection-carousel__track>.card{flex:0 0 85%}}.collection-carousel__dots{display:flex;align-items:center;justify-content:center;gap:8px;margin-top:18px}.collection-carousel__dot{width:10px;height:10px;border-radius:50%;border:0;padding:0;background:var(--line-strong);opacity:.5;cursor:pointer;transition:opacity .12s ease,background .12s ease,transform .12s ease}.collection-carousel__dot:hover{opacity:.8}.collection-carousel__dot.is-active{background:var(--accent);opacity:1;transform:scale(1.1)}.item-detail--notfound{min-height:46vh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px}.item-detail__notfound-ico{width:44px;height:44px;opacity:.4}.item-detail__notfound-title{font-size:22px}.item-detail--notfound .btn{margin-top:6px}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DEFc7rHy.js","assets/react-BMZSDQJw.js","assets/index-W4B_IWIP.js","assets/ethers-BZNCwGB1.js","assets/index-D2idpE6X.css","assets/emotion-styled.browser.esm-C2X3f31i.js","assets/useTheme-BSc7aqCZ.js","assets/CircularProgress-BGTYLSVF.js","assets/index-FLQXl_Se.js","assets/useTheme-0gLXH6kA.js","assets/CssVarsProvider-CxQAolcH.js","assets/getOverlayAlpha-DIkhrJTf.js","assets/index-BMwA__hl.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as X,r as n,j as e,d as ve,b as je,L as Ne}from"./react-BMZSDQJw.js";import{a as ee,a2 as ge,h as Ce,ai as we,m as ke,n as Ie,a5 as Ae,a3 as Y,t as O,k as ie,a6 as J,aj as Se,j as re,C as T,ae as G,_ as Z,x as Ee,D as Le,z as Pe,aw as Be,W as Te,g as K,e as he,ax as Fe,ay as le,A as Me,af as ne,u as ce,b as D,az as Re,aA as $e,aB as We,aC as qe,aD as Ve,ap as De,aE as Oe,aF as Ke,ag as ze,aG as de,aH as Ue,an as Ye,aI as Ge,aJ as Qe,ao as He,aK as Je}from"./index-W4B_IWIP.js";import{b as oe}from"./buy-DCyi2TCj.js";import{g as Ze,b as Xe,w as es,S as ss,G as as}from"./buy-gasless-CgSRLXqb.js";import{C as ts,c as is}from"./payments-DJNklmWA.js";import{R as ue}from"./resume-buy-Bf0zIH7y.js";import{C as rs}from"./CircularProgress-BGTYLSVF.js";import"./ethers-BZNCwGB1.js";import"./trade-encoding-BOT9-UWu.js";import"./index-ge5YPyFz.js";function me(a){const i=a,t=(i.message??"").toLowerCase();return i.code===4001||t.includes("reject")||t.includes("denied")||t.includes("cancel")?"You cancelled the request.":t.includes("not for sale")||t.includes("not found")||t.includes("404")?"This item was just sold or removed.":t.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete the purchase — please try again."}function ls(a){const i=a;return i.code===402||i.status===402||(i.message??"").toLowerCase().includes("insufficient")}const $=ts.slice(0,3);function ns({item:a,onClose:i,resume:t=!1}){var P,M;const{session:l}=ee(),{data:_}=ge(l),p=Ce(),y=X(),[u,s]=n.useState("loading"),[w,j]=n.useState(null),[f,b]=n.useState(""),[k,v]=n.useState(a.priceCredits),[o,c]=n.useState(null),N=n.useRef(null),C=(o==null?void 0:o.credits)??k,F=(_==null?void 0:_.credits)??0;n.useEffect(()=>{let r=!1;if(!l){s("error"),j("Sign in to check out.");return}const g=m=>{const x=m-((_==null?void 0:_.credits)??0),h=$.find(A=>A.credits>=x)??$[$.length-1];b(h.id),O("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:m,credits_balance:(_==null?void 0:_.credits)??0,shortfall:Math.max(0,x)}),s("nofunds")};return(async()=>{var m,x;try{const h=await we(a);if(!h)throw new Error("not for sale");if(ke(h,l.address))throw new Error("You can't buy your own listing.");const A=Ie((x=(m=h.received)==null?void 0:m[0])==null?void 0:x.amount);if(!Number.isFinite(A)||A<=0)throw new Error("price unavailable");const S=Math.ceil(A/10);if(r)return;if(v(S),_!=null&&_.credits<S){g(S);return}try{const{credit:E,maxCreditedValue:H,usdCents:W}=await Ae(l.identity,A,h.id);if(r){Y(l.identity,[E.id]).catch(()=>{});return}N.current=E.id;const q=Math.ceil(W/10);v(q);const V={trade:h,credit:E,maxCreditedValue:H,usdCents:W,credits:q};c(V),t?R(V):s("ready")}catch(E){if(r)return;if(ls(E)){g(S);return}throw E}}catch(h){if(r)return;O(J(h)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:ie(h)}),s("error"),j(me(h))}})(),()=>{r=!0,N.current&&l&&(Y(l.identity,[N.current]).catch(()=>{}),N.current=null)}},[]);async function R(r=o){if(!l||!r)return;s("processing"),j(null);let g=!1;try{const m={trade:r.trade,buyer:l.address,signer:l.signer,credits:[r.credit],maxCreditedValue:r.maxCreditedValue};let x;if(Ze())try{x=await Xe(m),await es(x),g=!0}catch(h){if(h instanceof ss)g=!0;else if(h instanceof as)x=await oe(m);else throw h}else x=await oe(m);N.current=null,O("Shop Completed Purchase",{...Se([a]),payment_type:"credits",no_crypto_step:g,transaction_hash:x??null}),p.invalidateQueries({queryKey:["usd-balance"]}),s("complete")}catch(m){J(m)||re(m,{flow:"buy",step:"submit",gasless:g}),Y(l.identity,[r.credit.id]).catch(()=>{}),N.current=null,O(J(m)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:ie(m)}),p.invalidateQueries({queryKey:["usd-balance"]}),j(me(m)),s("error")}}async function I(){if(!(!f||!l)){try{sessionStorage.setItem(ue,JSON.stringify(a))}catch{}o&&Y(l.identity,[o.credit.id]).catch(()=>{}),N.current=null,s("loading");try{const r=await is(f,{address:l.address,identity:l.identity});if(r.url){window.location.href=r.url;return}y("/credits")}catch(r){re(r,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(ue)}catch{}j("Couldn't start the credits checkout — please try again."),s("error")}}}const z=u==="processing",Q=u==="complete"?"Purchase complete!":u==="nofunds"?"Buy Credits and Item":"Buy Asset";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${a.name}`,children:[e.jsx("div",{className:"buy-modal__scrim",onClick:z?void 0:i,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${u==="processing"||u==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:Q}),!z&&e.jsx("button",{className:"buy-modal__x",onClick:i,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:u==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(T,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:G(F)})]})]}),u==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(rs,{size:44})}),u==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:w}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:i,children:"Close"})})]}),u==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy"," ",e.jsxs("b",{children:[Math.max(0,C-F)," Credits"]})," to purchase this item."]})]}),e.jsx(_e,{item:a,priceCredits:C}),e.jsx("div",{className:"buy-modal__packs",children:$.map(r=>{const g=r.credits,m=r.id===f;return e.jsxs("button",{className:`buy-modal__pack${m?" buy-modal__pack--on":""}`,onClick:()=>b(r.id),children:[e.jsx(T,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:G(g)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",r.usd.toFixed(2),")"]})]},r.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(T,{className:"buy-modal__total-ico"}),e.jsx("span",{children:G(((P=$.find(r=>r.id===f))==null?void 0:P.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((M=$.find(r=>r.id===f))==null?void 0:M.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:i,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:I,children:"Buy"})]})]}),u==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(_e,{item:a,priceCredits:C}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient buy-modal__btn--full",onClick:()=>R(),children:"Buy"})})]}),u==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:t?"Completing Purchase…":"Completing transaction…"}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),u==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>y("/assets?tab=mine"),children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:i,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function _e({item:a,priceCredits:i}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:a.thumbnail?e.jsx("img",{src:a.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:a.name,children:a.name||"Item"}),a.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",a.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(T,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:G(i)})]})]})]})}const cs=n.lazy(async()=>{const[{EmoteControls:a},{Experimental_CssVarsProvider:i},{light:t}]=await Promise.all([Z(()=>import("./index-DEFc7rHy.js").then(l=>l.i),__vite__mapDeps([0,1,2,3,4,5,6,7])),Z(()=>import("./index-FLQXl_Se.js"),__vite__mapDeps([8,2,1,3,4,9,6,10,11])),Z(()=>import("./index-BMwA__hl.js"),__vite__mapDeps([12,2,1,3,4,13,11,10,6]))]);return{default:l=>e.jsx(i,{theme:t,children:e.jsx(a,{...l})})}});function ds(a){return e.jsx(n.Suspense,{fallback:null,children:e.jsx(cs,{...a})})}function os({item:a}){const i=ee(o=>{var c;return(c=o.session)==null?void 0:c.address}),{data:t,isLoading:l}=Ee(i),_=i&&t?i:"default",p=a.category==="emote",[y,u]=n.useState("avatar"),s=!p&&y==="item",[w,j]=n.useState(!0);n.useEffect(()=>{j(!0)},[a.id,s]);const f=!!i&&!!t,b=f&&Le(a,Pe(t)),k=Be(a)[0],v=f&&!b&&!p;return e.jsxs(e.Fragment,{children:[l?null:e.jsx(Te,{id:"shop-item-preview",contractAddress:a.contractAddress,tokenId:a.tokenId??void 0,itemId:a.tokenId?void 0:a.itemId??void 0,profile:s?void 0:b?_:"default",bodyShape:s||b?void 0:k,type:p?void 0:s?K.PreviewType.WEARABLE:K.PreviewType.AVATAR,emote:p||s?void 0:K.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:p?1.5:void 0,wheelStart:p?100:void 0,dev:he.chainId===80002,onLoad:()=>j(!1)},a.id),l||w?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,v&&!s?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",Fe(k)," body — this item isn’t made for your avatar’s shape."]}):null,p?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(ds,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsx("button",{type:"button",className:y==="avatar"?"is-active":"","aria-pressed":y==="avatar",onClick:()=>u("avatar"),children:"On avatar"}),e.jsx("button",{type:"button",className:y==="item"?"is-active":"","aria-pressed":y==="item",onClick:()=>u("item"),children:"Item"})]})]})}function us({title:a,items:i,onViewAll:t}){const l=n.useRef(null),[_,p]=n.useState(1),[y,u]=n.useState(0),[s,w]=n.useState(!0),[j,f]=n.useState(!1),b=n.useCallback(()=>{const o=l.current;if(!o)return;const{scrollLeft:c,scrollWidth:N,clientWidth:C}=o,F=Math.max(1,Math.ceil(N/C));p(F),u(Math.min(F-1,Math.round(c/C))),w(c<=1),f(c+C>=N-1)},[]);if(n.useEffect(()=>{b();const o=l.current;if(o)return o.addEventListener("scroll",b,{passive:!0}),window.addEventListener("resize",b),()=>{o.removeEventListener("scroll",b),window.removeEventListener("resize",b)}},[b,i.length]),i.length===0)return null;function k(o){const c=l.current;c&&c.scrollBy({left:o*c.clientWidth,behavior:"smooth"})}function v(o){const c=l.current;c&&c.scrollTo({left:o*c.clientWidth,behavior:"smooth"})}return e.jsxs("section",{className:"collection-carousel",children:[e.jsxs("div",{className:"collection-carousel__head",children:[e.jsx("h2",{className:"collection-carousel__title",children:a}),t?e.jsxs("button",{className:"collection-carousel__viewall",onClick:t,children:["View all",e.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),e.jsxs("div",{className:"collection-carousel__viewport",children:[e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>k(-1),"aria-label":"Scroll left",disabled:s,children:e.jsx("img",{src:le,alt:"","aria-hidden":!0})}),e.jsx("div",{className:"collection-carousel__track",ref:l,children:i.map(o=>e.jsx(Me,{item:o},o.id))}),e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>k(1),"aria-label":"Scroll right",disabled:j,children:e.jsx("img",{src:le,alt:"","aria-hidden":!0})})]}),_>1?e.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:_}).map((o,c)=>e.jsx("button",{className:`collection-carousel__dot${c===y?" is-active":""}`,"aria-label":`Go to page ${c+1}`,"aria-current":c===y?"true":void 0,onClick:()=>v(c)},c))}):null]})}function ms(a){let i=0;for(let t=0;t<a.length;t++)i=i*31+a.charCodeAt(t)>>>0;return`hsl(${i%360}, 52%, 45%)`}function _s({contractAddress:a,name:i,className:t}){const l=X();if(!a||!i)return null;const _=(i.trim()[0]||"?").toUpperCase();return e.jsxs("button",{className:`creator creator--link${t?` ${t}`:""}`,onClick:p=>{p.stopPropagation(),l(`/collection/${a}`)},children:[e.jsx("span",{className:"creator__ava creator__ava--letter",style:{backgroundColor:ms(a)},"aria-hidden":!0,children:_}),e.jsx("span",{className:"creator__name",children:i})]})}function hs(a){return Object.values(K.Rarity).includes(a)}function ps(a){return a==="male"?"Male":a==="female"?"Female":a==="unisex"?"Unisex":null}function bs(a){return a.wearableCategory?a.wearableCategory.replace(/_/g," "):a.category==="emote"?"Emote":"Wearable"}function Is(){const{contractAddress:a,tokenId:i}=ve(),{state:t}=je(),l=X(),_=ne(d=>d.add),p=ne(d=>d.items),y=ce(d=>d.toggle),{session:u}=ee(),[s,w]=n.useState(()=>t!=null&&t.item?{...t.item,tradeId:t.tradeId??t.item.tradeId}:{id:`${a}-${i}`,name:"",creator:"",contractAddress:a??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:he.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:i??void 0,tradeId:t==null?void 0:t.tradeId}),[j,f]=n.useState(!1),[b,k]=n.useState(!!(t!=null&&t.resumeBuy));n.useEffect(()=>{t!=null&&t.resumeBuy&&f(!0)},[t==null?void 0:t.resumeBuy]);const{data:v=[],isFetched:o}=D({queryKey:["collection-items",s.contractAddress],enabled:!!s.contractAddress,queryFn:()=>Ye(s.contractAddress,{first:20}).then(d=>d.items)}),{data:c,isLoading:N}=D({queryKey:["shop-item",s.contractAddress,i],enabled:!(t!=null&&t.item)&&!!s.contractAddress&&!!i,queryFn:()=>Ge(s.contractAddress,i)});n.useEffect(()=>{c&&w(d=>d.tradeId?d:{...c})},[c]);const[C,F]=n.useState(!1),{data:R=""}=D({queryKey:["item-desc",s.contractAddress,s.itemId],enabled:!!s.contractAddress&&!!s.itemId,staleTime:5*6e4,queryFn:()=>Qe(s.contractAddress,s.itemId)}),{data:I}=D({queryKey:["collection-meta",s.contractAddress],enabled:!!s.contractAddress,staleTime:5*6e4,queryFn:()=>He(s.contractAddress)});n.useEffect(()=>{if(s.name||c||v.length===0)return;const d=i&&v.find(L=>L.tokenId===i||L.itemId===i)||v.find(L=>L.contractAddress===s.contractAddress);d&&w(L=>({...d,tradeId:L.tradeId??d.tradeId}))},[v,c]);const z=n.useMemo(()=>{const d=new Set,L=[];for(const B of v){if(B.id===s.id||s.itemId&&B.itemId===s.itemId||s.tokenId&&B.tokenId===s.tokenId)continue;const te=`${B.contractAddress}-${B.itemId??B.tokenId??B.id}`;d.has(te)||(d.add(te),L.push(B))}return L},[v,s.id,s.itemId,s.tokenId]),{data:Q,isLoading:P}=D({queryKey:["detail-trade",s.id,s.tradeId,s.contractAddress,s.itemId],enabled:!!s.contractAddress,queryFn:async()=>{if(s.tradeId)return s.tradeId;if(s.itemId){const d=await Je(s.contractAddress,s.itemId);return(d==null?void 0:d.id)??null}return null}}),M=s.tradeId??Q??void 0,r=!!M,g=Re({priceCredits:s.priceCredits,compareAtCredits:s.compareAtCredits,saleEndsAt:s.saleEndsAt}),m=n.useMemo(()=>({...s,tradeId:M,id:M??s.id}),[s,M]),x=p.some(d=>d.id===m.id),h=ce(d=>!!d.items[s.id]),A=n.useRef(null);n.useEffect(()=>{!s.name||P||A.current===s.id||(A.current=s.id,O("Shop Viewed Item",{...$e(s),for_sale:r}),We(s))},[s.id,s.name,P,r]);const S=`${a}/${i}`,E=n.useRef(S);n.useEffect(()=>{E.current!==S&&(E.current=S,t!=null&&t.item&&w({...t.item,tradeId:t.tradeId??t.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[S]);function H(){!r||x||U||_(m,"item_detail")}const W=hs(s.rarity)?s.rarity:K.Rarity.COMMON,q=ps(s.gender),V=qe(s),se=Ve(s.gender),pe=r&&g,be="More from this collection",U=De(s,u==null?void 0:u.address),ae=r?x?"In cart":P?"Checking…":"Add to cart":"Not for sale",xe=typeof s.available=="number"&&s.available>0&&!s.tokenId,fe=!U&&r,ye=N||!!s.contractAddress&&!o;return!s.name&&!ye?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx("span",{className:"ico ico-cart item-detail__notfound-ico","aria-hidden":!0}),e.jsx("h1",{className:"item-detail__notfound-title",children:"This item isn’t available"}),e.jsx("p",{className:"muted",children:"It may have been delisted or moved. Browse Collectibles for something else."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>l("/assets"),children:"Browse Collectibles"})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>l("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:s.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsx("div",{className:"item-detail__preview",children:s.name?e.jsx(os,{item:s}):e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})})}),e.jsxs("div",{className:"item-detail__info",children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:s.name||"Loading…"}),e.jsx("button",{className:`item-detail__fav${h?" is-on":""}`,onClick:()=>y(s),"aria-pressed":h,"aria-label":h?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${h?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:Ke(W),color:Oe(W)},children:s.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[V?e.jsx("span",{className:`ico ico-${V} item-detail__chip-ico`,"aria-hidden":!0}):null,bs(s)]}),q?e.jsxs("span",{className:"chip item-detail__chip",children:[se?e.jsx("span",{className:`ico ico-${se} item-detail__chip-ico`,"aria-hidden":!0}):null,q]}):null]}),R?e.jsxs("div",{className:"item-detail__section item-detail__description",children:[e.jsx("div",{className:"item-detail__label",children:"Description"}),e.jsx("p",{className:`item-detail__desc-text${C?" is-expanded":""}`,children:R}),R.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>F(d=>!d),children:C?"Show less":"Read more"}):null]}):null,s.creator||I!=null&&I.name?e.jsxs("div",{className:"item-detail__meta",children:[s.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(ze,{address:s.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,I!=null&&I.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:"Collection"}),e.jsx(_s,{contractAddress:s.contractAddress,name:I.name,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),r?pe?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(T,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:s.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(T,{className:"item-detail__diamond item-detail__diamond--was"}),s.compareAtCredits]}),de(s.compareAtCredits,s.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",de(s.compareAtCredits,s.priceCredits),"%"]}):null,e.jsx(Ue,{endsAt:s.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(T,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:s.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"})]}),xe?e.jsxs("div",{className:"item-detail__stock-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Stock"}),e.jsx("div",{className:"item-detail__stock-value",children:s.available})]}):null]})}),e.jsx("div",{className:`item-detail__ctas${U?"":" item-detail__ctas--buttons"}${fe?" item-detail__ctas--dual":""}`,children:U?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(Ne,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[r?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>f(!0),disabled:P,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(T,{className:"item-detail__cta-diamond"}),s.priceCredits]})]}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:H,disabled:!r||x||P,"aria-label":ae,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),e.jsx("span",{className:"item-detail__addcart-label",children:ae})]})]})})]})]}),e.jsx(us,{title:be,items:z,onViewAll:s.contractAddress?()=>l(`/collection/${s.contractAddress}`):void 0}),j?e.jsx(ns,{item:m,resume:b,onClose:()=>{f(!1),k(!1)}}):null]})}export{Is as ItemDetail,Is as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as l}from"./react-
|
|
1
|
+
import{r as i,j as l}from"./react-BMZSDQJw.js";function a({hasNextPage:e,isFetching:r,onLoadMore:n}){const t=i.useRef(null);return i.useEffect(()=>{const s=t.current;if(!s||!e)return;const o=new IntersectionObserver(u=>{var c;(c=u[0])!=null&&c.isIntersecting&&!r&&n()},{rootMargin:"600px 0px"});return o.observe(s),()=>o.disconnect()},[e,r,n]),e?l.jsx("div",{className:"load-more",ref:t,children:l.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:r,children:r?"Loading…":"Load more"})}):null}export{a as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as U,r as d,j as s,L as re}from"./react-BMZSDQJw.js";import{g as z,e as V,v as le,h as B,C as q,i as w,p as ee,t as P,ad as G,j as W,k as se,a as ce,b as D,aq as oe,d as de,ar as me}from"./index-W4B_IWIP.js";import{f as ue}from"./import-w6IYTyx9.js";import{c as he}from"./buy-DCyi2TCj.js";import{a as pe,b as ge,i as be,e as ye,c as xe}from"./trade-encoding-BOT9-UWu.js";import{s as je}from"./wallet-kind-Bio8Yuti.js";import{L as fe}from"./LoadMore-Borbhtjd.js";import{u as _e}from"./useInfiniteGrid-BK47MfTg.js";import"./ethers-BZNCwGB1.js";import"./mana-rate-brJZyjav.js";import"./index-ge5YPyFz.js";const F=()=>`${V.builderServerUrl}/v1`;function ae(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 ne(e,i){const n=await le(e,{method:"GET",identity:i,metadata:{}});if(!n.ok)throw new Error(`builder-server ${n.status}: ${await n.text()}`);const c=await n.json();return c.data??c}function Ne(e,i){const n=i-e;return n>0?n:0}function ve(e){var i,n,c,r,l;return((n=(i=e.data)==null?void 0:i.wearable)==null?void 0:n.category)??((r=(c=e.data)==null?void 0:c.emote)==null?void 0:r.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function J(e){return`${F()}/storage/contents/${e}`}function $(e,i){if(!e)return"";if(/^https?:\/\//.test(e))return e;const n=i==null?void 0:i[e];return n?J(n):/^(ba|Qm)/.test(e)?J(e):""}async function Ie(e,i){try{const n=await fetch(`${F()}/items/${e}/${i}/contents`);if(!n.ok)return{};const c=await n.json();return c.data??c}catch{return{}}}async function ke(e,i,n){const c=$(e.thumbnail,e.contents)||$("thumbnail.png",e.contents);if(c)return c;if(i&&n){const r=await Ie(i,n);return $(e.thumbnail,r)||$("thumbnail.png",r)||$("image.png",r)}return""}async function Se(e,i){const n=`${F()}/${e.toLowerCase()}/collections?is_published=true`,c=await ne(n,i);return ae(c).filter(r=>r.is_published&&!!r.contract_address).map(r=>({id:r.id,name:r.name,contractAddress:r.contract_address.toLowerCase(),isPublished:r.is_published,isApproved:r.is_approved,minters:(r.minters??[]).map(l=>l.toLowerCase())}))}async function we(e,i){const n=`${F()}/collections/${e.id}/items`,c=await ne(n,i);return(await Promise.all(ae(c).map(async l=>{const v=l.rarity??"common",f=Number(l.total_supply??0)||0;let m;try{m=z.Rarity.getMaxSupply(v)}catch{m=0}const _=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:_,blockchainItemId:p,name:l.name,category:ve(l),rarity:v,thumbnail:await ke(l,_,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:f,maxSupply:m,remainingSupply:Ne(f,m),minters:e.minters}}))).filter(Ce)}function Ce(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function Ae(e,i){const n=await Se(e,i);return(await Promise.all(n.map(async r=>{try{return await we(r,i)}catch{return[]}}))).flat()}const Pe=1e3*60*60*24*182;function $e(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't list your item — please try again."}function Le({asset:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[f,m]=d.useState(null),[_,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null);async function C(){p(null);const o=Number(l);if(!Number.isInteger(o)||o<=0){p("Enter a whole number of credits");return}k(!0);try{m("Getting your item ready…"),await pe({signer:i.signer,contractAddress:e.contractAddress,chainId:e.chainId}),m("Listing your item…");const N=await ge({signer:i.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:o/10,expiresAtMs:Date.now()+Pe});m("Publishing…"),await ee(N,i.identity),m(null),I(o),P("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:o,price_usd:o/10,listing_type:"secondary",is_primary:!1}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["my-assets",i.address]})}catch(N){W(N,{flow:"list_secondary"}),P("Shop Listing Failed",{listing_type:"secondary",error_code:se(N)}),p($e(N)),m(null)}finally{k(!1)}}function x(){n(),r(`/item/${e.contractAddress}/${e.tokenId}`)}return j!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:o=>o.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:"It’s on sale! 🎉"}),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:["Listed for"," ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",j]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:x,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["List “",e.name,"”"]}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",w.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:o=>v(o.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",w.name," (1 ",w.nameSingular," = $0.10)."]}),f?s.jsx("p",{className:"muted",children:f}):null,_?s.jsx("p",{className:"error",children:_}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:()=>void C(),disabled:g,children:g?"Listing…":"Put on sale"})]})]})})}const Ee=1e3*60*60*24*182;function Me(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't publish your item — please try again."}function qe({item:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[f,m]=d.useState(null),[_,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null),[C,x]=d.useState(null),o=V.chainId,N=je(i.providerType);d.useEffect(()=>{let u=!1;return(async()=>{try{const b=await be({contractAddress:e.contractAddress,chainId:o});u||I(b)}catch{u||I(!1)}})(),()=>{u=!0}},[e.contractAddress,o]);async function T(){p(null);const u=Number(l);if(!Number.isInteger(u)||u<=0){p("Enter a whole number of credits");return}k(!0);try{j||(m("Enabling sales for this collection…"),await ye({signer:i.signer,contractAddress:e.contractAddress,chainId:o}),I(!0)),m("Publishing your item…");const b=await xe({signer:i.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:z.Network.MATIC,chainId:o},usdPrice:u/10,uses:e.remainingSupply,expiresAtMs:Date.now()+Ee});m("Finishing up…"),await ee(b,i.identity),m(null),x(u),P("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:u,price_usd:u/10,listing_type:"primary",is_primary:!0}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["publishable-items"]}),c.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){W(b,{flow:"list_primary"}),P("Shop Listing Failed",{listing_type:"primary",error_code:se(b)}),p(Me(b)),m(null)}finally{k(!1)}}function O(){n(),r(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const L=g?"Listing…":j===!1?"Enable & put on sale":"Put on sale";return C!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:u=>u.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:"It’s on sale! 🎉"}),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:["Listed for"," ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",C]})," ","· ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:O,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["Publish “",e.name,"”"]}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsxs("p",{className:"muted small",children:["From your collection “",e.collectionName,"” · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",w.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:u=>v(u.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",w.name," (1 ",w.nameSingular," = $0.10)."]}),j===!1&&!g?N?s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? It needs a one-time approval, then you’ll confirm the listing — two quick confirmations. After this, listing more items from this collection is a single step."]}):s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? Setting it up takes a moment — after that, listing more items from this collection is instant."]}):j===!0&&!g?N?s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is a single confirmation."}):s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is instant."}):null,f?s.jsx("p",{className:"muted",children:f}):null,_?s.jsx("p",{className:"error",children:_}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:()=>void T(),disabled:g||j===null,children:j===null?"Checking…":L})]})]})})}const Fe=48;function Te(e){return{id:e.id,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,rarity:e.rarity??"common",network:e.network,chainId:e.chainId,thumbnail:e.image,priceCredits:e.listingPrice??0,gender:null,isSmart:!1,tokenId:e.tokenId}}function Z(e){return{id:`${e.contractAddress}-${e.blockchainItemId}`,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.blockchainItemId,category:e.category,rarity:e.rarity,network:"MATIC",chainId:V.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function He(){const{session:e,error:i,signIn:n,restore:c}=ce(),r=U(),l=B(),[v,f]=d.useState(null),[m,_]=d.useState(null),[p,g]=d.useState(null),[k,j]=d.useState(null);function I(a){const t=a.tokenId??a.itemId??"";!a.contractAddress||!t||r(`/item/${a.contractAddress}/${t}`,{state:{item:a}})}async function C(a,t,h){if(e){j(null),g(h);try{const y=await de(a);await he({trade:y,signer:e.signer}),G.success(`“${t}” is no longer for sale.`),await l.invalidateQueries({queryKey:["my-assets",e.address]}),await l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(y){const E=y,M=(E.message??"").toLowerCase(),X=E.code===4001||M.includes("reject")||M.includes("denied");X||W(y,{flow:"remove-listing",tradeId:a}),j(X?"You cancelled the request.":"Couldn't remove the listing — please try again.")}finally{g(null)}}}d.useEffect(()=>{c()},[c]);const x=e==null?void 0:e.address,{items:o,isLoading:N,error:T,hasNextPage:O,isFetchingNextPage:L,fetchNextPage:u}=_e(["my-assets",x],a=>oe(x,{first:Fe,skip:a}).then(t=>({items:t.assets,total:t.total})),{enabled:!!x}),{data:b}=D({queryKey:["importable",x],queryFn:()=>ue(x),enabled:!!x}),R=((b==null?void 0:b.creations.length)??0)+((b==null?void 0:b.owned.length)??0),{data:A,isLoading:te,isError:ie}=D({queryKey:["publishable-items",x],queryFn:()=>Ae(x,e.identity),enabled:!!e,retry:!1}),K=d.useMemo(()=>[...new Set((A??[]).map(a=>a.contractAddress))],[A]),{data:S}=D({queryKey:["collection-sale-state",x,K],enabled:K.length>0,queryFn:async()=>{const a=await Promise.all(K.map(async h=>[h,await me(h)])),t={};for(const[h,y]of a)for(const[E,M]of Object.entries(y))t[`${h}-${E}`]=M;return t}}),Q=a=>S==null?void 0:S[`${a.contractAddress}-${a.blockchainItemId}`],Y=d.useMemo(()=>(A??[]).filter(a=>{var t;return(t=Q(a))==null?void 0:t.isOnSale}),[A,S]),H=d.useMemo(()=>{var t;const a=new Map;for(const h of A??[]){if((t=S==null?void 0:S[`${h.contractAddress}-${h.blockchainItemId}`])!=null&&t.isOnSale)continue;const y=a.get(h.collectionId)??{id:h.collectionId,name:h.collectionName,items:[]};y.items.push(h),a.set(h.collectionId,y)}return[...a.values()]},[A,S]);return e?s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),R>0?s.jsxs(re,{className:"import-banner",to:"/import",children:[s.jsx("span",{className:"import-banner__ico","aria-hidden":!0,children:"📦"}),s.jsxs("span",{className:"import-banner__text",children:[s.jsx("strong",{children:"Import your listings"}),s.jsxs("span",{className:"import-banner__sub",children:["You have ",R," item",R===1?"":"s"," for sale elsewhere — bring them into the Shop."]})]}),s.jsx("span",{className:"import-banner__cta",children:"Import"})]}):null,s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Items you own"}),s.jsx("p",{className:"myassets__section-sub",children:"Wearables & emotes you’ve bought — resell them in the Shop."})]}),T?s.jsx("p",{className:"error",children:"Couldn’t load your items — please try again."}):null,k?s.jsx("p",{className:"error",children:k}):null,s.jsxs("div",{className:"asset-grid",children:[N?Array.from({length:8}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`sk-${t}`)):o.map(a=>s.jsxs("article",{className:"asset-card asset-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Te(a))}),s.jsx("div",{className:"asset-card__img",children:a.image?s.jsx("img",{src:a.image,alt:a.name}):null}),s.jsx("div",{className:"asset-card__name",title:a.name,children:a.name}),a.isOnSale?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"asset-card__listed",children:[s.jsxs("span",{className:"asset-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",a.listingPrice]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost asset-card__remove",disabled:p===a.id||!a.tradeId,onClick:t=>{t.stopPropagation(),a.tradeId&&C(a.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]}):s.jsx("button",{className:"btn btn--sm",onClick:t=>{t.stopPropagation(),P("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),f(a)},children:"Put on sale"})]},a.id)),L?Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`msk-${t}`)):null]}),s.jsx(fe,{hasNextPage:O,isFetching:L,onLoadMore:()=>void u()}),!N&&o.length===0?s.jsx("p",{className:"muted",children:"No items in your wardrobe yet."}):null]}),s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Your creations"}),s.jsxs("p",{className:"myassets__section-sub",children:["Items you made. Put them on sale in the Shop — set a price in ",w.name," and buyers pay with"," ",w.name,"."]})]}),te?s.jsx("div",{className:"publish-grid",children:Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`pub-sk-${t}`))}):ie?s.jsx("p",{className:"publish-empty",children:"We couldn’t load your collections right now. Please try again in a moment."}):Y.length===0&&H.length===0?s.jsx("p",{className:"publish-empty",children:"You don’t have any items to publish yet."}):s.jsxs(s.Fragment,{children:[Y.length>0?s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:"On sale"}),s.jsx("div",{className:"publish-grid",children:Y.map(a=>{var t;return s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Z(a))}),s.jsx("div",{className:"publish-card__img",children:a.thumbnail?s.jsx("img",{src:a.thumbnail,alt:a.name}):null}),s.jsx("div",{className:"publish-card__name",title:a.name,children:a.name}),s.jsxs("div",{className:"publish-card__listed",children:[s.jsxs("span",{className:"publish-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",((t=Q(a))==null?void 0:t.priceCredits)??0]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost publish-card__cta",disabled:p===a.id,onClick:h=>{h.stopPropagation();const y=Q(a);y!=null&&y.tradeId&&C(y.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]},`${a.contractAddress}-${a.blockchainItemId}`)})})]}):null,H.map(a=>s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:a.name}),s.jsx("div",{className:"publish-grid",children:a.items.map(t=>s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${t.name}`,onClick:()=>I(Z(t))}),s.jsx("div",{className:"publish-card__img",children:t.thumbnail?s.jsx("img",{src:t.thumbnail,alt:t.name}):null}),s.jsx("div",{className:"publish-card__name",title:t.name,children:t.name}),s.jsxs("div",{className:"publish-card__meta",children:[s.jsx("span",{className:"publish-chip publish-chip--rarity",children:t.rarity}),s.jsxs("span",{className:"publish-card__supply",children:[t.remainingSupply.toLocaleString()," available"]})]}),s.jsx("button",{className:"btn btn--sm btn--purple publish-card__cta",onClick:h=>{h.stopPropagation(),P("Shop Started Listing",{listing_type:"primary",item_id:t.blockchainItemId}),_(t)},children:"Put on sale"})]},`${t.contractAddress}-${t.blockchainItemId}`))})]},a.id))]})]}),v?s.jsx(Le,{asset:v,session:e,onClose:()=>f(null)}):null,m?s.jsx(qe,{item:m,session:e,onClose:()=>_(null)}):null]}):s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),s.jsx("p",{className:"muted",children:"Sign in to sell your items."}),s.jsx("div",{className:"connect-row",children:s.jsx("button",{className:"btn btn--purple",onClick:()=>n(),children:"Sign in"})}),i?s.jsx("p",{className:"error",children:i}):null]})}export{He as MyAssets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as s,L as n}from"./react-
|
|
1
|
+
import{r as o,j as s,L as n}from"./react-BMZSDQJw.js";import{u as c,A as l}from"./index-W4B_IWIP.js";import{L as m}from"./LoadMore-Borbhtjd.js";import"./ethers-BZNCwGB1.js";const i=24;function v(){const t=c(e=>Object.values(e.items)),[a,r]=o.useState(i);return t.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx("span",{className:"ico ico-heart favorites-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"favorites-empty__title",children:"No favorites yet"}),s.jsx("p",{className:"muted",children:"Tap the heart on any item to save it here."}),s.jsx(n,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:"My Favorites"}),s.jsxs("span",{className:"favorites__count",children:[t.length," item",t.length>1?"s":""]})]}),s.jsx("div",{className:"grid",children:t.slice(0,a).map(e=>s.jsx(l,{item:e},e.id))}),s.jsx(m,{hasNextPage:a<t.length,isFetching:!1,onLoadMore:()=>r(e=>e+i)})]})}export{v as MyFavorites};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,L as o}from"./react-
|
|
1
|
+
import{j as e,L as o}from"./react-BMZSDQJw.js";import{a as l,f as u,b as m,C as p,c as x}from"./index-W4B_IWIP.js";import{L as _}from"./LoadMore-Borbhtjd.js";import{u as j}from"./useInfiniteGrid-BK47MfTg.js";import"./ethers-BZNCwGB1.js";const N=24;function g(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function f({status:s}){return s==="PENDING"?e.jsx("span",{className:"purchase__badge purchase__badge--pending",children:"Processing"}):e.jsx("span",{className:"purchase__badge purchase__badge--done",children:"Completed"})}function y({purchase:s}){const{data:a}=m({queryKey:["trade-display",s.tradeId],queryFn:()=>x(s.tradeId),enabled:!!s.tradeId,staleTime:3e5}),t=(a==null?void 0:a.name)??"Item",i=(a==null?void 0:a.thumbnail)??"",n=(a==null?void 0:a.tokenId)??(a==null?void 0:a.itemId)??"",d=a!=null&&a.contractAddress&&n?`/item/${a.contractAddress}/${n}`:void 0,c=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"purchase__thumb",children:i?e.jsx("img",{src:i,alt:t}):null}),e.jsxs("div",{className:"purchase__info",children:[e.jsx("div",{className:"purchase__name",title:t,children:t}),e.jsx("div",{className:"muted purchase__date",children:g(s.createdAt)})]}),e.jsx(f,{status:s.status}),e.jsxs("div",{className:"purchase__price",children:[e.jsx(p,{className:"ccy-mark"})," ",s.credits]})]});return d?e.jsx(o,{className:"purchase",to:d,children:c}):e.jsx("div",{className:"purchase",children:c})}function A(){const{session:s}=l(),{items:a,isLoading:t,hasNextPage:i,isFetchingNextPage:n,fetchNextPage:d}=j(["purchases",s==null?void 0:s.address],r=>u(s.address,s.identity,{first:N,skip:r}),{enabled:!!s});if(!s)return e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"Sign in to see your purchases"}),e.jsx("p",{className:"muted",children:"Your order history shows up here once you sign in."})]});const c=a.filter(r=>r.status!=="EXPIRED");return!t&&c.length===0?e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"No purchases yet"}),e.jsx("p",{className:"muted",children:"When you buy something it’ll appear here."}),e.jsx(o,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):e.jsxs("section",{className:"purchases",children:[e.jsxs("div",{className:"purchases__head",children:[e.jsx("h1",{children:"My Purchases"}),t?null:e.jsxs("span",{className:"purchases__count",children:[c.length," order",c.length>1?"s":""]})]}),e.jsx("div",{className:"purchases__list",children:t?Array.from({length:4}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},h)):e.jsxs(e.Fragment,{children:[c.map(r=>e.jsx(y,{purchase:r},r.id)),n?Array.from({length:2}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},`m-${h}`)):null]})}),e.jsx(_,{hasNextPage:i,isFetching:n,onLoadMore:()=>void d()})]})}export{A as MyPurchases};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as ee}from"./ethers-
|
|
1
|
+
import{p as ee}from"./ethers-BZNCwGB1.js";const ae="2.54.1";let T={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${ae}`};class o extends Error{constructor(e,t={}){var p;const n=(()=>{var u;return t.cause instanceof o?t.cause.details:(u=t.cause)!=null&&u.message?t.cause.message:t.details})(),a=t.cause instanceof o&&t.cause.docsPath||t.docsPath,s=(p=T.getDocsUrl)==null?void 0:p.call(T,{...t,docsPath:a}),i=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...T.version?[`Version: ${T.version}`]:[]].join(`
|
|
2
2
|
`);super(i,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=a,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=ae}walk(e){return se(this,e)}}function se(r,e){return e!=null&&e(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause!==void 0?se(r.cause,e):e?null:r}class oe extends o{constructor({max:e,min:t,signed:n,size:a,value:s}){super(`Number "${s}" is not in safe ${a?`${a*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class Ke extends o{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class fe extends o{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class me extends o{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function ie(r,{strict:e=!0}={}){return!r||typeof r!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(r):r.startsWith("0x")}function te(r){return ie(r,{strict:!1})?Math.ceil((r.length-2)/2):r.length}function v(r,{dir:e="left"}={}){let t=typeof r=="string"?r.replace("0x",""):r,n=0;for(let a=0;a<t.length-1&&t[e==="left"?a:t.length-a-1].toString()==="0";a++)n++;return t=e==="left"?t.slice(n):t.slice(0,t.length-n),typeof r=="string"?(t.length===1&&e==="right"&&(t=`${t}0`),`0x${t.length%2===1?`0${t}`:t}`):t}class Ve extends o{constructor({offset:e,position:t,size:n}){super(`Slice ${t==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class ue extends o{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class Ye extends o{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function g(r,{dir:e,size:t=32}={}){return typeof r=="string"?he(r,{dir:e,size:t}):ye(r,{dir:e,size:t})}function he(r,{dir:e,size:t=32}={}){if(t===null)return r;const n=r.replace("0x","");if(n.length>t*2)throw new ue({size:Math.ceil(n.length/2),targetSize:t,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function ye(r,{dir:e,size:t=32}={}){if(t===null)return r;if(r.length>t)throw new ue({size:r.length,targetSize:t,type:"bytes"});const n=new Uint8Array(t);for(let a=0;a<t;a++){const s=e==="right";n[s?a:t-a-1]=r[s?a:r.length-a-1]}return n}const ge=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Xe(r,e={}){return typeof r=="number"||typeof r=="bigint"?le(r,e):typeof r=="string"?Te(r,e):typeof r=="boolean"?Ee(r,e):ce(r,e)}function Ee(r,e={}){const t=`0x${Number(r)}`;return typeof e.size=="number"?(y(t,{size:e.size}),g(t,{size:e.size})):t}function ce(r,e={}){let t="";for(let a=0;a<r.length;a++)t+=ge[r[a]];const n=`0x${t}`;return typeof e.size=="number"?(y(n,{size:e.size}),g(n,{dir:"right",size:e.size})):n}function le(r,e={}){const{signed:t,size:n}=e,a=BigInt(r);let s;n?t?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof r=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof s=="bigint"&&t?-s-1n:0;if(s&&a>s||a<i){const u=typeof r=="bigint"?"n":"";throw new oe({max:s?`${s}${u}`:void 0,min:`${i}${u}`,signed:t,size:n,value:`${r}${u}`})}const p=`0x${(t&&a<0?(1n<<BigInt(n*8))+BigInt(a):a).toString(16)}`;return n?g(p,{size:n}):p}const Ne=new TextEncoder;function Te(r,e={}){const t=Ne.encode(r);return ce(t,e)}const ve=new TextEncoder;function Je(r,e={}){return typeof r=="number"||typeof r=="bigint"?Oe(r,e):typeof r=="boolean"?we(r,e):ie(r)?O(r,e):Ae(r,e)}function we(r,e={}){const t=new Uint8Array(1);return t[0]=Number(r),typeof e.size=="number"?(y(t,{size:e.size}),g(t,{size:e.size})):t}const m={zero:48,nine:57,A:65,F:70,a:97,f:102};function re(r){if(r>=m.zero&&r<=m.nine)return r-m.zero;if(r>=m.A&&r<=m.F)return r-(m.A-10);if(r>=m.a&&r<=m.f)return r-(m.a-10)}function O(r,e={}){let t=r;e.size&&(y(t,{size:e.size}),t=g(t,{dir:"right",size:e.size}));let n=t.slice(2);n.length%2&&(n=`0${n}`);const a=n.length/2,s=new Uint8Array(a);for(let i=0,p=0;i<a;i++){const u=re(n.charCodeAt(p++)),E=re(n.charCodeAt(p++));if(u===void 0||E===void 0)throw new o(`Invalid byte sequence ("${n[p-2]}${n[p-1]}" in "${n}").`);s[i]=u*16+E}return s}function Oe(r,e){const t=le(r,e);return O(t)}function Ae(r,e={}){const t=ve.encode(r);return typeof e.size=="number"?(y(t,{size:e.size}),g(t,{dir:"right",size:e.size})):t}function y(r,{size:e}){if(te(r)>e)throw new me({givenSize:te(r),maxSize:e})}function Qe(r,e){const t={to:e},n=t.to;return n==="number"?Me(r,t):n==="bigint"?de(r,t):n==="string"?Ce(r,t):n==="boolean"?xe(r,t):O(r,t)}function de(r,e={}){const{signed:t}=e;e.size&&y(r,{size:e.size});const n=BigInt(r);if(!t)return n;const a=(r.length-2)/2,s=(1n<<BigInt(a)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(a*2,"f")}`)-1n}function xe(r,e={}){let t=r;if(e.size&&(y(t,{size:e.size}),t=v(t)),v(t)==="0x00")return!1;if(v(t)==="0x01")return!0;throw new fe(t)}function Me(r,e={}){const t=de(r,e),n=Number(t);if(!Number.isSafeInteger(n))throw new oe({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:e.signed,size:e.size,value:`${t}n`});return n}function Ce(r,e={}){let t=O(r);return e.size&&(y(t,{size:e.size}),t=v(t,{dir:"right"})),new TextDecoder().decode(t)}const Ze={gwei:9,wei:18},Re={ether:-9,wei:9};function Se(r,e){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(e,"0");let[a,s]=[t.slice(0,t.length-e),t.slice(t.length-e)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${a||"0"}${s?`.${s}`:""}`}function w(r,e="wei"){return Se(r,Re[e])}class pe extends o{constructor({cause:e,message:t}={}){var a;const n=(a=t==null?void 0:t.replace("execution reverted: ",""))==null?void 0:a.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(pe,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(pe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Pe extends o{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${w(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Pe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class _e extends o{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${w(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(_e,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Ie extends o{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Ie,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class $e extends o{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
|
|
3
3
|
`),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty($e,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Ue extends o{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Ue,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class De extends o{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
|
|
4
4
|
`),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(De,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class je extends o{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(je,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Le extends o{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Le,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ze extends o{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ze,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Be extends o{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${w(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${w(n)} gwei`:""}).`].join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,L as n}from"./react-BMZSDQJw.js";import{o}from"./index-W4B_IWIP.js";import"./ethers-BZNCwGB1.js";function i(){return t.jsxs("div",{className:"notfound",children:[t.jsx("span",{className:"ico ico-cart notfound__ico","aria-hidden":!0}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(n,{className:"btn btn--purple",to:"/assets",children:o("notFound.cta")})]})}export{i as NotFound,i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,u as U,r as i,L as W}from"./react-
|
|
1
|
+
import{j as s,u as U,r as i,L as W}from"./react-BMZSDQJw.js";import{a as X,h as Z,o as a,ad as T}from"./index-W4B_IWIP.js";import{u as ee,d as se,t as te,L as ae,i as I,a as v,s as re}from"./useStore-CgLb6TAk.js";import"./ethers-BZNCwGB1.js";const ne="https://cdn.decentraland.org/@dcl/shop/0.1.0-29584116670.commit-7b991d9/assets/template-cover-1-BETekfHg.jpeg",ie="https://cdn.decentraland.org/@dcl/shop/0.1.0-29584116670.commit-7b991d9/assets/template-cover-2-Dni9s0i_.jpeg",oe=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ne,"../assets/creator-covers/template-cover-2.jpeg":ie}),h=Object.entries(oe).sort(([r],[d])=>r.localeCompare(d)).map(([r,d])=>({name:r.split("/").pop(),url:d}));function le({label:r,size:d="medium",direction:b="column",className:f}){return s.jsxs("div",{className:`spinner-box spinner-box--${b}${f?` ${f}`:""}`,role:"status","aria-live":"polite","aria-label":r?void 0:"Loading",children:[s.jsx("span",{className:`spinner-box__ring spinner-box__ring--${d}`,"aria-hidden":!0}),r?s.jsx("span",{className:"spinner-box__label",children:r}):null]})}const M=1e6,O={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function R(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ge(){const{session:r,signIn:d}=X(),b=U(),f=Z(),c=r==null?void 0:r.address,{data:x,isLoading:z}=ee(c),[n,u]=i.useState(O),[E,w]=i.useState(O),[j,g]=i.useState(),[p,C]=i.useState(!1),[o,N]=i.useState(null),[_,A]=i.useState({}),L=i.useRef(null);i.useEffect(()=>{if(x){const e=se(x);u(e),w(e),g(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[x]),i.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await te(t.url)])).then(t=>{e||A(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const S=i.useMemo(()=>{const e=h.find(l=>n.coverName===`cover/${l.name}`);if(e)return e.name;const t=n.coverHash?h.find(l=>_[l.name]===n.coverHash):void 0;return t==null?void 0:t.name},[n.coverName,n.coverHash,_]);i.useEffect(()=>{o!=null&&o.hash&&h.some(e=>_[e.name]===o.hash)&&N(null)},[_,o]);const $=j!==void 0&&j>M,D=i.useMemo(()=>ae.filter(e=>!I(e,n.links[e])),[n.links]),P=$||D.length>0,k=i.useMemo(()=>JSON.stringify(n)!==JSON.stringify(E),[n,E]),F=k&&!P&&!p;if(i.useEffect(()=>{if(!k)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[k]),!r)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("button",{className:"btn btn--purple store-settings__signin-btn",onClick:d,children:a("storeSettings.signIn")})]});function B(e,t){g(void 0),u(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const V=["image/png","image/jpeg","image/webp"];function Y(e){var y;const t=(y=e.target.files)==null?void 0:y[0];if(!t||!V.includes(t.type))return;g(t.size);const l=`cover/${t.name}`,m=new FileReader;m.onload=()=>{const H=m.result;N({url:H,name:l,hash:""}),u(Q=>({...Q,cover:H,coverName:l,coverHash:""}))},m.readAsDataURL(t)}function K(){o&&(g(void 0),u(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function q(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";u(m=>({...m,links:{...m.links,[e]:l}}))}function G(e){const t=n.links[e];return e==="website"?t:t.replace(v[e],"")}async function J(){if(!(!c||!r)){C(!0);try{await re(c,n,r.identity),w(n),g(void 0),await f.invalidateQueries({queryKey:["store",c.toLowerCase()]}),T.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{T.error(a("storeSettings.saveError"))}finally{C(!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(W,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0})}):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("span",{className:"ico ico-external","aria-hidden":!0})]}):null]}),z?s.jsx(le,{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=S===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"aria-pressed":t,onClick:()=>B(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${S?"":" is-selected"}`,"aria-pressed":!S,onClick:K,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload",onClick:()=>{var e;return(e=L.current)==null?void 0:e.click()},children:[s.jsx("span",{className:"ico ico-upload","aria-hidden":!0}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:L,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input",onChange:Y})]}),$?s.jsx("p",{className:"error",children:a("storeSettings.sizeError",{max:R(M),current:R(j)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:n.description,rows:4,disabled:p,onChange:e=>u(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:n.links.website,placeholder:v.website,disabled:p,onChange:e=>u(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),I("website",n.links.website)?null:s.jsx("p",{className:"error",children: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:G(e),disabled:p,onChange:t=>q(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx("button",{className:"btn btn--purple store-settings__save",onClick:()=>void J(),disabled:!F,children:p?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ge as StoreSettings,ge as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,b as E,u as F,N as $,r as w}from"./react-BMZSDQJw.js";import{a as T,x as C,y as V,z as R,D as M,E as B,F as L,W as A,g as _,e as g,G as O}from"./index-W4B_IWIP.js";import{s as U}from"./wallet-kind-Bio8Yuti.js";import{w as W,S as z}from"./buy-gasless-CgSRLXqb.js";import"./ethers-BZNCwGB1.js";import"./trade-encoding-BOT9-UWu.js";import"./index-ge5YPyFz.js";function K(){return e.jsxs("div",{className:"success-anim",role:"img","aria-label":"Purchase successful",children:[e.jsxs("svg",{className:"success-anim__svg",viewBox:"0 0 120 120",children:[e.jsx("circle",{className:"success-anim__ring",cx:"60",cy:"60",r:"54"}),e.jsx("path",{className:"success-anim__check",d:"M37 61 l16 16 l30 -34"})]}),e.jsx("span",{className:"success-anim__spark success-anim__spark--1","aria-hidden":!0,children:"✦"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--2","aria-hidden":!0,children:"✦"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--3","aria-hidden":!0,children:"◈"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--4","aria-hidden":!0,children:"✦"})]})}const Y=t=>new Promise(s=>setTimeout(s,t));function X(t,s){const[a,o]=w.useState(t?"pending":"confirmed"),d=s?`${s.owner}-${s.contractAddress}-${s.itemId}`:"";return w.useEffect(()=>{if(!t)return;let r=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!r;n++)try{await W(t,{timeoutMs:15e3}),h=!0;break}catch(c){if(c instanceof z)continue;r||o("failed");return}if(!r){if(!h){o("timed-out");return}if(!s){o("confirmed");return}o("indexing");for(let n=0;n<40&&!r;n++){if(await O(s.owner,s.contractAddress,s.itemId)){r||o("confirmed");return}await Y(3e3)}r||o("timed-out")}})(),()=>{r=!0}},[t,d]),a}const D=g.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",x=g.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function se(){const{state:t}=E(),s=F(),{session:a}=T(),{data:o}=C(a==null?void 0:a.address),d=t==null?void 0:t.txHash,r=(t==null?void 0:t.items)??[],l=r[0],h=a!=null&&a.address&&(l!=null&&l.contractAddress)&&(l!=null&&l.itemId)?{owner:a.address,contractAddress:l.contractAddress,itemId:l.itemId}:null,n=X(d,h),c=r;if(c.length===0)return e.jsx($,{to:"/assets",replace:!0});const u=c[0],j=c.filter(i=>i.category!=="emote"),I=c.find(i=>i.category==="emote")??null,b=j.map(V).filter(i=>!!i),f=R(o),S=!!f&&j.every(i=>M(i,f)),P=B(j)??f??L,v=!!(a!=null&&a.address)&&S,y=v?a.address:"default",k=v?void 0:P,m=I??u,N=m.category==="emote",p=!!d&&U(a==null?void 0:a.providerType);return e.jsxs("div",{className:"success",children:[e.jsx("div",{className:"success__preview",children:b.length>0?e.jsx(A,{profile:y,bodyShape:k,urns:b,type:_.PreviewType.AVATAR,emote:_.PreviewEmote.FASHION,background:"ecebed",dev:g.chainId===80002},u.id):e.jsx(A,{contractAddress:m.contractAddress,tokenId:m.tokenId??void 0,itemId:m.tokenId?void 0:m.itemId??void 0,profile:y,bodyShape:N?void 0:k,type:N?void 0:_.PreviewType.AVATAR,emote:N?void 0:_.PreviewEmote.FASHION,background:"ecebed",dev:g.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"?"Finalizing your purchase…":"Processing your purchase…"}),e.jsx("p",{className:"success__sub",children:n==="indexing"?e.jsxs(e.Fragment,{children:["Payment confirmed — adding"," ",c.length===1?e.jsx("strong",{children:u.name}):`${c.length} items`," to your wardrobe. Almost there."]}):e.jsxs(e.Fragment,{children:["Confirming ",c.length===1?e.jsx("strong",{children:u.name}):`${c.length} items`," on-chain. This usually takes a few seconds — keep this tab open."]})}),p?e.jsx("div",{className:"success__links",children:e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"})}):null]}):n==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:"Still processing…"}),e.jsxs("p",{className:"success__sub",children:["This is taking longer than usual to confirm. Your purchase may still complete — check"," ",e.jsx("button",{className:"link",onClick:()=>s("/my-purchases"),children:"My Purchases"})," ","in a few minutes to see the final status. No need to buy again."]}),e.jsx("div",{className:"success__links",children:p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null}),e.jsxs("div",{className:"success__actions",children:[e.jsx("button",{className:"btn btn--purple",onClick:()=>s("/my-purchases"),children:"View my purchases"}),e.jsx("button",{className:"btn btn--ghost",onClick:()=>s("/assets"),children:"Keep shopping"})]})]}):n==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:"Your purchase didn’t go through"}),e.jsx("p",{className:"success__sub",children:"The transaction failed on-chain, so nothing was delivered. Your credits weren’t spent (any hold is released shortly) — you can try again."}),e.jsx("div",{className:"success__links",children:p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null}),e.jsx("div",{className:"success__actions",children:e.jsx("button",{className:"btn btn--purple",onClick:()=>s("/assets"),children:"Back to shop"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{}),e.jsx("h1",{className:"success__title",children:"It’s yours!"}),c.length===1?e.jsxs("p",{className:"success__sub",children:[e.jsx("strong",{children:u.name})," is now in your wardrobe."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"success__sub",children:[c.length," items are now in your wardrobe."]}),e.jsx("ul",{className:"success__list",children:c.map(i=>e.jsx("li",{children:i.name},i.id))})]}),e.jsxs("div",{className:"success__links",children:[e.jsx("button",{className:"success__receipt",onClick:()=>s("/my-purchases"),children:"View order"}),p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null]}),e.jsxs("div",{className:"success__actions",children:[e.jsx("a",{className:"btn btn--purple",href:D,target:"_blank",rel:"noreferrer",children:"Use it in-world"}),e.jsx("button",{className:"btn btn--ghost",onClick:()=>s("/assets"),children:"Keep shopping"})]})]})})]})}export{se as Success,se 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-BrDTQqcr.js";import{au as C}from"./NetworkUtil-DInevqnn.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-C3ngIw23.js";import{au as C}from"./NetworkUtil-bxmjbsdp.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};
|