From 0d180ee7c9aebd6e2dcfa04bb3f1fef385e11f82 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 8 May 2023 17:37:23 -0700 Subject: [PATCH] Small fixes, fix reconnecting websockets, fix rewards webln --- frontend/src/basic/BookPage/index.tsx | 29 ++++++-- frontend/src/basic/Main.tsx | 12 ++-- frontend/src/basic/MainDialogs/index.tsx | 33 +++++++--- frontend/src/basic/MakerPage/index.tsx | 17 +++-- frontend/src/basic/NavBar/MoreTooltip.tsx | 24 +++++-- frontend/src/basic/NavBar/NavBar.tsx | 15 +++-- frontend/src/basic/OrderPage/index.tsx | 10 ++- frontend/src/basic/RobotPage/Onboarding.tsx | 35 ++++++++-- frontend/src/basic/RobotPage/Recovery.tsx | 2 +- frontend/src/basic/RobotPage/RobotProfile.tsx | 11 +++- frontend/src/basic/RobotPage/TokenInput.tsx | 10 ++- frontend/src/basic/RobotPage/Welcome.tsx | 8 ++- frontend/src/basic/RobotPage/index.tsx | 2 +- frontend/src/basic/SettingsPage/index.tsx | 2 +- .../src/components/BookTable/BookControl.tsx | 6 +- frontend/src/components/BookTable/index.tsx | 44 ++++++++----- .../components/Charts/DepthChart/index.tsx | 37 +++++++---- .../src/components/Charts/NivoScheme/index.ts | 4 +- frontend/src/components/Dialogs/AuditPGP.tsx | 16 +++-- .../components/Dialogs/CoordinatorSummary.tsx | 2 +- .../src/components/Dialogs/EnableTelegram.tsx | 2 +- frontend/src/components/Dialogs/Profile.tsx | 59 ++++++++++++----- frontend/src/components/Dialogs/Stats.tsx | 2 +- .../src/components/Dialogs/StoreToken.tsx | 8 ++- .../src/components/Dialogs/UpdateClient.tsx | 7 +- frontend/src/components/ErrorBoundary.tsx | 1 + .../src/components/MakerForm/AmountRange.tsx | 4 +- .../MakerForm/AutocompletePayments.tsx | 8 ++- .../src/components/MakerForm/MakerForm.tsx | 36 ++++++---- .../src/components/Notifications/index.tsx | 12 ++-- .../components/OrderDetails/TakeButton.tsx | 32 ++++++--- .../src/components/OrderDetails/index.tsx | 22 ++++--- frontend/src/components/RobotAvatar/index.tsx | 4 +- .../SettingsForm/SelectLanguage.tsx | 2 +- .../src/components/SettingsForm/index.tsx | 2 +- frontend/src/components/TorConnection.tsx | 2 +- .../src/components/TradeBox/CancelButton.tsx | 2 +- .../components/TradeBox/CollabCancelAlert.tsx | 2 +- .../TradeBox/Dialogs/ConfirmCollabCancel.tsx | 2 +- .../TradeBox/Dialogs/ConfirmFiatReceived.tsx | 2 +- .../TradeBox/Dialogs/ConfirmFiatSent.tsx | 2 +- .../TradeBox/Dialogs/ConfirmUndoFiatSent.tsx | 6 +- .../EncryptedChat/ChatBottom/index.tsx | 17 ++++- .../EncryptedChat/ChatHeader/index.tsx | 4 +- .../EncryptedSocketChat/index.tsx | 30 ++++++--- .../EncryptedTurtleChat/index.tsx | 16 +++-- .../EncryptedChat/MessageCard/index.tsx | 12 ++-- .../TradeBox/EncryptedChat/index.tsx | 2 +- .../src/components/TradeBox/Forms/Dispute.tsx | 8 ++- .../TradeBox/Forms/LightningPayout.tsx | 42 +++++++----- .../TradeBox/Forms/OnchainPayout.tsx | 6 +- .../src/components/TradeBox/Prompts/Chat.tsx | 4 +- .../components/TradeBox/Prompts/Dispute.tsx | 2 +- .../components/TradeBox/Prompts/Expired.tsx | 2 +- .../TradeBox/Prompts/LockInvoice.tsx | 4 +- .../components/TradeBox/Prompts/Payout.tsx | 13 +++- .../TradeBox/Prompts/PublicWait.tsx | 2 +- .../TradeBox/Prompts/RoutingFailed.tsx | 6 +- .../TradeBox/Prompts/Successful.tsx | 2 +- .../src/components/TradeBox/Title/index.tsx | 2 +- .../src/components/TradeBox/TradeSummary.tsx | 26 ++++++-- frontend/src/components/TradeBox/index.tsx | 66 +++++++++++++------ frontend/src/components/TradeBox/stepXofY.ts | 2 +- frontend/src/components/UnsafeAlert.tsx | 26 ++++++-- frontend/src/contexts/AppContext.ts | 37 ++++++----- frontend/src/models/Garage.model.ts | 2 +- frontend/src/models/Limit.model.ts | 4 +- frontend/src/pro/Main.tsx | 15 +++-- frontend/src/pro/ToolBar/index.tsx | 8 +-- frontend/src/pro/Widgets/Book.tsx | 4 +- frontend/src/pro/Widgets/Depth.tsx | 2 +- frontend/src/pro/Widgets/Maker.tsx | 2 +- frontend/src/pro/Widgets/Settings.tsx | 2 +- frontend/src/services/Native/index.d.ts | 2 +- frontend/src/services/Native/index.ts | 12 ++-- .../System/SystemNativeClient/index.ts | 2 +- .../services/System/SystemWebClient/index.ts | 2 +- .../Websocket/WebsocketConnectionWeb/index.ts | 8 ++- .../Websocket/WebsocketWebClient/index.ts | 2 +- .../src/services/api/ApiNativeClient/index.ts | 16 +++-- .../src/services/api/ApiWebClient/index.ts | 6 +- frontend/src/utils/filterOrders.ts | 2 +- frontend/src/utils/hexToBase91.ts | 2 +- frontend/src/utils/webln.ts | 2 +- 84 files changed, 656 insertions(+), 308 deletions(-) diff --git a/frontend/src/basic/BookPage/index.tsx b/frontend/src/basic/BookPage/index.tsx index 39ee7927..d1607385 100644 --- a/frontend/src/basic/BookPage/index.tsx +++ b/frontend/src/basic/BookPage/index.tsx @@ -10,7 +10,7 @@ import BookTable from '../../components/BookTable'; // Icons import { BarChart, FormatListBulleted } from '@mui/icons-material'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; const BookPage = (): JSX.Element => { const { robot, fetchBook, windowSize, setDelay, setOrder } = @@ -47,13 +47,22 @@ const BookPage = (): JSX.Element => { const NavButtons = function () { return ( - {doubleView ? ( <> ) : ( - @@ -237,11 +245,21 @@ const Onboarding = ({ - - @@ -273,7 +291,12 @@ const Onboarding = ({ - diff --git a/frontend/src/basic/RobotPage/Recovery.tsx b/frontend/src/basic/RobotPage/Recovery.tsx index 436a3d80..a27bc09f 100644 --- a/frontend/src/basic/RobotPage/Recovery.tsx +++ b/frontend/src/basic/RobotPage/Recovery.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Button, Grid, Typography } from '@mui/material'; -import { Robot } from '../../models'; +import { type Robot } from '../../models'; import TokenInput from './TokenInput'; import Key from '@mui/icons-material/Key'; diff --git a/frontend/src/basic/RobotPage/RobotProfile.tsx b/frontend/src/basic/RobotPage/RobotProfile.tsx index c73d1b89..e6da0d81 100644 --- a/frontend/src/basic/RobotPage/RobotProfile.tsx +++ b/frontend/src/basic/RobotPage/RobotProfile.tsx @@ -16,8 +16,8 @@ import { import { Bolt, Add, DeleteSweep, Logout, Download } from '@mui/icons-material'; import RobotAvatar from '../../components/RobotAvatar'; import TokenInput from './TokenInput'; -import { Slot, Robot } from '../../models'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { type Slot, type Robot } from '../../models'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { genBase62Token } from '../../utils'; import { LoadingButton } from '@mui/lab'; @@ -298,7 +298,12 @@ const RobotProfile = ({ {window.NativeRobosats === undefined ? ( - diff --git a/frontend/src/basic/RobotPage/TokenInput.tsx b/frontend/src/basic/RobotPage/TokenInput.tsx index 296008af..678bd2f8 100644 --- a/frontend/src/basic/RobotPage/TokenInput.tsx +++ b/frontend/src/basic/RobotPage/TokenInput.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { IconButton, LinearProgress, TextField, Tooltip } from '@mui/material'; -import { Robot } from '../../models'; +import { type Robot } from '../../models'; import { ContentCopy } from '@mui/icons-material'; import { systemClient } from '../../services/System'; @@ -57,7 +57,9 @@ const TokenInput = ({ variant={editable ? 'outlined' : 'filled'} helperText={badToken} size='medium' - onChange={(e) => setInputToken(e.target.value)} + onChange={(e) => { + setInputToken(e.target.value); + }} onKeyPress={(e) => { if (e.key === 'Enter') { onPressEnter(); @@ -72,7 +74,9 @@ const TokenInput = ({ onClick={() => { systemClient.copyToClipboard(inputToken); setShowCopied(true); - setTimeout(() => setShowCopied(false), 1000); + setTimeout(() => { + setShowCopied(false); + }, 1000); setRobot((robot) => { return { ...robot, copiedToken: true }; }); diff --git a/frontend/src/basic/RobotPage/Welcome.tsx b/frontend/src/basic/RobotPage/Welcome.tsx index df5f2b68..57a7ec79 100644 --- a/frontend/src/basic/RobotPage/Welcome.tsx +++ b/frontend/src/basic/RobotPage/Welcome.tsx @@ -73,7 +73,9 @@ const Welcome = ({ setView, width, getGenerateRobot }: WelcomeProps): JSX.Elemen size='large' color='primary' variant='contained' - onClick={() => setView('onboarding')} + onClick={() => { + setView('onboarding'); + }} >
@@ -91,7 +93,9 @@ const Welcome = ({ setView, width, getGenerateRobot }: WelcomeProps): JSX.Elemen size='small' color='secondary' variant='contained' - onClick={() => setView('recovery')} + onClick={() => { + setView('recovery'); + }} >
{t('Recovery')} diff --git a/frontend/src/basic/RobotPage/index.tsx b/frontend/src/basic/RobotPage/index.tsx index 87a93508..64ef2943 100644 --- a/frontend/src/basic/RobotPage/index.tsx +++ b/frontend/src/basic/RobotPage/index.tsx @@ -19,7 +19,7 @@ import RobotProfile from './RobotProfile'; import Recovery from './Recovery'; import { TorIcon } from '../../components/Icons'; import { genKey } from '../../pgp'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { validateTokenEntropy } from '../../utils'; const RobotPage = (): JSX.Element => { diff --git a/frontend/src/basic/SettingsPage/index.tsx b/frontend/src/basic/SettingsPage/index.tsx index bc4cfe2e..8ae3bb67 100644 --- a/frontend/src/basic/SettingsPage/index.tsx +++ b/frontend/src/basic/SettingsPage/index.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import { Grid, Paper } from '@mui/material'; import SettingsForm from '../../components/SettingsForm'; -import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; +import { type UseAppStoreType, AppContext } from '../../contexts/AppContext'; const SettingsPage = (): JSX.Element => { const { windowSize, navbarHeight } = useContext(AppContext); diff --git a/frontend/src/components/BookTable/BookControl.tsx b/frontend/src/components/BookTable/BookControl.tsx index ecb41a2d..bb3c845e 100644 --- a/frontend/src/components/BookTable/BookControl.tsx +++ b/frontend/src/components/BookTable/BookControl.tsx @@ -18,7 +18,7 @@ import { fiatMethods, swapMethods, PaymentIcon } from '../PaymentMethods'; import { FlagWithProps } from '../Icons'; import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank'; -import { Favorites } from '../../models'; +import { type Favorites } from '../../models'; import SwapCalls from '@mui/icons-material/SwapCalls'; interface BookControlProps { @@ -259,7 +259,9 @@ const BookControl = ({ style: { textAlign: 'center' }, }} value={paymentMethod[0] ? paymentMethod[0] : 'ANY'} - onChange={(e) => setPaymentMethods(e.target.value == 'ANY' ? [] : [e.target.value])} + onChange={(e) => { + setPaymentMethods(e.target.value == 'ANY' ? [] : [e.target.value]); + }} >
diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index 2c854e0d..2407589a 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -14,17 +14,17 @@ import { LinearProgress, IconButton, Tooltip, - LinearProgressProps, + type LinearProgressProps, styled, } from '@mui/material'; import { DataGrid, - GridColumnVisibilityModel, + type GridColumnVisibilityModel, GridPagination, - GridPaginationModel, + type GridPaginationModel, } from '@mui/x-data-grid'; import currencyDict from '../../../static/assets/currencies.json'; -import { PublicOrder } from '../../models'; +import { type PublicOrder } from '../../models'; import { filterOrders, hexToRgb, statusBadgeColor, pn, amountToString } from '../../utils'; import BookControl from './BookControl'; @@ -34,7 +34,7 @@ import RobotAvatar from '../RobotAvatar'; // Icons import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; const ClickThroughDataGrid = styled(DataGrid)({ '& .MuiDataGrid-overlayWrapperInner': { @@ -609,7 +609,7 @@ const BookTable = ({ const filteredColumns = function (maxWidth: number) { const useSmall = maxWidth < 70; const selectedColumns: object[] = []; - let columnVisibilityModel: GridColumnVisibilityModel = {}; + const columnVisibilityModel: GridColumnVisibilityModel = {}; let width: number = 0; for (const [key, value] of Object.entries(columnSpecs)) { @@ -654,12 +654,20 @@ const BookTable = ({ - setFullscreen(!fullscreen)}> + { + setFullscreen(!fullscreen); + }} + > {fullscreen ? : } - fetchBook()}> + { + fetchBook(); + }} + > @@ -758,9 +766,9 @@ const BookTable = ({ loading={book.loading} columns={columns} columnVisibilityModel={columnVisibilityModel} - onColumnVisibilityModelChange={(newColumnVisibilityModel) => - setColumnVisibilityModel(newColumnVisibilityModel) - } + onColumnVisibilityModelChange={(newColumnVisibilityModel) => { + setColumnVisibilityModel(newColumnVisibilityModel); + }} hideFooter={!showFooter} components={gridComponents} componentsProps={{ @@ -777,7 +785,9 @@ const BookTable = ({ onPaginationModelChange={(newPaginationModel) => { setPaginationModel(newPaginationModel); }} - onRowClick={(params: any) => onOrderClicked(params.row.id)} + onRowClick={(params: any) => { + onOrderClicked(params.row.id); + }} /> ); @@ -795,9 +805,9 @@ const BookTable = ({ hideFooter={!showFooter} components={gridComponents} columnVisibilityModel={columnVisibilityModel} - onColumnVisibilityModelChange={(newColumnVisibilityModel) => - setColumnVisibilityModel(newColumnVisibilityModel) - } + onColumnVisibilityModelChange={(newColumnVisibilityModel) => { + setColumnVisibilityModel(newColumnVisibilityModel); + }} componentsProps={{ toolbar: { width, @@ -812,7 +822,9 @@ const BookTable = ({ onPaginationModelChange={(newPaginationModel) => { setPaginationModel(newPaginationModel); }} - onRowClick={(params: any) => onOrderClicked(params.row.id)} + onRowClick={(params: any) => { + onOrderClicked(params.row.id); + }} /> diff --git a/frontend/src/components/Charts/DepthChart/index.tsx b/frontend/src/components/Charts/DepthChart/index.tsx index ad3a65ed..5302f52d 100644 --- a/frontend/src/components/Charts/DepthChart/index.tsx +++ b/frontend/src/components/Charts/DepthChart/index.tsx @@ -1,12 +1,12 @@ import React, { useEffect, useState, useContext } from 'react'; import { ResponsiveLine, - Serie, - Datum, - PointTooltipProps, - PointMouseHandler, - Point, - CustomLayer, + type Serie, + type Datum, + type PointTooltipProps, + type PointMouseHandler, + type Point, + type CustomLayer, } from '@nivo/line'; import { Box, @@ -20,13 +20,13 @@ import { } from '@mui/material'; import { AddCircleOutline, RemoveCircleOutline } from '@mui/icons-material'; import { useTranslation } from 'react-i18next'; -import { PublicOrder, LimitList, Order } from '../../../models'; +import { type PublicOrder, LimitList, type Order } from '../../../models'; import RobotAvatar from '../../RobotAvatar'; import { amountToString, matchMedian, statusBadgeColor } from '../../../utils'; import currencyDict from '../../../../static/assets/currencies.json'; import { PaymentStringAsIcons } from '../../PaymentMethods'; import getNivoScheme from '../NivoScheme'; -import { UseAppStoreType, AppContext } from '../../../contexts/AppContext'; +import { type UseAppStoreType, AppContext } from '../../../contexts/AppContext'; interface DepthChartProps { maxWidth: number; @@ -316,7 +316,13 @@ const DepthChart: React.FC = ({ alignItems='flex-start' style={{ paddingLeft: '1em' }} > - { + setXType(e.target.value); + }} + >
{t('Premium')} @@ -333,7 +339,11 @@ const DepthChart: React.FC = ({ - setXRange(xRange + rangeSteps)}> + { + setXRange(xRange + rangeSteps); + }} + > @@ -345,7 +355,12 @@ const DepthChart: React.FC = ({ - setXRange(xRange - rangeSteps)} disabled={xRange <= 1}> + { + setXRange(xRange - rangeSteps); + }} + disabled={xRange <= 1} + > diff --git a/frontend/src/components/Charts/NivoScheme/index.ts b/frontend/src/components/Charts/NivoScheme/index.ts index f52913d9..e5eb8b08 100644 --- a/frontend/src/components/Charts/NivoScheme/index.ts +++ b/frontend/src/components/Charts/NivoScheme/index.ts @@ -1,5 +1,5 @@ -import { Theme as NivoTheme } from '@nivo/core'; -import { Theme as MuiTheme } from '@mui/material/styles'; +import { type Theme as NivoTheme } from '@nivo/core'; +import { type Theme as MuiTheme } from '@mui/material/styles'; export const getNivoScheme: (theme: MuiTheme) => NivoTheme = (theme) => { const lightMode = { diff --git a/frontend/src/components/Dialogs/AuditPGP.tsx b/frontend/src/components/Dialogs/AuditPGP.tsx index b481469b..1389e13c 100644 --- a/frontend/src/components/Dialogs/AuditPGP.tsx +++ b/frontend/src/components/Dialogs/AuditPGP.tsx @@ -37,7 +37,11 @@ function CredentialTextfield(props) { InputProps={{ endAdornment: ( - systemClient.copyToClipboard(props.value)}> + { + systemClient.copyToClipboard(props.value); + }} + > @@ -144,14 +148,14 @@ const AuditPGPDialog = ({ size='small' color='primary' variant='contained' - onClick={() => + onClick={() => { saveAsJson('keys_' + orderId + '.json', { own_public_key: own_pub_key, peer_public_key: peer_pub_key, encrypted_private_key: own_enc_priv_key, passphrase, - }) - } + }); + }} >
@@ -176,7 +180,9 @@ const AuditPGPDialog = ({ size='small' color='primary' variant='contained' - onClick={() => saveAsJson('messages_' + orderId + '.json', messages)} + onClick={() => { + saveAsJson('messages_' + orderId + '.json', messages); + }} >
diff --git a/frontend/src/components/Dialogs/CoordinatorSummary.tsx b/frontend/src/components/Dialogs/CoordinatorSummary.tsx index afdc0cef..1983e260 100644 --- a/frontend/src/components/Dialogs/CoordinatorSummary.tsx +++ b/frontend/src/components/Dialogs/CoordinatorSummary.tsx @@ -23,7 +23,7 @@ import BookIcon from '@mui/icons-material/Book'; import LinkIcon from '@mui/icons-material/Link'; import { pn } from '../../utils'; -import { Info } from '../../models'; +import { type Info } from '../../models'; interface Props { open: boolean; diff --git a/frontend/src/components/Dialogs/EnableTelegram.tsx b/frontend/src/components/Dialogs/EnableTelegram.tsx index f9f562d1..da5a112e 100644 --- a/frontend/src/components/Dialogs/EnableTelegram.tsx +++ b/frontend/src/components/Dialogs/EnableTelegram.tsx @@ -13,7 +13,7 @@ import { Grid, } from '@mui/material'; import { NewTabIcon } from '../Icons'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; interface Props { open: boolean; diff --git a/frontend/src/components/Dialogs/Profile.tsx b/frontend/src/components/Dialogs/Profile.tsx index e6676529..f82053c1 100644 --- a/frontend/src/components/Dialogs/Profile.tsx +++ b/frontend/src/components/Dialogs/Profile.tsx @@ -33,10 +33,10 @@ import NumbersIcon from '@mui/icons-material/Numbers'; import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; import { UserNinjaIcon } from '../Icons'; -import { getHost, getWebln } from '../../utils'; +import { getWebln } from '../../utils'; import RobotAvatar from '../RobotAvatar'; import { apiClient } from '../../services/api'; -import { Robot } from '../../models'; +import { type Robot } from '../../models'; interface Props { open: boolean; @@ -50,7 +50,6 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop const { t } = useTranslation(); const navigate = useNavigate(); const theme = useTheme(); - const host = getHost(); const [rewardInvoice, setRewardInvoice] = useState(''); const [showRewardsSpinner, setShowRewardsSpinner] = useState(false); @@ -60,13 +59,20 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop const [weblnEnabled, setWeblnEnabled] = useState(false); const [openEnableTelegram, setOpenEnableTelegram] = useState(false); + const handleWebln = async () => { + const webln = await getWebln() + .then(() => { + setWeblnEnabled(true); + }) + .catch(() => { + setWeblnEnabled(false); + console.log('WebLN not available'); + }); + return webln; + }; + useEffect(() => { - const handleWebln = async (order: Order) => { - const webln = await getWebln().catch(() => console.log('WebLN not available')); - return webln; - }; - const webln = handleWebln(); - setWeblnEnabled(webln !== undefined); + handleWebln(); }, []); const handleWeblnInvoiceClicked = async (e: any) => { @@ -107,7 +113,9 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop const setStealthInvoice = (wantsStealth: boolean) => { apiClient .post(baseUrl, '/api/stealth/', { wantsStealth }, { tokenSHA256: robot.tokenSHA256 }) - .then((data) => setRobot({ ...robot, stealthInvoices: data?.wantsStealth })); + .then((data) => { + setRobot({ ...robot, stealthInvoices: data?.wantsStealth }); + }); }; return ( @@ -213,7 +221,9 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop setOpenEnableTelegram(false)} + onClose={() => { + setOpenEnableTelegram(false); + }} tgBotName={robot.tgBotName} tgToken={robot.tgToken} /> @@ -229,7 +239,12 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop {t('Telegram enabled')} ) : ( - )} @@ -256,7 +271,9 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop control={ setStealthInvoice(!robot.stealthInvoices)} + onChange={() => { + setStealthInvoice(!robot.stealthInvoices); + }} /> } /> @@ -280,7 +297,9 @@ const ProfileDialog = ({ open = false, baseUrl, onClose, robot, setRobot }: Prop - {weblnEnabled && ( + {weblnEnabled ? ( + ) : ( + <> )} )} diff --git a/frontend/src/components/Dialogs/Stats.tsx b/frontend/src/components/Dialogs/Stats.tsx index 8312c755..9b442c75 100644 --- a/frontend/src/components/Dialogs/Stats.tsx +++ b/frontend/src/components/Dialogs/Stats.tsx @@ -25,7 +25,7 @@ import EqualizerIcon from '@mui/icons-material/Equalizer'; import { AmbossIcon, BitcoinSignIcon, RoboSatsNoTextIcon } from '../Icons'; import { pn } from '../../utils'; -import { Info } from '../../models'; +import { type Info } from '../../models'; interface Props { open: boolean; diff --git a/frontend/src/components/Dialogs/StoreToken.tsx b/frontend/src/components/Dialogs/StoreToken.tsx index 2bd82b26..97a96238 100644 --- a/frontend/src/components/Dialogs/StoreToken.tsx +++ b/frontend/src/components/Dialogs/StoreToken.tsx @@ -14,7 +14,7 @@ import { } from '@mui/material'; import { systemClient } from '../../services/System'; import ContentCopy from '@mui/icons-material/ContentCopy'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; interface Props { open: boolean; @@ -49,7 +49,11 @@ const StoreTokenDialog = ({ open, onClose, onClickBack, onClickDone }: Props): J InputProps={{ endAdornment: ( - systemClient.copyToClipboard(robot.token)}> + { + systemClient.copyToClipboard(robot.token); + }} + > diff --git a/frontend/src/components/Dialogs/UpdateClient.tsx b/frontend/src/components/Dialogs/UpdateClient.tsx index 6988dd14..228102f8 100644 --- a/frontend/src/components/Dialogs/UpdateClient.tsx +++ b/frontend/src/components/Dialogs/UpdateClient.tsx @@ -88,7 +88,12 @@ const UpdateClientDialog = ({ - location.reload(true)}> + { + location.reload(true); + }} + > diff --git a/frontend/src/components/ErrorBoundary.tsx b/frontend/src/components/ErrorBoundary.tsx index 33035da2..f113b464 100644 --- a/frontend/src/components/ErrorBoundary.tsx +++ b/frontend/src/components/ErrorBoundary.tsx @@ -29,6 +29,7 @@ export default class ErrorBoundary extends Component currencyCode} - onChange={(e) => handleCurrencyChange(e.target.value)} + onChange={(e) => { + handleCurrencyChange(e.target.value); + }} > {Object.entries(currencyDict).map(([key, value]) => ( diff --git a/frontend/src/components/MakerForm/AutocompletePayments.tsx b/frontend/src/components/MakerForm/AutocompletePayments.tsx index 7d7d829e..55ef6664 100644 --- a/frontend/src/components/MakerForm/AutocompletePayments.tsx +++ b/frontend/src/components/MakerForm/AutocompletePayments.tsx @@ -226,9 +226,13 @@ export default function AutocompletePayments(props) { value: props.value, options: props.optionsType == 'fiat' ? fiatMethods : swapMethods, getOptionLabel: (option) => option.name, - onInputChange: (e) => setVal(e ? (e.target.value ? e.target.value : '') : ''), + onInputChange: (e) => { + setVal(e ? (e.target.value ? e.target.value : '') : ''); + }, onChange: (event, value) => props.onAutocompleteChange(value), - onClose: () => setVal(() => ''), + onClose: () => { + setVal(() => ''); + }, }); const [val, setVal] = useState(''); diff --git a/frontend/src/components/MakerForm/MakerForm.tsx b/frontend/src/components/MakerForm/MakerForm.tsx index 901eedc0..5a7e9a29 100644 --- a/frontend/src/components/MakerForm/MakerForm.tsx +++ b/frontend/src/components/MakerForm/MakerForm.tsx @@ -25,7 +25,7 @@ import { IconButton, } from '@mui/material'; -import { LimitList, defaultMaker } from '../../models'; +import { type LimitList, defaultMaker } from '../../models'; import { LocalizationProvider, MobileTimePicker } from '@mui/x-date-pickers'; import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; @@ -40,7 +40,7 @@ import { amountToString, computeSats, pn } from '../../utils'; import { SelfImprovement, Lock, HourglassTop, DeleteSweep, Edit } from '@mui/icons-material'; import { LoadingButton } from '@mui/lab'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; interface MakerFormProps { disableRequest?: boolean; @@ -464,7 +464,9 @@ const MakerForm = ({ setOpenDialogs(false)} + onClose={() => { + setOpenDialogs(false); + }} onClickDone={handleCreateOrder} hasRobot={robot.avatarLoaded} /> @@ -531,7 +533,9 @@ const MakerForm = ({ handleCurrencyChange(fav.mode == 'swap' ? 1 : 1000)} + onClick={() => { + handleCurrencyChange(fav.mode == 'swap' ? 1 : 1000); + }} /> @@ -547,12 +551,12 @@ const MakerForm = ({ - @@ -313,7 +327,9 @@ const TakeButton = ({ order, setOrder, baseUrl, info }: TakeButtonProps): JSX.El setOpen({ ...open, confirmation: false })} + onClose={() => { + setOpen({ ...open, confirmation: false }); + }} onClickDone={() => { takeOrder(); setLoadingTake(true); diff --git a/frontend/src/components/OrderDetails/index.tsx b/frontend/src/components/OrderDetails/index.tsx index 6ed1d863..3f4411c3 100644 --- a/frontend/src/components/OrderDetails/index.tsx +++ b/frontend/src/components/OrderDetails/index.tsx @@ -16,7 +16,7 @@ import { IconButton, } from '@mui/material'; -import Countdown, { CountdownRenderProps, zeroPad } from 'react-countdown'; +import Countdown, { type CountdownRenderProps, zeroPad } from 'react-countdown'; import RobotAvatar from '../../components/RobotAvatar'; import currencies from '../../../static/assets/currencies.json'; @@ -34,7 +34,7 @@ import { PaymentStringAsIcons } from '../../components/PaymentMethods'; import { FlagWithProps, SendReceiveIcon } from '../Icons'; import LinearDeterminate from './LinearDeterminate'; -import { Order, Info } from '../../models'; +import { type Order, type Info } from '../../models'; import { statusBadgeColor, pn, amountToString, computeSats } from '../../utils'; import TakeButton from './TakeButton'; @@ -160,20 +160,20 @@ const OrderDetails = ({ amount: order.amount, fee: -tradeFee, routingBudget: defaultRoutingBudget, - rate: rate, + rate, }); } else { const min = computeSats({ amount: Number(order.min_amount), fee: -tradeFee, routingBudget: defaultRoutingBudget, - rate: rate, + rate, }); const max = computeSats({ amount: Number(order.max_amount), fee: -tradeFee, routingBudget: defaultRoutingBudget, - rate: rate, + rate, }); sats = `${min}-${max}`; } @@ -190,18 +190,18 @@ const OrderDetails = ({ sats = computeSats({ amount: order.amount, fee: tradeFee, - rate: rate, + rate, }); } else { const min = computeSats({ amount: order.min_amount, fee: tradeFee, - rate: rate, + rate, }); const max = computeSats({ amount: order.max_amount, fee: tradeFee, - rate: rate, + rate, }); sats = `${min}-${max}`; } @@ -297,7 +297,11 @@ const OrderDetails = ({ secondary={order.amount ? 'Amount' : 'Amount Range'} /> - setShowSatsDetails(!showSatsDetails)}> + { + setShowSatsDetails(!showSatsDetails); + }} + > {showSatsDetails ? : } diff --git a/frontend/src/components/RobotAvatar/index.tsx b/frontend/src/components/RobotAvatar/index.tsx index aefe0f32..f655a131 100644 --- a/frontend/src/components/RobotAvatar/index.tsx +++ b/frontend/src/components/RobotAvatar/index.tsx @@ -105,7 +105,9 @@ const RobotAvatar: React.FC = ({ border: '0.3px solid #55555', filter: 'dropShadow(0.5px 0.5px 0.5px #000000)', ...imageStyle, - onLoad: setTimeout(() => setActiveBackground(false), 1000), + onLoad: setTimeout(() => { + setActiveBackground(false); + }, 1000), }} />
diff --git a/frontend/src/components/SettingsForm/SelectLanguage.tsx b/frontend/src/components/SettingsForm/SelectLanguage.tsx index 8f62df98..17697910 100644 --- a/frontend/src/components/SettingsForm/SelectLanguage.tsx +++ b/frontend/src/components/SettingsForm/SelectLanguage.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Select, MenuItem, useTheme, Grid, Typography } from '@mui/material'; -import Language from '../../models/Language.model'; +import type Language from '../../models/Language.model'; import Flags from 'country-flag-icons/react/3x2'; import { CataloniaFlag, BasqueCountryFlag } from '../Icons'; diff --git a/frontend/src/components/SettingsForm/index.tsx b/frontend/src/components/SettingsForm/index.tsx index 5bb6dce4..9c263698 100644 --- a/frontend/src/components/SettingsForm/index.tsx +++ b/frontend/src/components/SettingsForm/index.tsx @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; -import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; +import { type UseAppStoreType, AppContext } from '../../contexts/AppContext'; import { Grid, Paper, diff --git a/frontend/src/components/TorConnection.tsx b/frontend/src/components/TorConnection.tsx index d4e72d9a..77e33b88 100644 --- a/frontend/src/components/TorConnection.tsx +++ b/frontend/src/components/TorConnection.tsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import { Box, CircularProgress, Tooltip } from '@mui/material'; import { TorIcon } from './Icons'; import { useTranslation } from 'react-i18next'; -import { AppContext, UseAppStoreType } from '../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../contexts/AppContext'; interface TorIndicatorProps { color: 'inherit' | 'error' | 'warning' | 'success' | 'primary' | 'secondary' | 'info' | undefined; diff --git a/frontend/src/components/TradeBox/CancelButton.tsx b/frontend/src/components/TradeBox/CancelButton.tsx index c08d5e0c..f9f4157e 100644 --- a/frontend/src/components/TradeBox/CancelButton.tsx +++ b/frontend/src/components/TradeBox/CancelButton.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Box, Tooltip } from '@mui/material'; -import { Order } from '../../models'; +import { type Order } from '../../models'; import { LoadingButton } from '@mui/lab'; interface CancelButtonProps { diff --git a/frontend/src/components/TradeBox/CollabCancelAlert.tsx b/frontend/src/components/TradeBox/CollabCancelAlert.tsx index adc1defd..a3c628ae 100644 --- a/frontend/src/components/TradeBox/CollabCancelAlert.tsx +++ b/frontend/src/components/TradeBox/CollabCancelAlert.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Alert } from '@mui/material'; -import { Order } from '../../models'; +import { type Order } from '../../models'; interface CollabCancelAlertProps { order: Order; diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmCollabCancel.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmCollabCancel.tsx index bf7af5d1..d160c0a4 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmCollabCancel.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmCollabCancel.tsx @@ -12,7 +12,7 @@ import { LoadingButton } from '@mui/lab'; interface ConfirmCollabCancelDialogProps { open: boolean; - loading: Boolean; + loading: boolean; onClose: () => void; onCollabCancelClick: () => void; peerAskedCancel: boolean; diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx index 91bce631..35a55e11 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx @@ -8,7 +8,7 @@ import { DialogContentText, Button, } from '@mui/material'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; import currencies from '../../../../static/assets/currencies.json'; import { pn } from '../../../utils'; import { LoadingButton } from '@mui/lab'; diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx index a4d3f36c..e87d06d1 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx @@ -8,7 +8,7 @@ import { DialogContentText, Button, } from '@mui/material'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; import currencies from '../../../../static/assets/currencies.json'; import { pn } from '../../../utils'; import { LoadingButton } from '@mui/lab'; diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmUndoFiatSent.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmUndoFiatSent.tsx index 1e9960a2..11456dc5 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmUndoFiatSent.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmUndoFiatSent.tsx @@ -8,7 +8,7 @@ import { DialogContentText, Button, } from '@mui/material'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; import { LoadingButton } from '@mui/lab'; interface ConfirmUndoFiatSentDialogProps { @@ -30,7 +30,9 @@ export const ConfirmUndoFiatSentDialog = ({ useEffect(() => { if (time > 0 && open) { - setTimeout(() => setTime(time - 1), 1000); + setTimeout(() => { + setTime(time - 1); + }, 1000); } }, [time, open]); diff --git a/frontend/src/components/TradeBox/EncryptedChat/ChatBottom/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/ChatBottom/index.tsx index dcc49f55..71876895 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/ChatBottom/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/ChatBottom/index.tsx @@ -34,7 +34,14 @@ const ChatBottom: React.FC = ({ orderId, setAudit, audit, createJsonFile enterNextDelay={2000} title={t('Verify your privacy')} > - @@ -54,7 +61,9 @@ const ChatBottom: React.FC = ({ orderId, setAudit, audit, createJsonFile size='small' color='primary' variant='outlined' - onClick={() => saveAsJson('complete_log_chat_' + orderId + '.json', createJsonFile())} + onClick={() => { + saveAsJson('complete_log_chat_' + orderId + '.json', createJsonFile()); + }} >
@@ -68,7 +77,9 @@ const ChatBottom: React.FC = ({ orderId, setAudit, audit, createJsonFile size='small' color='primary' variant='outlined' - onClick={() => systemClient.copyToClipboard(JSON.stringify(createJsonFile()))} + onClick={() => { + systemClient.copyToClipboard(JSON.stringify(createJsonFile())); + }} >
diff --git a/frontend/src/components/TradeBox/EncryptedChat/ChatHeader/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/ChatHeader/index.tsx index c287c9e3..8e4f43cb 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/ChatHeader/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/ChatHeader/index.tsx @@ -53,7 +53,9 @@ const ChatHeader: React.FC = ({ connected, peerConnected, turtleMode, set setTurtleMode(!turtleMode)} + onClick={() => { + setTurtleMode(!turtleMode); + }} > diff --git a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx index 585d1dbb..672c6c3e 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx @@ -3,8 +3,8 @@ import { useTranslation } from 'react-i18next'; import { Button, Tooltip, TextField, Grid, Paper, Typography } from '@mui/material'; import { encryptMessage, decryptMessage } from '../../../../pgp'; import { AuditPGPDialog } from '../../../Dialogs'; -import { websocketClient, WebsocketConnection } from '../../../../services/Websocket'; -import { Robot } from '../../../../models'; +import { websocketClient, type WebsocketConnection } from '../../../../services/Websocket'; +import { type Robot } from '../../../../models'; // Icons import CircularProgress from '@mui/material/CircularProgress'; @@ -12,7 +12,7 @@ import KeyIcon from '@mui/icons-material/Key'; import { useTheme } from '@mui/system'; import MessageCard from '../MessageCard'; import ChatHeader from '../ChatHeader'; -import { EncryptedChatMessage, ServerMessage } from '..'; +import { type EncryptedChatMessage, type ServerMessage } from '..'; import ChatBottom from '../ChatBottom'; import { sha256 } from 'js-sha256'; @@ -107,9 +107,15 @@ const EncryptedSocketChat: React.FC = ({ nick: userNick, }); - connection.onMessage((message) => setServerMessages((prev) => [...prev, message])); - connection.onClose(() => setConnected(false)); - connection.onError(() => setConnected(false)); + connection.onMessage((message) => { + setServerMessages((prev) => [...prev, message]); + }); + connection.onClose(() => { + setConnected(false); + }); + connection.onError(() => { + setConnected(false); + }); }); }; @@ -230,7 +236,9 @@ const EncryptedSocketChat: React.FC = ({ }); } }) - .catch((error) => setError(error.toString())); + .catch((error) => { + setError(error.toString()); + }); } e.preventDefault(); }; @@ -245,14 +253,18 @@ const EncryptedSocketChat: React.FC = ({ > setAudit(false)} + onClose={() => { + setAudit(false); + }} orderId={Number(orderId)} messages={messages} own_pub_key={robot.pubKey || ''} own_enc_priv_key={robot.encPrivKey || ''} peer_pub_key={peerPubKey || 'Not received yet'} passphrase={robot.token || ''} - onClickBack={() => setAudit(false)} + onClickBack={() => { + setAudit(false); + }} /> = ({ setValue(''); }); }) - .catch((error) => setError(error.toString())); + .catch((error) => { + setError(error.toString()); + }); } e.preventDefault(); }; @@ -237,14 +239,18 @@ const EncryptedTurtleChat: React.FC = ({ > setAudit(false)} + onClose={() => { + setAudit(false); + }} orderId={Number(orderId)} messages={messages} own_pub_key={robot.pubKey || ''} own_enc_priv_key={robot.encPrivKey || ''} peer_pub_key={peerPubKey || 'Not received yet'} passphrase={robot.token || ''} - onClickBack={() => setAudit(false)} + onClickBack={() => { + setAudit(false); + }} /> diff --git a/frontend/src/components/TradeBox/EncryptedChat/MessageCard/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/MessageCard/index.tsx index 4fe6faf2..6e0e12f5 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/MessageCard/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/MessageCard/index.tsx @@ -9,7 +9,7 @@ import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from '@mui/icons-material/Close'; import ContentCopy from '@mui/icons-material/ContentCopy'; import VisibilityIcon from '@mui/icons-material/Visibility'; -import { EncryptedChatMessage } from '..'; +import { type EncryptedChatMessage } from '..'; interface Props { message: EncryptedChatMessage; @@ -81,7 +81,9 @@ const MessageCard: React.FC = ({ message, isTaker, userConnected, baseUrl
setShowPGP(!showPGP)} + onClick={() => { + setShowPGP(!showPGP); + }} > = ({ message, isTaker, userConnected, baseUrl + onClick={() => { systemClient.copyToClipboard( showPGP ? message.encryptedMessage : message.plainTextMessage, - ) - } + ); + }} > setDispute({ ...dispute, statement: e.target.value })} + onChange={(e) => { + setDispute({ ...dispute, statement: e.target.value }); + }} /> @@ -67,7 +69,9 @@ export const DisputeStatementForm = ({ control={ setDispute({ ...dispute, attachLogs: !dispute.attachLogs })} + onChange={() => { + setDispute({ ...dispute, attachLogs: !dispute.attachLogs }); + }} /> } label={t('Attach chat logs')} diff --git a/frontend/src/components/TradeBox/Forms/LightningPayout.tsx b/frontend/src/components/TradeBox/Forms/LightningPayout.tsx index 8aa0e33a..83077047 100644 --- a/frontend/src/components/TradeBox/Forms/LightningPayout.tsx +++ b/frontend/src/components/TradeBox/Forms/LightningPayout.tsx @@ -21,7 +21,7 @@ import { FormHelperText, } from '@mui/material'; -import { Order, Settings } from '../../../models'; +import { type Order, type Settings } from '../../../models'; import { decode } from 'light-bolt11-decoder'; import WalletsButton from '../WalletsButton'; import { LoadingButton } from '@mui/lab'; @@ -195,7 +195,9 @@ export const LightningPayoutForm = ({ .catch(() => { setLightning({ ...lightning, badLnproxy: 'Lnproxy server uncaught error' }); }) - .finally(() => setLoadingLnproxy(false)); + .finally(() => { + setLoadingLnproxy(false); + }); }; const handleAdvancedOptions = function (checked: boolean) { @@ -291,7 +293,9 @@ export const LightningPayoutForm = ({ handleAdvancedOptions(e.target.checked)} + onChange={(e) => { + handleAdvancedOptions(e.target.checked); + }} /> @@ -375,13 +379,13 @@ export const LightningPayoutForm = ({ >
+ onChange={(e) => { setLightning({ ...lightning, useLnproxy: e.target.checked, invoice: e.target.checked ? '' : lightning.invoice, - }) - } + }); + }} checked={lightning.useLnproxy} control={} label={ @@ -419,9 +423,9 @@ export const LightningPayoutForm = ({ label={t('Server')} labelId='select-label' value={lightning.lnproxyServer} - onChange={(e) => - setLightning({ ...lightning, lnproxyServer: Number(e.target.value) }) - } + onChange={(e) => { + setLightning({ ...lightning, lnproxyServer: Number(e.target.value) }); + }} > {lnproxies.map((lnproxyServer, index) => ( @@ -494,13 +498,13 @@ export const LightningPayoutForm = ({ + onClick={() => { systemClient.copyToClipboard( lightning.useLnproxy ? String(lightning.lnproxyAmount) : String(lightning.amount), - ) - } + ); + }} > @@ -523,9 +527,9 @@ export const LightningPayoutForm = ({ style: { textAlign: 'center' }, }} variant='outlined' - onChange={(e) => - setLightning({ ...lightning, lnproxyInvoice: e.target.value ?? '' }) - } + onChange={(e) => { + setLightning({ ...lightning, lnproxyInvoice: e.target.value ?? '' }); + }} /> ) : ( <> @@ -547,7 +551,9 @@ export const LightningPayoutForm = ({ multiline={!lightning.useLnproxy} minRows={3} maxRows={5} - onChange={(e) => setLightning({ ...lightning, invoice: e.target.value ?? '' })} + onChange={(e) => { + setLightning({ ...lightning, invoice: e.target.value ?? '' }); + }} /> @@ -572,7 +578,9 @@ export const LightningPayoutForm = ({ onClickSubmit(lightning.invoice)} + onClick={() => { + onClickSubmit(lightning.invoice); + }} variant='outlined' color='primary' > diff --git a/frontend/src/components/TradeBox/Forms/OnchainPayout.tsx b/frontend/src/components/TradeBox/Forms/OnchainPayout.tsx index 94140e08..b5ecd8b7 100644 --- a/frontend/src/components/TradeBox/Forms/OnchainPayout.tsx +++ b/frontend/src/components/TradeBox/Forms/OnchainPayout.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { Grid, Typography, TextField, List, Divider, ListItemText, ListItem } from '@mui/material'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; import { LoadingButton } from '@mui/lab'; import { pn } from '../../../utils'; @@ -124,7 +124,9 @@ export const OnchainPayoutForm = ({ inputProps={{ style: { textAlign: 'center' }, }} - onChange={(e) => setOnchain({ ...onchain, address: e.target.value })} + onChange={(e) => { + setOnchain({ ...onchain, address: e.target.value }); + }} /> diff --git a/frontend/src/components/TradeBox/Prompts/Chat.tsx b/frontend/src/components/TradeBox/Prompts/Chat.tsx index 60bac6aa..b95fa968 100644 --- a/frontend/src/components/TradeBox/Prompts/Chat.tsx +++ b/frontend/src/components/TradeBox/Prompts/Chat.tsx @@ -3,9 +3,9 @@ import { useTranslation } from 'react-i18next'; import { Grid, Typography, Tooltip, Collapse, IconButton } from '@mui/material'; import currencies from '../../../../static/assets/currencies.json'; -import { Order, Robot } from '../../../models'; +import { type Order, type Robot } from '../../../models'; import { pn } from '../../../utils'; -import EncryptedChat, { EncryptedChatMessage } from '../EncryptedChat'; +import EncryptedChat, { type EncryptedChatMessage } from '../EncryptedChat'; import Countdown, { zeroPad } from 'react-countdown'; import { LoadingButton } from '@mui/lab'; diff --git a/frontend/src/components/TradeBox/Prompts/Dispute.tsx b/frontend/src/components/TradeBox/Prompts/Dispute.tsx index fa02d9ae..1f6b6dd9 100644 --- a/frontend/src/components/TradeBox/Prompts/Dispute.tsx +++ b/frontend/src/components/TradeBox/Prompts/Dispute.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Grid, Typography } from '@mui/material'; -import { DisputeForm, DisputeStatementForm } from '../Forms'; +import { type DisputeForm, DisputeStatementForm } from '../Forms'; interface DisputePromptProps { loading: boolean; diff --git a/frontend/src/components/TradeBox/Prompts/Expired.tsx b/frontend/src/components/TradeBox/Prompts/Expired.tsx index 3324b49c..bde01baf 100644 --- a/frontend/src/components/TradeBox/Prompts/Expired.tsx +++ b/frontend/src/components/TradeBox/Prompts/Expired.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { Grid, Typography } from '@mui/material'; import { LoadingButton } from '@mui/lab'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; interface ExpiredPromptProps { order: Order; diff --git a/frontend/src/components/TradeBox/Prompts/LockInvoice.tsx b/frontend/src/components/TradeBox/Prompts/LockInvoice.tsx index f5f7ee73..7452ca91 100644 --- a/frontend/src/components/TradeBox/Prompts/LockInvoice.tsx +++ b/frontend/src/components/TradeBox/Prompts/LockInvoice.tsx @@ -3,11 +3,11 @@ import { useTranslation } from 'react-i18next'; import { Button, Box, Grid, Typography, TextField, Tooltip, useTheme } from '@mui/material'; import { ContentCopy } from '@mui/icons-material'; import QRCode from 'react-qr-code'; -import { Order } from '../../../models'; +import { type Order } from '../../../models'; import { systemClient } from '../../../services/System'; import currencies from '../../../../static/assets/currencies.json'; import WalletsButton from '../WalletsButton'; -import { AppContext, UseAppStoreType } from '../../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../../contexts/AppContext'; interface LockInvoicePromptProps { order: Order; diff --git a/frontend/src/components/TradeBox/Prompts/Payout.tsx b/frontend/src/components/TradeBox/Prompts/Payout.tsx index fd65dfbf..a265e6ef 100644 --- a/frontend/src/components/TradeBox/Prompts/Payout.tsx +++ b/frontend/src/components/TradeBox/Prompts/Payout.tsx @@ -4,10 +4,15 @@ import { Grid, Typography, ToggleButtonGroup, ToggleButton } from '@mui/material import currencies from '../../../../static/assets/currencies.json'; -import { Order, Settings } from '../../../models'; +import { type Order, type Settings } from '../../../models'; import { pn } from '../../../utils'; import { Bolt, Link } from '@mui/icons-material'; -import { LightningPayoutForm, LightningForm, OnchainPayoutForm, OnchainForm } from '../Forms'; +import { + LightningPayoutForm, + type LightningForm, + OnchainPayoutForm, + type OnchainForm, +} from '../Forms'; interface PayoutPrompProps { order: Order; @@ -71,7 +76,9 @@ export const PayoutPrompt = ({ size='small' value={tab} exclusive - onChange={(mouseEvent, value) => setTab(value == null ? tab : value)} + onChange={(mouseEvent, value) => { + setTab(value == null ? tab : value); + }} >
- setButtonValue(0)}> + { + setButtonValue(0); + }} + > - setButtonValue(1)}> + { + setButtonValue(1); + }} + > - setButtonValue(2)}> + { + setButtonValue(2); + }} + > {t('Taker')}   { - const webln = await getWebln().catch(() => console.log('WebLN not available')); + const webln = await getWebln().catch(() => { + console.log('WebLN not available'); + }); // If Webln implements locked payments compatibility, this logic might be simplier if (webln == undefined) { return null; @@ -488,13 +490,21 @@ const TradeBox = ({ setOpen({ ...open, confirmFiatSent: true })} - onClickUndoConfirmSent={() => setOpen({ ...open, confirmUndoFiatSent: true })} - onClickConfirmReceived={() => setOpen({ ...open, confirmFiatReceived: true })} + onClickConfirmSent={() => { + setOpen({ ...open, confirmFiatSent: true }); + }} + onClickUndoConfirmSent={() => { + setOpen({ ...open, confirmUndoFiatSent: true }); + }} + onClickConfirmReceived={() => { + setOpen({ ...open, confirmFiatReceived: true }); + }} loadingSent={loadingButtons.fiatSent} loadingUndoSent={loadingButtons.undoFiatSent} loadingReceived={loadingButtons.fiatReceived} - onClickDispute={() => setOpen({ ...open, confirmDispute: true })} + onClickDispute={() => { + setOpen({ ...open, confirmDispute: true }); + }} loadingDispute={loadingButtons.openDispute} baseUrl={baseUrl} messages={messages} @@ -668,23 +678,31 @@ const TradeBox = ({ setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} waitingWebln={waitingWebln} isBuyer={order.is_buyer} /> setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onAgreeClick={openDispute} /> setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onCancelClick={cancel} /> setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onCollabCancelClick={cancel} loading={loadingButtons.cancel} peerAskedCancel={order.pending_cancel} @@ -693,21 +711,27 @@ const TradeBox = ({ open={open.confirmFiatSent} order={order} loadingButton={loadingButtons.fiatSent} - onClose={() => setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onConfirmClick={confirmFiatSent} /> setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onConfirmClick={confirmUndoFiatSent} /> setOpen(closeAll)} + onClose={() => { + setOpen(closeAll); + }} onConfirmClick={confirmFiatReceived} /> @@ -745,8 +769,12 @@ const TradeBox = ({ setOpen({ ...closeAll, confirmCancel: true })} - openCollabCancelDialog={() => setOpen({ ...closeAll, confirmCollabCancel: true })} + openCancelDialog={() => { + setOpen({ ...closeAll, confirmCancel: true }); + }} + openCollabCancelDialog={() => { + setOpen({ ...closeAll, confirmCollabCancel: true }); + }} loading={loadingButtons.cancel} /> diff --git a/frontend/src/components/TradeBox/stepXofY.ts b/frontend/src/components/TradeBox/stepXofY.ts index 98644d15..af504193 100644 --- a/frontend/src/components/TradeBox/stepXofY.ts +++ b/frontend/src/components/TradeBox/stepXofY.ts @@ -1,4 +1,4 @@ -import { Order } from '../../models'; +import { type Order } from '../../models'; const stepXofY = function (order: Order): string { // set y value diff --git a/frontend/src/components/UnsafeAlert.tsx b/frontend/src/components/UnsafeAlert.tsx index 51a0019e..09d162e1 100644 --- a/frontend/src/components/UnsafeAlert.tsx +++ b/frontend/src/components/UnsafeAlert.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext } from 'react'; -import { AppContext, UseAppStoreType } from '../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../contexts/AppContext'; import { useTranslation, Trans } from 'react-i18next'; import { Paper, Alert, AlertTitle, Button, Link } from '@mui/material'; import { getHost } from '../utils'; @@ -57,7 +57,12 @@ const UnsafeAlert = (): JSX.Element => { severity='success' sx={{ maxHeight: '8em' }} action={ - } @@ -80,7 +85,15 @@ const UnsafeAlert = (): JSX.Element => { setShow(false)}>{t('Hide')}} + action={ + + } > {t('You are not using RoboSats privately')} @@ -120,7 +133,12 @@ const UnsafeAlert = (): JSX.Element => { site.
-
diff --git a/frontend/src/contexts/AppContext.ts b/frontend/src/contexts/AppContext.ts index 9c069614..26797527 100644 --- a/frontend/src/contexts/AppContext.ts +++ b/frontend/src/contexts/AppContext.ts @@ -1,20 +1,20 @@ import React, { createContext, useEffect, useState } from 'react'; -import { Page } from '../basic/NavBar'; -import { OpenDialogs } from '../basic/MainDialogs'; +import { type Page } from '../basic/NavBar'; +import { type OpenDialogs } from '../basic/MainDialogs'; import { - Book, - LimitList, - Maker, + type Book, + type LimitList, + type Maker, Robot, Garage, - Info, + type Info, Settings, - Favorites, + type Favorites, defaultMaker, defaultInfo, - Coordinator, - Order, + type Coordinator, + type Order, } from '../models'; import { apiClient } from '../services/api'; @@ -22,7 +22,7 @@ import { checkVer, getHost, hexToBase91, validateTokenEntropy } from '../utils'; import { sha256 } from 'js-sha256'; import defaultCoordinators from '../../static/federation.json'; -import { createTheme, Theme } from '@mui/material/styles'; +import { createTheme, type Theme } from '@mui/material/styles'; import i18n from '../i18n/Web'; import { systemClient } from '../services/System'; @@ -163,7 +163,12 @@ export const useAppStore = () => { useEffect(() => { window.addEventListener('torStatus', (event) => { // Trick to improve UX on Android webview: delay the "Connected to TOR" status by 5 secs to avoid long waits on the first request. - setTimeout(() => setTorStatus(event?.detail), event?.detail === '"Done"' ? 5000 : 0); + setTimeout( + () => { + setTorStatus(event?.detail); + }, + event?.detail === '"Done"' ? 5000 : 0, + ); }); }, []); @@ -213,12 +218,12 @@ export const useAppStore = () => { setBook((book) => { return { ...book, loading: true }; }); - apiClient.get(baseUrl, '/api/book/').then((data: any) => + apiClient.get(baseUrl, '/api/book/').then((data: any) => { setBook({ loading: false, orders: data.not_found ? [] : data, - }), - ); + }); + }); }; const fetchLimits = async () => { @@ -272,7 +277,9 @@ export const useAppStore = () => { useEffect(() => { clearInterval(timer); setTimer(setInterval(fetchOrder, delay)); - return () => clearInterval(timer); + return () => { + clearInterval(timer); + }; }, [delay, currentOrder, page, badOrder]); const orderReceived = function (data: any) { diff --git a/frontend/src/models/Garage.model.ts b/frontend/src/models/Garage.model.ts index c377690e..fa4df0cc 100644 --- a/frontend/src/models/Garage.model.ts +++ b/frontend/src/models/Garage.model.ts @@ -1,4 +1,4 @@ -import { Robot, Order } from '.'; +import { Robot, type Order } from '.'; import { systemClient } from '../services/System'; import { saveAsJson } from '../utils'; export interface Slot { diff --git a/frontend/src/models/Limit.model.ts b/frontend/src/models/Limit.model.ts index fad01981..0bd892c6 100644 --- a/frontend/src/models/Limit.model.ts +++ b/frontend/src/models/Limit.model.ts @@ -6,8 +6,6 @@ export interface Limit { max_bondless_amount: number; } -export interface LimitList { - [currencyCode: string]: Limit; -} +export type LimitList = Record; export default Limit; diff --git a/frontend/src/pro/Main.tsx b/frontend/src/pro/Main.tsx index 738f1220..c55255b6 100644 --- a/frontend/src/pro/Main.tsx +++ b/frontend/src/pro/Main.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useContext, useState } from 'react'; -import GridLayout, { Layout } from 'react-grid-layout'; +import GridLayout, { type Layout } from 'react-grid-layout'; import { Grid, styled, useTheme } from '@mui/material'; import { @@ -12,7 +12,7 @@ import { import ToolBar from '../pro/ToolBar'; import LandingDialog from '../pro/LandingDialog'; -import { AppContext, UseAppStoreType } from '../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../contexts/AppContext'; // To Do. Add dotted grid when layout is not frozen // ${freeze ? @@ -83,7 +83,12 @@ const Main = (): JSX.Element => { - setOpenLanding(!openLanding)} /> + { + setOpenLanding(!openLanding); + }} + /> @@ -101,7 +106,9 @@ const Main = (): JSX.Element => { isResizable={!settings.freezeViewports} rowHeight={gridCellSize * em} // rows are 2em high autoSize={true} - onLayoutChange={(layout: Layout) => setLayout(layout)} + onLayoutChange={(layout: Layout) => { + setLayout(layout); + }} >
diff --git a/frontend/src/pro/ToolBar/index.tsx b/frontend/src/pro/ToolBar/index.tsx index a78ab3af..b2246a00 100644 --- a/frontend/src/pro/ToolBar/index.tsx +++ b/frontend/src/pro/ToolBar/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Paper, Grid, IconButton, Tooltip, Typography } from '@mui/material'; import { Lock, LockOpen } from '@mui/icons-material'; import { useTranslation } from 'react-i18next'; -import { Settings } from '../../models'; +import { type Settings } from '../../models'; interface ToolBarProps { settings: Settings; @@ -39,9 +39,9 @@ const ToolBar = ({ height = '3em', settings, setSettings }: ToolBarProps): JSX.E enterNextDelay={2000} > - setSettings({ ...settings, freezeViewports: !settings.freezeViewports }) - } + onClick={() => { + setSettings({ ...settings, freezeViewports: !settings.freezeViewports }); + }} sx={{ position: 'fixed', right: '1em', top: '0em', color: 'text.secondary' }} > {settings.freezeViewports ? : } diff --git a/frontend/src/pro/Widgets/Book.tsx b/frontend/src/pro/Widgets/Book.tsx index 4a764ffc..358bd084 100644 --- a/frontend/src/pro/Widgets/Book.tsx +++ b/frontend/src/pro/Widgets/Book.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; -import { Book, Favorites } from '../../models'; +import { type Book, type Favorites } from '../../models'; import { Paper } from '@mui/material'; import BookTable from '../../components/BookTable'; diff --git a/frontend/src/pro/Widgets/Depth.tsx b/frontend/src/pro/Widgets/Depth.tsx index b3ead134..cfafaf63 100644 --- a/frontend/src/pro/Widgets/Depth.tsx +++ b/frontend/src/pro/Widgets/Depth.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { Paper, useTheme } from '@mui/material'; import DepthChart from '../../components/Charts/DepthChart'; diff --git a/frontend/src/pro/Widgets/Maker.tsx b/frontend/src/pro/Widgets/Maker.tsx index c1a26ab3..9acd962f 100644 --- a/frontend/src/pro/Widgets/Maker.tsx +++ b/frontend/src/pro/Widgets/Maker.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; +import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import MakerForm from '../../components/MakerForm'; import { LimitList, Maker, Favorites } from '../../models'; diff --git a/frontend/src/pro/Widgets/Settings.tsx b/frontend/src/pro/Widgets/Settings.tsx index cfe99f0b..2e86b070 100644 --- a/frontend/src/pro/Widgets/Settings.tsx +++ b/frontend/src/pro/Widgets/Settings.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { UseAppStoreType, AppContext } from '../../contexts/AppContext'; +import { type UseAppStoreType, AppContext } from '../../contexts/AppContext'; import { Settings } from '../../models'; import { Paper } from '@mui/material'; import SettingsForm from '../../components/SettingsForm'; diff --git a/frontend/src/services/Native/index.d.ts b/frontend/src/services/Native/index.d.ts index 4ed495e8..6683c90d 100644 --- a/frontend/src/services/Native/index.d.ts +++ b/frontend/src/services/Native/index.d.ts @@ -1,4 +1,4 @@ -import NativeRobosats from './index'; +import type NativeRobosats from './index'; declare global { interface Window { diff --git a/frontend/src/services/Native/index.ts b/frontend/src/services/Native/index.ts index fda462b2..532180e6 100644 --- a/frontend/src/services/Native/index.ts +++ b/frontend/src/services/Native/index.ts @@ -1,13 +1,17 @@ -import { NativeRobosatsPromise, NativeWebViewMessage, NativeWebViewMessageSystem } from './index.d'; +import { + type NativeRobosatsPromise, + type NativeWebViewMessage, + type NativeWebViewMessageSystem, +} from './index.d'; class NativeRobosats { public torDaemonStatus = 'NOTINIT'; private messageCounter: number = 0; - private pendingMessages: { [id: number]: NativeRobosatsPromise } = {}; + private pendingMessages: Record = {}; - public cookies: { [key: string]: string } = {}; + public cookies: Record = {}; public loadCookie = (cookie: { key: string; value: string }) => { this.cookies[cookie.key] = cookie.value; @@ -44,7 +48,7 @@ class NativeRobosats { } }; - public postMessage: (message: NativeWebViewMessage) => Promise<{ [key: string]: any }> = async ( + public postMessage: (message: NativeWebViewMessage) => Promise> = async ( message, ) => { this.messageCounter += 1; diff --git a/frontend/src/services/System/SystemNativeClient/index.ts b/frontend/src/services/System/SystemNativeClient/index.ts index 03999cfb..a37da1fb 100644 --- a/frontend/src/services/System/SystemNativeClient/index.ts +++ b/frontend/src/services/System/SystemNativeClient/index.ts @@ -1,4 +1,4 @@ -import { SystemClient } from '..'; +import { type SystemClient } from '..'; import NativeRobosats from '../../Native'; class SystemNativeClient implements SystemClient { diff --git a/frontend/src/services/System/SystemWebClient/index.ts b/frontend/src/services/System/SystemWebClient/index.ts index aed9ecdd..19365ec1 100644 --- a/frontend/src/services/System/SystemWebClient/index.ts +++ b/frontend/src/services/System/SystemWebClient/index.ts @@ -1,4 +1,4 @@ -import { SystemClient } from '..'; +import { type SystemClient } from '..'; class SystemWebClient implements SystemClient { public loading = false; diff --git a/frontend/src/services/Websocket/WebsocketConnectionWeb/index.ts b/frontend/src/services/Websocket/WebsocketConnectionWeb/index.ts index 831e0be8..70fbf3d3 100644 --- a/frontend/src/services/Websocket/WebsocketConnectionWeb/index.ts +++ b/frontend/src/services/Websocket/WebsocketConnectionWeb/index.ts @@ -1,12 +1,14 @@ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { WebsocketConnection } from '..'; +import { type WebsocketConnection } from '..'; class WebsocketConnectionWeb implements WebsocketConnection { constructor(path: string) { this.rws = new ReconnectingWebSocket(path, [], { + WebSocket, + minReconnectionDelay: 15000, connectionTimeout: 15000, - reconnectionDelayGrowFactor: 1.5, - maxRetries: 15, + reconnectionDelayGrowFactor: 2, + maxRetries: 4, maxReconnectionDelay: 1000000, }); } diff --git a/frontend/src/services/Websocket/WebsocketWebClient/index.ts b/frontend/src/services/Websocket/WebsocketWebClient/index.ts index 494a0308..4fbdf36b 100644 --- a/frontend/src/services/Websocket/WebsocketWebClient/index.ts +++ b/frontend/src/services/Websocket/WebsocketWebClient/index.ts @@ -1,4 +1,4 @@ -import { WebsocketClient, WebsocketConnection } from '..'; +import { type WebsocketClient, type WebsocketConnection } from '..'; import WebsocketConnectionWeb from '../WebsocketConnectionWeb'; class WebsocketWebClient implements WebsocketClient { diff --git a/frontend/src/services/api/ApiNativeClient/index.ts b/frontend/src/services/api/ApiNativeClient/index.ts index 8223a093..5181ca29 100644 --- a/frontend/src/services/api/ApiNativeClient/index.ts +++ b/frontend/src/services/api/ApiNativeClient/index.ts @@ -1,16 +1,16 @@ -import { ApiClient, Auth } from '..'; +import { type ApiClient, type Auth } from '..'; import { systemClient } from '../../System'; class ApiNativeClient implements ApiClient { - private assetsCache: { [path: string]: string } = {}; - private assetsPromises: { [path: string]: Promise } = {}; + private assetsCache: Record = {}; + private assetsPromises: Record> = {}; private readonly getHeaders: (auth?: Auth) => HeadersInit = (auth) => { let headers = { 'Content-Type': 'application/json', }; - if (auth) { + if (auth != null) { headers = { ...headers, ...{ @@ -19,7 +19,7 @@ class ApiNativeClient implements ApiClient { }; } - if (auth?.keys) { + if (auth?.keys != null) { headers = { ...headers, ...{ @@ -31,7 +31,7 @@ class ApiNativeClient implements ApiClient { return headers; }; - private readonly parseResponse = (response: { [key: string]: any }): object => { + private readonly parseResponse = (response: Record): object => { if (response.headers['set-cookie']) { response.headers['set-cookie'].forEach((cookie: string) => { const keySplit: string[] = cookie.split('='); @@ -46,7 +46,9 @@ class ApiNativeClient implements ApiClient { path, body, ) => { - return await new Promise((res, _rej) => res({})); + return await new Promise((res, _rej) => { + res({}); + }); }; public delete: (baseUrl: string, path: string, auth?: Auth) => Promise = diff --git a/frontend/src/services/api/ApiWebClient/index.ts b/frontend/src/services/api/ApiWebClient/index.ts index a942c87c..d8f79711 100644 --- a/frontend/src/services/api/ApiWebClient/index.ts +++ b/frontend/src/services/api/ApiWebClient/index.ts @@ -1,4 +1,4 @@ -import { ApiClient, Auth } from '..'; +import { type ApiClient, type Auth } from '..'; import { systemClient } from '../../System'; class ApiWebClient implements ApiClient { @@ -7,7 +7,7 @@ class ApiWebClient implements ApiClient { 'Content-Type': 'application/json', }; - if (auth) { + if (auth != null) { headers = { ...headers, ...{ @@ -17,7 +17,7 @@ class ApiWebClient implements ApiClient { } // set cookies before sending the request - if (auth?.keys) { + if (auth?.keys != null) { systemClient.setCookie('public_key', auth.keys.pubKey); systemClient.setCookie('encrypted_private_key', auth.keys.encPrivKey); } diff --git a/frontend/src/utils/filterOrders.ts b/frontend/src/utils/filterOrders.ts index 1dc1cf75..463af8ac 100644 --- a/frontend/src/utils/filterOrders.ts +++ b/frontend/src/utils/filterOrders.ts @@ -1,4 +1,4 @@ -import { PublicOrder, Favorites } from '../models'; +import { type PublicOrder, type Favorites } from '../models'; interface AmountFilter { amount: string; diff --git a/frontend/src/utils/hexToBase91.ts b/frontend/src/utils/hexToBase91.ts index edfe5d24..73955d3a 100644 --- a/frontend/src/utils/hexToBase91.ts +++ b/frontend/src/utils/hexToBase91.ts @@ -2,7 +2,7 @@ import { Base91 } from 'base-ex'; export default function hexToBase85(hex: string): string { const hexes = hex.match(/.{1,2}/g); - if (!hexes) return ''; + if (hexes == null) return ''; const byteArray = hexes.map((byte) => parseInt(byte, 16)); const b91 = new Base91(); const base91string = b91.encode(new Uint8Array(byteArray)); diff --git a/frontend/src/utils/webln.ts b/frontend/src/utils/webln.ts index aefecccb..72253e18 100644 --- a/frontend/src/utils/webln.ts +++ b/frontend/src/utils/webln.ts @@ -1,4 +1,4 @@ -import { requestProvider, WeblnProvider } from 'webln'; +import { requestProvider, type WeblnProvider } from 'webln'; const getWebln = async (): Promise => { const resultPromise = new Promise(async (resolve, reject) => {