@dcl/shop 1.0.2-31061650925.commit-fa244eb → 1.0.2-31061952187.commit-8d8b09e
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-DAMRT2bN.js → Activity-D_fQdZon.js} +8 -8
- package/_assets/{AnimatedBackground-N_wcSf6D.js → AnimatedBackground-C9W4RBcZ.js} +1 -1
- package/_assets/{Assets-7wgiv5MU.js → Assets-CvZql_4R.js} +2 -2
- package/_assets/{Assets.styles-9R6ppWqo.js → Assets.styles-BBWJCcMx.js} +1 -1
- package/_assets/{Authorizations-DCP2Yevg.js → Authorizations-DVwQ95Ww.js} +1 -1
- package/_assets/{Cart-CpLaRQWb.js → Cart-CBLHJRVj.js} +6 -6
- package/_assets/{CircularProgress-BYXbDw8X.js → CircularProgress-D09608yv.js} +1 -1
- package/_assets/{Collection-CA94Ylrk.js → Collection-DllncUVv.js} +10 -10
- package/_assets/{CollectionCarousel-BkFV4le7.js → CollectionCarousel-B9HmGuVb.js} +6 -6
- package/_assets/{Confetti-D7bsXMqQ.js → Confetti-Dl6FT7nL.js} +1 -1
- package/_assets/{Creator-DWKYxWTB.js → Creator-BreBnKPX.js} +5 -5
- package/_assets/{ErrorNotice-CCsvrT3H.js → ErrorNotice-OUNK486K.js} +1 -1
- package/_assets/{ExchangeController-KIbY1TeV.js → ExchangeController-Cp3qbfAM.js} +1 -1
- package/_assets/{Faq-YyrvPI25.js → Faq-DXtTtsuA.js} +1 -1
- package/_assets/{GetCredits-gCz6CMY3.js → GetCredits-BhRNCaTG.js} +10 -10
- package/_assets/{Grow-B6W2xyXd.js → Grow-DXdR0gI9.js} +1 -1
- package/_assets/{HelpersUtil-BmHoBPAz.js → HelpersUtil-rQp5uDAx.js} +1 -1
- package/_assets/{ItemDetail-DsP2PTh3.js → ItemDetail-clRbfaLQ.js} +28 -28
- package/_assets/LazyEmoteControls-B7UYn8xk.js +2 -0
- package/_assets/{LoadMore-ChGcAM1i.js → LoadMore-jSNRJiwZ.js} +1 -1
- package/_assets/{ManaPricingBanner.styles-CZgGH3OR.js → ManaPricingBanner.styles-vDUAKLLe.js} +1 -1
- package/_assets/{MyAssets-jgTQywGo.js → MyAssets-CsWhc-qa.js} +4 -4
- package/_assets/{MyFavorites-B_oQzUR9.js → MyFavorites-BLrz2vwY.js} +1 -1
- package/_assets/{NotFound-CjDp1Ys_.js → NotFound-DP4nosOd.js} +1 -1
- package/_assets/{NotificationsBell-Dkr9JB0w.js → NotificationsBell-ARziPv8W.js} +1 -1
- package/_assets/OutfitDetail-CLmuEgB3.js +374 -0
- package/_assets/{OutfitPreview-J5m3e8Gl.js → OutfitPreview-PWdXvCaE.js} +2 -2
- package/_assets/{OutfitStudio-xpf5tPAA.js → OutfitStudio-Cx3Xm6ff.js} +11 -11
- package/_assets/{StoreSettings-BkFED3xP.js → StoreSettings-BQtEgWRm.js} +21 -21
- package/_assets/{Success-lmJVKgtL.js → Success-BWfI3_Mu.js} +1 -1
- package/_assets/{SwapController-DKvQsgHw.js → SwapController-Bf58lQ6b.js} +1 -1
- package/_assets/{Tooltip-BBYuQHQb.js → Tooltip-BDmKiALz.js} +1 -1
- package/_assets/{TradeService-CkbprpVw.js → TradeService-Yecm1OxI.js} +1 -1
- package/_assets/{W3MFrameProviderSingleton-6oL2Do5B.js → W3MFrameProviderSingleton-BQyeyr-U.js} +3 -3
- package/_assets/{WebCryptoP256-6t0_XFco.js → WebCryptoP256-Ou_F2OJp.js} +1 -1
- package/_assets/{authorizations-CbXH-W_L.js → authorizations-B3AvOvOm.js} +1 -1
- package/_assets/{basic-DSLXBfxu.js → basic-DTDRwam-.js} +1 -1
- package/_assets/{biconomy-DKrndD59.js → biconomy-DaLi1O64.js} +1 -1
- package/_assets/{builder-CVMQir9d.js → builder-DxumJmKw.js} +1 -1
- package/_assets/{buy-BllmT-mt.js → buy-BHkfYJLe.js} +1 -1
- package/_assets/{buy-gasless-BuzErI_K.js → buy-gasless-BfTEWjT9.js} +1 -1
- package/_assets/{categories-Bjf-PXbG.js → categories-D23W_J-A.js} +1 -1
- package/_assets/{ccip-DI15Urx-.js → ccip-DGVhZCZ4.js} +1 -1
- package/_assets/{ccip-DyRqdu6M.js → ccip-qhHiv1gU.js} +1 -1
- package/_assets/{collectionPage.styles-BgKDi1Aa.js → collectionPage.styles-CoEdrsfq.js} +3 -3
- package/_assets/{controller-BSVA5WKe.js → controller-DGtmLk4f.js} +2 -2
- package/_assets/{core-CflNwoXZ.js → core-BAqS3vu7.js} +4 -4
- package/_assets/{createSvgIcon-BCgRSx6l.js → createSvgIcon-Bm9nxGqG.js} +2 -2
- package/_assets/{custom-ekboJ4XZ.js → custom-MaGTnz7S.js} +1 -1
- package/_assets/{data-capture-C00Edv8o.js → data-capture-5Vi1cyBa.js} +1 -1
- package/_assets/{email-D7bKqbcO.js → email-BG6hRXMo.js} +1 -1
- package/_assets/{embedded-wallet-BgZe_e0-.js → embedded-wallet-CfnknCH8.js} +1 -1
- package/_assets/{emotion-styled.browser.esm-BsZP4P-B.js → emotion-styled.browser.esm-CoxAZUrJ.js} +1 -1
- package/_assets/{engine-Cnqy1olA.js → engine-nQGCV50K.js} +1 -1
- package/_assets/{errors-BXmP5k3l.js → errors-DZ_QWsza.js} +1 -1
- package/_assets/{estimate-l1-fee-9ryWwmxC.js → estimate-l1-fee-CVpJ9ym5.js} +1 -1
- package/_assets/{execute-CY4XWL-J.js → execute-DFvUDrLY.js} +2 -2
- package/_assets/{features-MG4MlDMD.js → features-BXUedULM.js} +1 -1
- package/_assets/{fetchTokenMetadata-qCCUs6iE.js → fetchTokenMetadata-CkQcnzmO.js} +2 -2
- package/_assets/{field.styles-DEvu6yNO.js → field.styles-PE4ZasC2.js} +1 -1
- package/_assets/{get-ecosystem-wallet-info-DEImAnzE.js → get-ecosystem-wallet-info-CRLH8I6C.js} +1 -1
- package/_assets/{getBalance-J5grsfOj.js → getBalance-CiV48JsZ.js} +1 -1
- package/_assets/{getNFT-ByNh7y6k.js → getNFT-C3ucNb89.js} +1 -1
- package/_assets/{getNFT-Dm5aL9u2.js → getNFT-CV3N9TTA.js} +1 -1
- package/_assets/{grid.styles-CtrXwvIr.js → grid.styles-hOZTJ80g.js} +1 -1
- package/_assets/{hashTypedData-CgttwS7E.js → hashTypedData-BtF2J233.js} +1 -1
- package/_assets/{hashTypedData-BxKbqj1M.js → hashTypedData-gTABcRB5.js} +1 -1
- package/_assets/{in-app-DF-fkkCZ.js → in-app-CSDr4Blb.js} +1 -1
- package/_assets/{in-app-wallet-calls-D9z1I0uV.js → in-app-wallet-calls-Crivl9zc.js} +1 -1
- package/_assets/{index-BybKxZca.js → index-1oceTWwb.js} +3 -3
- package/_assets/{index-Fn-DLeUg.js → index-9_4ZEs3N.js} +1 -1
- package/_assets/{index-C5fUw5Ha.js → index-9x1mGBeU.js} +1 -1
- package/_assets/{index-DXpGefPo.js → index-BBbwMaBz.js} +1 -1
- package/_assets/{index-BiSRuBrK.js → index-BNBzDf6z.js} +1 -1
- package/_assets/{index-CjSsletQ.js → index-BTDIKmoC.js} +1 -1
- package/_assets/{index-CuZ7SJno.js → index-Bg_gOSx_.js} +1 -1
- package/_assets/{index-BFgGvh7x.js → index-BniGBCAO.js} +1 -1
- package/_assets/{index-DbCIWeQF.js → index-Bs4LvV4K.js} +2 -2
- package/_assets/{index-B6xwPPMs.js → index-C0pcaEQl.js} +1 -1
- package/_assets/{index-BDPRDW4c.js → index-C23D_vyT.js} +1 -1
- package/_assets/{index-C0xt2SIQ.js → index-C5Evg5sh.js} +1 -1
- package/_assets/{index-D7foy_c1.js → index-C7hpB9s1.js} +3 -3
- package/_assets/{index-zG9t0hxJ.js → index-CGBg3yUz.js} +11 -11
- package/_assets/{index--tlhUPhu.js → index-CHf7lsmp.js} +1 -1
- package/_assets/{index-B7sgFJOZ.js → index-CHolIX6U.js} +1 -1
- package/_assets/{index-D7dTUoYt.js → index-CKUuopSw.js} +12 -12
- package/_assets/{index-Z6tclw43.js → index-CS27am7J.js} +1 -1
- package/_assets/{index-BlIt7KpC.js → index-Cf-gi-Qq.js} +1 -1
- package/_assets/{index-C2s-_3dE.js → index-CkGO7qOd.js} +1 -1
- package/_assets/{index-BcW0TBOx.js → index-ClUPCoEW.js} +1 -1
- package/_assets/{index-gbxeK1C-.js → index-CmY0V0eX.js} +1 -1
- package/_assets/{index-BKC-pfo2.js → index-CvwosU6Y.js} +1 -1
- package/_assets/{index-B7Mvi-Fg.js → index-CwRTjZPC.js} +3 -3
- package/_assets/{index-lIySTE8R.js → index-CyRHowbs.js} +1 -1
- package/_assets/{index-CpxvlmGa.js → index-D5eMvKb_.js} +1 -1
- package/_assets/{index-7eX0SEVb.js → index-D769FdFr.js} +1 -1
- package/_assets/{index-CszjRehO.js → index-D7LYoLo4.js} +1 -1
- package/_assets/{index-CAj85Mcv.js → index-DKHMu0o3.js} +1 -1
- package/_assets/{index-CuZGDrIM.js → index-DKdQUEzy.js} +1 -1
- package/_assets/{index-DYQXXAKt.js → index-DLFQdlEW.js} +1 -1
- package/_assets/{index-Cbj1bJsc.js → index-DSuiX4WG.js} +1 -1
- package/_assets/{index-BSmKDErh.js → index-DXRL-4ld.js} +1 -1
- package/_assets/{index-BZNkhtbZ.js → index-DY1xBku2.js} +1 -1
- package/_assets/{index-D_a1Dj89.js → index-DdmULNRk.js} +2 -2
- package/_assets/{index-DVJFosyx.js → index-DgOiZShm.js} +1 -1
- package/_assets/{index-BsD9lKdu.js → index-Dh85kccn.js} +1 -1
- package/_assets/{index-CkHS5p_Q.js → index-DjTNPtj2.js} +1 -1
- package/_assets/{index-CIKoh-oU.js → index-DkV5TYom.js} +1 -1
- package/_assets/{index-DRjhhI6j.js → index-DnJJn52L.js} +1 -1
- package/_assets/{index-CKXjZ-Kd.js → index-DoGz07sk.js} +1 -1
- package/_assets/{index-D20327nw.js → index-Dp2641E3.js} +1 -1
- package/_assets/{index-CbQYrUIv.js → index-DwX-9Zo4.js} +1 -1
- package/_assets/{index-BcQ98rhd.js → index-EKmmXx1j.js} +1 -1
- package/_assets/{index-gmA5M3R1.js → index-HAEoS9R6.js} +1 -1
- package/_assets/{index-DlewIau_.js → index-ItjVcw1b.js} +1 -1
- package/_assets/{index-B5TGt1q8.js → index-KWEbYeSY.js} +1 -1
- package/_assets/{index-CAzui_hj.js → index-S0X-BG2b.js} +1 -1
- package/_assets/{index-C6RxhKIE.js → index-UyXkCiLs.js} +1 -1
- package/_assets/{index-Dc_jl2yy.js → index-hKv-BpxY.js} +1 -1
- package/_assets/{index-CgKz1pmK.js → index-qGMuaBIs.js} +1 -1
- package/_assets/{index-D5jN8YQk.js → index-wRmEiTlP.js} +2 -2
- package/_assets/{index.es-BOuSF7GL.js → index.es-DnMGDxtr.js} +1 -1
- package/_assets/{index.es-6tzroQMk.js → index.es-g_bB-nFv.js} +1 -1
- package/_assets/{index.es-11O0MAa5.js → index.es-wpL2Ycto.js} +4 -4
- package/_assets/{localBatchGatewayRequest-CByVkxJB.js → localBatchGatewayRequest-DtELSHiE.js} +1 -1
- package/_assets/{networks-CLAHX11r.js → networks-ZmRqsvV6.js} +1 -1
- package/_assets/{onramp-X6DWjNa-.js → onramp-Bffl3qa3.js} +1 -1
- package/_assets/{openzeppelin-DWrLU4le.js → openzeppelin-BmH-LNci.js} +1 -1
- package/_assets/{parseNft-C0F1eSr9.js → parseNft-PSjb4qKi.js} +2 -2
- package/_assets/{parseSignature-Cfa0bf3p.js → parseSignature-D947kFfv.js} +3 -3
- package/_assets/{parseSignature-B1BDTVRI.js → parseSignature-IigTmAp7.js} +1 -1
- package/_assets/{passkeys-Bq7ndAcy.js → passkeys-BsJVcpuM.js} +1 -1
- package/_assets/{pay-with-exchange-DU8q52b9.js → pay-with-exchange-CU_HZd9F.js} +1 -1
- package/_assets/{qr-overlay-2pcgXiq0.js → qr-overlay-EMShc5uE.js} +1 -1
- package/_assets/{receive-UZ0WD1OR.js → receive-CO6WElZa.js} +1 -1
- package/_assets/{resolveImplementation-C5KIPshP.js → resolveImplementation-CUngPhAv.js} +1 -1
- package/_assets/{rpc-q5JetAPC.js → rpc-BqH_VMy9.js} +1 -1
- package/_assets/{secp256k1-C79pdbKP.js → secp256k1-CTsmRKJj.js} +1 -1
- package/_assets/{secp256k1-C35ing1J.js → secp256k1-D7kpLshE.js} +1 -1
- package/_assets/{secp256k1-CYrjGZQC.js → secp256k1-DneM3aYG.js} +1 -1
- package/_assets/{send-_ymraJKw.js → send-DnwW2LgN.js} +1 -1
- package/_assets/{send-batch-transaction-DkYVZ1xj.js → send-batch-transaction-BgJnfEM8.js} +1 -1
- package/_assets/{send-eip712-transaction-BzZBuy56.js → send-eip712-transaction-Cw3ykz5y.js} +2 -2
- package/_assets/{send-gasless-transaction-ByRZPFH6.js → send-gasless-transaction-BjGhnCwR.js} +2 -2
- package/_assets/{send-transaction-CUkh0xRu.js → send-transaction-COKVeGfk.js} +2 -2
- package/_assets/{sendMetaTransaction-De85nOcx.js → sendMetaTransaction-Bp3kwdLJ.js} +1 -1
- package/_assets/{sendRawTransaction-D5RykxPX.js → sendRawTransaction-eVli2oE3.js} +3 -3
- package/_assets/{serializeTransaction-EYy94JNM.js → serializeTransaction-CIM9i_-w.js} +1 -1
- package/_assets/{session-proposal-Bf_Po3Sl.js → session-proposal-KGl_Ah2b.js} +1 -1
- package/_assets/{session-request-DEDmAqA-.js → session-request-VAEXTksW.js} +2 -2
- package/_assets/{signing-DqKP5KUZ.js → signing-Cgx49_1X.js} +3 -3
- package/_assets/{skeleton.styles-CVQk0siV.js → skeleton.styles-BXNXDWEi.js} +1 -1
- package/_assets/{socials-3pLrS-E7.js → socials-oKAOeF-k.js} +1 -1
- package/_assets/{styled-8pFgehSd.js → styled-pD_2hanx.js} +1 -1
- package/_assets/{swaps-C-dgABl9.js → swaps-BcAY_D99.js} +1 -1
- package/_assets/{thirdweb-C6_KggNb.js → thirdweb-ChAqWFCO.js} +3 -3
- package/_assets/{to-serializable-transaction-BWUJjZdO.js → to-serializable-transaction-D9qGbcrS.js} +2 -2
- package/_assets/{transactionReceipt-DmwkwkkP.js → transactionReceipt-BMw52z-f.js} +1 -1
- package/_assets/{transactions-BSJMdJi4.js → transactions-CeENvGIt.js} +1 -1
- package/_assets/{useCreditPacks-DQxqJepP.js → useCreditPacks-BcavayJ3.js} +1 -1
- package/_assets/{useImportable-Co0AaRPY.js → useImportable-CqnIvzif.js} +1 -1
- package/_assets/{useInfiniteGrid-UHC0Jjfu.js → useInfiniteGrid-BjEQAabI.js} +1 -1
- package/_assets/{useTheme-B-55uBZP.js → useTheme-BnnteKI4.js} +1 -1
- package/_assets/{verifyHash-BGJh7VH4.js → verifyHash-CuRmy06R.js} +1 -1
- package/_assets/{w3m-modal-CwXD068w.js → w3m-modal-BvOCJx7k.js} +1 -1
- package/_assets/{w3m-modal-CjXODL26.js → w3m-modal-CkBFH4cA.js} +1 -1
- package/_assets/{wait-for-tx-receipt-DRA8zhkS.js → wait-for-tx-receipt-B2KaPYJT.js} +1 -1
- package/_assets/{wallets-DOXRX-PZ.js → wallets-CpXU08d2.js} +5 -5
- package/_assets/{web-connector-CXxJTFl4.js → web-connector-BHRkWbB9.js} +3 -3
- package/_assets/{writeContract-BdEWRAPa.js → writeContract-DNDGvg0r.js} +1 -1
- package/_assets/{zoraTestnet-CzfX948o.js → zoraTestnet-CCn01jlp.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/_assets/LazyEmoteControls-lVtDIvME.js +0 -2
- package/_assets/OutfitDetail-BNlw-NwV.js +0 -334
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as
|
|
1
|
+
import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t as j,s as a,w as ce,B as G,x as de,o as pe,A as ue,bt as ge,by as me,bz as xe,bA as he,bB as R,I as C,bC as f,bD as fe,E as F}from"./index-CKUuopSw.js";import{E as D}from"./ErrorNotice-OUNK486K.js";import{F as w}from"./field.styles-PE4ZasC2.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/1.0.2-31061952187.commit-8d8b09e/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.0.2-31061952187.commit-8d8b09e/_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
|
}
|
|
5
|
-
`,Se=
|
|
5
|
+
`,Se=a.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
8
8
|
justify-content: center;
|
|
@@ -16,7 +16,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
text-align: center;
|
|
18
18
|
}
|
|
19
|
-
`,ke=
|
|
19
|
+
`,ke=a.span`
|
|
20
20
|
flex: none;
|
|
21
21
|
border-radius: 50%;
|
|
22
22
|
border-style: solid;
|
|
@@ -43,21 +43,21 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
43
43
|
@media (prefers-reduced-motion: reduce) {
|
|
44
44
|
animation-duration: 2s;
|
|
45
45
|
}
|
|
46
|
-
`,$e=
|
|
46
|
+
`,$e=a.span`
|
|
47
47
|
font-size: 14px;
|
|
48
48
|
font-weight: 600;
|
|
49
|
-
`;function ye({label:r,size:u="medium",direction:S="column",className:k}){return t.jsxs(Se,{className:k,"data-testid":"spinner-box","data-direction":S,role:"status","aria-live":"polite","aria-label":r?void 0:
|
|
49
|
+
`;function ye({label:r,size:u="medium",direction:S="column",className:k}){return t.jsxs(Se,{className:k,"data-testid":"spinner-box","data-direction":S,role:"status","aria-live":"polite","aria-label":r?void 0:n("spinner.loading"),children:[t.jsx(ke,{"data-testid":"spinner-box-ring","data-size":u,"aria-hidden":!0}),r?t.jsx($e,{children:r}):null]})}const{colors:s,radius:_e,media:K}=j,Ee=a(ye)`
|
|
50
50
|
display: grid;
|
|
51
51
|
place-items: center;
|
|
52
52
|
min-height: 60vh;
|
|
53
|
-
`,ze=
|
|
53
|
+
`,ze=a(G)`
|
|
54
54
|
align-self: center;
|
|
55
55
|
min-width: 200px;
|
|
56
56
|
margin-top: 8px;
|
|
57
|
-
`,Ce=
|
|
57
|
+
`,Ce=a.p`
|
|
58
58
|
margin: 0;
|
|
59
59
|
color: ${s.gray4};
|
|
60
|
-
`,M=
|
|
60
|
+
`,M=a.section`
|
|
61
61
|
max-width: 640px;
|
|
62
62
|
margin: 0 auto;
|
|
63
63
|
padding: 8px 0 48px;
|
|
@@ -88,17 +88,17 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
88
88
|
resize: vertical;
|
|
89
89
|
min-height: 88px;
|
|
90
90
|
}
|
|
91
|
-
`,Ne=
|
|
91
|
+
`,Ne=a.div`
|
|
92
92
|
display: flex;
|
|
93
93
|
align-items: baseline;
|
|
94
94
|
justify-content: space-between;
|
|
95
95
|
gap: 16px;
|
|
96
96
|
flex-wrap: wrap;
|
|
97
|
-
`,Le=
|
|
97
|
+
`,Le=a.div`
|
|
98
98
|
display: flex;
|
|
99
99
|
align-items: center;
|
|
100
100
|
gap: 10px;
|
|
101
|
-
`,He=
|
|
101
|
+
`,He=a(oe)`
|
|
102
102
|
display: flex;
|
|
103
103
|
align-items: center;
|
|
104
104
|
justify-content: center;
|
|
@@ -112,10 +112,10 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
112
112
|
width: 22px;
|
|
113
113
|
height: 22px;
|
|
114
114
|
}
|
|
115
|
-
`,O=
|
|
115
|
+
`,O=a.h1`
|
|
116
116
|
font-size: 24px;
|
|
117
117
|
font-weight: 800;
|
|
118
|
-
`,Ie=
|
|
118
|
+
`,Ie=a.a`
|
|
119
119
|
display: inline-flex;
|
|
120
120
|
align-items: center;
|
|
121
121
|
gap: 6px;
|
|
@@ -131,7 +131,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
131
131
|
width: 15px;
|
|
132
132
|
height: 15px;
|
|
133
133
|
}
|
|
134
|
-
`,Te=
|
|
134
|
+
`,Te=a.div`
|
|
135
135
|
display: flex;
|
|
136
136
|
align-items: stretch;
|
|
137
137
|
border: 1px solid ${s.lineStrong};
|
|
@@ -145,7 +145,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
145
145
|
flex: 1;
|
|
146
146
|
min-width: 0;
|
|
147
147
|
}
|
|
148
|
-
`,Be=
|
|
148
|
+
`,Be=a.span`
|
|
149
149
|
display: flex;
|
|
150
150
|
align-items: center;
|
|
151
151
|
padding: 0 10px;
|
|
@@ -154,7 +154,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
154
154
|
font-size: 13px;
|
|
155
155
|
white-space: nowrap;
|
|
156
156
|
border-right: 1px solid ${s.lineStrong};
|
|
157
|
-
`,Pe=
|
|
157
|
+
`,Pe=a.div`
|
|
158
158
|
display: grid;
|
|
159
159
|
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
160
160
|
gap: 12px;
|
|
@@ -162,7 +162,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
162
162
|
${K.maxWidth("mobile")} {
|
|
163
163
|
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
164
164
|
}
|
|
165
|
-
`,N=
|
|
165
|
+
`,N=a.button`
|
|
166
166
|
position: relative;
|
|
167
167
|
padding: 0;
|
|
168
168
|
border: 2px solid ${s.lineStrong};
|
|
@@ -223,21 +223,21 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as a,t a
|
|
|
223
223
|
&[data-variant='upload']:hover .ico {
|
|
224
224
|
background: ${s.accent};
|
|
225
225
|
}
|
|
226
|
-
`,Ae=
|
|
226
|
+
`,Ae=a.input`
|
|
227
227
|
position: absolute;
|
|
228
228
|
width: 1px;
|
|
229
229
|
height: 1px;
|
|
230
230
|
opacity: 0;
|
|
231
231
|
pointer-events: none;
|
|
232
|
-
`,
|
|
232
|
+
`,Re=a.div`
|
|
233
233
|
display: flex;
|
|
234
234
|
justify-content: flex-end;
|
|
235
235
|
gap: 12px;
|
|
236
236
|
margin-top: 8px;
|
|
237
|
-
`,
|
|
237
|
+
`,Fe=a(G)`
|
|
238
238
|
min-width: 180px;
|
|
239
239
|
|
|
240
240
|
${K.maxWidth("mobile")} {
|
|
241
241
|
width: 100%;
|
|
242
242
|
}
|
|
243
|
-
`,W=1e6,V={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function qe(){de({title:
|
|
243
|
+
`,W=1e6,V={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function qe(){de({title:n("seo.storeSettings.title"),noindex:!0});const{session:r,signIn:u}=pe(),S=le(),k=ue(),p=r==null?void 0:r.address,{data:$,isLoading:q}=ge(p),[o,g]=l.useState(V),[L,H]=l.useState(V),[y,x]=l.useState(),[h,I]=l.useState(!1),[c,_]=l.useState(null),[b,J]=l.useState({}),T=l.useRef(null);l.useEffect(()=>{if($){const e=me($);g(e),H(e),x(void 0),_(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[$]),l.useEffect(()=>{let e=!1;return Promise.all(v.map(async i=>[i.name,await xe(i.url)])).then(i=>{e||J(Object.fromEntries(i))}).catch(()=>{}),()=>{e=!0}},[]);const E=l.useMemo(()=>{const e=v.find(d=>o.coverName===`cover/${d.name}`);if(e)return e.name;const i=o.coverHash?v.find(d=>b[d.name]===o.coverHash):void 0;return i==null?void 0:i.name},[o.coverName,o.coverHash,b]);l.useEffect(()=>{c!=null&&c.hash&&v.some(e=>b[e.name]===c.hash)&&_(null)},[b,c]);const B=y!==void 0&&y>W,Q=l.useMemo(()=>he.filter(e=>!R(e,o.links[e])),[o.links]),U=B||Q.length>0,z=l.useMemo(()=>JSON.stringify(o)!==JSON.stringify(L),[o,L]),X=z&&!U&&!h;if(l.useEffect(()=>{if(!z)return;const e=i=>{i.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[z]),!r)return t.jsxs(M,{"data-signin":!0,"aria-label":n("storeSettings.title"),children:[t.jsx(O,{children:n("storeSettings.title")}),t.jsx(Ce,{children:n("storeSettings.signInPrompt")}),t.jsx(ze,{variant:"white",onClick:u,children:n("storeSettings.signIn")})]});function Z(e,i){x(void 0),g(d=>({...d,cover:i,coverName:`cover/${e}`,coverHash:""}))}const ee=["image/png","image/jpeg","image/webp"];function te(e){var P;const i=(P=e.target.files)==null?void 0:P[0];if(!i||!ee.includes(i.type))return;x(i.size);const d=`cover/${i.name}`,m=new FileReader;m.onload=()=>{const A=m.result;_({url:A,name:d,hash:""}),g(re=>({...re,cover:A,coverName:d,coverHash:""}))},m.readAsDataURL(i)}function ie(){c&&(x(void 0),g(e=>({...e,cover:c.url,coverName:c.name,coverHash:c.hash})))}function se(e,i){const d=i?(f[e]+i).replace(/\s/g,""):"";g(m=>({...m,links:{...m.links,[e]:d}}))}function ne(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function ae(){if(!(!p||!r)){I(!0);try{await fe(p,o,r.identity),H(o),x(void 0),await k.invalidateQueries({queryKey:["store",p.toLowerCase()]}),F.success(n("storeSettings.saved")),S(`/items/creator/${p}`)}catch{F.error(n("storeSettings.saveError"))}finally{I(!1)}}}return t.jsxs(M,{"aria-label":n("storeSettings.title"),children:[t.jsxs(Ne,{children:[t.jsxs(Le,{children:[p?t.jsx(He,{to:`/items/creator/${p}`,title:n("storeSettings.back"),"aria-label":n("storeSettings.back"),children:t.jsx(C,{name:"arrow-left"})}):null,t.jsx(O,{children:n("storeSettings.title")})]}),p?t.jsxs(Ie,{href:`/items/creator/${p}`,target:"_blank",rel:"noopener noreferrer",children:[n("storeSettings.seeAsGuest"),t.jsx(C,{name:"external-link"})]}):null]}),q?t.jsx(Ee,{size:"large",label:n("storeSettings.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs(w,{children:[t.jsx("span",{className:"field__label",children:n("storeSettings.cover")}),t.jsxs(Pe,{role:"group","aria-label":n("storeSettings.cover"),children:[v.map(e=>{const i=E===e.name;return t.jsx(N,{type:"button","data-testid":"cover-picker-tile","data-selected":i,"aria-pressed":i,onClick:()=>Z(e.name,e.url),children:t.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),c?t.jsx(N,{type:"button","data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!E,"aria-pressed":!E,onClick:ie,children:t.jsx("img",{src:c.url,alt:""})}):null,t.jsxs(N,{type:"button","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=T.current)==null?void 0:e.click()},children:[t.jsx(C,{name:"upload"}),t.jsx("span",{children:n("storeSettings.upload")})]}),t.jsx(Ae,{ref:T,type:"file",accept:"image/png, image/jpeg, image/webp","data-testid":"cover-picker-input",onChange:te})]}),B?t.jsx(D,{message:n("storeSettings.sizeError",{max:Y(W),current:Y(y)})}):null]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:n("storeSettings.description")}),t.jsx("textarea",{value:o.description,rows:4,disabled:h,onChange:e=>g(i=>({...i,description:e.target.value}))})]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:n("storeSettings.website")}),t.jsx("input",{type:"url",value:o.links.website,placeholder:f.website,disabled:h,onChange:e=>g(i=>({...i,links:{...i.links,website:e.target.value.replace(/\s/g,"")}}))}),R("website",o.links.website)?null:t.jsx(D,{message:n("storeSettings.linkError",{value:f.website})})]}),["twitter","discord","facebook"].map(e=>t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:n(`storeSettings.${e}`)}),t.jsxs(Te,{children:[t.jsx(Be,{children:f[e]}),t.jsx("input",{type:"text",value:ne(e),disabled:h,onChange:i=>se(e,i.target.value)})]})]},e)),t.jsx(Re,{children:t.jsx(Fe,{variant:"white","data-testid":"store-settings-save",onClick:()=>void ae(),disabled:!X,children:h?n("storeSettings.saving"):n("storeSettings.save")})})]})]})}export{qe as StoreSettings,qe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as E,b as F,j as e,N as M,r as S}from"./react-BYHuwl8r.js";import{t as P,s as t,z as B,J as W,K as O,o as _,x as q,b as n,y as J,C as U,L as D,M as H,c as T,B as K,N as X}from"./index-
|
|
1
|
+
import{a as E,b as F,j as e,N as M,r as S}from"./react-BYHuwl8r.js";import{t as P,s as t,z as B,J as W,K as O,o as _,x as q,b as n,y as J,C as U,L as D,M as H,c as T,B as K,N as X}from"./index-CKUuopSw.js";import{C as Q}from"./Confetti-Dl6FT7nL.js";import{w as Y,S as G}from"./buy-gasless-BfTEWjT9.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./authorizations-B3AvOvOm.js";import"./sendMetaTransaction-Bp3kwdLJ.js";import"./buy-BHkfYJLe.js";const{colors:s,radius:f}=P,m="@media (max-width: 600px)",I=t.div`
|
|
2
2
|
/* Its own stacking context, above the confetti layer (z-index 0). Needed because z-index is inert without
|
|
3
3
|
a position, so the content would otherwise sit below the burst regardless of order. */
|
|
4
4
|
position: relative;
|
|
@@ -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-6oL2Do5B.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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-BQyeyr-U.js";import{au as C}from"./NetworkUtil-DXqql1Wz.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,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-
|
|
1
|
+
import{r as o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-CKUuopSw.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-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.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-BDpbhgX6.js";import{a as Ee,d as B}from"./dcl-schemas-CmtP3U6y.js";import{c as ee}from"./react-BYHuwl8r.js";import{cp as Re,f as te,g as re}from"./index-CKUuopSw.js";import{c as q,e as Ie}from"./index-DdmULNRk.js";import{s as Pe}from"./sendMetaTransaction-Bp3kwdLJ.js";import"./sentry-Dx-KuLV3.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};
|