Commit ffe67092 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

feat: remove fortmatic (#4167)

* rm fortmatic (wip for test)

* remove isChainAllowed

* handle unexpected connector

* clear on catch

* Revert "remove isChainAllowed"

This reverts commit d505cac39a446cb2c273016d03896469ba39eb60.

* fix to actually use ALLOWED_CHAIN_IDS

* fix
parent 21649967
...@@ -181,7 +181,6 @@ ...@@ -181,7 +181,6 @@
"ethers": "^5.1.4", "ethers": "^5.1.4",
"firebase": "^9.1.3", "firebase": "^9.1.3",
"focus-visible": "^5.2.0", "focus-visible": "^5.2.0",
"fortmatic": "^2.4.0",
"graphql": "^16.5.0", "graphql": "^16.5.0",
"graphql-request": "^3.4.0", "graphql-request": "^3.4.0",
"immer": "^9.0.6", "immer": "^9.0.6",
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#ff007a" /> <meta name="theme-color" content="#ff007a" />
<meta name="fortmatic-site-verification" content="j93LgcVZk79qcgyo" />
<!-- <!--
manifest.json provides metadata used when the app is installed as a PWA. manifest.json provides metadata used when the app is installed as a PWA.
......
...@@ -281,7 +281,7 @@ const NETWORK_SELECTOR_CHAINS = [ ...@@ -281,7 +281,7 @@ const NETWORK_SELECTOR_CHAINS = [
] ]
export default function NetworkSelector() { export default function NetworkSelector() {
const { chainId, provider, connector } = useWeb3React() const { chainId, provider } = useWeb3React()
const node = useRef<HTMLDivElement>(null) const node = useRef<HTMLDivElement>(null)
const isOpen = useModalIsOpen(ApplicationModal.NETWORK_SELECTOR) const isOpen = useModalIsOpen(ApplicationModal.NETWORK_SELECTOR)
...@@ -329,7 +329,7 @@ export default function NetworkSelector() { ...@@ -329,7 +329,7 @@ export default function NetworkSelector() {
<Trans>Select a {!onSupportedChain ? ' supported ' : ''}network</Trans> <Trans>Select a {!onSupportedChain ? ' supported ' : ''}network</Trans>
</FlyoutHeader> </FlyoutHeader>
{NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => {NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) =>
isChainAllowed(connector, chainId) ? ( isChainAllowed(chainId) ? (
<Row <Row
onSelectChain={async (targetChainId: SupportedChainId) => { onSelectChain={async (targetChainId: SupportedChainId) => {
await selectChain(targetChainId) await selectChain(targetChainId)
......
...@@ -2,7 +2,6 @@ import { ConnectionType } from 'connection' ...@@ -2,7 +2,6 @@ import { ConnectionType } from 'connection'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import CoinbaseWalletIcon from '../../assets/images/coinbaseWalletIcon.svg' import CoinbaseWalletIcon from '../../assets/images/coinbaseWalletIcon.svg'
import FortmaticIcon from '../../assets/images/fortmaticIcon.png'
import WalletConnectIcon from '../../assets/images/walletConnectIcon.svg' import WalletConnectIcon from '../../assets/images/walletConnectIcon.svg'
import Identicon from '../Identicon' import Identicon from '../Identicon'
...@@ -33,9 +32,6 @@ export default function StatusIcon({ connectionType, size }: { connectionType: C ...@@ -33,9 +32,6 @@ export default function StatusIcon({ connectionType, size }: { connectionType: C
case ConnectionType.COINBASE_WALLET: case ConnectionType.COINBASE_WALLET:
image = <img src={CoinbaseWalletIcon} alt="Coinbase Wallet" /> image = <img src={CoinbaseWalletIcon} alt="Coinbase Wallet" />
break break
case ConnectionType.FORTMATIC:
image = <img src={FortmaticIcon} alt="Fortmatic" />
break
} }
return <IconWrapper size={size ?? 16}>{image}</IconWrapper> return <IconWrapper size={size ?? 16}>{image}</IconWrapper>
......
...@@ -57,7 +57,7 @@ interface ChainSwitcherProps { ...@@ -57,7 +57,7 @@ interface ChainSwitcherProps {
} }
export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => { export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => {
const { chainId, connector } = useWeb3React() const { chainId } = useWeb3React()
const [isOpen, toggleOpen] = useReducer((s) => !s, false) const [isOpen, toggleOpen] = useReducer((s) => !s, false)
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
...@@ -89,7 +89,7 @@ export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => { ...@@ -89,7 +89,7 @@ export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => {
<NavDropdown top={60} leftAligned={isMobile}> <NavDropdown top={60} leftAligned={isMobile}>
<Column gap="4"> <Column gap="4">
{NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => {NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) =>
isChainAllowed(connector, chainId) ? ( isChainAllowed(chainId) ? (
<ChainRow <ChainRow
onSelectChain={async (targetChainId: SupportedChainId) => { onSelectChain={async (targetChainId: SupportedChainId) => {
await selectChain(targetChainId) await selectChain(targetChainId)
......
import { Connector } from '@web3-react/types'
import FORTMATIC_ICON_URL from 'assets/images/fortmaticIcon.png'
import { ConnectionType, fortmaticConnection } from 'connection'
import { getConnectionName } from 'connection/utils'
import Option from './Option'
const BASE_PROPS = {
color: '#6748FF',
icon: FORTMATIC_ICON_URL,
id: 'fortmatic',
}
export function FortmaticOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) {
const isActive = fortmaticConnection.hooks.useIsActive()
return (
<Option
{...BASE_PROPS}
isActive={isActive}
onClick={() => tryActivation(fortmaticConnection.connector)}
header={getConnectionName(ConnectionType.FORTMATIC)}
/>
)
}
...@@ -81,8 +81,7 @@ it('loads Wallet Modal on desktop', async () => { ...@@ -81,8 +81,7 @@ it('loads Wallet Modal on desktop', async () => {
expect(screen.getByText('Install MetaMask')).toBeInTheDocument() expect(screen.getByText('Install MetaMask')).toBeInTheDocument()
expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument() expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument()
expect(screen.getByText('WalletConnect')).toBeInTheDocument() expect(screen.getByText('WalletConnect')).toBeInTheDocument()
expect(screen.getByText('Fortmatic')).toBeInTheDocument() expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3)
expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(4)
}) })
it('loads Wallet Modal on desktop with generic Injected', async () => { it('loads Wallet Modal on desktop with generic Injected', async () => {
...@@ -94,8 +93,7 @@ it('loads Wallet Modal on desktop with generic Injected', async () => { ...@@ -94,8 +93,7 @@ it('loads Wallet Modal on desktop with generic Injected', async () => {
expect(screen.getByText('Injected')).toBeInTheDocument() expect(screen.getByText('Injected')).toBeInTheDocument()
expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument() expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument()
expect(screen.getByText('WalletConnect')).toBeInTheDocument() expect(screen.getByText('WalletConnect')).toBeInTheDocument()
expect(screen.getByText('Fortmatic')).toBeInTheDocument() expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3)
expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(4)
}) })
it('loads Wallet Modal on desktop with MetaMask installed', async () => { it('loads Wallet Modal on desktop with MetaMask installed', async () => {
...@@ -107,8 +105,7 @@ it('loads Wallet Modal on desktop with MetaMask installed', async () => { ...@@ -107,8 +105,7 @@ it('loads Wallet Modal on desktop with MetaMask installed', async () => {
expect(screen.getByText('MetaMask')).toBeInTheDocument() expect(screen.getByText('MetaMask')).toBeInTheDocument()
expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument() expect(screen.getByText('Coinbase Wallet')).toBeInTheDocument()
expect(screen.getByText('WalletConnect')).toBeInTheDocument() expect(screen.getByText('WalletConnect')).toBeInTheDocument()
expect(screen.getByText('Fortmatic')).toBeInTheDocument() expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3)
expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(4)
}) })
it('loads Wallet Modal on mobile', async () => { it('loads Wallet Modal on mobile', async () => {
...@@ -121,8 +118,7 @@ it('loads Wallet Modal on mobile', async () => { ...@@ -121,8 +118,7 @@ it('loads Wallet Modal on mobile', async () => {
render(<WalletModal pendingTransactions={[]} confirmedTransactions={[]} />) render(<WalletModal pendingTransactions={[]} confirmedTransactions={[]} />)
expect(screen.getByText('Open in Coinbase Wallet')).toBeInTheDocument() expect(screen.getByText('Open in Coinbase Wallet')).toBeInTheDocument()
expect(screen.getByText('WalletConnect')).toBeInTheDocument() expect(screen.getByText('WalletConnect')).toBeInTheDocument()
expect(screen.getByText('Fortmatic')).toBeInTheDocument() expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(2)
expect(screen.getAllByTestId('wallet-modal-option')).toHaveLength(3)
}) })
it('loads Wallet Modal on MetaMask browser', async () => { it('loads Wallet Modal on MetaMask browser', async () => {
......
...@@ -13,7 +13,6 @@ import { formatToDecimal, getTokenAddress } from 'components/AmplitudeAnalytics/ ...@@ -13,7 +13,6 @@ import { formatToDecimal, getTokenAddress } from 'components/AmplitudeAnalytics/
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import { AutoRow } from 'components/Row' import { AutoRow } from 'components/Row'
import { ConnectionType } from 'connection'
import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils' import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils'
import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign' import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign'
import { useStablecoinValue } from 'hooks/useStablecoinPrice' import { useStablecoinValue } from 'hooks/useStablecoinPrice'
...@@ -39,7 +38,6 @@ import AccountDetails from '../AccountDetails' ...@@ -39,7 +38,6 @@ import AccountDetails from '../AccountDetails'
import { LightCard } from '../Card' import { LightCard } from '../Card'
import Modal from '../Modal' import Modal from '../Modal'
import { CoinbaseWalletOption, OpenCoinbaseWalletOption } from './CoinbaseWalletOption' import { CoinbaseWalletOption, OpenCoinbaseWalletOption } from './CoinbaseWalletOption'
import { FortmaticOption } from './FortmaticOption'
import { InjectedOption, InstallMetaMaskOption, MetaMaskOption } from './InjectedOption' import { InjectedOption, InstallMetaMaskOption, MetaMaskOption } from './InjectedOption'
import PendingView from './PendingView' import PendingView from './PendingView'
import { WalletConnectOption } from './WalletConnectOption' import { WalletConnectOption } from './WalletConnectOption'
...@@ -281,12 +279,6 @@ export default function WalletModal({ ...@@ -281,12 +279,6 @@ export default function WalletModal({
}) })
try { try {
// Fortmatic opens it's own modal on activation to log in. This modal has a tabIndex
// collision into the WalletModal, so we special case by closing the modal.
if (connectionType === ConnectionType.FORTMATIC) {
toggleWalletModal()
}
setPendingConnector(connector) setPendingConnector(connector)
setWalletView(WALLET_VIEWS.PENDING) setWalletView(WALLET_VIEWS.PENDING)
dispatch(updateConnectionError({ connectionType, error: undefined })) dispatch(updateConnectionError({ connectionType, error: undefined }))
...@@ -304,7 +296,7 @@ export default function WalletModal({ ...@@ -304,7 +296,7 @@ export default function WalletModal({
}) })
} }
}, },
[dispatch, toggleWalletModal] [dispatch]
) )
function getOptions() { function getOptions() {
...@@ -339,14 +331,11 @@ export default function WalletModal({ ...@@ -339,14 +331,11 @@ export default function WalletModal({
const walletConnectionOption = const walletConnectionOption =
(!isInjectedMobileBrowser && <WalletConnectOption tryActivation={tryActivation} />) ?? null (!isInjectedMobileBrowser && <WalletConnectOption tryActivation={tryActivation} />) ?? null
const fortmaticOption = (!isInjectedMobileBrowser && <FortmaticOption tryActivation={tryActivation} />) ?? null
return ( return (
<> <>
{injectedOption} {injectedOption}
{coinbaseWalletOption} {coinbaseWalletOption}
{walletConnectionOption} {walletConnectionOption}
{fortmaticOption}
</> </>
) )
} }
......
import { CoinbaseWallet } from '@web3-react/coinbase-wallet' import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import { initializeConnector, Web3ReactHooks } from '@web3-react/core' import { initializeConnector, Web3ReactHooks } from '@web3-react/core'
import { EIP1193 } from '@web3-react/eip1193'
import { GnosisSafe } from '@web3-react/gnosis-safe' import { GnosisSafe } from '@web3-react/gnosis-safe'
import { MetaMask } from '@web3-react/metamask' import { MetaMask } from '@web3-react/metamask'
import { Network } from '@web3-react/network' import { Network } from '@web3-react/network'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { WalletConnect } from '@web3-react/walletconnect' import { WalletConnect } from '@web3-react/walletconnect'
import { SupportedChainId } from 'constants/chains' import { SupportedChainId } from 'constants/chains'
import Fortmatic from 'fortmatic'
import UNISWAP_LOGO_URL from '../assets/svg/logo.svg' import UNISWAP_LOGO_URL from '../assets/svg/logo.svg'
import { RPC_URLS } from '../constants/networks' import { RPC_URLS } from '../constants/networks'
...@@ -16,7 +14,6 @@ export enum ConnectionType { ...@@ -16,7 +14,6 @@ export enum ConnectionType {
INJECTED = 'INJECTED', INJECTED = 'INJECTED',
COINBASE_WALLET = 'COINBASE_WALLET', COINBASE_WALLET = 'COINBASE_WALLET',
WALLET_CONNECT = 'WALLET_CONNECT', WALLET_CONNECT = 'WALLET_CONNECT',
FORTMATIC = 'FORTMATIC',
NETWORK = 'NETWORK', NETWORK = 'NETWORK',
GNOSIS_SAFE = 'GNOSIS_SAFE', GNOSIS_SAFE = 'GNOSIS_SAFE',
} }
...@@ -71,15 +68,6 @@ export const walletConnectConnection: Connection = { ...@@ -71,15 +68,6 @@ export const walletConnectConnection: Connection = {
type: ConnectionType.WALLET_CONNECT, type: ConnectionType.WALLET_CONNECT,
} }
const [web3Fortmatic, web3FortmaticHooks] = initializeConnector<EIP1193>(
(actions) => new EIP1193({ actions, provider: new Fortmatic(process.env.REACT_APP_FORTMATIC_KEY).getProvider() })
)
export const fortmaticConnection: Connection = {
connector: web3Fortmatic,
hooks: web3FortmaticHooks,
type: ConnectionType.FORTMATIC,
}
const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<CoinbaseWallet>( const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<CoinbaseWallet>(
(actions) => (actions) =>
new CoinbaseWallet({ new CoinbaseWallet({
......
...@@ -2,7 +2,6 @@ import { Connector } from '@web3-react/types' ...@@ -2,7 +2,6 @@ import { Connector } from '@web3-react/types'
import { import {
coinbaseWalletConnection, coinbaseWalletConnection,
ConnectionType, ConnectionType,
fortmaticConnection,
gnosisSafeConnection, gnosisSafeConnection,
injectedConnection, injectedConnection,
networkConnection, networkConnection,
...@@ -26,7 +25,6 @@ const CONNECTIONS = [ ...@@ -26,7 +25,6 @@ const CONNECTIONS = [
injectedConnection, injectedConnection,
coinbaseWalletConnection, coinbaseWalletConnection,
walletConnectConnection, walletConnectConnection,
fortmaticConnection,
networkConnection, networkConnection,
] ]
export function getConnection(c: Connector | ConnectionType) { export function getConnection(c: Connector | ConnectionType) {
...@@ -44,8 +42,6 @@ export function getConnection(c: Connector | ConnectionType) { ...@@ -44,8 +42,6 @@ export function getConnection(c: Connector | ConnectionType) {
return coinbaseWalletConnection return coinbaseWalletConnection
case ConnectionType.WALLET_CONNECT: case ConnectionType.WALLET_CONNECT:
return walletConnectConnection return walletConnectConnection
case ConnectionType.FORTMATIC:
return fortmaticConnection
case ConnectionType.NETWORK: case ConnectionType.NETWORK:
return networkConnection return networkConnection
case ConnectionType.GNOSIS_SAFE: case ConnectionType.GNOSIS_SAFE:
...@@ -62,8 +58,6 @@ export function getConnectionName(connectionType: ConnectionType, isMetaMask?: b ...@@ -62,8 +58,6 @@ export function getConnectionName(connectionType: ConnectionType, isMetaMask?: b
return 'Coinbase Wallet' return 'Coinbase Wallet'
case ConnectionType.WALLET_CONNECT: case ConnectionType.WALLET_CONNECT:
return 'WalletConnect' return 'WalletConnect'
case ConnectionType.FORTMATIC:
return 'Fortmatic'
case ConnectionType.NETWORK: case ConnectionType.NETWORK:
return 'Network' return 'Network'
case ConnectionType.GNOSIS_SAFE: case ConnectionType.GNOSIS_SAFE:
......
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { gnosisSafeConnection, networkConnection } from 'connection' import { Connection, gnosisSafeConnection, networkConnection } from 'connection'
import { getConnection } from 'connection/utils' import { getConnection } from 'connection/utils'
import { useEffect } from 'react' import { useEffect } from 'react'
import { useAppSelector } from 'state/hooks' import { useAppDispatch, useAppSelector } from 'state/hooks'
import { updateSelectedWallet } from 'state/user/reducer'
async function connect(connector: Connector) { async function connect(connector: Connector) {
try { try {
...@@ -17,14 +18,25 @@ async function connect(connector: Connector) { ...@@ -17,14 +18,25 @@ async function connect(connector: Connector) {
} }
export default function useEagerlyConnect() { export default function useEagerlyConnect() {
const dispatch = useAppDispatch()
const selectedWallet = useAppSelector((state) => state.user.selectedWallet) const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
let selectedConnection: Connection | undefined
if (selectedWallet) {
try {
selectedConnection = getConnection(selectedWallet)
} catch {
dispatch(updateSelectedWallet({ wallet: undefined }))
}
}
useEffect(() => { useEffect(() => {
connect(gnosisSafeConnection.connector) connect(gnosisSafeConnection.connector)
connect(networkConnection.connector) connect(networkConnection.connector)
if (selectedWallet) { if (selectedConnection) {
connect(getConnection(selectedWallet).connector) connect(selectedConnection.connector)
} // The dependency list is empty so this is only run once on mount } // The dependency list is empty so this is only run once on mount
}, []) // eslint-disable-line react-hooks/exhaustive-deps }, []) // eslint-disable-line react-hooks/exhaustive-deps
} }
...@@ -3,12 +3,7 @@ import { getConnection } from 'connection/utils' ...@@ -3,12 +3,7 @@ import { getConnection } from 'connection/utils'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useAppSelector } from 'state/hooks' import { useAppSelector } from 'state/hooks'
const SELECTABLE_WALLETS = [ const SELECTABLE_WALLETS = [ConnectionType.INJECTED, ConnectionType.COINBASE_WALLET, ConnectionType.WALLET_CONNECT]
ConnectionType.INJECTED,
ConnectionType.COINBASE_WALLET,
ConnectionType.WALLET_CONNECT,
ConnectionType.FORTMATIC,
]
export default function useOrderedConnections() { export default function useOrderedConnections() {
const selectedWallet = useAppSelector((state) => state.user.selectedWallet) const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
......
...@@ -30,8 +30,8 @@ function parseStringOrBytes32(str: string | undefined, bytes32: string | undefin ...@@ -30,8 +30,8 @@ function parseStringOrBytes32(str: string | undefined, bytes32: string | undefin
* Returns undefined if tokenAddress is invalid or token does not exist. * Returns undefined if tokenAddress is invalid or token does not exist.
*/ */
export function useTokenFromNetwork(tokenAddress: string | null | undefined): Token | null | undefined { export function useTokenFromNetwork(tokenAddress: string | null | undefined): Token | null | undefined {
const { chainId, connector } = useWeb3React() const { chainId } = useWeb3React()
const chainAllowed = chainId && isChainAllowed(connector, chainId) const chainAllowed = chainId && isChainAllowed(chainId)
const formattedAddress = isAddress(tokenAddress) const formattedAddress = isAddress(tokenAddress)
...@@ -96,7 +96,7 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string ...@@ -96,7 +96,7 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string
*/ */
export function useCurrencyFromMap(tokens: TokenMap, currencyId?: string | null): Currency | null | undefined { export function useCurrencyFromMap(tokens: TokenMap, currencyId?: string | null): Currency | null | undefined {
const nativeCurrency = useNativeCurrency() const nativeCurrency = useNativeCurrency()
const { chainId, connector } = useWeb3React() const { chainId } = useWeb3React()
const isNative = Boolean(nativeCurrency && currencyId?.toUpperCase() === 'ETH') const isNative = Boolean(nativeCurrency && currencyId?.toUpperCase() === 'ETH')
const shorthandMatchAddress = useMemo(() => { const shorthandMatchAddress = useMemo(() => {
const chain = supportedChainId(chainId) const chain = supportedChainId(chainId)
...@@ -105,7 +105,7 @@ export function useCurrencyFromMap(tokens: TokenMap, currencyId?: string | null) ...@@ -105,7 +105,7 @@ export function useCurrencyFromMap(tokens: TokenMap, currencyId?: string | null)
const token = useTokenFromMapOrNetwork(tokens, isNative ? undefined : shorthandMatchAddress ?? currencyId) const token = useTokenFromMapOrNetwork(tokens, isNative ? undefined : shorthandMatchAddress ?? currencyId)
const chainAllowed = chainId && isChainAllowed(connector, chainId) const chainAllowed = chainId && isChainAllowed(chainId)
if (currencyId === null || currencyId === undefined || !chainAllowed) return null if (currencyId === null || currencyId === undefined || !chainAllowed) return null
// this case so we use our builtin wrapped token instead of wrapped tokens on token lists // this case so we use our builtin wrapped token instead of wrapped tokens on token lists
......
...@@ -4,8 +4,6 @@ declare module '@metamask/jazzicon' { ...@@ -4,8 +4,6 @@ declare module '@metamask/jazzicon' {
export default function (diameter: number, seed: number): HTMLElement export default function (diameter: number, seed: number): HTMLElement
} }
declare module 'fortmatic'
interface Window { interface Window {
// walletLinkExtension is injected by the Coinbase Wallet extension // walletLinkExtension is injected by the Coinbase Wallet extension
walletLinkExtension?: any walletLinkExtension?: any
......
...@@ -8,7 +8,6 @@ export interface ConnectionState { ...@@ -8,7 +8,6 @@ export interface ConnectionState {
export const initialState: ConnectionState = { export const initialState: ConnectionState = {
errorByConnectionType: { errorByConnectionType: {
[ConnectionType.INJECTED]: undefined, [ConnectionType.INJECTED]: undefined,
[ConnectionType.FORTMATIC]: undefined,
[ConnectionType.WALLET_CONNECT]: undefined, [ConnectionType.WALLET_CONNECT]: undefined,
[ConnectionType.COINBASE_WALLET]: undefined, [ConnectionType.COINBASE_WALLET]: undefined,
[ConnectionType.NETWORK]: undefined, [ConnectionType.NETWORK]: undefined,
......
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { import { networkConnection, walletConnectConnection } from 'connection'
coinbaseWalletConnection,
fortmaticConnection,
gnosisSafeConnection,
injectedConnection,
networkConnection,
walletConnectConnection,
} from 'connection'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { ALL_SUPPORTED_CHAIN_IDS, SupportedChainId } from 'constants/chains' import { ALL_SUPPORTED_CHAIN_IDS, SupportedChainId } from 'constants/chains'
import { RPC_URLS } from 'constants/networks' import { RPC_URLS } from 'constants/networks'
...@@ -41,23 +34,12 @@ function getRpcUrls(chainId: SupportedChainId): [string] { ...@@ -41,23 +34,12 @@ function getRpcUrls(chainId: SupportedChainId): [string] {
throw new Error('RPC URLs must use public endpoints') throw new Error('RPC URLs must use public endpoints')
} }
export function isChainAllowed(connector: Connector, chainId: number) { export function isChainAllowed(chainId: number) {
switch (connector) { return ALL_SUPPORTED_CHAIN_IDS.includes(chainId)
case fortmaticConnection.connector:
return chainId === SupportedChainId.MAINNET
case injectedConnection.connector:
case coinbaseWalletConnection.connector:
case walletConnectConnection.connector:
case networkConnection.connector:
case gnosisSafeConnection.connector:
return ALL_SUPPORTED_CHAIN_IDS.includes(chainId)
default:
return false
}
} }
export const switchChain = async (connector: Connector, chainId: SupportedChainId) => { export const switchChain = async (connector: Connector, chainId: SupportedChainId) => {
if (!isChainAllowed(connector, chainId)) { if (!isChainAllowed(chainId)) {
throw new Error(`Chain ${chainId} not supported for connector (${typeof connector})`) throw new Error(`Chain ${chainId} not supported for connector (${typeof connector})`)
} else if (connector === walletConnectConnection.connector || connector === networkConnection.connector) { } else if (connector === walletConnectConnection.connector || connector === networkConnection.connector) {
await connector.activate(chainId) await connector.activate(chainId)
......
...@@ -10284,11 +10284,6 @@ form-data@~2.3.2: ...@@ -10284,11 +10284,6 @@ form-data@~2.3.2:
combined-stream "^1.0.6" combined-stream "^1.0.6"
mime-types "^2.1.12" mime-types "^2.1.12"
fortmatic@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/fortmatic/-/fortmatic-2.4.0.tgz#0546803d5c6187c06b3367eba66235cf4a195ece"
integrity sha512-4LVxybyWcz8eFkTjIW12JRyRCUV9/qih435l0+5ncTVIb+zzXjvjQ5dZU0eBAXXyAgmV9BIRYkQL9H/lc76w/w==
forwarded@0.2.0: forwarded@0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
......
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