From 9f29f397882bf2f7aebe91f194d64a15f0c61e81 Mon Sep 17 00:00:00 2001 From: totop716 Date: Tue, 25 Jan 2022 14:38:19 -0500 Subject: [PATCH 1/2] Fix errors when loading on mumbai testnet --- src/utils/useUSDCPrice.ts | 6 +++--- src/utils/wrappedCurrency.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/useUSDCPrice.ts b/src/utils/useUSDCPrice.ts index 59433b013..a734a983b 100755 --- a/src/utils/useUSDCPrice.ts +++ b/src/utils/useUSDCPrice.ts @@ -24,7 +24,7 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined { [ chainId && wrapped && currencyEquals(WETH[chainId], wrapped) ? undefined - : currency, + : wrapped, chainId ? WETH[chainId] : undefined, ], [ @@ -48,11 +48,11 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined { chainId === ChainId.MATIC ? returnTokenFromKey('USDC') : undefined, ], [ - chainId ? returnTokenFromKey('QUICK') : undefined, + chainId === ChainId.MATIC ? returnTokenFromKey('QUICK') : undefined, chainId === ChainId.MATIC ? returnTokenFromKey('USDC') : undefined, ], ], - [chainId, currency, wrapped], + [chainId, wrapped], ); const [ [ethPairState, ethPair], diff --git a/src/utils/wrappedCurrency.ts b/src/utils/wrappedCurrency.ts index 9f0391b94..4e89da643 100755 --- a/src/utils/wrappedCurrency.ts +++ b/src/utils/wrappedCurrency.ts @@ -14,7 +14,7 @@ export function wrappedCurrency( ): Token | undefined { return chainId && currency === ETHER ? WETH[chainId] - : currency instanceof Token + : currency instanceof Token && currency.chainId === chainId ? currency : undefined; } From 9dd84ccf29532dbd73d21226aa879475f1d051c7 Mon Sep 17 00:00:00 2001 From: totop716 Date: Wed, 26 Jan 2022 04:06:11 -0500 Subject: [PATCH 2/2] show wrong network on mumbai testnet and update condition to check if it is not Polygon mainnet --- src/components/Header/Header.tsx | 9 ++++----- src/pages/LandingPage/LandingPage.tsx | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 21c901bd4..a61edff58 100755 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useState } from 'react'; +import { ChainId } from '@uniswap/sdk'; import { Link, useLocation } from 'react-router-dom'; import { Box, Button, Typography, useMediaQuery } from '@material-ui/core'; import cx from 'classnames'; @@ -275,9 +276,8 @@ const newTransactionsFirst = (a: TransactionDetails, b: TransactionDetails) => { const Header: React.FC = () => { const classes = useStyles(); const { pathname } = useLocation(); - const { account } = useActiveWeb3React(); + const { account, chainId } = useActiveWeb3React(); const { ENSName } = useENSName(account ?? undefined); - const { ethereum } = window as any; const [openDetailMenu, setOpenDetailMenu] = useState(false); const theme = useTheme(); const allTransactions = useAllTransactions(); @@ -292,8 +292,7 @@ const Header: React.FC = () => { const confirmed = sortedRecentTransactions .filter((tx: any) => tx.receipt) .map((tx: any) => tx.hash); - const isnotMatic = - ethereum && ethereum.isMetaMask && Number(ethereum.chainId) !== 137; + const isnotMatic = chainId !== ChainId.MATIC; const tabletWindowSize = useMediaQuery(theme.breakpoints.down('sm')); const mobileWindowSize = useMediaQuery(theme.breakpoints.down('xs')); const toggleWalletModal = useWalletModalToggle(); @@ -458,7 +457,7 @@ const Header: React.FC = () => { > - {account ? ( + {!isnotMatic && account ? ( {shortenAddress(account)} Wallet diff --git a/src/pages/LandingPage/LandingPage.tsx b/src/pages/LandingPage/LandingPage.tsx index bfedb464d..8ef962917 100755 --- a/src/pages/LandingPage/LandingPage.tsx +++ b/src/pages/LandingPage/LandingPage.tsx @@ -10,7 +10,7 @@ import { useMediaQuery, } from '@material-ui/core'; import Skeleton from '@material-ui/lab/Skeleton'; -import { Currency } from '@uniswap/sdk'; +import { Currency, ChainId } from '@uniswap/sdk'; import { useTheme } from '@material-ui/core/styles'; import Motif from 'assets/images/Motif.svg'; import BuyWithFiat from 'assets/images/featured/BuywithFiat.svg'; @@ -428,9 +428,7 @@ const LandingPage: React.FC = () => { const [openStakeModal, setOpenStakeModal] = useState(false); const { palette, breakpoints } = useTheme(); const { account, chainId } = useActiveWeb3React(); - const { ethereum } = window as any; - const isnotMatic = - ethereum && ethereum.isMetaMask && Number(ethereum.chainId) !== 137; + const isnotMatic = chainId !== ChainId.MATIC; const mobileWindowSize = useMediaQuery(breakpoints.down('sm')); const { initTransak } = useInitTransak(); const toggleWalletModal = useWalletModalToggle();