chore: import from ethers (#3094)

* chore: rm lodash

* chore: improve styled-components lint

* chore: import from ethers

* fix: use provider JsonRpcProvider
This commit is contained in:
Zach Pomerantz 2022-01-11 11:32:20 -08:00 committed by GitHub
parent 90dfdc6bef
commit 27412e49d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 133 additions and 142 deletions

@ -59,21 +59,13 @@
{
"paths": [
{
"name": "lodash",
"message": "Please import from 'lodash/module' directly to support tree-shaking."
},
{
"name": "ethers",
"message": "Please import from '@ethersproject/module' directly to support tree-shaking."
"name": "@lingui/macro",
"importNames": ["t"],
"message": "Please use <Trans> instead of t."
},
{
"name": "styled-components",
"message": "Please import from styled-components/macro."
},
{
"name": "@lingui/macro",
"importNames": ["t"],
"message": "Please use <Trans> instead of t."
}
],
"patterns": [
@ -81,6 +73,10 @@
"group": ["**/dist"],
"message": "Do not import from dist/ - this is an implementation detail, and breaks tree-shaking."
},
{
"group": ["@ethersproject"],
"message": "Please import from 'ethers' to support bundling."
},
{
"group": ["!styled-components/macro"]
}

@ -4,9 +4,9 @@
// https://on.cypress.io/custom-commands
// ***********************************************
// eslint-disable-next-line no-restricted-imports
import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge'
import { JsonRpcProvider } from '@ethersproject/providers'
import { Wallet } from '@ethersproject/wallet'
import { providers, Wallet } from 'ethers'
// todo: figure out how env vars actually work in CI
// const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY')
@ -81,7 +81,7 @@ Cypress.Commands.overwrite('visit', (original, url, options) => {
onBeforeLoad(win) {
options && options.onBeforeLoad && options.onBeforeLoad(win)
win.localStorage.clear()
const provider = new JsonRpcProvider('https://rinkeby.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 4)
const provider = new providers.JsonRpcProvider('https://rinkeby.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 4)
const signer = new Wallet(TEST_PRIVATE_KEY, provider)
win.ethereum = new CustomizedBridge(signer, provider)
},

@ -83,7 +83,6 @@
"eslint-plugin-react-hooks": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"ethers": "^5.4.6",
"firebase": "^9.1.3",
"graphql": "^15.5.0",
"graphql-request": "^3.4.0",
@ -135,7 +134,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=./custom-test-env.js",
"test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run --record'",
"test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
"assets:generate": "yarn assets:svg:generate && yarn assets:font:generate",
"assets:svg:generate": "svgr -d src/lib/assets/svg --ext tsx --typescript src/lib/assets/svg && rm src/lib/assets/svg/index.tsx",
"assets:font:generate": "sass src/lib/assets/fonts/index.scss src/lib/assets/fonts/index.css --no-source-map -I node_modules",
@ -157,10 +156,6 @@
},
"license": "GPL-3.0-or-later",
"dependencies": {
"@ethersproject/contracts": "5.4.1",
"@ethersproject/hash": "5.4.0",
"@ethersproject/address": "5.4.0",
"@ethersproject/constants": "5.4.0",
"@fontsource/ibm-plex-mono": "^4.5.1",
"@fontsource/inter": "^4.5.1",
"@lingui/core": "^3.9.0",
@ -172,9 +167,9 @@
"@uniswap/token-lists": "^1.0.0-beta.27",
"ajv": "^6.12.3",
"cids": "^1.0.0",
"ethers": "^5.4.6",
"immer": "^9.0.6",
"jotai": "^1.3.7",
"lodash": "^4.17.21",
"make-plural": "^7.0.0",
"multicodec": "^3.0.1",
"multihashes": "^4.0.2",

@ -1,6 +1,6 @@
import { isAddress } from '@ethersproject/address'
import { Trans } from '@lingui/macro'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { isAddress } from 'ethers/lib/utils'
import { useState } from 'react'
import { Text } from 'rebass'
import styled from 'styled-components/macro'

@ -1,6 +1,6 @@
import { isAddress } from '@ethersproject/address'
import { Trans } from '@lingui/macro'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { isAddress } from 'ethers/lib/utils'
import JSBI from 'jsbi'
import { useEffect, useState } from 'react'
import { Text } from 'rebass'

@ -1,5 +1,5 @@
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import type { providers } from 'ethers'
import { ReactNode, useState } from 'react'
import styled from 'styled-components/macro'
@ -47,7 +47,7 @@ export default function ClaimRewardModal({ isOpen, onDismiss, stakingInfo }: Sta
setAttempting(true)
await stakingContract
.getReward({ gasLimit: 350000 })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.CLAIM,
recipient: account,

@ -1,7 +1,7 @@
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import type { providers } from 'ethers'
import { useCallback, useState } from 'react'
import styled from 'styled-components/macro'
@ -105,7 +105,7 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui
signatureData.s,
{ gasLimit: 350000 }
)
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.DEPOSIT_LIQUIDITY_STAKING,
token0Address: stakingInfo.tokens[0].address,

@ -1,5 +1,5 @@
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import type { providers } from 'ethers'
import { ReactNode, useState } from 'react'
import styled from 'styled-components/macro'
@ -48,7 +48,7 @@ export default function UnstakingModal({ isOpen, onDismiss, stakingInfo }: Staki
setAttempting(true)
await stakingContract
.exit({ gasLimit: 300000 })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.WITHDRAW_LIQUIDITY_STAKING,
token0Address: stakingInfo.tokens[0].address,

@ -1,5 +1,5 @@
import { isAddress } from '@ethersproject/address'
import { Trans } from '@lingui/macro'
import { isAddress } from 'ethers/lib/utils'
import { ReactNode, useState } from 'react'
import { X } from 'react-feather'
import styled from 'styled-components/macro'

@ -1,9 +1,9 @@
import { Web3Provider } from '@ethersproject/providers'
import { SafeAppConnector } from '@gnosis.pm/safe-apps-web3-react'
import { InjectedConnector } from '@web3-react/injected-connector'
import { PortisConnector } from '@web3-react/portis-connector'
import { WalletConnectConnector } from '@web3-react/walletconnect-connector'
import { WalletLinkConnector } from '@web3-react/walletlink-connector'
import type { providers } from 'ethers'
import UNISWAP_LOGO_URL from '../assets/svg/logo.svg'
import { ALL_SUPPORTED_CHAIN_IDS, INFURA_NETWORK_URLS, SupportedChainId } from '../constants/chains'
@ -19,8 +19,8 @@ export const network = new NetworkConnector({
defaultChainId: 1,
})
let networkLibrary: Web3Provider | undefined
export function getNetworkLibrary(): Web3Provider {
let networkLibrary: providers.Web3Provider | undefined
export function getNetworkLibrary(): providers.Web3Provider {
return (networkLibrary = networkLibrary ?? getLibrary(network.provider))
}

@ -1,7 +1,6 @@
import { arrayify } from '@ethersproject/bytes'
import { parseBytes32String } from '@ethersproject/strings'
import { Currency, Token } from '@uniswap/sdk-core'
import { CHAIN_INFO, L2_CHAIN_IDS, SupportedChainId, SupportedL2ChainId } from 'constants/chains'
import { arrayify, parseBytes32String } from 'ethers/lib/utils'
import { useMemo } from 'react'
import { createTokenFilterFunction } from '../components/SearchModal/filtering'

@ -1,13 +1,13 @@
import { Web3Provider } from '@ethersproject/providers'
import { useWeb3React } from '@web3-react/core'
import { providers } from 'ethers'
import { default as useWidgetsWeb3React } from 'lib/hooks/useActiveWeb3React'
import { NetworkContextName } from '../constants/misc'
export default function useActiveWeb3React() {
const widgetsContext = useWidgetsWeb3React()
const interfaceContext = useWeb3React<Web3Provider>()
const interfaceNetworkContext = useWeb3React<Web3Provider>(
const interfaceContext = useWeb3React<providers.Web3Provider>()
const interfaceNetworkContext = useWeb3React<providers.Web3Provider>(
process.env.REACT_APP_IS_WIDGET ? undefined : NetworkContextName
)

@ -1,9 +1,9 @@
import { MaxUint256 } from '@ethersproject/constants'
import { TransactionResponse } from '@ethersproject/providers'
import { Protocol, Trade } from '@uniswap/router-sdk'
import { Currency, CurrencyAmount, Percent, TradeType } from '@uniswap/sdk-core'
import { Pair, Route as V2Route, Trade as V2Trade } from '@uniswap/v2-sdk'
import { Pool, Route as V3Route, Trade as V3Trade } from '@uniswap/v3-sdk'
import type { providers } from 'ethers'
import { constants } from 'ethers'
import { useCallback, useMemo } from 'react'
import { getTxOptimizedSwapRouter, SwapRouterVersion } from 'utils/getTxOptimizedSwapRouter'
@ -111,17 +111,17 @@ export function useApproveCallback(
}
let useExact = false
const estimatedGas = await tokenContract.estimateGas.approve(spender, MaxUint256).catch(() => {
const estimatedGas = await tokenContract.estimateGas.approve(spender, constants.MaxUint256).catch(() => {
// general fallback for tokens who restrict approval amounts
useExact = true
return tokenContract.estimateGas.approve(spender, amountToApprove.quotient.toString())
})
return tokenContract
.approve(spender, useExact ? amountToApprove.quotient.toString() : MaxUint256, {
.approve(spender, useExact ? amountToApprove.quotient.toString() : constants.MaxUint256, {
gasLimit: calculateGasMargin(estimatedGas),
})
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, { type: TransactionType.APPROVAL, tokenAddress: token.address, spender })
})
.catch((error: Error) => {

@ -1,4 +1,3 @@
import { Contract } from '@ethersproject/contracts'
import { abi as GOVERNANCE_ABI } from '@uniswap/governance/build/GovernorAlpha.json'
import { abi as UNI_ABI } from '@uniswap/governance/build/Uni.json'
import { abi as STAKING_REWARDS_ABI } from '@uniswap/liquidity-staker/build/StakingRewards.json'
@ -32,6 +31,7 @@ import {
V2_ROUTER_ADDRESS,
V3_MIGRATOR_ADDRESSES,
} from 'constants/addresses'
import { Contract } from 'ethers'
import { useMemo } from 'react'
import { NonfungiblePositionManager, Quoter, UniswapInterfaceMulticall } from 'types/v3'
import { V3Migrator } from 'types/v3/V3Migrator'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
import { useSingleCallResult } from '../state/multicall/hooks'
import { useInterfaceMulticall } from './useContract'

@ -1,6 +1,5 @@
import { BigNumber } from '@ethersproject/bignumber'
import { hexZeroPad } from '@ethersproject/bytes'
import { namehash } from '@ethersproject/hash'
import { BigNumber } from 'ethers'
import { hexZeroPad, namehash } from 'ethers/lib/utils'
import uriToHttp from 'lib/utils/uriToHttp'
import { useEffect, useMemo, useState } from 'react'
import { safeNamehash } from 'utils/safeNamehash'

@ -1,4 +1,4 @@
import { namehash } from '@ethersproject/hash'
import { namehash } from 'ethers/lib/utils'
import { useMemo } from 'react'
import { useSingleCallResult } from '../state/multicall/hooks'

@ -1,8 +1,8 @@
import { splitSignature } from '@ethersproject/bytes'
import { Trade } from '@uniswap/router-sdk'
import { Currency, CurrencyAmount, Percent, Token, TradeType } from '@uniswap/sdk-core'
import { Trade as V2Trade } from '@uniswap/v2-sdk'
import { Trade as V3Trade } from '@uniswap/v3-sdk'
import { splitSignature } from 'ethers/lib/utils'
import JSBI from 'jsbi'
import { useMemo, useState } from 'react'

@ -1,4 +1,4 @@
import { TransactionResponse } from '@ethersproject/providers'
import { providers } from 'ethers'
import { initializeApp } from 'firebase/app'
import { getDatabase, push, ref } from 'firebase/database'
import { useCallback } from 'react'
@ -6,7 +6,7 @@ import { TransactionInfo, TransactionType } from 'state/transactions/actions'
import { useActiveWeb3React } from './web3'
type PartialTransactionResponse = Pick<TransactionResponse, 'hash' | 'v' | 'r' | 's'>
type PartialTransactionResponse = Pick<providers.TransactionResponse, 'hash' | 'v' | 'r' | 's'>
const SUPPORTED_TRANSACTION_TYPES = [
TransactionType.ADD_LIQUIDITY_V2_POOL,
@ -61,7 +61,7 @@ export function useTransactionMonitoringEventCallback() {
const log = useMonitoringEventCallback()
return useCallback(
(info: TransactionInfo, transactionResponse: TransactionResponse) => {
(info: TransactionInfo, transactionResponse: providers.TransactionResponse) => {
if (SUPPORTED_TRANSACTION_TYPES.includes(info.type)) {
log(TransactionType[info.type], {
transactionResponse: (({ hash, v, r, s }: PartialTransactionResponse) => ({ hash, v, r, s }))(

@ -1,8 +1,8 @@
import { Interface } from '@ethersproject/abi'
import { Currency, Token } from '@uniswap/sdk-core'
import { abi as IUniswapV3PoolStateABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json'
import { computePoolAddress } from '@uniswap/v3-sdk'
import { FeeAmount, Pool } from '@uniswap/v3-sdk'
import { Interface } from 'ethers/lib/utils'
import { useMemo } from 'react'
import { V3_CORE_FACTORY_ADDRESSES } from '../constants/addresses'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
import JSBI from 'jsbi'
import { useMemo } from 'react'

@ -1,10 +1,10 @@
import { BigNumber } from '@ethersproject/bignumber'
// eslint-disable-next-line no-restricted-imports
import { t, Trans } from '@lingui/macro'
import { SwapRouter, Trade } from '@uniswap/router-sdk'
import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
import { Router as V2SwapRouter, Trade as V2Trade } from '@uniswap/v2-sdk'
import { SwapRouter as V3SwapRouter, Trade as V3Trade } from '@uniswap/v3-sdk'
import { BigNumber } from 'ethers'
import { ReactNode, useMemo } from 'react'
import { SWAP_ROUTER_ADDRESSES, V3_ROUTER_ADDRESS } from '../constants/addresses'

@ -1,5 +1,5 @@
import { BigNumber } from '@ethersproject/bignumber'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import { BigNumber } from 'ethers'
import { useSingleCallResult } from '../state/multicall/hooks'
import { useTokenContract } from './useContract'

@ -1,6 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'
import { L2_CHAIN_IDS } from 'constants/chains'
import { L2_DEADLINE_FROM_NOW } from 'constants/misc'
import { BigNumber } from 'ethers'
import { useMemo } from 'react'
import { useAppSelector } from 'state/hooks'

@ -1,7 +1,7 @@
import { Interface } from '@ethersproject/abi'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { computePairAddress, Pair } from '@uniswap/v2-sdk'
import { Interface } from 'ethers/lib/utils'
import { useMemo } from 'react'
import { V2_FACTORY_ADDRESSES } from '../constants/addresses'

@ -1,6 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
import { Pool } from '@uniswap/v3-sdk'
import { BigNumber } from 'ethers'
import { useEffect, useState } from 'react'
import { useBlockNumber } from 'state/application/hooks'
import { useSingleCallResult } from 'state/multicall/hooks'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
import { useMemo } from 'react'
import { CallStateResult, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks'
import { PositionDetails } from 'types/position'

@ -7,14 +7,16 @@
"error",
{
"paths": [
{
"name": "styled-components/macro",
"message": "Please import styled from lib/theme to get the correct typings."
},
{
"name": "react-feather",
"message": "Please import from lib/icons to ensure performant usage."
}
],
"patterns": [
{
"group": ["styled-components"],
"message": "Please import styled from lib/theme to get the correct typings."
}
]
}
]

@ -1,5 +1,6 @@
import styled, { css, ThemedText } from 'lib/theme'
import { ReactNode } from 'react'
// eslint-disable-next-line no-restricted-imports
import { AnyStyledComponent } from 'styled-components'
import Row from '../../Row'

@ -1,6 +1,6 @@
import { Provider } from '@ethersproject/abstract-provider'
import { Contract } from '@ethersproject/contracts'
import { namehash } from '@ethersproject/hash'
import type { providers } from 'ethers'
import { Contract } from 'ethers'
import { namehash } from 'ethers/lib/utils'
const REGISTRAR_ABI = [
{
@ -50,7 +50,7 @@ const RESOLVER_ABI = [
]
// cache the resolver contracts since most of them are the public resolver
function resolverContract(resolverAddress: string, provider: Provider): Contract {
function resolverContract(resolverAddress: string, provider: providers.Provider): Contract {
return new Contract(resolverAddress, RESOLVER_ABI, provider)
}
@ -59,7 +59,7 @@ function resolverContract(resolverAddress: string, provider: Provider): Contract
* @param ensName to resolve
* @param provider provider to use to fetch the data
*/
export default async function resolveENSContentHash(ensName: string, provider: Provider): Promise<string> {
export default async function resolveENSContentHash(ensName: string, provider: providers.Provider): Promise<string> {
const ensRegistrarContract = new Contract(REGISTRAR_ADDRESS, REGISTRAR_ABI, provider)
const hash = namehash(ensName)
const resolverAddress = await ensRegistrarContract.resolver(hash)

@ -1,9 +1,9 @@
import { BigNumber } from '@ethersproject/bignumber'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'
import { FeeAmount, NonfungiblePositionManager } from '@uniswap/v3-sdk'
import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter'
import type { providers } from 'ethers'
import { BigNumber } from 'ethers'
import { useCallback, useContext, useEffect, useState } from 'react'
import { AlertTriangle } from 'react-feather'
import ReactGA from 'react-ga'
@ -272,7 +272,7 @@ export default function AddLiquidity({
return library
.getSigner()
.sendTransaction(newTxn)
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
setAttemptingTxn(false)
addTransaction(response, {
type: TransactionType.ADD_LIQUIDITY_V3_POOL,

@ -1,9 +1,9 @@
import { BigNumber } from '@ethersproject/bignumber'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'
import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter'
import { SwitchLocaleLink } from 'components/SwitchLocaleLink'
import type { providers } from 'ethers'
import { BigNumber } from 'ethers'
import { useCallback, useContext, useState } from 'react'
import { Plus } from 'react-feather'
import ReactGA from 'react-ga'
@ -147,7 +147,7 @@ export default function AddLiquidity({
}
let estimate,
method: (...args: any) => Promise<TransactionResponse>,
method: (...args: any) => Promise<providers.TransactionResponse>,
args: Array<string | string[] | number>,
value: BigNumber | null
if (currencyA.isNative || currencyB.isNative) {

@ -1,10 +1,9 @@
import { defaultAbiCoder } from '@ethersproject/abi'
import { getAddress, isAddress } from '@ethersproject/address'
import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import { ButtonError } from 'components/Button'
import { BlueCard } from 'components/Card'
import { AutoColumn } from 'components/Column'
import { defaultAbiCoder, getAddress, isAddress } from 'ethers/lib/utils'
import { useActiveWeb3React } from 'hooks/web3'
import JSBI from 'jsbi'
import { Wrapper } from 'pages/Pool/styleds'

@ -1,5 +1,3 @@
import { Contract } from '@ethersproject/contracts'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { CurrencyAmount, Fraction, Percent, Price, Token } from '@uniswap/sdk-core'
import { FeeAmount, Pool, Position, priceToClosestTick, TickMath } from '@uniswap/v3-sdk'
@ -12,6 +10,8 @@ import RangeSelector from 'components/RangeSelector'
import RateToggle from 'components/RateToggle'
import SettingsTab from 'components/Settings'
import { Dots } from 'components/swap/styleds'
import type { providers } from 'ethers'
import { Contract } from 'ethers'
import { ApprovalState, useApproveCallback } from 'hooks/useApproveCallback'
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import { PoolState, usePool } from 'hooks/usePools'
@ -335,7 +335,7 @@ function V2PairMigration({
.then((gasEstimate) => {
return migrator
.multicall(data, { gasLimit: calculateGasMargin(gasEstimate) })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
ReactGA.event({
category: 'Migrate',
action: `${isNotUniswap ? 'SushiSwap' : 'V2'}->V3`,

@ -1,11 +1,10 @@
import { getCreate2Address } from '@ethersproject/address'
import { keccak256, pack } from '@ethersproject/solidity'
import { Trans } from '@lingui/macro'
import { Token } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import MigrateSushiPositionCard from 'components/PositionCard/Sushi'
import MigrateV2PositionCard from 'components/PositionCard/V2'
import { SwitchLocaleLink } from 'components/SwitchLocaleLink'
import { getCreate2Address, solidityKeccak256 as keccak256, solidityPack as pack } from 'ethers/lib/utils'
import { PairState, useV2Pairs } from 'hooks/useV2Pairs'
import { ReactNode, useContext, useMemo } from 'react'
import { Text } from 'rebass'

@ -1,5 +1,3 @@
import { BigNumber } from '@ethersproject/bignumber'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Fraction, Percent, Price, Token } from '@uniswap/sdk-core'
import { NonfungiblePositionManager, Pool, Position } from '@uniswap/v3-sdk'
@ -14,6 +12,8 @@ import { RowBetween, RowFixed } from 'components/Row'
import { Dots } from 'components/swap/styleds'
import Toggle from 'components/Toggle'
import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal'
import type { providers } from 'ethers'
import { BigNumber } from 'ethers'
import { useToken } from 'hooks/Tokens'
import { useV3NFTPositionManagerContract } from 'hooks/useContract'
import useIsTickAtLimit from 'hooks/useIsTickAtLimit'
@ -448,7 +448,7 @@ export function PositionPage({
return library
.getSigner()
.sendTransaction(newTxn)
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
setCollectMigrationHash(response.hash)
setCollecting(false)

@ -1,5 +1,3 @@
import { BigNumber } from '@ethersproject/bignumber'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { Percent } from '@uniswap/sdk-core'
import { NonfungiblePositionManager } from '@uniswap/v3-sdk'
@ -16,6 +14,8 @@ import { AddRemoveTabs } from 'components/NavigationTabs'
import { AutoRow, RowBetween, RowFixed } from 'components/Row'
import Slider from 'components/Slider'
import Toggle from 'components/Toggle'
import type { providers } from 'ethers'
import { BigNumber } from 'ethers'
import { useV3NFTPositionManagerContract } from 'hooks/useContract'
import useDebouncedChangeHandler from 'hooks/useDebouncedChangeHandler'
import useTheme from 'hooks/useTheme'
@ -145,7 +145,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
return library
.getSigner()
.sendTransaction(newTxn)
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
ReactGA.event({
category: 'Liquidity',
action: 'RemoveV3',

@ -1,8 +1,7 @@
import { BigNumber } from '@ethersproject/bignumber'
import { Contract } from '@ethersproject/contracts'
import { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro'
import { Currency, Percent } from '@uniswap/sdk-core'
import type { providers } from 'ethers'
import { BigNumber, Contract } from 'ethers'
import { useCallback, useContext, useMemo, useState } from 'react'
import { ArrowDown, Plus } from 'react-feather'
import ReactGA from 'react-ga'
@ -262,7 +261,7 @@ export default function RemoveLiquidity({
await router[methodName](...args, {
gasLimit: safeGasEstimate,
})
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
setAttemptingTxn(false)
addTransaction(response, {

@ -1,7 +1,7 @@
import { BigNumber } from '@ethersproject/bignumber'
// eslint-disable-next-line no-restricted-imports
import { t, Trans } from '@lingui/macro'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { BigNumber } from 'ethers'
import { useActiveLocale } from 'hooks/useActiveLocale'
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import JSBI from 'jsbi'

@ -1,5 +1,5 @@
import { TransactionResponse } from '@ethersproject/providers'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import type { providers } from 'ethers'
import JSBI from 'jsbi'
import { useEffect, useState } from 'react'
@ -165,7 +165,7 @@ export function useClaimCallback(account: string | null | undefined): {
return distributorContract.estimateGas['claim'](...args, {}).then((estimatedGasLimit) => {
return distributorContract
.claim(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.CLAIM,
recipient: account,

@ -1,15 +1,20 @@
import { defaultAbiCoder, Interface } from '@ethersproject/abi'
import { isAddress } from '@ethersproject/address'
import { Contract } from '@ethersproject/contracts'
import { TransactionResponse } from '@ethersproject/providers'
import { toUtf8String, Utf8ErrorFuncs, Utf8ErrorReason } from '@ethersproject/strings'
import { formatUnits } from '@ethersproject/units'
// eslint-disable-next-line no-restricted-imports
import { t } from '@lingui/macro'
import { abi as GOV_ABI } from '@uniswap/governance/build/GovernorAlpha.json'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { POLYGON_PROPOSAL_TITLE } from 'constants/proposals/polygon_proposal_title'
import { UNISWAP_GRANTS_PROPOSAL_DESCRIPTION } from 'constants/proposals/uniswap_grants_proposal_description'
import type { providers } from 'ethers'
import { Contract } from 'ethers'
import {
defaultAbiCoder,
formatUnits,
Interface,
isAddress,
toUtf8String,
Utf8ErrorFuncs,
Utf8ErrorReason,
} from 'ethers/lib/utils'
import {
useGovernanceBravoContract,
useGovernanceV0Contract,
@ -320,7 +325,7 @@ export function useDelegateCallback(): (delegatee: string | undefined) => undefi
return uniContract.estimateGas.delegate(...args, {}).then((estimatedGasLimit) => {
return uniContract
.delegate(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.DELEGATE,
delegatee,
@ -349,7 +354,7 @@ export function useVoteCallback(): {
return latestGovernanceContract.estimateGas.castVote(...args, {}).then((estimatedGasLimit) => {
return latestGovernanceContract
.castVote(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.VOTE,
decision: voteOption,
@ -389,7 +394,7 @@ export function useCreateProposalCallback(): (
return latestGovernanceContract.estimateGas.propose(...args).then((estimatedGasLimit) => {
return latestGovernanceContract
.propose(...args, { gasLimit: calculateGasMargin(estimatedGasLimit) })
.then((response: TransactionResponse) => {
.then((response: providers.TransactionResponse) => {
addTransaction(response, {
type: TransactionType.SUBMIT_PROPOSAL,
})

@ -1,8 +1,8 @@
import { Interface } from '@ethersproject/abi'
import { Trans } from '@lingui/macro'
import { abi as STAKING_REWARDS_ABI } from '@uniswap/liquidity-staker/build/StakingRewards.json'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import { Interface } from 'ethers/lib/utils'
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import JSBI from 'jsbi'
import { ReactNode, useMemo } from 'react'

@ -1,6 +1,6 @@
import { parseUnits } from '@ethersproject/units'
import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Percent, TradeType } from '@uniswap/sdk-core'
import { parseUnits } from 'ethers/lib/utils'
import { useBestTrade } from 'hooks/useBestTrade'
import JSBI from 'jsbi'
import { ParsedQs } from 'qs'

@ -1,4 +1,4 @@
import { TransactionResponse } from '@ethersproject/providers'
import type { providers } from 'ethers'
import { useTransactionMonitoringEventCallback } from 'hooks/useMonitoringEventCallback'
import { useCallback, useMemo } from 'react'
import { useAppDispatch, useAppSelector } from 'state/hooks'
@ -8,14 +8,14 @@ import { addTransaction, TransactionInfo, TransactionType } from './actions'
import { TransactionDetails } from './reducer'
// helper that can take a ethers library transaction response and add it to the list of transactions
export function useTransactionAdder(): (response: TransactionResponse, info: TransactionInfo) => void {
export function useTransactionAdder(): (response: providers.TransactionResponse, info: TransactionInfo) => void {
const { chainId, account } = useActiveWeb3React()
const dispatch = useAppDispatch()
const logMonitoringEvent = useTransactionMonitoringEventCallback()
return useCallback(
(response: TransactionResponse, info: TransactionInfo) => {
(response: providers.TransactionResponse, info: TransactionInfo) => {
if (!account) return
if (!chainId) return

@ -1,7 +1,7 @@
import { Interface } from '@ethersproject/abi'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import ERC20ABI from 'abis/erc20.json'
import { Erc20Interface } from 'abis/types/Erc20'
import { Interface } from 'ethers/lib/utils'
import JSBI from 'jsbi'
import { useMemo } from 'react'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
export interface PositionDetails {
nonce: BigNumber

@ -1,6 +1,6 @@
import { Interface } from '@ethersproject/abi'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
import { toHex } from '@uniswap/v3-sdk'
import { Interface } from 'ethers/lib/utils'
import { Erc20Interface } from '../abis/types/Erc20'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
import { calculateGasMargin } from './calculateGasMargin'

@ -1,4 +1,4 @@
import { BigNumber } from '@ethersproject/bignumber'
import { BigNumber } from 'ethers'
/**
* Returns the gas value plus a margin for unexpected or variable gas costs

@ -1,11 +1,11 @@
import { AddressZero } from '@ethersproject/constants'
import { CurrencyAmount, Percent, Token } from '@uniswap/sdk-core'
import { constants } from 'ethers'
import { calculateSlippageAmount } from './calculateSlippageAmount'
describe('#calculateSlippageAmount', () => {
it('bounds are correct', () => {
const tokenAmount = CurrencyAmount.fromRawAmount(new Token(1, AddressZero, 0), '100')
const tokenAmount = CurrencyAmount.fromRawAmount(new Token(1, constants.AddressZero, 0), '100')
expect(() => calculateSlippageAmount(tokenAmount, new Percent(-1, 10_000))).toThrow('Unexpected slippage')
expect(() => calculateSlippageAmount(tokenAmount, new Percent(10_001, 10_000))).toThrow('Unexpected slippage')
expect(calculateSlippageAmount(tokenAmount, new Percent(0, 10_000)).map((bound) => bound.toString())).toEqual([
@ -30,7 +30,7 @@ describe('#calculateSlippageAmount', () => {
])
})
it('works for 18 decimals', () => {
const tokenAmount = CurrencyAmount.fromRawAmount(new Token(1, AddressZero, 18), '100')
const tokenAmount = CurrencyAmount.fromRawAmount(new Token(1, constants.AddressZero, 18), '100')
expect(() => calculateSlippageAmount(tokenAmount, new Percent(-1, 10_000))).toThrow('Unexpected slippage')
expect(() => calculateSlippageAmount(tokenAmount, new Percent(10_001, 10_000))).toThrow('Unexpected slippage')
expect(calculateSlippageAmount(tokenAmount, new Percent(0, 10_000)).map((bound) => bound.toString())).toEqual([

@ -1,5 +1,5 @@
import { BigNumber } from '@ethersproject/bignumber'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { BigNumber } from 'ethers'
import JSBI from 'jsbi'
import { ZERO_ADDRESS } from '../constants/misc'

@ -1,5 +1,5 @@
import { BigNumber } from '@ethersproject/bignumber'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { BigNumber } from 'ethers'
import JSBI from 'jsbi'
import { STAKING_GENESIS } from '../state/stake/hooks'

@ -1,4 +1,4 @@
import { Web3Provider } from '@ethersproject/providers'
import { providers } from 'ethers'
import ms from 'ms.macro'
import { SupportedChainId } from '../constants/chains'
@ -10,8 +10,8 @@ const NETWORK_POLLING_INTERVALS: { [chainId: number]: number } = {
[SupportedChainId.OPTIMISTIC_KOVAN]: ms`1s`,
}
export default function getLibrary(provider: any): Web3Provider {
const library = new Web3Provider(
export default function getLibrary(provider: any): providers.Web3Provider {
const library = new providers.Web3Provider(
provider,
typeof provider.chainId === 'number'
? provider.chainId

@ -1,9 +1,8 @@
import { getAddress } from '@ethersproject/address'
import { AddressZero } from '@ethersproject/constants'
import { Contract } from '@ethersproject/contracts'
import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
import { Token } from '@uniswap/sdk-core'
import { FeeAmount } from '@uniswap/v3-sdk'
import type { providers } from 'ethers'
import { constants, Contract } from 'ethers'
import { getAddress } from 'ethers/lib/utils'
import { TokenAddressMap } from '../state/lists/hooks'
@ -26,18 +25,21 @@ export function shortenAddress(address: string, chars = 4): string {
}
// account is not optional
function getSigner(library: Web3Provider, account: string): JsonRpcSigner {
function getSigner(library: providers.Web3Provider, account: string): providers.JsonRpcSigner {
return library.getSigner(account).connectUnchecked()
}
// account is optional
function getProviderOrSigner(library: Web3Provider, account?: string): Web3Provider | JsonRpcSigner {
function getProviderOrSigner(
library: providers.Web3Provider,
account?: string
): providers.Web3Provider | providers.JsonRpcSigner {
return account ? getSigner(library, account) : library
}
// account is optional
export function getContract(address: string, ABI: any, library: Web3Provider, account?: string): Contract {
if (!isAddress(address) || address === AddressZero) {
export function getContract(address: string, ABI: any, library: providers.Web3Provider, account?: string): Contract {
if (!isAddress(address) || address === constants.AddressZero) {
throw Error(`Invalid 'address' parameter '${address}'.`)
}

@ -1,4 +1,4 @@
import { namehash } from '@ethersproject/hash'
import { namehash } from 'ethers/lib/utils'
import { safeNamehash } from './safeNamehash'

@ -1,4 +1,4 @@
import { namehash } from '@ethersproject/hash'
import { namehash } from 'ethers/lib/utils'
export function safeNamehash(name?: string): string | undefined {
if (name === undefined) return undefined

@ -1,10 +1,10 @@
import { BigNumber } from '@ethersproject/bignumber'
import { hexStripZeros } from '@ethersproject/bytes'
import { Web3Provider } from '@ethersproject/providers'
import { CHAIN_INFO, SupportedChainId } from 'constants/chains'
import type { providers } from 'ethers'
import { BigNumber } from 'ethers'
import { hexStripZeros } from 'ethers/lib/utils'
interface SwitchNetworkArguments {
library: Web3Provider
library: providers.Web3Provider
chainId: SupportedChainId
}

@ -4942,11 +4942,6 @@
resolved "https://registry.yarnpkg.com/@uniswap/default-token-list/-/default-token-list-2.2.0.tgz#d85a5c2520f57f4920bd989dfc9f01e1b701a567"
integrity sha512-vFPWoGzDjHP4i2l7yLaober/lZMmzOZXXirVF8XNyfNzRxgmYCWKO6SzKtfEUwxpd3/KUebgdK55II4Mnak62A==
"@uniswap/default-token-list@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@uniswap/default-token-list/-/default-token-list-3.0.0.tgz#427ff2a65bbc77a5a24e60f6158441956773f684"
integrity sha512-t0H96s1Mx2ga6cGMj/wP/3NWdX4c9yZFd0ydiTOWLhWf1i5RjhWWND/ZTdn8QhmNsdHlhrGsWrEU62xoAY11bw==
"@uniswap/governance@^1.0.2":
version "1.0.2"
resolved "https://registry.npmjs.org/@uniswap/governance/-/governance-1.0.2.tgz"