@dcl/shop 0.7.3-31002809274.commit-68e2004 → 0.7.3-31004669641.commit-bf2b4b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_assets/Activity-BY9v5uGI.js +381 -0
- package/_assets/{AnimatedBackground-BPNjZnHs.js → AnimatedBackground-d_qXXLZ1.js} +2 -2
- package/_assets/{Assets-B9gu6JnA.js → Assets-BZE6MNTH.js} +11 -11
- package/_assets/{Assets.styles-DiCnesUC.js → Assets.styles-CnXHifI7.js} +2 -2
- package/_assets/{Authorizations-BQzDrrA_.js → Authorizations-DWPIfXPK.js} +4 -4
- package/_assets/Cart-eLOXdOz1.js +695 -0
- package/_assets/{CircularProgress-CQb8cfhx.js → CircularProgress-DTjTksS3.js} +3 -3
- package/_assets/{Collection-DvApaJVE.js → Collection-CIFeZjf3.js} +2 -2
- package/_assets/{CollectionCarousel-3Ff7fmHM.js → CollectionCarousel-DQNzqOkv.js} +55 -55
- package/_assets/{ContentClient-Bv-dXg1a.js → ContentClient-CRr9ZuRH.js} +1 -1
- package/_assets/{Creator-phXYNMmi.js → Creator-CrPYV324.js} +26 -26
- package/_assets/{DeploymentBuilder-DbR23a3M.js → DeploymentBuilder-DYNbIRzZ.js} +1 -1
- package/_assets/{ErrorNotice-Biw7jacR.js → ErrorNotice--UMHyZQ4.js} +1 -1
- package/_assets/{ExchangeController-j0EaU5ur.js → ExchangeController-Cw3I4QaN.js} +1 -1
- package/_assets/{Faq-CYehw8Xd.js → Faq-Bp-D4IrP.js} +2 -2
- package/_assets/{GetCredits-B5t5SiEY.js → GetCredits-CP5H3xk1.js} +4 -4
- package/_assets/{Grow-BbO3nPWz.js → Grow-CJ1PmyMj.js} +1 -1
- package/_assets/{HelpersUtil-Bm2I2riv.js → HelpersUtil-SHIQGznF.js} +1 -1
- package/_assets/ItemDetail-JScjMgo5.js +3516 -0
- package/_assets/LazyEmoteControls-D0uKVSFP.js +2 -0
- package/_assets/{LoadMore-DMhOO7Nq.js → LoadMore-CYbQF7Q0.js} +2 -2
- package/_assets/ManaPricingBanner.styles-7PjhHSIi.js +74 -0
- package/_assets/{MyAssets-pppiT6fl.js → MyAssets-BtVKb2bo.js} +2 -2
- package/_assets/{MyFavorites-B8NF0NVk.js → MyFavorites-BjdScB7R.js} +1 -1
- package/_assets/{NotFound-ySn_lkJ7.js → NotFound-DJy-difK.js} +4 -4
- package/_assets/{NotificationsBell-Mz-RqcfB.js → NotificationsBell-CYkkKwLS.js} +1 -1
- package/_assets/{OutfitDetail-dru3bX0e.js → OutfitDetail-Bd_MlsAu.js} +4 -4
- package/_assets/{OutfitPreview-RhS9kvYc.js → OutfitPreview-Bog0LK-T.js} +2 -2
- package/_assets/{OutfitStudio-B-MkV2Nw.js → OutfitStudio-GawF1FlF.js} +10 -10
- package/_assets/{StoreSettings-DMlPpaxq.js → StoreSettings-BuuzjCNb.js} +1 -1
- package/_assets/{Success-DGiWm-dB.js → Success-B6PVyVMT.js} +7 -7
- package/_assets/{SwapController-DC-RT5b2.js → SwapController-vRfOqnfY.js} +1 -1
- package/_assets/{Tooltip-DIS1AoSo.js → Tooltip-z-K5_r2G.js} +1 -1
- package/_assets/{TradeService-CW14jFoK.js → TradeService-DXen8uyN.js} +1 -1
- package/_assets/{W3MFrameProviderSingleton-Bn14TsAB.js → W3MFrameProviderSingleton-D0DuVK1Q.js} +3 -3
- package/_assets/{WebCryptoP256-DN6bPKJH.js → WebCryptoP256-oxgpEQ_A.js} +1 -1
- package/_assets/authorizations-jqQwcb6e.js +1 -0
- package/_assets/{basic-Db4hGFC-.js → basic-8OT967no.js} +1 -1
- package/_assets/{biconomy-yx9AAdUi.js → biconomy-C_1YJrQx.js} +1 -1
- package/_assets/{builder-Db8kqGSp.js → builder-DWtVDpBN.js} +1 -1
- package/_assets/buy-BQaJKCDU.js +1 -0
- package/_assets/buy-gasless-CZ9IMCzy.js +1 -0
- package/_assets/{categories-BMCKe30t.js → categories-gEEglioA.js} +32 -38
- package/_assets/{ccip-DSJk995u.js → ccip-SKapXXwI.js} +1 -1
- package/_assets/{ccip-kyphTkC8.js → ccip-y4ibU2Cv.js} +1 -1
- package/_assets/{collectionPage.styles-Dmgr28GG.js → collectionPage.styles-BYaw_6eJ.js} +7 -7
- package/_assets/{controller-BxSHfLz5.js → controller-DiG2j0Bj.js} +2 -2
- package/_assets/{core-FJbXZcd9.js → core-DVkS31SH.js} +4 -4
- package/_assets/{createSvgIcon-BVj0atRc.js → createSvgIcon-BUYy_aBs.js} +1 -1
- package/_assets/{custom-8lpWNVH1.js → custom-z_Yw6ggL.js} +1 -1
- package/_assets/{data-capture-ZsoqccWO.js → data-capture-DjCvuOfO.js} +1 -1
- package/_assets/{dcl-schemas-Dr9BTjb7.js → dcl-schemas-CmtP3U6y.js} +1 -1
- package/_assets/{disposePreview-8oEf57G7.js → disposePreview-B96DpOZy.js} +1 -1
- package/_assets/{email-TmqKH5rK.js → email-BaVWsYiK.js} +1 -1
- package/_assets/{embedded-wallet-D8AjSmuZ.js → embedded-wallet-C6OnTlQL.js} +1 -1
- package/_assets/{emotion-styled.browser.esm-B1CecDgm.js → emotion-styled.browser.esm-EAs3eW_Y.js} +1 -1
- package/_assets/{engine-CTKRqGmj.js → engine-CTTcDaNZ.js} +1 -1
- package/_assets/errors-DEg1qT4Y.js +1 -0
- package/_assets/{estimate-l1-fee-DpS-XaOF.js → estimate-l1-fee-AmLKK3kz.js} +1 -1
- package/_assets/{ethers-CtNGBird.js → ethers-DejfrZ8i.js} +1 -1
- package/_assets/{execute-Bz7pyjbp.js → execute-CG71Q0V6.js} +2 -2
- package/_assets/{features-W9H6sjcF.js → features-PXGl3AnM.js} +1 -1
- package/_assets/{fetchTokenMetadata-COd7SGVt.js → fetchTokenMetadata-CwMSW9Tj.js} +2 -2
- package/_assets/{field.styles-CdYHVXFs.js → field.styles-i8y02t11.js} +1 -1
- package/_assets/{get-ecosystem-wallet-info-CMuxAyIB.js → get-ecosystem-wallet-info-DtXl85OB.js} +1 -1
- package/_assets/{getBalance-DQubrLKJ.js → getBalance-CiuYRk08.js} +1 -1
- package/_assets/{getNFT-BNY2enZa.js → getNFT-BuPS2uUr.js} +1 -1
- package/_assets/{getNFT-CSRtW3h-.js → getNFT-CqiHMUz2.js} +1 -1
- package/_assets/{grid.styles-DH_ZretM.js → grid.styles-DEbulSnv.js} +1 -1
- package/_assets/{hashTypedData-Dqqcre1R.js → hashTypedData-BLt2Myt1.js} +1 -1
- package/_assets/{hashTypedData-BA0RWbmG.js → hashTypedData-DFL6TdkK.js} +1 -1
- package/_assets/{in-app-BvYCjHKb.js → in-app-sxEWWI71.js} +1 -1
- package/_assets/{in-app-wallet-calls-CxpZt-vc.js → in-app-wallet-calls-C5cCPgXV.js} +1 -1
- package/_assets/{index-BpsXe6IR.js → index-5ckQJdvo.js} +1 -1
- package/_assets/{index-C-IYvYAw.js → index-67nX322c.js} +1 -1
- package/_assets/{index-B91rfq1c.js → index-78Cn6c_7.js} +1 -1
- package/_assets/{index-Lb7odxFK.js → index-B1dodBTd.js} +1 -1
- package/_assets/{index-BDuns4Lg.js → index-B3D9_3qT.js} +1 -1
- package/_assets/{index-CuJbAAma.js → index-B7ZIe8-o.js} +1 -1
- package/_assets/index-BIZt_Cii.js +1 -0
- package/_assets/{index-CNepofQh.js → index-B_JiruyT.js} +1 -1
- package/_assets/{index-Bqt5iJBo.js → index-Bc0XpRAE.js} +1 -1
- package/_assets/{index-kUOBQ2KK.js → index-BkMwrTJ3.js} +1 -1
- package/_assets/{index-Cfy91mWw.js → index-BvRxx-Op.js} +1 -1
- package/_assets/{index-CNDHrB-N.js → index-C1zDjUql.js} +1 -1
- package/_assets/{index-qsorFlMF.js → index-C33PRPh0.js} +1 -1
- package/_assets/{index-BGOWhyHo.js → index-C3OG0-Rm.js} +3 -3
- package/_assets/{index-BiAcVSuI.js → index-C4dNaJNB.js} +1 -1
- package/_assets/{index-jjnXqv_1.js → index-C5KfCPRU.js} +1 -1
- package/_assets/{index-BjtZr1Rk.js → index-C7bppXGo.js} +1 -1
- package/_assets/{index-CkZ39O4D.js → index-C8xUshki.js} +1 -1
- package/_assets/{index-vZmAzias.js → index-CHcpd_Ml.js} +1 -1
- package/_assets/{index-C0jkYp6u.js → index-CIehX5LY.js} +1 -1
- package/_assets/{index-DtS2WMUT.js → index-CLEBFSaY.js} +1 -1
- package/_assets/{index-BmtMCuH8.js → index-CQ-nzCsh.js} +1 -1
- package/_assets/{index-Cj_FIJ6O.js → index-CW7T-svS.js} +1 -1
- package/_assets/{index-o5wXH6k1.js → index-CYXSUQre.js} +1 -1
- package/_assets/{index-DDe_P04W.js → index-CaVKZu6I.js} +1 -1
- package/_assets/index-CeopVToX.js +3504 -0
- package/_assets/{index-DsSWYz9j.js → index-ClN4jZIk.js} +1 -1
- package/_assets/{index-Wj_hpWlf.js → index-CoFiKLCF.js} +1 -1
- package/_assets/{index-Vcg4k-hF.js → index-CoPWTFH8.js} +1 -1
- package/_assets/{index-DIYqluqo.js → index-CtmC7UzU.js} +3 -3
- package/_assets/{index-CjpWKs8Q.js → index-Cv1Bu0gQ.js} +1 -1
- package/_assets/index-CvmGmJY_.js +2 -0
- package/_assets/{index-DOPim6Hs.js → index-D3pGB9SZ.js} +1 -1
- package/_assets/{index-BsEcuD0O.js → index-D93EJWs2.js} +2 -2
- package/_assets/{index-DhygeoM5.js → index-DHQ2fPeu.js} +3 -3
- package/_assets/{index-Ch2NaYC8.js → index-DN_dErJN.js} +1 -1
- package/_assets/{index-CRKbJ2OP.js → index-DQ6Egb9a.js} +1 -1
- package/_assets/{index-BJNlk-SI.js → index-DQJrunBx.js} +1 -1
- package/_assets/{index-Bl9hxKO2.js → index-DRX1VYfQ.js} +1 -1
- package/_assets/{index-Cr_vaK1b.js → index-DdKN54Dm.js} +1 -1
- package/_assets/{index-l92NuJVf.js → index-Dfv984cL.js} +1 -1
- package/_assets/{index-DBwuf2dy.js → index-Dqs83TPk.js} +1 -1
- package/_assets/{index-DLrjz4Tx.js → index-DsTxG252.js} +1 -1
- package/_assets/{index-WguW8tuP.js → index-DurGhmUt.js} +1 -1
- package/_assets/{index-CtwVaZjN.js → index-DvlueLuH.js} +1 -1
- package/_assets/{index-BfAg05xe.js → index-FAGRZO5x.js} +1 -1
- package/_assets/{index-CN8Fwkg_.js → index-FjcfjJmU.js} +2 -2
- package/_assets/{index-DG6oakSS.js → index-G6kG-9qx.js} +1 -1
- package/_assets/{index-DFAt726n.js → index-JjDJFXBe.js} +1 -1
- package/_assets/{index-DFCfS17C.js → index-K5Fr8OrY.js} +1 -1
- package/_assets/{index-DYoWqsAK.js → index-SVsxH_b4.js} +1 -1
- package/_assets/{index-DBGfpyip.js → index-dFGs7ucu.js} +1 -1
- package/_assets/{index-CefOdSuo.js → index-kQ-ETH4W.js} +1 -1
- package/_assets/{index-CxlN6NCL.js → index-miZ-bpMn.js} +7 -7
- package/_assets/{index-BogeqjBp.js → index-tAv2AuqO.js} +1 -1
- package/_assets/{index-DZOsxVd8.js → index-v6z9lSk-.js} +1 -1
- package/_assets/{index-CTvMZ0av.js → index-vW-YvhXV.js} +1 -1
- package/_assets/{index-Bw6vREOp.js → index-yniyfO-A.js} +2 -2
- package/_assets/{index.es-Db0bppXh.js → index.es-B_R9O1eE.js} +4 -4
- package/_assets/{index.es-DRPff5jo.js → index.es-CnlQU9TO.js} +1 -1
- package/_assets/{index.es-vm3av0ZU.js → index.es-nH3kt9zb.js} +1 -1
- package/_assets/{localBatchGatewayRequest-BT4bgYX3.js → localBatchGatewayRequest-CRA7Ohwq.js} +1 -1
- package/_assets/{networks-BjCyq87b.js → networks-BPbRQuXJ.js} +1 -1
- package/_assets/{onramp-MxLeUwo5.js → onramp-DAURmNvI.js} +1 -1
- package/_assets/{openzeppelin-NiqHvD0o.js → openzeppelin-RAIrBNFG.js} +1 -1
- package/_assets/{parseNft-DXKUZt78.js → parseNft-C8cGcKny.js} +2 -2
- package/_assets/{parseSignature-CHSFJk_c.js → parseSignature-Cosz4bIV.js} +1 -1
- package/_assets/{parseSignature-JjWPQjiQ.js → parseSignature-DI4-gGRK.js} +3 -3
- package/_assets/{passkeys-Dp5NPgWw.js → passkeys-Dx5zNag-.js} +1 -1
- package/_assets/{pay-with-exchange-CxuzzGwq.js → pay-with-exchange-DL_Cj2vD.js} +1 -1
- package/_assets/{qr-overlay-C29AmkL1.js → qr-overlay-D-IY5b74.js} +1 -1
- package/_assets/{receive-BSxHY6Lk.js → receive-BK0cXamC.js} +1 -1
- package/_assets/{resolveImplementation-DBwFo6J8.js → resolveImplementation-DtBE8M6b.js} +1 -1
- package/_assets/{rpc-B7hkwqRp.js → rpc-DvdjRONR.js} +1 -1
- package/_assets/{secp256k1-80kUQxfu.js → secp256k1-BGblV5cK.js} +1 -1
- package/_assets/{secp256k1-dBN4ORWU.js → secp256k1-DqooDfDM.js} +1 -1
- package/_assets/{secp256k1-BmlNWGtD.js → secp256k1-Jn3F0n__.js} +1 -1
- package/_assets/{send-C63T079L.js → send-DsSxPyoB.js} +1 -1
- package/_assets/{send-batch-transaction-BkwLmlea.js → send-batch-transaction-CjeCT7XS.js} +1 -1
- package/_assets/{send-eip712-transaction-6nm-uQAt.js → send-eip712-transaction-CTme_bPY.js} +2 -2
- package/_assets/{send-gasless-transaction-ASekpRez.js → send-gasless-transaction-Bb4bNRR9.js} +2 -2
- package/_assets/{send-transaction-Bzhp2g8b.js → send-transaction-pABhtz56.js} +2 -2
- package/_assets/{sendMetaTransaction-BATUzHIf.js → sendMetaTransaction-H67kFub1.js} +1 -1
- package/_assets/{sendRawTransaction-_Kv849f3.js → sendRawTransaction-B79pWyP7.js} +3 -3
- package/_assets/{serializeTransaction-ZzhlS1TB.js → serializeTransaction-48HG-PU6.js} +1 -1
- package/_assets/{session-proposal-DzR3pRyS.js → session-proposal-BcsaTK8S.js} +1 -1
- package/_assets/{session-request-VXo9pQwV.js → session-request-CeeAG1yH.js} +2 -2
- package/_assets/{signing-CGrYz3PN.js → signing-BKuWdGYf.js} +3 -3
- package/_assets/{socials-B-JrWB2l.js → socials-D_UOJlsU.js} +1 -1
- package/_assets/{styled-gTPQAN-Y.js → styled-BiSZljCY.js} +2 -2
- package/_assets/{swaps-CyAk4mTe.js → swaps-Czr01d7W.js} +1 -1
- package/_assets/{thirdweb-8szcRqMp.js → thirdweb-vG4lgpUb.js} +3 -3
- package/_assets/{to-serializable-transaction-CF8YxIRs.js → to-serializable-transaction-wl_9nUoT.js} +2 -2
- package/_assets/{transactionReceipt-CGVPV54W.js → transactionReceipt-CcSJiG0c.js} +1 -1
- package/_assets/{transactions-BIRi6SwZ.js → transactions-Ddia0n7n.js} +1 -1
- package/_assets/{useCreditPacks-B-X7zfCn.js → useCreditPacks-MqR7c3SM.js} +1 -1
- package/_assets/useImportable-NxQmNfsn.js +1 -0
- package/_assets/{useInfiniteGrid-6IGMMT5_.js → useInfiniteGrid-Kcee13Mj.js} +1 -1
- package/_assets/{useTheme-BwoD3vEY.js → useTheme-B7WRHLy8.js} +1 -1
- package/_assets/{verifyHash-C5CdkBh3.js → verifyHash-DyarspWE.js} +1 -1
- package/_assets/{w3m-modal-B3GHykWz.js → w3m-modal-DF93OTvH.js} +1 -1
- package/_assets/{w3m-modal-B3F6Mnna.js → w3m-modal-DKYntPky.js} +1 -1
- package/_assets/{wait-for-tx-receipt-C_FjDUYj.js → wait-for-tx-receipt-DR-RY-a_.js} +1 -1
- package/_assets/{wallets-DzQ1vri5.js → wallets-C9IItlAk.js} +5 -5
- package/_assets/{web-connector-B4iFaMmt.js → web-connector-BuJ7c2wG.js} +3 -3
- package/_assets/{writeContract-DaZaDo8I.js → writeContract-Buu3J9V_.js} +1 -1
- package/_assets/{zoraTestnet-W4T_ajaY.js → zoraTestnet-jeCAG28W.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/_assets/Activity-DRU10G0s.js +0 -381
- package/_assets/Cart-BHkq2PkV.js +0 -695
- package/_assets/ItemDetail-D-C6pe19.js +0 -3497
- package/_assets/LazyEmoteControls-BxXOD9g-.js +0 -2
- package/_assets/ManaPricingBanner.styles-D0ksfubq.js +0 -74
- package/_assets/authorizations-BJlchz9P.js +0 -1
- package/_assets/buy-DHqPe2Je.js +0 -1
- package/_assets/buy-gasless-CvTXQoUY.js +0 -1
- package/_assets/errors-CCUK8cBW.js +0 -1
- package/_assets/index-4grC8vnQ.js +0 -3386
- package/_assets/index-DAPvhTCu.js +0 -1
- package/_assets/index-DBkJBt2j.js +0 -2
- package/_assets/trade-encoding-dpFoczNW.js +0 -1
- package/_assets/useImportable-C11MUaBr.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as k,u as te,j as e,r as p}from"./react-DehiWSvs.js";import{s as t,I as j,t as ie,
|
|
1
|
+
import{L as k,u as te,j as e,r as p}from"./react-DehiWSvs.js";import{s as t,I as j,t as ie,F as se,G as ae,H as ne,B as w,J as oe,k as R,K as re,n as le,q as de,b as a,L as B,M as F,N as ce,O as pe,P as he,Q as me,R as ue,S as xe,U as ge,V as fe,W as be,X as ye,Y as ve,Z as je,$ as we,a0 as ke,a1 as Ie,a2 as $e,w as E,a3 as Ce,a4 as Ee,a5 as ze,a6 as Le,a7 as Oe,a8 as Se}from"./index-CeopVToX.js";import{E as _}from"./ErrorNotice--UMHyZQ4.js";import{E as Ae}from"./LazyEmoteControls-D0uKVSFP.js";import{O as Fe}from"./OutfitPreview-Bog0LK-T.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-CmtP3U6y.js";import"./ethers-DejfrZ8i.js";import"./intl-CBcMB1D2.js";import"./disposePreview-B96DpOZy.js";const{colors:o,radius:Ne,media:d}=ie,H=t.div`
|
|
2
2
|
max-width: 1721px;
|
|
3
3
|
margin: 0 auto;
|
|
4
4
|
`,Te=t.nav`
|
|
@@ -8,7 +8,7 @@ import{L as k,u as te,j as e,r as p}from"./react-DehiWSvs.js";import{s as t,I as
|
|
|
8
8
|
font-size: 13px;
|
|
9
9
|
color: ${o.muted};
|
|
10
10
|
margin-bottom: 18px;
|
|
11
|
-
`,
|
|
11
|
+
`,N=t(k)`
|
|
12
12
|
color: ${o.muted};
|
|
13
13
|
|
|
14
14
|
&:hover {
|
|
@@ -231,7 +231,7 @@ import{L as k,u as te,j as e,r as p}from"./react-DehiWSvs.js";import{s as t,I as
|
|
|
231
231
|
font-size: 12px;
|
|
232
232
|
font-weight: 400;
|
|
233
233
|
padding: 2px 8px;
|
|
234
|
-
border-radius: ${
|
|
234
|
+
border-radius: ${Ne.chip};
|
|
235
235
|
background: ${o.chip};
|
|
236
236
|
color: ${o.text2};
|
|
237
237
|
white-space: nowrap;
|
|
@@ -331,4 +331,4 @@ import{L as k,u as te,j as e,r as p}from"./react-DehiWSvs.js";import{s as t,I as
|
|
|
331
331
|
opacity: 0.4;
|
|
332
332
|
`,nt=t.h1`
|
|
333
333
|
font-size: 24px;
|
|
334
|
-
`,M="outfit-detail-preview";function bt(){const{id:i}=te(),n=R(f=>f.session),c=re(),g=c==="creator",{data:r,isError:I,refetch:m}=le({queryKey:["outfit",i,g],enabled:
|
|
334
|
+
`,M="outfit-detail-preview";function bt(){const{id:i}=te(),n=R(f=>f.session),c=re(),g=c==="creator",{data:r,isError:I,refetch:m}=le({queryKey:["outfit",i,g],enabled:F()&&!!i,staleTime:6e4,queryFn:()=>Se(i,g&&n?n.identity:void 0)}),l=!F()||!i||r===null&&c!=="pending";return de(l?{title:a("seo.outfit.notFoundTitle"),noindex:!0}:r?{title:r.name,image:B(r.thumbnailHash)??void 0}:{}),l?e.jsxs(W,{"data-testid":"outfit-notfound",children:[e.jsx(at,{name:"cart",size:44}),e.jsx(nt,{children:a("outfits.detail.notFoundTitle")}),e.jsx("p",{className:"muted",children:a("outfits.detail.notFoundBody")}),e.jsx(w,{as:k,to:"/items",variant:"purple",children:a("notFound.cta")})]}):I?e.jsxs(W,{"data-testid":"outfit-detail-error",children:[e.jsx(_,{message:a("outfits.errors.generic")}),e.jsx(w,{variant:"purple",onClick:()=>void m(),children:a("outfits.detail.retry")})]}):r?e.jsx(rt,{outfit:r}):e.jsx(H,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(K,{children:[e.jsx(q,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(D,{children:[e.jsx("span",{className:"skeleton",style:{width:"60%",height:32},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"40%",height:16},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"100%",height:48},"aria-hidden":!0})]})]})})}function ot({item:i}){const n=Ce(i),c=Ee(i.gender);return e.jsxs(Qe,{children:[i.rarity?e.jsx(v,{"data-variant":"rarity",style:{background:Oe(i.rarity),color:Le(i.rarity)},title:ze(i.rarity),children:i.rarity}):null,i.isSmart?e.jsxs(v,{"data-variant":"smart",children:[e.jsx(j,{name:"smart",size:13}),a("assetCard.smart")]}):null,n?e.jsx(v,{"data-variant":"icon",children:e.jsx(j,{name:n})}):null,c?e.jsx(v,{"data-variant":"icon",children:e.jsx(j,{name:c})}):null]})}function rt({outfit:i}){const n=ce(i),{split:c,availableCount:g,totalCredits:r,addOutfit:I,isAdding:m}=pe(i,n),l=R(s=>{var x;return(x=s.session)==null?void 0:x.address}),f=he(s=>s.items),L=p.useMemo(()=>new Set(f.map(me)),[f]),O=B(i.thumbnailHash),S=p.useRef(null);p.useEffect(()=>{S.current!==i.id&&(S.current=i.id,ue("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const $=p.useMemo(()=>i.items.map(s=>{const x=xe(s),C=n.byKey.get(x)??null;return{key:x,item:C,state:C?ge(C,{address:l,cartKeys:L}):"missing"}}),[i,n.byKey,l,L]),{data:U,isFetched:V}=fe(l),G=!l||V,Q=!!l&&!!U,J=i.bodyShape==="female"?be:i.bodyShape==="male"?ye:void 0,u=p.useMemo(()=>$.map(s=>s.item).filter(s=>!!s),[$]),A=p.useMemo(()=>ve(u),[u]),X=p.useMemo(()=>!!je(u),[u]),Y=p.useMemo(()=>u.map(s=>we(s)??"").filter(Boolean),[u]),h=ke({address:l,tryOnUrns:A,tryOnCategories:Y}),Z=i.items.length,ee=!n.isLoading&&!n.isError,b=c.purchasable.length;return e.jsxs(H,{"data-testid":"outfit-detail",children:[e.jsxs(Te,{"aria-label":a("outfits.detail.breadcrumbAria"),children:[e.jsx(N,{to:"/overview",children:a("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(N,{to:"/overview",children:a("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Pe,{children:i.name})]}),e.jsxs(K,{children:[e.jsx(q,{"data-testid":"outfit-detail-preview",style:{background:Ie(i)},children:O&&!n.isLoading&&A.length===0?e.jsx(Me,{src:O,alt:i.name}):e.jsx(Fe,{id:M,profile:h.profile,bodyShape:h.bodyShape??(Q?void 0:J),urns:h.urns,skin:h.skin,hair:h.hair,eyes:h.eyes,enabled:G&&!h.isLoading&&!n.isLoading,controls:X?e.jsx(We,{"data-testid":"outfit-emote-controls",children:e.jsx(Ae,{wearablePreviewId:M,hideFrameInput:!0})}):null})}),e.jsxs(D,{children:[e.jsx(Re,{children:i.name}),e.jsx(Be,{"data-testid":"outfit-detail-meta",children:a("outfits.detail.itemsCount",{count:Z})}),n.isError?e.jsxs(Xe,{children:[e.jsx(_,{message:a("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(w,{variant:"outline","data-testid":"outfit-detail-retry",onClick:n.retry,children:a("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_e,{children:[e.jsx(He,{children:$.map(s=>e.jsx(Ke,{"data-testid":"outfit-detail-item","data-state":s.state,children:s.item?e.jsxs(e.Fragment,{children:[e.jsx(qe,{to:`/item/${s.item.contractAddress}/${s.item.itemId}`,state:{item:s.item},"aria-label":s.item.name}),e.jsx(De,{src:s.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(T,{children:[e.jsx(z,{children:s.item.name}),s.item.creator?e.jsx(Ve,{to:`/items/creator/${s.item.creator}`,children:e.jsx($e,{address:s.item.creator})}):null,e.jsxs(P,{children:[s.state!=="unavailable"?e.jsxs(Ge,{children:[e.jsx(E,{size:15}),s.item.priceCredits.toLocaleString()]}):null,s.state==="unavailable"?e.jsx(y,{children:a("outfits.card.unavailable")}):s.state==="own_listing"?e.jsx(y,{children:a("outfits.detail.yourListing")}):s.state==="in_cart"?e.jsx(y,{children:a("outfits.detail.inCart")}):null,e.jsx(ot,{item:s.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:n.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(T,{children:n.isLoading?e.jsx(z,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"muted",children:a("outfits.card.unavailable")}),e.jsx(P,{children:e.jsx(y,{children:a("outfits.card.unavailable")})})]})})]})},s.key))}),ee&&c.ownListing.length>0?e.jsx(Je,{className:"muted small",children:a("outfits.detail.yourListingHint")}):null]}),e.jsxs(Ye,{"data-testid":"outfit-detail-ctabar",children:[e.jsxs(Ze,{children:[e.jsx(et,{children:a("outfits.detail.totalPrice")}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(tt,{children:[e.jsx(E,{size:22}),r.toLocaleString()]})]}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(it,{variant:"purple","data-testid":"outfit-detail-cta",onClick:I,disabled:m||b===0,"aria-busy":m||void 0,children:[m?a("outfits.card.adding"):b>0?a("outfits.detail.addCount",{count:b}):g>0?a("outfits.detail.nothingToAdd"):a("outfits.card.unavailable"),!m&&b>0?e.jsxs(st,{children:[e.jsx(E,{size:16}),r.toLocaleString()]}):null]})]})]})]})]})]})}export{bt as OutfitDetail,bt as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r,j as n}from"./react-DehiWSvs.js";import{d as v}from"./dcl-schemas-
|
|
1
|
+
import{r,j as n}from"./react-DehiWSvs.js";import{d as v}from"./dcl-schemas-CmtP3U6y.js";import{s as I,P as R,c as F,a9 as O,b as S}from"./index-CeopVToX.js";import{u as B,d as W}from"./disposePreview-B96DpOZy.js";const H=I.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
inset: 0;
|
|
4
4
|
display: grid;
|
|
5
5
|
place-items: center;
|
|
6
|
-
`;function q({id:a,profile:i,bodyShape:g,urns:s,enabled:c=!0,skin:l,hair:f,eyes:d,controls:w}){const E=
|
|
6
|
+
`;function q({id:a,profile:i,bodyShape:g,urns:s,enabled:c=!0,skin:l,hair:f,eyes:d,controls:w}){const E=R(t=>t.fittingOpen),{ref:x,active:h}=B(),e=c&&s.length>0&&h&&!E,y=s.length>0?s[0].includes(":amoy:"):F.chainId===80002,[j,o]=r.useState(!1),A=s.join(",");r.useEffect(()=>{o(!1)},[A,i,l,f,d]),r.useEffect(()=>{e&&o(!1)},[e]);const[P,m]=r.useState(!1);r.useEffect(()=>{if(!e){m(!1);return}let t=0,b=0;const p=()=>{document.getElementById(a)?m(!0):b++<300&&(t=requestAnimationFrame(p))};return p(),()=>cancelAnimationFrame(t)},[e,a]);const u=r.useRef(null);return r.useEffect(()=>{if(e)return()=>{W(u.current),u.current=null}},[e]),n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:x,"data-preview-viewport":!0,"aria-hidden":!0}),e?n.jsx(O,{id:a,profile:i,bodyShape:g,urns:s,skin:l,hair:f,eyes:d,type:v.PreviewType.AVATAR,emote:v.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,onLoad:()=>{var t;o(!0),u.current=((t=document.getElementById(a))==null?void 0:t.contentWindow)??null}},i):null,P?w:null,c&&s.length===0?null:!e||!j?n.jsx(H,{"aria-busy":"true","aria-label":S("spinner.loading"),children:n.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{q as O};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";import{s as o,t as dt,I as K,
|
|
1
|
+
import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";import{s as o,t as dt,I as K,aC as Xt,b as e,w as st,B as x,ae as kt,k as V,K as Yt,q as Zt,x as Tt,n as Ct,N as te,S as N,aD as Q,aE as ee,aF as ie,aG as J,Y as se,Z as oe,W as ae,X as ne,L as It,a1 as re,aH as ot,aI as de,aJ as le,aK as ue,z as F,aL as Et,aM as Lt,aN as O,A as at,aO as nt,aP as ce,aQ as pe,aR as fe,R as me,aS as he,aT as xe,a8 as ge}from"./index-CeopVToX.js";import{E as U}from"./ErrorNotice--UMHyZQ4.js";import{L as be}from"./LoadMore-CYbQF7Q0.js";import{u as ye}from"./useInfiniteGrid-Kcee13Mj.js";import{O as je}from"./OutfitPreview-Bog0LK-T.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-CmtP3U6y.js";import"./ethers-DejfrZ8i.js";import"./intl-CBcMB1D2.js";import"./disposePreview-B96DpOZy.js";const{colors:h,radius:X,media:ve}=dt,we=o.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 12px;
|
|
@@ -47,10 +47,10 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
47
47
|
${ve.maxWidth("mobile")} {
|
|
48
48
|
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
|
|
49
49
|
}
|
|
50
|
-
`,
|
|
50
|
+
`,Te=o.span`
|
|
51
51
|
height: 190px;
|
|
52
52
|
border-radius: ${X.card};
|
|
53
|
-
`,
|
|
53
|
+
`,Ce=o.button`
|
|
54
54
|
position: relative;
|
|
55
55
|
display: flex;
|
|
56
56
|
flex-direction: column;
|
|
@@ -102,7 +102,7 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
102
102
|
color: ${h.accent};
|
|
103
103
|
background: ${h.bg};
|
|
104
104
|
border-radius: 50%;
|
|
105
|
-
`,Re=[{key:"wearable",labelKey:"categories.wearables"},{key:"emote",labelKey:"categories.emotes"}];function ze({selectedKeys:r,onPick:m,canPick:f}){const[c,y]=d.useState("wearable"),[j,b]=d.useState(""),[s,L]=d.useState("");d.useEffect(()=>{const l=setTimeout(()=>L(j.trim()),300);return()=>clearTimeout(l)},[j]);const{items:
|
|
105
|
+
`,Re=[{key:"wearable",labelKey:"categories.wearables"},{key:"emote",labelKey:"categories.emotes"}];function ze({selectedKeys:r,onPick:m,canPick:f}){const[c,y]=d.useState("wearable"),[j,b]=d.useState(""),[s,L]=d.useState("");d.useEffect(()=>{const l=setTimeout(()=>L(j.trim()),300);return()=>clearTimeout(l)},[j]);const{items:T,isLoading:C,isPlaceholderData:u,isError:S,hasNextPage:I,isFetchingNextPage:Y,fetchNextPage:$}=ye(["outfit-picker",c,s],l=>Xt({search:s||void 0,category:c,onSale:!0,listingType:"primary",first:24,skip:l,sortBy:"cheapest"})),g=e(c==="emote"?"outfits.studio.searchEmotes":"outfits.studio.searchWearables"),W=new Set,M=T.filter(l=>{if(!l.itemId)return!1;const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`;return W.has(v)?!1:(W.add(v),!0)});return t.jsxs(we,{"data-testid":"outfit-picker",children:[t.jsx(Se,{role:"group","aria-label":e("outfits.studio.pickerCategory"),"data-testid":"outfit-picker-category",children:Re.map(({key:l,labelKey:v})=>t.jsx(ke,{type:"button","data-category":l,"data-selected":c===l||void 0,"aria-pressed":c===l,onClick:()=>{y(l),b("")},children:e(v)},l))}),t.jsxs($e,{children:[t.jsx(K,{name:"search",color:dt.colors.muted}),t.jsx("input",{value:j,placeholder:g,"aria-label":g,onChange:l=>b(l.target.value),"data-testid":"outfit-picker-search"})]}),S?t.jsx("p",{className:"muted small",children:e("outfits.errors.generic")}):C||u?t.jsx(jt,{"aria-busy":"true",children:Array.from({length:8},(l,v)=>t.jsx(Te,{className:"skeleton","aria-hidden":!0},v))}):M.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noResults")}):t.jsx(jt,{children:M.map(l=>{const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`,D=r.has(v);return t.jsxs(Ce,{type:"button","data-testid":"outfit-picker-item","data-selected":D||void 0,disabled:!D&&!f(l),onClick:()=>m(l),title:l.name,children:[t.jsx(Ie,{src:l.thumbnail,alt:"",loading:"lazy"}),t.jsx(Ee,{children:l.name}),t.jsxs(Le,{children:[t.jsx(st,{size:12}),l.priceCredits.toLocaleString()]}),D?t.jsx(Ne,{name:"check-rounded",size:18}):null]},v)})}),!S&&!C&&!u?t.jsx(be,{auto:!1,hasNextPage:!!I,isFetching:Y,onLoadMore:()=>void $()}):null]})}const{colors:a,radius:w,media:B,z:Pe}=dt,Nt=o.div`
|
|
106
106
|
max-width: 1200px;
|
|
107
107
|
margin: 0 auto;
|
|
108
108
|
display: flex;
|
|
@@ -189,19 +189,19 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
189
189
|
`,Me=o.span`
|
|
190
190
|
${Ot};
|
|
191
191
|
display: inline-block;
|
|
192
|
-
`,
|
|
192
|
+
`,De=o.div`
|
|
193
193
|
flex: 1;
|
|
194
194
|
min-width: 0;
|
|
195
195
|
display: flex;
|
|
196
196
|
flex-direction: column;
|
|
197
197
|
gap: 4px;
|
|
198
|
-
`,
|
|
198
|
+
`,He=o.span`
|
|
199
199
|
font-size: 15px;
|
|
200
200
|
font-weight: 700;
|
|
201
201
|
white-space: nowrap;
|
|
202
202
|
overflow: hidden;
|
|
203
203
|
text-overflow: ellipsis;
|
|
204
|
-
`,
|
|
204
|
+
`,Ue=o.span`
|
|
205
205
|
display: inline-flex;
|
|
206
206
|
align-items: center;
|
|
207
207
|
gap: 8px;
|
|
@@ -216,7 +216,7 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
216
216
|
width: 100%;
|
|
217
217
|
justify-content: flex-end;
|
|
218
218
|
}
|
|
219
|
-
`,
|
|
219
|
+
`,We=o.button`
|
|
220
220
|
display: inline-flex;
|
|
221
221
|
align-items: center;
|
|
222
222
|
justify-content: center;
|
|
@@ -237,7 +237,7 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
237
237
|
opacity: 0.5;
|
|
238
238
|
cursor: default;
|
|
239
239
|
}
|
|
240
|
-
`,
|
|
240
|
+
`,_e=o.div`
|
|
241
241
|
position: fixed;
|
|
242
242
|
inset: 0;
|
|
243
243
|
z-index: ${Pe.overlay};
|
|
@@ -534,4 +534,4 @@ import{r as d,j as t,L as A,u as Qt,b as Jt,d as Vt}from"./react-DehiWSvs.js";im
|
|
|
534
534
|
display: flex;
|
|
535
535
|
flex-wrap: wrap;
|
|
536
536
|
gap: 10px;
|
|
537
|
-
`;function Ui(){const{id:r}=Qt(),{pathname:m}=Jt(),f=V(b=>b.session),c=V(b=>b.signIn),y=Yt();Zt({title:e("outfits.studio.title"),noindex:!0});const j=m.endsWith("/new")?"new":r?"edit":"list";return y==="pending"?t.jsx(P,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):f?y!=="creator"?t.jsxs(P,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(vt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.notAvailable")}),t.jsx(x,{as:A,to:"/overview",variant:"purple",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(ki,{}):t.jsx(Ii,{outfitId:j==="edit"?r:null},r??"new"):t.jsxs(P,{"data-testid":"outfit-studio-signin",children:[t.jsx(vt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.signInPrompt")}),t.jsx(x,{variant:"purple",onClick:()=>c(),children:e("outfits.studio.signIn")})]})}function Si({outfit:r}){const m=It(r.thumbnailHash);return m?t.jsx(Be,{style:{background:le(r)},children:t.jsx("img",{src:m,alt:"",loading:"lazy"})}):t.jsx(Me,{"aria-hidden":!0})}function ki(){const r=V(u=>u.session),m=Ct(),[f,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:s,isError:L,refetch:C}=Tt({queryKey:["outfits-all"],enabled:!!r,staleTime:3e4,queryFn:()=>xe(r.identity)});async function T(u,S){if(r){j(u.id);try{S==="delete"?(await ue(u.id,r.identity),F.success(e("outfits.studio.deleted"))):(await Et({...rt(u),published:!1},r.identity,"update"),F.success(e("outfits.studio.unpublished"))),Lt(m)}catch(I){I instanceof O||at(I,{flow:`outfit-${S}`}),F.error(e(I instanceof O?nt(I.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Nt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Rt,{children:[t.jsx(zt,{children:e("outfits.studio.myOutfits")}),t.jsx(x,{as:A,to:"/outfits/new",variant:"purple","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),s?t.jsx(wt,{"aria-busy":"true",children:Array.from({length:3},(u,S)=>t.jsx(Ae,{className:"skeleton","aria-hidden":!0},S))}):L?t.jsxs(P,{children:[t.jsx(H,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"purple",onClick:()=>void C(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx("p",{className:"muted",children:e("outfits.studio.empty")}):t.jsx(wt,{children:b.map(u=>t.jsxs(Fe,{"data-testid":"outfit-studio-row","data-published":u.published||void 0,children:[t.jsx(Si,{outfit:u}),t.jsxs(Ue,{children:[t.jsx(De,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(He,{children:[t.jsx(Pt,{"data-state":u.published?"published":"draft",children:u.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:u.items.length})]})]}),t.jsxs(Ke,{children:[u.published?t.jsx(x,{as:A,to:`/items/outfits/${u.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(x,{as:A,to:`/outfits/${u.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(_e,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:y===u.id,onClick:()=>c(u),children:t.jsx(K,{name:"trash",size:18})})]})]},u.id))}),f?t.jsxs(We,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ge,{onClick:()=>c(null)}),t.jsxs(qe,{children:[t.jsx(Qe,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Je,{children:[f.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===f.id,onClick:()=>void T(f,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(x,{variant:f.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:y===f.id,onClick:()=>void T(f,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(x,{variant:"ghost",onClick:()=>c(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const St=["image/png","image/jpeg","image/webp"];function Ci(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:ot.from,gradientTo:ot.to,published:!1}}function rt(r){return{id:r.id,name:r.name,thumbnailHash:r.thumbnailHash,items:r.items,bodyShape:r.bodyShape,gradientFrom:r.gradientFrom,gradientTo:r.gradientTo,published:r.published}}function Ti(r){try{const m=sessionStorage.getItem(r);return m?JSON.parse(m):null}catch{return null}}function Ii({outfitId:r}){const m=r===null,f=`outfit-draft:${r??"new"}`,c=V(i=>i.session),y=Ct(),j=Vt(),[b]=d.useState(()=>Ti(f)),[s,L]=d.useState(()=>b??(m?Ci():null)),[C,T]=d.useState(!!b),{data:u,isLoading:S,isError:I,refetch:Y}=Tt({queryKey:["outfit",r,!0],enabled:!m&&!!c,staleTime:0,queryFn:()=>ge(r,c.identity)});d.useEffect(()=>{u&&L(i=>i??rt(u))},[u]);function $(i){L(n=>n&&{...n,...i}),T(!0)}d.useEffect(()=>{if(!(!s||!C))try{sessionStorage.setItem(f,JSON.stringify(s))}catch{}},[s,C,f]),d.useEffect(()=>{if(!C)return;const i=n=>n.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[C]),d.useEffect(()=>()=>sessionStorage.removeItem(f),[f]);const g=te(s??void 0),_=d.useMemo(()=>new Set(((s==null?void 0:s.items)??[]).map(N)),[s]),M=i=>he((s==null?void 0:s.items)??[],i,g.byKey),l=i=>!!i.itemId&&M(i).length<=J;function v(i){!s||!l(i)||$({items:M(i)})}const[U,lt]=d.useState(null),E=d.useRef(null),Z=d.useRef(!0);d.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const[W,ut]=d.useState(!1),[Ft,G]=d.useState(null),[tt,ct]=d.useState(""),[Bt,pt]=d.useState(null),[k,Mt]=d.useState();d.useEffect(()=>()=>{E.current&&URL.revokeObjectURL(E.current)},[]);function ft(){const i=fe(tt);if(!i){pt(e("outfits.studio.importError"));return}pt(null),ct(""),Mt(i.colors),$({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),F.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Ut(i){if(!i||!c)return;if(G(null),!St.includes(i.type)){G(e("outfits.errors.unsupportedType"));return}if(i.size>ce){G(e("outfits.errors.tooLarge"));return}E.current&&URL.revokeObjectURL(E.current);const n=URL.createObjectURL(i);E.current=n,lt(n),ut(!0);try{const p=await pe(i,c.identity);$({thumbnailHash:p})}catch(p){p instanceof O||at(p,{flow:"outfit-thumbnail"}),G(e(p instanceof O?nt(p.code):"outfits.errors.generic")),E.current&&(URL.revokeObjectURL(E.current),E.current=null),lt(null)}finally{ut(!1)}}const[D,mt]=d.useState(!1),[Dt,ht]=d.useState(null),et=!!s&&s.name.trim().length>0&&s.name.length<=60,Ht=!!s&&Q(s.gradientFrom)&&Q(s.gradientTo),xt=!!s&&s.items.some(i=>{const n=g.byKey.get(N(i));return!n||ee(n)}),gt=!!s&&et&&!!s.thumbnailHash&&Ht&&xt&&s.items.length>=ie&&s.items.length<=J;async function it(i){if(!(!c||!s||D)){mt(!0),ht(null);try{const n=await Et({...s,published:i},c.identity,m?"create":"update");if(!Z.current)return;sessionStorage.removeItem(f),L(rt(n)),T(!1),Lt(y),i&&!s.published?(me("Shop Outfit Published",{outfit_id:n.id,item_count:n.items.length}),F.success(e("outfits.studio.publishedToast"))):F.success(e("outfits.studio.saved")),m&&(y.setQueryData(["outfit",n.id,!0],n),j(`/outfits/${n.id}/edit`,{replace:!0}))}catch(n){n instanceof O||at(n,{flow:"outfit-save"}),ht(e(n instanceof O?nt(n.code):"outfits.errors.generic"))}finally{mt(!1)}}}const q=d.useMemo(()=>((s==null?void 0:s.items)??[]).map(i=>g.byKey.get(N(i))).filter(i=>!!i),[s,g.byKey]),bt=d.useMemo(()=>se(q),[q]),Kt=d.useMemo(()=>{const i=oe(q);return i!=null&&i.itemId?N({contractAddress:i.contractAddress,itemId:i.itemId}):null},[q]),_t=(s==null?void 0:s.bodyShape)==="female"?ae:(s==null?void 0:s.bodyShape)==="male"?ne:void 0;if(!c)return null;if(!s)return I?t.jsxs(P,{children:[t.jsx(H,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"purple",onClick:()=>void Y(),children:e("outfits.detail.retry")})]}):!S&&u===null?t.jsxs(P,{"data-testid":"outfit-studio-missing",children:[t.jsx("p",{className:"muted",children:e("outfits.errors.notFound")}),t.jsx(x,{as:A,to:"/outfits/manage",variant:"purple",children:e("outfits.studio.myOutfits")})]}):t.jsx(P,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const yt=U??It(s.thumbnailHash),Wt={...s,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Gt=s.items.reduce((i,n)=>{var p;return i+(((p=g.byKey.get(N(n)))==null?void 0:p.priceCredits)??0)},0);return t.jsxs(Nt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Rt,{children:[t.jsx(Oe,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(K,{name:"arrow-left",size:18})}),t.jsx(zt,{children:m?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Pt,{"data-state":s.published?"published":"draft",children:s.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(Ve,{children:[t.jsxs(Xe,{children:[t.jsxs(Ze,{"data-testid":"outfit-studio-preview",style:{background:re(s)},children:[t.jsx(je,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:_t,urns:bt,skin:k==null?void 0:k.skin,hair:k==null?void 0:k.hair,eyes:k==null?void 0:k.eyes,enabled:!g.isLoading}),bt.length===0&&!g.isLoading?t.jsx(ti,{className:"muted",children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(ei,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(ii,{type:"button","data-selected":s.bodyShape===i||void 0,onClick:()=>$({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(oi,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(ai,{children:[t.jsx(ni,{type:"color",value:Q(s[i])?s[i]:ot.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:n=>$({[i]:n.target.value.toLowerCase()})}),t.jsxs(ri,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(di,{value:s[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!Q(s[i])||void 0,onChange:n=>{const p=n.target.value.trim().toLowerCase();$({[i]:p.startsWith("#")||p===""?p:`#${p}`})}})]})]},i))}),t.jsx("p",{className:"muted small",children:e("outfits.studio.gradientHint")})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.thumbnail")}),yt?t.jsx(si,{"data-busy":W||void 0,children:t.jsx("img",{src:yt,alt:""})}):null,t.jsxs(ui,{as:"label",variant:"outline",size:"sm","data-busy":W||void 0,children:[W?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:St.join(","),hidden:!0,disabled:W,onChange:i=>{var n;return void Ut((n=i.target.files)==null?void 0:n[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.thumbnailHint")}),t.jsx(H,{message:Ft,testId:"outfit-studio-thumb-error"})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(li,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(de,{outfit:Wt,resolution:g})})]})]}),t.jsxs(Ye,{children:[t.jsxs(R,{children:[t.jsx(z,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(ci,{children:[t.jsx($t,{id:"outfit-import",value:tt,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>ct(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ft()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:ft,disabled:tt.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.importHint")}),t.jsx(H,{message:Bt,testId:"outfit-studio-import-error"})]}),t.jsxs(R,{children:[t.jsx(z,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx($t,{id:"outfit-name",value:s.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>$({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(R,{children:[t.jsxs(z,{as:"span",children:[e("outfits.studio.items")," (",s.items.length,"/",J,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(pi,{children:s.items.map(i=>{const n=N(i),p=g.byKey.get(n);return t.jsxs(fi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(mi,{src:p.thumbnail,alt:""}):t.jsx(hi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(xi,{className:p?void 0:"muted",children:p?p.name:g.isLoading?"…":e("outfits.card.unavailable")}),n===Kt?t.jsx(gi,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(bi,{children:[t.jsx(st,{size:12}),p.priceCredits.toLocaleString()]}):null,t.jsx(vi,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>$({items:s.items.filter(qt=>N(qt)!==n)}),children:t.jsx(K,{name:"trash",size:16})})]},n)})}),s.items.length>0?t.jsxs(yi,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ji,{children:[t.jsx(st,{size:14}),Gt.toLocaleString()]})]}):null,s.items.length>=J?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(ze,{selectedKeys:_,onPick:v,canPick:l})]})]}),t.jsxs(wi,{"data-testid":"outfit-studio-savebar",children:[t.jsx(H,{message:Dt,testId:"outfit-studio-save-error"}),et?!gt&&!s.published?t.jsx("p",{className:"muted small","data-testid":"outfit-studio-publish-hint",children:!xt&&s.items.length>0?e("outfits.studio.needsWearable"):e("outfits.errors.notPublishable")}):null:t.jsx("p",{className:"muted small",children:e("outfits.studio.needName")}),t.jsxs($i,{children:[t.jsx(x,{variant:"outline","data-testid":"outfit-studio-save",disabled:D||!et,onClick:()=>void it(s.published),children:D?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),s.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-unpublish",disabled:D,onClick:()=>void it(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"purple","data-testid":"outfit-studio-publish",disabled:D||!gt,onClick:()=>void it(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ui as OutfitStudio,Ui as default};
|
|
537
|
+
`;function Di(){const{id:r}=Qt(),{pathname:m}=Jt(),f=V(b=>b.session),c=V(b=>b.signIn),y=Yt();Zt({title:e("outfits.studio.title"),noindex:!0});const j=m.endsWith("/new")?"new":r?"edit":"list";return y==="pending"?t.jsx(P,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):f?y!=="creator"?t.jsxs(P,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(vt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.notAvailable")}),t.jsx(x,{as:A,to:"/overview",variant:"purple",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(ki,{}):t.jsx(Ii,{outfitId:j==="edit"?r:null},r??"new"):t.jsxs(P,{"data-testid":"outfit-studio-signin",children:[t.jsx(vt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.signInPrompt")}),t.jsx(x,{variant:"purple",onClick:()=>c(),children:e("outfits.studio.signIn")})]})}function Si({outfit:r}){const m=It(r.thumbnailHash);return m?t.jsx(Be,{style:{background:le(r)},children:t.jsx("img",{src:m,alt:"",loading:"lazy"})}):t.jsx(Me,{"aria-hidden":!0})}function ki(){const r=V(u=>u.session),m=Tt(),[f,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:s,isError:L,refetch:T}=Ct({queryKey:["outfits-all"],enabled:!!r,staleTime:3e4,queryFn:()=>xe(r.identity)});async function C(u,S){if(r){j(u.id);try{S==="delete"?(await ue(u.id,r.identity),F.success(e("outfits.studio.deleted"))):(await Et({...rt(u),published:!1},r.identity,"update"),F.success(e("outfits.studio.unpublished"))),Lt(m)}catch(I){I instanceof O||at(I,{flow:`outfit-${S}`}),F.error(e(I instanceof O?nt(I.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Nt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Rt,{children:[t.jsx(zt,{children:e("outfits.studio.myOutfits")}),t.jsx(x,{as:A,to:"/outfits/new",variant:"purple","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),s?t.jsx(wt,{"aria-busy":"true",children:Array.from({length:3},(u,S)=>t.jsx(Ae,{className:"skeleton","aria-hidden":!0},S))}):L?t.jsxs(P,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"purple",onClick:()=>void T(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx("p",{className:"muted",children:e("outfits.studio.empty")}):t.jsx(wt,{children:b.map(u=>t.jsxs(Fe,{"data-testid":"outfit-studio-row","data-published":u.published||void 0,children:[t.jsx(Si,{outfit:u}),t.jsxs(De,{children:[t.jsx(He,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(Ue,{children:[t.jsx(Pt,{"data-state":u.published?"published":"draft",children:u.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:u.items.length})]})]}),t.jsxs(Ke,{children:[u.published?t.jsx(x,{as:A,to:`/items/outfits/${u.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(x,{as:A,to:`/outfits/${u.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(We,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:y===u.id,onClick:()=>c(u),children:t.jsx(K,{name:"trash",size:18})})]})]},u.id))}),f?t.jsxs(_e,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ge,{onClick:()=>c(null)}),t.jsxs(qe,{children:[t.jsx(Qe,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Je,{children:[f.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===f.id,onClick:()=>void C(f,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(x,{variant:f.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:y===f.id,onClick:()=>void C(f,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(x,{variant:"ghost",onClick:()=>c(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const St=["image/png","image/jpeg","image/webp"];function Ti(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:ot.from,gradientTo:ot.to,published:!1}}function rt(r){return{id:r.id,name:r.name,thumbnailHash:r.thumbnailHash,items:r.items,bodyShape:r.bodyShape,gradientFrom:r.gradientFrom,gradientTo:r.gradientTo,published:r.published}}function Ci(r){try{const m=sessionStorage.getItem(r);return m?JSON.parse(m):null}catch{return null}}function Ii({outfitId:r}){const m=r===null,f=`outfit-draft:${r??"new"}`,c=V(i=>i.session),y=Tt(),j=Vt(),[b]=d.useState(()=>Ci(f)),[s,L]=d.useState(()=>b??(m?Ti():null)),[T,C]=d.useState(!!b),{data:u,isLoading:S,isError:I,refetch:Y}=Ct({queryKey:["outfit",r,!0],enabled:!m&&!!c,staleTime:0,queryFn:()=>ge(r,c.identity)});d.useEffect(()=>{u&&L(i=>i??rt(u))},[u]);function $(i){L(n=>n&&{...n,...i}),C(!0)}d.useEffect(()=>{if(!(!s||!T))try{sessionStorage.setItem(f,JSON.stringify(s))}catch{}},[s,T,f]),d.useEffect(()=>{if(!T)return;const i=n=>n.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[T]),d.useEffect(()=>()=>sessionStorage.removeItem(f),[f]);const g=te(s??void 0),W=d.useMemo(()=>new Set(((s==null?void 0:s.items)??[]).map(N)),[s]),M=i=>he((s==null?void 0:s.items)??[],i,g.byKey),l=i=>!!i.itemId&&M(i).length<=J;function v(i){!s||!l(i)||$({items:M(i)})}const[D,lt]=d.useState(null),E=d.useRef(null),Z=d.useRef(!0);d.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const[_,ut]=d.useState(!1),[Ft,G]=d.useState(null),[tt,ct]=d.useState(""),[Bt,pt]=d.useState(null),[k,Mt]=d.useState();d.useEffect(()=>()=>{E.current&&URL.revokeObjectURL(E.current)},[]);function ft(){const i=fe(tt);if(!i){pt(e("outfits.studio.importError"));return}pt(null),ct(""),Mt(i.colors),$({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),F.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Dt(i){if(!i||!c)return;if(G(null),!St.includes(i.type)){G(e("outfits.errors.unsupportedType"));return}if(i.size>ce){G(e("outfits.errors.tooLarge"));return}E.current&&URL.revokeObjectURL(E.current);const n=URL.createObjectURL(i);E.current=n,lt(n),ut(!0);try{const p=await pe(i,c.identity);$({thumbnailHash:p})}catch(p){p instanceof O||at(p,{flow:"outfit-thumbnail"}),G(e(p instanceof O?nt(p.code):"outfits.errors.generic")),E.current&&(URL.revokeObjectURL(E.current),E.current=null),lt(null)}finally{ut(!1)}}const[H,mt]=d.useState(!1),[Ht,ht]=d.useState(null),et=!!s&&s.name.trim().length>0&&s.name.length<=60,Ut=!!s&&Q(s.gradientFrom)&&Q(s.gradientTo),xt=!!s&&s.items.some(i=>{const n=g.byKey.get(N(i));return!n||ee(n)}),gt=!!s&&et&&!!s.thumbnailHash&&Ut&&xt&&s.items.length>=ie&&s.items.length<=J;async function it(i){if(!(!c||!s||H)){mt(!0),ht(null);try{const n=await Et({...s,published:i},c.identity,m?"create":"update");if(!Z.current)return;sessionStorage.removeItem(f),L(rt(n)),C(!1),Lt(y),i&&!s.published?(me("Shop Outfit Published",{outfit_id:n.id,item_count:n.items.length}),F.success(e("outfits.studio.publishedToast"))):F.success(e("outfits.studio.saved")),m&&(y.setQueryData(["outfit",n.id,!0],n),j(`/outfits/${n.id}/edit`,{replace:!0}))}catch(n){n instanceof O||at(n,{flow:"outfit-save"}),ht(e(n instanceof O?nt(n.code):"outfits.errors.generic"))}finally{mt(!1)}}}const q=d.useMemo(()=>((s==null?void 0:s.items)??[]).map(i=>g.byKey.get(N(i))).filter(i=>!!i),[s,g.byKey]),bt=d.useMemo(()=>se(q),[q]),Kt=d.useMemo(()=>{const i=oe(q);return i!=null&&i.itemId?N({contractAddress:i.contractAddress,itemId:i.itemId}):null},[q]),Wt=(s==null?void 0:s.bodyShape)==="female"?ae:(s==null?void 0:s.bodyShape)==="male"?ne:void 0;if(!c)return null;if(!s)return I?t.jsxs(P,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"purple",onClick:()=>void Y(),children:e("outfits.detail.retry")})]}):!S&&u===null?t.jsxs(P,{"data-testid":"outfit-studio-missing",children:[t.jsx("p",{className:"muted",children:e("outfits.errors.notFound")}),t.jsx(x,{as:A,to:"/outfits/manage",variant:"purple",children:e("outfits.studio.myOutfits")})]}):t.jsx(P,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const yt=D??It(s.thumbnailHash),_t={...s,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Gt=s.items.reduce((i,n)=>{var p;return i+(((p=g.byKey.get(N(n)))==null?void 0:p.priceCredits)??0)},0);return t.jsxs(Nt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Rt,{children:[t.jsx(Oe,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(K,{name:"arrow-left",size:18})}),t.jsx(zt,{children:m?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Pt,{"data-state":s.published?"published":"draft",children:s.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(Ve,{children:[t.jsxs(Xe,{children:[t.jsxs(Ze,{"data-testid":"outfit-studio-preview",style:{background:re(s)},children:[t.jsx(je,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Wt,urns:bt,skin:k==null?void 0:k.skin,hair:k==null?void 0:k.hair,eyes:k==null?void 0:k.eyes,enabled:!g.isLoading}),bt.length===0&&!g.isLoading?t.jsx(ti,{className:"muted",children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(ei,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(ii,{type:"button","data-selected":s.bodyShape===i||void 0,onClick:()=>$({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(oi,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(ai,{children:[t.jsx(ni,{type:"color",value:Q(s[i])?s[i]:ot.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:n=>$({[i]:n.target.value.toLowerCase()})}),t.jsxs(ri,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(di,{value:s[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!Q(s[i])||void 0,onChange:n=>{const p=n.target.value.trim().toLowerCase();$({[i]:p.startsWith("#")||p===""?p:`#${p}`})}})]})]},i))}),t.jsx("p",{className:"muted small",children:e("outfits.studio.gradientHint")})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.thumbnail")}),yt?t.jsx(si,{"data-busy":_||void 0,children:t.jsx("img",{src:yt,alt:""})}):null,t.jsxs(ui,{as:"label",variant:"outline",size:"sm","data-busy":_||void 0,children:[_?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:St.join(","),hidden:!0,disabled:_,onChange:i=>{var n;return void Dt((n=i.target.files)==null?void 0:n[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.thumbnailHint")}),t.jsx(U,{message:Ft,testId:"outfit-studio-thumb-error"})]}),t.jsxs(R,{children:[t.jsx(z,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(li,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(de,{outfit:_t,resolution:g})})]})]}),t.jsxs(Ye,{children:[t.jsxs(R,{children:[t.jsx(z,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(ci,{children:[t.jsx($t,{id:"outfit-import",value:tt,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>ct(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ft()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:ft,disabled:tt.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.importHint")}),t.jsx(U,{message:Bt,testId:"outfit-studio-import-error"})]}),t.jsxs(R,{children:[t.jsx(z,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx($t,{id:"outfit-name",value:s.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>$({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(R,{children:[t.jsxs(z,{as:"span",children:[e("outfits.studio.items")," (",s.items.length,"/",J,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(pi,{children:s.items.map(i=>{const n=N(i),p=g.byKey.get(n);return t.jsxs(fi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(mi,{src:p.thumbnail,alt:""}):t.jsx(hi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(xi,{className:p?void 0:"muted",children:p?p.name:g.isLoading?"…":e("outfits.card.unavailable")}),n===Kt?t.jsx(gi,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(bi,{children:[t.jsx(st,{size:12}),p.priceCredits.toLocaleString()]}):null,t.jsx(vi,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>$({items:s.items.filter(qt=>N(qt)!==n)}),children:t.jsx(K,{name:"trash",size:16})})]},n)})}),s.items.length>0?t.jsxs(yi,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ji,{children:[t.jsx(st,{size:14}),Gt.toLocaleString()]})]}):null,s.items.length>=J?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(ze,{selectedKeys:W,onPick:v,canPick:l})]})]}),t.jsxs(wi,{"data-testid":"outfit-studio-savebar",children:[t.jsx(U,{message:Ht,testId:"outfit-studio-save-error"}),et?!gt&&!s.published?t.jsx("p",{className:"muted small","data-testid":"outfit-studio-publish-hint",children:!xt&&s.items.length>0?e("outfits.studio.needsWearable"):e("outfits.errors.notPublishable")}):null:t.jsx("p",{className:"muted small",children:e("outfits.studio.needName")}),t.jsxs($i,{children:[t.jsx(x,{variant:"outline","data-testid":"outfit-studio-save",disabled:H||!et,onClick:()=>void it(s.published),children:H?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),s.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-unpublish",disabled:H,onClick:()=>void it(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"purple","data-testid":"outfit-studio-publish",disabled:H||!gt,onClick:()=>void it(!0),children:e("outfits.studio.publish")})]})]})]})}export{Di as OutfitStudio,Di as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{
|
|
1
|
+
import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t as j,s as a,o as ce,B as q,q as de,k as pe,x as ue,bo as ge,bt as me,bu as xe,bv as he,bw as F,I as N,bx as f,by as fe,z as A}from"./index-CeopVToX.js";import{E as M}from"./ErrorNotice--UMHyZQ4.js";import{F as w}from"./field.styles-i8y02t11.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-CmtP3U6y.js";import"./ethers-DejfrZ8i.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/0.7.3-31004669641.commit-bf2b4b9/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.7.3-31004669641.commit-bf2b4b9/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),je=ce`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/index.es-DQ3AciL_.js","_assets/react-DehiWSvs.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,w as
|
|
2
|
+
import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,w as B,az as O,ae as W,k as D,q,b as n,v as U,C as V,aA as H,c as _,B as J,aB as X}from"./index-CeopVToX.js";import{w as G,S as K}from"./buy-gasless-CZ9IMCzy.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-CmtP3U6y.js";import"./ethers-DejfrZ8i.js";import"./intl-CBcMB1D2.js";import"./authorizations-jqQwcb6e.js";import"./sendMetaTransaction-H67kFub1.js";import"./buy-BQaJKCDU.js";const Q=t.div`
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
5
5
|
/**
|
|
@@ -43,7 +43,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
43
43
|
font-size: 18px;
|
|
44
44
|
color: #4b4b57;
|
|
45
45
|
margin: 0 0 22px;
|
|
46
|
-
`,
|
|
46
|
+
`,b=t.div`
|
|
47
47
|
display: flex;
|
|
48
48
|
gap: 18px;
|
|
49
49
|
justify-content: center;
|
|
@@ -121,7 +121,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
121
121
|
border-radius: ${m.btn};
|
|
122
122
|
background: #f4e9ff;
|
|
123
123
|
color: ${s.text};
|
|
124
|
-
`,xe=t(
|
|
124
|
+
`,xe=t(B)`
|
|
125
125
|
width: 30px;
|
|
126
126
|
height: 30px;
|
|
127
127
|
color: ${s.text};
|
|
@@ -196,7 +196,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
196
196
|
${j} {
|
|
197
197
|
font-size: 16px;
|
|
198
198
|
}
|
|
199
|
-
`,
|
|
199
|
+
`,be=t.span`
|
|
200
200
|
margin-left: 8px;
|
|
201
201
|
font-weight: 600;
|
|
202
202
|
font-size: 13px;
|
|
@@ -210,7 +210,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
210
210
|
& [data-avatar] {
|
|
211
211
|
display: none;
|
|
212
212
|
}
|
|
213
|
-
`,
|
|
213
|
+
`,ye=t.div`
|
|
214
214
|
flex-shrink: 0;
|
|
215
215
|
display: flex;
|
|
216
216
|
align-items: center;
|
|
@@ -224,7 +224,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
224
224
|
${j} {
|
|
225
225
|
font-size: 18px;
|
|
226
226
|
}
|
|
227
|
-
`,ke=t(
|
|
227
|
+
`,ke=t(B)`
|
|
228
228
|
width: 22px;
|
|
229
229
|
height: 22px;
|
|
230
230
|
`,$e=t.div`
|
|
@@ -293,4 +293,4 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
|
|
|
293
293
|
`,R=t(J)`
|
|
294
294
|
min-width: 160px;
|
|
295
295
|
text-align: center;
|
|
296
|
-
`;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(
|
|
296
|
+
`;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(y){if(y instanceof K)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let o=0;o<40&&!l;o++){if(await X(r.owner,r.contractAddress,r.itemId)){l||a("confirmed");return}await Se(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[c,x]),i}const Le=_.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Te=_.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ue(){var S;const{state:c,search:r}=P(),i=c??Ae(),a=N(),{session:x}=D(),l=i==null?void 0:i.txHash,v=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=v[0],y=x!=null&&x.address&&(o!=null&&o.contractAddress)&&(o!=null&&o.itemId)?{owner:x.address,contractAddress:o.contractAddress,itemId:o.itemId}:null,u=Ie(i!=null&&i.settled?void 0:l,y);q({title:n("seo.success.title"),noindex:!0});const p=v;if(p.length===0)return e.jsx(M,{to:"/items",replace:!0});const A=p[0],w=(S=i==null?void 0:i.txHashes)!=null&&S.length?i.txHashes:l?[l]:[],h=w.length>0&&U(x==null?void 0:x.providerType)?w.map((d,k)=>e.jsx(ne,{href:`${Te}${d}`,target:"_blank",rel:"noreferrer",children:w.length>1?n("success.viewTransactionNumbered",{n:k+1,total:w.length}):n("success.viewTransaction")},d)):null;return u!=="confirmed"?e.jsx(L,{children:e.jsx(ee,{children:u==="pending"||u==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"spinner","aria-hidden":!0}),e.jsx(C,{children:u==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(z,{children:u==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",p.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:p.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",p.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:p.length})," ",n("success.confirmingAfter")]})}),h?e.jsx(b,{children:h}):null]}):u==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.stillProcessingTitle")}),e.jsxs(z,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),h?e.jsx(b,{children:h}):null,e.jsxs(T,{children:[e.jsx(R,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(R,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.failedTitle")}),e.jsx(z,{children:n("success.failedBody")}),h?e.jsx(b,{children:h}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(L,{children:[e.jsx(Z,{}),e.jsxs(ie,{children:[e.jsxs(se,{role:"status",children:[e.jsx(re,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(oe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(le,{"data-testid":"success-credits",children:[e.jsx(xe,{}),e.jsxs(he,{children:[e.jsx(pe,{children:n("getCredits.creditsAmount",{credits:f,currency:V.name})})," ",e.jsx(ue,{children:n("getCredits.creditsAdded")})]})]}):null,p.map((d,k)=>{const $=d.quantity??1;return e.jsxs(ae,{children:[k>0?e.jsx(de,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(ge,{children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(me,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(je,{children:[e.jsxs(we,{title:d.name,children:[d.name||n("buyModal.itemFallback"),$>1?e.jsx(be,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(ve,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(ye,{children:[e.jsx(ke,{}),e.jsx("span",{children:H(d.priceCredits*$)})]})]})]},d.id)})]}),h?e.jsx(b,{"data-receipt":!0,children:h}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-items"),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Le,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})]})}export{Ue as Success,Ue 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-Bn14TsAB.js";import{au as C}from"./NetworkUtil-EoWQDMpU.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-D0DuVK1Q.js";import{au as C}from"./NetworkUtil-EoWQDMpU.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-
|
|
1
|
+
import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-CeopVToX.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
|
|
2
2
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
3
3
|
${({block:t})=>t?"width: 100%;":""}
|
|
4
4
|
`,I=P("span",B("placement"))`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-
|
|
1
|
+
var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-DejfrZ8i.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-DehiWSvs.js";import{ch as Re,d as te,g as re}from"./index-CeopVToX.js";import{c as q,e as Ie}from"./index-CvmGmJY_.js";import{s as Pe}from"./sendMetaTransaction-H67kFub1.js";import"./sentry-973sfbO9.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function be(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await be(r);return new ue(t)}const S=new Ie.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),I=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(I.populateTransaction):I.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const b=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:b.hash}),b.hash}else{const v=await Pe(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&ⅇ(c.global===c||c.window===c||c.self===c)&&(e=c);var l,I=2147483647,T=36,v=1,b=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*b>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,P,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(P=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((I-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+b?b:m-h,!(g<A);m+=T)L=T-A,f>E(I/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-P,u,P==0),E(d/u)>I-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,P,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=I,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((I-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>I&&F("overflow"),f==a){for(x=o,R=T;P=R<=y?v:R>=y+b?b:R-y,!(x<P);R+=T)j=x-P,L=T-P,m.push(O(Y(P+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
|