mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Eslint fixes
This commit is contained in:
parent
a936006a65
commit
958da6a11b
@ -40,14 +40,14 @@ const OrderPage = (): JSX.Element => {
|
|||||||
const shortAlias = params.shortAlias;
|
const shortAlias = params.shortAlias;
|
||||||
const coordinator = federation.getCoordinator(shortAlias ?? '');
|
const coordinator = federation.getCoordinator(shortAlias ?? '');
|
||||||
if (coordinator) {
|
if (coordinator) {
|
||||||
const { url, basePath } = coordinator?.getEndpoint(
|
const endpoint = coordinator?.getEndpoint(
|
||||||
settings.network,
|
settings.network,
|
||||||
origin,
|
origin,
|
||||||
settings.selfhostedClient,
|
settings.selfhostedClient,
|
||||||
hostUrl,
|
hostUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
setBaseUrl(`${url}${basePath}`);
|
if (endpoint) setBaseUrl(`${endpoint?.url}${endpoint?.basePath}`);
|
||||||
|
|
||||||
const orderId = Number(params.orderId);
|
const orderId = Number(params.orderId);
|
||||||
if (
|
if (
|
||||||
|
@ -156,7 +156,7 @@ const RobotProfile = ({
|
|||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
{loadingCoordinators > 0 && !Boolean(robot?.activeOrderId) ? (
|
{loadingCoordinators > 0 && !robot?.activeOrderId ? (
|
||||||
<Grid>
|
<Grid>
|
||||||
<b>{t('Looking for orders!')}</b>
|
<b>{t('Looking for orders!')}</b>
|
||||||
<LinearProgress />
|
<LinearProgress />
|
||||||
@ -210,9 +210,9 @@ const RobotProfile = ({
|
|||||||
</Grid>
|
</Grid>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{!Boolean(robot?.activeOrderId) &&
|
{!robot?.activeOrderId &&
|
||||||
slot?.hashId &&
|
slot?.hashId &&
|
||||||
!Boolean(robot?.lastOrderId) &&
|
!robot?.lastOrderId &&
|
||||||
loadingCoordinators === 0 ? (
|
loadingCoordinators === 0 ? (
|
||||||
<Grid item>{t('No existing orders found')}</Grid>
|
<Grid item>{t('No existing orders found')}</Grid>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -4,7 +4,7 @@ import SettingsForm from '../../components/SettingsForm';
|
|||||||
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
||||||
import FederationTable from '../../components/FederationTable';
|
import FederationTable from '../../components/FederationTable';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';
|
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||||
|
|
||||||
const SettingsPage = (): JSX.Element => {
|
const SettingsPage = (): JSX.Element => {
|
||||||
const { windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
|
const { windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
|
||||||
@ -16,7 +16,7 @@ const SettingsPage = (): JSX.Element => {
|
|||||||
// Regular expression to match a valid .onion URL
|
// Regular expression to match a valid .onion URL
|
||||||
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
|
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
|
||||||
|
|
||||||
const addCoordinator = () => {
|
const addCoordinator: () => void = () => {
|
||||||
if (federation.coordinators[newAlias]) {
|
if (federation.coordinators[newAlias]) {
|
||||||
setError(t('Alias already exists'));
|
setError(t('Alias already exists'));
|
||||||
} else {
|
} else {
|
||||||
@ -65,7 +65,9 @@ const SettingsPage = (): JSX.Element => {
|
|||||||
variant='outlined'
|
variant='outlined'
|
||||||
size='small'
|
size='small'
|
||||||
value={newAlias}
|
value={newAlias}
|
||||||
onChange={(e) => setNewAlias(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setNewAlias(e.target.value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
id='outlined-basic'
|
id='outlined-basic'
|
||||||
@ -73,7 +75,9 @@ const SettingsPage = (): JSX.Element => {
|
|||||||
variant='outlined'
|
variant='outlined'
|
||||||
size='small'
|
size='small'
|
||||||
value={newUrl}
|
value={newUrl}
|
||||||
onChange={(e) => setNewUrl(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setNewUrl(e.target.value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
sx={{ maxHeight: 38 }}
|
sx={{ maxHeight: 38 }}
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
LinearProgress,
|
LinearProgress,
|
||||||
IconButton,
|
IconButton,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
type LinearProgressProps,
|
|
||||||
styled,
|
styled,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import {
|
import {
|
||||||
@ -24,7 +23,7 @@ import {
|
|||||||
type GridPaginationModel,
|
type GridPaginationModel,
|
||||||
type GridColDef,
|
type GridColDef,
|
||||||
type GridValidRowModel,
|
type GridValidRowModel,
|
||||||
GridSlotsComponent,
|
type GridSlotsComponent,
|
||||||
} from '@mui/x-data-grid';
|
} from '@mui/x-data-grid';
|
||||||
import currencyDict from '../../../static/assets/currencies.json';
|
import currencyDict from '../../../static/assets/currencies.json';
|
||||||
import { type PublicOrder } from '../../models';
|
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 {
|
const NoResultsOverlay = function (): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
|
@ -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 { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -409,9 +409,8 @@ const AutocompletePayments: React.FC<AutocompletePaymentsProps> = (props) => {
|
|||||||
))}
|
))}
|
||||||
{qttHiddenTags > 0 ? (
|
{qttHiddenTags > 0 ? (
|
||||||
<StyledChip
|
<StyledChip
|
||||||
sx={{ borderRadius: 1 }}
|
|
||||||
label={`+${qttHiddenTags}`}
|
label={`+${qttHiddenTags}`}
|
||||||
sx={{ height: '1.6rem' }}
|
sx={{ borderRadius: 1, height: '1.6rem' }}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useMemo } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import {
|
import {
|
||||||
Grid,
|
Grid,
|
||||||
Select,
|
Select,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
|
import { type UseAppStoreType, AppContext } from '../../contexts/AppContext';
|
||||||
import {
|
import {
|
||||||
@ -26,13 +26,10 @@ import {
|
|||||||
AccountBalance,
|
AccountBalance,
|
||||||
AttachMoney,
|
AttachMoney,
|
||||||
QrCode,
|
QrCode,
|
||||||
ControlPoint,
|
|
||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
import { systemClient } from '../../services/System';
|
import { systemClient } from '../../services/System';
|
||||||
import { TorIcon } from '../Icons';
|
import { TorIcon } from '../Icons';
|
||||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
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';
|
import { apiClient } from '../../services/api';
|
||||||
|
|
||||||
interface SettingsFormProps {
|
interface SettingsFormProps {
|
||||||
@ -41,8 +38,6 @@ interface SettingsFormProps {
|
|||||||
|
|
||||||
const SettingsForm = ({ dense = false }: SettingsFormProps): JSX.Element => {
|
const SettingsForm = ({ dense = false }: SettingsFormProps): JSX.Element => {
|
||||||
const { fav, setFav, settings, setSettings } = useContext<UseAppStoreType>(AppContext);
|
const { fav, setFav, settings, setSettings } = useContext<UseAppStoreType>(AppContext);
|
||||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
|
||||||
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const fontSizes = [
|
const fontSizes = [
|
||||||
|
@ -4,19 +4,17 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
type SetStateAction,
|
type SetStateAction,
|
||||||
useMemo,
|
|
||||||
useContext,
|
useContext,
|
||||||
type ReactNode,
|
type ReactNode,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
import { type Order, Federation, Settings, Coordinator } from '../models';
|
import { type Order, Federation, Settings } from '../models';
|
||||||
|
|
||||||
import { federationLottery } from '../utils';
|
import { federationLottery } from '../utils';
|
||||||
|
|
||||||
import { AppContext, type UseAppStoreType } from './AppContext';
|
import { AppContext, type UseAppStoreType } from './AppContext';
|
||||||
import { GarageContext, type UseGarageStoreType } from './GarageContext';
|
import { GarageContext, type UseGarageStoreType } from './GarageContext';
|
||||||
import NativeRobosats from '../services/Native';
|
import { type Origin, type Origins } from '../models/Coordinator.model';
|
||||||
import { Origins } from '../models/Coordinator.model';
|
|
||||||
|
|
||||||
// Refresh delays (ms) according to Order status
|
// Refresh delays (ms) according to Order status
|
||||||
const defaultDelay = 5000;
|
const defaultDelay = 5000;
|
||||||
@ -175,14 +173,15 @@ export const FederationContextProvider = ({
|
|||||||
federated: false,
|
federated: false,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
};
|
};
|
||||||
|
const origins: Origins = {
|
||||||
|
clearnet: undefined,
|
||||||
|
onion: url as Origin,
|
||||||
|
i2p: undefined,
|
||||||
|
};
|
||||||
if (settings.network === 'mainnet') {
|
if (settings.network === 'mainnet') {
|
||||||
attributes.mainnet = {
|
attributes.mainnet = origins;
|
||||||
onion: url,
|
|
||||||
} as Origins;
|
|
||||||
} else {
|
} else {
|
||||||
attributes.testnet = {
|
attributes.testnet = origins;
|
||||||
onion: url,
|
|
||||||
} as Origins;
|
|
||||||
}
|
}
|
||||||
federation.addCoordinator(origin, settings, hostUrl, attributes);
|
federation.addCoordinator(origin, settings, hostUrl, attributes);
|
||||||
const newCoordinator = federation.coordinators[alias];
|
const newCoordinator = federation.coordinators[alias];
|
||||||
|
@ -210,7 +210,7 @@ export class Coordinator {
|
|||||||
|
|
||||||
generateAllMakerAvatars = async (data: [PublicOrder]): Promise<void> => {
|
generateAllMakerAvatars = async (data: [PublicOrder]): Promise<void> => {
|
||||||
for (const order of data) {
|
for (const order of data) {
|
||||||
roboidentitiesClient.generateRobohash(order.maker_hash_id, 'small');
|
void roboidentitiesClient.generateRobohash(order.maker_hash_id, 'small');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ export class Federation {
|
|||||||
settings: Settings,
|
settings: Settings,
|
||||||
hostUrl: string,
|
hostUrl: string,
|
||||||
attributes: Record<any, any>,
|
attributes: Record<any, any>,
|
||||||
) => {
|
): void => {
|
||||||
const value = {
|
const value = {
|
||||||
...coordinatorDefaultValues,
|
...coordinatorDefaultValues,
|
||||||
...attributes,
|
...attributes,
|
||||||
@ -111,7 +111,7 @@ export class Federation {
|
|||||||
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
||||||
this.updateEnabledCoordinators();
|
this.updateEnabledCoordinators();
|
||||||
for (const coor of Object.values(this.coordinators)) {
|
for (const coor of Object.values(this.coordinators)) {
|
||||||
coor.update(() => {
|
void coor.update(() => {
|
||||||
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
|
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
|
||||||
this.onCoordinatorSaved();
|
this.onCoordinatorSaved();
|
||||||
});
|
});
|
||||||
@ -124,7 +124,7 @@ export class Federation {
|
|||||||
this.triggerHook('onCoordinatorUpdate');
|
this.triggerHook('onCoordinatorUpdate');
|
||||||
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
||||||
for (const coor of Object.values(this.coordinators)) {
|
for (const coor of Object.values(this.coordinators)) {
|
||||||
coor.updateBook(() => {
|
void coor.updateBook(() => {
|
||||||
this.onCoordinatorSaved();
|
this.onCoordinatorSaved();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Coordinator, type Order } from '.';
|
import { type Coordinator, type Order } from '.';
|
||||||
import { systemClient } from '../services/System';
|
import { systemClient } from '../services/System';
|
||||||
import { saveAsJson } from '../utils';
|
import { saveAsJson } from '../utils';
|
||||||
import Slot from './Slot.model';
|
import Slot from './Slot.model';
|
||||||
@ -59,8 +59,13 @@ class Garage {
|
|||||||
const rawSlots = JSON.parse(slotsDump);
|
const rawSlots = JSON.parse(slotsDump);
|
||||||
Object.values(rawSlots).forEach((rawSlot: Record<any, any>) => {
|
Object.values(rawSlots).forEach((rawSlot: Record<any, any>) => {
|
||||||
if (rawSlot?.token) {
|
if (rawSlot?.token) {
|
||||||
this.slots[rawSlot.token] = new Slot(rawSlot.token, Object.keys(rawSlot.robots), {}, () =>
|
this.slots[rawSlot.token] = new Slot(
|
||||||
this.triggerHook('onRobotUpdate'),
|
rawSlot.token,
|
||||||
|
Object.keys(rawSlot.robots),
|
||||||
|
{},
|
||||||
|
() => {
|
||||||
|
this.triggerHook('onRobotUpdate');
|
||||||
|
},
|
||||||
);
|
);
|
||||||
Object.keys(rawSlot.robots).forEach((shortAlias) => {
|
Object.keys(rawSlot.robots).forEach((shortAlias) => {
|
||||||
const rawRobot = rawSlot.robots[shortAlias];
|
const rawRobot = rawSlot.robots[shortAlias];
|
||||||
@ -118,9 +123,9 @@ class Garage {
|
|||||||
if (!token || !shortAliases) return;
|
if (!token || !shortAliases) return;
|
||||||
|
|
||||||
if (this.getSlot(token) === null) {
|
if (this.getSlot(token) === null) {
|
||||||
this.slots[token] = new Slot(token, shortAliases, attributes, () =>
|
this.slots[token] = new Slot(token, shortAliases, attributes, () => {
|
||||||
this.triggerHook('onRobotUpdate'),
|
this.triggerHook('onRobotUpdate');
|
||||||
);
|
});
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { sha256 } from 'js-sha256';
|
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';
|
import { roboidentitiesClient } from '../services/Roboidentities/Web';
|
||||||
|
|
||||||
class Slot {
|
class Slot {
|
||||||
@ -13,12 +13,12 @@ class Slot {
|
|||||||
|
|
||||||
this.hashId = sha256(sha256(this.token));
|
this.hashId = sha256(sha256(this.token));
|
||||||
this.nickname = null;
|
this.nickname = null;
|
||||||
roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
|
void roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
onRobotUpdate();
|
onRobotUpdate();
|
||||||
});
|
});
|
||||||
roboidentitiesClient.generateRobohash(this.hashId, 'small');
|
void roboidentitiesClient.generateRobohash(this.hashId, 'small');
|
||||||
roboidentitiesClient.generateRobohash(this.hashId, 'large');
|
void roboidentitiesClient.generateRobohash(this.hashId, 'large');
|
||||||
|
|
||||||
this.robots = shortAliases.reduce((acc: Record<string, Robot>, shortAlias: string) => {
|
this.robots = shortAliases.reduce((acc: Record<string, Robot>, shortAlias: string) => {
|
||||||
acc[shortAlias] = new Robot(robotAttributes);
|
acc[shortAlias] = new Robot(robotAttributes);
|
||||||
@ -82,7 +82,7 @@ class Slot {
|
|||||||
pubKey: defaultRobot.pubKey,
|
pubKey: defaultRobot.pubKey,
|
||||||
encPrivKey: defaultRobot.encPrivKey,
|
encPrivKey: defaultRobot.encPrivKey,
|
||||||
});
|
});
|
||||||
coordinator.fetchRobot(garage, defaultRobot.token);
|
void coordinator.fetchRobot(garage, defaultRobot.token);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import RoboidentitiesClientNativeClient from './RoboidentitiesNativeClient';
|
import RoboidentitiesClientNativeClient from './RoboidentitiesNativeClient';
|
||||||
import { RoboidentitiesClient } from './type';
|
import { type RoboidentitiesClient } from './type';
|
||||||
|
|
||||||
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientNativeClient();
|
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientNativeClient();
|
||||||
|
@ -31,8 +31,8 @@ class RoboidentitiesNativeClient implements RoboidentitiesClient {
|
|||||||
type: 'robohash',
|
type: 'robohash',
|
||||||
detail: key,
|
detail: key,
|
||||||
});
|
});
|
||||||
const result = response ? Object.values(response)[0] : '';
|
const result: string = response ? Object.values(response)[0] : '';
|
||||||
const image = `data:image/png;base64,${result}`;
|
const image: string = `data:image/png;base64,${result}`;
|
||||||
this.robohashes[key] = image;
|
this.robohashes[key] = image;
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ import { robohash } from './RobohashGenerator';
|
|||||||
|
|
||||||
class RoboidentitiesClientWebClient implements RoboidentitiesClient {
|
class RoboidentitiesClientWebClient implements RoboidentitiesClient {
|
||||||
public generateRoboname: (initialString: string) => Promise<string> = async (initialString) => {
|
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));
|
resolve(generate_roboname(initialString));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
public generateRobohash: (initialString: string, size: 'small' | 'large') => Promise<string> =
|
public generateRobohash: (initialString: string, size: 'small' | 'large') => Promise<string> =
|
||||||
async (initialString, size) => {
|
async (initialString, size) => {
|
||||||
return robohash.generate(initialString, size);
|
return await robohash.generate(initialString, size);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import RoboidentitiesClientWebClient from './RoboidentitiesWebClient';
|
import RoboidentitiesClientWebClient from './RoboidentitiesWebClient';
|
||||||
import { RoboidentitiesClient } from './type';
|
import { type RoboidentitiesClient } from './type';
|
||||||
|
|
||||||
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientWebClient();
|
export const roboidentitiesClient: RoboidentitiesClient = new RoboidentitiesClientWebClient();
|
||||||
|
@ -5,7 +5,7 @@ import ApiWebClient from '../ApiWebClient';
|
|||||||
class ApiNativeClient implements ApiClient {
|
class ApiNativeClient implements ApiClient {
|
||||||
public useProxy = true;
|
public useProxy = true;
|
||||||
|
|
||||||
private webClient: ApiClient = new ApiWebClient();
|
private readonly webClient: ApiClient = new ApiWebClient();
|
||||||
|
|
||||||
private readonly assetsPromises = new Map<string, Promise<string | undefined>>();
|
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> =
|
public delete: (baseUrl: string, path: string, auth?: Auth) => Promise<object | undefined> =
|
||||||
async (baseUrl, path, auth) => {
|
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({
|
return await window.NativeRobosats?.postMessage({
|
||||||
category: 'http',
|
category: 'http',
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
@ -71,7 +71,7 @@ class ApiNativeClient implements ApiClient {
|
|||||||
body: object,
|
body: object,
|
||||||
auth?: Auth,
|
auth?: Auth,
|
||||||
) => Promise<object | undefined> = async (baseUrl, path, body, 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({
|
return await window.NativeRobosats?.postMessage({
|
||||||
category: 'http',
|
category: 'http',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
@ -87,7 +87,7 @@ class ApiNativeClient implements ApiClient {
|
|||||||
path,
|
path,
|
||||||
auth,
|
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({
|
return await window.NativeRobosats?.postMessage({
|
||||||
category: 'http',
|
category: 'http',
|
||||||
type: 'get',
|
type: 'get',
|
||||||
|
@ -16,14 +16,6 @@ export interface AggregatedInfo {
|
|||||||
version: Version;
|
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 => {
|
export const weightedMean = (arrValues: number[], arrWeights: number[]): number => {
|
||||||
if (arrValues.length === 0) {
|
if (arrValues.length === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user