fix lint warnings

This commit is contained in:
fmtabbara
2022-03-14 11:00:47 +00:00
parent 893b28c51c
commit 3483a9e7f9
11 changed files with 30 additions and 14 deletions
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Button, IconButton, Tooltip } from '@mui/material';
import { Check, ContentCopy } from '@mui/icons-material';
import { clipboard } from '@tauri-apps/api';
import { Console } from '../utils/console';
export const CopyToClipboard = ({
text = '',
@@ -19,7 +20,7 @@ export const CopyToClipboard = ({
await clipboard.writeText(_text);
setCopied(true);
} catch (e) {
console.log(`failed to copy: ${e}`);
Console.error(`failed to copy: ${e}`);
}
};
+3 -2
View File
@@ -6,6 +6,7 @@ import { TUseuserBalance, useGetBalance } from '../hooks/useGetBalance';
import { config } from '../../config';
import { getMixnodeBondDetails, selectNetwork, signInWithMnemonic, signOut } from '../requests';
import { currencyMap } from '../utils';
import { Console } from '../utils/console';
export const { ADMIN_ADDRESS, IS_DEV_MODE } = config;
@@ -62,7 +63,7 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode
setClientDetails(client);
} catch (e) {
enqueueSnackbar('Error loading account', { variant: 'error' });
console.error(e);
Console.error(e as string);
} finally {
setCurrency(currencyMap(n));
}
@@ -74,7 +75,7 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode
const mixnode = await getMixnodeBondDetails();
setMixnodeDetails(mixnode);
} catch (e) {
console.log(e);
Console.error(e as string);
}
};
+2 -1
View File
@@ -11,6 +11,7 @@ import {
getCurrentVestingPeriod,
getVestingAccountInfo,
} from '../requests';
import { Console } from '../utils/console';
type TTokenAllocation = {
[key in 'vesting' | 'vested' | 'locked' | 'spendable']: Coin['amount'];
@@ -76,7 +77,7 @@ export const useGetBalance = (address?: string): TUseuserBalance => {
} catch (e) {
clearTokenAllocation();
clearOriginalVesting();
console.error(e);
Console.error(e as string);
}
}
setIsLoading(false);
-1
View File
@@ -19,7 +19,6 @@ const AdminForm: React.FC<{
const onSubmit = async (data: TauriContractStateParams) => {
await setContractParams(data);
console.log(data);
onCancel();
};
+2 -1
View File
@@ -20,6 +20,7 @@ import { ClientContext } from '../../context/main';
import { withdrawVestedCoins } from '../../requests';
import { Period } from '../../types';
import { VestingTimeline } from './components/vesting-timeline';
import { Console } from '../../utils/console';
const columnsHeaders: Array<{ title: string; align: TableCellProps['align'] }> = [
{ title: 'Locked', align: 'left' },
@@ -165,7 +166,7 @@ export const VestingCard = () => {
preventDuplicate: true,
});
} catch (e) {
console.log(e);
Console.error(e as string);
enqueueSnackbar('Token transfer failed. You may not have any transferable tokens at this time', {
variant: 'error',
preventDuplicate: true,
@@ -7,6 +7,7 @@ import { validationSchema } from './validationSchema';
import { ClientContext } from '../../context/main';
import { delegate, majorToMinor, vestingDelegateToMixnode } from '../../requests';
import { Fee, TokenPoolSelector } from '../../components';
import { Console } from '../../utils/console';
type TDelegateForm = {
identity: string;
@@ -63,7 +64,7 @@ export const DelegateForm = ({
onSuccess({ amount: data.amount, address: res.target_address });
})
.catch((e) => {
console.log(e);
Console.error(e as string);
onError(e);
});
};
+2 -1
View File
@@ -11,6 +11,7 @@ import { validationSchema } from './validationSchema';
import { TauriTxResult, TransactionDetails } from '../../types';
import { getGasFee, majorToMinor, send } from '../../requests';
import { checkHasEnoughFunds } from '../../utils';
import { Console } from '../../utils/console';
const defaultValues = {
amount: '',
@@ -98,7 +99,7 @@ export const SendWizard = () => {
.catch((e) => {
setRequestError(e);
setIsLoading(false);
console.error(e);
Console.error(e);
});
};
@@ -10,6 +10,7 @@ import { InclusionProbabilityResponse } from '../../types';
import { useCheckOwnership } from '../../hooks/useCheckOwnership';
import { updateMixnode, vestingUpdateMixnode } from '../../requests';
import { ClientContext } from '../../context/main';
import { Console } from '../../utils/console';
const DataField = ({ title, info, Indicator }: { title: string; info: string; Indicator: React.ReactElement }) => (
<Grid container justifyContent="space-between">
@@ -78,7 +79,7 @@ export const SystemVariables = ({
setNodeUpdateResponse('success');
} catch (e) {
setNodeUpdateResponse('failed');
console.log(e);
Console.log(e as string);
}
}
};
+2 -1
View File
@@ -1,4 +1,5 @@
import { invoke } from '@tauri-apps/api';
import { Console } from '../utils/console';
import { Coin, DelegationResult, EnumNodeType, TauriTxResult, TBondArgs } from '../types';
export const bond = async ({ type, data, pledge, ownerSignature }: TBondArgs): Promise<any> => {
@@ -33,7 +34,7 @@ export const undelegate = async ({
const res: DelegationResult = await invoke(`undelegate_from_${type}`, { identity });
return res;
} catch (e) {
console.log(e);
Console.log(e as string);
return undefined;
}
};
+8
View File
@@ -0,0 +1,8 @@
/* eslint-disable no-console */
import { config } from '../../config';
export const Console = {
log: (output: string) => (config.IS_DEV_MODE ? console.log(output) : undefined),
warn: (output: string) => (config.IS_DEV_MODE ? console.warn(output) : undefined),
error: (output: string) => console.error(output),
};
+5 -4
View File
@@ -4,6 +4,7 @@ import bs58 from 'bs58';
import { minor, valid } from 'semver';
import { userBalance, majorToMinor, getLockedCoins, getSpendableCoins } from '../requests';
import { Coin, Network, TCurrency } from '../types';
import { Console } from './console';
export const validateKey = (key: string, bytesLength: number): boolean => {
// it must be a valid base58 key
@@ -12,7 +13,7 @@ export const validateKey = (key: string, bytesLength: number): boolean => {
// of length 32
return bytes.length === bytesLength;
} catch (e) {
console.error(e);
Console.error(e as string);
return false;
}
};
@@ -53,7 +54,7 @@ export const validateAmount = async (amount: string, minimum: string): Promise<b
return minorValue >= parseInt(minimum, Number(10));
} catch (e) {
console.error(e);
Console.error(e as string);
return false;
}
@@ -95,7 +96,7 @@ export const checkHasEnoughFunds = async (allocationValue: string): Promise<bool
const remainingBalance = +walletValue.coin.amount - +minorValue.amount;
return remainingBalance >= 0;
} catch (e) {
console.log(e);
Console.log(e as string);
}
return false;
};
@@ -107,7 +108,7 @@ export const checkHasEnoughLockedTokens = async (allocationValue: string) => {
const remainingBalance = +lockedTokens.amount + +spendableTokens.amount - +allocationValue;
return remainingBalance >= 0;
} catch (e) {
console.error(e);
Console.error(e as string);
}
return false;
};