@multiversx/sdk-dapp-liquidity 1.0.12 → 1.0.14
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/ConstantsUtil-BinYIDR2.mjs +8 -0
- package/ConstantsUtil-CbnVdQ5P.js +8 -0
- package/add-D-ECcdUh.mjs +19 -0
- package/add-Diz8heiY.js +20 -0
- package/all-wallets-_iOQf3bl.js +11 -0
- package/all-wallets-puIIQy3Y.mjs +10 -0
- package/app-store-BGTKFL27.js +22 -0
- package/app-store-Bsf7w3pv.mjs +21 -0
- package/apple-Cw8e8IGH.mjs +22 -0
- package/apple-DF7n_Yzl.js +23 -0
- package/arrow-bottom-Cp2C4fQv.mjs +12 -0
- package/arrow-bottom-DTvIR3s3.js +13 -0
- package/arrow-bottom-circle-CN6i5mHz.mjs +15 -0
- package/arrow-bottom-circle-CzPwiwWH.js +16 -0
- package/arrow-left-9VFYHQSW.js +13 -0
- package/arrow-left-BDQHoEvX.mjs +12 -0
- package/arrow-right-BxkuSpWU.mjs +12 -0
- package/arrow-right-DBLQ6w92.js +13 -0
- package/arrow-top-BiQd5Aey.js +13 -0
- package/arrow-top-BrLVX4Rj.mjs +12 -0
- package/bank-B7EC6Kdz.mjs +18 -0
- package/bank-CvPn9sfV.js +19 -0
- package/{bignumber-CKZkoo0g.mjs → bignumber-2Z7uapuD.mjs} +6 -6
- package/{bignumber-B8vjg9qn.js → bignumber-D1Wl54dL.js} +6 -6
- package/bin-BXO1kNZh.js +9 -0
- package/bin-CwiYVJ1L.mjs +8 -0
- package/bitcoin-C3kBVar_.mjs +17 -0
- package/bitcoin-DAvQGpeP.js +3251 -0
- package/bitcoin-dNBGbS2B.mjs +3251 -0
- package/bitcoin-k6bvmzMA.js +18 -0
- package/browser-ShRLuKKz.mjs +18 -0
- package/browser-t7nfT7HL.js +19 -0
- package/card-BJg5bdoM.mjs +18 -0
- package/card-hxUDXttT.js +19 -0
- package/checkmark-BpR0Yy93.mjs +15 -0
- package/checkmark-D9AVWgl5.js +16 -0
- package/checkmark-bold-D3Xcby1U.mjs +12 -0
- package/checkmark-bold-De02hde8.js +13 -0
- package/chevron-bottom-DcBf7T5F.js +13 -0
- package/chevron-bottom-DfGpWIz7.mjs +12 -0
- package/chevron-left-BKvYVnUo.js +13 -0
- package/chevron-left-DGSG9WJQ.mjs +12 -0
- package/chevron-right-BLgYIEeO.js +13 -0
- package/chevron-right-C2nsTx_Y.mjs +12 -0
- package/chevron-top-CwFOEFy8.js +13 -0
- package/chevron-top-vk-9DvUU.mjs +12 -0
- package/chrome-store-4H_ie3vA.mjs +65 -0
- package/chrome-store-BWarxVMl.js +66 -0
- package/circle-BtqWJU0_.mjs +8 -0
- package/circle-DYjG6o7-.js +9 -0
- package/clock-Ba5SM-pl.mjs +12 -0
- package/clock-DPzNREdU.js +13 -0
- package/close-CJHKFOyp.mjs +12 -0
- package/close-DDWnJdJe.js +13 -0
- package/coinPlaceholder-Cbba3D1H.mjs +12 -0
- package/coinPlaceholder-DdxQIc2D.js +13 -0
- package/compass-CugCxeSC.js +13 -0
- package/compass-DbN5DkTl.mjs +12 -0
- package/copy-CHSZprYJ.mjs +19 -0
- package/copy-En5h5Uhu.js +20 -0
- package/cursor-DCRkvEhr.mjs +7 -0
- package/cursor-DnEQtrUK.js +8 -0
- package/cursor-transparent-CU8lk-xg.js +17 -0
- package/cursor-transparent-CliETg4d.mjs +16 -0
- package/desktop-BgD7aypB.js +14 -0
- package/desktop-Cg5I32-p.mjs +13 -0
- package/disconnect-CCyMbAdw.js +13 -0
- package/disconnect-Cp2vRWB2.mjs +12 -0
- package/discord-B1d-qeSk.mjs +21 -0
- package/discord-BEB5klec.js +22 -0
- package/email-CorlePKz.js +873 -0
- package/email-Znno7H8_.mjs +878 -0
- package/embedded-wallet-B9ro9Tel.js +549 -0
- package/embedded-wallet-CnTWeseG.mjs +552 -0
- package/ethereum-BRcsRjUU.mjs +14 -0
- package/ethereum-CZ_xe09e.js +15 -0
- package/etherscan-BZKGpKp8.mjs +10 -0
- package/etherscan-DtLi-C3z.js +11 -0
- package/exclamation-triangle-BLNnBLEc.js +9 -0
- package/exclamation-triangle-CFThXxRT.mjs +8 -0
- package/extension-CwUepr-W.mjs +12 -0
- package/extension-DOD67G1k.js +13 -0
- package/external-link-CZkQS5XK.js +13 -0
- package/external-link-ClYNKSPt.mjs +12 -0
- package/facebook-CFjrd4my.mjs +30 -0
- package/facebook-CbE6K6AK.js +31 -0
- package/farcaster-Ba7_C-Vm.js +17 -0
- package/farcaster-DyVJtVS9.mjs +16 -0
- package/filters-CpHaFNjT.mjs +12 -0
- package/filters-w5LC-r6e.js +13 -0
- package/github-CeO70C3E.mjs +22 -0
- package/github-uLFBWAa5.js +23 -0
- package/google-CyOdUlbw.mjs +22 -0
- package/google-ILGK-opP.js +23 -0
- package/help-circle-Dh3dRNoB.mjs +16 -0
- package/help-circle-HUMbz_KN.js +17 -0
- package/id-Cy3Qkrvb.js +17 -0
- package/id-D-Q0uPFM.mjs +16 -0
- package/if-defined-CJ5EZLw2.js +815 -0
- package/if-defined-DjC5UMfF.mjs +815 -0
- package/image-BTGOf8bb.mjs +8 -0
- package/image-WFQO5bWa.js +9 -0
- package/index--O5ypTeK.mjs +70 -0
- package/index--Vg7VI9t.js +173 -0
- package/index-2iRSO1sa.mjs +9964 -0
- package/index-42Rpweo5.mjs +95 -0
- package/index-70kjE43k.mjs +90 -0
- package/index-8VyNYS01.js +273 -0
- package/index-B-dx8l0g.mjs +82 -0
- package/index-BB0nW9RB.mjs +198 -0
- package/index-BBwuv2SS.js +97 -0
- package/index-BIe-kofv.mjs +273 -0
- package/index-BQf6VHil.js +278 -0
- package/index-BWIZXhFv.mjs +630 -0
- package/index-BXkamf-I.js +337 -0
- package/index-BYTxCmKH.js +64 -0
- package/index-BYoOxo0S.js +218 -0
- package/index-Ba0tVdql.js +200 -0
- package/index-BdOAPWyt.mjs +210 -0
- package/index-BirWzf8c.mjs +71 -0
- package/index-BnCJUHtW.mjs +346 -0
- package/index-BuL2FC61.mjs +216 -0
- package/index-BxSUTfaY.js +88 -0
- package/index-C49C5Rxf.js +743 -0
- package/index-CNMDBpW7.js +346 -0
- package/index-CP0CGjqQ.mjs +263 -0
- package/index-CQaHcTZM.mjs +86 -0
- package/index-CRGXQei1.js +178 -0
- package/index-CSykUIfV.mjs +176 -0
- package/index-CWIHaLkQ.mjs +101 -0
- package/index-CZSDJd0P.mjs +1070 -0
- package/index-CZaV8JgR.mjs +49 -0
- package/index-CZjdy6QP.js +101 -0
- package/index-C_lIGGlC.js +632 -0
- package/index-CcgeRPs2.mjs +57 -0
- package/index-CeY_DRuc.js +566 -0
- package/index-ChFNkSxT.js +92 -0
- package/index-CkjZc20w.js +677 -0
- package/index-CtFcWwAd.js +72 -0
- package/index-D0mOfznC.mjs +362 -0
- package/index-DAtWLY21.js +84 -0
- package/index-DEs8H3w2.js +262 -0
- package/index-DLnxotbC.mjs +566 -0
- package/index-DN4fGDgg.mjs +743 -0
- package/index-DT_mc1hV.mjs +335 -0
- package/index-DZEwxUMS.js +59 -0
- package/index-DaRH_4bD.js +9939 -0
- package/index-Daok2ZKn.js +73 -0
- package/index-DomzHmwk.js +210 -0
- package/index-Dx7NyDyv.mjs +101 -0
- package/index-DyGir6_2.mjs +675 -0
- package/index-GglJmM2C.js +2237 -0
- package/index-H5b7UTeJ.mjs +173 -0
- package/index-NNZ1lNuc.mjs +168 -0
- package/index-RJd-gQcv.mjs +2235 -0
- package/index-dnFzVpGy.js +103 -0
- package/index-kwVLu8EV.js +168 -0
- package/index-miQwZPmn.js +51 -0
- package/index-oCj_SpOa.mjs +62 -0
- package/index-pNK-h_x9.js +1069 -0
- package/index-r6Kre1rx.js +362 -0
- package/index-xBD0nXoB.mjs +276 -0
- package/index.js +3 -3
- package/index.mjs +3 -3
- package/info-BKNAiN0k.js +8 -0
- package/info-DQE0s-A4.mjs +7 -0
- package/info-circle-C3uTocjH.js +17 -0
- package/info-circle-CIn6yeQo.mjs +16 -0
- package/lightbulb-CB-BmIop.js +8 -0
- package/lightbulb-Gv7IbnzO.mjs +7 -0
- package/mail-CFYm95wn.mjs +12 -0
- package/mail-GEwk-Fzr.js +13 -0
- package/mobile-CZ7ZBfa5.js +14 -0
- package/mobile-OIbnpFsU.mjs +13 -0
- package/more-C8N_RV55.mjs +15 -0
- package/more-CiQpPZwq.js +16 -0
- package/network-placeholder-CxEcczEx.mjs +18 -0
- package/network-placeholder-DwR8E8hP.js +19 -0
- package/nftPlaceholder-BFexVcGX.js +13 -0
- package/nftPlaceholder-MiYL110I.mjs +12 -0
- package/off-BNiMlpUU.mjs +8 -0
- package/off-iJHSK3Z7.js +9 -0
- package/onramp-Bs8HHFFY.js +1474 -0
- package/onramp-C6fuQfX7.mjs +1480 -0
- package/package.json +11 -11
- package/play-store-B4ssIYUA.js +37 -0
- package/play-store-D6nmQXhX.mjs +36 -0
- package/plus-Bh7z7Oc0.js +18 -0
- package/plus-C8ioZuCD.mjs +17 -0
- package/qr-code-CSVwaBLf.mjs +10 -0
- package/qr-code-YgtXPokK.js +11 -0
- package/react-BWxe90Ar.mjs +6342 -0
- package/react-BzZcQig5.js +6342 -0
- package/react-C_wTMVq_.js +23003 -0
- package/react-M-DnxvZl.mjs +23003 -0
- package/reactjs/components/BridgeForm/BridgeForm.js +2 -1
- package/reactjs/components/BridgeForm/BridgeForm.mjs +2 -1
- package/reactjs/components/Connect/BridgeAccountDisplay.js +3 -2
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +3 -2
- package/reactjs/components/Connect/CustomConnectButton.js +3 -2
- package/reactjs/components/Connect/CustomConnectButton.mjs +3 -2
- package/reactjs/components/Connect/SwitchChainButton.js +4 -3
- package/reactjs/components/Connect/SwitchChainButton.mjs +4 -3
- package/reactjs/components/DisplayAmount/DisplayAmount.js +1 -1
- package/reactjs/components/DisplayAmount/DisplayAmount.mjs +1 -1
- package/reactjs/components/TokenSelector/components/TokenItem.js +1 -1
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +1 -1
- package/reactjs/hooks/useAccount.d.ts +4 -4
- package/reactjs/hooks/useAccount.js +3 -2
- package/reactjs/hooks/useAccount.mjs +3 -2
- package/reactjs/hooks/useGetChainId.js +1 -1
- package/reactjs/hooks/useGetChainId.mjs +1 -1
- package/reactjs/index.js +3 -3
- package/reactjs/index.mjs +3 -3
- package/reactjs/init/init.js +4 -3
- package/reactjs/init/init.mjs +4 -3
- package/reactjs/init/tests/init.spec.js +2 -2
- package/reactjs/init/tests/init.spec.mjs +2 -2
- package/reactjs/queries/useGetEvmTokensBalances.query.js +3 -2
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +3 -2
- package/reactjs/reexports.js +3 -3
- package/reactjs/reexports.mjs +3 -3
- package/reactjs/utils/getCleanStringAmount.js +1 -1
- package/reactjs/utils/getCleanStringAmount.mjs +1 -1
- package/reactjs/utils/hasEnoughFunds.js +1 -1
- package/reactjs/utils/hasEnoughFunds.mjs +1 -1
- package/reactjs/utils/isStringFloat.js +1 -1
- package/reactjs/utils/isStringFloat.mjs +1 -1
- package/reactjs/utils/roundAmount.js +1 -1
- package/reactjs/utils/roundAmount.mjs +1 -1
- package/receive-CK0hRQPr.js +212 -0
- package/receive-CQcD6bZf.mjs +212 -0
- package/recycle-horizontal--x5cMoTE.js +14 -0
- package/recycle-horizontal-QI0xtDHK.mjs +13 -0
- package/ref-CqxfRkBm.mjs +41 -0
- package/ref-FGI2cUQB.js +41 -0
- package/refresh-CFNHjhDi.js +13 -0
- package/refresh-CSOC1NUY.mjs +12 -0
- package/reown-logo-BfU5xFX5.js +17 -0
- package/reown-logo-CZAEp1jU.mjs +16 -0
- package/search-Do_rb-9-.mjs +12 -0
- package/search-V9CGMHkm.js +13 -0
- package/send-D-5G7tDL.mjs +1204 -0
- package/send-D4yYsIHV.mjs +19 -0
- package/send-DoiSHLsX.js +1202 -0
- package/send-_jfNFrys.js +20 -0
- package/socials-BL7-97fT.mjs +758 -0
- package/socials-DF0CK9cN.js +756 -0
- package/solana-BQ0Jh8lh.js +18 -0
- package/solana-YAkDp6j_.mjs +17 -0
- package/swapHorizontal-DOIo-Ccx.mjs +12 -0
- package/swapHorizontal-OHKtz4Gu.js +13 -0
- package/swapHorizontalBold-D7QmFj-c.js +13 -0
- package/swapHorizontalBold-DDroA0Af.mjs +12 -0
- package/swapHorizontalMedium-CU_v0kFz.mjs +20 -0
- package/swapHorizontalMedium-D-yMmtml.js +21 -0
- package/swapHorizontalRoundedBold-CHvbmnjw.js +13 -0
- package/swapHorizontalRoundedBold-DXMH0sgK.mjs +12 -0
- package/swapVertical-CH7fTK6w.js +13 -0
- package/swapVertical-HJZ6rFcr.mjs +12 -0
- package/swaps-CETflhdU.js +1952 -0
- package/swaps-DRUV6d3p.mjs +1954 -0
- package/telegram-CsCauOwj.mjs +20 -0
- package/telegram-DKEcF_Tq.js +21 -0
- package/three-dots-B-7hr8Nl.js +10 -0
- package/three-dots-LNZ_fjP7.mjs +9 -0
- package/transactions-BTTsGV2W.mjs +37 -0
- package/transactions-mpNNlClw.js +37 -0
- package/twitch-CCWVT2ij.js +23 -0
- package/twitch-Dg1CCQvd.mjs +22 -0
- package/twitterIcon-BjR09Cj9.mjs +10 -0
- package/twitterIcon-CeEs0iDJ.js +11 -0
- package/verify-B8WZq7kt.mjs +12 -0
- package/verify-filled-BeqC1imk.mjs +12 -0
- package/verify-filled-C-mv3ApD.js +13 -0
- package/verify-yATdPqt-.js +13 -0
- package/w3m-modal-3GziKj7h.js +1254 -0
- package/w3m-modal-81Z5PngE.mjs +1255 -0
- package/wallet-BMXEH23x.js +13 -0
- package/wallet-CNAVQCfm.mjs +12 -0
- package/wallet-placeholder-CQ-7CmVN.mjs +18 -0
- package/wallet-placeholder-CdoQy2e6.js +19 -0
- package/walletconnect-ACr-R1QZ.mjs +38 -0
- package/walletconnect-BWSkiS2F.js +39 -0
- package/warning-circle-CYnuYwpt.js +17 -0
- package/warning-circle-HV2lOiCj.mjs +16 -0
- package/x-CW5dozRj.js +17 -0
- package/x-Cgm2OFpL.mjs +16 -0
- package/x-mark-CR8SpZvu.js +8 -0
- package/x-mark-u0KJjUJ1.mjs +7 -0
- package/index-B4Eq5P3w.mjs +0 -91
- package/index-C4WV9nam.js +0 -329
- package/index-CWMcKi_X.js +0 -107
- package/index-D8E0O3qL.mjs +0 -68744
- package/index-DJ8CdHSw.mjs +0 -107
- package/index-nigVQYBu.js +0 -68665
- package/react-C43nEIqn.js +0 -3133
- package/react-DKUsVej7.js +0 -50
- package/react-Dp0H8q2z.mjs +0 -50
- package/react-wMhOUFOm.mjs +0 -3133
- package/w3m-modal-DLyg7Voy.js +0 -356
- package/w3m-modal-hC-B8qZP.mjs +0 -356
|
@@ -0,0 +1,1954 @@
|
|
|
1
|
+
import { i, f as i$1, x, c as resetStyles, e as elementStyles } from "./bitcoin-dNBGbS2B.mjs";
|
|
2
|
+
import { r, n, c as customElement, U as UiHelperUtil } from "./if-defined-DjC5UMfF.mjs";
|
|
3
|
+
import "./index-DT_mc1hV.mjs";
|
|
4
|
+
import { M as MathUtil } from "./index-CWIHaLkQ.mjs";
|
|
5
|
+
import "./index-NNZ1lNuc.mjs";
|
|
6
|
+
import { c as ChainController, N as NumberUtil, i as ConstantsUtil, E as EventsController, R as RouterController, A as AccountController, d as CoreHelperUtil, M as ModalController, g as getPreferredAccountType, W as W3mFrameRpcConstants } from "./react-BWxe90Ar.mjs";
|
|
7
|
+
import { S as SwapController } from "./index-DN4fGDgg.mjs";
|
|
8
|
+
import "./index-B-dx8l0g.mjs";
|
|
9
|
+
import "./index-xBD0nXoB.mjs";
|
|
10
|
+
import "./index--O5ypTeK.mjs";
|
|
11
|
+
const InputUtil = {
|
|
12
|
+
numericInputKeyDown(event, currentValue, onChange) {
|
|
13
|
+
const allowedKeys = [
|
|
14
|
+
"Backspace",
|
|
15
|
+
"Meta",
|
|
16
|
+
"Ctrl",
|
|
17
|
+
"a",
|
|
18
|
+
"A",
|
|
19
|
+
"c",
|
|
20
|
+
"C",
|
|
21
|
+
"x",
|
|
22
|
+
"X",
|
|
23
|
+
"v",
|
|
24
|
+
"V",
|
|
25
|
+
"ArrowLeft",
|
|
26
|
+
"ArrowRight",
|
|
27
|
+
"Tab"
|
|
28
|
+
];
|
|
29
|
+
const controlPressed = event.metaKey || event.ctrlKey;
|
|
30
|
+
const eventKey = event.key;
|
|
31
|
+
const lowercaseEventKey = eventKey.toLocaleLowerCase();
|
|
32
|
+
const selectAll = lowercaseEventKey === "a";
|
|
33
|
+
const copyKey = lowercaseEventKey === "c";
|
|
34
|
+
const pasteKey = lowercaseEventKey === "v";
|
|
35
|
+
const cutKey = lowercaseEventKey === "x";
|
|
36
|
+
const isComma = eventKey === ",";
|
|
37
|
+
const isDot = eventKey === ".";
|
|
38
|
+
const isNumericKey = eventKey >= "0" && eventKey <= "9";
|
|
39
|
+
if (!controlPressed && (selectAll || copyKey || pasteKey || cutKey)) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
}
|
|
42
|
+
if (currentValue === "0" && !isComma && !isDot && eventKey === "0") {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
}
|
|
45
|
+
if (currentValue === "0" && isNumericKey) {
|
|
46
|
+
onChange(eventKey);
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
}
|
|
49
|
+
if (isComma || isDot) {
|
|
50
|
+
if (!currentValue) {
|
|
51
|
+
onChange("0.");
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
if ((currentValue == null ? void 0 : currentValue.includes(".")) || (currentValue == null ? void 0 : currentValue.includes(","))) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!isNumericKey && !allowedKeys.includes(eventKey) && !isDot && !isComma) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const styles$6 = i`
|
|
64
|
+
:host {
|
|
65
|
+
width: 100%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.details-container > wui-flex {
|
|
69
|
+
background: var(--wui-color-gray-glass-002);
|
|
70
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
71
|
+
width: 100%;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.details-container > wui-flex > button {
|
|
75
|
+
border: none;
|
|
76
|
+
background: none;
|
|
77
|
+
padding: var(--wui-spacing-s);
|
|
78
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.details-content-container {
|
|
83
|
+
padding: var(--wui-spacing-1xs);
|
|
84
|
+
padding-top: 0px;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.details-content-container > wui-flex {
|
|
91
|
+
width: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.details-row {
|
|
95
|
+
width: 100%;
|
|
96
|
+
padding: var(--wui-spacing-s);
|
|
97
|
+
padding-left: var(--wui-spacing-s);
|
|
98
|
+
padding-right: var(--wui-spacing-1xs);
|
|
99
|
+
border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs));
|
|
100
|
+
background: var(--wui-color-gray-glass-002);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.details-row-title {
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.details-row.provider-free-row {
|
|
108
|
+
padding-right: var(--wui-spacing-xs);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
var __decorate$6 = function(decorators, target, key, desc) {
|
|
112
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
113
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
114
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
115
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
116
|
+
};
|
|
117
|
+
const slippageRate = ConstantsUtil.CONVERT_SLIPPAGE_TOLERANCE;
|
|
118
|
+
let WuiSwapDetails = class WuiSwapDetails2 extends i$1 {
|
|
119
|
+
constructor() {
|
|
120
|
+
var _a;
|
|
121
|
+
super();
|
|
122
|
+
this.unsubscribe = [];
|
|
123
|
+
this.networkName = (_a = ChainController.state.activeCaipNetwork) == null ? void 0 : _a.name;
|
|
124
|
+
this.detailsOpen = false;
|
|
125
|
+
this.sourceToken = SwapController.state.sourceToken;
|
|
126
|
+
this.toToken = SwapController.state.toToken;
|
|
127
|
+
this.toTokenAmount = SwapController.state.toTokenAmount;
|
|
128
|
+
this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
|
|
129
|
+
this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
|
|
130
|
+
this.priceImpact = SwapController.state.priceImpact;
|
|
131
|
+
this.maxSlippage = SwapController.state.maxSlippage;
|
|
132
|
+
this.networkTokenSymbol = SwapController.state.networkTokenSymbol;
|
|
133
|
+
this.inputError = SwapController.state.inputError;
|
|
134
|
+
this.unsubscribe.push(...[
|
|
135
|
+
SwapController.subscribe((newState) => {
|
|
136
|
+
this.sourceToken = newState.sourceToken;
|
|
137
|
+
this.toToken = newState.toToken;
|
|
138
|
+
this.toTokenAmount = newState.toTokenAmount;
|
|
139
|
+
this.priceImpact = newState.priceImpact;
|
|
140
|
+
this.maxSlippage = newState.maxSlippage;
|
|
141
|
+
this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
|
|
142
|
+
this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
|
|
143
|
+
this.inputError = newState.inputError;
|
|
144
|
+
})
|
|
145
|
+
]);
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
const minReceivedAmount = this.toTokenAmount && this.maxSlippage ? NumberUtil.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString() : null;
|
|
149
|
+
if (!this.sourceToken || !this.toToken || this.inputError) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const toTokenSwappedAmount = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD ? 1 / this.toTokenPriceInUSD * this.sourceTokenPriceInUSD : 0;
|
|
153
|
+
return x`
|
|
154
|
+
<wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container">
|
|
155
|
+
<wui-flex flexDirection="column">
|
|
156
|
+
<button @click=${this.toggleDetails.bind(this)}>
|
|
157
|
+
<wui-flex justifyContent="space-between" .padding=${["0", "xs", "0", "xs"]}>
|
|
158
|
+
<wui-flex justifyContent="flex-start" flexGrow="1" gap="xs">
|
|
159
|
+
<wui-text variant="small-400" color="fg-100">
|
|
160
|
+
1 ${this.sourceToken.symbol} =
|
|
161
|
+
${UiHelperUtil.formatNumberToLocalString(toTokenSwappedAmount, 3)}
|
|
162
|
+
${this.toToken.symbol}
|
|
163
|
+
</wui-text>
|
|
164
|
+
<wui-text variant="small-400" color="fg-200">
|
|
165
|
+
$${UiHelperUtil.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
|
|
166
|
+
</wui-text>
|
|
167
|
+
</wui-flex>
|
|
168
|
+
<wui-icon name="chevronBottom"></wui-icon>
|
|
169
|
+
</wui-flex>
|
|
170
|
+
</button>
|
|
171
|
+
${this.detailsOpen ? x`
|
|
172
|
+
<wui-flex flexDirection="column" gap="xs" class="details-content-container">
|
|
173
|
+
${this.priceImpact ? x` <wui-flex flexDirection="column" gap="xs">
|
|
174
|
+
<wui-flex
|
|
175
|
+
justifyContent="space-between"
|
|
176
|
+
alignItems="center"
|
|
177
|
+
class="details-row"
|
|
178
|
+
>
|
|
179
|
+
<wui-flex alignItems="center" gap="xs">
|
|
180
|
+
<wui-text class="details-row-title" variant="small-400" color="fg-150">
|
|
181
|
+
Price impact
|
|
182
|
+
</wui-text>
|
|
183
|
+
<w3m-tooltip-trigger
|
|
184
|
+
text="Price impact reflects the change in market price due to your trade"
|
|
185
|
+
>
|
|
186
|
+
<wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
|
|
187
|
+
</w3m-tooltip-trigger>
|
|
188
|
+
</wui-flex>
|
|
189
|
+
<wui-flex>
|
|
190
|
+
<wui-text variant="small-400" color="fg-200">
|
|
191
|
+
${UiHelperUtil.formatNumberToLocalString(this.priceImpact, 3)}%
|
|
192
|
+
</wui-text>
|
|
193
|
+
</wui-flex>
|
|
194
|
+
</wui-flex>
|
|
195
|
+
</wui-flex>` : null}
|
|
196
|
+
${this.maxSlippage && this.sourceToken.symbol ? x`<wui-flex flexDirection="column" gap="xs">
|
|
197
|
+
<wui-flex
|
|
198
|
+
justifyContent="space-between"
|
|
199
|
+
alignItems="center"
|
|
200
|
+
class="details-row"
|
|
201
|
+
>
|
|
202
|
+
<wui-flex alignItems="center" gap="xs">
|
|
203
|
+
<wui-text class="details-row-title" variant="small-400" color="fg-150">
|
|
204
|
+
Max. slippage
|
|
205
|
+
</wui-text>
|
|
206
|
+
<w3m-tooltip-trigger
|
|
207
|
+
text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${minReceivedAmount ? `Transaction will be reversed if you receive less than ${UiHelperUtil.formatNumberToLocalString(minReceivedAmount, 6)} ${this.toToken.symbol} due to price changes.` : ""}`}
|
|
208
|
+
>
|
|
209
|
+
<wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
|
|
210
|
+
</w3m-tooltip-trigger>
|
|
211
|
+
</wui-flex>
|
|
212
|
+
<wui-flex>
|
|
213
|
+
<wui-text variant="small-400" color="fg-200">
|
|
214
|
+
${UiHelperUtil.formatNumberToLocalString(this.maxSlippage, 6)}
|
|
215
|
+
${this.toToken.symbol} ${slippageRate}%
|
|
216
|
+
</wui-text>
|
|
217
|
+
</wui-flex>
|
|
218
|
+
</wui-flex>
|
|
219
|
+
</wui-flex>` : null}
|
|
220
|
+
<wui-flex flexDirection="column" gap="xs">
|
|
221
|
+
<wui-flex
|
|
222
|
+
justifyContent="space-between"
|
|
223
|
+
alignItems="center"
|
|
224
|
+
class="details-row provider-free-row"
|
|
225
|
+
>
|
|
226
|
+
<wui-flex alignItems="center" gap="xs">
|
|
227
|
+
<wui-text class="details-row-title" variant="small-400" color="fg-150">
|
|
228
|
+
Provider fee
|
|
229
|
+
</wui-text>
|
|
230
|
+
</wui-flex>
|
|
231
|
+
<wui-flex>
|
|
232
|
+
<wui-text variant="small-400" color="fg-200">0.85%</wui-text>
|
|
233
|
+
</wui-flex>
|
|
234
|
+
</wui-flex>
|
|
235
|
+
</wui-flex>
|
|
236
|
+
</wui-flex>
|
|
237
|
+
` : null}
|
|
238
|
+
</wui-flex>
|
|
239
|
+
</wui-flex>
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
toggleDetails() {
|
|
243
|
+
this.detailsOpen = !this.detailsOpen;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
WuiSwapDetails.styles = [styles$6];
|
|
247
|
+
__decorate$6([
|
|
248
|
+
r()
|
|
249
|
+
], WuiSwapDetails.prototype, "networkName", void 0);
|
|
250
|
+
__decorate$6([
|
|
251
|
+
n()
|
|
252
|
+
], WuiSwapDetails.prototype, "detailsOpen", void 0);
|
|
253
|
+
__decorate$6([
|
|
254
|
+
r()
|
|
255
|
+
], WuiSwapDetails.prototype, "sourceToken", void 0);
|
|
256
|
+
__decorate$6([
|
|
257
|
+
r()
|
|
258
|
+
], WuiSwapDetails.prototype, "toToken", void 0);
|
|
259
|
+
__decorate$6([
|
|
260
|
+
r()
|
|
261
|
+
], WuiSwapDetails.prototype, "toTokenAmount", void 0);
|
|
262
|
+
__decorate$6([
|
|
263
|
+
r()
|
|
264
|
+
], WuiSwapDetails.prototype, "sourceTokenPriceInUSD", void 0);
|
|
265
|
+
__decorate$6([
|
|
266
|
+
r()
|
|
267
|
+
], WuiSwapDetails.prototype, "toTokenPriceInUSD", void 0);
|
|
268
|
+
__decorate$6([
|
|
269
|
+
r()
|
|
270
|
+
], WuiSwapDetails.prototype, "priceImpact", void 0);
|
|
271
|
+
__decorate$6([
|
|
272
|
+
r()
|
|
273
|
+
], WuiSwapDetails.prototype, "maxSlippage", void 0);
|
|
274
|
+
__decorate$6([
|
|
275
|
+
r()
|
|
276
|
+
], WuiSwapDetails.prototype, "networkTokenSymbol", void 0);
|
|
277
|
+
__decorate$6([
|
|
278
|
+
r()
|
|
279
|
+
], WuiSwapDetails.prototype, "inputError", void 0);
|
|
280
|
+
WuiSwapDetails = __decorate$6([
|
|
281
|
+
customElement("w3m-swap-details")
|
|
282
|
+
], WuiSwapDetails);
|
|
283
|
+
const styles$5 = i`
|
|
284
|
+
:host {
|
|
285
|
+
width: 100%;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
:host > wui-flex {
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: row;
|
|
291
|
+
justify-content: space-between;
|
|
292
|
+
align-items: center;
|
|
293
|
+
border-radius: var(--wui-border-radius-s);
|
|
294
|
+
padding: var(--wui-spacing-xl);
|
|
295
|
+
padding-right: var(--wui-spacing-s);
|
|
296
|
+
background-color: var(--wui-color-gray-glass-002);
|
|
297
|
+
box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
|
|
298
|
+
width: 100%;
|
|
299
|
+
height: 100px;
|
|
300
|
+
box-sizing: border-box;
|
|
301
|
+
position: relative;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
wui-shimmer.market-value {
|
|
305
|
+
opacity: 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
:host > wui-flex > svg.input_mask {
|
|
309
|
+
position: absolute;
|
|
310
|
+
inset: 0;
|
|
311
|
+
z-index: 5;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
:host wui-flex .input_mask__border,
|
|
315
|
+
:host wui-flex .input_mask__background {
|
|
316
|
+
transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1);
|
|
317
|
+
will-change: fill;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
:host wui-flex .input_mask__border {
|
|
321
|
+
fill: var(--wui-color-gray-glass-020);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
:host wui-flex .input_mask__background {
|
|
325
|
+
fill: var(--wui-color-gray-glass-002);
|
|
326
|
+
}
|
|
327
|
+
`;
|
|
328
|
+
var __decorate$5 = function(decorators, target, key, desc) {
|
|
329
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
330
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
331
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
332
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
333
|
+
};
|
|
334
|
+
let W3mSwapInputSkeleton = class W3mSwapInputSkeleton2 extends i$1 {
|
|
335
|
+
constructor() {
|
|
336
|
+
super(...arguments);
|
|
337
|
+
this.target = "sourceToken";
|
|
338
|
+
}
|
|
339
|
+
render() {
|
|
340
|
+
return x`
|
|
341
|
+
<wui-flex class justifyContent="space-between">
|
|
342
|
+
<wui-flex
|
|
343
|
+
flex="1"
|
|
344
|
+
flexDirection="column"
|
|
345
|
+
alignItems="flex-start"
|
|
346
|
+
justifyContent="center"
|
|
347
|
+
class="swap-input"
|
|
348
|
+
gap="xxs"
|
|
349
|
+
>
|
|
350
|
+
<wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer>
|
|
351
|
+
</wui-flex>
|
|
352
|
+
${this.templateTokenSelectButton()}
|
|
353
|
+
</wui-flex>
|
|
354
|
+
`;
|
|
355
|
+
}
|
|
356
|
+
templateTokenSelectButton() {
|
|
357
|
+
return x`
|
|
358
|
+
<wui-flex
|
|
359
|
+
class="swap-token-button"
|
|
360
|
+
flexDirection="column"
|
|
361
|
+
alignItems="flex-end"
|
|
362
|
+
justifyContent="center"
|
|
363
|
+
gap="xxs"
|
|
364
|
+
>
|
|
365
|
+
<wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer>
|
|
366
|
+
</wui-flex>
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
W3mSwapInputSkeleton.styles = [styles$5];
|
|
371
|
+
__decorate$5([
|
|
372
|
+
n()
|
|
373
|
+
], W3mSwapInputSkeleton.prototype, "target", void 0);
|
|
374
|
+
W3mSwapInputSkeleton = __decorate$5([
|
|
375
|
+
customElement("w3m-swap-input-skeleton")
|
|
376
|
+
], W3mSwapInputSkeleton);
|
|
377
|
+
const styles$4 = i`
|
|
378
|
+
:host > wui-flex {
|
|
379
|
+
display: flex;
|
|
380
|
+
flex-direction: row;
|
|
381
|
+
justify-content: space-between;
|
|
382
|
+
align-items: center;
|
|
383
|
+
border-radius: var(--wui-border-radius-s);
|
|
384
|
+
background-color: var(--wui-color-gray-glass-002);
|
|
385
|
+
padding: var(--wui-spacing-xl);
|
|
386
|
+
padding-right: var(--wui-spacing-s);
|
|
387
|
+
width: 100%;
|
|
388
|
+
height: 100px;
|
|
389
|
+
box-sizing: border-box;
|
|
390
|
+
box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
|
|
391
|
+
position: relative;
|
|
392
|
+
transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg);
|
|
393
|
+
will-change: background-color;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
:host wui-flex.focus {
|
|
397
|
+
box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
:host > wui-flex .swap-input,
|
|
401
|
+
:host > wui-flex .swap-token-button {
|
|
402
|
+
z-index: 10;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
:host > wui-flex .swap-input {
|
|
406
|
+
-webkit-mask-image: linear-gradient(
|
|
407
|
+
270deg,
|
|
408
|
+
transparent 0px,
|
|
409
|
+
transparent 8px,
|
|
410
|
+
black 24px,
|
|
411
|
+
black 25px,
|
|
412
|
+
black 32px,
|
|
413
|
+
black 100%
|
|
414
|
+
);
|
|
415
|
+
mask-image: linear-gradient(
|
|
416
|
+
270deg,
|
|
417
|
+
transparent 0px,
|
|
418
|
+
transparent 8px,
|
|
419
|
+
black 24px,
|
|
420
|
+
black 25px,
|
|
421
|
+
black 32px,
|
|
422
|
+
black 100%
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
:host > wui-flex .swap-input input {
|
|
427
|
+
background: none;
|
|
428
|
+
border: none;
|
|
429
|
+
height: 42px;
|
|
430
|
+
width: 100%;
|
|
431
|
+
font-size: 32px;
|
|
432
|
+
font-style: normal;
|
|
433
|
+
font-weight: 400;
|
|
434
|
+
line-height: 130%;
|
|
435
|
+
letter-spacing: -1.28px;
|
|
436
|
+
outline: none;
|
|
437
|
+
caret-color: var(--wui-color-accent-100);
|
|
438
|
+
color: var(--wui-color-fg-100);
|
|
439
|
+
padding: 0px;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
:host > wui-flex .swap-input input:focus-visible {
|
|
443
|
+
outline: none;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
:host > wui-flex .swap-input input::-webkit-outer-spin-button,
|
|
447
|
+
:host > wui-flex .swap-input input::-webkit-inner-spin-button {
|
|
448
|
+
-webkit-appearance: none;
|
|
449
|
+
margin: 0;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.max-value-button {
|
|
453
|
+
background-color: transparent;
|
|
454
|
+
border: none;
|
|
455
|
+
cursor: pointer;
|
|
456
|
+
color: var(--wui-color-gray-glass-020);
|
|
457
|
+
padding-left: 0px;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.market-value {
|
|
461
|
+
min-height: 18px;
|
|
462
|
+
}
|
|
463
|
+
`;
|
|
464
|
+
var __decorate$4 = function(decorators, target, key, desc) {
|
|
465
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
466
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
467
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
468
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
469
|
+
};
|
|
470
|
+
const MINIMUM_USD_VALUE_TO_CONVERT = 5e-5;
|
|
471
|
+
let W3mSwapInput = class W3mSwapInput2 extends i$1 {
|
|
472
|
+
constructor() {
|
|
473
|
+
super(...arguments);
|
|
474
|
+
this.focused = false;
|
|
475
|
+
this.price = 0;
|
|
476
|
+
this.target = "sourceToken";
|
|
477
|
+
this.onSetAmount = null;
|
|
478
|
+
this.onSetMaxValue = null;
|
|
479
|
+
}
|
|
480
|
+
render() {
|
|
481
|
+
const marketValue = this.marketValue || "0";
|
|
482
|
+
const isMarketValueGreaterThanZero = NumberUtil.bigNumber(marketValue).gt("0");
|
|
483
|
+
return x`
|
|
484
|
+
<wui-flex class="${this.focused ? "focus" : ""}" justifyContent="space-between">
|
|
485
|
+
<wui-flex
|
|
486
|
+
flex="1"
|
|
487
|
+
flexDirection="column"
|
|
488
|
+
alignItems="flex-start"
|
|
489
|
+
justifyContent="center"
|
|
490
|
+
class="swap-input"
|
|
491
|
+
>
|
|
492
|
+
<input
|
|
493
|
+
data-testid="swap-input-${this.target}"
|
|
494
|
+
@focusin=${() => this.onFocusChange(true)}
|
|
495
|
+
@focusout=${() => this.onFocusChange(false)}
|
|
496
|
+
?disabled=${this.disabled}
|
|
497
|
+
.value=${this.value}
|
|
498
|
+
@input=${this.dispatchInputChangeEvent}
|
|
499
|
+
@keydown=${this.handleKeydown}
|
|
500
|
+
placeholder="0"
|
|
501
|
+
type="text"
|
|
502
|
+
inputmode="decimal"
|
|
503
|
+
/>
|
|
504
|
+
<wui-text class="market-value" variant="small-400" color="fg-200">
|
|
505
|
+
${isMarketValueGreaterThanZero ? `$${UiHelperUtil.formatNumberToLocalString(this.marketValue, 2)}` : null}
|
|
506
|
+
</wui-text>
|
|
507
|
+
</wui-flex>
|
|
508
|
+
${this.templateTokenSelectButton()}
|
|
509
|
+
</wui-flex>
|
|
510
|
+
`;
|
|
511
|
+
}
|
|
512
|
+
handleKeydown(event) {
|
|
513
|
+
return InputUtil.numericInputKeyDown(event, this.value, (value) => {
|
|
514
|
+
var _a;
|
|
515
|
+
return (_a = this.onSetAmount) == null ? void 0 : _a.call(this, this.target, value);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
dispatchInputChangeEvent(event) {
|
|
519
|
+
if (!this.onSetAmount) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const value = event.target.value.replace(/[^0-9.]/gu, "");
|
|
523
|
+
if (value === "," || value === ".") {
|
|
524
|
+
this.onSetAmount(this.target, "0.");
|
|
525
|
+
} else if (value.endsWith(",")) {
|
|
526
|
+
this.onSetAmount(this.target, value.replace(",", "."));
|
|
527
|
+
} else {
|
|
528
|
+
this.onSetAmount(this.target, value);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
setMaxValueToInput() {
|
|
532
|
+
var _a;
|
|
533
|
+
(_a = this.onSetMaxValue) == null ? void 0 : _a.call(this, this.target, this.balance);
|
|
534
|
+
}
|
|
535
|
+
templateTokenSelectButton() {
|
|
536
|
+
if (!this.token) {
|
|
537
|
+
return x` <wui-button
|
|
538
|
+
data-testid="swap-select-token-button-${this.target}"
|
|
539
|
+
class="swap-token-button"
|
|
540
|
+
size="md"
|
|
541
|
+
variant="accent"
|
|
542
|
+
@click=${this.onSelectToken.bind(this)}
|
|
543
|
+
>
|
|
544
|
+
Select token
|
|
545
|
+
</wui-button>`;
|
|
546
|
+
}
|
|
547
|
+
return x`
|
|
548
|
+
<wui-flex
|
|
549
|
+
class="swap-token-button"
|
|
550
|
+
flexDirection="column"
|
|
551
|
+
alignItems="flex-end"
|
|
552
|
+
justifyContent="center"
|
|
553
|
+
gap="xxs"
|
|
554
|
+
>
|
|
555
|
+
<wui-token-button
|
|
556
|
+
data-testid="swap-input-token-${this.target}"
|
|
557
|
+
text=${this.token.symbol}
|
|
558
|
+
imageSrc=${this.token.logoUri}
|
|
559
|
+
@click=${this.onSelectToken.bind(this)}
|
|
560
|
+
>
|
|
561
|
+
</wui-token-button>
|
|
562
|
+
<wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex>
|
|
563
|
+
</wui-flex>
|
|
564
|
+
`;
|
|
565
|
+
}
|
|
566
|
+
tokenBalanceTemplate() {
|
|
567
|
+
const balanceValueInUSD = NumberUtil.multiply(this.balance, this.price);
|
|
568
|
+
const haveBalance = balanceValueInUSD ? balanceValueInUSD == null ? void 0 : balanceValueInUSD.gt(MINIMUM_USD_VALUE_TO_CONVERT) : false;
|
|
569
|
+
return x`
|
|
570
|
+
${haveBalance ? x`<wui-text variant="small-400" color="fg-200">
|
|
571
|
+
${UiHelperUtil.formatNumberToLocalString(this.balance, 2)}
|
|
572
|
+
</wui-text>` : null}
|
|
573
|
+
${this.target === "sourceToken" ? this.tokenActionButtonTemplate(haveBalance) : null}
|
|
574
|
+
`;
|
|
575
|
+
}
|
|
576
|
+
tokenActionButtonTemplate(haveBalance) {
|
|
577
|
+
if (haveBalance) {
|
|
578
|
+
return x` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
|
|
579
|
+
<wui-text color="accent-100" variant="small-600">Max</wui-text>
|
|
580
|
+
</button>`;
|
|
581
|
+
}
|
|
582
|
+
return x` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
|
|
583
|
+
<wui-text color="accent-100" variant="small-600">Buy</wui-text>
|
|
584
|
+
</button>`;
|
|
585
|
+
}
|
|
586
|
+
onFocusChange(state) {
|
|
587
|
+
this.focused = state;
|
|
588
|
+
}
|
|
589
|
+
onSelectToken() {
|
|
590
|
+
EventsController.sendEvent({ type: "track", event: "CLICK_SELECT_TOKEN_TO_SWAP" });
|
|
591
|
+
RouterController.push("SwapSelectToken", {
|
|
592
|
+
target: this.target
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
onBuyToken() {
|
|
596
|
+
RouterController.push("OnRampProviders");
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
W3mSwapInput.styles = [styles$4];
|
|
600
|
+
__decorate$4([
|
|
601
|
+
n()
|
|
602
|
+
], W3mSwapInput.prototype, "focused", void 0);
|
|
603
|
+
__decorate$4([
|
|
604
|
+
n()
|
|
605
|
+
], W3mSwapInput.prototype, "balance", void 0);
|
|
606
|
+
__decorate$4([
|
|
607
|
+
n()
|
|
608
|
+
], W3mSwapInput.prototype, "value", void 0);
|
|
609
|
+
__decorate$4([
|
|
610
|
+
n()
|
|
611
|
+
], W3mSwapInput.prototype, "price", void 0);
|
|
612
|
+
__decorate$4([
|
|
613
|
+
n()
|
|
614
|
+
], W3mSwapInput.prototype, "marketValue", void 0);
|
|
615
|
+
__decorate$4([
|
|
616
|
+
n()
|
|
617
|
+
], W3mSwapInput.prototype, "disabled", void 0);
|
|
618
|
+
__decorate$4([
|
|
619
|
+
n()
|
|
620
|
+
], W3mSwapInput.prototype, "target", void 0);
|
|
621
|
+
__decorate$4([
|
|
622
|
+
n()
|
|
623
|
+
], W3mSwapInput.prototype, "token", void 0);
|
|
624
|
+
__decorate$4([
|
|
625
|
+
n()
|
|
626
|
+
], W3mSwapInput.prototype, "onSetAmount", void 0);
|
|
627
|
+
__decorate$4([
|
|
628
|
+
n()
|
|
629
|
+
], W3mSwapInput.prototype, "onSetMaxValue", void 0);
|
|
630
|
+
W3mSwapInput = __decorate$4([
|
|
631
|
+
customElement("w3m-swap-input")
|
|
632
|
+
], W3mSwapInput);
|
|
633
|
+
const styles$3 = i`
|
|
634
|
+
:host > wui-flex:first-child {
|
|
635
|
+
overflow-y: auto;
|
|
636
|
+
overflow-x: hidden;
|
|
637
|
+
scrollbar-width: none;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
641
|
+
display: none;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
wui-loading-hexagon {
|
|
645
|
+
position: absolute;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.action-button {
|
|
649
|
+
width: 100%;
|
|
650
|
+
border-radius: var(--wui-border-radius-xs);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.action-button:disabled {
|
|
654
|
+
border-color: 1px solid var(--wui-color-gray-glass-005);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.swap-inputs-container {
|
|
658
|
+
position: relative;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.replace-tokens-button-container {
|
|
662
|
+
display: flex;
|
|
663
|
+
justify-content: center;
|
|
664
|
+
align-items: center;
|
|
665
|
+
position: absolute;
|
|
666
|
+
top: 50%;
|
|
667
|
+
left: 50%;
|
|
668
|
+
transform: translate(-50%, -50%);
|
|
669
|
+
gap: var(--wui-spacing-1xs);
|
|
670
|
+
border-radius: var(--wui-border-radius-xs);
|
|
671
|
+
background-color: var(--wui-color-modal-bg-base);
|
|
672
|
+
padding: var(--wui-spacing-xxs);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
.replace-tokens-button-container > button {
|
|
676
|
+
display: flex;
|
|
677
|
+
justify-content: center;
|
|
678
|
+
align-items: center;
|
|
679
|
+
height: 40px;
|
|
680
|
+
width: 40px;
|
|
681
|
+
padding: var(--wui-spacing-xs);
|
|
682
|
+
border: none;
|
|
683
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
684
|
+
background: var(--wui-color-gray-glass-002);
|
|
685
|
+
transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1);
|
|
686
|
+
will-change: background-color;
|
|
687
|
+
z-index: 20;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.replace-tokens-button-container > button:hover {
|
|
691
|
+
background: var(--wui-color-gray-glass-005);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.details-container > wui-flex {
|
|
695
|
+
background: var(--wui-color-gray-glass-002);
|
|
696
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
697
|
+
width: 100%;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.details-container > wui-flex > button {
|
|
701
|
+
border: none;
|
|
702
|
+
background: none;
|
|
703
|
+
padding: var(--wui-spacing-s);
|
|
704
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
705
|
+
transition: background 0.2s linear;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.details-container > wui-flex > button:hover {
|
|
709
|
+
background: var(--wui-color-gray-glass-002);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.details-content-container {
|
|
713
|
+
padding: var(--wui-spacing-1xs);
|
|
714
|
+
display: flex;
|
|
715
|
+
align-items: center;
|
|
716
|
+
justify-content: center;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.details-content-container > wui-flex {
|
|
720
|
+
width: 100%;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.details-row {
|
|
724
|
+
width: 100%;
|
|
725
|
+
padding: var(--wui-spacing-s) var(--wui-spacing-xl);
|
|
726
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
727
|
+
background: var(--wui-color-gray-glass-002);
|
|
728
|
+
}
|
|
729
|
+
`;
|
|
730
|
+
var __decorate$3 = function(decorators, target, key, desc) {
|
|
731
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
732
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
733
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
734
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
735
|
+
};
|
|
736
|
+
let W3mSwapView = class W3mSwapView2 extends i$1 {
|
|
737
|
+
constructor() {
|
|
738
|
+
var _a, _b;
|
|
739
|
+
super();
|
|
740
|
+
this.unsubscribe = [];
|
|
741
|
+
this.initialParams = (_a = RouterController.state.data) == null ? void 0 : _a.swap;
|
|
742
|
+
this.detailsOpen = false;
|
|
743
|
+
this.caipAddress = AccountController.state.caipAddress;
|
|
744
|
+
this.caipNetworkId = (_b = ChainController.state.activeCaipNetwork) == null ? void 0 : _b.caipNetworkId;
|
|
745
|
+
this.initialized = SwapController.state.initialized;
|
|
746
|
+
this.loadingQuote = SwapController.state.loadingQuote;
|
|
747
|
+
this.loadingPrices = SwapController.state.loadingPrices;
|
|
748
|
+
this.loadingTransaction = SwapController.state.loadingTransaction;
|
|
749
|
+
this.sourceToken = SwapController.state.sourceToken;
|
|
750
|
+
this.sourceTokenAmount = SwapController.state.sourceTokenAmount;
|
|
751
|
+
this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
|
|
752
|
+
this.toToken = SwapController.state.toToken;
|
|
753
|
+
this.toTokenAmount = SwapController.state.toTokenAmount;
|
|
754
|
+
this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
|
|
755
|
+
this.inputError = SwapController.state.inputError;
|
|
756
|
+
this.fetchError = SwapController.state.fetchError;
|
|
757
|
+
this.onDebouncedGetSwapCalldata = CoreHelperUtil.debounce(async () => {
|
|
758
|
+
await SwapController.swapTokens();
|
|
759
|
+
}, 200);
|
|
760
|
+
ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => this.onCaipNetworkChange({
|
|
761
|
+
newCaipNetwork,
|
|
762
|
+
resetSwapState: true,
|
|
763
|
+
initializeSwapState: false
|
|
764
|
+
}));
|
|
765
|
+
AccountController.subscribeKey("caipAddress", (newCaipAddress) => this.onCaipAddressChange({
|
|
766
|
+
newCaipAddress,
|
|
767
|
+
resetSwapState: true,
|
|
768
|
+
initializeSwapState: false
|
|
769
|
+
}));
|
|
770
|
+
this.unsubscribe.push(...[
|
|
771
|
+
ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => this.onCaipNetworkChange({
|
|
772
|
+
newCaipNetwork,
|
|
773
|
+
resetSwapState: false,
|
|
774
|
+
initializeSwapState: true
|
|
775
|
+
})),
|
|
776
|
+
AccountController.subscribeKey("caipAddress", (newCaipAddress) => this.onCaipAddressChange({
|
|
777
|
+
newCaipAddress,
|
|
778
|
+
resetSwapState: false,
|
|
779
|
+
initializeSwapState: true
|
|
780
|
+
})),
|
|
781
|
+
ModalController.subscribeKey("open", (isOpen) => {
|
|
782
|
+
if (!isOpen) {
|
|
783
|
+
SwapController.resetState();
|
|
784
|
+
}
|
|
785
|
+
}),
|
|
786
|
+
RouterController.subscribeKey("view", (newRoute) => {
|
|
787
|
+
if (!newRoute.includes("Swap")) {
|
|
788
|
+
SwapController.resetValues();
|
|
789
|
+
}
|
|
790
|
+
}),
|
|
791
|
+
SwapController.subscribe((newState) => {
|
|
792
|
+
this.initialized = newState.initialized;
|
|
793
|
+
this.loadingQuote = newState.loadingQuote;
|
|
794
|
+
this.loadingPrices = newState.loadingPrices;
|
|
795
|
+
this.loadingTransaction = newState.loadingTransaction;
|
|
796
|
+
this.sourceToken = newState.sourceToken;
|
|
797
|
+
this.sourceTokenAmount = newState.sourceTokenAmount;
|
|
798
|
+
this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
|
|
799
|
+
this.toToken = newState.toToken;
|
|
800
|
+
this.toTokenAmount = newState.toTokenAmount;
|
|
801
|
+
this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
|
|
802
|
+
this.inputError = newState.inputError;
|
|
803
|
+
this.fetchError = newState.fetchError;
|
|
804
|
+
})
|
|
805
|
+
]);
|
|
806
|
+
}
|
|
807
|
+
async firstUpdated() {
|
|
808
|
+
SwapController.initializeState();
|
|
809
|
+
this.watchTokensAndValues();
|
|
810
|
+
await this.handleSwapParameters();
|
|
811
|
+
}
|
|
812
|
+
disconnectedCallback() {
|
|
813
|
+
this.unsubscribe.forEach((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe());
|
|
814
|
+
clearInterval(this.interval);
|
|
815
|
+
}
|
|
816
|
+
render() {
|
|
817
|
+
return x`
|
|
818
|
+
<wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
|
|
819
|
+
${this.initialized ? this.templateSwap() : this.templateLoading()}
|
|
820
|
+
</wui-flex>
|
|
821
|
+
`;
|
|
822
|
+
}
|
|
823
|
+
watchTokensAndValues() {
|
|
824
|
+
this.interval = setInterval(() => {
|
|
825
|
+
SwapController.getNetworkTokenPrice();
|
|
826
|
+
SwapController.getMyTokensWithBalance();
|
|
827
|
+
SwapController.swapTokens();
|
|
828
|
+
}, 1e4);
|
|
829
|
+
}
|
|
830
|
+
templateSwap() {
|
|
831
|
+
return x`
|
|
832
|
+
<wui-flex flexDirection="column" gap="s">
|
|
833
|
+
<wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
|
|
834
|
+
${this.templateTokenInput("sourceToken", this.sourceToken)}
|
|
835
|
+
${this.templateTokenInput("toToken", this.toToken)} ${this.templateReplaceTokensButton()}
|
|
836
|
+
</wui-flex>
|
|
837
|
+
${this.templateDetails()} ${this.templateActionButton()}
|
|
838
|
+
</wui-flex>
|
|
839
|
+
`;
|
|
840
|
+
}
|
|
841
|
+
actionButtonLabel() {
|
|
842
|
+
if (this.fetchError) {
|
|
843
|
+
return "Swap";
|
|
844
|
+
}
|
|
845
|
+
if (!this.sourceToken || !this.toToken) {
|
|
846
|
+
return "Select token";
|
|
847
|
+
}
|
|
848
|
+
if (!this.sourceTokenAmount) {
|
|
849
|
+
return "Enter amount";
|
|
850
|
+
}
|
|
851
|
+
if (this.inputError) {
|
|
852
|
+
return this.inputError;
|
|
853
|
+
}
|
|
854
|
+
return "Review swap";
|
|
855
|
+
}
|
|
856
|
+
templateReplaceTokensButton() {
|
|
857
|
+
return x`
|
|
858
|
+
<wui-flex class="replace-tokens-button-container">
|
|
859
|
+
<button @click=${this.onSwitchTokens.bind(this)}>
|
|
860
|
+
<wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon>
|
|
861
|
+
</button>
|
|
862
|
+
</wui-flex>
|
|
863
|
+
`;
|
|
864
|
+
}
|
|
865
|
+
templateLoading() {
|
|
866
|
+
return x`
|
|
867
|
+
<wui-flex flexDirection="column" gap="l">
|
|
868
|
+
<wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
|
|
869
|
+
<w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
|
|
870
|
+
<w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
|
|
871
|
+
${this.templateReplaceTokensButton()}
|
|
872
|
+
</wui-flex>
|
|
873
|
+
${this.templateActionButton()}
|
|
874
|
+
</wui-flex>
|
|
875
|
+
`;
|
|
876
|
+
}
|
|
877
|
+
templateTokenInput(target, token) {
|
|
878
|
+
var _a, _b;
|
|
879
|
+
const myToken = (_a = SwapController.state.myTokensWithBalance) == null ? void 0 : _a.find((ct) => (ct == null ? void 0 : ct.address) === (token == null ? void 0 : token.address));
|
|
880
|
+
const amount = target === "toToken" ? this.toTokenAmount : this.sourceTokenAmount;
|
|
881
|
+
const price = target === "toToken" ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD;
|
|
882
|
+
const marketValue = NumberUtil.parseLocalStringToNumber(amount) * price;
|
|
883
|
+
return x`<w3m-swap-input
|
|
884
|
+
.value=${target === "toToken" ? this.toTokenAmount : this.sourceTokenAmount}
|
|
885
|
+
.disabled=${target === "toToken"}
|
|
886
|
+
.onSetAmount=${this.handleChangeAmount.bind(this)}
|
|
887
|
+
target=${target}
|
|
888
|
+
.token=${token}
|
|
889
|
+
.balance=${(_b = myToken == null ? void 0 : myToken.quantity) == null ? void 0 : _b.numeric}
|
|
890
|
+
.price=${myToken == null ? void 0 : myToken.price}
|
|
891
|
+
.marketValue=${marketValue}
|
|
892
|
+
.onSetMaxValue=${this.onSetMaxValue.bind(this)}
|
|
893
|
+
></w3m-swap-input>`;
|
|
894
|
+
}
|
|
895
|
+
onSetMaxValue(target, balance) {
|
|
896
|
+
const maxValue = NumberUtil.bigNumber(balance || "0");
|
|
897
|
+
this.handleChangeAmount(target, maxValue.gt(0) ? maxValue.toFixed(20) : "0");
|
|
898
|
+
}
|
|
899
|
+
templateDetails() {
|
|
900
|
+
if (!this.sourceToken || !this.toToken || this.inputError) {
|
|
901
|
+
return null;
|
|
902
|
+
}
|
|
903
|
+
return x`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
|
|
904
|
+
}
|
|
905
|
+
handleChangeAmount(target, value) {
|
|
906
|
+
SwapController.clearError();
|
|
907
|
+
if (target === "sourceToken") {
|
|
908
|
+
SwapController.setSourceTokenAmount(value);
|
|
909
|
+
} else {
|
|
910
|
+
SwapController.setToTokenAmount(value);
|
|
911
|
+
}
|
|
912
|
+
this.onDebouncedGetSwapCalldata();
|
|
913
|
+
}
|
|
914
|
+
templateActionButton() {
|
|
915
|
+
const haveNoTokenSelected = !this.toToken || !this.sourceToken;
|
|
916
|
+
const haveNoAmount = !this.sourceTokenAmount;
|
|
917
|
+
const loading = this.loadingQuote || this.loadingPrices || this.loadingTransaction;
|
|
918
|
+
const disabled = loading || haveNoTokenSelected || haveNoAmount || this.inputError;
|
|
919
|
+
return x` <wui-flex gap="xs">
|
|
920
|
+
<wui-button
|
|
921
|
+
data-testid="swap-action-button"
|
|
922
|
+
class="action-button"
|
|
923
|
+
fullWidth
|
|
924
|
+
size="lg"
|
|
925
|
+
borderRadius="xs"
|
|
926
|
+
variant=${haveNoTokenSelected ? "neutral" : "main"}
|
|
927
|
+
.loading=${loading}
|
|
928
|
+
.disabled=${disabled}
|
|
929
|
+
@click=${this.onSwapPreview.bind(this)}
|
|
930
|
+
>
|
|
931
|
+
${this.actionButtonLabel()}
|
|
932
|
+
</wui-button>
|
|
933
|
+
</wui-flex>`;
|
|
934
|
+
}
|
|
935
|
+
onSwitchTokens() {
|
|
936
|
+
SwapController.switchTokens();
|
|
937
|
+
}
|
|
938
|
+
async onSwapPreview() {
|
|
939
|
+
var _a, _b;
|
|
940
|
+
const activeChainNamespace = ChainController.state.activeChain;
|
|
941
|
+
if (this.fetchError) {
|
|
942
|
+
await SwapController.swapTokens();
|
|
943
|
+
}
|
|
944
|
+
EventsController.sendEvent({
|
|
945
|
+
type: "track",
|
|
946
|
+
event: "INITIATE_SWAP",
|
|
947
|
+
properties: {
|
|
948
|
+
network: this.caipNetworkId || "",
|
|
949
|
+
swapFromToken: ((_a = this.sourceToken) == null ? void 0 : _a.symbol) || "",
|
|
950
|
+
swapToToken: ((_b = this.toToken) == null ? void 0 : _b.symbol) || "",
|
|
951
|
+
swapFromAmount: this.sourceTokenAmount || "",
|
|
952
|
+
swapToAmount: this.toTokenAmount || "",
|
|
953
|
+
isSmartAccount: getPreferredAccountType(activeChainNamespace) === W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
RouterController.push("SwapPreview");
|
|
957
|
+
}
|
|
958
|
+
async handleSwapParameters() {
|
|
959
|
+
if (!this.initialParams) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
if (!SwapController.state.initialized) {
|
|
963
|
+
const waitForInitialization = new Promise((resolve) => {
|
|
964
|
+
const unsubscribe = SwapController.subscribeKey("initialized", (initialized) => {
|
|
965
|
+
if (initialized) {
|
|
966
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
967
|
+
resolve();
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
});
|
|
971
|
+
await waitForInitialization;
|
|
972
|
+
}
|
|
973
|
+
await this.setSwapParameters(this.initialParams);
|
|
974
|
+
}
|
|
975
|
+
async setSwapParameters({ amount, fromToken, toToken }) {
|
|
976
|
+
if (!SwapController.state.tokens || !SwapController.state.myTokensWithBalance) {
|
|
977
|
+
const waitForTokens = new Promise((resolve) => {
|
|
978
|
+
const unsubscribe = SwapController.subscribeKey("myTokensWithBalance", (tokens) => {
|
|
979
|
+
if (tokens && tokens.length > 0) {
|
|
980
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
981
|
+
resolve();
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
setTimeout(() => {
|
|
985
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
986
|
+
resolve();
|
|
987
|
+
}, 5e3);
|
|
988
|
+
});
|
|
989
|
+
await waitForTokens;
|
|
990
|
+
}
|
|
991
|
+
const allTokens = [
|
|
992
|
+
...SwapController.state.tokens || [],
|
|
993
|
+
...SwapController.state.myTokensWithBalance || []
|
|
994
|
+
];
|
|
995
|
+
if (fromToken) {
|
|
996
|
+
const token = allTokens.find((t) => t.symbol.toLowerCase() === fromToken.toLowerCase());
|
|
997
|
+
if (token) {
|
|
998
|
+
SwapController.setSourceToken(token);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (toToken) {
|
|
1002
|
+
const token = allTokens.find((t) => t.symbol.toLowerCase() === toToken.toLowerCase());
|
|
1003
|
+
if (token) {
|
|
1004
|
+
SwapController.setToToken(token);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
if (amount && !isNaN(Number(amount))) {
|
|
1008
|
+
SwapController.setSourceTokenAmount(amount);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
onCaipAddressChange({ newCaipAddress, resetSwapState, initializeSwapState }) {
|
|
1012
|
+
if (this.caipAddress !== newCaipAddress) {
|
|
1013
|
+
this.caipAddress = newCaipAddress;
|
|
1014
|
+
if (resetSwapState) {
|
|
1015
|
+
SwapController.resetState();
|
|
1016
|
+
}
|
|
1017
|
+
if (initializeSwapState) {
|
|
1018
|
+
SwapController.initializeState();
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
onCaipNetworkChange({ newCaipNetwork, resetSwapState, initializeSwapState }) {
|
|
1023
|
+
if (this.caipNetworkId !== (newCaipNetwork == null ? void 0 : newCaipNetwork.caipNetworkId)) {
|
|
1024
|
+
this.caipNetworkId = newCaipNetwork == null ? void 0 : newCaipNetwork.caipNetworkId;
|
|
1025
|
+
if (resetSwapState) {
|
|
1026
|
+
SwapController.resetState();
|
|
1027
|
+
}
|
|
1028
|
+
if (initializeSwapState) {
|
|
1029
|
+
SwapController.initializeState();
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
W3mSwapView.styles = styles$3;
|
|
1035
|
+
__decorate$3([
|
|
1036
|
+
n({ type: Object })
|
|
1037
|
+
], W3mSwapView.prototype, "initialParams", void 0);
|
|
1038
|
+
__decorate$3([
|
|
1039
|
+
r()
|
|
1040
|
+
], W3mSwapView.prototype, "interval", void 0);
|
|
1041
|
+
__decorate$3([
|
|
1042
|
+
r()
|
|
1043
|
+
], W3mSwapView.prototype, "detailsOpen", void 0);
|
|
1044
|
+
__decorate$3([
|
|
1045
|
+
r()
|
|
1046
|
+
], W3mSwapView.prototype, "caipAddress", void 0);
|
|
1047
|
+
__decorate$3([
|
|
1048
|
+
r()
|
|
1049
|
+
], W3mSwapView.prototype, "caipNetworkId", void 0);
|
|
1050
|
+
__decorate$3([
|
|
1051
|
+
r()
|
|
1052
|
+
], W3mSwapView.prototype, "initialized", void 0);
|
|
1053
|
+
__decorate$3([
|
|
1054
|
+
r()
|
|
1055
|
+
], W3mSwapView.prototype, "loadingQuote", void 0);
|
|
1056
|
+
__decorate$3([
|
|
1057
|
+
r()
|
|
1058
|
+
], W3mSwapView.prototype, "loadingPrices", void 0);
|
|
1059
|
+
__decorate$3([
|
|
1060
|
+
r()
|
|
1061
|
+
], W3mSwapView.prototype, "loadingTransaction", void 0);
|
|
1062
|
+
__decorate$3([
|
|
1063
|
+
r()
|
|
1064
|
+
], W3mSwapView.prototype, "sourceToken", void 0);
|
|
1065
|
+
__decorate$3([
|
|
1066
|
+
r()
|
|
1067
|
+
], W3mSwapView.prototype, "sourceTokenAmount", void 0);
|
|
1068
|
+
__decorate$3([
|
|
1069
|
+
r()
|
|
1070
|
+
], W3mSwapView.prototype, "sourceTokenPriceInUSD", void 0);
|
|
1071
|
+
__decorate$3([
|
|
1072
|
+
r()
|
|
1073
|
+
], W3mSwapView.prototype, "toToken", void 0);
|
|
1074
|
+
__decorate$3([
|
|
1075
|
+
r()
|
|
1076
|
+
], W3mSwapView.prototype, "toTokenAmount", void 0);
|
|
1077
|
+
__decorate$3([
|
|
1078
|
+
r()
|
|
1079
|
+
], W3mSwapView.prototype, "toTokenPriceInUSD", void 0);
|
|
1080
|
+
__decorate$3([
|
|
1081
|
+
r()
|
|
1082
|
+
], W3mSwapView.prototype, "inputError", void 0);
|
|
1083
|
+
__decorate$3([
|
|
1084
|
+
r()
|
|
1085
|
+
], W3mSwapView.prototype, "fetchError", void 0);
|
|
1086
|
+
W3mSwapView = __decorate$3([
|
|
1087
|
+
customElement("w3m-swap-view")
|
|
1088
|
+
], W3mSwapView);
|
|
1089
|
+
const styles$2 = i`
|
|
1090
|
+
:host > wui-flex:first-child {
|
|
1091
|
+
overflow-y: auto;
|
|
1092
|
+
overflow-x: hidden;
|
|
1093
|
+
scrollbar-width: none;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
1097
|
+
display: none;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
.preview-container,
|
|
1101
|
+
.details-container {
|
|
1102
|
+
width: 100%;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
.token-image {
|
|
1106
|
+
width: 24px;
|
|
1107
|
+
height: 24px;
|
|
1108
|
+
box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005);
|
|
1109
|
+
border-radius: 12px;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
wui-loading-hexagon {
|
|
1113
|
+
position: absolute;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
.token-item {
|
|
1117
|
+
display: flex;
|
|
1118
|
+
align-items: center;
|
|
1119
|
+
justify-content: center;
|
|
1120
|
+
gap: var(--wui-spacing-xxs);
|
|
1121
|
+
padding: var(--wui-spacing-xs);
|
|
1122
|
+
height: 40px;
|
|
1123
|
+
border: none;
|
|
1124
|
+
border-radius: 80px;
|
|
1125
|
+
background: var(--wui-color-gray-glass-002);
|
|
1126
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
|
|
1127
|
+
cursor: pointer;
|
|
1128
|
+
transition: background 0.2s linear;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
.token-item:hover {
|
|
1132
|
+
background: var(--wui-color-gray-glass-005);
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
.preview-token-details-container {
|
|
1136
|
+
width: 100%;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
.details-row {
|
|
1140
|
+
width: 100%;
|
|
1141
|
+
padding: var(--wui-spacing-s) var(--wui-spacing-xl);
|
|
1142
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
1143
|
+
background: var(--wui-color-gray-glass-002);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
.action-buttons-container {
|
|
1147
|
+
width: 100%;
|
|
1148
|
+
gap: var(--wui-spacing-xs);
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
.action-buttons-container > button {
|
|
1152
|
+
display: flex;
|
|
1153
|
+
align-items: center;
|
|
1154
|
+
justify-content: center;
|
|
1155
|
+
background: transparent;
|
|
1156
|
+
height: 48px;
|
|
1157
|
+
border-radius: var(--wui-border-radius-xs);
|
|
1158
|
+
border: none;
|
|
1159
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
.action-buttons-container > button:disabled {
|
|
1163
|
+
opacity: 0.8;
|
|
1164
|
+
cursor: not-allowed;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
.action-button > wui-loading-spinner {
|
|
1168
|
+
display: inline-block;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
.cancel-button:hover,
|
|
1172
|
+
.action-button:hover {
|
|
1173
|
+
cursor: pointer;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
.action-buttons-container > wui-button.cancel-button {
|
|
1177
|
+
flex: 2;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.action-buttons-container > wui-button.action-button {
|
|
1181
|
+
flex: 4;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.action-buttons-container > button.action-button > wui-text {
|
|
1185
|
+
color: white;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
.details-container > wui-flex {
|
|
1189
|
+
background: var(--wui-color-gray-glass-002);
|
|
1190
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
1191
|
+
width: 100%;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
.details-container > wui-flex > button {
|
|
1195
|
+
border: none;
|
|
1196
|
+
background: none;
|
|
1197
|
+
padding: var(--wui-spacing-s);
|
|
1198
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
1199
|
+
transition: background 0.2s linear;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
.details-container > wui-flex > button:hover {
|
|
1203
|
+
background: var(--wui-color-gray-glass-002);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
.details-content-container {
|
|
1207
|
+
padding: var(--wui-spacing-1xs);
|
|
1208
|
+
display: flex;
|
|
1209
|
+
align-items: center;
|
|
1210
|
+
justify-content: center;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
.details-content-container > wui-flex {
|
|
1214
|
+
width: 100%;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
.details-row {
|
|
1218
|
+
width: 100%;
|
|
1219
|
+
padding: var(--wui-spacing-s) var(--wui-spacing-xl);
|
|
1220
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
1221
|
+
background: var(--wui-color-gray-glass-002);
|
|
1222
|
+
}
|
|
1223
|
+
`;
|
|
1224
|
+
var __decorate$2 = function(decorators, target, key, desc) {
|
|
1225
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1226
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
1227
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
1228
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
1229
|
+
};
|
|
1230
|
+
let W3mSwapPreviewView = class W3mSwapPreviewView2 extends i$1 {
|
|
1231
|
+
constructor() {
|
|
1232
|
+
super();
|
|
1233
|
+
this.unsubscribe = [];
|
|
1234
|
+
this.detailsOpen = true;
|
|
1235
|
+
this.approvalTransaction = SwapController.state.approvalTransaction;
|
|
1236
|
+
this.swapTransaction = SwapController.state.swapTransaction;
|
|
1237
|
+
this.sourceToken = SwapController.state.sourceToken;
|
|
1238
|
+
this.sourceTokenAmount = SwapController.state.sourceTokenAmount ?? "";
|
|
1239
|
+
this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
|
|
1240
|
+
this.toToken = SwapController.state.toToken;
|
|
1241
|
+
this.toTokenAmount = SwapController.state.toTokenAmount ?? "";
|
|
1242
|
+
this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
|
|
1243
|
+
this.caipNetwork = ChainController.state.activeCaipNetwork;
|
|
1244
|
+
this.balanceSymbol = AccountController.state.balanceSymbol;
|
|
1245
|
+
this.inputError = SwapController.state.inputError;
|
|
1246
|
+
this.loadingQuote = SwapController.state.loadingQuote;
|
|
1247
|
+
this.loadingApprovalTransaction = SwapController.state.loadingApprovalTransaction;
|
|
1248
|
+
this.loadingBuildTransaction = SwapController.state.loadingBuildTransaction;
|
|
1249
|
+
this.loadingTransaction = SwapController.state.loadingTransaction;
|
|
1250
|
+
this.unsubscribe.push(...[
|
|
1251
|
+
AccountController.subscribeKey("balanceSymbol", (newBalanceSymbol) => {
|
|
1252
|
+
if (this.balanceSymbol !== newBalanceSymbol) {
|
|
1253
|
+
RouterController.goBack();
|
|
1254
|
+
}
|
|
1255
|
+
}),
|
|
1256
|
+
ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => {
|
|
1257
|
+
if (this.caipNetwork !== newCaipNetwork) {
|
|
1258
|
+
this.caipNetwork = newCaipNetwork;
|
|
1259
|
+
}
|
|
1260
|
+
}),
|
|
1261
|
+
SwapController.subscribe((newState) => {
|
|
1262
|
+
this.approvalTransaction = newState.approvalTransaction;
|
|
1263
|
+
this.swapTransaction = newState.swapTransaction;
|
|
1264
|
+
this.sourceToken = newState.sourceToken;
|
|
1265
|
+
this.toToken = newState.toToken;
|
|
1266
|
+
this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
|
|
1267
|
+
this.sourceTokenAmount = newState.sourceTokenAmount ?? "";
|
|
1268
|
+
this.toTokenAmount = newState.toTokenAmount ?? "";
|
|
1269
|
+
this.inputError = newState.inputError;
|
|
1270
|
+
if (newState.inputError) {
|
|
1271
|
+
RouterController.goBack();
|
|
1272
|
+
}
|
|
1273
|
+
this.loadingQuote = newState.loadingQuote;
|
|
1274
|
+
this.loadingApprovalTransaction = newState.loadingApprovalTransaction;
|
|
1275
|
+
this.loadingBuildTransaction = newState.loadingBuildTransaction;
|
|
1276
|
+
this.loadingTransaction = newState.loadingTransaction;
|
|
1277
|
+
})
|
|
1278
|
+
]);
|
|
1279
|
+
}
|
|
1280
|
+
firstUpdated() {
|
|
1281
|
+
SwapController.getTransaction();
|
|
1282
|
+
this.refreshTransaction();
|
|
1283
|
+
}
|
|
1284
|
+
disconnectedCallback() {
|
|
1285
|
+
this.unsubscribe.forEach((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe());
|
|
1286
|
+
clearInterval(this.interval);
|
|
1287
|
+
}
|
|
1288
|
+
render() {
|
|
1289
|
+
return x`
|
|
1290
|
+
<wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
|
|
1291
|
+
${this.templateSwap()}
|
|
1292
|
+
</wui-flex>
|
|
1293
|
+
`;
|
|
1294
|
+
}
|
|
1295
|
+
refreshTransaction() {
|
|
1296
|
+
this.interval = setInterval(() => {
|
|
1297
|
+
if (!SwapController.getApprovalLoadingState()) {
|
|
1298
|
+
SwapController.getTransaction();
|
|
1299
|
+
}
|
|
1300
|
+
}, 1e4);
|
|
1301
|
+
}
|
|
1302
|
+
templateSwap() {
|
|
1303
|
+
var _a, _b, _c, _d;
|
|
1304
|
+
const sourceTokenText = `${UiHelperUtil.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(_a = this.sourceToken) == null ? void 0 : _a.symbol}`;
|
|
1305
|
+
const toTokenText = `${UiHelperUtil.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(_b = this.toToken) == null ? void 0 : _b.symbol}`;
|
|
1306
|
+
const sourceTokenValue = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD;
|
|
1307
|
+
const toTokenValue = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD;
|
|
1308
|
+
const sentPrice = UiHelperUtil.formatNumberToLocalString(sourceTokenValue);
|
|
1309
|
+
const receivePrice = UiHelperUtil.formatNumberToLocalString(toTokenValue);
|
|
1310
|
+
const loading = this.loadingQuote || this.loadingBuildTransaction || this.loadingTransaction || this.loadingApprovalTransaction;
|
|
1311
|
+
return x`
|
|
1312
|
+
<wui-flex flexDirection="column" alignItems="center" gap="l">
|
|
1313
|
+
<wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l">
|
|
1314
|
+
<wui-flex
|
|
1315
|
+
class="preview-token-details-container"
|
|
1316
|
+
alignItems="center"
|
|
1317
|
+
justifyContent="space-between"
|
|
1318
|
+
gap="l"
|
|
1319
|
+
>
|
|
1320
|
+
<wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
|
|
1321
|
+
<wui-text variant="small-400" color="fg-150">Send</wui-text>
|
|
1322
|
+
<wui-text variant="paragraph-400" color="fg-100">$${sentPrice}</wui-text>
|
|
1323
|
+
</wui-flex>
|
|
1324
|
+
<wui-token-button
|
|
1325
|
+
flexDirection="row-reverse"
|
|
1326
|
+
text=${sourceTokenText}
|
|
1327
|
+
imageSrc=${(_c = this.sourceToken) == null ? void 0 : _c.logoUri}
|
|
1328
|
+
>
|
|
1329
|
+
</wui-token-button>
|
|
1330
|
+
</wui-flex>
|
|
1331
|
+
<wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon>
|
|
1332
|
+
<wui-flex
|
|
1333
|
+
class="preview-token-details-container"
|
|
1334
|
+
alignItems="center"
|
|
1335
|
+
justifyContent="space-between"
|
|
1336
|
+
gap="l"
|
|
1337
|
+
>
|
|
1338
|
+
<wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
|
|
1339
|
+
<wui-text variant="small-400" color="fg-150">Receive</wui-text>
|
|
1340
|
+
<wui-text variant="paragraph-400" color="fg-100">$${receivePrice}</wui-text>
|
|
1341
|
+
</wui-flex>
|
|
1342
|
+
<wui-token-button
|
|
1343
|
+
flexDirection="row-reverse"
|
|
1344
|
+
text=${toTokenText}
|
|
1345
|
+
imageSrc=${(_d = this.toToken) == null ? void 0 : _d.logoUri}
|
|
1346
|
+
>
|
|
1347
|
+
</wui-token-button>
|
|
1348
|
+
</wui-flex>
|
|
1349
|
+
</wui-flex>
|
|
1350
|
+
|
|
1351
|
+
${this.templateDetails()}
|
|
1352
|
+
|
|
1353
|
+
<wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs">
|
|
1354
|
+
<wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon>
|
|
1355
|
+
<wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text>
|
|
1356
|
+
</wui-flex>
|
|
1357
|
+
|
|
1358
|
+
<wui-flex
|
|
1359
|
+
class="action-buttons-container"
|
|
1360
|
+
flexDirection="row"
|
|
1361
|
+
alignItems="center"
|
|
1362
|
+
justifyContent="space-between"
|
|
1363
|
+
gap="xs"
|
|
1364
|
+
>
|
|
1365
|
+
<wui-button
|
|
1366
|
+
class="cancel-button"
|
|
1367
|
+
fullWidth
|
|
1368
|
+
size="lg"
|
|
1369
|
+
borderRadius="xs"
|
|
1370
|
+
variant="neutral"
|
|
1371
|
+
@click=${this.onCancelTransaction.bind(this)}
|
|
1372
|
+
>
|
|
1373
|
+
<wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text>
|
|
1374
|
+
</wui-button>
|
|
1375
|
+
<wui-button
|
|
1376
|
+
class="action-button"
|
|
1377
|
+
fullWidth
|
|
1378
|
+
size="lg"
|
|
1379
|
+
borderRadius="xs"
|
|
1380
|
+
variant="main"
|
|
1381
|
+
?loading=${loading}
|
|
1382
|
+
?disabled=${loading}
|
|
1383
|
+
@click=${this.onSendTransaction.bind(this)}
|
|
1384
|
+
>
|
|
1385
|
+
<wui-text variant="paragraph-600" color="inverse-100">
|
|
1386
|
+
${this.actionButtonLabel()}
|
|
1387
|
+
</wui-text>
|
|
1388
|
+
</wui-button>
|
|
1389
|
+
</wui-flex>
|
|
1390
|
+
</wui-flex>
|
|
1391
|
+
`;
|
|
1392
|
+
}
|
|
1393
|
+
templateDetails() {
|
|
1394
|
+
if (!this.sourceToken || !this.toToken || this.inputError) {
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
return x`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
|
|
1398
|
+
}
|
|
1399
|
+
actionButtonLabel() {
|
|
1400
|
+
if (this.loadingApprovalTransaction) {
|
|
1401
|
+
return "Approving...";
|
|
1402
|
+
}
|
|
1403
|
+
if (this.approvalTransaction) {
|
|
1404
|
+
return "Approve";
|
|
1405
|
+
}
|
|
1406
|
+
return "Swap";
|
|
1407
|
+
}
|
|
1408
|
+
onCancelTransaction() {
|
|
1409
|
+
RouterController.goBack();
|
|
1410
|
+
}
|
|
1411
|
+
onSendTransaction() {
|
|
1412
|
+
if (this.approvalTransaction) {
|
|
1413
|
+
SwapController.sendTransactionForApproval(this.approvalTransaction);
|
|
1414
|
+
} else {
|
|
1415
|
+
SwapController.sendTransactionForSwap(this.swapTransaction);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
W3mSwapPreviewView.styles = styles$2;
|
|
1420
|
+
__decorate$2([
|
|
1421
|
+
r()
|
|
1422
|
+
], W3mSwapPreviewView.prototype, "interval", void 0);
|
|
1423
|
+
__decorate$2([
|
|
1424
|
+
r()
|
|
1425
|
+
], W3mSwapPreviewView.prototype, "detailsOpen", void 0);
|
|
1426
|
+
__decorate$2([
|
|
1427
|
+
r()
|
|
1428
|
+
], W3mSwapPreviewView.prototype, "approvalTransaction", void 0);
|
|
1429
|
+
__decorate$2([
|
|
1430
|
+
r()
|
|
1431
|
+
], W3mSwapPreviewView.prototype, "swapTransaction", void 0);
|
|
1432
|
+
__decorate$2([
|
|
1433
|
+
r()
|
|
1434
|
+
], W3mSwapPreviewView.prototype, "sourceToken", void 0);
|
|
1435
|
+
__decorate$2([
|
|
1436
|
+
r()
|
|
1437
|
+
], W3mSwapPreviewView.prototype, "sourceTokenAmount", void 0);
|
|
1438
|
+
__decorate$2([
|
|
1439
|
+
r()
|
|
1440
|
+
], W3mSwapPreviewView.prototype, "sourceTokenPriceInUSD", void 0);
|
|
1441
|
+
__decorate$2([
|
|
1442
|
+
r()
|
|
1443
|
+
], W3mSwapPreviewView.prototype, "toToken", void 0);
|
|
1444
|
+
__decorate$2([
|
|
1445
|
+
r()
|
|
1446
|
+
], W3mSwapPreviewView.prototype, "toTokenAmount", void 0);
|
|
1447
|
+
__decorate$2([
|
|
1448
|
+
r()
|
|
1449
|
+
], W3mSwapPreviewView.prototype, "toTokenPriceInUSD", void 0);
|
|
1450
|
+
__decorate$2([
|
|
1451
|
+
r()
|
|
1452
|
+
], W3mSwapPreviewView.prototype, "caipNetwork", void 0);
|
|
1453
|
+
__decorate$2([
|
|
1454
|
+
r()
|
|
1455
|
+
], W3mSwapPreviewView.prototype, "balanceSymbol", void 0);
|
|
1456
|
+
__decorate$2([
|
|
1457
|
+
r()
|
|
1458
|
+
], W3mSwapPreviewView.prototype, "inputError", void 0);
|
|
1459
|
+
__decorate$2([
|
|
1460
|
+
r()
|
|
1461
|
+
], W3mSwapPreviewView.prototype, "loadingQuote", void 0);
|
|
1462
|
+
__decorate$2([
|
|
1463
|
+
r()
|
|
1464
|
+
], W3mSwapPreviewView.prototype, "loadingApprovalTransaction", void 0);
|
|
1465
|
+
__decorate$2([
|
|
1466
|
+
r()
|
|
1467
|
+
], W3mSwapPreviewView.prototype, "loadingBuildTransaction", void 0);
|
|
1468
|
+
__decorate$2([
|
|
1469
|
+
r()
|
|
1470
|
+
], W3mSwapPreviewView.prototype, "loadingTransaction", void 0);
|
|
1471
|
+
W3mSwapPreviewView = __decorate$2([
|
|
1472
|
+
customElement("w3m-swap-preview-view")
|
|
1473
|
+
], W3mSwapPreviewView);
|
|
1474
|
+
const styles$1 = i`
|
|
1475
|
+
:host {
|
|
1476
|
+
height: 60px;
|
|
1477
|
+
min-height: 60px;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
:host > wui-flex {
|
|
1481
|
+
cursor: pointer;
|
|
1482
|
+
height: 100%;
|
|
1483
|
+
display: flex;
|
|
1484
|
+
column-gap: var(--wui-spacing-s);
|
|
1485
|
+
padding: var(--wui-spacing-xs);
|
|
1486
|
+
padding-right: var(--wui-spacing-l);
|
|
1487
|
+
width: 100%;
|
|
1488
|
+
background-color: transparent;
|
|
1489
|
+
border-radius: var(--wui-border-radius-xs);
|
|
1490
|
+
color: var(--wui-color-fg-250);
|
|
1491
|
+
transition:
|
|
1492
|
+
background-color var(--wui-ease-out-power-1) var(--wui-duration-lg),
|
|
1493
|
+
opacity var(--wui-ease-out-power-1) var(--wui-duration-lg);
|
|
1494
|
+
will-change: background-color, opacity;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
@media (hover: hover) and (pointer: fine) {
|
|
1498
|
+
:host > wui-flex:hover {
|
|
1499
|
+
background-color: var(--wui-color-gray-glass-002);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
:host > wui-flex:active {
|
|
1503
|
+
background-color: var(--wui-color-gray-glass-005);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
:host([disabled]) > wui-flex {
|
|
1508
|
+
opacity: 0.6;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
:host([disabled]) > wui-flex:hover {
|
|
1512
|
+
background-color: transparent;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
:host > wui-flex > wui-flex {
|
|
1516
|
+
flex: 1;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
:host > wui-flex > wui-image,
|
|
1520
|
+
:host > wui-flex > .token-item-image-placeholder {
|
|
1521
|
+
width: 40px;
|
|
1522
|
+
max-width: 40px;
|
|
1523
|
+
height: 40px;
|
|
1524
|
+
border-radius: var(--wui-border-radius-3xl);
|
|
1525
|
+
position: relative;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
:host > wui-flex > .token-item-image-placeholder {
|
|
1529
|
+
display: flex;
|
|
1530
|
+
align-items: center;
|
|
1531
|
+
justify-content: center;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
:host > wui-flex > wui-image::after,
|
|
1535
|
+
:host > wui-flex > .token-item-image-placeholder::after {
|
|
1536
|
+
position: absolute;
|
|
1537
|
+
content: '';
|
|
1538
|
+
inset: 0;
|
|
1539
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
|
|
1540
|
+
border-radius: var(--wui-border-radius-l);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
button > wui-icon-box[data-variant='square-blue'] {
|
|
1544
|
+
border-radius: var(--wui-border-radius-3xs);
|
|
1545
|
+
position: relative;
|
|
1546
|
+
border: none;
|
|
1547
|
+
width: 36px;
|
|
1548
|
+
height: 36px;
|
|
1549
|
+
}
|
|
1550
|
+
`;
|
|
1551
|
+
var __decorate$1 = function(decorators, target, key, desc) {
|
|
1552
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1553
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
1554
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
1555
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
1556
|
+
};
|
|
1557
|
+
let WuiTokenListItem = class WuiTokenListItem2 extends i$1 {
|
|
1558
|
+
constructor() {
|
|
1559
|
+
super();
|
|
1560
|
+
this.observer = new IntersectionObserver(() => void 0);
|
|
1561
|
+
this.imageSrc = void 0;
|
|
1562
|
+
this.name = void 0;
|
|
1563
|
+
this.symbol = void 0;
|
|
1564
|
+
this.price = void 0;
|
|
1565
|
+
this.amount = void 0;
|
|
1566
|
+
this.visible = false;
|
|
1567
|
+
this.imageError = false;
|
|
1568
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
1569
|
+
entries.forEach((entry) => {
|
|
1570
|
+
if (entry.isIntersecting) {
|
|
1571
|
+
this.visible = true;
|
|
1572
|
+
} else {
|
|
1573
|
+
this.visible = false;
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
}, { threshold: 0.1 });
|
|
1577
|
+
}
|
|
1578
|
+
firstUpdated() {
|
|
1579
|
+
this.observer.observe(this);
|
|
1580
|
+
}
|
|
1581
|
+
disconnectedCallback() {
|
|
1582
|
+
this.observer.disconnect();
|
|
1583
|
+
}
|
|
1584
|
+
render() {
|
|
1585
|
+
var _a;
|
|
1586
|
+
if (!this.visible) {
|
|
1587
|
+
return null;
|
|
1588
|
+
}
|
|
1589
|
+
const value = this.amount && this.price ? (_a = NumberUtil.multiply(this.price, this.amount)) == null ? void 0 : _a.toFixed(3) : null;
|
|
1590
|
+
return x`
|
|
1591
|
+
<wui-flex alignItems="center">
|
|
1592
|
+
${this.visualTemplate()}
|
|
1593
|
+
<wui-flex flexDirection="column" gap="3xs">
|
|
1594
|
+
<wui-flex justifyContent="space-between">
|
|
1595
|
+
<wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text>
|
|
1596
|
+
${value ? x`
|
|
1597
|
+
<wui-text variant="paragraph-500" color="fg-100">
|
|
1598
|
+
$${UiHelperUtil.formatNumberToLocalString(value, 3)}
|
|
1599
|
+
</wui-text>
|
|
1600
|
+
` : null}
|
|
1601
|
+
</wui-flex>
|
|
1602
|
+
<wui-flex justifyContent="space-between">
|
|
1603
|
+
<wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text>
|
|
1604
|
+
${this.amount ? x`<wui-text variant="small-400" color="fg-200">
|
|
1605
|
+
${UiHelperUtil.formatNumberToLocalString(this.amount, 4)}
|
|
1606
|
+
</wui-text>` : null}
|
|
1607
|
+
</wui-flex>
|
|
1608
|
+
</wui-flex>
|
|
1609
|
+
</wui-flex>
|
|
1610
|
+
`;
|
|
1611
|
+
}
|
|
1612
|
+
visualTemplate() {
|
|
1613
|
+
if (this.imageError) {
|
|
1614
|
+
return x`<wui-flex class="token-item-image-placeholder">
|
|
1615
|
+
<wui-icon name="image" color="inherit"></wui-icon>
|
|
1616
|
+
</wui-flex>`;
|
|
1617
|
+
}
|
|
1618
|
+
if (this.imageSrc) {
|
|
1619
|
+
return x`<wui-image
|
|
1620
|
+
width="40"
|
|
1621
|
+
height="40"
|
|
1622
|
+
src=${this.imageSrc}
|
|
1623
|
+
@onLoadError=${this.imageLoadError}
|
|
1624
|
+
></wui-image>`;
|
|
1625
|
+
}
|
|
1626
|
+
return null;
|
|
1627
|
+
}
|
|
1628
|
+
imageLoadError() {
|
|
1629
|
+
this.imageError = true;
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
WuiTokenListItem.styles = [resetStyles, elementStyles, styles$1];
|
|
1633
|
+
__decorate$1([
|
|
1634
|
+
n()
|
|
1635
|
+
], WuiTokenListItem.prototype, "imageSrc", void 0);
|
|
1636
|
+
__decorate$1([
|
|
1637
|
+
n()
|
|
1638
|
+
], WuiTokenListItem.prototype, "name", void 0);
|
|
1639
|
+
__decorate$1([
|
|
1640
|
+
n()
|
|
1641
|
+
], WuiTokenListItem.prototype, "symbol", void 0);
|
|
1642
|
+
__decorate$1([
|
|
1643
|
+
n()
|
|
1644
|
+
], WuiTokenListItem.prototype, "price", void 0);
|
|
1645
|
+
__decorate$1([
|
|
1646
|
+
n()
|
|
1647
|
+
], WuiTokenListItem.prototype, "amount", void 0);
|
|
1648
|
+
__decorate$1([
|
|
1649
|
+
r()
|
|
1650
|
+
], WuiTokenListItem.prototype, "visible", void 0);
|
|
1651
|
+
__decorate$1([
|
|
1652
|
+
r()
|
|
1653
|
+
], WuiTokenListItem.prototype, "imageError", void 0);
|
|
1654
|
+
WuiTokenListItem = __decorate$1([
|
|
1655
|
+
customElement("wui-token-list-item")
|
|
1656
|
+
], WuiTokenListItem);
|
|
1657
|
+
const styles = i`
|
|
1658
|
+
:host {
|
|
1659
|
+
--tokens-scroll--top-opacity: 0;
|
|
1660
|
+
--tokens-scroll--bottom-opacity: 1;
|
|
1661
|
+
--suggested-tokens-scroll--left-opacity: 0;
|
|
1662
|
+
--suggested-tokens-scroll--right-opacity: 1;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
:host > wui-flex:first-child {
|
|
1666
|
+
overflow-y: hidden;
|
|
1667
|
+
overflow-x: hidden;
|
|
1668
|
+
scrollbar-width: none;
|
|
1669
|
+
scrollbar-height: none;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
1673
|
+
display: none;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
wui-loading-hexagon {
|
|
1677
|
+
position: absolute;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
.suggested-tokens-container {
|
|
1681
|
+
overflow-x: auto;
|
|
1682
|
+
mask-image: linear-gradient(
|
|
1683
|
+
to right,
|
|
1684
|
+
rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
|
|
1685
|
+
rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
|
|
1686
|
+
black 50px,
|
|
1687
|
+
black 90px,
|
|
1688
|
+
black calc(100% - 90px),
|
|
1689
|
+
black calc(100% - 50px),
|
|
1690
|
+
rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
|
|
1691
|
+
rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
.suggested-tokens-container::-webkit-scrollbar {
|
|
1696
|
+
display: none;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
.tokens-container {
|
|
1700
|
+
border-top: 1px solid var(--wui-color-gray-glass-005);
|
|
1701
|
+
height: 100%;
|
|
1702
|
+
max-height: 390px;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
.tokens {
|
|
1706
|
+
width: 100%;
|
|
1707
|
+
overflow-y: auto;
|
|
1708
|
+
mask-image: linear-gradient(
|
|
1709
|
+
to bottom,
|
|
1710
|
+
rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
|
|
1711
|
+
rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
|
|
1712
|
+
black 50px,
|
|
1713
|
+
black 90px,
|
|
1714
|
+
black calc(100% - 90px),
|
|
1715
|
+
black calc(100% - 50px),
|
|
1716
|
+
rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
|
|
1717
|
+
rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
.network-search-input,
|
|
1722
|
+
.select-network-button {
|
|
1723
|
+
height: 40px;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
.select-network-button {
|
|
1727
|
+
border: none;
|
|
1728
|
+
display: flex;
|
|
1729
|
+
flex-direction: row;
|
|
1730
|
+
align-items: center;
|
|
1731
|
+
justify-content: center;
|
|
1732
|
+
gap: var(--wui-spacing-xs);
|
|
1733
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005);
|
|
1734
|
+
background-color: transparent;
|
|
1735
|
+
border-radius: var(--wui-border-radius-xxs);
|
|
1736
|
+
padding: var(--wui-spacing-xs);
|
|
1737
|
+
align-items: center;
|
|
1738
|
+
transition: background-color 0.2s linear;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
.select-network-button:hover {
|
|
1742
|
+
background-color: var(--wui-color-gray-glass-002);
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
.select-network-button > wui-image {
|
|
1746
|
+
width: 26px;
|
|
1747
|
+
height: 26px;
|
|
1748
|
+
border-radius: var(--wui-border-radius-xs);
|
|
1749
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
|
|
1750
|
+
}
|
|
1751
|
+
`;
|
|
1752
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
1753
|
+
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1754
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
1755
|
+
else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
1756
|
+
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
1757
|
+
};
|
|
1758
|
+
let W3mSwapSelectTokenView = class W3mSwapSelectTokenView2 extends i$1 {
|
|
1759
|
+
constructor() {
|
|
1760
|
+
var _a;
|
|
1761
|
+
super();
|
|
1762
|
+
this.unsubscribe = [];
|
|
1763
|
+
this.targetToken = (_a = RouterController.state.data) == null ? void 0 : _a.target;
|
|
1764
|
+
this.sourceToken = SwapController.state.sourceToken;
|
|
1765
|
+
this.sourceTokenAmount = SwapController.state.sourceTokenAmount;
|
|
1766
|
+
this.toToken = SwapController.state.toToken;
|
|
1767
|
+
this.myTokensWithBalance = SwapController.state.myTokensWithBalance;
|
|
1768
|
+
this.popularTokens = SwapController.state.popularTokens;
|
|
1769
|
+
this.searchValue = "";
|
|
1770
|
+
this.unsubscribe.push(...[
|
|
1771
|
+
SwapController.subscribe((newState) => {
|
|
1772
|
+
this.sourceToken = newState.sourceToken;
|
|
1773
|
+
this.toToken = newState.toToken;
|
|
1774
|
+
this.myTokensWithBalance = newState.myTokensWithBalance;
|
|
1775
|
+
})
|
|
1776
|
+
]);
|
|
1777
|
+
}
|
|
1778
|
+
updated() {
|
|
1779
|
+
var _a, _b;
|
|
1780
|
+
const suggestedTokensContainer = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
|
|
1781
|
+
suggestedTokensContainer == null ? void 0 : suggestedTokensContainer.addEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
|
|
1782
|
+
const tokensList = (_b = this.renderRoot) == null ? void 0 : _b.querySelector(".tokens");
|
|
1783
|
+
tokensList == null ? void 0 : tokensList.addEventListener("scroll", this.handleTokenListScroll.bind(this));
|
|
1784
|
+
}
|
|
1785
|
+
disconnectedCallback() {
|
|
1786
|
+
var _a, _b;
|
|
1787
|
+
super.disconnectedCallback();
|
|
1788
|
+
const suggestedTokensContainer = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
|
|
1789
|
+
const tokensList = (_b = this.renderRoot) == null ? void 0 : _b.querySelector(".tokens");
|
|
1790
|
+
suggestedTokensContainer == null ? void 0 : suggestedTokensContainer.removeEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
|
|
1791
|
+
tokensList == null ? void 0 : tokensList.removeEventListener("scroll", this.handleTokenListScroll.bind(this));
|
|
1792
|
+
clearInterval(this.interval);
|
|
1793
|
+
}
|
|
1794
|
+
render() {
|
|
1795
|
+
return x`
|
|
1796
|
+
<wui-flex flexDirection="column" gap="s">
|
|
1797
|
+
${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
|
|
1798
|
+
</wui-flex>
|
|
1799
|
+
`;
|
|
1800
|
+
}
|
|
1801
|
+
onSelectToken(token) {
|
|
1802
|
+
if (this.targetToken === "sourceToken") {
|
|
1803
|
+
SwapController.setSourceToken(token);
|
|
1804
|
+
} else {
|
|
1805
|
+
SwapController.setToToken(token);
|
|
1806
|
+
if (this.sourceToken && this.sourceTokenAmount) {
|
|
1807
|
+
SwapController.swapTokens();
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
RouterController.goBack();
|
|
1811
|
+
}
|
|
1812
|
+
templateSearchInput() {
|
|
1813
|
+
return x`
|
|
1814
|
+
<wui-flex .padding=${["3xs", "s", "0", "s"]} gap="xs">
|
|
1815
|
+
<wui-input-text
|
|
1816
|
+
data-testid="swap-select-token-search-input"
|
|
1817
|
+
class="network-search-input"
|
|
1818
|
+
size="sm"
|
|
1819
|
+
placeholder="Search token"
|
|
1820
|
+
icon="search"
|
|
1821
|
+
.value=${this.searchValue}
|
|
1822
|
+
@inputChange=${this.onSearchInputChange.bind(this)}
|
|
1823
|
+
></wui-input-text>
|
|
1824
|
+
</wui-flex>
|
|
1825
|
+
`;
|
|
1826
|
+
}
|
|
1827
|
+
templateTokens() {
|
|
1828
|
+
const yourTokens = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [];
|
|
1829
|
+
const tokens = this.popularTokens ? this.popularTokens : [];
|
|
1830
|
+
const filteredYourTokens = this.filterTokensWithText(yourTokens, this.searchValue);
|
|
1831
|
+
const filteredTokens = this.filterTokensWithText(tokens, this.searchValue);
|
|
1832
|
+
return x`
|
|
1833
|
+
<wui-flex class="tokens-container">
|
|
1834
|
+
<wui-flex class="tokens" .padding=${["0", "s", "s", "s"]} flexDirection="column">
|
|
1835
|
+
${(filteredYourTokens == null ? void 0 : filteredYourTokens.length) > 0 ? x`
|
|
1836
|
+
<wui-flex justifyContent="flex-start" padding="s">
|
|
1837
|
+
<wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text>
|
|
1838
|
+
</wui-flex>
|
|
1839
|
+
${filteredYourTokens.map((token) => {
|
|
1840
|
+
var _a, _b, _c;
|
|
1841
|
+
const selected = token.symbol === ((_a = this.sourceToken) == null ? void 0 : _a.symbol) || token.symbol === ((_b = this.toToken) == null ? void 0 : _b.symbol);
|
|
1842
|
+
return x`
|
|
1843
|
+
<wui-token-list-item
|
|
1844
|
+
data-testid="swap-select-token-item-${token.symbol}"
|
|
1845
|
+
name=${token.name}
|
|
1846
|
+
?disabled=${selected}
|
|
1847
|
+
symbol=${token.symbol}
|
|
1848
|
+
price=${token == null ? void 0 : token.price}
|
|
1849
|
+
amount=${(_c = token == null ? void 0 : token.quantity) == null ? void 0 : _c.numeric}
|
|
1850
|
+
imageSrc=${token.logoUri}
|
|
1851
|
+
@click=${() => {
|
|
1852
|
+
if (!selected) {
|
|
1853
|
+
this.onSelectToken(token);
|
|
1854
|
+
}
|
|
1855
|
+
}}
|
|
1856
|
+
>
|
|
1857
|
+
</wui-token-list-item>
|
|
1858
|
+
`;
|
|
1859
|
+
})}
|
|
1860
|
+
` : null}
|
|
1861
|
+
|
|
1862
|
+
<wui-flex justifyContent="flex-start" padding="s">
|
|
1863
|
+
<wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text>
|
|
1864
|
+
</wui-flex>
|
|
1865
|
+
${(filteredTokens == null ? void 0 : filteredTokens.length) > 0 ? filteredTokens.map((token) => x`
|
|
1866
|
+
<wui-token-list-item
|
|
1867
|
+
data-testid="swap-select-token-item-${token.symbol}"
|
|
1868
|
+
name=${token.name}
|
|
1869
|
+
symbol=${token.symbol}
|
|
1870
|
+
imageSrc=${token.logoUri}
|
|
1871
|
+
@click=${() => this.onSelectToken(token)}
|
|
1872
|
+
>
|
|
1873
|
+
</wui-token-list-item>
|
|
1874
|
+
`) : null}
|
|
1875
|
+
</wui-flex>
|
|
1876
|
+
</wui-flex>
|
|
1877
|
+
`;
|
|
1878
|
+
}
|
|
1879
|
+
templateSuggestedTokens() {
|
|
1880
|
+
const tokens = SwapController.state.suggestedTokens ? SwapController.state.suggestedTokens.slice(0, 8) : null;
|
|
1881
|
+
if (!tokens) {
|
|
1882
|
+
return null;
|
|
1883
|
+
}
|
|
1884
|
+
return x`
|
|
1885
|
+
<wui-flex class="suggested-tokens-container" .padding=${["0", "s", "0", "s"]} gap="xs">
|
|
1886
|
+
${tokens.map((token) => x`
|
|
1887
|
+
<wui-token-button
|
|
1888
|
+
text=${token.symbol}
|
|
1889
|
+
imageSrc=${token.logoUri}
|
|
1890
|
+
@click=${() => this.onSelectToken(token)}
|
|
1891
|
+
>
|
|
1892
|
+
</wui-token-button>
|
|
1893
|
+
`)}
|
|
1894
|
+
</wui-flex>
|
|
1895
|
+
`;
|
|
1896
|
+
}
|
|
1897
|
+
onSearchInputChange(event) {
|
|
1898
|
+
this.searchValue = event.detail;
|
|
1899
|
+
}
|
|
1900
|
+
handleSuggestedTokensScroll() {
|
|
1901
|
+
var _a;
|
|
1902
|
+
const container = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
|
|
1903
|
+
if (!container) {
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
container.style.setProperty("--suggested-tokens-scroll--left-opacity", MathUtil.interpolate([0, 100], [0, 1], container.scrollLeft).toString());
|
|
1907
|
+
container.style.setProperty("--suggested-tokens-scroll--right-opacity", MathUtil.interpolate([0, 100], [0, 1], container.scrollWidth - container.scrollLeft - container.offsetWidth).toString());
|
|
1908
|
+
}
|
|
1909
|
+
handleTokenListScroll() {
|
|
1910
|
+
var _a;
|
|
1911
|
+
const container = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".tokens");
|
|
1912
|
+
if (!container) {
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
1915
|
+
container.style.setProperty("--tokens-scroll--top-opacity", MathUtil.interpolate([0, 100], [0, 1], container.scrollTop).toString());
|
|
1916
|
+
container.style.setProperty("--tokens-scroll--bottom-opacity", MathUtil.interpolate([0, 100], [0, 1], container.scrollHeight - container.scrollTop - container.offsetHeight).toString());
|
|
1917
|
+
}
|
|
1918
|
+
filterTokensWithText(tokens, text) {
|
|
1919
|
+
return tokens.filter((token) => `${token.symbol} ${token.name} ${token.address}`.toLowerCase().includes(text.toLowerCase()));
|
|
1920
|
+
}
|
|
1921
|
+
};
|
|
1922
|
+
W3mSwapSelectTokenView.styles = styles;
|
|
1923
|
+
__decorate([
|
|
1924
|
+
r()
|
|
1925
|
+
], W3mSwapSelectTokenView.prototype, "interval", void 0);
|
|
1926
|
+
__decorate([
|
|
1927
|
+
r()
|
|
1928
|
+
], W3mSwapSelectTokenView.prototype, "targetToken", void 0);
|
|
1929
|
+
__decorate([
|
|
1930
|
+
r()
|
|
1931
|
+
], W3mSwapSelectTokenView.prototype, "sourceToken", void 0);
|
|
1932
|
+
__decorate([
|
|
1933
|
+
r()
|
|
1934
|
+
], W3mSwapSelectTokenView.prototype, "sourceTokenAmount", void 0);
|
|
1935
|
+
__decorate([
|
|
1936
|
+
r()
|
|
1937
|
+
], W3mSwapSelectTokenView.prototype, "toToken", void 0);
|
|
1938
|
+
__decorate([
|
|
1939
|
+
r()
|
|
1940
|
+
], W3mSwapSelectTokenView.prototype, "myTokensWithBalance", void 0);
|
|
1941
|
+
__decorate([
|
|
1942
|
+
r()
|
|
1943
|
+
], W3mSwapSelectTokenView.prototype, "popularTokens", void 0);
|
|
1944
|
+
__decorate([
|
|
1945
|
+
r()
|
|
1946
|
+
], W3mSwapSelectTokenView.prototype, "searchValue", void 0);
|
|
1947
|
+
W3mSwapSelectTokenView = __decorate([
|
|
1948
|
+
customElement("w3m-swap-select-token-view")
|
|
1949
|
+
], W3mSwapSelectTokenView);
|
|
1950
|
+
export {
|
|
1951
|
+
W3mSwapPreviewView,
|
|
1952
|
+
W3mSwapSelectTokenView,
|
|
1953
|
+
W3mSwapView
|
|
1954
|
+
};
|