Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Upgrade TypeScript
Browse files Browse the repository at this point in the history
- Upgrade TypeScript to 4.1.3
- Remove unused connectors
- Remove unused contract definitions (should be handled by TypeChain)
- Fix type errors
- Add missing peer deps
  • Loading branch information
JamesLefrere committed Jan 18, 2021
1 parent 821940f commit 63db4e6
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 1,616 deletions.
26 changes: 20 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
"@testing-library/react": "^10.0.4",
"@testing-library/user-event": "^10.1.2",
"@types/date-fns": "^2.6.0",
"@types/jest": "^25.2.1",
"@types/lodash.assign": "^4.2.6",
"@types/lodash.groupby": "^4.6.6",
"@types/lossless-json": "^1.0.0",
"@types/numeral": "^0.0.28",
"@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.6",
"@types/react-transition-group": "^4.2.4",
"@types/recharts": "^1.8.16",
"@types/styled-components": "^5.1.0",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.5.0",
"apollo-boost": "^0.4.9",
"apollo-cache-persist": "^0.1.1",
"apollo-link": "^1.2.14",
Expand All @@ -31,6 +36,18 @@
"bignumber.js": "^9.0.0",
"bnc-onboard": "^1.14.0",
"date-fns": "^2.14.0",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0",
"eslint": "^7.11.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.9.2",
"eslint-webpack-plugin": "^2.1.0",
"ethereumjs-util": "^7.0.4",
"ethers": "^4.0.45",
"lossless-json": "^1.0.4",
Expand All @@ -39,9 +56,10 @@
"react-countup": "^4.3.3",
"react-dom": "^16.13.1",
"react-github-btn": "^1.2.0",
"react-is": "^16.13.1",
"react-loading-skeleton": "^2.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"react-scripts": "^4.0.1",
"react-swipeable": "^5.5.1",
"react-tooltip": "^4.2.7",
"react-transition-group": "^4.4.1",
Expand Down Expand Up @@ -105,11 +123,7 @@
"@mstable/protocol": "^1.2.1",
"@testing-library/react-hooks": "^3.2.1",
"@typechain/ethers-v4": "^1.0.0",
"@types/jest": "^25.2.1",
"@types/react-transition-group": "^4.2.4",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"cross-fetch": "^3.0.5",
"dotenv": "^8.2.0",
"env-cmd": "^10.1.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^7.1.0",
Expand All @@ -123,7 +137,7 @@
"react-test-renderer": "^16.13.1",
"ts-node": "^8.10.2",
"typechain": "^2.0.0",
"typescript": "^3.8.2",
"typescript": "^4.1.3",
"yargs": "^15.4.1"
}
}
7 changes: 5 additions & 2 deletions src/components/pages/Save/v2/deposit/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ const DepositForm: FC = () => {
if (savingsContract && valid && walletAddress) {
if (transactionType === TransactionType.Deposit && amount) {
const body = `${amount.format()} ${massetSymbol}`;
setFormManifest<Interfaces.SavingsContract, 'deposit'>({
setFormManifest<
Interfaces.SavingsContract,
'depositSavings(uint256,address)'
>({
iface: savingsContract,
args: [amount.exact, walletAddress],
fn: 'deposit',
fn: 'depositSavings(uint256,address)',
purpose: {
present: `Depositing ${body}`,
past: `Deposited ${body}`,
Expand Down
2 changes: 1 addition & 1 deletion src/context/DataProvider/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useBlockPollingSubscription = <TData, TVariables>(

// Long poll (15s interval) if the block number isn't available.
useEffect(() => {
let interval: number;
let interval: NodeJS.Timeout;

if (!skip && !hasBlock) {
run();
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FC } from 'react';
import { TransactionResponse } from 'ethers/providers';
import { BigNumber } from 'ethers/utils';

Expand Down Expand Up @@ -132,7 +131,6 @@ export interface Connector {
id: string;
subType?: string;
label: string;
icon?: FC;
}

export enum Platforms {
Expand Down
100 changes: 5 additions & 95 deletions src/web3/connectors.ts
Original file line number Diff line number Diff line change
@@ -1,117 +1,27 @@
import { ReactComponent as BraveIcon } from '../components/icons/wallets/brave.svg';
import { ReactComponent as MetaMaskIcon } from '../components/icons/wallets/metamask.svg';
import { ReactComponent as FortmaticIcon } from '../components/icons/wallets/fortmatic.svg';
import { ReactComponent as PortisIcon } from '../components/icons/wallets/portis.svg';
import { ReactComponent as SquarelinkIcon } from '../components/icons/wallets/squarelink.svg';
import { ReactComponent as WalletConnectIcon } from '../components/icons/wallets/walletconnect.svg';
import { ReactComponent as CoinbaseIcon } from '../components/icons/wallets/coinbase.svg';
import { ReactComponent as MeetOneIcon } from '../components/icons/wallets/meetone.svg';
import { Connector } from '../types';
import { CHAIN_ID } from './constants';

export const CONNECTORS: Connector[] = [
{
id: 'injected',
subType: 'metamask',
label: 'MetaMask',
icon: MetaMaskIcon,
},
{
id: 'injected',
subType: 'brave',
label: 'Brave',
icon: BraveIcon,
},
{
id: 'injected',
subType: 'meetOne',
label: 'MEET.ONE',
icon: MeetOneIcon,
},
{ id: 'fortmatic', label: 'Fortmatic', icon: FortmaticIcon },
{ id: 'portis', label: 'Portis', icon: PortisIcon },
// TODO add missing icons
{ id: 'fortmatic', label: 'Fortmatic' },
{ id: 'portis', label: 'Portis' },
{ id: 'authereum', label: 'Authereum' },
{ id: 'squarelink', label: 'Squarelink', icon: SquarelinkIcon },
{ id: 'squarelink', label: 'Squarelink' },
{ id: 'torus', label: 'Torus' },
{ id: 'walletconnect', label: 'WalletConnect', icon: WalletConnectIcon },
{ id: 'walletlink', label: 'WalletLink', icon: CoinbaseIcon },
{ id: 'walletconnect', label: 'WalletConnect' },
{ id: 'walletlink', label: 'WalletLink' },
{ id: 'frame', label: 'Frame' },
];

const injected = {};

if (!process.env.REACT_APP_RPC_URL) {
throw new Error('`REACT_APP_RPC_URL` must be set');
}

if (!process.env.REACT_APP_RPC_API_KEY) {
throw new Error('`REACT_APP_RPC_API_KEY` must be set');
}

export const RPC_URL = `${process.env.REACT_APP_RPC_URL}${process.env.REACT_APP_RPC_API_KEY}`;

const walletlink = {
url: RPC_URL,
appLogoUrl: 'https://app.mstable.org/icons/apple-icon-180x180.png',
appName: 'mStable',
};

const squarelink = {
options: {},
clientId: process.env.REACT_APP_SQUARELINK_CLIENT_ID as string,
};

const portis = { dAppId: process.env.REACT_APP_PORTIS_DAPP_ID as string };

const walletconnect = {
rpcUrl: RPC_URL,
};

// These connectors are currently not fully supported by `use-wallet`
// const torus = {
// initOptions: {
// showTorusButton: true,
// },
// };

export const getConnectors = (chainId: number): object => {
switch (chainId) {
case 1:
return {
injected,
portis,
squarelink,
fortmatic: {
apiKey: process.env.REACT_APP_FORTMATIC_API_KEY as string,
},
walletlink,
walletconnect,
// torus: {
// ...torus,
// chainId,
// },
};
case 1337:
return {
injected,
};
default:
return {
injected,
portis,
squarelink,
fortmatic: {
apiKey: process.env.REACT_APP_FORTMATIC_API_KEY as string,
},
walletconnect,
// walletlink, // In theory it supports Ropsten; in reality the tx gas is broken :(
// torus: {
// ...torus,
// chainId,
// },
};
}
};

export const AVAILABLE_CONNECTORS = getConnectors(CHAIN_ID);
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"jsx": "react-jsx"
}
}

0 comments on commit 63db4e6

Please sign in to comment.