Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"@babel/core": "7.6.0",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@ethersproject/abi": "^5.0.1",
"@ethersproject/address": "^5.0.1",
"@ethersproject/constants": "^5.0.1",
"@ethersproject/contracts": "^5.0.1",
"@ethersproject/providers": "^5.0.4",
"@ethersproject/units": "^5.0.1",
"@ledgerhq/hw-app-eth": "^4.72.1",
"@ledgerhq/hw-transport-u2f": "^4.72.1",
"@material-ui/core": "^4.5.0",
Expand Down Expand Up @@ -45,7 +51,6 @@
"eslint-plugin-react-hooks": "^1.6.1",
"ethereumjs-tx": "^2.1.1",
"ethereumjs-util": "^6.1.0",
"ethers": "^4.0.45",
"file-loader": "3.0.1",
"fs-extra": "7.0.1",
"hdkey": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/abi/Multicall.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}
],
"payable": false,
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/Common/WrapEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useStores } from '../../contexts/storesContext';
import { toWei, formatBalance } from '../../utils/helpers';
import { ContractTypes } from '../../stores/Provider';
import Button from './Button';
import { ethers } from 'ethers';
import { parseEther } from '@ethersproject/units';

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -164,7 +164,7 @@ const WrapEth = () => {
const actionButtonHandler = async (action: ButtonAction) => {
if (action === ButtonAction.WRAP) {
let overrides = {
value: ethers.utils.parseEther(ethAmount),
value: parseEther(ethAmount),
};

await providerStore.sendTransaction(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pool/SwapsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { padToDecimalPlaces } from '../../utils/helpers';
import { getEtherscanLink } from '../../utils/helpers';
import { useStores } from '../../contexts/storesContext';
import { TokenIconAddress } from '../Common/WalletBalances';
import { getAddress } from 'ethers/utils';
import { getAddress } from '@ethersproject/address';
const ExternalLink = require('../../assets/images/external-link.svg') as string;

const formatDate = timestamp => {
Expand Down
43 changes: 0 additions & 43 deletions src/provider/UncheckedJsonRpcSigner.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/provider/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'isomorphic-fetch';
import { getAddress } from 'ethers/utils';
import { getAddress } from '@ethersproject/address';
import { Pool, PoolToken, Swap } from '../types';
import { bnum } from '../utils/helpers';
import { getSupportedChainId, SUBGRAPH_URLS } from './connectors';
Expand Down
16 changes: 8 additions & 8 deletions src/stores/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { action, observable, ObservableMap } from 'mobx';
import RootStore from 'stores/Root';
import { ethers } from 'ethers';
import UncheckedJsonRpcSigner from 'provider/UncheckedJsonRpcSigner';
import { Contract } from '@ethersproject/contracts'
import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers'
import { ActionResponse, sendAction } from './actions/actions';
import { web3Window as window } from 'provider/Web3Window';
import { backupUrls, supportedChainId, web3Modal } from 'provider/connectors';
Expand Down Expand Up @@ -132,19 +132,19 @@ export default class ProviderStore {
});

return account
? new UncheckedJsonRpcSigner(library.getSigner(account))
? library.getSigner(account).connectUnchecked()
: library;
}

getContract(
type: ContractTypes,
address: string,
signerAccount?: string
): ethers.Contract {
): Contract {
const library = this.providerStatus.library;

if (signerAccount) {
return new ethers.Contract(
return new Contract(
address,
schema[type],
this.getProviderOrSigner(
Expand All @@ -154,7 +154,7 @@ export default class ProviderStore {
);
}

return new ethers.Contract(address, schema[type], library);
return new Contract(address, schema[type], library);
}

@action sendTransaction = async (
Expand Down Expand Up @@ -286,7 +286,7 @@ export default class ProviderStore {
await this.providerStatus.library.close();
}

let web3 = new ethers.providers.Web3Provider(provider);
let web3 = new Web3Provider(provider);

if ((provider as any).isMetaMask) {
console.log(`[Provider] MetaMask Auto Refresh Off`);
Expand Down Expand Up @@ -348,7 +348,7 @@ export default class ProviderStore {
this.providerStatus
);
try {
let web3 = new ethers.providers.JsonRpcProvider(
let web3 = new JsonRpcProvider(
backupUrls[supportedChainId]
);
let network = await web3.getNetwork();
Expand Down
4 changes: 2 additions & 2 deletions src/stores/Proxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { action, observable } from 'mobx';
import { Interface } from 'ethers/utils';
import { Interface } from '@ethersproject/abi';
import RootStore from './Root';
import { ContractTypes, schema } from './Provider';
import { FetchCode } from './Transaction';
Expand Down Expand Up @@ -60,7 +60,7 @@ export default class Proxy {
): string {
const abi = schema[contractType];
const iface = new Interface(abi);
const data = iface.functions[action].encode(params);
const data = iface.encodeFunctionData(action, params);
return data;
}
}
17 changes: 7 additions & 10 deletions src/stores/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import RootStore from 'stores/Root';
import { ContractTypes } from 'stores/Provider';
import * as helpers from 'utils/helpers';
import { bnum, scale } from 'utils/helpers';
import { parseEther, Interface } from 'ethers/utils';
import { Interface } from '@ethersproject/abi';
import { parseEther } from '@ethersproject/units';
import { FetchCode } from './Transaction';
import { BigNumber } from 'utils/bignumber';
import { AsyncStatus, UserAllowanceFetch } from './actions/fetch';
Expand Down Expand Up @@ -129,7 +130,7 @@ export default class TokenStore {
tokenAddresses.forEach(value => {
calls.push([
value,
iface.functions.allowance.encode([account, spender]),
iface.encodeFunctionData("allowance", [account, spender]),
]);
});

Expand Down Expand Up @@ -409,14 +410,12 @@ export default class TokenStore {
const iface = new Interface(tokenAbi);

tokensToTrack.forEach(value => {
calls.push([value, iface.functions.totalSupply.encode([])]);
calls.push([value, iface.encodeFunctionData("totalSupply",[])]);
});

try {
const [blockNumber, response] = await multi.aggregate(calls);
const supplies = response.map(value =>
bnum(iface.functions.totalSupply.decode(value))
);
const supplies = response.map(value => bnum(value));

this.setTotalSupplies(
tokensToTrack,
Expand Down Expand Up @@ -452,7 +451,7 @@ export default class TokenStore {
if (value !== EtherKey) {
calls.push([
value,
iface.functions.balanceOf.encode([account]),
iface.encodeFunctionData("balanceOf", [account]),
]);
}
});
Expand All @@ -464,9 +463,7 @@ export default class TokenStore {
const [[blockNumber, response], ethBalance] = await Promise.all(
promises
);
const balances = response.map(value =>
bnum(iface.functions.balanceOf.decode(value))
);
const balances = response.map(value => bnum(value));
if (tokensToTrack[0] === EtherKey) {
balances.unshift(bnum(ethBalance));
}
Expand Down
7 changes: 3 additions & 4 deletions src/stores/Transaction.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { action, observable } from 'mobx';
import { providers } from 'ethers';
import { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
import RootStore from 'stores/Root';
import { TransactionResponse } from 'ethers/providers';

export interface TransactionRecord {
hash: string;
response: providers.TransactionResponse;
response: TransactionResponse;
blockNumberChecked: number;
receipt: providers.TransactionReceipt | undefined;
receipt: TransactionReceipt | undefined;
}

const ERRORS = {
Expand Down
4 changes: 2 additions & 2 deletions src/stores/actions/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Contract } from 'ethers';
import { TransactionResponse } from 'ethers/providers';
import { Contract } from '@ethersproject/contracts';
import { TransactionResponse } from '@ethersproject/providers';

interface ActionRequest {
contract: Contract;
Expand Down
20 changes: 11 additions & 9 deletions src/utils/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// Libraries
import React from 'react';
import jazzicon from 'jazzicon';
import { ethers, utils } from 'ethers';
import { getAddress } from '@ethersproject/address';
import { MaxUint256 } from '@ethersproject/constants';
import { formatEther } from '@ethersproject/units';
import { BigNumber } from 'utils/bignumber';
import { Pool } from '../types';

// Utils
export const MAX_GAS = utils.bigNumberify('0xffffffff');
export const MAX_UINT = utils.bigNumberify(ethers.constants.MaxUint256);
export const MAX_GAS = new BigNumber('0xffffffff');
export const MAX_UINT = MaxUint256;
export const POOL_TOKENS_DECIMALS = 18;

export function toChecksum(address) {
return utils.getAddress(address);
return getAddress(address);
}

export const formatDate = timestamp => {
Expand All @@ -26,7 +28,7 @@ export const addZero = value => {
};

export function bnum(
val: string | number | utils.BigNumber | BigNumber
val: string | number | BigNumber
): BigNumber {
return new BigNumber(val.toString());
}
Expand All @@ -37,11 +39,11 @@ export function scale(input: BigNumber, decimalPlaces: number): BigNumber {
return input.times(scaleMul);
}

export function fromWei(val: string | utils.BigNumber | BigNumber): string {
return utils.formatEther(val.toString());
export function fromWei(val: string | BigNumber): string {
return formatEther(val.toString());
}

export function toWei(val: string | utils.BigNumber | BigNumber): BigNumber {
export function toWei(val: string | BigNumber): BigNumber {
return scale(bnum(val.toString()), 18).integerValue();
}

Expand Down Expand Up @@ -114,7 +116,7 @@ export function shortenTransactionHash(hash, digits = 4) {

export function isAddress(value) {
try {
return ethers.utils.getAddress(value.toLowerCase());
return getAddress(value.toLowerCase());
} catch {
return false;
}
Expand Down
Loading