Merge pull request #1403 from RoboSats/dependabot/npm_and_yarn/mobile/typescript-eslint/eslint-plugin-8.0.1

chore(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.7 to 8.0.1 in /mobile
This commit is contained in:
KoalaSat 2024-08-10 15:57:48 +00:00 committed by GitHub
commit 4c5670d8b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 757 additions and 220 deletions

View File

@ -40,14 +40,14 @@ const OrderPage = (): JSX.Element => {
const shortAlias = params.shortAlias;
const coordinator = federation.getCoordinator(shortAlias ?? '');
if (coordinator) {
const { url, basePath } = coordinator?.getEndpoint(
const endpoint = coordinator?.getEndpoint(
settings.network,
origin,
settings.selfhostedClient,
hostUrl,
);
setBaseUrl(`${url}${basePath}`);
if (endpoint) setBaseUrl(`${endpoint?.url}${endpoint?.basePath}`);
const orderId = Number(params.orderId);
if (

View File

@ -156,7 +156,7 @@ const RobotProfile = ({
)}
</Grid>
{loadingCoordinators > 0 && !Boolean(robot?.activeOrderId) ? (
{loadingCoordinators > 0 && !robot?.activeOrderId ? (
<Grid>
<b>{t('Looking for orders!')}</b>
<LinearProgress />
@ -210,9 +210,9 @@ const RobotProfile = ({
</Grid>
) : null}
{!Boolean(robot?.activeOrderId) &&
{!robot?.activeOrderId &&
slot?.hashId &&
!Boolean(robot?.lastOrderId) &&
!robot?.lastOrderId &&
loadingCoordinators === 0 ? (
<Grid item>{t('No existing orders found')}</Grid>
) : null}

View File

@ -4,7 +4,7 @@ import SettingsForm from '../../components/SettingsForm';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import FederationTable from '../../components/FederationTable';
import { t } from 'i18next';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
const SettingsPage = (): JSX.Element => {
const { windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
@ -16,7 +16,7 @@ const SettingsPage = (): JSX.Element => {
// Regular expression to match a valid .onion URL
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
const addCoordinator = () => {
const addCoordinator: () => void = () => {
if (federation.coordinators[newAlias]) {
setError(t('Alias already exists'));
} else {
@ -65,7 +65,9 @@ const SettingsPage = (): JSX.Element => {
variant='outlined'
size='small'
value={newAlias}
onChange={(e) => setNewAlias(e.target.value)}
onChange={(e) => {
setNewAlias(e.target.value);
}}
/>
<TextField
id='outlined-basic'
@ -73,7 +75,9 @@ const SettingsPage = (): JSX.Element => {
variant='outlined'
size='small'
value={newUrl}
onChange={(e) => setNewUrl(e.target.value)}
onChange={(e) => {
setNewUrl(e.target.value);
}}
/>
<Button
sx={{ maxHeight: 38 }}

View File

@ -14,7 +14,6 @@ import {
LinearProgress,
IconButton,
Tooltip,
type LinearProgressProps,
styled,
} from '@mui/material';
import {
@ -24,7 +23,7 @@ import {
type GridPaginationModel,
type GridColDef,
type GridValidRowModel,
GridSlotsComponent,
type GridSlotsComponent,
} from '@mui/x-data-grid';
import currencyDict from '../../../static/assets/currencies.json';
import { type PublicOrder } from '../../models';
@ -831,14 +830,6 @@ const BookTable = ({
);
};
interface GridComponentProps {
LoadingOverlay: (props: LinearProgressProps) => JSX.Element;
NoResultsOverlay?: (props: any) => JSX.Element;
NoRowsOverlay?: (props: any) => JSX.Element;
Footer?: (props: any) => JSX.Element;
Toolbar?: (props: any) => JSX.Element;
}
const NoResultsOverlay = function (): JSX.Element {
return (
<Grid

View File

@ -1,4 +1,4 @@
import React, { useContext, useEffect, useMemo, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {

View File

@ -409,9 +409,8 @@ const AutocompletePayments: React.FC<AutocompletePaymentsProps> = (props) => {
))}
{qttHiddenTags > 0 ? (
<StyledChip
sx={{ borderRadius: 1 }}
label={`+${qttHiddenTags}`}
sx={{ height: '1.6rem' }}
sx={{ borderRadius: 1, height: '1.6rem' }}
/>
) : null}
</>

View File

@ -1,4 +1,4 @@
import React, { useContext, useMemo } from 'react';
import React, { useContext } from 'react';
import {
Grid,
Select,

View File

@ -1,4 +1,4 @@
import React, { useContext, useEffect } from 'react';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
import {
@ -26,13 +26,10 @@ import {
AccountBalance,
AttachMoney,
QrCode,
ControlPoint,
} from '@mui/icons-material';
import { systemClient } from '../../services/System';
import { TorIcon } from '../Icons';
import SwapCalls from '@mui/icons-material/SwapCalls';
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
import { GarageContext, UseGarageStoreType } from '../../contexts/GarageContext';
import { apiClient } from '../../services/api';
interface SettingsFormProps {
@ -41,8 +38,6 @@ interface SettingsFormProps {
const SettingsForm = ({ dense = false }: SettingsFormProps): JSX.Element => {
const { fav, setFav, settings, setSettings } = useContext<UseAppStoreType>(AppContext);
const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { garage } = useContext<UseGarageStoreType>(GarageContext);
const theme = useTheme();
const { t } = useTranslation();
const fontSizes = [

View File

@ -4,19 +4,17 @@ import React, {
useEffect,
useState,
type SetStateAction,
useMemo,
useContext,
type ReactNode,
} from 'react';
import { type Order, Federation, Settings, Coordinator } from '../models';
import { type Order, Federation, Settings } from '../models';
import { federationLottery } from '../utils';
import { AppContext, type UseAppStoreType } from './AppContext';
import { GarageContext, type UseGarageStoreType } from './GarageContext';
import NativeRobosats from '../services/Native';
import { Origins } from '../models/Coordinator.model';
import { type Origin, type Origins } from '../models/Coordinator.model';
// Refresh delays (ms) according to Order status
const defaultDelay = 5000;
@ -175,14 +173,15 @@ export const FederationContextProvider = ({
federated: false,
enabled: true,
};
const origins: Origins = {
clearnet: undefined,
onion: url as Origin,
i2p: undefined,
};
if (settings.network === 'mainnet') {
attributes.mainnet = {
onion: url,
} as Origins;
attributes.mainnet = origins;
} else {
attributes.testnet = {
onion: url,
} as Origins;
attributes.testnet = origins;
}
federation.addCoordinator(origin, settings, hostUrl, attributes);
const newCoordinator = federation.coordinators[alias];

View File

@ -210,7 +210,7 @@ export class Coordinator {
generateAllMakerAvatars = async (data: [PublicOrder]): Promise<void> => {
for (const order of data) {
roboidentitiesClient.generateRobohash(order.maker_hash_id, 'small');
void roboidentitiesClient.generateRobohash(order.maker_hash_id, 'small');
}
};

View File

@ -55,7 +55,7 @@ export class Federation {
settings: Settings,
hostUrl: string,
attributes: Record<any, any>,
) => {
): void => {
const value = {
...coordinatorDefaultValues,
...attributes,
@ -111,7 +111,7 @@ export class Federation {
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
this.updateEnabledCoordinators();
for (const coor of Object.values(this.coordinators)) {
coor.update(() => {
void coor.update(() => {
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
this.onCoordinatorSaved();
});
@ -124,7 +124,7 @@ export class Federation {
this.triggerHook('onCoordinatorUpdate');
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
for (const coor of Object.values(this.coordinators)) {
coor.updateBook(() => {
void coor.updateBook(() => {
this.onCoordinatorSaved();
});
}

View File

@ -1,4 +1,4 @@
import { Coordinator, type Order } from '.';
import { type Coordinator, type Order } from '.';
import { systemClient } from '../services/System';
import { saveAsJson } from '../utils';
import Slot from './Slot.model';
@ -59,8 +59,13 @@ class Garage {
const rawSlots = JSON.parse(slotsDump);
Object.values(rawSlots).forEach((rawSlot: Record<any, any>) => {
if (rawSlot?.token) {
this.slots[rawSlot.token] = new Slot(rawSlot.token, Object.keys(rawSlot.robots), {}, () =>
this.triggerHook('onRobotUpdate'),
this.slots[rawSlot.token] = new Slot(
rawSlot.token,
Object.keys(rawSlot.robots),
{},
() => {
this.triggerHook('onRobotUpdate');
},
);
Object.keys(rawSlot.robots).forEach((shortAlias) => {
const rawRobot = rawSlot.robots[shortAlias];
@ -118,9 +123,9 @@ class Garage {
if (!token || !shortAliases) return;
if (this.getSlot(token) === null) {
this.slots[token] = new Slot(token, shortAliases, attributes, () =>
this.triggerHook('onRobotUpdate'),
);
this.slots[token] = new Slot(token, shortAliases, attributes, () => {
this.triggerHook('onRobotUpdate');
});
this.save();
}
};

View File

@ -1,5 +1,5 @@
import { sha256 } from 'js-sha256';
import { Coordinator, Garage, Robot, type Order } from '.';
import { type Coordinator, type Garage, Robot, type Order } from '.';
import { roboidentitiesClient } from '../services/Roboidentities/Web';
class Slot {
@ -13,12 +13,12 @@ class Slot {
this.hashId = sha256(sha256(this.token));
this.nickname = null;
roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
void roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
this.nickname = nickname;
onRobotUpdate();
});
roboidentitiesClient.generateRobohash(this.hashId, 'small');
roboidentitiesClient.generateRobohash(this.hashId, 'large');
void roboidentitiesClient.generateRobohash(this.hashId, 'small');
void roboidentitiesClient.generateRobohash(this.hashId, 'large');
this.robots = shortAliases.reduce((acc: Record<string, Robot>, shortAlias: string) => {
acc[shortAlias] = new Robot(robotAttributes);
@ -82,7 +82,7 @@ class Slot {
pubKey: defaultRobot.pubKey,
encPrivKey: defaultRobot.encPrivKey,
});
coordinator.fetchRobot(garage, defaultRobot.token);
void coordinator.fetchRobot(garage, defaultRobot.token);
}
};
}

View File

@ -1,4 +1,4 @@
import RoboidentitiesClientNativeClient from './RoboidentitiesNativeClient';
import { RoboidentitiesClient } from './type';
import { type RoboidentitiesClient } from './type';
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientNativeClient();

View File

@ -31,8 +31,8 @@ class RoboidentitiesNativeClient implements RoboidentitiesClient {
type: 'robohash',
detail: key,
});
const result = response ? Object.values(response)[0] : '';
const image = `data:image/png;base64,${result}`;
const result: string = response ? Object.values(response)[0] : '';
const image: string = `data:image/png;base64,${result}`;
this.robohashes[key] = image;
return image;
}

View File

@ -4,14 +4,14 @@ import { robohash } from './RobohashGenerator';
class RoboidentitiesClientWebClient implements RoboidentitiesClient {
public generateRoboname: (initialString: string) => Promise<string> = async (initialString) => {
return new Promise<string>(async (resolve, _reject) => {
return await new Promise<string>((resolve, _reject) => {
resolve(generate_roboname(initialString));
});
};
public generateRobohash: (initialString: string, size: 'small' | 'large') => Promise<string> =
async (initialString, size) => {
return robohash.generate(initialString, size);
return await robohash.generate(initialString, size);
};
}

View File

@ -1,4 +1,4 @@
import RoboidentitiesClientWebClient from './RoboidentitiesWebClient';
import { RoboidentitiesClient } from './type';
import { type RoboidentitiesClient } from './type';
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientWebClient();

View File

@ -5,7 +5,7 @@ import ApiWebClient from '../ApiWebClient';
class ApiNativeClient implements ApiClient {
public useProxy = true;
private webClient: ApiClient = new ApiWebClient();
private readonly webClient: ApiClient = new ApiWebClient();
private readonly assetsPromises = new Map<string, Promise<string | undefined>>();
@ -55,7 +55,7 @@ class ApiNativeClient implements ApiClient {
public delete: (baseUrl: string, path: string, auth?: Auth) => Promise<object | undefined> =
async (baseUrl, path, auth) => {
if (!this.useProxy) return this.webClient.delete(baseUrl, path, auth);
if (!this.useProxy) return await this.webClient.delete(baseUrl, path, auth);
return await window.NativeRobosats?.postMessage({
category: 'http',
type: 'delete',
@ -71,7 +71,7 @@ class ApiNativeClient implements ApiClient {
body: object,
auth?: Auth,
) => Promise<object | undefined> = async (baseUrl, path, body, auth) => {
if (!this.useProxy) return this.webClient.post(baseUrl, path, body, auth);
if (!this.useProxy) return await this.webClient.post(baseUrl, path, body, auth);
return await window.NativeRobosats?.postMessage({
category: 'http',
type: 'post',
@ -87,7 +87,7 @@ class ApiNativeClient implements ApiClient {
path,
auth,
) => {
if (!this.useProxy) return this.webClient.get(baseUrl, path, auth);
if (!this.useProxy) return await this.webClient.get(baseUrl, path, auth);
return await window.NativeRobosats?.postMessage({
category: 'http',
type: 'get',

View File

@ -16,14 +16,6 @@ export interface AggregatedInfo {
version: Version;
}
type toAdd =
| 'num_public_buy_orders'
| 'num_public_sell_orders'
| 'book_liquidity'
| 'active_robots_today'
| 'last_day_volume'
| 'lifetime_volume';
export const weightedMean = (arrValues: number[], arrWeights: number[]): number => {
if (arrValues.length === 0) {
return 0;

846
mobile/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
"@types/jest": "^29.5.12",
"@types/react-native": "^0.71.3",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^5.59.6",
"babel-jest": "^29.7.0",
"eslint": "^8.39.0",