@dcl/shop 0.1.0-30565861644.commit-86fa62d → 0.1.0-30631213700.commit-6a36b1d
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-YIu0M1Kf.js → Activity-9H_Nw9g2.js} +1 -1
- package/assets/{AnimatedBackground-BrxVl8X0.js → AnimatedBackground-Dl4OPt3I.js} +1 -1
- package/assets/{Assets-Dwlho6_C.js → Assets-hIVs4QX5.js} +7 -7
- package/assets/{Assets.styles-CfTWTkg9.js → Assets.styles-DxYgoIuy.js} +1 -1
- package/assets/{Authorizations-BMPo5lsC.js → Authorizations-7_r3pX8t.js} +1 -1
- package/assets/Cart-D0AduPfq.js +695 -0
- package/assets/{CircularProgress-BrgD7rFE.js → CircularProgress-4d3-DQmu.js} +1 -1
- package/assets/{Collection-wJlJYfNj.js → Collection-jJGlXbaI.js} +1 -1
- package/assets/{CollectionCarousel-Bns794gp.js → CollectionCarousel-Cf-VTi1F.js} +1 -1
- package/assets/{Creator-Bz4Ol9VJ.js → Creator-C7C3IC7M.js} +2 -2
- package/assets/{ErrorNotice-Z0D8os9s.js → ErrorNotice-B02EvdVc.js} +1 -1
- package/assets/{ExchangeController-DWJqUlaQ.js → ExchangeController-_mEAVfMP.js} +1 -1
- package/assets/{GetCredits-DaqSIDEt.js → GetCredits-DATwdND2.js} +97 -60
- package/assets/{HelpersUtil-BmEt66tk.js → HelpersUtil-B9-8MjrT.js} +1 -1
- package/assets/{ImportListings-tR_OXub1.js → ImportListings-Brvy0E2Q.js} +8 -8
- package/assets/{ItemDetail-n9hpow28.js → ItemDetail-iIR1rraN.js} +3 -3
- package/assets/{LoadMore-DI4Wyn-C.js → LoadMore-DmJy1HhZ.js} +1 -1
- package/assets/{MenuList-CYC3zRYf.js → MenuList-DaaQcK3Y.js} +1 -1
- package/assets/{MyAssets-CRBhFPGQ.js → MyAssets-BNDWBTvM.js} +1 -1
- package/assets/{MyFavorites-B6grtRZj.js → MyFavorites-DsQJRQwa.js} +1 -1
- package/assets/{NotFound-0L1xj8db.js → NotFound-DLfA3_kx.js} +1 -1
- package/assets/{NotificationsBell-B5Q9EIqa.js → NotificationsBell-BFpFtQ3R.js} +1 -1
- package/assets/{StoreSettings-CUyzwheq.js → StoreSettings-g8hG7Zop.js} +1 -1
- package/assets/Success-MIHHTcKK.js +276 -0
- package/assets/{SwapController-CP6wYtUi.js → SwapController-DR2uYAaA.js} +1 -1
- package/assets/{Tooltip-BbHzoPIy.js → Tooltip-gJZXgo0b.js} +1 -1
- package/assets/{TradeService-CbR5e6j8.js → TradeService-CY3xpaff.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-CAciSeGb.js → W3MFrameProviderSingleton-DSb_b_EZ.js} +3 -3
- package/assets/{WebCryptoP256-BJObUJ75.js → WebCryptoP256-CDxnkGVK.js} +1 -1
- package/assets/{authorizations-B6wWjXdQ.js → authorizations-BPcNtN-P.js} +1 -1
- package/assets/{basic-PrtqXBMx.js → basic-C5_ZcnK9.js} +1 -1
- package/assets/{biconomy-CXoNqd-Z.js → biconomy-CvmOdG97.js} +1 -1
- package/assets/{browseLayout.styles-B_NNL83E.js → browseLayout.styles-C9FVX_ZJ.js} +5 -5
- package/assets/{builder-DJzcrQAM.js → builder-CLIpwOL9.js} +1 -1
- package/assets/buy-B0vN0t4_.js +1 -0
- package/assets/{buy-gasless-CmOMFX1L.js → buy-gasless-DLYP_J55.js} +1 -1
- package/assets/{categories-CX6i4K78.js → categories-Ci0NfrXM.js} +1 -1
- package/assets/{ccip-Dd-dexDO.js → ccip-EF1o04u9.js} +1 -1
- package/assets/{ccip-w3FPfxqw.js → ccip-kyPwi4iD.js} +1 -1
- package/assets/{clsx-BRGjhjlu.js → clsx-CPW1aX4x.js} +2 -2
- package/assets/{controller-DwX-jKZc.js → controller-DC-xBsw3.js} +2 -2
- package/assets/{core-D2eU58P9.js → core-C7azBZfw.js} +4 -4
- package/assets/{createSvgIcon-BVcvIe2E.js → createSvgIcon-CE_QXUPt.js} +3 -3
- package/assets/{custom-C8kunAUg.js → custom-C7OSaKW8.js} +1 -1
- package/assets/{data-capture-5SXe7x0r.js → data-capture-D90UA04z.js} +1 -1
- package/assets/{email-Bn0Sv8j4.js → email-DdwMxrSu.js} +1 -1
- package/assets/{embedded-wallet-C8c_78Uv.js → embedded-wallet-CLTSxZAJ.js} +1 -1
- package/assets/{emotion-styled.browser.esm-3ejjGoWk.js → emotion-styled.browser.esm-C4PVOCRF.js} +1 -1
- package/assets/{engine-CNGw5SdF.js → engine-D-dAvXbf.js} +1 -1
- package/assets/{errors-BYKPLdNJ.js → errors-BSoF7pTC.js} +1 -1
- package/assets/{estimate-l1-fee-BrG1mArn.js → estimate-l1-fee-Cw86yh3k.js} +1 -1
- package/assets/{execute-BuBESW09.js → execute-CiNfIIwI.js} +2 -2
- package/assets/{features-DJEePSdY.js → features-CrsLW0vi.js} +1 -1
- package/assets/{fetchTokenMetadata-DbJ4fJYd.js → fetchTokenMetadata-DdYtEXX-.js} +2 -2
- package/assets/{get-ecosystem-wallet-info-BVDQHXZz.js → get-ecosystem-wallet-info-B9Lyre9K.js} +1 -1
- package/assets/{getBalance-Dwa97iHq.js → getBalance-C-EmBEJE.js} +1 -1
- package/assets/{getNFT-KnOGHpCx.js → getNFT-BQlxSGM2.js} +1 -1
- package/assets/{getNFT-8vTqe5mx.js → getNFT-ytL1936_.js} +1 -1
- package/assets/{getThemeProps-BkCaIJdf.js → getThemeProps-BGg8uFXd.js} +1 -1
- package/assets/{grid.styles-Cflo-ZKg.js → grid.styles-DMgsxY7L.js} +1 -1
- package/assets/{hashTypedData-ByA_PXdL.js → hashTypedData-BasXuEvC.js} +1 -1
- package/assets/{hashTypedData-zHAZUnlP.js → hashTypedData-j5fdDs4Y.js} +1 -1
- package/assets/{import-Da_I6gAZ.js → import-Dm0CsIi0.js} +1 -1
- package/assets/{in-app-DAfU34Xj.js → in-app-BEVydnuY.js} +1 -1
- package/assets/{in-app-wallet-calls-C8MSEj6u.js → in-app-wallet-calls-BY3W5GQ0.js} +1 -1
- package/assets/{index-Dla9ohqE.js → index-1J_FpndO.js} +2 -2
- package/assets/{index-IEBvb9g0.js → index-8VXxtKF1.js} +1 -1
- package/assets/{index-CRiWMT-r.js → index-B13XAdNZ.js} +1 -1
- package/assets/{index-Azrqm6Av.js → index-B1aFfP1l.js} +1 -1
- package/assets/{index-I6AhOucd.js → index-B3KRDhro.js} +1 -1
- package/assets/{index-vQ_2c6zv.js → index-B7JR23Ob.js} +1 -1
- package/assets/{index-Ddw9OYjW.js → index-BAljEUxu.js} +1 -1
- package/assets/{index-Q9aqPNo3.js → index-BE79xpUL.js} +1 -1
- package/assets/{index-CzKTIGRh.js → index-BFDvoquz.js} +2 -2
- package/assets/{index-DX8GIl1w.js → index-BLchEKaw.js} +2 -2
- package/assets/{index-DJk-Gyy6.js → index-BO8tonq1.js} +1 -1
- package/assets/{index-DeUn3r_V.js → index-BO95Zc7f.js} +1 -1
- package/assets/{index-DWsuciPI.js → index-BOKR1ZSE.js} +1 -1
- package/assets/{index-CkshIr8A.js → index-BRa-XcLg.js} +1 -1
- package/assets/{index-SG2QR9w5.js → index-BSBIVFxM.js} +3 -3
- package/assets/{index-Kl09Ztwk.js → index-BUmLgBCF.js} +1 -1
- package/assets/{index-DTtN3FMo.js → index-B_OIhLt0.js} +1 -1
- package/assets/{index-MmxQtN7S.js → index-Be7WGkuv.js} +1 -1
- package/assets/{index-BnWc8jyR.js → index-BgUZsiWa.js} +1 -1
- package/assets/{index-D34PBlHH.js → index-BkTT5bsx.js} +1 -1
- package/assets/{index-CkqeusMi.js → index-BwKYmXD4.js} +1 -1
- package/assets/{index-DMlJeY00.js → index-C1XoasUk.js} +1 -1
- package/assets/{index-BCGTwY9C.js → index-C9UOpi9s.js} +1 -1
- package/assets/{index-CGd-1UpW.js → index-CBgMGilO.js} +1 -1
- package/assets/{index-B6EsaBwe.js → index-CQm9diQZ.js} +1 -1
- package/assets/{index-DQwfF15K.js → index-CVglB0vh.js} +1 -1
- package/assets/{index-Dltarl5j.js → index-CYLjPyy6.js} +1 -1
- package/assets/{index-1YMH7MTk.js → index-CaRubzmQ.js} +1 -1
- package/assets/{index-DTvh0ZYF.js → index-CcaSnuYK.js} +1 -1
- package/assets/{index-MBO4iF-x.js → index-Ce4-q8Tn.js} +1 -1
- package/assets/{index-Dl_EomMH.js → index-ChgR_gSr.js} +1 -1
- package/assets/{index-DhHGVFYf.js → index-Cm1rAYH-.js} +1 -1
- package/assets/{index-BkQsw_6m.js → index-CqHixIDx.js} +1 -1
- package/assets/{index-Bvsc2jDb.js → index-CtyORnm3.js} +1 -1
- package/assets/{index-BOei64ey.js → index-D4au8-Sv.js} +1 -1
- package/assets/{index-CSAUfzci.js → index-D8fCyz4G.js} +1 -1
- package/assets/{index-CgmlJw-S.js → index-DCMoy5ft.js} +1 -1
- package/assets/{index-DiUDVsbw.js → index-DCNmX8Jr.js} +3 -3
- package/assets/{index-CkzcSx5U.js → index-DSjn_4OZ.js} +1 -1
- package/assets/{index-BzmmiLep.js → index-D_M6bHMQ.js} +1 -1
- package/assets/{index-BRBJXQFj.js → index-Df6G0l6L.js} +3 -3
- package/assets/{index-CuYL-Baw.js → index-DjDUzcsH.js} +2 -2
- package/assets/{index-BnbwrW-6.js → index-DzVTWEvS.js} +252 -252
- package/assets/{index-CVY0sxwP.js → index-I1HziGSE.js} +1 -1
- package/assets/{index-CfiHgp7t.js → index-NfzBgkBr.js} +2 -2
- package/assets/{index-BFQ3WGPq.js → index-O4GwlnrF.js} +1 -1
- package/assets/{index-BKmu2o-E.js → index-RrRV6pR_.js} +1 -1
- package/assets/{index-CvD8tr1x.js → index-S4WGeB0l.js} +1 -1
- package/assets/{index-DmUPrDg1.js → index-g7wbqJm1.js} +1 -1
- package/assets/{index-BBHWbqVq.js → index-t2owpKkf.js} +1 -1
- package/assets/{index-DHNHHzGW.js → index-uOJSYwZG.js} +1 -1
- package/assets/{index.es-Dcl8xzFM.js → index.es-B3rSZSDt.js} +4 -4
- package/assets/{index.es-1Eex98-c.js → index.es-DM2qW0lw.js} +1 -1
- package/assets/{index.es-8mJw4ztI.js → index.es-Dienktq9.js} +1 -1
- package/assets/{localBatchGatewayRequest-DLZcpxp5.js → localBatchGatewayRequest-DuHrf2MN.js} +1 -1
- package/assets/{mana-convert-Bc7WVBn5.js → mana-convert-CHkCsdrS.js} +1 -1
- package/assets/{mana-rate-CFfqtCHS.js → mana-rate-Dt1fufbZ.js} +1 -1
- package/assets/{networks-C9v8SYzv.js → networks-KCk_6KCy.js} +1 -1
- package/assets/{onramp-vHeI0Bdi.js → onramp-DIsBeuYv.js} +1 -1
- package/assets/{openzeppelin-yMR9b1FL.js → openzeppelin-DNjbwrBL.js} +1 -1
- package/assets/{parseNft-DOgBlFyM.js → parseNft-BftD-FxK.js} +2 -2
- package/assets/{parseSignature-CCtT275H.js → parseSignature-BWVrkDRs.js} +3 -3
- package/assets/{parseSignature-B_BQDXEi.js → parseSignature-znC0lvc7.js} +1 -1
- package/assets/{passkeys-DC9ui3MW.js → passkeys-BJPRW0V_.js} +1 -1
- package/assets/{pay-with-exchange-DzS3VV5h.js → pay-with-exchange-oV9YjYRd.js} +1 -1
- package/assets/{qr-overlay-DBMFsWbT.js → qr-overlay-BYTSXp-R.js} +1 -1
- package/assets/{receive-DL6eap6Y.js → receive-DWXEUP1p.js} +1 -1
- package/assets/{resolveImplementation-CbIwAEHk.js → resolveImplementation-D6NoPFBv.js} +1 -1
- package/assets/{rpc-4rFMN8E0.js → rpc-BRol_aMy.js} +1 -1
- package/assets/{secp256k1-CJEeTac_.js → secp256k1-BIRnWaVR.js} +1 -1
- package/assets/{secp256k1-7K_lKgAG.js → secp256k1-DnitHy6K.js} +1 -1
- package/assets/{secp256k1-Cc-OBcqq.js → secp256k1-xEJ152PU.js} +1 -1
- package/assets/{send-LziflfC8.js → send-IjXisfbb.js} +1 -1
- package/assets/{send-batch-transaction-cPuMc9MS.js → send-batch-transaction-DPQqc2pa.js} +1 -1
- package/assets/{send-eip712-transaction-DrVlY4sm.js → send-eip712-transaction-D0KKXrDM.js} +2 -2
- package/assets/{send-gasless-transaction-C7GQuNPZ.js → send-gasless-transaction-DEZ5jsUe.js} +2 -2
- package/assets/{send-transaction-DsHae-07.js → send-transaction-DSWW1MHr.js} +2 -2
- package/assets/{sendMetaTransaction-DVALeVb8.js → sendMetaTransaction-Ci7WU1n2.js} +1 -1
- package/assets/{sendRawTransaction-BwoXNrfy.js → sendRawTransaction-BhLbtdw6.js} +3 -3
- package/assets/{serializeTransaction-HjwgZYgE.js → serializeTransaction-BpvjoWlt.js} +1 -1
- package/assets/{session-proposal-D2B7jyYw.js → session-proposal-CySo5Ayx.js} +1 -1
- package/assets/{session-request-qG7jHYd4.js → session-request-CcKMNi2Y.js} +2 -2
- package/assets/{signing-2d-SxI7E.js → signing-1MEhDZTe.js} +3 -3
- package/assets/{socials-C5lHDsWb.js → socials-BxeqgBhJ.js} +1 -1
- package/assets/{swaps-D-FCeao1.js → swaps-gmJBWPLn.js} +1 -1
- package/assets/{thirdweb-BzCYZVQU.js → thirdweb-D1mOG5l6.js} +3 -3
- package/assets/{to-serializable-transaction-mtITaKz7.js → to-serializable-transaction-B0ueqSml.js} +2 -2
- package/assets/trade-encoding-8_nNixrP.js +1 -0
- package/assets/{transactionReceipt-C0Zt7siR.js → transactionReceipt-C4bedM4w.js} +1 -1
- package/assets/{transactions-3oKW7X2A.js → transactions-OfZRD4zD.js} +1 -1
- package/assets/useCreditPacks-By64V7Im.js +1 -0
- package/assets/{useInfiniteGrid-DxkPmxZ9.js → useInfiniteGrid-BRS4FUdG.js} +1 -1
- package/assets/useManaRate-B_yvKRm8.js +1 -0
- package/assets/{useSecondarySales-uafEfAWN.js → useSecondarySales-DvaILn1P.js} +1 -1
- package/assets/{useStore-HaFF1p2U.js → useStore-DT6_uEJ5.js} +1 -1
- package/assets/{useTheme-DVLL-c1A.js → useTheme-DxD5b5GX.js} +1 -1
- package/assets/{verifyHash-DR9pCFUe.js → verifyHash-B6ZBhWEY.js} +1 -1
- package/assets/{w3m-modal-B4U6A0YE.js → w3m-modal-BDgG1mEs.js} +1 -1
- package/assets/{w3m-modal-CaY0gxk7.js → w3m-modal-cY_JeRk0.js} +1 -1
- package/assets/{wait-for-tx-receipt-BDXxYIXq.js → wait-for-tx-receipt-BtuweTJB.js} +1 -1
- package/assets/{wallets-Y1872Ad0.js → wallets-7MiPMysL.js} +5 -5
- package/assets/{web-connector-CYEfuYp5.js → web-connector-UMu-oPn4.js} +3 -3
- package/assets/{writeContract-DrFAVNON.js → writeContract-Byuqugox.js} +1 -1
- package/assets/{zoraTestnet-CZflXjbY.js → zoraTestnet-CkN0XqkJ.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/Cart-DS3i-ZcL.js +0 -695
- package/assets/Success-DXPvtMrB.js +0 -276
- package/assets/buy-D3hY4JG8.js +0 -1
- package/assets/trade-encoding-ZhCceq00.js +0 -1
- package/assets/useCreditPacks-DTZSsQrR.js +0 -1
- package/assets/useManaRate-DJlj41tJ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,L as le,b as ce,r as l}from"./react-vyZjIDcS.js";import{t as b,s as a,e as s,x as de,B as K,m as pe,n as ue,E as ge,I as N,F as A}from"./index-
|
|
1
|
+
import{j as t,L as le,b as ce,r as l}from"./react-vyZjIDcS.js";import{t as b,s as a,e as s,x as de,B as K,m as pe,n as ue,E as ge,I as N,F as A}from"./index-DzVTWEvS.js";import{u as xe,d as me,t as he,L as fe,i as M,a as f,s as ve}from"./useStore-DT6_uEJ5.js";import{E as O}from"./ErrorNotice-B02EvdVc.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const be="https://cdn.decentraland.org/@dcl/shop/0.1.0-30631213700.commit-6a36b1d/assets/template-cover-1-BETekfHg.jpeg",we="https://cdn.decentraland.org/@dcl/shop/0.1.0-30631213700.commit-6a36b1d/assets/template-cover-2-Dni9s0i_.jpeg",je=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":be,"../assets/creator-covers/template-cover-2.jpeg":we}),v=Object.entries(je).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),{colors:L}=b,j=a.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 6px;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import{a as T,b as E,j as e,N,r as A}from"./react-vyZjIDcS.js";import{t as P,s as t,z as B,G as F,H as M,n as W,m as O,e as n,y as _,h as q,J as H,c as L,B as J,K as U}from"./index-DzVTWEvS.js";import{w as D,S as K}from"./buy-gasless-DLYP_J55.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./authorizations-BPcNtN-P.js";import"./sendMetaTransaction-Ci7WU1n2.js";import"./trade-encoding-8_nNixrP.js";const{colors:s,radius:u}=P,g="@media (max-width: 600px)",z=t.div`
|
|
2
|
+
max-width: 895px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 32px 12px;
|
|
5
|
+
min-height: 72vh;
|
|
6
|
+
`,X=t.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
align-items: center;
|
|
10
|
+
text-align: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
min-height: 60vh;
|
|
13
|
+
`,G=t.span`
|
|
14
|
+
margin: 4px auto 8px;
|
|
15
|
+
width: 40px;
|
|
16
|
+
height: 40px;
|
|
17
|
+
`,v=t.h1`
|
|
18
|
+
font-size: clamp(30px, 4vw, 42px);
|
|
19
|
+
font-weight: 800;
|
|
20
|
+
letter-spacing: -0.02em;
|
|
21
|
+
margin: 20px 0 8px;
|
|
22
|
+
`,k=t.p`
|
|
23
|
+
font-size: 18px;
|
|
24
|
+
color: #4b4b57;
|
|
25
|
+
margin: 0 0 22px;
|
|
26
|
+
`,w=t.div`
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: 18px;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
margin: 0 0 20px;
|
|
31
|
+
|
|
32
|
+
&[data-receipt] {
|
|
33
|
+
justify-content: flex-end;
|
|
34
|
+
margin: 0;
|
|
35
|
+
}
|
|
36
|
+
`,Q=t.a`
|
|
37
|
+
display: inline-block;
|
|
38
|
+
margin: 0;
|
|
39
|
+
color: ${s.accent};
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
text-decoration: none;
|
|
43
|
+
`,S=t.div`
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 12px;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
`,Y=t.div`
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: 12px;
|
|
52
|
+
width: 100%;
|
|
53
|
+
`,V=t.div`
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
gap: 16px;
|
|
58
|
+
padding: 24px 16px;
|
|
59
|
+
background: #e0f7e7;
|
|
60
|
+
border: 1px solid #34ce77;
|
|
61
|
+
border-radius: 16px;
|
|
62
|
+
`,Z=t.span`
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
width: 60px;
|
|
65
|
+
height: 60px;
|
|
66
|
+
line-height: 0;
|
|
67
|
+
`,ee=t.p`
|
|
68
|
+
flex: 1;
|
|
69
|
+
margin: 0;
|
|
70
|
+
text-align: center;
|
|
71
|
+
font-size: 20px;
|
|
72
|
+
line-height: 1.334;
|
|
73
|
+
color: ${s.text2};
|
|
74
|
+
|
|
75
|
+
& b {
|
|
76
|
+
font-weight: 700;
|
|
77
|
+
}
|
|
78
|
+
`,te=t.div`
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
padding: 24px;
|
|
82
|
+
background: ${s.white};
|
|
83
|
+
border: 1px solid ${s.gray4};
|
|
84
|
+
border-radius: 16px;
|
|
85
|
+
`,ne=t.div`
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
`,ie=t.span`
|
|
89
|
+
display: block;
|
|
90
|
+
height: 1px;
|
|
91
|
+
margin: 12px 0;
|
|
92
|
+
background: ${s.gray4};
|
|
93
|
+
`,se=t.div`
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
gap: 8px;
|
|
98
|
+
min-height: 109px;
|
|
99
|
+
margin-bottom: 12px;
|
|
100
|
+
padding: 8px 24px;
|
|
101
|
+
border-radius: ${u.btn};
|
|
102
|
+
background: #f4e9ff;
|
|
103
|
+
color: ${s.text};
|
|
104
|
+
`,re=t(B)`
|
|
105
|
+
width: 30px;
|
|
106
|
+
height: 30px;
|
|
107
|
+
color: ${s.text};
|
|
108
|
+
`,ce=t.p`
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
align-items: baseline;
|
|
111
|
+
gap: 6px;
|
|
112
|
+
margin: 0;
|
|
113
|
+
`,oe=t.span`
|
|
114
|
+
font-size: 24px;
|
|
115
|
+
font-weight: 700;
|
|
116
|
+
text-transform: capitalize;
|
|
117
|
+
`,ae=t.span`
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
font-weight: 400;
|
|
120
|
+
`,de=t.div`
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 12px;
|
|
124
|
+
`,le=t.div`
|
|
125
|
+
position: relative;
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
width: 137px;
|
|
128
|
+
height: 137px;
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
background: ${s.media};
|
|
133
|
+
border: 0.134px solid ${s.muted2};
|
|
134
|
+
border-radius: ${u.btn};
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
|
|
137
|
+
& img {
|
|
138
|
+
width: 83%;
|
|
139
|
+
height: 83%;
|
|
140
|
+
object-fit: contain;
|
|
141
|
+
filter: drop-shadow(0.56px 2.24px 2.8px rgba(0, 0, 0, 0.1));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
${g} {
|
|
145
|
+
width: 96px;
|
|
146
|
+
height: 96px;
|
|
147
|
+
}
|
|
148
|
+
`,xe=t.span`
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: 8px;
|
|
151
|
+
left: 8px;
|
|
152
|
+
width: 20px;
|
|
153
|
+
height: 20px;
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
background: ${s.dclRed};
|
|
158
|
+
border-radius: ${u.chip};
|
|
159
|
+
line-height: 0;
|
|
160
|
+
`,pe=t.div`
|
|
161
|
+
flex: 1;
|
|
162
|
+
min-width: 0;
|
|
163
|
+
display: flex;
|
|
164
|
+
flex-direction: column;
|
|
165
|
+
gap: 2px;
|
|
166
|
+
padding: 8px;
|
|
167
|
+
`,he=t.div`
|
|
168
|
+
font-weight: 600;
|
|
169
|
+
font-size: 20px;
|
|
170
|
+
line-height: 1.57;
|
|
171
|
+
color: ${s.text};
|
|
172
|
+
overflow: hidden;
|
|
173
|
+
text-overflow: ellipsis;
|
|
174
|
+
white-space: nowrap;
|
|
175
|
+
|
|
176
|
+
${g} {
|
|
177
|
+
font-size: 16px;
|
|
178
|
+
}
|
|
179
|
+
`,ue=t.span`
|
|
180
|
+
margin-left: 8px;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
font-size: 13px;
|
|
183
|
+
color: ${s.muted};
|
|
184
|
+
`,ge=t(F)`
|
|
185
|
+
position: relative;
|
|
186
|
+
z-index: 1;
|
|
187
|
+
color: ${s.muted};
|
|
188
|
+
font-size: 10px;
|
|
189
|
+
|
|
190
|
+
& [data-avatar] {
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
`,fe=t.div`
|
|
194
|
+
flex-shrink: 0;
|
|
195
|
+
display: flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
gap: 4px;
|
|
198
|
+
padding: 8px;
|
|
199
|
+
font-weight: 600;
|
|
200
|
+
font-size: 21px;
|
|
201
|
+
color: ${s.text2};
|
|
202
|
+
white-space: nowrap;
|
|
203
|
+
|
|
204
|
+
${g} {
|
|
205
|
+
font-size: 18px;
|
|
206
|
+
}
|
|
207
|
+
`,me=t(B)`
|
|
208
|
+
width: 22px;
|
|
209
|
+
height: 22px;
|
|
210
|
+
`,je=t.div`
|
|
211
|
+
display: flex;
|
|
212
|
+
gap: 12px;
|
|
213
|
+
align-items: center;
|
|
214
|
+
justify-content: flex-end;
|
|
215
|
+
|
|
216
|
+
${g} {
|
|
217
|
+
flex-direction: column-reverse;
|
|
218
|
+
}
|
|
219
|
+
`,I=M`
|
|
220
|
+
flex: 1;
|
|
221
|
+
min-width: 0;
|
|
222
|
+
height: 48px;
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
gap: 12px;
|
|
227
|
+
padding: 0 24px;
|
|
228
|
+
border-radius: ${u.btn};
|
|
229
|
+
font-weight: 600;
|
|
230
|
+
font-size: 15px;
|
|
231
|
+
letter-spacing: 0.04em;
|
|
232
|
+
text-transform: uppercase;
|
|
233
|
+
text-decoration: none;
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
transition:
|
|
236
|
+
filter 0.15s ease,
|
|
237
|
+
background 0.15s ease;
|
|
238
|
+
|
|
239
|
+
&[data-variant='ghost'] {
|
|
240
|
+
background: transparent;
|
|
241
|
+
border: 2px solid ${s.accent};
|
|
242
|
+
color: ${s.accent};
|
|
243
|
+
}
|
|
244
|
+
&[data-variant='ghost']:hover {
|
|
245
|
+
background: rgba(105, 31, 169, 0.06);
|
|
246
|
+
}
|
|
247
|
+
&[data-variant='ruby'] {
|
|
248
|
+
background: ${s.dclRed};
|
|
249
|
+
border: 0;
|
|
250
|
+
color: ${s.softWhite};
|
|
251
|
+
}
|
|
252
|
+
&[data-variant='ruby']:hover {
|
|
253
|
+
filter: brightness(0.95);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
${g} {
|
|
257
|
+
width: 100%;
|
|
258
|
+
flex: none;
|
|
259
|
+
}
|
|
260
|
+
`,we=t.button`
|
|
261
|
+
${I};
|
|
262
|
+
`,ye=t.a`
|
|
263
|
+
${I};
|
|
264
|
+
`,be=t.span`
|
|
265
|
+
display: inline-flex;
|
|
266
|
+
align-items: center;
|
|
267
|
+
justify-content: center;
|
|
268
|
+
width: 32px;
|
|
269
|
+
height: 32px;
|
|
270
|
+
border: 2.5px solid rgba(252, 252, 252, 0.5);
|
|
271
|
+
border-radius: ${u.btn};
|
|
272
|
+
line-height: 0;
|
|
273
|
+
`,$=t(J)`
|
|
274
|
+
min-width: 160px;
|
|
275
|
+
text-align: center;
|
|
276
|
+
`,ve=i=>new Promise(r=>setTimeout(r,i));function ke(i,r){const[l,a]=A.useState(i?"pending":"confirmed"),f=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return A.useEffect(()=>{if(!i)return;let d=!1;return(async()=>{let m=!1;for(let c=0;c<20&&!d;c++)try{await D(i,{timeoutMs:15e3}),m=!0;break}catch(p){if(p instanceof K)continue;d||a("failed");return}if(!d){if(!m){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let c=0;c<40&&!d;c++){if(await U(r.owner,r.contractAddress,r.itemId)){d||a("confirmed");return}await ve(3e3)}d||a("timed-out")}})(),()=>{d=!0}},[i,f]),l}const $e=L.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Ce=L.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Fe(){var R;const{state:i}=T(),r=E(),{session:l}=W(),a=i==null?void 0:i.txHash,f=(i==null?void 0:i.items)??[],d=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,x=f[0],m=l!=null&&l.address&&(x!=null&&x.contractAddress)&&(x!=null&&x.itemId)?{owner:l.address,contractAddress:x.contractAddress,itemId:x.itemId}:null,c=ke(i!=null&&i.settled?void 0:a,m);O({title:n("seo.success.title"),noindex:!0});const p=f;if(p.length===0)return e.jsx(N,{to:"/assets",replace:!0});const C=p[0],j=(R=i==null?void 0:i.txHashes)!=null&&R.length?i.txHashes:a?[a]:[],h=j.length>0&&_(l==null?void 0:l.providerType)?j.map((o,y)=>e.jsx(Q,{href:`${Ce}${o}`,target:"_blank",rel:"noreferrer",children:j.length>1?n("success.viewTransactionNumbered",{n:y+1,total:j.length}):n("success.viewTransaction")},o)):null;return c!=="confirmed"?e.jsx(z,{children:e.jsx(X,{children:c==="pending"||c==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"spinner","aria-hidden":!0}),e.jsx(v,{children:c==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(k,{children:c==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",p.length===1?e.jsx("strong",{children:C.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:C.name}):n("success.itemCount",{count:p.length})," ",n("success.confirmingAfter")]})}),h?e.jsx(w,{children:h}):null]}):c==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(v,{children:n("success.stillProcessingTitle")}),e.jsxs(k,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>r("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),h?e.jsx(w,{children:h}):null,e.jsxs(S,{children:[e.jsx($,{variant:"purple",onClick:()=>r("/activity"),children:n("success.viewActivity")}),e.jsx($,{variant:"ghost",onClick:()=>r("/assets"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{children:n("success.failedTitle")}),e.jsx(k,{children:n("success.failedBody")}),h?e.jsx(w,{children:h}):null,e.jsx(S,{children:e.jsx($,{variant:"purple",onClick:()=>r("/assets"),children:n("success.backToShop")})})]})})}):e.jsx(z,{children:e.jsxs(Y,{children:[e.jsxs(V,{role:"status",children:[e.jsx(Z,{"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(ee,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(te,{children:[d?e.jsxs(se,{"data-testid":"success-credits",children:[e.jsx(re,{}),e.jsxs(ce,{children:[e.jsx(oe,{children:n("getCredits.creditsAmount",{credits:d,currency:q.name})})," ",e.jsx(ae,{children:n("getCredits.creditsAdded")})]})]}):null,p.map((o,y)=>{const b=o.quantity??1;return e.jsxs(ne,{children:[y>0?e.jsx(ie,{"aria-hidden":!0}):null,e.jsxs(de,{children:[e.jsxs(le,{children:[o.thumbnail?e.jsx("img",{src:o.thumbnail,alt:""}):null,e.jsx(xe,{"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(pe,{children:[e.jsxs(he,{title:o.name,children:[o.name||n("buyModal.itemFallback"),b>1?e.jsx(ue,{children:n("cartCheckout.qty",{count:b})}):null]}),o.creator?e.jsx(ge,{address:o.creator,linkToProfile:!0}):null]}),e.jsxs(fe,{children:[e.jsx(me,{}),e.jsx("span",{children:H(o.priceCredits*b)})]})]})]},o.id)})]}),h?e.jsx(w,{"data-receipt":!0,children:h}):null,e.jsxs(je,{children:[e.jsx(we,{"data-variant":"ghost",onClick:()=>r("/my-assets"),children:n("success.myAssets")}),e.jsxs(ye,{"data-variant":"ruby",href:$e,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(be,{"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{Fe as Success,Fe 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-CAciSeGb.js";import{au as C}from"./NetworkUtil-HlUKXKcF.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-DSb_b_EZ.js";import{au as C}from"./NetworkUtil-HlUKXKcF.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,d as T}from"./react-vyZjIDcS.js";import{s as P,t as i}from"./index-
|
|
1
|
+
import{r as o,j as C,d as T}from"./react-vyZjIDcS.js";import{s as P,t as i}from"./index-DzVTWEvS.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-CXBJm_wN.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-vyZjIDcS.js";import{
|
|
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-CXBJm_wN.js";import{p as Ee,d as B}from"./dcl-schemas-BICTSpB5.js";import{c as ee}from"./react-vyZjIDcS.js";import{bi as be,b as te,a as re}from"./index-DzVTWEvS.js";import{c as q,e as Re}from"./index-1J_FpndO.js";import{s as Ie}from"./sendMetaTransaction-Ci7WU1n2.js";import"./sentry-B35L1FdR.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new Re.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),R=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(R.populateTransaction):R.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&ⅇ(c.global===c||c.window===c||c.self===c)&&(e=c);var l,R=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,b,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(b=w>0?w+1:0;b<o;){for(I=d,f=1,m=T;b>=o&&F("invalid-input"),g=Te(n.charCodeAt(b++)),(g>=T||g>E((R-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(R/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>R-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,b,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=R,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((R-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>R&&F("overflow"),f==a){for(x=o,b=T;I=b<=y?v:b>=y+P?P:b-y,!(x<I);b+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return be.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};
|