From e1549b1852a27254fa00e99f09cae7bff8b5f34a Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Thu, 12 Dec 2024 11:11:22 -0600 Subject: [PATCH 1/4] feat: config for cypress test --- .env.example | 1 + custom.d.ts | 1 + cypress/tsconfig.json | 1 + src/libs/web3-data-provider/Web3Provider.tsx | 29 ++++++--- src/ui-config/wagmiConfig.ts | 62 +++++++++++++++++--- src/utils/marketsAndNetworksConfig.ts | 6 +- 6 files changed, 79 insertions(+), 21 deletions(-) diff --git a/.env.example b/.env.example index 0a565d8495..d67e6ccb89 100644 --- a/.env.example +++ b/.env.example @@ -16,3 +16,4 @@ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID= NEXT_PUBLIC_MIXPANEL= NEXT_PUBLIC_FIAT_ON_RAMP=true NEXT_PUBLIC_SUBGRAPH_API_KEY= +NEXT_PUBLIC_IS_CYPRESS_ENABLED=false diff --git a/custom.d.ts b/custom.d.ts index 087bda4a84..745111581b 100644 --- a/custom.d.ts +++ b/custom.d.ts @@ -14,5 +14,6 @@ namespace NodeJS { NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: string; NEXT_PUBLIC_FIAT_ON_RAMP: string; NEXT_PUBLIC_SUBGRAPH_API_KEY: string; + NEXT_PUBLIC_IS_CYPRESS_ENABLED: string; } } diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index b96260896a..b5b7784ae7 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "noEmit": true, "types": ["cypress", "cypress-wait-until"], + "sourceMap": false, }, "include": [ "../node_modules/cypress", diff --git a/src/libs/web3-data-provider/Web3Provider.tsx b/src/libs/web3-data-provider/Web3Provider.tsx index 9298c47b54..f8b4420f80 100644 --- a/src/libs/web3-data-provider/Web3Provider.tsx +++ b/src/libs/web3-data-provider/Web3Provider.tsx @@ -5,12 +5,12 @@ import { BigNumber, PopulatedTransaction } from 'ethers'; import React, { ReactElement, useEffect, useState } from 'react'; import { useRootStore } from 'src/store/root'; import { hexToAscii } from 'src/utils/utils'; +import { UserRejectedRequestError } from 'viem'; +import { useAccount, useConnect, useConnectorClient, useSwitchChain, useWatchAsset } from 'wagmi'; // import { isLedgerDappBrowserProvider } from 'web3-ledgerhq-frame-connector'; import { Web3Context } from '../hooks/useWeb3Context'; -import { useAccount, useClient, useConnectorClient, useSwitchChain, useWatchAsset } from 'wagmi'; -import { clientToSigner, useEthersProvider, useEthersSigner } from './adapters/EthersAdapter'; -import { UserRejectedRequestError } from 'viem'; +import { clientToSigner, useEthersProvider } from './adapters/EthersAdapter'; export type ERC20TokenType = { address: string; @@ -43,17 +43,15 @@ interface ConnectWalletOpts { address?: string | null; } +let didConnect = false; + export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ children }) => { // const { chainId: chainId, connector, provider, isActivating, isActive } = useWeb3React(); const { switchChainAsync } = useSwitchChain(); const { watchAssetAsync } = useWatchAsset(); - const { chainId, address, isConnected, isConnecting, connector } = useAccount(); - const client = useClient({ chainId }); + const { chainId, address, isConnected, isConnecting } = useAccount(); const { data: connectorClient } = useConnectorClient({ chainId }); - - console.log(connector?.getChainId()); - console.log(client); - console.log(connectorClient); + const { connect, connectors } = useConnect(); // const { sendTransaction } = useSendTransaction(); const provider = useEthersProvider({ chainId }); @@ -66,6 +64,19 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil const setAccountLoading = useRootStore((store) => store.setAccountLoading); const setWalletType = useRootStore((store) => store.setWalletType); + useEffect(() => { + // If running cypress tests, then we try to auto connect on app load + // so it doesn't have to be driven through the UI. + const isCypressEnabled = process.env.NEXT_PUBLIC_IS_CYPRESS_ENABLED === 'true'; + if (!isCypressEnabled || didConnect) { + return; + } + + const injected = connectors[0]; + connect({ connector: injected }); + didConnect = true; + }); + // const disconnectWallet = useCallback(async () => { // localStorage.removeItem('walletProvider'); // localStorage.removeItem('readOnlyModeAddress'); diff --git a/src/ui-config/wagmiConfig.ts b/src/ui-config/wagmiConfig.ts index 38f1b408af..49023d9aa8 100644 --- a/src/ui-config/wagmiConfig.ts +++ b/src/ui-config/wagmiConfig.ts @@ -1,6 +1,14 @@ import { getDefaultConfig } from 'connectkit'; -import { ENABLE_TESTNET } from 'src/utils/marketsAndNetworksConfig'; -import { createConfig, CreateConfigParameters } from 'wagmi'; +import { + ENABLE_TESTNET, + FORK_BASE_CHAIN_ID, + FORK_CHAIN_ID, + FORK_ENABLED, + FORK_RPC_URL, + networkConfigs, +} from 'src/utils/marketsAndNetworksConfig'; +import { type Chain } from 'viem'; +import { createConfig, CreateConfigParameters, injected } from 'wagmi'; import { arbitrum, arbitrumSepolia, @@ -30,7 +38,7 @@ const testnetChains: CreateConfigParameters['chains'] = [ scrollSepolia, ]; -const prodChains: CreateConfigParameters['chains'] = [ +let prodChains: CreateConfigParameters['chains'] = [ mainnet, base, arbitrum, @@ -44,13 +52,49 @@ const prodChains: CreateConfigParameters['chains'] = [ zksync, ]; -export const wagmiConfig = createConfig( +const { name, baseAssetDecimals, baseAssetSymbol } = networkConfigs[FORK_BASE_CHAIN_ID]; + +const forkChain: Chain = { + id: FORK_CHAIN_ID, + name, + nativeCurrency: { + decimals: baseAssetDecimals, + name: baseAssetSymbol, + symbol: baseAssetSymbol, + }, + rpcUrls: { + default: { http: [FORK_RPC_URL] }, + }, + testnet: false, +}; + +if (FORK_ENABLED) { + prodChains = [forkChain, ...prodChains]; +} + +const defaultConfig = { + walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID as string, + appName: 'Aave', + appDescription: 'Non-custodial liquidity protocol', + appUrl: 'https://app.aave.com', + appIcon: 'https://avatars.githubusercontent.com/u/47617460?s=200&v=4', +}; + +const cypressConfig = createConfig( + getDefaultConfig({ + chains: [forkChain], + connectors: [injected()], + ...defaultConfig, + }) +); + +const prodConfig = createConfig( getDefaultConfig({ chains: ENABLE_TESTNET ? testnetChains : prodChains, - walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID as string, - appName: 'Aave', - appDescription: 'Non-custodial liquidity protocol', - appUrl: 'https://app.aave.com', - appIcon: 'https://avatars.githubusercontent.com/u/47617460?s=200&v=4', + ...defaultConfig, }) ); + +const isCypressEnabled = process.env.NEXT_PUBLIC_IS_CYPRESS_ENABLED === 'true'; + +export const wagmiConfig = isCypressEnabled ? cypressConfig : prodConfig; diff --git a/src/utils/marketsAndNetworksConfig.ts b/src/utils/marketsAndNetworksConfig.ts index c61d41df6b..1e6efa2434 100644 --- a/src/utils/marketsAndNetworksConfig.ts +++ b/src/utils/marketsAndNetworksConfig.ts @@ -30,14 +30,14 @@ export const FORK_ENABLED = !!process.env.NEXT_PUBLIC_FORK_URL_RPC || global?.window?.localStorage.getItem('forkEnabled') === 'true'; // specifies which network was forked -const FORK_BASE_CHAIN_ID = +export const FORK_BASE_CHAIN_ID = Number(process.env.NEXT_PUBLIC_FORK_BASE_CHAIN_ID) || Number(global?.window?.localStorage.getItem('forkBaseChainId') || 1); // specifies on which chainId the fork is running -const FORK_CHAIN_ID = +export const FORK_CHAIN_ID = Number(process.env.NEXT_PUBLIC_FORK_CHAIN_ID) || Number(global?.window?.localStorage.getItem('forkNetworkId') || 3030); -const FORK_RPC_URL = +export const FORK_RPC_URL = process.env.NEXT_PUBLIC_FORK_URL_RPC || global?.window?.localStorage.getItem('forkRPCUrl') || 'http://127.0.0.1:8545'; From 9a9bba325a01a2563df836cca35f1df04c65b6f6 Mon Sep 17 00:00:00 2001 From: Mark Hinschberger Date: Thu, 12 Dec 2024 17:37:55 +0000 Subject: [PATCH 2/4] fix: falsy loading state --- src/components/WalletConnection/ReadOnlyModal.tsx | 10 +++++----- src/layouts/SettingsMenu.tsx | 2 +- src/libs/web3-data-provider/Web3Provider.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/WalletConnection/ReadOnlyModal.tsx b/src/components/WalletConnection/ReadOnlyModal.tsx index 394af88939..28325b6492 100644 --- a/src/components/WalletConnection/ReadOnlyModal.tsx +++ b/src/components/WalletConnection/ReadOnlyModal.tsx @@ -59,7 +59,7 @@ export const ReadOnlyModal = () => { useEffect(() => { const readOnlyAddress = localStorage.getItem('readOnlyModeAddress'); if (readOnlyAddress) { - connect({ connector: mock({ accounts: [ readOnlyAddress as `0x${string}` ] }) }); + connect({ connector: mock({ accounts: [readOnlyAddress as `0x${string}`] }) }); } }, [connect]); @@ -81,7 +81,7 @@ export const ReadOnlyModal = () => { if (validAddressError) setValidAddressError(false); if (utils.isAddress(inputMockWalletAddress)) { localStorage.setItem('readOnlyModeAddress', inputMockWalletAddress); - connect({ connector: mock({ accounts: [ inputMockWalletAddress as `0x${string}` ] }) }); + connect({ connector: mock({ accounts: [inputMockWalletAddress as `0x${string}`] }) }); close(); } else { // Check if address could be valid ENS before trying to resolve @@ -90,7 +90,7 @@ export const ReadOnlyModal = () => { const resolvedAddress = await mainnetProvider.resolveName(inputMockWalletAddress); if (resolvedAddress && utils.isAddress(resolvedAddress)) { localStorage.setItem('readOnlyModeAddress', inputMockWalletAddress); - connect({ connector: mock({ accounts: [ inputMockWalletAddress as `0x${string}` ] }) }); + connect({ connector: mock({ accounts: [inputMockWalletAddress as `0x${string}`] }) }); close(); } else { setValidAddressError(true); @@ -109,11 +109,11 @@ export const ReadOnlyModal = () => { return ( - + {error && {handleBlocking()}} - Track wallet balance in read-only mode + Watch a wallet balance in read-only mode diff --git a/src/layouts/SettingsMenu.tsx b/src/layouts/SettingsMenu.tsx index 41cc13bed9..151c16d824 100644 --- a/src/layouts/SettingsMenu.tsx +++ b/src/layouts/SettingsMenu.tsx @@ -99,7 +99,7 @@ export function SettingsMenu() { - Read mode + Watch wallet diff --git a/src/libs/web3-data-provider/Web3Provider.tsx b/src/libs/web3-data-provider/Web3Provider.tsx index 9298c47b54..2a1d802ecc 100644 --- a/src/libs/web3-data-provider/Web3Provider.tsx +++ b/src/libs/web3-data-provider/Web3Provider.tsx @@ -47,7 +47,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil // const { chainId: chainId, connector, provider, isActivating, isActive } = useWeb3React(); const { switchChainAsync } = useSwitchChain(); const { watchAssetAsync } = useWatchAsset(); - const { chainId, address, isConnected, isConnecting, connector } = useAccount(); + const { chainId, address, isConnected, connector } = useAccount(); const client = useClient({ chainId }); const { data: connectorClient } = useConnectorClient({ chainId }); @@ -252,7 +252,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil value={{ web3ProviderData: { connected: isConnected, - loading: isConnecting, + loading: false, chainId: chainId || 1, switchNetwork, getTxError, From 815ae2fe54cfac38086932aa95f500092652b7df Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Thu, 12 Dec 2024 13:40:50 -0600 Subject: [PATCH 3/4] feat: cleanup --- pages/_app.page.tsx | 10 +- pages/index.page.tsx | 4 +- pages/v3-migration.page.tsx | 3 +- src/components/AddressBlocked.tsx | 6 +- src/components/ConnectWalletPaper.tsx | 15 +- src/components/UserDisplay.tsx | 7 +- .../WalletConnection/ConnectWalletButton.tsx | 3 +- .../WalletConnection/ReadOnlyModal.tsx | 8 +- .../WalletConnection/WalletModal.tsx | 14 - .../WalletConnection/WalletSelector.tsx | 258 ------------- src/hooks/useWalletModal.tsx | 9 - src/layouts/AppHeader.tsx | 6 - src/layouts/WalletWidget.tsx | 362 ------------------ src/libs/web3-data-provider/WalletOptions.ts | 72 ---- src/libs/web3-data-provider/Web3Provider.tsx | 103 +---- .../adapters/EthersAdapter.ts | 4 +- src/modules/bridge/BridgeWrapper.tsx | 3 +- src/modules/faucet/FaucetAssetsList.tsx | 1 - src/modules/history/HistoryWrapper.tsx | 3 +- src/store/walletSlice.ts | 10 +- 20 files changed, 43 insertions(+), 858 deletions(-) delete mode 100644 src/components/WalletConnection/WalletModal.tsx delete mode 100644 src/components/WalletConnection/WalletSelector.tsx delete mode 100644 src/hooks/useWalletModal.tsx delete mode 100644 src/layouts/WalletWidget.tsx delete mode 100644 src/libs/web3-data-provider/WalletOptions.ts diff --git a/pages/_app.page.tsx b/pages/_app.page.tsx index 5c7ffa5a97..9059f3f753 100644 --- a/pages/_app.page.tsx +++ b/pages/_app.page.tsx @@ -96,7 +96,10 @@ interface MyAppProps extends AppProps { export default function MyApp(props: MyAppProps) { const { Component, emotionCache = clientSideEmotionCache, pageProps } = props; const getLayout = Component.getLayout ?? ((page: ReactNode) => page); - const initializeMixpanel = useRootStore((store) => store.initializeMixpanel); + const [initializeMixpanel, setWalletType] = useRootStore((store) => [ + store.initializeMixpanel, + store.setWalletType, + ]); const [queryClient] = useState( () => new QueryClient({ @@ -137,7 +140,10 @@ export default function MyApp(props: MyAppProps) { - + setWalletType(connectorId)} + > diff --git a/pages/index.page.tsx b/pages/index.page.tsx index f934df8fbd..1b1c8e2d34 100644 --- a/pages/index.page.tsx +++ b/pages/index.page.tsx @@ -14,7 +14,7 @@ import { DashboardContentWrapper } from '../src/modules/dashboard/DashboardConte import { DashboardTopPanel } from '../src/modules/dashboard/DashboardTopPanel'; export default function Home() { - const { currentAccount, loading: web3Loading } = useWeb3Context(); + const { currentAccount } = useWeb3Context(); const { currentMarket } = useProtocolDataContext(); const trackEvent = useRootStore((store) => store.trackEvent); @@ -63,7 +63,7 @@ export default function Home() { {currentAccount ? ( ) : ( - + )} diff --git a/pages/v3-migration.page.tsx b/pages/v3-migration.page.tsx index e0ecce54ab..01a3bec7a5 100644 --- a/pages/v3-migration.page.tsx +++ b/pages/v3-migration.page.tsx @@ -51,7 +51,7 @@ const selectableMarkets = [ ]; export default function V3Migration() { - const { currentAccount, loading: web3Loading } = useWeb3Context(); + const { currentAccount } = useWeb3Context(); const router = useRouter(); const [fromMarketData, setFromMarketData] = useState(() => { if (router.query.market) { @@ -255,7 +255,6 @@ export default function V3Migration() { ) : ( Please connect your wallet to see migration tool.} /> )} diff --git a/src/components/AddressBlocked.tsx b/src/components/AddressBlocked.tsx index c5d604bd1b..305cacc7a5 100644 --- a/src/components/AddressBlocked.tsx +++ b/src/components/AddressBlocked.tsx @@ -3,18 +3,20 @@ import { useAddressAllowed } from 'src/hooks/useAddressAllowed'; import { MainLayout } from 'src/layouts/MainLayout'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import { ENABLE_TESTNET } from 'src/utils/marketsAndNetworksConfig'; +import { useDisconnect } from 'wagmi'; import { AddressBlockedModal } from './AddressBlockedModal'; export const AddressBlocked = ({ children }: { children: ReactNode }) => { - const { currentAccount, disconnectWallet, readOnlyMode, loading } = useWeb3Context(); + const { currentAccount, readOnlyMode, loading } = useWeb3Context(); + const { disconnect } = useDisconnect(); const screenAddress = readOnlyMode || loading || ENABLE_TESTNET ? '' : currentAccount; const { isAllowed } = useAddressAllowed(screenAddress); if (!isAllowed) { return ( - ; + disconnect()} />; ); } diff --git a/src/components/ConnectWalletPaper.tsx b/src/components/ConnectWalletPaper.tsx index 85422e3325..d5f62de91a 100644 --- a/src/components/ConnectWalletPaper.tsx +++ b/src/components/ConnectWalletPaper.tsx @@ -1,22 +1,21 @@ import { Trans } from '@lingui/macro'; import { Box, CircularProgress, Paper, PaperProps, Typography } from '@mui/material'; +import { useModal } from 'connectkit'; import { ReactNode } from 'react'; +import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import LandingGhost from '/public/resting-gho-hat-purple.svg'; import { ConnectWalletButton } from './WalletConnection/ConnectWalletButton'; interface ConnectWalletPaperProps extends PaperProps { - loading?: boolean; description?: ReactNode; } -export const ConnectWalletPaper = ({ - loading, - description, - sx, - ...rest -}: ConnectWalletPaperProps) => { +export const ConnectWalletPaper = ({ description, sx, ...rest }: ConnectWalletPaperProps) => { + const { open } = useModal(); + const { loading } = useWeb3Context(); + return ( <> - {loading ? ( + {open || loading ? ( ) : ( <> diff --git a/src/components/UserDisplay.tsx b/src/components/UserDisplay.tsx index 16c9b77a05..42ffe720dc 100644 --- a/src/components/UserDisplay.tsx +++ b/src/components/UserDisplay.tsx @@ -4,6 +4,7 @@ import { useMemo } from 'react'; import useGetEns from 'src/libs/hooks/use-get-ens'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import { useRootStore } from 'src/store/root'; +import { useAccount } from 'wagmi'; import { shallow } from 'zustand/shallow'; import { Avatar, AvatarProps } from './Avatar'; @@ -27,12 +28,12 @@ export const UserDisplay: React.FC = ({ withLink, funnel, }) => { - const { account, defaultDomain, domainsLoading, accountLoading } = useRootStore( + const { isConnecting } = useAccount(); + const { account, defaultDomain, domainsLoading } = useRootStore( (state) => ({ account: state.account, defaultDomain: state.defaultDomain, domainsLoading: state.domainsLoading, - accountLoading: state.accountLoading, }), shallow ); @@ -41,7 +42,7 @@ export const UserDisplay: React.FC = ({ () => (account ? blo(account as `0x${string}`) : undefined), [account] ); - const loading = domainsLoading || accountLoading; + const loading = domainsLoading || isConnecting; return ( diff --git a/src/components/WalletConnection/ConnectWalletButton.tsx b/src/components/WalletConnection/ConnectWalletButton.tsx index e5cf129a8b..0d7c3694be 100644 --- a/src/components/WalletConnection/ConnectWalletButton.tsx +++ b/src/components/WalletConnection/ConnectWalletButton.tsx @@ -1,7 +1,6 @@ import { Trans } from '@lingui/macro'; import { Button } from '@mui/material'; import { ConnectKitButton } from 'connectkit'; -import { useWalletModalContext } from 'src/hooks/useWalletModal'; import { useRootStore } from 'src/store/root'; import { AUTH } from 'src/utils/mixPanelEvents'; @@ -10,6 +9,7 @@ import { UserDisplay } from '../UserDisplay'; export interface ConnectWalletProps { funnel?: string; + onIsConnecting?: (isConnecting: boolean) => void; } export const ConnectWalletButton: React.FC = ({ funnel }) => { @@ -24,6 +24,7 @@ export const ConnectWalletButton: React.FC = ({ funnel }) => variant={isConnected ? 'surface' : 'gradient'} onClick={() => { show && show(); + trackEvent(AUTH.CONNECT_WALLET, { funnel: funnel }); }} > {isConnected ? ( diff --git a/src/components/WalletConnection/ReadOnlyModal.tsx b/src/components/WalletConnection/ReadOnlyModal.tsx index 28325b6492..f7ba0f6bdd 100644 --- a/src/components/WalletConnection/ReadOnlyModal.tsx +++ b/src/components/WalletConnection/ReadOnlyModal.tsx @@ -5,20 +5,14 @@ import { useEffect, useState } from 'react'; import { ReadOnlyModeTooltip } from 'src/components/infoTooltips/ReadOnlyModeTooltip'; import { ModalType, useModalContext } from 'src/hooks/useModal'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; -import { WalletType } from 'src/libs/web3-data-provider/WalletOptions'; import { useRootStore } from 'src/store/root'; import { getENSProvider } from 'src/utils/marketsAndNetworksConfig'; import { AUTH } from 'src/utils/mixPanelEvents'; +import { mock, useConnect } from 'wagmi'; import { BasicModal } from '../primitives/BasicModal'; import { Warning } from '../primitives/Warning'; import { TxModalTitle } from '../transactions/FlowCommons/TxModalTitle'; -import { mock, useConnect } from 'wagmi'; - -export type WalletRowProps = { - walletName: string; - walletType: WalletType; -}; export enum ErrorType { UNSUPORTED_CHAIN, diff --git a/src/components/WalletConnection/WalletModal.tsx b/src/components/WalletConnection/WalletModal.tsx deleted file mode 100644 index 572b68e7c2..0000000000 --- a/src/components/WalletConnection/WalletModal.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { useWalletModalContext } from 'src/hooks/useWalletModal'; - -import { BasicModal } from '../primitives/BasicModal'; -import { WalletSelector } from './WalletSelector'; - -export const WalletModal = () => { - const { isWalletModalOpen, setWalletModalOpen } = useWalletModalContext(); - - return ( - - - - ); -}; diff --git a/src/components/WalletConnection/WalletSelector.tsx b/src/components/WalletConnection/WalletSelector.tsx deleted file mode 100644 index b85480f2f3..0000000000 --- a/src/components/WalletConnection/WalletSelector.tsx +++ /dev/null @@ -1,258 +0,0 @@ -import { Trans } from '@lingui/macro'; -import { Box, Button, InputBase, Link, Typography, useMediaQuery, useTheme } from '@mui/material'; -import { NoMetaMaskError } from '@web3-react/metamask'; -import { utils } from 'ethers'; -import { useState } from 'react'; -import { ReadOnlyModeTooltip } from 'src/components/infoTooltips/ReadOnlyModeTooltip'; -import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; -import { UserRejectedRequestError } from 'src/libs/web3-data-provider/connectors/WalletConnectConnector'; -import { WalletType } from 'src/libs/web3-data-provider/WalletOptions'; -import { useRootStore } from 'src/store/root'; -import { getENSProvider } from 'src/utils/marketsAndNetworksConfig'; -import { AUTH } from 'src/utils/mixPanelEvents'; - -import { Warning } from '../primitives/Warning'; -import { TxModalTitle } from '../transactions/FlowCommons/TxModalTitle'; - -export type WalletRowProps = { - walletName: string; - walletType: WalletType; -}; -const WalletRow = ({ walletName, walletType }: WalletRowProps) => { - const { connectWallet, loading } = useWeb3Context(); - const trackEvent = useRootStore((store) => store.trackEvent); - - const getWalletIcon = (walletType: WalletType) => { - switch (walletType) { - case WalletType.INJECTED: - return ( - {`browser - ); - case WalletType.WALLET_CONNECT: - return ( - {`browser - ); - case WalletType.COINBASE_WALLET: - return ( - {`browser - ); - // case WalletType.TORUS: - // return ( - // {`browser - // ); - // case WalletType.FRAME: - // return ( - // {`browser - // ); - default: - return null; - } - }; - - const connectWalletClick = () => { - trackEvent(AUTH.CONNECT_WALLET, { walletType: walletType, walletName: walletName }); - connectWallet(walletType); - }; - return ( - - ); -}; - -export enum ErrorType { - UNSUPORTED_CHAIN, - USER_REJECTED_REQUEST, - UNDETERMINED_ERROR, - NO_WALLET_DETECTED, -} - -export const WalletSelector = () => { - const { error, connectWallet } = useWeb3Context(); - const [inputMockWalletAddress, setInputMockWalletAddress] = useState(''); - const [validAddressError, setValidAddressError] = useState(false); - const { breakpoints } = useTheme(); - const sm = useMediaQuery(breakpoints.down('sm')); - const mainnetProvider = getENSProvider(); - const trackEvent = useRootStore((store) => store.trackEvent); - - let blockingError: ErrorType | undefined = undefined; - if (error) { - if (error instanceof UserRejectedRequestError) { - blockingError = ErrorType.UNSUPORTED_CHAIN; - } else if (error instanceof UserRejectedRequestError) { - blockingError = ErrorType.USER_REJECTED_REQUEST; - } else if (error instanceof NoMetaMaskError) { - blockingError = ErrorType.NO_WALLET_DETECTED; - } else { - blockingError = ErrorType.UNDETERMINED_ERROR; - } - // TODO: add other errors - } - - const handleBlocking = () => { - switch (blockingError) { - case ErrorType.UNSUPORTED_CHAIN: - return Network not supported for this wallet; - case ErrorType.USER_REJECTED_REQUEST: - return Rejected connection request; - case ErrorType.NO_WALLET_DETECTED: - return Wallet not detected. Connect or install wallet and retry; - default: - console.log('Uncatched error: ', error); - return Error connecting. Try refreshing the page.; - } - }; - - const handleReadAddress = async (inputMockWalletAddress: string): Promise => { - if (validAddressError) setValidAddressError(false); - if (utils.isAddress(inputMockWalletAddress)) { - console.log('connect the read only wallethere'); - connectWallet(WalletType.READ_ONLY_MODE, { address: inputMockWalletAddress }); - } else { - // Check if address could be valid ENS before trying to resolve - if (inputMockWalletAddress.slice(-4) === '.eth') { - // Attempt to resolve ENS name and use resolved address if valid - const resolvedAddress = await mainnetProvider.resolveName(inputMockWalletAddress); - if (resolvedAddress && utils.isAddress(resolvedAddress)) { - connectWallet(WalletType.READ_ONLY_MODE, { address: resolvedAddress }); - } else { - setValidAddressError(true); - } - } else { - setValidAddressError(true); - } - } - }; - - const handleSubmit = (event: React.FormEvent): void => { - event.preventDefault(); - handleReadAddress(inputMockWalletAddress); - }; - - return ( - - - {error && {handleBlocking()}} - - - - {/* */} - - - Track wallet balance in read-only mode - - - -
- ({ - py: 1, - px: 3, - border: `1px solid ${theme.palette.divider}`, - borderRadius: '6px', - mb: 1, - overflow: 'show', - fontSize: sm ? '16px' : '14px', - })} - placeholder="Enter ethereum address or ENS name" - fullWidth - value={inputMockWalletAddress} - onChange={(e) => setInputMockWalletAddress(e.target.value)} - inputProps={{ - 'aria-label': 'read-only mode address', - }} - /> - - - {validAddressError && ( - - Please enter a valid wallet address. - - )} - - - Need help connecting a wallet?{' '} - - Read our FAQ - - - - - - Wallets are provided by External Providers and by selecting you agree to Terms of those - Providers. Your access to the wallet might be reliant on the External Provider being - operational. - - -
- ); -}; diff --git a/src/hooks/useWalletModal.tsx b/src/hooks/useWalletModal.tsx deleted file mode 100644 index e98c0fb147..0000000000 --- a/src/hooks/useWalletModal.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { useRootStore } from 'src/store/root'; - -// TODO: remove this -// currently this reexport is a workaround so i don't have to alter and potentially create conflicts in 200 files -export const useWalletModalContext = () => - useRootStore((state) => ({ - isWalletModalOpen: state.isWalletModalOpen, - setWalletModalOpen: state.setWalletModalOpen, - })); diff --git a/src/layouts/AppHeader.tsx b/src/layouts/AppHeader.tsx index fbf7f6ebdb..ff758893f4 100644 --- a/src/layouts/AppHeader.tsx +++ b/src/layouts/AppHeader.tsx @@ -31,7 +31,6 @@ import { uiConfig } from '../uiConfig'; import { NavItems } from './components/NavItems'; import { MobileMenu } from './MobileMenu'; import { SettingsMenu } from './SettingsMenu'; -import WalletWidget from './WalletWidget'; interface Props { children: React.ReactElement; @@ -118,11 +117,6 @@ export function AppHeader() { const headerHeight = 48; - const toggleWalletWigit = (state: boolean) => { - if (md) setMobileDrawerOpen(state); - setWalletWidgetOpen(state); - }; - const toggleMobileMenu = (state: boolean) => { if (md) setMobileDrawerOpen(state); setMobileMenuOpen(state); diff --git a/src/layouts/WalletWidget.tsx b/src/layouts/WalletWidget.tsx deleted file mode 100644 index 5e562e89eb..0000000000 --- a/src/layouts/WalletWidget.tsx +++ /dev/null @@ -1,362 +0,0 @@ -import { DuplicateIcon } from '@heroicons/react/outline'; -import { ChevronDownIcon, ChevronUpIcon, ExternalLinkIcon } from '@heroicons/react/solid'; -import { Trans } from '@lingui/macro'; -import { - Box, - Button, - Divider, - List, - ListItem, - ListItemIcon, - ListItemText, - Menu, - MenuItem, - MenuList, - Skeleton, - SvgIcon, - Typography, - useMediaQuery, - useTheme, -} from '@mui/material'; -import React, { useState } from 'react'; -import { AvatarSize } from 'src/components/Avatar'; -import { CompactMode } from 'src/components/CompactableTypography'; -import { Warning } from 'src/components/primitives/Warning'; -import { UserDisplay } from 'src/components/UserDisplay'; -import { WalletModal } from 'src/components/WalletConnection/WalletModal'; -import { useWalletModalContext } from 'src/hooks/useWalletModal'; -import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; -import { useRootStore } from 'src/store/root'; -import { AUTH, GENERAL } from 'src/utils/mixPanelEvents'; - -import { Link } from '../components/primitives/Link'; -import { ENABLE_TESTNET, getNetworkConfig, STAGING_ENV } from '../utils/marketsAndNetworksConfig'; -import { DrawerWrapper } from './components/DrawerWrapper'; -import { MobileCloseButton } from './components/MobileCloseButton'; - -interface WalletWidgetProps { - open: boolean; - setOpen: (value: boolean) => void; - headerHeight: number; -} - -export default function WalletWidget({ open, setOpen, headerHeight }: WalletWidgetProps) { - const { currentAccount, connected, chainId, loading, readOnlyModeAddress } = useWeb3Context(); - - const { setWalletModalOpen } = useWalletModalContext(); - - const { breakpoints, palette } = useTheme(); - const xsm = useMediaQuery(breakpoints.down('xsm')); - const md = useMediaQuery(breakpoints.down('md')); - const trackEvent = useRootStore((store) => store.trackEvent); - - const [anchorEl, setAnchorEl] = useState(null); - - const networkConfig = getNetworkConfig(chainId); - let networkColor = ''; - if (networkConfig?.isFork) { - networkColor = '#ff4a8d'; - } else if (networkConfig?.isTestnet) { - networkColor = '#7157ff'; - } else { - networkColor = '#65c970'; - } - - const handleClose = () => { - setOpen(false); - }; - - const handleClick = (event: React.MouseEvent) => { - if (!connected) { - trackEvent(GENERAL.OPEN_MODAL, { modal: 'Connect Waller' }); - setWalletModalOpen(true); - } else { - setOpen(true); - setAnchorEl(event.currentTarget); - } - }; - - const handleDisconnect = () => { - if (connected) { - disconnectWallet(); - trackEvent(AUTH.DISCONNECT_WALLET); - handleClose(); - } - }; - - const handleCopy = async () => { - navigator.clipboard.writeText(currentAccount); - trackEvent(AUTH.COPY_ADDRESS); - handleClose(); - }; - - const handleSwitchWallet = (): void => { - setWalletModalOpen(true); - trackEvent(AUTH.SWITCH_WALLET); - handleClose(); - }; - - const handleViewOnExplorer = (): void => { - trackEvent(GENERAL.EXTERNAL_LINK, { Link: 'Etherscan for Wallet' }); - handleClose(); - }; - - const hideWalletAccountText = xsm && (ENABLE_TESTNET || STAGING_ENV || readOnlyModeAddress); - - const Content = ({ component = ListItem }: { component?: typeof MenuItem | typeof ListItem }) => ( - <> - - Account - - - - - - {readOnlyModeAddress && ( - - Read-only mode. - - )} - - - {!md && ( - - - - - )} - - - - - - - Network - - - - - - {networkConfig.name} - - - - - - - - - - - - - - Copy address - - - - {networkConfig?.explorerLinkBuilder && ( - - - - - - - - - View on Explorer - - - - )} - {md && ( - <> - - - - - - - )} - - ); - - return ( - <> - {md && connected && open ? ( - - ) : loading ? ( - - ) : ( - - )} - - {md ? ( - - - - - - ) : ( - - - - - - )} - - {/* */} - - ); -} diff --git a/src/libs/web3-data-provider/WalletOptions.ts b/src/libs/web3-data-provider/WalletOptions.ts deleted file mode 100644 index 26d1ef5566..0000000000 --- a/src/libs/web3-data-provider/WalletOptions.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Connector } from '@web3-react/types'; - -// import { LedgerHQFrameConnector } from 'web3-ledgerhq-frame-connector'; -import { coinbaseWallet } from './connectors/CoinbaseConnector'; -import { gnosisSafe } from './connectors/GnosisSafeConnector'; -import { metaMask } from './connectors/MetamaskConnector'; -import { readOnly } from './connectors/ReadOnlyConnector'; -import { walletConnect } from './connectors/WalletConnectConnector'; - -export enum WalletType { - INJECTED = 'injected', - WALLET_CONNECT = 'wallet_connect', - WALLET_LINK = 'wallet_link', - TORUS = 'torus', - FRAME = 'frame', - GNOSIS = 'gnosis', - LEDGER = 'ledger', - READ_ONLY_MODE = 'read_only_mode', - COINBASE_WALLET = 'coinbase_wallet', -} - -// const APP_NAME = 'Aave'; -// const APP_LOGO_URL = 'https://aave.com/favicon.ico'; - -export const getWallet = (wallet: WalletType): Connector => { - console.log('wallet', wallet); - switch (wallet) { - case WalletType.READ_ONLY_MODE: - return readOnly; - // case WalletType.LEDGER: - // return new LedgerHQFrameConnector({}); - case WalletType.INJECTED: - return metaMask; - case WalletType.COINBASE_WALLET: - return coinbaseWallet; - // case WalletType.WALLET_LINK: - // const networkConfig = getNetworkConfig(chainId); - // return new WalletLinkConnector({ - // appName: APP_NAME, - // appLogoUrl: APP_LOGO_URL, - // url: networkConfig.privateJsonRPCUrl || networkConfig.publicJsonRPCUrl[0], - // }); - case WalletType.WALLET_CONNECT: - return walletConnect; - case WalletType.GNOSIS: - if (window) { - return gnosisSafe; - } - throw new Error('Safe app not working'); - // case WalletType.TORUS: - // return new TorusConnector({ - // chainId, - // initOptions: { - // network: { - // host: chainId === ChainId.polygon ? 'matic' : chainId, - // }, - // showTorusButton: false, - // enableLogging: false, - // enabledVerifiers: false, - // }, - // }); - // case WalletType.FRAME: { - // if (chainId !== ChainId.mainnet) { - // throw new UnsupportedChainIdError(chainId, [1]); - // } - // return new FrameConnector({ supportedChainIds: [1] }); - // } - default: { - throw new Error(`unsupported wallet`); - } - } -}; diff --git a/src/libs/web3-data-provider/Web3Provider.tsx b/src/libs/web3-data-provider/Web3Provider.tsx index 5bf6520ed3..ea0cd8a6da 100644 --- a/src/libs/web3-data-provider/Web3Provider.tsx +++ b/src/libs/web3-data-provider/Web3Provider.tsx @@ -8,7 +8,6 @@ import { hexToAscii } from 'src/utils/utils'; import { UserRejectedRequestError } from 'viem'; import { useAccount, useConnect, useConnectorClient, useSwitchChain, useWatchAsset } from 'wagmi'; -// import { isLedgerDappBrowserProvider } from 'web3-ledgerhq-frame-connector'; import { Web3Context } from '../hooks/useWeb3Context'; import { clientToSigner, useEthersProvider } from './adapters/EthersAdapter'; @@ -38,31 +37,28 @@ export type Web3Data = { provider: JsonRpcProvider | undefined; }; -interface ConnectWalletOpts { - silently?: boolean; - address?: string | null; -} - let didConnect = false; export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ children }) => { - // const { chainId: chainId, connector, provider, isActivating, isActive } = useWeb3React(); const { switchChainAsync } = useSwitchChain(); const { watchAssetAsync } = useWatchAsset(); - const { chainId, address, isConnected, isConnecting } = useAccount(); + const { chainId, address, isConnected, isConnecting, isReconnecting } = useAccount(); const { data: connectorClient } = useConnectorClient({ chainId }); const { connect, connectors } = useConnect(); + console.log('isConnected', isConnected); + console.log('isConnecting', isConnecting); + console.log('isReconnecting', isReconnecting); // const { sendTransaction } = useSendTransaction(); const provider = useEthersProvider({ chainId }); // const signer = useEthersSigner({ chainId }); const account = address; const [error, setError] = useState(); + console.log('TODO', setError); + const [switchNetworkError, setSwitchNetworkError] = useState(); const setAccount = useRootStore((store) => store.setAccount); - const setAccountLoading = useRootStore((store) => store.setAccountLoading); - const setWalletType = useRootStore((store) => store.setWalletType); useEffect(() => { // If running cypress tests, then we try to auto connect on app load @@ -77,91 +73,6 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil didConnect = true; }); - // const disconnectWallet = useCallback(async () => { - // localStorage.removeItem('walletProvider'); - // localStorage.removeItem('readOnlyModeAddress'); - // connector.resetState(); - // if (connector.deactivate) { - // connector.deactivate(); - // } - // setWalletType(undefined); - // setSwitchNetworkError(undefined); - // }, [connector, setWalletType]); - - // connect to the wallet specified by wallet type - // const connectWallet = useCallback( - // async (wallet: WalletType, opts?: ConnectWalletOpts) => { - // try { - // const connector: Connector = getWallet(wallet); - // if (wallet === WalletType.READ_ONLY_MODE && opts?.address) { - // localStorage.setItem('readOnlyModeAddress', opts.address); - // } else { - // localStorage.removeItem('readOnlyModeAddress'); - // } - // await connector.activate(opts?.address); - // setSwitchNetworkError(undefined); - // setWalletType(wallet); - // localStorage.setItem('walletProvider', wallet.toString()); - // } catch (e) { - // if (!opts?.silently) { - // console.log('error on activation', e); - // setError(e); - // } - // localStorage.removeItem('readOnlyModeAddress'); - // localStorage.removeItem('walletProvider'); - // setWalletType(undefined); - // } - // }, - // [setWalletType] - // ); - - // handle logic to eagerly connect to the injected ethereum provider, - // if it exists and has granted access already - - // useEffect(() => { - // const tryAppWalletsSilently = async () => { - // await connectWallet(WalletType.GNOSIS, { silently: true }) - // .catch(async () => { - // // eslint-disable-next-line @typescript-eslint/no-explicit-any - // const provider = (window as any)?.ethereum; - - // if (provider && provider.isCoinbaseBrowser) { - // await connectWallet(WalletType.INJECTED); - // } else { - // // TODO check other providers? family - // throw new Error('No provider detected'); - // } - // }) - // .catch(); - // }; - // try { - // const lastWalletProvider = localStorage.getItem('walletProvider'); - // const lastReadOnlyAddress = localStorage.getItem('readOnlyModeAddress'); - // if (lastWalletProvider) { - // connectWallet(lastWalletProvider as WalletType, { - // address: lastReadOnlyAddress, - // silently: true, - // }); - // } else { - // tryAppWalletsSilently(); - // } - // } catch { - // localStorage.removeItem('walletProvider'); - // localStorage.removeItem('readOnlyModeAddress'); - // } - // }, [connectWallet]); - /* - // if the connection worked, wait until we get confirmation of that to flip the flag - useEffect(() => { - if (!tried && active) { - setTried(true); - } - }, [tried, active]); - - */ - - // Tx methods - // TODO: we use from instead of currentAccount because of the mock wallet. // If we used current account then the tx could get executed const sendTx = async ( @@ -263,7 +174,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil value={{ web3ProviderData: { connected: isConnected, - loading: false, + loading: isConnecting && !isConnected, chainId: chainId || 1, switchNetwork, getTxError, diff --git a/src/libs/web3-data-provider/adapters/EthersAdapter.ts b/src/libs/web3-data-provider/adapters/EthersAdapter.ts index 55f5c9b366..5366c60b49 100644 --- a/src/libs/web3-data-provider/adapters/EthersAdapter.ts +++ b/src/libs/web3-data-provider/adapters/EthersAdapter.ts @@ -30,7 +30,9 @@ export function useEthersSigner({ chainId }: { chainId?: number } = {}) { } function getNetwork(chain: Chain) { - // if chain is undefined, it means that the client is connected to a chain that is not supported by the app + // If chain is undefined, it means that the client is connected to a chain that is not supported by the app. + // Just stub out the network so no errors are thrown, we show a message in the UI if they are not connected + // to the right network. const network = { chainId: chain?.id || -1, name: chain?.name || 'unknown', diff --git a/src/modules/bridge/BridgeWrapper.tsx b/src/modules/bridge/BridgeWrapper.tsx index 4c5a6cc0c4..65eb374f7a 100644 --- a/src/modules/bridge/BridgeWrapper.tsx +++ b/src/modules/bridge/BridgeWrapper.tsx @@ -20,7 +20,7 @@ import { } from './TransactionListItemLoader'; export function BridgeWrapper() { - const { currentAccount, loading: web3Loading } = useWeb3Context(); + const { currentAccount } = useWeb3Context(); const { openBridge } = useModalContext(); const theme = useTheme(); @@ -32,7 +32,6 @@ export function BridgeWrapper() { if (!currentAccount) { return ( Please connect your wallet to view transaction history.} /> ); diff --git a/src/modules/faucet/FaucetAssetsList.tsx b/src/modules/faucet/FaucetAssetsList.tsx index 7e2676cfc6..09092a15e0 100644 --- a/src/modules/faucet/FaucetAssetsList.tsx +++ b/src/modules/faucet/FaucetAssetsList.tsx @@ -49,7 +49,6 @@ export default function FaucetAssetsList() { if (!currentAccount || web3Loading) { return ( Please connect your wallet to get free testnet assets.} /> ); diff --git a/src/modules/history/HistoryWrapper.tsx b/src/modules/history/HistoryWrapper.tsx index c3c85332bf..1880a6a1b7 100644 --- a/src/modules/history/HistoryWrapper.tsx +++ b/src/modules/history/HistoryWrapper.tsx @@ -106,7 +106,7 @@ export const HistoryWrapper = () => { ); const theme = useTheme(); const downToMD = useMediaQuery(theme.breakpoints.down('md')); - const { currentAccount, loading: web3Loading } = useWeb3Context(); + const { currentAccount } = useWeb3Context(); const flatTxns = useMemo( () => transactions?.pages?.flatMap((page) => page) || [], @@ -141,7 +141,6 @@ export const HistoryWrapper = () => { if (!currentAccount) { return ( Please connect your wallet to view transaction history.} /> ); diff --git a/src/store/walletSlice.ts b/src/store/walletSlice.ts index 9943977334..b6a1d6c26e 100644 --- a/src/store/walletSlice.ts +++ b/src/store/walletSlice.ts @@ -1,4 +1,3 @@ -import { WalletType } from 'src/libs/web3-data-provider/WalletOptions'; import { StateCreator } from 'zustand'; import { RootStore } from './root'; @@ -10,11 +9,9 @@ export enum ApprovalMethod { export interface WalletSlice { account: string; - accountLoading: boolean; - walletType: WalletType | undefined; + walletType: string | undefined; setAccount: (account: string | undefined) => void; - setAccountLoading: (loading: boolean) => void; - setWalletType: (walletType: WalletType | undefined) => void; + setWalletType: (walletType: string | undefined) => void; isWalletModalOpen: boolean; setWalletModalOpen: (open: boolean) => void; walletApprovalMethodPreference: ApprovalMethod; @@ -48,9 +45,6 @@ export const createWalletSlice: StateCreator< const refresh = get().refreshWalletApprovalMethod; refresh(); }, - setAccountLoading(loading) { - set({ accountLoading: loading }); - }, isWalletModalOpen: false, setWalletModalOpen(open) { set({ isWalletModalOpen: open }); From a1f0e55c3025a3d794a0e14d5de4e98c9ed1f5ff Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Thu, 12 Dec 2024 13:58:37 -0600 Subject: [PATCH 4/4] fix: default import lint --- .eslintrc.js | 2 +- src/components/ConnectWalletPaper.tsx | 4 +--- src/components/HealthFactorNumber.tsx | 2 +- src/components/infoTooltips/PriceImpactTooltip.tsx | 2 +- src/components/transactions/Bridge/BridgeModalContent.tsx | 2 +- .../transactions/DebtSwitch/DebtSwitchModalContent.tsx | 2 +- .../transactions/Repay/CollateralRepayModalContent.tsx | 2 +- src/components/transactions/Repay/RepayModalContent.tsx | 2 +- src/components/transactions/Supply/SupplyModalContent.tsx | 2 +- src/components/transactions/Swap/SwapModalContent.tsx | 2 +- src/components/transactions/Withdraw/WithdrawError.tsx | 2 +- src/components/transactions/Withdraw/utils.ts | 2 +- src/hooks/pool/useUserYield.ts | 2 +- .../LiquidationRiskParametresModal/components/LTVContent.tsx | 2 +- .../dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx | 2 +- src/modules/governance/utils/formatProposal.ts | 2 +- src/modules/reserve-overview/ReserveActions.tsx | 2 +- src/store/v3MigrationSelectors.ts | 2 +- src/utils/getMaxAmountAvailableToBorrow.ts | 2 +- src/utils/getMaxAmountAvailableToSupply.ts | 2 +- src/utils/hfUtils.ts | 2 +- 21 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8d627eefc7..b8d3583656 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,7 +19,7 @@ module.exports = { 'import/first': 'error', 'import/newline-after-import': 'error', 'import/no-duplicates': 'error', - 'import/no-named-as-default': 'warn', + 'import/no-named-as-default': 'error', 'import/no-unresolved': 'warn', // disabled as with the static export Image does not make to much sense '@next/next/no-img-element': 'off', diff --git a/src/components/ConnectWalletPaper.tsx b/src/components/ConnectWalletPaper.tsx index d5f62de91a..3c408addb2 100644 --- a/src/components/ConnectWalletPaper.tsx +++ b/src/components/ConnectWalletPaper.tsx @@ -2,7 +2,6 @@ import { Trans } from '@lingui/macro'; import { Box, CircularProgress, Paper, PaperProps, Typography } from '@mui/material'; import { useModal } from 'connectkit'; import { ReactNode } from 'react'; -import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import LandingGhost from '/public/resting-gho-hat-purple.svg'; @@ -14,7 +13,6 @@ interface ConnectWalletPaperProps extends PaperProps { export const ConnectWalletPaper = ({ description, sx, ...rest }: ConnectWalletPaperProps) => { const { open } = useModal(); - const { loading } = useWeb3Context(); return ( <> - {open || loading ? ( + {open ? ( ) : ( <> diff --git a/src/components/HealthFactorNumber.tsx b/src/components/HealthFactorNumber.tsx index 8b4341ff28..2f7d615d91 100644 --- a/src/components/HealthFactorNumber.tsx +++ b/src/components/HealthFactorNumber.tsx @@ -2,7 +2,7 @@ import { valueToBigNumber } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; import { Box, Button, Typography, useTheme } from '@mui/material'; import { TypographyProps } from '@mui/material/Typography'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { FormattedNumber } from './primitives/FormattedNumber'; diff --git a/src/components/infoTooltips/PriceImpactTooltip.tsx b/src/components/infoTooltips/PriceImpactTooltip.tsx index 0cd3dd0d04..c64d9d008e 100644 --- a/src/components/infoTooltips/PriceImpactTooltip.tsx +++ b/src/components/infoTooltips/PriceImpactTooltip.tsx @@ -1,6 +1,6 @@ import { Trans } from '@lingui/macro'; import { Box, Skeleton } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { GENERAL } from 'src/utils/mixPanelEvents'; import { FormattedNumber } from '../primitives/FormattedNumber'; diff --git a/src/components/transactions/Bridge/BridgeModalContent.tsx b/src/components/transactions/Bridge/BridgeModalContent.tsx index 583d1d91d2..f161204bcb 100644 --- a/src/components/transactions/Bridge/BridgeModalContent.tsx +++ b/src/components/transactions/Bridge/BridgeModalContent.tsx @@ -10,7 +10,7 @@ import { SvgIcon, Typography, } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { constants } from 'ethers'; import { formatUnits } from 'ethers/lib/utils'; import React, { useEffect, useState } from 'react'; diff --git a/src/components/transactions/DebtSwitch/DebtSwitchModalContent.tsx b/src/components/transactions/DebtSwitch/DebtSwitchModalContent.tsx index a5251e4770..30bcbfc367 100644 --- a/src/components/transactions/DebtSwitch/DebtSwitchModalContent.tsx +++ b/src/components/transactions/DebtSwitch/DebtSwitchModalContent.tsx @@ -4,7 +4,7 @@ import { ArrowDownIcon } from '@heroicons/react/outline'; import { ArrowNarrowRightIcon } from '@heroicons/react/solid'; import { Trans } from '@lingui/macro'; import { Box, ListItemText, ListSubheader, Stack, SvgIcon, Typography } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React, { useRef, useState } from 'react'; import { GhoIncentivesCard } from 'src/components/incentives/GhoIncentivesCard'; import { PriceImpactTooltip } from 'src/components/infoTooltips/PriceImpactTooltip'; diff --git a/src/components/transactions/Repay/CollateralRepayModalContent.tsx b/src/components/transactions/Repay/CollateralRepayModalContent.tsx index 078463b62e..d7bc12e75d 100644 --- a/src/components/transactions/Repay/CollateralRepayModalContent.tsx +++ b/src/components/transactions/Repay/CollateralRepayModalContent.tsx @@ -3,7 +3,7 @@ import { valueToBigNumber } from '@aave/math-utils'; import { ArrowDownIcon } from '@heroicons/react/outline'; import { Trans } from '@lingui/macro'; import { Box, Stack, SvgIcon, Typography } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { useRef, useState } from 'react'; import { PriceImpactTooltip } from 'src/components/infoTooltips/PriceImpactTooltip'; import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; diff --git a/src/components/transactions/Repay/RepayModalContent.tsx b/src/components/transactions/Repay/RepayModalContent.tsx index f13de946eb..4cb2a41d02 100644 --- a/src/components/transactions/Repay/RepayModalContent.tsx +++ b/src/components/transactions/Repay/RepayModalContent.tsx @@ -7,7 +7,7 @@ import { } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; import Typography from '@mui/material/Typography'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React, { useEffect, useRef, useState } from 'react'; import { ExtendedFormattedUser, diff --git a/src/components/transactions/Supply/SupplyModalContent.tsx b/src/components/transactions/Supply/SupplyModalContent.tsx index 14a35e1ee1..15d7f89260 100644 --- a/src/components/transactions/Supply/SupplyModalContent.tsx +++ b/src/components/transactions/Supply/SupplyModalContent.tsx @@ -2,7 +2,7 @@ import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers'; import { USD_DECIMALS, valueToBigNumber } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; import { Skeleton, Stack, Typography } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React, { useEffect, useState } from 'react'; import { WrappedTokenTooltipContent } from 'src/components/infoTooltips/WrappedTokenToolTipContent'; import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; diff --git a/src/components/transactions/Swap/SwapModalContent.tsx b/src/components/transactions/Swap/SwapModalContent.tsx index fd61891576..d07acb097d 100644 --- a/src/components/transactions/Swap/SwapModalContent.tsx +++ b/src/components/transactions/Swap/SwapModalContent.tsx @@ -1,7 +1,7 @@ import { SwitchVerticalIcon } from '@heroicons/react/outline'; import { Trans } from '@lingui/macro'; import { Box, Stack, SvgIcon, Typography } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React, { useRef, useState } from 'react'; import { PriceImpactTooltip } from 'src/components/infoTooltips/PriceImpactTooltip'; import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; diff --git a/src/components/transactions/Withdraw/WithdrawError.tsx b/src/components/transactions/Withdraw/WithdrawError.tsx index 0bfe76f445..a0529f2ebf 100644 --- a/src/components/transactions/Withdraw/WithdrawError.tsx +++ b/src/components/transactions/Withdraw/WithdrawError.tsx @@ -1,6 +1,6 @@ import { valueToBigNumber } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ComputedReserveData, ExtendedFormattedUser, diff --git a/src/components/transactions/Withdraw/utils.ts b/src/components/transactions/Withdraw/utils.ts index fef6a51265..8ea110ac5a 100644 --- a/src/components/transactions/Withdraw/utils.ts +++ b/src/components/transactions/Withdraw/utils.ts @@ -1,5 +1,5 @@ import { valueToBigNumber } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ComputedReserveData, ComputedUserReserveData, diff --git a/src/hooks/pool/useUserYield.ts b/src/hooks/pool/useUserYield.ts index fbd6412b63..6cc2e91d1d 100644 --- a/src/hooks/pool/useUserYield.ts +++ b/src/hooks/pool/useUserYield.ts @@ -3,7 +3,7 @@ import { FormattedGhoUserData, FormatUserSummaryAndIncentivesResponse, } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import memoize from 'micro-memoize'; import { MarketDataType } from 'src/ui-config/marketsConfig'; import { diff --git a/src/modules/dashboard/LiquidationRiskParametresModal/components/LTVContent.tsx b/src/modules/dashboard/LiquidationRiskParametresModal/components/LTVContent.tsx index 24c47a21a0..09a247c6a0 100644 --- a/src/modules/dashboard/LiquidationRiskParametresModal/components/LTVContent.tsx +++ b/src/modules/dashboard/LiquidationRiskParametresModal/components/LTVContent.tsx @@ -1,7 +1,7 @@ import { valueToBigNumber } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; import { AlertColor, Box, Typography, useTheme } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React from 'react'; import { FormattedNumber } from '../../../../components/primitives/FormattedNumber'; diff --git a/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx b/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx index e9dd650317..7c9c686577 100644 --- a/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx +++ b/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx @@ -2,7 +2,7 @@ import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers'; import { USD_DECIMALS, valueToBigNumber } from '@aave/math-utils'; import { Trans } from '@lingui/macro'; import { Box, Typography, useMediaQuery, useTheme } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { Fragment, useState } from 'react'; import { ListColumn } from 'src/components/lists/ListColumn'; import { ListHeaderTitle } from 'src/components/lists/ListHeaderTitle'; diff --git a/src/modules/governance/utils/formatProposal.ts b/src/modules/governance/utils/formatProposal.ts index 4e61b67fb0..09b16d9faf 100644 --- a/src/modules/governance/utils/formatProposal.ts +++ b/src/modules/governance/utils/formatProposal.ts @@ -6,7 +6,7 @@ import { VotingMachineProposalState, } from '@aave/contract-helpers'; import { normalizeBN, valueToBigNumber } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { EnhancedSubgraphProposal, Proposal, diff --git a/src/modules/reserve-overview/ReserveActions.tsx b/src/modules/reserve-overview/ReserveActions.tsx index 76292223d5..d93b8fceac 100644 --- a/src/modules/reserve-overview/ReserveActions.tsx +++ b/src/modules/reserve-overview/ReserveActions.tsx @@ -12,7 +12,7 @@ import { Typography, useTheme, } from '@mui/material'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import React, { ReactNode, useState } from 'react'; import { WalletIcon } from 'src/components/icons/WalletIcon'; import { getMarketInfoById } from 'src/components/MarketSwitcher'; diff --git a/src/store/v3MigrationSelectors.ts b/src/store/v3MigrationSelectors.ts index 80f8862255..76c70d7756 100644 --- a/src/store/v3MigrationSelectors.ts +++ b/src/store/v3MigrationSelectors.ts @@ -25,7 +25,7 @@ import { ReserveIncentiveResponse, } from '@aave/math-utils/dist/esm/formatters/incentive/calculate-reserve-incentives'; import { SignatureLike } from '@ethersproject/bytes'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { BigNumberish } from 'ethers'; import { Approval } from 'src/helpers/useTransactionHandler'; import { diff --git a/src/utils/getMaxAmountAvailableToBorrow.ts b/src/utils/getMaxAmountAvailableToBorrow.ts index 8b7b720e1c..3e093146b0 100644 --- a/src/utils/getMaxAmountAvailableToBorrow.ts +++ b/src/utils/getMaxAmountAvailableToBorrow.ts @@ -1,5 +1,5 @@ import { FormatUserSummaryAndIncentivesResponse, valueToBigNumber } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { diff --git a/src/utils/getMaxAmountAvailableToSupply.ts b/src/utils/getMaxAmountAvailableToSupply.ts index 49b5d9e01a..42b43d3958 100644 --- a/src/utils/getMaxAmountAvailableToSupply.ts +++ b/src/utils/getMaxAmountAvailableToSupply.ts @@ -1,6 +1,6 @@ import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers'; import { valueToBigNumber } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { roundToTokenDecimals } from './utils'; diff --git a/src/utils/hfUtils.ts b/src/utils/hfUtils.ts index 70ece2a050..e7b021ea3d 100644 --- a/src/utils/hfUtils.ts +++ b/src/utils/hfUtils.ts @@ -5,7 +5,7 @@ import { UserReserveData, valueToBigNumber, } from '@aave/math-utils'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ComputedReserveData, ComputedUserReserveData,