Commit 7fb7517a authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

chore: remove more unused exports (#5529)

* chore: remove more unused exports

* fix

* undo top tokens change
parent 1a6fe3c1
......@@ -7,7 +7,7 @@ import { getCLS, getFCP, getFID, getLCP, Metric } from 'web-vitals'
import GoogleAnalyticsProvider from './GoogleAnalyticsProvider'
export const GOOGLE_ANALYTICS_CLIENT_ID_STORAGE_KEY = 'ga_client_id'
const GOOGLE_ANALYTICS_CLIENT_ID_STORAGE_KEY = 'ga_client_id'
const GOOGLE_ANALYTICS_ID: string | undefined = process.env.REACT_APP_GOOGLE_ANALYTICS_ID
const storedClientId = window.localStorage.getItem(GOOGLE_ANALYTICS_CLIENT_ID_STORAGE_KEY)
......
......@@ -36,7 +36,7 @@ interface BaseChainInfo {
readonly backgroundColor?: string
}
export interface L1ChainInfo extends BaseChainInfo {
interface L1ChainInfo extends BaseChainInfo {
readonly networkType: NetworkType.L1
readonly defaultListUrl?: string
}
......@@ -48,7 +48,7 @@ export interface L2ChainInfo extends BaseChainInfo {
readonly defaultListUrl: string
}
export type ChainInfoMap = { readonly [chainId: number]: L1ChainInfo | L2ChainInfo } & {
type ChainInfoMap = { readonly [chainId: number]: L1ChainInfo | L2ChainInfo } & {
readonly [chainId in SupportedL2ChainId]: L2ChainInfo
} & { readonly [chainId in SupportedL1ChainId]: L1ChainInfo }
......@@ -240,7 +240,7 @@ export function getChainInfo(chainId: any): any {
return undefined
}
export const MAINNET_INFO = CHAIN_INFO[SupportedChainId.MAINNET]
const MAINNET_INFO = CHAIN_INFO[SupportedChainId.MAINNET]
export function getChainInfoOrDefault(chainId: number | undefined) {
return getChainInfo(chainId) ?? MAINNET_INFO
}
......@@ -89,13 +89,6 @@ export const PORTAL_USDC_CELO = new Token(
'USDCet',
'USDC (Portal from Ethereum)'
)
const USDC_CELO_ALFAJORES = new Token(
SupportedChainId.CELO_ALFAJORES,
'0x41F4a5d2632b019Ae6CE9625bE3c9CaC143AcC7D',
6,
'USDC',
'USD//C'
)
export const AMPL = new Token(
SupportedChainId.MAINNET,
'0xD46bA6D942050d489DBd938a2C909A5d5039A161',
......@@ -124,21 +117,6 @@ export const DAI_OPTIMISM = new Token(
'DAI',
'Dai stable coin'
)
export const USDC: { [chainId in SupportedChainId]: Token } = {
[SupportedChainId.MAINNET]: USDC_MAINNET,
[SupportedChainId.ARBITRUM_ONE]: USDC_ARBITRUM,
[SupportedChainId.OPTIMISM]: USDC_OPTIMISM,
[SupportedChainId.ARBITRUM_RINKEBY]: USDC_ARBITRUM_RINKEBY,
[SupportedChainId.OPTIMISM_GOERLI]: USDC_OPTIMISM_GOERLI,
[SupportedChainId.POLYGON]: USDC_POLYGON,
[SupportedChainId.POLYGON_MUMBAI]: USDC_POLYGON_MUMBAI,
[SupportedChainId.CELO]: PORTAL_USDC_CELO,
[SupportedChainId.CELO_ALFAJORES]: USDC_CELO_ALFAJORES,
[SupportedChainId.GOERLI]: USDC_GOERLI,
[SupportedChainId.RINKEBY]: USDC_RINKEBY,
[SupportedChainId.KOVAN]: USDC_KOVAN,
[SupportedChainId.ROPSTEN]: USDC_ROPSTEN,
}
export const DAI_POLYGON = new Token(
SupportedChainId.POLYGON,
'0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063',
......@@ -436,7 +414,7 @@ class MaticNativeCurrency extends NativeCurrency {
}
}
export class ExtendedEther extends Ether {
class ExtendedEther extends Ether {
public get wrapped(): Token {
const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId]
if (wrapped) return wrapped
......
......@@ -9,7 +9,7 @@ interface FeatureFlagsContextType {
const FeatureFlagContext = createContext<FeatureFlagsContextType>({ isLoaded: false, flags: {} })
export function useFeatureFlagsContext(): FeatureFlagsContextType {
function useFeatureFlagsContext(): FeatureFlagsContextType {
const context = useContext(FeatureFlagContext)
if (!context) {
throw Error('Feature flag hooks can only be used by children of FeatureFlagProvider.')
......
......@@ -50,7 +50,7 @@ const network = new RelayNetworkLayer(
{ noThrow: true }
)
export const CachingEnvironment = new Environment({
const CachingEnvironment = new Environment({
network,
store: new Store(new RecordSource(), { gcReleaseBufferSize, queryCacheExpirationTime }),
})
......
......@@ -55,7 +55,7 @@ export const tokenQuery = graphql`
}
}
`
export type { Chain, ContractInput, TokenQuery } from './__generated__/TokenQuery.graphql'
export type { Chain, TokenQuery } from './__generated__/TokenQuery.graphql'
export type TokenQueryData = NonNullable<TokenQuery$data['tokens']>[number]
......
......@@ -52,7 +52,7 @@ export function chainIdToBackendName(chainId: number | undefined) {
: CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET]
}
export const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: Chain } = {
const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: Chain } = {
ethereum: 'ETHEREUM',
polygon: 'POLYGON',
celo: 'CELO',
......
......@@ -4,7 +4,7 @@ import uriToHttp from 'lib/utils/uriToHttp'
import { useCallback, useEffect, useState } from 'react'
import { isAddress } from 'utils'
export const BAD_SRCS: { [tokenAddress: string]: true } = {}
const BAD_SRCS: { [tokenAddress: string]: true } = {}
// Converts uri's into fetchable urls
function parseLogoSources(uris: string[]) {
......
......@@ -13,9 +13,9 @@ import { InterfaceTrade } from 'state/routing/types'
import useGasPrice from './useGasPrice'
import useStablecoinPrice, { useStablecoinValue } from './useStablecoinPrice'
export const V3_SWAP_DEFAULT_SLIPPAGE = new Percent(50, 10_000) // .50%
const V3_SWAP_DEFAULT_SLIPPAGE = new Percent(50, 10_000) // .50%
const ONE_TENTHS_PERCENT = new Percent(10, 10_000) // .10%
export const DEFAULT_AUTO_SLIPPAGE = ONE_TENTHS_PERCENT
const DEFAULT_AUTO_SLIPPAGE = ONE_TENTHS_PERCENT
const GAS_ESTIMATE_BUFFER = new Percent(10, 100) // 10%
// Base costs regardless of how many hops in the route
......
import { Currency, CurrencyAmount, NativeCurrency, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import { Weth } from 'abis/types'
import WETH_ABI from 'abis/weth.json'
import { ALL_SUPPORTED_CHAIN_IDS, isSupportedChain, SupportedChainId, TESTNET_CHAIN_IDS } from 'constants/chains'
import { RPC_PROVIDERS } from 'constants/providers'
import { NATIVE_CHAIN_ID, nativeOnChain, WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
import { BaseVariant, FeatureFlag, useBaseFlag } from 'featureFlags'
import { useCallback, useEffect, useState } from 'react'
import { getContract } from 'utils'
interface useMultiNetworkAddressBalancesArgs {
ownerAddress: string | undefined
tokenAddress: 'NATIVE' | string | undefined
}
type AddressNetworkBalanceData = Partial<
Record<
SupportedChainId,
Record<string | 'NATIVE', CurrencyAmount<Token> | CurrencyAmount<NativeCurrency> | undefined>
>
>
interface handleBalanceArg {
amount: CurrencyAmount<Currency>
chainId: SupportedChainId
tokenAddress: string | 'NATIVE'
}
const testnetSet = new Set(TESTNET_CHAIN_IDS) as Set<SupportedChainId>
export function useMultiNetworkAddressBalances({ ownerAddress, tokenAddress }: useMultiNetworkAddressBalancesArgs) {
const [data, setData] = useState<AddressNetworkBalanceData>({})
const [error] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
const { chainId: connectedChainId } = useWeb3React()
const feature_flag_multi_network_balances = useBaseFlag(FeatureFlag.multiNetworkBalances)
const handleBalance = useCallback(({ amount, chainId, tokenAddress }: handleBalanceArg) => {
if (!amount.greaterThan(0) || !tokenAddress) {
return
}
setData((data) => ({
...data,
[chainId]: {
...(data[chainId] ?? {}),
[tokenAddress]: amount,
},
}))
}, [])
useEffect(() => {
if (!ownerAddress || !tokenAddress) {
return
}
const isConnecteToTestnet = connectedChainId ? TESTNET_CHAIN_IDS.includes(connectedChainId) : false
setLoading(true)
const isNative = tokenAddress === NATIVE_CHAIN_ID
const promises: Promise<any>[] = []
const isWrappedNative = ALL_SUPPORTED_CHAIN_IDS.some(
(chainId) => WRAPPED_NATIVE_CURRENCY[chainId]?.address.toLowerCase() === tokenAddress.toLowerCase()
)
const chainsToCheck: SupportedChainId[] =
feature_flag_multi_network_balances === BaseVariant.Enabled
? ALL_SUPPORTED_CHAIN_IDS
: isSupportedChain(connectedChainId)
? [SupportedChainId.MAINNET, connectedChainId]
: [SupportedChainId.MAINNET]
chainsToCheck.forEach((chainId) => {
const isTestnet = testnetSet.has(chainId)
if ((isConnecteToTestnet && isTestnet) || !isTestnet) {
const provider = RPC_PROVIDERS[chainId]
if (isWrappedNative || isNative) {
const wrappedNative = WRAPPED_NATIVE_CURRENCY[chainId]
if (wrappedNative) {
promises.push(
new Promise(async (resolve) => {
try {
const wrappedNativeContract = getContract(wrappedNative.address, WETH_ABI, provider) as Weth
const balance = await wrappedNativeContract.balanceOf(ownerAddress, { blockTag: 'latest' })
const amount = CurrencyAmount.fromRawAmount(wrappedNative, balance.toString())
resolve(handleBalance({ amount, chainId, tokenAddress: wrappedNative.address.toLowerCase() }))
} catch (e) {}
})
)
}
promises.push(
new Promise(async (resolve) => {
try {
const balance = await provider.getBalance(ownerAddress, 'latest')
const nativeCurrency = nativeOnChain(chainId)
const amount = CurrencyAmount.fromRawAmount(nativeCurrency, balance.toString())
resolve(handleBalance({ amount, chainId, tokenAddress: 'NATIVE' }))
} catch (e) {}
})
)
// todo (jordan): support multi-network ERC20 balances
// } else {
// promises.push(
// new Promise(async (resolve) => {
// try {
// const ERC20Contract = getContract(tokenAddress, ERC20_ABI, provider) as Erc20
// const balance = await ERC20Contract.balanceOf(ownerAddress, { blockTag: 'latest' })
// const amount = //
// resolve(handleBalance({ amount, chainId, tokenAddress }))
// } catch (e) {}
// })
// )
}
}
})
Promise.all(promises)
.catch(() => ({}))
.finally(() => setLoading(false))
}, [connectedChainId, feature_flag_multi_network_balances, handleBalance, ownerAddress, tokenAddress])
return { data, error, loading }
}
......@@ -6,8 +6,6 @@ import { useMemo } from 'react'
import { useApproval } from '../useApproval'
export { ApprovalState } from '../useApproval'
// wraps useApproveCallback in the context of a swap
export default function useSwapApproval(
trade: Trade<Currency, Currency, TradeType> | undefined,
......
......@@ -26,7 +26,7 @@ function parseStringOrBytes32(str: string | undefined, bytes32: string | undefin
}
export const UNKNOWN_TOKEN_SYMBOL = 'UNKNOWN'
export const UNKNOWN_TOKEN_NAME = 'Unknown Token'
const UNKNOWN_TOKEN_NAME = 'Unknown Token'
/**
* Returns a Token from the tokenAddress.
......
......@@ -30,7 +30,7 @@ const ExploreContainer = styled.div`
padding-top: 20px;
}
`
export const TitleContainer = styled.div`
const TitleContainer = styled.div`
margin-bottom: 32px;
max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT};
margin-left: auto;
......
......@@ -5,7 +5,7 @@ import { Route } from 'workbox-routing'
import { isDevelopment } from './utils'
const fileExtensionRegexp = new RegExp('/[^/?]+\\.[^/]+$')
export const DOCUMENT = process.env.PUBLIC_URL + '/index.html'
const DOCUMENT = process.env.PUBLIC_URL + '/index.html'
/**
* Matches with App Shell-style routing, so that navigation requests are fulfilled with an index.html shell.
......
......@@ -20,7 +20,6 @@ import {
updateHideClosedPositions,
updateHideNFTWelcomeModal,
updateShowNftPromoBanner,
updateShowSurveyPopup,
updateUserClientSideRouter,
updateUserDarkMode,
updateUserDeadline,
......@@ -106,18 +105,6 @@ export function useExpertModeManager(): [boolean, () => void] {
return [expertMode, toggleSetExpertMode]
}
export function useShowSurveyPopup(): [boolean | undefined, (showPopup: boolean) => void] {
const dispatch = useAppDispatch()
const showSurveyPopup = useAppSelector((state) => state.user.showSurveyPopup)
const toggleShowSurveyPopup = useCallback(
(showPopup: boolean) => {
dispatch(updateShowSurveyPopup({ showSurveyPopup: showPopup }))
},
[dispatch]
)
return [showSurveyPopup, toggleShowSurveyPopup]
}
export function useHideNFTWelcomeModal(): [boolean | undefined, () => void] {
const dispatch = useAppDispatch()
const hideNFTWelcomeModal = useAppSelector((state) => state.user.hideNFTWelcomeModal)
......
......@@ -30,7 +30,7 @@ const transitions = {
},
}
export const fadeIn = keyframes`
const fadeIn = keyframes`
from {
opacity: 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment