@dcl/shop 0.1.0-29842546509.commit-9321ed0 → 0.1.0-29842599290.commit-2475f4f
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-CpD4azi2.js → AnimatedBackground-D2JRqhrS.js} +1 -1
- package/assets/Assets-D_767CI9.js +503 -0
- package/assets/{Cart-BTzfi4XX.js → Cart-DpvMVP-7.js} +2 -2
- package/assets/{CircularProgress-Diq42zDa.js → CircularProgress-BJ_TjCN_.js} +4 -4
- package/assets/{Collection-C1gray1q.js → Collection-CROpeZdX.js} +6 -6
- package/assets/{CollectionCarousel-Su-Z1nF7.js → CollectionCarousel-BB3DzDmR.js} +1 -1
- package/assets/{ConstantsUtil-BbIzv5xN.js → ConstantsUtil-CJUlyS7R.js} +1 -1
- package/assets/{ContentClient-BiP6T0o-.js → ContentClient-B6BvDsXj.js} +1 -1
- package/assets/{Creator-Caa3VNPC.js → Creator-_z1lwt4_.js} +1 -1
- package/assets/{CssVarsProvider-9L72NL5y.js → CssVarsProvider-Cb_KA4y8.js} +2 -2
- package/assets/{DeploymentBuilder-DUGl9QwQ.js → DeploymentBuilder-Cp9K3LCu.js} +1 -1
- package/assets/{ErrorNotice-CKeOu_Oi.js → ErrorNotice-C7soUjRV.js} +1 -1
- package/assets/{ExchangeController-Dx4qeF41.js → ExchangeController-CBn3jEwJ.js} +1 -1
- package/assets/{GetCredits-DX1eiFT9.js → GetCredits-CBBS-hLK.js} +1 -1
- package/assets/{HelpersUtil-CVaHX5I0.js → HelpersUtil-HdrIw3ED.js} +1 -1
- package/assets/{ImportListings-BKMbUHyp.js → ImportListings-B4Ah3yQs.js} +2 -2
- package/assets/{ItemDetail-Bbh8gvnt.js → ItemDetail-Bdnzeft3.js} +2 -2
- package/assets/{LoadMore-O4DX_7vg.js → LoadMore-Blqu_ob_.js} +1 -1
- package/assets/{MarketCheckout-rUkLpvLK.js → MarketCheckout-DOEU43Cr.js} +1 -1
- package/assets/{MyAssets-CQHv1izk.js → MyAssets-KamgxHyB.js} +3 -3
- package/assets/{MyFavorites-DzooEDTl.js → MyFavorites-46gv8iFB.js} +2 -2
- package/assets/{MyPurchases-CHvG_Z0u.js → MyPurchases-xyHXfcs_.js} +2 -2
- package/assets/{NetworkUtil-CLSFaUe_.js → NetworkUtil-Xp0fNa8X.js} +1 -1
- package/assets/{NotFound-Cm2xdnvh.js → NotFound-SYVjtlXK.js} +1 -1
- package/assets/{PrimaryListModal-CQLHGKtA.js → PrimaryListModal-B8X89MoS.js} +1 -1
- package/assets/{StoreSettings-CaOtAVWs.js → StoreSettings-B4i_rpq0.js} +5 -5
- package/assets/{Success-hmqx-31C.js → Success-BoPV7W7T.js} +2 -2
- package/assets/{SwapController-BoTtiWz_.js → SwapController-CBn7it3D.js} +1 -1
- package/assets/{TradeService-wOOx4LfF.js → TradeService-BUz_DTCw.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-DdXvw0GT.js → W3MFrameProviderSingleton-tZh6bMfi.js} +3 -3
- package/assets/{WebCryptoP256-DplJpmWw.js → WebCryptoP256-DSBDULPY.js} +1 -1
- package/assets/{basic-gyOPqk-z.js → basic-DlABK3_N.js} +1 -1
- package/assets/{biconomy-UVLr_gX2.js → biconomy-MRqMpiGP.js} +1 -1
- package/assets/{browser-L8b8z1bK.js → browser-9oFjBwrz.js} +1 -1
- package/assets/{browser-ponyfill-jziBOMa-.js → browser-ponyfill-DMgE6PM5.js} +1 -1
- package/assets/browser-ponyfill-Djb5Py6a.js +1 -0
- package/assets/{buy-B1dela3y.js → buy-B5ZS4ZBM.js} +1 -1
- package/assets/{buy-gasless-Dd7g2EOb.js → buy-gasless-Ba7WiBbA.js} +1 -1
- package/assets/cart-checkout-Cv0O-IMr.js +1 -0
- package/assets/categories-BicEp1xc.js +305 -0
- package/assets/{ccip-B5H9PYgE.js → ccip-7UmS1PeQ.js} +1 -1
- package/assets/{ccip-BwyWY-5W.js → ccip-LxG2dAFM.js} +1 -1
- package/assets/{chains-DxiOcj_1.js → chains-CpxWadaj.js} +1 -1
- package/assets/collection-5wVB2Die.js +1 -0
- package/assets/{common-B-aETE4R.js → common-l22vMua4.js} +1 -1
- package/assets/{controller-CNvp38sW.js → controller-DduDD9ay.js} +2 -2
- package/assets/{core-BuTmfnDO.js → core-CeGBqHMO.js} +4 -4
- package/assets/{custom-AzDnARiB.js → custom-D0AtamZ4.js} +1 -1
- package/assets/{data-capture-CSfFUSsx.js → data-capture-DvKKxnqn.js} +1 -1
- package/assets/{decimals-CgBMbKmx.js → decimals-BHuuK15t.js} +1 -1
- package/assets/decimals-Cy9cbsXq.js +1 -0
- package/assets/{detectExtension-BqOd3Bu-.js → detectExtension-DFy8j1N5.js} +1 -1
- package/assets/{email-C9i0Gajg.js → email-Bafq5LVA.js} +1 -1
- package/assets/{embedded-wallet-BEHagNmA.js → embedded-wallet-Cq9sdxt_.js} +1 -1
- package/assets/emotion-styled.browser.esm-IwF2UC65.js +1 -0
- package/assets/{engine-Dju27jhc.js → engine-CkrY35__.js} +1 -1
- package/assets/{errors-UirjYlqN.js → errors-VkIbnyNm.js} +1 -1
- package/assets/{estimate-l1-fee-CXA-7fQg.js → estimate-l1-fee-i2iZ2Vqn.js} +1 -1
- package/assets/eth_estimateGas-DSwQmDKV.js +1 -0
- package/assets/{eth_getStorageAt-D5eoja8P.js → eth_getStorageAt-DtuLpaRO.js} +1 -1
- package/assets/eth_getTransactionCount-jaO8Tr8s.js +1 -0
- package/assets/{ethereum-7lBI8s3D.js → ethereum-CkPyqOMA.js} +1 -1
- package/assets/{ethers-w2AslR0v.js → ethers-BeFqf2KO.js} +1 -1
- package/assets/{extractIPFS-CZ6KIYgU.js → extractIPFS-B1rYPZY7.js} +1 -1
- package/assets/{features-CUQxBKNG.js → features-BEM4jzxK.js} +1 -1
- package/assets/{fetchTokenMetadata-BFnxXbAd.js → fetchTokenMetadata-BhtlFZh7.js} +2 -2
- package/assets/{fortmatic-BAdaY-Dp.js → fortmatic-DhmlcDbL.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-DClE6CNQ.js → get-ecosystem-wallet-info-CT1s8m3e.js} +1 -1
- package/assets/{getBalance-BW2tkFwm.js → getBalance-CfJ0XnIl.js} +2 -2
- package/assets/{getInstalledModules-BjCN5fY7.js → getInstalledModules-CaXPPvdO.js} +1 -1
- package/assets/{getNFT-CQBhplyk.js → getNFT-CZfISvmz.js} +2 -2
- package/assets/{getNFT-A8I7QU7c.js → getNFT-DlVnt9Q9.js} +1 -1
- package/assets/{getOverlayAlpha-BbisUv6F.js → getOverlayAlpha-BueYXZ9u.js} +1 -1
- package/assets/{hashTypedData-BE61kXBX.js → hashTypedData-CuVSwrXW.js} +1 -1
- package/assets/{hashTypedData-C-cd52UI.js → hashTypedData-DLnXsDCk.js} +1 -1
- package/assets/{import-U21zX42V.js → import-CN6p_MqT.js} +1 -1
- package/assets/{in-app-wallet-calls-COdrbaQd.js → in-app-wallet-calls-CJqUcl-9.js} +1 -1
- package/assets/{index-2Ps9ND5D.js → index-1gbEXIom.js} +1 -1
- package/assets/{index-nV78it5W.js → index-B1B5XO_U.js} +1 -1
- package/assets/index-B4D19REm.js +231 -0
- package/assets/{index-B7_ZTJgS.js → index-B4edWAth.js} +2 -2
- package/assets/{index-CjRIGcVo.js → index-BEAmVVuB.js} +1 -1
- package/assets/{index-BLlP71ei.js → index-BGBt5Xm9.js} +1 -1
- package/assets/{index-DtQvODFY.js → index-BHCsuHPe.js} +1 -1
- package/assets/{index-IlKjOw66.js → index-BHVOprA5.js} +1 -1
- package/assets/{index-nTpCUsGR.js → index-BIPP0co7.js} +1 -1
- package/assets/{index-BbwpVs44.js → index-BONeQS2n.js} +2 -2
- package/assets/{index-BtWBj6Af.js → index-BPlP5Yrj.js} +1 -1
- package/assets/{index-C8MsuiTF.js → index-BQxvWH_G.js} +1 -1
- package/assets/{index-Chyha2y1.js → index-BY9My0oM.js} +1 -1
- package/assets/{index-DGJ-icG_.js → index-BYGUxDY4.js} +1 -1
- package/assets/{index-6Kyym41O.js → index-BfnFZQqu.js} +1 -1
- package/assets/{index-CNHeMoTf.js → index-BfoFTQum.js} +1 -1
- package/assets/{index-Dbqfw_1n.js → index-Bk6ayCIs.js} +1 -1
- package/assets/{index-BRZU29EO.js → index-BlNrP_ot.js} +1 -1
- package/assets/{index-BDSBJHh0.js → index-BmFerGWY.js} +1 -1
- package/assets/{index-WBH-r8wY.js → index-Bpmady1C.js} +1 -1
- package/assets/{index-CIPOyWcz.js → index-BrkctpUM.js} +1 -1
- package/assets/{index-D_6r6MGN.js → index-Bsrh1wrG.js} +3 -3
- package/assets/{index-CC63Imtj.js → index-BvYeGTV6.js} +1 -1
- package/assets/{index-D2Btfj2f.js → index-Bzl-y_xE.js} +1 -1
- package/assets/{index-C3Zl4Bwc.js → index-C7SiFPEi.js} +1 -1
- package/assets/{index-Dc-FCzcP.js → index-C8LSdB4m.js} +1 -1
- package/assets/{index-C3-7Y2XQ.js → index-CDneVgN3.js} +1 -1
- package/assets/{index-BQUzfdXy.js → index-CI-AD5iw.js} +1 -1
- package/assets/{index-DG6FVhAC.js → index-CLJtuWHL.js} +1 -1
- package/assets/{index-CaFo6MNc.js → index-CgwJgOun.js} +3 -3
- package/assets/{index-e6S5D9jo.js → index-Ckm2E71r.js} +1 -1
- package/assets/{index-Do2ywXf0.js → index-Cw5PuAy9.js} +1 -1
- package/assets/{index-3ywnJvSO.js → index-D5CqgRew.js} +1 -1
- package/assets/{index-DabupnD7.js → index-DF-DiDVu.js} +1 -1
- package/assets/{index-CNkjr1DA.js → index-DGOaB47n.js} +1 -1
- package/assets/index-DH3Yzbz3.js +1 -0
- package/assets/{index-B_DYNK0p.js → index-DOeRQwCQ.js} +2 -2
- package/assets/{index-DiGdTf_a.js → index-DOpbd-jp.js} +1 -1
- package/assets/{index-BG7HXbm5.js → index-DQfozNLU.js} +1 -1
- package/assets/{index-Cay9LHwQ.js → index-DWUDXdC9.js} +1 -1
- package/assets/{index-D0OG--76.js → index-DZl9hhbT.js} +2 -2
- package/assets/{index-DOYkzg8s.js → index-D_kcwQmd.js} +1 -1
- package/assets/{index-Bi7A4OhJ.js → index-Dl9esg1J.js} +1 -1
- package/assets/{index-sFssfP96.js → index-Dp3Py-Ws.js} +1 -1
- package/assets/{index-BXoEX0LF.js → index-Dtj-WGsX.js} +1 -1
- package/assets/{index-DZf65m6Q.js → index-FXbiSAAP.js} +1 -1
- package/assets/{index-CPJOSm7j.js → index-IqrjnIQ9.js} +1 -1
- package/assets/{index-D1y_7SUl.js → index-OQjcAgDp.js} +1 -1
- package/assets/{index-Ddx_rMxr.js → index-P0Yx7vsd.js} +1 -1
- package/assets/{index-CBQ1afGx.js → index-QMzB_9kT.js} +1 -1
- package/assets/{index-DXF8dQf_.js → index-TjznWbc4.js} +1 -1
- package/assets/{index-C89kko53.js → index-Tx1QPCiA.js} +1 -1
- package/assets/index-VVTks7i3.js +2 -0
- package/assets/{index-CKLx84x6.js → index-ZQBK6Pdm.js} +1 -1
- package/assets/{index-D-5bkeWr.js → index-ZV7fMVI5.js} +1 -1
- package/assets/{index-Dy9UEH5H.js → index-bDNg_irz.js} +1 -1
- package/assets/{index-B6hUxDdz.js → index-dYP5cvK2.js} +1 -1
- package/assets/index-eE-_qVda.css +1 -0
- package/assets/{index-DfD3kcZV.js → index-htvE856q.js} +1 -1
- package/assets/{index-DsoFUpzH.js → index-i1ke3OIj.js} +1 -1
- package/assets/{index-BTpn82ck.js → index-jtb2-_sz.js} +1 -1
- package/assets/{index-NPFJH5aq.js → index-oG-jQqT1.js} +1 -1
- package/assets/{index-BmdMMxfk.js → index-pbhVNuOA.js} +1 -1
- package/assets/{index-BJTKQhV8.js → index-sEQX5urS.js} +1 -1
- package/assets/{index.es-B5BbUoZc.js → index.es-BCuQ9fc-.js} +4 -4
- package/assets/{index.es-D5_DLam3.js → index.es-C89JefA5.js} +1 -1
- package/assets/{index.es-DDq0aq8p.js → index.es-hSZLYkrj.js} +1 -1
- package/assets/{localBatchGatewayRequest-DVWvmWuO.js → localBatchGatewayRequest-CZllhI1g.js} +1 -1
- package/assets/{mana-rate-CqkveB3D.js → mana-rate-Bf-vAahU.js} +1 -1
- package/assets/{native-BHXbWt16.js → native-BMBZUPnx.js} +1 -1
- package/assets/{networks-BjHHyPur.js → networks-kfrZy_3R.js} +1 -1
- package/assets/{onramp-kPzdQpfb.js → onramp-cgk7gEx6.js} +1 -1
- package/assets/{openzeppelin-DOJ727PR.js → openzeppelin-CBxu6ipZ.js} +1 -1
- package/assets/{ownerOf-D69S8pXi.js → ownerOf-q_CySRt_.js} +1 -1
- package/assets/{parseNft-C4n-mowD.js → parseNft-5mLnHHsb.js} +2 -2
- package/assets/{parseSignature-BRZuUR8w.js → parseSignature-BXQWiyxd.js} +1 -1
- package/assets/{parseSignature-CaalnObB.js → parseSignature-Xsezcdr3.js} +3 -3
- package/assets/{pay-with-exchange-D80avj-b.js → pay-with-exchange-8pnV59u_.js} +1 -1
- package/assets/{qr-overlay-DVT08IDB.js → qr-overlay-BDJyO_OZ.js} +3 -3
- package/assets/{react-yytiy0wi.js → react-C51i12iP.js} +1 -1
- package/assets/{receive-M4IPM7Ph.js → receive-BSmYsMYb.js} +1 -1
- package/assets/{resolveImplementation-CHCmpxV2.js → resolveImplementation-pTzqT2n7.js} +1 -1
- package/assets/{rpc-uK2Otrei.js → rpc-2aRT-2co.js} +1 -1
- package/assets/{secp256k1-DgpvP6R0.js → secp256k1-CBqMIQsl.js} +1 -1
- package/assets/{secp256k1-BFONvueK.js → secp256k1-CV0oEz43.js} +1 -1
- package/assets/{secp256k1-D8fIl0aD.js → secp256k1-DlGyN83x.js} +1 -1
- package/assets/{send-w4Ix8n56.js → send-CtmOo9OT.js} +1 -1
- package/assets/{send-batch-transaction-CP35fkqm.js → send-batch-transaction-DczlMlYX.js} +1 -1
- package/assets/{send-eip712-transaction-DLMBp-3H.js → send-eip712-transaction-C7NnRqWA.js} +2 -2
- package/assets/{send-gasless-transaction-BtVD4DN5.js → send-gasless-transaction-CGNQiDpn.js} +2 -2
- package/assets/{sendRawTransaction-2KWo-N-V.js → sendRawTransaction-C-hku157.js} +3 -3
- package/assets/{sentry-BPJvc5GU.js → sentry-DKBoGDXH.js} +1 -1
- package/assets/{serializeTransaction-9HR-LrYr.js → serializeTransaction-BsWWwZbQ.js} +1 -1
- package/assets/{session-proposal-CkaGCSrv.js → session-proposal-ni3LdMGP.js} +1 -1
- package/assets/{session-request-Cn_2Y-jY.js → session-request-IgqIbKir.js} +2 -2
- package/assets/{sha256-BKPxKApM.js → sha256-4_9oQ2I6.js} +1 -1
- package/assets/{signing-2kjDw3zV.js → signing-Bhm8lszD.js} +5 -5
- package/assets/{socials-CVEMspCh.js → socials-DSk2lLL3.js} +1 -1
- package/assets/{swaps-BPGThNG4.js → swaps-C363NeRy.js} +1 -1
- package/assets/{thirdweb-C0S5kfOA.js → thirdweb-BhNxfjG0.js} +3 -3
- package/assets/{totalSupply-DHPUJmNP.js → totalSupply-Be_gMWWK.js} +1 -1
- package/assets/{trade-encoding-j_wZd1-j.js → trade-encoding-D5hlkp_r.js} +1 -1
- package/assets/{transactionReceipt-Dlb-aH3i.js → transactionReceipt-pNi0w4mU.js} +1 -1
- package/assets/{transactions-DkgyEJFa.js → transactions-CCTEkhLH.js} +1 -1
- package/assets/{useCreditPacks-CZrPuU50.js → useCreditPacks-BE-fG45H.js} +1 -1
- package/assets/{useInfiniteGrid-CpjNJcvu.js → useInfiniteGrid-zYFhuy60.js} +1 -1
- package/assets/{useStore-BiFpmikY.js → useStore-DlgSV8xZ.js} +2 -2
- package/assets/useTheme-BmPzYbts.js +1 -0
- package/assets/{useTheme-Dfa-fM20.js → useTheme-DSjNsZwZ.js} +1 -1
- package/assets/{utils-CsEYBURh.js → utils-CBfcEx8F.js} +1 -1
- package/assets/{verifyHash-ioGoqswc.js → verifyHash-DBA8HgBY.js} +1 -1
- package/assets/{w3m-modal-CLpZJeQd.js → w3m-modal-C9hrB0_f.js} +1 -1
- package/assets/{w3m-modal-BAKNrM0t.js → w3m-modal-CJSKRyIz.js} +1 -1
- package/assets/{wait-for-tx-receipt-lYEZMs5k.js → wait-for-tx-receipt-BdSu8YP0.js} +1 -1
- package/assets/{wallets-CtOsy9m8.js → wallets-CJn4BiVq.js} +6 -6
- package/assets/{web-connector-m174MKL_.js → web-connector-CB2KBra0.js} +3 -3
- package/assets/{writeContract-DPWAZqQk.js → writeContract-DobkVUdS.js} +1 -1
- package/assets/{zora-sepolia-CKeXJ6uD.js → zora-sepolia-CKT05Lph.js} +1 -1
- package/assets/{zoraTestnet-BejTHMIV.js → zoraTestnet-DXF2ZpAM.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Assets-D3UQqWYv.js +0 -1
- package/assets/browser-ponyfill-Cl4XgbUp.js +0 -1
- package/assets/cart-checkout-BGyVbAnU.js +0 -1
- package/assets/categories-DGAkVv39.js +0 -7
- package/assets/collection-Dj0UO6A8.js +0 -1
- package/assets/decimals-9VC5prnp.js +0 -1
- package/assets/emotion-styled.browser.esm-qnTJSlwi.js +0 -1
- package/assets/eth_estimateGas-Bp7rqFOP.js +0 -1
- package/assets/eth_getTransactionCount-C7wA7Kya.js +0 -1
- package/assets/index-CIiavQLK.js +0 -1
- package/assets/index-DPHDecnV.css +0 -1
- package/assets/index-DdKkZ1Lj.js +0 -2
- package/assets/index-DkLziN-4.js +0 -231
- package/assets/useTheme-CUKi-fkK.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{a as pe,r as o,j as e,d as na,b as da,L as ca}from"./react-yytiy0wi.js";import{d as ye,o as oa,u as Ve,t,ad as ma,l as ua,m as ha,w as _a,q as te,b as H,x as Te,y as ue,ae as pa,D as _e,C as S,a9 as ie,_ as he,ai as ya,al as ba,ak as xa,az as fa,ao as va,j as Qe,aA as ja,ah as re,s as z,aB as ga,aC as Na,aD as wa,aE as ka,aa as Be,c as Re,g as T,aF as Ca,aG as Ia,aH as Aa,aI as Sa,aJ as Ma,aq as Pa,a as Ea,I as O,aK as Fa,aL as La,aM as Da,ab as Ta,aN as qe,aO as Ba,B as be,i as Ra,F as qa,at as $a,aP as Ka,aQ as Oa,au as Wa,aR as za,aS as Va}from"./index-DkLziN-4.js";import{d as W}from"./dcl-schemas-BICTSpB5.js";import{b as $e,c as Qa}from"./buy-B1dela3y.js";import{S as Ua,P as Ga,f as Ha}from"./PrimaryListModal-CQLHGKtA.js";import{g as Ya,b as Ja,w as Za,S as Xa,G as et}from"./buy-gasless-Dd7g2EOb.js";import{u as at,c as tt}from"./useCreditPacks-CZrPuU50.js";import{R as Ke}from"./resume-buy-Bf0zIH7y.js";import{a as st,f as Oe,i as it}from"./errors-UirjYlqN.js";import{E as Ue}from"./ErrorNotice-CKeOu_Oi.js";import{C as rt}from"./CircularProgress-Diq42zDa.js";import{u as lt,M as nt}from"./MarketCheckout-rUkLpvLK.js";import{s as dt}from"./address-DrURAr9O.js";import{C as ct}from"./CollectionCarousel-Su-Z1nF7.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-j_wZd1-j.js";import"./index-HN6Rk25C.js";import"./wallet-kind-B9P1TeIH.js";import"./mana-rate-CqkveB3D.js";function ot({item:r,onClose:u,resume:i=!1}){var J,Z;const{session:h}=ye(),{data:c}=oa(h),_=Ve(),g=pe(),b=at().packs.slice(0,3),[n,l]=o.useState("loading"),[a,N]=o.useState(null),[k,j]=o.useState(""),[B,R]=o.useState(r.priceCredits),[x,q]=o.useState(null),M=o.useRef(null),C=(x==null?void 0:x.credits)??B,Y=(c==null?void 0:c.credits)??0;o.useEffect(()=>{let d=!1;if(!h){l("error"),N(t("buyModal.signInToCheckout"));return}const f=m=>{const v=m-((c==null?void 0:c.credits)??0),p=b.find(E=>E.credits>=v)??b[b.length-1];j(p.id),H("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:m,credits_balance:(c==null?void 0:c.credits)??0,shortfall:Math.max(0,v)}),l("nofunds")};return(async()=>{var m,v;try{const p=await ma(r);if(!p)throw new Error("not for sale");if(ua(p,h.address))throw new Error("You can't buy your own listing.");const E=ha((v=(m=p.received)==null?void 0:m[0])==null?void 0:v.amount);if(!Number.isFinite(E)||E<=0)throw new Error("price unavailable");const $=Math.ceil(E/10);if(d)return;if(R($),c!=null&&c.credits<$){f($);return}try{const{credit:w,maxCreditedValue:Q,usdCents:D}=await _a(h.identity,E,p.id);if(d){te(h.identity,[w.id]).catch(()=>{});return}M.current=w.id;const X=Math.ceil(D/10);R(X);const K={trade:p,credit:w,maxCreditedValue:Q,usdCents:D,credits:X};q(K),i?V(K):l("ready")}catch(w){if(d)return;if(st(w)){f($);return}throw w}}catch(p){if(d)return;H(ue(p)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:Te(p)}),l("error"),N(Oe(p,t("buyModal.error.generic"),{sale:!0}))}})(),()=>{d=!0,M.current&&h&&(te(h.identity,[M.current]).catch(()=>{}),M.current=null)}},[]);async function V(d=x){if(!h||!d)return;l("processing"),N(null);let f=!1;try{const m={trade:d.trade,buyer:h.address,signer:h.signer,credits:[d.credit],maxCreditedValue:d.maxCreditedValue};let v;if(Ya())try{v=await Ja(m),await Za(v),f=!0}catch(p){if(p instanceof Xa)f=!0;else if(p instanceof et)v=await $e(m);else throw p}else v=await $e(m);M.current=null,H("Shop Completed Purchase",{...pa([r]),payment_type:"credits",no_crypto_step:f,transaction_hash:v??null}),_.invalidateQueries({queryKey:["usd-balance"]}),l("complete")}catch(m){ue(m)||_e(m,{flow:"buy",step:"submit",gasless:f}),te(h.identity,[d.credit.id]).catch(()=>{}),M.current=null,H(ue(m)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:Te(m)}),_.invalidateQueries({queryKey:["usd-balance"]}),N(Oe(m,t("buyModal.error.generic"),{sale:!0})),l("error")}}async function le(){if(!(!k||!h)){try{sessionStorage.setItem(Ke,JSON.stringify(r))}catch{}x&&te(h.identity,[x.credit.id]).catch(()=>{}),M.current=null,l("loading");try{const d=await tt(k,{address:h.address,identity:h.identity});if(d.url){window.location.href=d.url;return}g("/credits")}catch(d){_e(d,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(Ke)}catch{}N(t("buyModal.error.creditsCheckout")),l("error")}}}const L=n==="processing",P=n==="complete"?t("buyModal.titleComplete"):n==="nofunds"?t("buyModal.titleNoFunds"):t("buyModal.titleBuy");return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:r.name}),children:[e.jsx("div",{className:"buy-modal__scrim",onClick:L?void 0:u,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${n==="processing"||n==="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:P}),!L&&e.jsx("button",{className:"buy-modal__x",onClick:u,"aria-label":t("buyModal.close"),children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:n==="nofunds"?t("buyModal.dclBalance"):t("buyModal.myCreditsBalance")}),e.jsx(S,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:ie(Y)})]})]}),n==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(rt,{size:44})}),n==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(Ue,{message:a}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:u,children:t("buyModal.close")})})]}),n==="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:t("buyModal.insufficientFunds")})," ",t("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:t("buyModal.warningCreditsAmount",{count:Math.max(0,C-Y)})})," ",t("buyModal.warningToPurchase",{count:1})]})]}),e.jsx(We,{item:r,priceCredits:C}),e.jsx("div",{className:"buy-modal__packs",children:b.map(d=>{const f=d.credits,m=d.id===k;return e.jsxs("button",{className:`buy-modal__pack${m?" buy-modal__pack--on":""}`,onClick:()=>j(d.id),children:[e.jsx(S,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:ie(f)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",d.usd.toFixed(2),")"]})]},d.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(S,{className:"buy-modal__total-ico"}),e.jsx("span",{children:ie(((J=b.find(d=>d.id===k))==null?void 0:J.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((Z=b.find(d=>d.id===k))==null?void 0:Z.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:u,children:t("buyModal.cancel")}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:()=>void le(),children:t("buyModal.buy")})]})]}),n==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(We,{item:r,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:()=>void V(),children:t("buyModal.buy")})})]}),n==="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:i?t("buyModal.completingPurchase"):t("buyModal.completingTransaction")}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),n==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:t("getCredits.successTitle")})," ",t("buyModal.successBody")]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>g("/assets?tab=mine"),children:t("buyModal.myAssets")}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:u,children:[t("buyModal.tryInWorld"),e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function We({item:r,priceCredits:u}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:r.thumbnail?e.jsx("img",{src:r.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:r.name,children:r.name||t("buyModal.itemFallback")}),r.creator?e.jsx("div",{className:"buy-modal__asset-creator",children:t("search.byCreator",{name:r.creator})}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(S,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:ie(u)})]})]})]})}const mt=o.lazy(async()=>{const[{EmoteControls:r},{Experimental_CssVarsProvider:u},{light:i}]=await Promise.all([he(()=>import("./index-CC63Imtj.js").then(h=>h.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),he(()=>import("./index-DdKkZ1Lj.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),he(()=>import("./index-BTpn82ck.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:h=>e.jsx(u,{theme:i,children:e.jsx(r,{...h})})}});function ut(r){return e.jsx(o.Suspense,{fallback:null,children:e.jsx(mt,{...r})})}function ht({item:r}){const u=ye(x=>{var q;return(q=x.session)==null?void 0:q.address}),{data:i,isLoading:h}=ya(u),c=u&&i?u:"default",_=r.category==="emote",[g,b]=o.useState("item"),n=!_&&g==="item",l=n||!h,[a,N]=o.useState(!0);o.useEffect(()=>{N(!0)},[r.id,n]);const k=!!u&&!!i,j=k&&ba(r,xa(i)),B=fa(r)[0],R=k&&!j&&!_;return e.jsxs(e.Fragment,{children:[l?e.jsx(va,{id:"shop-item-preview",contractAddress:r.contractAddress,tokenId:r.tokenId??void 0,itemId:r.tokenId?void 0:r.itemId??void 0,profile:n?void 0:j?c:"default",bodyShape:n||j?void 0:B,type:_?void 0:n?W.PreviewType.WEARABLE:W.PreviewType.AVATAR,emote:_||n?void 0:W.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:_?1.5:void 0,wheelStart:_?100:void 0,dev:Qe.chainId===80002,onLoad:()=>N(!1)}):null,!l||a?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":t("itemPreview.loading"),children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,R&&!n?e.jsx("p",{className:"item-preview__note",children:t("itemPreview.shownOnBody",{shape:ja(B)})}):null,_?e.jsx("div",{className:"item-preview__emote-controls","data-testid":"emote-controls",children:e.jsx(ut,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":t("itemPreview.previewMode"),children:[e.jsxs("button",{type:"button",className:g==="avatar"?"is-active":"","aria-pressed":g==="avatar","aria-label":t("itemPreview.onAvatar"),onClick:()=>b("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.onAvatar")})]}),e.jsxs("button",{type:"button",className:g==="item"?"is-active":"","aria-pressed":g==="item","aria-label":t("itemPreview.item"),onClick:()=>b("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.item")})]})]})]})}const _t=z(ga)`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BvYeGTV6.js","assets/react-C51i12iP.js","assets/dcl-schemas-BICTSpB5.js","assets/index-B4D19REm.js","assets/sentry-DKBoGDXH.js","assets/ethers-BeFqf2KO.js","assets/intl-CBcMB1D2.js","assets/index-eE-_qVda.css","assets/emotion-styled.browser.esm-IwF2UC65.js","assets/useTheme-DSjNsZwZ.js","assets/CircularProgress-BJ_TjCN_.js","assets/index-VVTks7i3.js","assets/useTheme-BmPzYbts.js","assets/CssVarsProvider-Cb_KA4y8.js","assets/getOverlayAlpha-BueYXZ9u.js","assets/index-jtb2-_sz.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as pe,r as o,j as e,d as na,a as da,L as ca}from"./react-C51i12iP.js";import{b as ye,l as oa,m as Ve,t,ac as ma,i as ua,j as ha,r as _a,n as te,v as H,w as Te,x as ue,ad as pa,z as _e,C as S,a8 as ie,_ as he,ah as ya,ak as ba,aj as xa,aA as fa,an as va,g as Qe,aB as ja,ag as re,s as z,aC as ga,aD as Na,aE as wa,ap as ka,a9 as Be,a as Re,c as T,aF as Ca,aG as Ia,aH as Aa,aI as Sa,aJ as Ma,ar as Pa,u as Ea,I as O,aK as Fa,aL as La,aM as Da,aa as Ta,aN as qe,aO as Ba,B as be,e as Ra,E as qa,au as $a,aP as Ka,aQ as Oa,av as Wa,aR as za,aS as Va}from"./index-B4D19REm.js";import{d as W}from"./dcl-schemas-BICTSpB5.js";import{b as $e,c as Qa}from"./buy-B5ZS4ZBM.js";import{S as Ua,P as Ga,f as Ha}from"./PrimaryListModal-B8X89MoS.js";import{g as Ya,b as Ja,w as Za,S as Xa,G as et}from"./buy-gasless-Ba7WiBbA.js";import{u as at,c as tt}from"./useCreditPacks-BE-fG45H.js";import{R as Ke}from"./resume-buy-Bf0zIH7y.js";import{a as st,f as Oe,i as it}from"./errors-VkIbnyNm.js";import{E as Ue}from"./ErrorNotice-C7soUjRV.js";import{C as rt}from"./CircularProgress-BJ_TjCN_.js";import{u as lt,M as nt}from"./MarketCheckout-DOEU43Cr.js";import{s as dt}from"./address-DrURAr9O.js";import{C as ct}from"./CollectionCarousel-BB3DzDmR.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-D5hlkp_r.js";import"./index-HN6Rk25C.js";import"./wallet-kind-B9P1TeIH.js";import"./mana-rate-Bf-vAahU.js";function ot({item:r,onClose:u,resume:i=!1}){var J,Z;const{session:h}=ye(),{data:c}=oa(h),_=Ve(),g=pe(),b=at().packs.slice(0,3),[n,l]=o.useState("loading"),[a,N]=o.useState(null),[k,j]=o.useState(""),[B,R]=o.useState(r.priceCredits),[x,q]=o.useState(null),M=o.useRef(null),C=(x==null?void 0:x.credits)??B,Y=(c==null?void 0:c.credits)??0;o.useEffect(()=>{let d=!1;if(!h){l("error"),N(t("buyModal.signInToCheckout"));return}const f=m=>{const v=m-((c==null?void 0:c.credits)??0),p=b.find(E=>E.credits>=v)??b[b.length-1];j(p.id),H("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:m,credits_balance:(c==null?void 0:c.credits)??0,shortfall:Math.max(0,v)}),l("nofunds")};return(async()=>{var m,v;try{const p=await ma(r);if(!p)throw new Error("not for sale");if(ua(p,h.address))throw new Error("You can't buy your own listing.");const E=ha((v=(m=p.received)==null?void 0:m[0])==null?void 0:v.amount);if(!Number.isFinite(E)||E<=0)throw new Error("price unavailable");const $=Math.ceil(E/10);if(d)return;if(R($),c!=null&&c.credits<$){f($);return}try{const{credit:w,maxCreditedValue:Q,usdCents:D}=await _a(h.identity,E,p.id);if(d){te(h.identity,[w.id]).catch(()=>{});return}M.current=w.id;const X=Math.ceil(D/10);R(X);const K={trade:p,credit:w,maxCreditedValue:Q,usdCents:D,credits:X};q(K),i?V(K):l("ready")}catch(w){if(d)return;if(st(w)){f($);return}throw w}}catch(p){if(d)return;H(ue(p)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:Te(p)}),l("error"),N(Oe(p,t("buyModal.error.generic"),{sale:!0}))}})(),()=>{d=!0,M.current&&h&&(te(h.identity,[M.current]).catch(()=>{}),M.current=null)}},[]);async function V(d=x){if(!h||!d)return;l("processing"),N(null);let f=!1;try{const m={trade:d.trade,buyer:h.address,signer:h.signer,credits:[d.credit],maxCreditedValue:d.maxCreditedValue};let v;if(Ya())try{v=await Ja(m),await Za(v),f=!0}catch(p){if(p instanceof Xa)f=!0;else if(p instanceof et)v=await $e(m);else throw p}else v=await $e(m);M.current=null,H("Shop Completed Purchase",{...pa([r]),payment_type:"credits",no_crypto_step:f,transaction_hash:v??null}),_.invalidateQueries({queryKey:["usd-balance"]}),l("complete")}catch(m){ue(m)||_e(m,{flow:"buy",step:"submit",gasless:f}),te(h.identity,[d.credit.id]).catch(()=>{}),M.current=null,H(ue(m)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:Te(m)}),_.invalidateQueries({queryKey:["usd-balance"]}),N(Oe(m,t("buyModal.error.generic"),{sale:!0})),l("error")}}async function le(){if(!(!k||!h)){try{sessionStorage.setItem(Ke,JSON.stringify(r))}catch{}x&&te(h.identity,[x.credit.id]).catch(()=>{}),M.current=null,l("loading");try{const d=await tt(k,{address:h.address,identity:h.identity});if(d.url){window.location.href=d.url;return}g("/credits")}catch(d){_e(d,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(Ke)}catch{}N(t("buyModal.error.creditsCheckout")),l("error")}}}const L=n==="processing",P=n==="complete"?t("buyModal.titleComplete"):n==="nofunds"?t("buyModal.titleNoFunds"):t("buyModal.titleBuy");return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:r.name}),children:[e.jsx("div",{className:"buy-modal__scrim",onClick:L?void 0:u,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${n==="processing"||n==="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:P}),!L&&e.jsx("button",{className:"buy-modal__x",onClick:u,"aria-label":t("buyModal.close"),children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:n==="nofunds"?t("buyModal.dclBalance"):t("buyModal.myCreditsBalance")}),e.jsx(S,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:ie(Y)})]})]}),n==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(rt,{size:44})}),n==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(Ue,{message:a}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:u,children:t("buyModal.close")})})]}),n==="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:t("buyModal.insufficientFunds")})," ",t("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:t("buyModal.warningCreditsAmount",{count:Math.max(0,C-Y)})})," ",t("buyModal.warningToPurchase",{count:1})]})]}),e.jsx(We,{item:r,priceCredits:C}),e.jsx("div",{className:"buy-modal__packs",children:b.map(d=>{const f=d.credits,m=d.id===k;return e.jsxs("button",{className:`buy-modal__pack${m?" buy-modal__pack--on":""}`,onClick:()=>j(d.id),children:[e.jsx(S,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:ie(f)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",d.usd.toFixed(2),")"]})]},d.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(S,{className:"buy-modal__total-ico"}),e.jsx("span",{children:ie(((J=b.find(d=>d.id===k))==null?void 0:J.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((Z=b.find(d=>d.id===k))==null?void 0:Z.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:u,children:t("buyModal.cancel")}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:()=>void le(),children:t("buyModal.buy")})]})]}),n==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(We,{item:r,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:()=>void V(),children:t("buyModal.buy")})})]}),n==="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:i?t("buyModal.completingPurchase"):t("buyModal.completingTransaction")}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),n==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:t("getCredits.successTitle")})," ",t("buyModal.successBody")]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>g("/assets?tab=mine"),children:t("buyModal.myAssets")}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:u,children:[t("buyModal.tryInWorld"),e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function We({item:r,priceCredits:u}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:r.thumbnail?e.jsx("img",{src:r.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:r.name,children:r.name||t("buyModal.itemFallback")}),r.creator?e.jsx("div",{className:"buy-modal__asset-creator",children:t("search.byCreator",{name:r.creator})}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(S,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:ie(u)})]})]})]})}const mt=o.lazy(async()=>{const[{EmoteControls:r},{Experimental_CssVarsProvider:u},{light:i}]=await Promise.all([he(()=>import("./index-BvYeGTV6.js").then(h=>h.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),he(()=>import("./index-VVTks7i3.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),he(()=>import("./index-jtb2-_sz.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:h=>e.jsx(u,{theme:i,children:e.jsx(r,{...h})})}});function ut(r){return e.jsx(o.Suspense,{fallback:null,children:e.jsx(mt,{...r})})}function ht({item:r}){const u=ye(x=>{var q;return(q=x.session)==null?void 0:q.address}),{data:i,isLoading:h}=ya(u),c=u&&i?u:"default",_=r.category==="emote",[g,b]=o.useState("item"),n=!_&&g==="item",l=n||!h,[a,N]=o.useState(!0);o.useEffect(()=>{N(!0)},[r.id,n]);const k=!!u&&!!i,j=k&&ba(r,xa(i)),B=fa(r)[0],R=k&&!j&&!_;return e.jsxs(e.Fragment,{children:[l?e.jsx(va,{id:"shop-item-preview",contractAddress:r.contractAddress,tokenId:r.tokenId??void 0,itemId:r.tokenId?void 0:r.itemId??void 0,profile:n?void 0:j?c:"default",bodyShape:n||j?void 0:B,type:_?void 0:n?W.PreviewType.WEARABLE:W.PreviewType.AVATAR,emote:_||n?void 0:W.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:_?1.5:void 0,wheelStart:_?100:void 0,dev:Qe.chainId===80002,onLoad:()=>N(!1)}):null,!l||a?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":t("itemPreview.loading"),children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,R&&!n?e.jsx("p",{className:"item-preview__note",children:t("itemPreview.shownOnBody",{shape:ja(B)})}):null,_?e.jsx("div",{className:"item-preview__emote-controls","data-testid":"emote-controls",children:e.jsx(ut,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":t("itemPreview.previewMode"),children:[e.jsxs("button",{type:"button",className:g==="avatar"?"is-active":"","aria-pressed":g==="avatar","aria-label":t("itemPreview.onAvatar"),onClick:()=>b("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.onAvatar")})]}),e.jsxs("button",{type:"button",className:g==="item"?"is-active":"","aria-pressed":g==="item","aria-label":t("itemPreview.item"),onClick:()=>b("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:t("itemPreview.item")})]})]})]})}const _t=z(ga)`
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
overflow: hidden;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as c}from"./react-
|
|
1
|
+
import{r as l,j as c}from"./react-C51i12iP.js";import{s as u,B as p,t as d}from"./index-B4D19REm.js";const a=u.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
padding: 28px 0 8px;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as O,g as S,b as V,l as Y,m as H,t,n as h,C as x,o as M,q as $,h as j,e as D,i as J,r as X,v as y,w as F,x as R,s as Z,B as ee}from"./index-B4D19REm.js";import{r as re,a as b}from"./mana-rate-Bf-vAahU.js";import{u as ae,r as m,j as r}from"./react-C51i12iP.js";import{b as A}from"./buy-B5ZS4ZBM.js";import{g as te,b as se,w as ie,S as ce,G as ne}from"./buy-gasless-Ba7WiBbA.js";import{i as de}from"./errors-VkIbnyNm.js";import{E as oe}from"./ErrorNotice-C7soUjRV.js";function pe(e=!0){return O({queryKey:["mana-rate",S.chainId],queryFn:()=>re(S.chainId),enabled:e,staleTime:6e4,refetchInterval:6e4,retry:1})}const B=Z(ee)`
|
|
2
2
|
flex: 1;
|
|
3
3
|
`;function U(e){if(de(e))return t("errors.rejected");const n=(e.message??"").toLowerCase();return n.includes("insufficient")?t("marketCheckout.error.insufficient",{currency:j.name}):n.includes("not found")||n.includes("no active listing")||n.includes("404")?t("marketCheckout.error.soldOrRemoved"):n.includes("your own listing")?t("errors.cantBuyOwn"):t("marketCheckout.error.generic")}function le(e){return{id:e.tradeId,tradeId:e.tradeId,name:e.name,creator:e.creator,contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,wearableCategory:e.wearableCategory??void 0,rarity:e.rarity,network:e.network,chainId:e.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function Ce({listing:e,rate:n,onClose:q,onSold:W}){const{session:i}=V(),{data:d,isError:T}=Y(i),w=H(),g=ae(),[N,k]=m.useState("confirm"),[p,I]=m.useState(t("marketCheckout.lockingPrice")),[G,f]=m.useState(null),[a,L]=m.useState(null),o=m.useRef(null),Q=Math.ceil(b(e.manaWei,n)/10);m.useEffect(()=>{let l=!1;if(!i){k("error"),f(t("buyModal.signInToCheckout"));return}return(async()=>{try{const s=await D(e.tradeId);if(!s)throw new Error("not found");if(J(s,i.address))throw new Error("You can't buy your own listing.");const u=b(e.manaWei,n);if(!Number.isFinite(u)||u<=0)throw new Error("price unavailable");const{credit:v,maxCreditedValue:K,usdCents:P}=await X(i.identity,u,e.tradeId);if(l){h(i.identity,[v.id]).catch(()=>{});return}o.current=v.id,L({trade:s,credit:v,maxCreditedValue:K,usdCents:P,credits:Math.ceil(P/10)}),I("")}catch(s){if(l)return;console.error("[market] authorize failed",s),y(R(s)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:F(s),value_usd:Math.round(b(e.manaWei,n))/100}),k("error"),f(U(s))}})(),()=>{l=!0,o.current&&i&&(h(i.identity,[o.current]).catch(()=>{}),o.current=null)}},[]);const C=!!a&&d!=null&&d.credits<a.credits;async function z(){if(!i||!a)return;if(C){y("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:a.credits,credits_balance:(d==null?void 0:d.credits)??0,shortfall:Math.max(0,a.credits-((d==null?void 0:d.credits)??0))}),h(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,g("/credits");return}k("working"),f(null);let l=!1;try{I(t("marketCheckout.confirming"));const c={trade:a.trade,buyer:i.address,signer:i.signer,credits:[a.credit],maxCreditedValue:a.maxCreditedValue};let s;if(te())try{s=await se(c),await ie(s),l=!0}catch(u){if(u instanceof ce)l=!0;else if(u instanceof ne)s=await A(c);else throw u}else s=await A(c);o.current=null,y("Shop Completed Purchase",{items:[{item_id:e.itemId??null,contract_address:e.contractAddress,token_id:null,price_usd:a.usdCents/100}],value_credits:a.credits,value_usd:a.usdCents/100,purchase_type:"item",is_primary:!0,payment_type:"credits",no_crypto_step:l,transaction_hash:s??null}),w.invalidateQueries({queryKey:["usd-balance"]}),g("/success",{state:{items:[le(e)],txHash:s}})}catch(c){console.error("[market] buy now failed",c),h(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,y(R(c)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:F(c),value_usd:a.usdCents/100}),w.invalidateQueries({queryKey:["usd-balance"]}),f(U(c)),k("error");const s=(c.message??"").toLowerCase();(s.includes("not found")||s.includes("no active listing")||s.includes("404"))&&W()}}function E(){i&&a&&h(i.identity,[a.credit.id]).catch(()=>{}),o.current=null,q()}const _=N==="working";return r.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":t("buyModal.dialogAria",{name:e.name}),children:[r.jsx("div",{className:"mkt-modal__scrim",onClick:_?void 0:E,"aria-hidden":!0}),r.jsxs("div",{className:"mkt-modal__card",children:[r.jsxs("div",{className:"mkt-modal__head",children:[r.jsx("div",{className:"mkt-modal__thumb",children:e.thumbnail?r.jsx("img",{src:e.thumbnail,alt:""}):null}),r.jsxs("div",{children:[r.jsx("div",{className:"mkt-modal__name",title:e.name,children:e.name||t("buyModal.itemFallback")}),r.jsx("span",{className:"chip chip--rarity",children:e.rarity})]})]}),r.jsx("div",{className:"mkt-modal__price",children:a?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.finalPrice")}),r.jsxs("div",{className:"mkt-modal__price-value",children:[r.jsx(x,{className:"mkt-modal__diamond"}),M(a.credits)]}),r.jsxs("div",{className:"mkt-modal__price-sub muted",children:[t("marketCheckout.lockedForPurchase")," · $",(a.usdCents/100).toFixed(2)]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mkt-modal__price-label",children:t("marketCheckout.todaysPrice")}),r.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[r.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),r.jsx(x,{className:"mkt-modal__diamond"}),M(Q)]}),r.jsx("div",{className:"mkt-modal__price-sub muted",children:p||t("marketCheckout.lockingPrice")})]})}),i?r.jsxs("div",{className:"mkt-modal__balance muted",children:[t("marketCheckout.yourBalance")," ",r.jsx(x,{className:"ccy-mark"})," ",$(d,T)]}):null,C?r.jsx("p",{className:"muted mkt-modal__note",children:t("marketCheckout.needMore",{currency:j.name})}):null,p&&N==="working"?r.jsx("p",{className:"muted mkt-modal__note",children:p}):null,r.jsx(oe,{message:G,className:"mkt-modal__note"}),r.jsxs("div",{className:"mkt-modal__actions",children:[r.jsx(B,{variant:"ghost",onClick:E,disabled:_,children:t("buyModal.cancel")}),r.jsx(B,{variant:"purple",onClick:()=>void z(),disabled:_||!a,children:_?t("marketCheckout.buying"):C?t("nav.getCredits",{currency:j.name}):t("marketCheckout.confirmPurchase")})]})]})]})}export{Ce as M,pe as u};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{u as J,r as o,j as s,L as V}from"./react-C51i12iP.js";import{u as X,t,b as ss,m as es,c as N,B as y,C as T,v as O,D as as,s as B,e as ns,E as ts,z as is,g as rs,h as cs,F as ls}from"./index-B4D19REm.js";import{f as os}from"./import-CN6p_MqT.js";import{S as ds,P as ms,f as hs}from"./PrimaryListModal-B8X89MoS.js";import{c as us}from"./buy-B5ZS4ZBM.js";import{L as ps}from"./LoadMore-Blqu_ob_.js";import{u as ys}from"./useInfiniteGrid-zYFhuy60.js";import{E as _}from"./ErrorNotice-C7soUjRV.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";import"./mana-rate-Bf-vAahU.js";import"./index-HN6Rk25C.js";import"./trade-encoding-D5hlkp_r.js";import"./errors-VkIbnyNm.js";import"./wallet-kind-B9P1TeIH.js";const gs=B(y)`
|
|
2
2
|
margin-top: 8px;
|
|
3
3
|
width: 100%;
|
|
4
|
-
`,
|
|
4
|
+
`,z=B(y)`
|
|
5
5
|
margin-top: auto;
|
|
6
6
|
width: 100%;
|
|
7
|
-
`,xs=48;function js(n){return{id:n.id,name:n.name,creator:"",contractAddress:n.contractAddress,itemId:n.itemId,category:n.category,rarity:n.rarity??"common",network:n.network,chainId:n.chainId,thumbnail:n.image,priceCredits:n.listingPrice??0,gender:null,isSmart:!1,tokenId:n.tokenId}}function
|
|
7
|
+
`,xs=48;function js(n){return{id:n.id,name:n.name,creator:"",contractAddress:n.contractAddress,itemId:n.itemId,category:n.category,rarity:n.rarity??"common",network:n.network,chainId:n.chainId,thumbnail:n.image,priceCredits:n.listingPrice??0,gender:null,isSmart:!1,tokenId:n.tokenId}}function K(n){return{id:`${n.contractAddress}-${n.blockchainItemId}`,name:n.name,creator:"",contractAddress:n.contractAddress,itemId:n.blockchainItemId,category:n.category,rarity:n.rarity,network:"MATIC",chainId:rs.chainId,thumbnail:n.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function Fs(){X({title:t("nav.myAssets"),noindex:!0});const{session:n,error:Q,signIn:R,restore:v}=ss(),D=J(),A=es(),[I,f]=o.useState(null),[k,S]=o.useState(null),[h,C]=o.useState(null),[G,w]=o.useState(null);function g(e){const a=e.tokenId??e.itemId??"";!e.contractAddress||!a||D(`/item/${e.contractAddress}/${a}`,{state:{item:e}})}async function E(e,a,i){if(n){w(null),C(i);try{const r=await ns(e);await us({trade:r,signer:n.signer}),ts.success(t("myAssets.removedFromSale",{name:a})),await A.invalidateQueries({queryKey:["my-assets",n.address]}),await A.invalidateQueries({queryKey:["collection-sale-state"]})}catch(r){const u=r,p=(u.message??"").toLowerCase(),F=u.code===4001||p.includes("reject")||p.includes("denied");F||is(r,{flow:"remove-listing",tradeId:e}),w(F?t("getCredits.errorCanceled"):t("myAssets.removeListingError"))}finally{C(null)}}}o.useEffect(()=>{v()},[v]);const c=n==null?void 0:n.address,{items:P,isLoading:$,error:U,hasNextPage:W,isFetchingNextPage:L,fetchNextPage:Y}=ys(["my-assets",c],e=>as(c,{first:xs,skip:e}).then(a=>({items:a.assets,total:a.total})),{enabled:!!c}),{data:d}=N({queryKey:["importable",c],queryFn:()=>os(c),enabled:!!c}),M=((d==null?void 0:d.creations.length)??0)+((d==null?void 0:d.owned.length)??0),{data:m,isLoading:Z,isError:H}=N({queryKey:["publishable-items",c],queryFn:()=>hs(c,n.identity),enabled:!!n,retry:!1}),x=o.useMemo(()=>[...new Set((m??[]).map(e=>e.contractAddress))],[m]),{data:l}=N({queryKey:["collection-sale-state",c,x],enabled:x.length>0,queryFn:async()=>{const e=await Promise.all(x.map(async i=>[i,await ls(i)])),a={};for(const[i,r]of e)for(const[u,p]of Object.entries(r))a[`${i}-${u}`]=p;return a}}),j=e=>l==null?void 0:l[`${e.contractAddress}-${e.blockchainItemId}`],b=o.useMemo(()=>(m??[]).filter(e=>{var a;return(a=j(e))==null?void 0:a.isOnSale}),[m,l]),q=o.useMemo(()=>{var a;const e=new Map;for(const i of m??[]){if((a=l==null?void 0:l[`${i.contractAddress}-${i.blockchainItemId}`])!=null&&a.isOnSale)continue;const r=e.get(i.collectionId)??{id:i.collectionId,name:i.collectionName,items:[]};r.items.push(i),e.set(i.collectionId,r)}return[...e.values()]},[m,l]);return n?s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:t("nav.myAssets")}),M>0?s.jsxs(V,{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:t("myAssets.importTitle")}),s.jsx("span",{className:"import-banner__sub",children:t("myAssets.importSub",{count:M})})]}),s.jsx("span",{className:"import-banner__cta",children:t("myAssets.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:t("myAssets.ownedTitle")}),s.jsx("p",{className:"myassets__section-sub",children:t("myAssets.ownedSub")})]}),U?s.jsx(_,{message:t("myAssets.ownedError")}):null,s.jsx(_,{message:G}),s.jsxs("div",{className:"asset-grid",children:[$?Array.from({length:8}).map((e,a)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`sk-${a}`)):P.map(e=>s.jsxs("article",{className:"asset-card asset-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":t("myAssets.viewItem",{name:e.name}),onClick:()=>g(js(e))}),s.jsx("div",{className:"asset-card__img",children:e.image?s.jsx("img",{src:e.image,alt:e.name}):null}),s.jsx("div",{className:"asset-card__name",title:e.name,children:e.name}),e.isOnSale?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"asset-card__listed",children:[s.jsxs("span",{className:"asset-card__price",children:[s.jsx(T,{className:"ccy-mark"})," ",e.listingPrice]}),s.jsx("span",{className:"badge",children:t("myAssets.onSale")})]}),s.jsx(gs,{size:"sm",variant:"ghost",disabled:h===e.id||!e.tradeId,onClick:a=>{a.stopPropagation(),e.tradeId&&E(e.tradeId,e.name,e.id)},children:h===e.id?t("myAssets.removing"):t("myAssets.removeListing")})]}):s.jsx(y,{size:"sm",onClick:a=>{a.stopPropagation(),O("Shop Started Listing",{listing_type:"secondary",item_id:e.itemId??e.tokenId??null}),f(e)},children:t("myAssets.putOnSale")})]},e.id)),L?Array.from({length:4}).map((e,a)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`msk-${a}`)):null]}),s.jsx(ps,{hasNextPage:W,isFetching:L,onLoadMore:()=>void Y()}),!$&&P.length===0?s.jsx("p",{className:"muted",children:t("myAssets.ownedEmpty")}):null]}),s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:t("myAssets.creationsTitle")}),s.jsx("p",{className:"myassets__section-sub",children:t("myAssets.creationsSub",{currency:cs.name})})]}),Z?s.jsx("div",{className:"publish-grid",children:Array.from({length:4}).map((e,a)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`pub-sk-${a}`))}):H?s.jsx("p",{className:"publish-empty",children:t("myAssets.collectionsError")}):b.length===0&&q.length===0?s.jsx("p",{className:"publish-empty",children:t("myAssets.nothingToPublish")}):s.jsxs(s.Fragment,{children:[b.length>0?s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:t("myAssets.onSale")}),s.jsx("div",{className:"publish-grid",children:b.map(e=>{var a;return s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":t("myAssets.viewItem",{name:e.name}),onClick:()=>g(K(e))}),s.jsx("div",{className:"publish-card__img",children:e.thumbnail?s.jsx("img",{src:e.thumbnail,alt:e.name}):null}),s.jsx("div",{className:"publish-card__name",title:e.name,children:e.name}),s.jsxs("div",{className:"publish-card__listed",children:[s.jsxs("span",{className:"publish-card__price",children:[s.jsx(T,{className:"ccy-mark"})," ",((a=j(e))==null?void 0:a.priceCredits)??0]}),s.jsx("span",{className:"badge",children:t("myAssets.onSale")})]}),s.jsx(z,{size:"sm",variant:"ghost",disabled:h===e.id,onClick:i=>{i.stopPropagation();const r=j(e);r!=null&&r.tradeId&&E(r.tradeId,e.name,e.id)},children:h===e.id?t("myAssets.removing"):t("myAssets.removeListing")})]},`${e.contractAddress}-${e.blockchainItemId}`)})})]}):null,q.map(e=>s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:e.name}),s.jsx("div",{className:"publish-grid",children:e.items.map(a=>s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":t("myAssets.viewItem",{name:a.name}),onClick:()=>g(K(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__meta",children:[s.jsx("span",{className:"publish-chip publish-chip--rarity",children:a.rarity}),s.jsx("span",{className:"publish-card__supply",children:t("myAssets.available",{count:a.remainingSupply})})]}),s.jsx(z,{size:"sm",variant:"purple",onClick:i=>{i.stopPropagation(),O("Shop Started Listing",{listing_type:"primary",item_id:a.blockchainItemId}),S(a)},children:t("myAssets.putOnSale")})]},`${a.contractAddress}-${a.blockchainItemId}`))})]},e.id))]})]}),I?s.jsx(ds,{asset:I,session:n,onClose:()=>f(null)}):null,k?s.jsx(ms,{item:k,session:n,onClose:()=>S(null)}):null]}):s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:t("nav.myAssets")}),s.jsx("p",{className:"muted",children:t("myAssets.signInPrompt")}),s.jsx("div",{className:"connect-row",children:s.jsx(y,{variant:"purple",onClick:()=>R(),children:t("storeSettings.signIn")})}),s.jsx(_,{message:Q})]})}export{Fs as MyAssets};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as n,j as s,L as m}from"./react-
|
|
1
|
+
import{r as n,j as s,L as m}from"./react-C51i12iP.js";import{u as c,t,a as l,I as d,A as p,s as v,B as x}from"./index-B4D19REm.js";import{L as u}from"./LoadMore-Blqu_ob_.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";const h=v(x)`
|
|
2
2
|
margin-top: 12px;
|
|
3
|
-
`,r=24;function E(){c({title:t("nav.myFavorites"),noindex:!0});const a=l(e=>Object.values(e.items)),[i,o]=n.useState(r);return a.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx(d,{name:"heart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"favorites-empty__title",children:t("myFavorites.emptyTitle")}),s.jsx("p",{className:"muted",children:t("myFavorites.emptyBody")}),s.jsx(
|
|
3
|
+
`,r=24;function E(){c({title:t("nav.myFavorites"),noindex:!0});const a=l(e=>Object.values(e.items)),[i,o]=n.useState(r);return a.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx(d,{name:"heart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"favorites-empty__title",children:t("myFavorites.emptyTitle")}),s.jsx("p",{className:"muted",children:t("myFavorites.emptyBody")}),s.jsx(h,{as:m,to:"/assets",variant:"purple",children:t("notFound.cta")})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:t("nav.myFavorites")}),s.jsx("span",{className:"favorites__count",children:t("myFavorites.itemCount",{count:a.length})})]}),s.jsx("div",{className:"grid",children:a.slice(0,i).map(e=>s.jsx(p,{item:e},e.id))}),s.jsx(u,{hasNextPage:i<a.length,isFetching:!1,onLoadMore:()=>o(e=>e+r)})]})}export{E as MyFavorites};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as s,L as
|
|
1
|
+
import{j as s,L as h}from"./react-C51i12iP.js";import{u as l,t as r,b as p,I as o,f as x,s as j,B as _,c as y,C as N,d as g}from"./index-B4D19REm.js";import{L as f}from"./LoadMore-Blqu_ob_.js";import{u as v}from"./useInfiniteGrid-zYFhuy60.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";const P=j(_)`
|
|
2
2
|
margin-top: 12px;
|
|
3
|
-
`,I=24;function b(e){try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function E({status:e}){return e==="PENDING"?s.jsx("span",{className:"purchase__badge purchase__badge--pending",children:r("myPurchases.processing")}):s.jsx("span",{className:"purchase__badge purchase__badge--done",children:r("myPurchases.completed")})}function F({purchase:e}){const{data:a}=y({queryKey:["trade-display",e.tradeId],queryFn:()=>g(e.tradeId),enabled:!!e.tradeId,staleTime:3e5}),c=(a==null?void 0:a.name)??r("myPurchases.itemFallback"),m=(a==null?void 0:a.thumbnail)??"",i=(a==null?void 0:a.tokenId)??(a==null?void 0:a.itemId)??"",d=a!=null&&a.contractAddress&&i?`/item/${a.contractAddress}/${i}`:void 0,n=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"purchase__thumb",children:m?s.jsx("img",{src:m,alt:c}):null}),s.jsxs("div",{className:"purchase__info",children:[s.jsx("div",{className:"purchase__name",title:c,children:c}),s.jsx("div",{className:"muted purchase__date",children:b(e.createdAt)})]}),s.jsx(E,{status:e.status}),s.jsxs("div",{className:"purchase__price",children:[s.jsx(N,{className:"ccy-mark"})," ",e.credits]})]});return d?s.jsx(
|
|
3
|
+
`,I=24;function b(e){try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function E({status:e}){return e==="PENDING"?s.jsx("span",{className:"purchase__badge purchase__badge--pending",children:r("myPurchases.processing")}):s.jsx("span",{className:"purchase__badge purchase__badge--done",children:r("myPurchases.completed")})}function F({purchase:e}){const{data:a}=y({queryKey:["trade-display",e.tradeId],queryFn:()=>g(e.tradeId),enabled:!!e.tradeId,staleTime:3e5}),c=(a==null?void 0:a.name)??r("myPurchases.itemFallback"),m=(a==null?void 0:a.thumbnail)??"",i=(a==null?void 0:a.tokenId)??(a==null?void 0:a.itemId)??"",d=a!=null&&a.contractAddress&&i?`/item/${a.contractAddress}/${i}`:void 0,n=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"purchase__thumb",children:m?s.jsx("img",{src:m,alt:c}):null}),s.jsxs("div",{className:"purchase__info",children:[s.jsx("div",{className:"purchase__name",title:c,children:c}),s.jsx("div",{className:"muted purchase__date",children:b(e.createdAt)})]}),s.jsx(E,{status:e.status}),s.jsxs("div",{className:"purchase__price",children:[s.jsx(N,{className:"ccy-mark"})," ",e.credits]})]});return d?s.jsx(h,{className:"purchase",to:d,children:n}):s.jsx("div",{className:"purchase",children:n})}function G(){l({title:r("nav.myPurchases"),noindex:!0});const{session:e}=p(),{items:a,isLoading:c,hasNextPage:m,isFetchingNextPage:i,fetchNextPage:d}=v(["purchases",e==null?void 0:e.address],t=>x(e.address,e.identity,{first:I,skip:t}),{enabled:!!e});if(!e)return s.jsxs("div",{className:"purchases-empty",children:[s.jsx(o,{name:"cart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"purchases-empty__title",children:r("myPurchases.signInTitle")}),s.jsx("p",{className:"muted",children:r("myPurchases.signInBody")})]});const n=a.filter(t=>t.status!=="EXPIRED");return!c&&n.length===0?s.jsxs("div",{className:"purchases-empty",children:[s.jsx(o,{name:"cart",size:40,color:"var(--muted-2)"}),s.jsx("p",{className:"purchases-empty__title",children:r("myPurchases.emptyTitle")}),s.jsx("p",{className:"muted",children:r("myPurchases.emptyBody")}),s.jsx(P,{as:h,to:"/assets",variant:"purple",children:r("notFound.cta")})]}):s.jsxs("section",{className:"purchases",children:[s.jsxs("div",{className:"purchases__head",children:[s.jsx("h1",{children:r("nav.myPurchases")}),c?null:s.jsx("span",{className:"purchases__count",children:r("myPurchases.orderCount",{count:n.length})})]}),s.jsx("div",{className:"purchases__list",children:c?Array.from({length:4}).map((t,u)=>s.jsx("div",{className:"purchase purchase--skeleton"},u)):s.jsxs(s.Fragment,{children:[n.map(t=>s.jsx(F,{purchase:t},t.id)),i?Array.from({length:2}).map((t,u)=>s.jsx("div",{className:"purchase purchase--skeleton"},`m-${u}`)):null]})}),s.jsx(f,{hasNextPage:m,isFetching:i,onLoadMore:()=>void d()})]})}export{G as MyPurchases};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as ee}from"./sentry-
|
|
1
|
+
import{p as ee}from"./sentry-DKBoGDXH.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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,L as n}from"./react-
|
|
1
|
+
import{j as t,L as n}from"./react-C51i12iP.js";import{u as s,t as o,I as e,B as a}from"./index-B4D19REm.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";function c(){return s({title:o("seo.notFound.title"),noindex:!0}),t.jsxs("div",{className:"notfound","data-testid":"notfound",children:[t.jsx(e,{name:"cart",className:"notfound__ico"}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(a,{as:n,to:"/assets",variant:"purple",children:o("notFound.cta")})]})}export{c as NotFound,c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as w,a3 as K,u as M,t as a,C as P,B as f,k as j,p as $,b as C,F as E,D as T,x as O}from"./index-DkLziN-4.js";import{d as F}from"./dcl-schemas-BICTSpB5.js";import{a as R,r as u,j as s}from"./react-yytiy0wi.js";import{a as H,b as X,i as J,e as V,c as Y}from"./trade-encoding-j_wZd1-j.js";import{f as U}from"./errors-UirjYlqN.js";import{E as q}from"./ErrorNotice-CKeOu_Oi.js";import{s as z}from"./wallet-kind-B9P1TeIH.js";const I=()=>`${w.builderServerUrl}/v1`;function B(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function Q(e,r){const t=await K(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const l=await t.json();return l.data??l}function Z(e,r){const t=r-e;return t>0?t:0}function ee(e){var r,t,l,i,n;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(l=e.data)==null?void 0:l.emote)==null?void 0:i.category)??((n=e.data)==null?void 0:n.category)??e.type??"wearable"}function A(e){return`${I()}/storage/contents/${e}`}function S(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?A(t):/^(ba|Qm)/.test(e)?A(e):""}async function se(e,r){try{const t=await fetch(`${I()}/items/${e}/${r}/contents`);if(!t.ok)return{};const l=await t.json();return l.data??l}catch{return{}}}async function ae(e,r,t){const l=S(e.thumbnail,e.contents)||S("thumbnail.png",e.contents);if(l)return l;if(r&&t){const i=await se(r,t);return S(e.thumbnail,i)||S("thumbnail.png",i)||S("image.png",i)}return""}async function te(e,r){const t=`${I()}/${e.toLowerCase()}/collections?is_published=true`,l=await Q(t,r);return B(l).filter(i=>i.is_published&&!!i.contract_address).map(i=>({id:i.id,name:i.name,contractAddress:i.contract_address.toLowerCase(),isPublished:i.is_published,isApproved:i.is_approved,minters:(i.minters??[]).map(n=>n.toLowerCase())}))}async function re(e,r){const t=`${I()}/collections/${e.id}/items`,l=await Q(t,r);return(await Promise.all(B(l).map(async n=>{const x=n.rarity??"common",y=Number(n.total_supply??0)||0;let o;try{o=F.Rarity.getMaxSupply(x)}catch{o=0}const _=(n.contract_address??e.contractAddress).toLowerCase(),p=n.blockchain_item_id??"";return{id:n.id,collectionId:e.id,collectionName:e.name,contractAddress:_,blockchainItemId:p,name:n.name,category:ee(n),rarity:x,thumbnail:await ae(n,_,p),type:n.type??"wearable",isPublished:n.is_published??e.isPublished,isApproved:n.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Z(y,o),minters:e.minters}}))).filter(ie)}function ie(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function ye(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await re(i,r)}catch{return[]}}))).flat()}const ne=1e3*60*60*24*182;function ge({asset:e,session:r,onClose:t}){const l=M(),i=R(),[n,x]=u.useState("10"),[y,o]=u.useState(null),[_,p]=u.useState(null),[m,N]=u.useState(!1),[h,v]=u.useState(null);async function k(){p(null);const c=Number(n);if(!Number.isInteger(c)||c<=0){p(a("sellModal.errorWholeNumber"));return}N(!0);try{o(a("sellModal.statusPreparing")),await H({signer:r.signer,contractAddress:e.contractAddress,chainId:e.chainId}),o(a("sellModal.statusListing"));const g=await X({signer:r.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:c/10,expiresAtMs:Date.now()+ne});o(a("sellModal.statusPublishing")),await $(g,r.identity),o(null),v(c),C("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"secondary",is_primary:!1}),E.success(a("sellModal.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["my-assets",r.address]})}catch(g){T(g,{flow:"list_secondary"}),C("Shop Listing Failed",{listing_type:"secondary",error_code:O(g)}),p(U(g,a("sellModal.errorGeneric"))),o(null)}finally{N(!1)}}function L(){t(),i(`/item/${e.contractAddress}/${e.tokenId}`)}return h!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("sellModal.successTitle")}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("sellModal.listedFor")," ",s.jsxs("strong",{children:[s.jsx(P,{className:"ccy-mark"})," ",h]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:L,children:a("sellModal.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("sellModal.listTitle",{name:e.name})}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("sellModal.priceLabel",{currency:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:c=>x(c.target.value),disabled:m})]}),s.jsx("p",{className:"muted small",children:a("sellModal.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(q,{message:_}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:m,children:a("sellModal.cancel")}),s.jsx(f,{onClick:()=>void k(),disabled:m,children:m?a("sellModal.listing"):a("sellModal.putOnSale")})]})]})})}const le=1e3*60*60*24*182;function fe({item:e,session:r,onClose:t}){const l=M(),i=R(),[n,x]=u.useState("10"),[y,o]=u.useState(null),[_,p]=u.useState(null),[m,N]=u.useState(!1),[h,v]=u.useState(null),[k,L]=u.useState(null),c=w.chainId,g=z(r.providerType);u.useEffect(()=>{let d=!1;return(async()=>{try{const b=await J({contractAddress:e.contractAddress,chainId:c});d||v(b)}catch{d||v(!1)}})(),()=>{d=!0}},[e.contractAddress,c]);async function W(){p(null);const d=Number(n);if(!Number.isInteger(d)||d<=0){p(a("primaryList.errorWholeNumber"));return}N(!0);try{h||(o(a("primaryList.statusEnabling")),await V({signer:r.signer,contractAddress:e.contractAddress,chainId:c}),v(!0)),o(a("primaryList.statusPublishing"));const b=await Y({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:F.Network.MATIC,chainId:c},usdPrice:d/10,uses:e.remainingSupply,expiresAtMs:Date.now()+le});o(a("primaryList.statusFinishing")),await $(b,r.identity),o(null),L(d),C("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:d,price_usd:d/10,listing_type:"primary",is_primary:!0}),E.success(a("primaryList.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["publishable-items"]}),l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){T(b,{flow:"list_primary"}),C("Shop Listing Failed",{listing_type:"primary",error_code:O(b)}),p(U(b,a("primaryList.errorGeneric"))),o(null)}finally{N(!1)}}function D(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const G=m?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return k!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("primaryList.successTitle")}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("primaryList.listedFor")," ",s.jsxs("strong",{children:[s.jsx(P,{className:"ccy-mark"})," ",k]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:D,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("primaryList.publishTitle",{name:e.name})}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"muted small",children:a("primaryList.fromCollection",{collectionName:e.collectionName,count:e.remainingSupply})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("primaryList.priceLabel",{currency:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:d=>x(d.target.value),disabled:m})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),h===!1&&!m?g?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeConfirm",{collectionName:e.collectionName})}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeManaged",{collectionName:e.collectionName})}):h===!0&&!m?g?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyConfirm")}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyManaged")}):null,y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(q,{message:_}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:m,children:a("primaryList.cancel")}),s.jsx(f,{onClick:()=>void W(),disabled:m||h===null,children:h===null?a("primaryList.checking"):G})]})]})})}export{fe as P,ge as S,ye as f};
|
|
1
|
+
import{g as w,a2 as K,m as M,t as a,C as P,B as f,h as j,p as E,v as C,E as $,z as T,w as O}from"./index-B4D19REm.js";import{d as F}from"./dcl-schemas-BICTSpB5.js";import{u as R,r as u,j as s}from"./react-C51i12iP.js";import{a as H,b as X,i as z,e as J,c as V}from"./trade-encoding-D5hlkp_r.js";import{f as U}from"./errors-VkIbnyNm.js";import{E as q}from"./ErrorNotice-C7soUjRV.js";import{s as Y}from"./wallet-kind-B9P1TeIH.js";const I=()=>`${w.builderServerUrl}/v1`;function B(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function Q(e,r){const t=await K(e,{method:"GET",identity:r,metadata:{}});if(!t.ok)throw new Error(`builder-server ${t.status}: ${await t.text()}`);const l=await t.json();return l.data??l}function Z(e,r){const t=r-e;return t>0?t:0}function ee(e){var r,t,l,i,n;return((t=(r=e.data)==null?void 0:r.wearable)==null?void 0:t.category)??((i=(l=e.data)==null?void 0:l.emote)==null?void 0:i.category)??((n=e.data)==null?void 0:n.category)??e.type??"wearable"}function A(e){return`${I()}/storage/contents/${e}`}function S(e,r){if(!e)return"";if(/^https?:\/\//.test(e))return e;const t=r==null?void 0:r[e];return t?A(t):/^(ba|Qm)/.test(e)?A(e):""}async function se(e,r){try{const t=await fetch(`${I()}/items/${e}/${r}/contents`);if(!t.ok)return{};const l=await t.json();return l.data??l}catch{return{}}}async function ae(e,r,t){const l=S(e.thumbnail,e.contents)||S("thumbnail.png",e.contents);if(l)return l;if(r&&t){const i=await se(r,t);return S(e.thumbnail,i)||S("thumbnail.png",i)||S("image.png",i)}return""}async function te(e,r){const t=`${I()}/${e.toLowerCase()}/collections?is_published=true`,l=await Q(t,r);return B(l).filter(i=>i.is_published&&!!i.contract_address).map(i=>({id:i.id,name:i.name,contractAddress:i.contract_address.toLowerCase(),isPublished:i.is_published,isApproved:i.is_approved,minters:(i.minters??[]).map(n=>n.toLowerCase())}))}async function re(e,r){const t=`${I()}/collections/${e.id}/items`,l=await Q(t,r);return(await Promise.all(B(l).map(async n=>{const _=n.rarity??"common",y=Number(n.total_supply??0)||0;let o;try{o=F.Rarity.getMaxSupply(_)}catch{o=0}const x=(n.contract_address??e.contractAddress).toLowerCase(),p=n.blockchain_item_id??"";return{id:n.id,collectionId:e.id,collectionName:e.name,contractAddress:x,blockchainItemId:p,name:n.name,category:ee(n),rarity:_,thumbnail:await ae(n,x,p),type:n.type??"wearable",isPublished:n.is_published??e.isPublished,isApproved:n.is_approved??e.isApproved,totalSupply:y,maxSupply:o,remainingSupply:Z(y,o),minters:e.minters}}))).filter(ie)}function ie(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function ye(e,r){const t=await te(e,r);return(await Promise.all(t.map(async i=>{try{return await re(i,r)}catch{return[]}}))).flat()}const ne=1e3*60*60*24*182;function ge({asset:e,session:r,onClose:t}){const l=M(),i=R(),[n,_]=u.useState("10"),[y,o]=u.useState(null),[x,p]=u.useState(null),[m,N]=u.useState(!1),[h,v]=u.useState(null);async function k(){p(null);const c=Number(n);if(!Number.isInteger(c)||c<=0){p(a("sellModal.errorWholeNumber"));return}N(!0);try{o(a("sellModal.statusPreparing")),await H({signer:r.signer,contractAddress:e.contractAddress,chainId:e.chainId}),o(a("sellModal.statusListing"));const g=await X({signer:r.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:c/10,expiresAtMs:Date.now()+ne});o(a("sellModal.statusPublishing")),await E(g,r.identity),o(null),v(c),C("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:c,price_usd:c/10,listing_type:"secondary",is_primary:!1}),$.success(a("sellModal.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["my-assets",r.address]})}catch(g){T(g,{flow:"list_secondary"}),C("Shop Listing Failed",{listing_type:"secondary",error_code:O(g)}),p(U(g,a("sellModal.errorGeneric"))),o(null)}finally{N(!1)}}function L(){t(),i(`/item/${e.contractAddress}/${e.tokenId}`)}return h!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("sellModal.successTitle")}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("sellModal.listedFor")," ",s.jsxs("strong",{children:[s.jsx(P,{className:"ccy-mark"})," ",h]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:L,children:a("sellModal.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("sellModal.listTitle",{name:e.name})}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("sellModal.priceLabel",{currency:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:c=>_(c.target.value),disabled:m})]}),s.jsx("p",{className:"muted small",children:a("sellModal.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(q,{message:x}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:m,children:a("sellModal.cancel")}),s.jsx(f,{onClick:()=>void k(),disabled:m,children:m?a("sellModal.listing"):a("sellModal.putOnSale")})]})]})})}const le=1e3*60*60*24*182;function fe({item:e,session:r,onClose:t}){const l=M(),i=R(),[n,_]=u.useState("10"),[y,o]=u.useState(null),[x,p]=u.useState(null),[m,N]=u.useState(!1),[h,v]=u.useState(null),[k,L]=u.useState(null),c=w.chainId,g=Y(r.providerType);u.useEffect(()=>{let d=!1;return(async()=>{try{const b=await z({contractAddress:e.contractAddress,chainId:c});d||v(b)}catch{d||v(!1)}})(),()=>{d=!0}},[e.contractAddress,c]);async function W(){p(null);const d=Number(n);if(!Number.isInteger(d)||d<=0){p(a("primaryList.errorWholeNumber"));return}N(!0);try{h||(o(a("primaryList.statusEnabling")),await J({signer:r.signer,contractAddress:e.contractAddress,chainId:c}),v(!0)),o(a("primaryList.statusPublishing"));const b=await V({signer:r.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:F.Network.MATIC,chainId:c},usdPrice:d/10,uses:e.remainingSupply,expiresAtMs:Date.now()+le});o(a("primaryList.statusFinishing")),await E(b,r.identity),o(null),L(d),C("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:d,price_usd:d/10,listing_type:"primary",is_primary:!0}),$.success(a("primaryList.toastOnSale",{name:e.name})),l.invalidateQueries({queryKey:["publishable-items"]}),l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){T(b,{flow:"list_primary"}),C("Shop Listing Failed",{listing_type:"primary",error_code:O(b)}),p(U(b,a("primaryList.errorGeneric"))),o(null)}finally{N(!1)}}function D(){t(),i(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const G=m?a("primaryList.listing"):h===!1?a("primaryList.enableAndPutOnSale"):a("primaryList.putOnSale");return k!==null?s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:a("primaryList.successTitle")}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:[a("primaryList.listedFor")," ",s.jsxs("strong",{children:[s.jsx(P,{className:"ccy-mark"})," ",k]})," ",a("primaryList.dotAvailable",{count:e.remainingSupply})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,children:a("getCredits.done")}),s.jsx(f,{variant:"purple",onClick:D,children:a("primaryList.viewInShop")})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{className:"modal","data-testid":"modal",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("h2",{className:"modal__title",children:a("primaryList.publishTitle",{name:e.name})}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"muted small",children:a("primaryList.fromCollection",{collectionName:e.collectionName,count:e.remainingSupply})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:a("primaryList.priceLabel",{currency:j.name})}),s.jsx("input",{type:"number",min:"1",step:"1",value:n,onChange:d=>_(d.target.value),disabled:m})]}),s.jsx("p",{className:"muted small",children:a("primaryList.pricedInWhole",{currency:j.name,currencySingular:j.nameSingular})}),h===!1&&!m?g?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeConfirm",{collectionName:e.collectionName})}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.firstTimeManaged",{collectionName:e.collectionName})}):h===!0&&!m?g?s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyConfirm")}):s.jsx("p",{className:"muted small primary-note",children:a("primaryList.readyManaged")}):null,y?s.jsx("p",{className:"muted",children:y}):null,s.jsx(q,{message:x}),s.jsxs("div",{className:"modal__actions",children:[s.jsx(f,{variant:"ghost",onClick:t,disabled:m,children:a("primaryList.cancel")}),s.jsx(f,{onClick:()=>void W(),disabled:m||h===null,children:h===null?a("primaryList.checking"):G})]})]})})}export{fe as P,ge as S,ye as f};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{j as s,
|
|
1
|
+
import{j as s,u as se,r as n,L as te}from"./react-C51i12iP.js";import{t as a,ag as C,s as _,S as ae,u as ie,b as re,m as ne,I as E,B as P,E as R}from"./index-B4D19REm.js";import{u as oe,d as le,t as ce,L as de,i as B,a as v,s as me}from"./useStore-DlgSV8xZ.js";import{E as M}from"./ErrorNotice-C7soUjRV.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";const ue="https://cdn.decentraland.org/@dcl/shop/0.1.0-29842599290.commit-2475f4f/assets/template-cover-1-BETekfHg.jpeg",pe="https://cdn.decentraland.org/@dcl/shop/0.1.0-29842599290.commit-2475f4f/assets/template-cover-2-Dni9s0i_.jpeg",ge=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ue,"../assets/creator-covers/template-cover-2.jpeg":pe}),f=Object.entries(ge).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>({name:i.split("/").pop(),url:d})),ve=ae`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,fe=_.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
8
8
|
justify-content: center;
|
|
@@ -16,7 +16,7 @@ import{j as s,a as se,r as n,L as te}from"./react-yytiy0wi.js";import{t as a,ah
|
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
text-align: center;
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,he=_.span`
|
|
20
20
|
flex: none;
|
|
21
21
|
border-radius: 50%;
|
|
22
22
|
border-style: solid;
|
|
@@ -46,8 +46,8 @@ import{j as s,a as se,r as n,L as te}from"./react-yytiy0wi.js";import{t as a,ah
|
|
|
46
46
|
`,xe=_.span`
|
|
47
47
|
font-size: 14px;
|
|
48
48
|
font-weight: 600;
|
|
49
|
-
`;function _e({label:i,size:d="medium",direction:b="column",className:j}){return s.jsxs(
|
|
49
|
+
`;function _e({label:i,size:d="medium",direction:b="column",className:j}){return s.jsxs(fe,{className:j,"data-testid":"spinner-box","data-direction":b,role:"status","aria-live":"polite","aria-label":i?void 0:a("spinner.loading"),children:[s.jsx(he,{"data-testid":"spinner-box-ring","data-size":d,"aria-hidden":!0}),i?s.jsx(xe,{children:i}):null]})}const be=_(P)`
|
|
50
50
|
align-self: center;
|
|
51
51
|
min-width: 200px;
|
|
52
52
|
margin-top: 8px;
|
|
53
|
-
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:
|
|
53
|
+
`,O=1e6,A={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function D(i){return`${(i/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ye(){ie({title:a("seo.storeSettings.title"),noindex:!0});const{session:i,signIn:d}=re(),b=se(),j=ne(),c=i==null?void 0:i.address,{data:S,isLoading:F}=oe(c),[r,m]=n.useState(A),[L,y]=n.useState(A),[k,p]=n.useState(),[g,$]=n.useState(!1),[o,N]=n.useState(null),[h,V]=n.useState({}),z=n.useRef(null);n.useEffect(()=>{if(S){const e=le(S);m(e),y(e),p(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[S]),n.useEffect(()=>{let e=!1;return Promise.all(f.map(async t=>[t.name,await ce(t.url)])).then(t=>{e||V(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const x=n.useMemo(()=>{const e=f.find(l=>r.coverName===`cover/${l.name}`);if(e)return e.name;const t=r.coverHash?f.find(l=>h[l.name]===r.coverHash):void 0;return t==null?void 0:t.name},[r.coverName,r.coverHash,h]);n.useEffect(()=>{o!=null&&o.hash&&f.some(e=>h[e.name]===o.hash)&&N(null)},[h,o]);const I=k!==void 0&&k>O,Y=n.useMemo(()=>de.filter(e=>!B(e,r.links[e])),[r.links]),K=I||Y.length>0,w=n.useMemo(()=>JSON.stringify(r)!==JSON.stringify(L),[r,L]),q=w&&!K&&!g;if(n.useEffect(()=>{if(!w)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[w]),!i)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx(be,{variant:"purple",onClick:d,children:a("storeSettings.signIn")})]});function G(e,t){p(void 0),m(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const J=["image/png","image/jpeg","image/webp"];function Q(e){var H;const t=(H=e.target.files)==null?void 0:H[0];if(!t||!J.includes(t.type))return;p(t.size);const l=`cover/${t.name}`,u=new FileReader;u.onload=()=>{const T=u.result;N({url:T,name:l,hash:""}),m(ee=>({...ee,cover:T,coverName:l,coverHash:""}))},u.readAsDataURL(t)}function U(){o&&(p(void 0),m(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function W(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";m(u=>({...u,links:{...u.links,[e]:l}}))}function X(e){const t=r.links[e];return e==="website"?t:t.replace(v[e],"")}async function Z(){if(!(!c||!i)){$(!0);try{await me(c,r,i.identity),y(r),p(void 0),await j.invalidateQueries({queryKey:["store",c.toLowerCase()]}),R.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{R.error(a("storeSettings.saveError"))}finally{$(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(te,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx(E,{name:"arrow-left"})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx(E,{name:"external-link"})]}):null]}),F?s.jsx(_e,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[f.map(e=>{const t=x===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"data-testid":"cover-picker-tile","data-selected":t,"aria-pressed":t,onClick:()=>G(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${x?"":" is-selected"}`,"data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!x,"aria-pressed":!x,onClick:U,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=z.current)==null?void 0:e.click()},children:[s.jsx(E,{name:"upload"}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:z,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input","data-testid":"cover-picker-input",onChange:Q})]}),I?s.jsx(M,{message:a("storeSettings.sizeError",{max:D(O),current:D(k)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:r.description,rows:4,disabled:g,onChange:e=>m(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:r.links.website,placeholder:v.website,disabled:g,onChange:e=>m(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),B("website",r.links.website)?null:s.jsx(M,{message:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:X(e),disabled:g,onChange:t=>W(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx(P,{variant:"purple",className:"store-settings__save","data-testid":"store-settings-save",onClick:()=>void Z(),disabled:!q,children:g?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ye as StoreSettings,ye as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,a as W,u as M,N as L,r as T}from"./react-C51i12iP.js";import{s as h,ag as N,S,t as s,b as V,ah as z,u as U,ai as X,aj as D,ak as G,al as H,am as J,an as E,g as v,B as K,ao as Y}from"./index-B4D19REm.js";import{d as j}from"./dcl-schemas-BICTSpB5.js";import{s as q}from"./wallet-kind-B9P1TeIH.js";import{w as Q,S as Z}from"./buy-gasless-Ba7WiBbA.js";import"./sentry-DKBoGDXH.js";import"./ethers-BeFqf2KO.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-D5hlkp_r.js";import"./index-HN6Rk25C.js";const C="#2bb673",F=S`
|
|
2
2
|
to {
|
|
3
3
|
stroke-dashoffset: 0;
|
|
4
4
|
}
|
|
@@ -95,4 +95,4 @@ import{j as e,b as W,a as M,N as L,r as T}from"./react-yytiy0wi.js";import{s as
|
|
|
95
95
|
`;function ne(){return e.jsxs(te,{role:"img","aria-label":s("successAnimation.label"),"data-testid":"success-anim",children:[e.jsxs(ae,{viewBox:"0 0 120 120",children:[e.jsx(ce,{cx:"60",cy:"60",r:"54"}),e.jsx(re,{d:"M37 61 l16 16 l30 -34"})]}),e.jsx(_,{"data-spark":"1","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"2","aria-hidden":!0,children:"✦"}),e.jsx(_,{"data-spark":"3","aria-hidden":!0,children:"◈"}),e.jsx(_,{"data-spark":"4","aria-hidden":!0,children:"✦"})]})}const f=h(K)`
|
|
96
96
|
min-width: 160px;
|
|
97
97
|
text-align: center;
|
|
98
|
-
`,ie=c=>new Promise(t=>setTimeout(t,c));function oe(c,t){const[a,l]=T.useState(c?"pending":"confirmed"),u=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return T.useEffect(()=>{if(!c)return;let i=!1;return(async()=>{let x=!1;for(let n=0;n<20&&!i;n++)try{await Q(c,{timeoutMs:15e3}),x=!0;break}catch(r){if(r instanceof Z)continue;i||l("failed");return}if(!i){if(!x){l("timed-out");return}if(!t){l("confirmed");return}l("indexing");for(let n=0;n<40&&!i;n++){if(await Y(t.owner,t.contractAddress,t.itemId)){i||l("confirmed");return}await ie(3e3)}i||l("timed-out")}})(),()=>{i=!0}},[c,u]),a}const de=v.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",k=v.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function ke(){const{state:c}=W(),t=M(),{session:a}=
|
|
98
|
+
`,ie=c=>new Promise(t=>setTimeout(t,c));function oe(c,t){const[a,l]=T.useState(c?"pending":"confirmed"),u=t?`${t.owner}-${t.contractAddress}-${t.itemId}`:"";return T.useEffect(()=>{if(!c)return;let i=!1;return(async()=>{let x=!1;for(let n=0;n<20&&!i;n++)try{await Q(c,{timeoutMs:15e3}),x=!0;break}catch(r){if(r instanceof Z)continue;i||l("failed");return}if(!i){if(!x){l("timed-out");return}if(!t){l("confirmed");return}l("indexing");for(let n=0;n<40&&!i;n++){if(await Y(t.owner,t.contractAddress,t.itemId)){i||l("confirmed");return}await ie(3e3)}i||l("timed-out")}})(),()=>{i=!0}},[c,u]),a}const de=v.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",k=v.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function ke(){const{state:c}=W(),t=M(),{session:a}=V(),{data:l}=z(a==null?void 0:a.address),u=c==null?void 0:c.txHash,i=(c==null?void 0:c.items)??[],d=i[0],x=a!=null&&a.address&&(d!=null&&d.contractAddress)&&(d!=null&&d.itemId)?{owner:a.address,contractAddress:d.contractAddress,itemId:d.itemId}:null,n=oe(u,x);U({title:s("seo.success.title"),noindex:!0});const r=i;if(r.length===0)return e.jsx(L,{to:"/assets",replace:!0});const p=r[0],b=r.filter(o=>o.category!=="emote"),B=r.find(o=>o.category==="emote")??null,A=b.map(X).filter(o=>!!o),y=D(l),R=!!y&&b.every(o=>G(o,y)),O=H(b)??y??J,I=!!(a!=null&&a.address)&&R,$=I?a.address:"default",P=I?void 0:O,m=B??p,w=m.category==="emote",g=!!u&&q(a==null?void 0:a.providerType);return e.jsxs("div",{className:"success",children:[e.jsx("div",{className:"success__preview",children:A.length>0?e.jsx(E,{profile:$,bodyShape:P,urns:A,type:j.PreviewType.AVATAR,emote:j.PreviewEmote.FASHION,background:"ecebed",dev:v.chainId===80002},p.id):e.jsx(E,{contractAddress:m.contractAddress,tokenId:m.tokenId??void 0,itemId:m.tokenId?void 0:m.itemId??void 0,profile:$,bodyShape:w?void 0:P,type:w?void 0:j.PreviewType.AVATAR,emote:w?void 0:j.PreviewEmote.FASHION,background:"ecebed",dev:v.chainId===80002},m.id)}),e.jsx("div",{className:"success__panel",children:n==="pending"||n==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),e.jsx("h1",{className:"success__title",children:n==="indexing"?s("success.finalizing"):s("success.processing")}),e.jsx("p",{className:"success__sub",children:n==="indexing"?e.jsxs(e.Fragment,{children:[s("success.indexingBefore")," ",r.length===1?e.jsx("strong",{children:p.name}):s("success.itemCount",{count:r.length})," ",s("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[s("success.confirmingBefore")," ",r.length===1?e.jsx("strong",{children:p.name}):s("success.itemCount",{count:r.length})," ",s("success.confirmingAfter")]})}),g?e.jsx("div",{className:"success__links",children:e.jsx("a",{className:"success__receipt",href:`${k}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")})}):null]}):n==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:s("success.stillProcessingTitle")}),e.jsxs("p",{className:"success__sub",children:[s("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>t("/my-purchases"),children:s("nav.myPurchases")})," ",s("success.timedOutAfter")]}),e.jsx("div",{className:"success__links",children:g?e.jsx("a",{className:"success__receipt",href:`${k}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null}),e.jsxs("div",{className:"success__actions",children:[e.jsx(f,{variant:"purple",onClick:()=>t("/my-purchases"),children:s("success.viewMyPurchases")}),e.jsx(f,{variant:"ghost",onClick:()=>t("/assets"),children:s("success.keepShopping")})]})]}):n==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:s("success.failedTitle")}),e.jsx("p",{className:"success__sub",children:s("success.failedBody")}),e.jsx("div",{className:"success__links",children:g?e.jsx("a",{className:"success__receipt",href:`${k}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null}),e.jsx("div",{className:"success__actions",children:e.jsx(f,{variant:"purple",onClick:()=>t("/assets"),children:s("success.backToShop")})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{}),e.jsx("h1",{className:"success__title",children:s("success.title")}),r.length===1?e.jsxs("p",{className:"success__sub",children:[e.jsx("strong",{children:p.name})," ",s("success.heroInWardrobe")]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"success__sub",children:s("success.itemsInWardrobe",{count:r.length})}),e.jsx("ul",{className:"success__list",children:r.map(o=>e.jsx("li",{children:o.name},o.id))})]}),e.jsxs("div",{className:"success__links",children:[e.jsx("button",{className:"success__receipt",onClick:()=>t("/my-purchases"),children:s("success.viewOrder")}),g?e.jsx("a",{className:"success__receipt",href:`${k}${u}`,target:"_blank",rel:"noreferrer",children:s("success.viewTransaction")}):null]}),e.jsxs("div",{className:"success__actions",children:[e.jsx(f,{as:"a",href:de,target:"_blank",rel:"noreferrer",variant:"purple",children:s("success.useItInWorld")}),e.jsx(f,{variant:"ghost",onClick:()=>t("/assets"),children:s("success.keepShopping")})]})]})})]})}export{ke as Success,ke 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-DdXvw0GT.js";import{au as C}from"./NetworkUtil-CLSFaUe_.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-tZh6bMfi.js";import{au as C}from"./NetworkUtil-Xp0fNa8X.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|