Commit 17eceebc authored by Moody Salem's avatar Moody Salem

Final typescript migration push

parent 6112c8a2
...@@ -261,7 +261,6 @@ export default function CurrencyInputPanel({ ...@@ -261,7 +261,6 @@ export default function CurrencyInputPanel({
}} }}
filterType="tokens" filterType="tokens"
urlAddedTokens={urlAddedTokens} urlAddedTokens={urlAddedTokens}
field={field}
onTokenSelect={onTokenSelection} onTokenSelect={onTokenSelection}
showSendWithSwap={showSendWithSwap} showSendWithSwap={showSendWithSwap}
hiddenToken={token?.address} hiddenToken={token?.address}
......
...@@ -2,9 +2,9 @@ import React, { useState, useRef, useMemo, useEffect, useContext } from 'react' ...@@ -2,9 +2,9 @@ import React, { useState, useRef, useMemo, useEffect, useContext } from 'react'
import '@reach/tooltip/styles.css' import '@reach/tooltip/styles.css'
import styled, { ThemeContext } from 'styled-components' import styled, { ThemeContext } from 'styled-components'
import escapeStringRegex from 'escape-string-regexp' import escapeStringRegex from 'escape-string-regexp'
import { JSBI, WETH } from '@uniswap/sdk' import { JSBI, Token, WETH } from '@uniswap/sdk'
import { isMobile } from 'react-device-detect' import { isMobile } from 'react-device-detect'
import { withRouter } from 'react-router-dom' import { RouteComponentProps, withRouter } from 'react-router-dom'
import { COMMON_BASES } from '../../constants' import { COMMON_BASES } from '../../constants'
import { Link as StyledLink } from '../../theme/components' import { Link as StyledLink } from '../../theme/components'
...@@ -140,6 +140,19 @@ const FILTERS = { ...@@ -140,6 +140,19 @@ const FILTERS = {
BALANCES: 'BALANCES' BALANCES: 'BALANCES'
} }
interface SearchModalProps extends RouteComponentProps<{}> {
isOpen?: boolean
onDismiss?: () => void
filterType?: 'tokens'
hiddenToken?: string
showSendWithSwap?: boolean
onTokenSelect?: (address: string) => void
urlAddedTokens?: Token[]
otherSelectedTokenAddress?: string
otherSelectedText?: string
showCommonBases?: boolean
}
function SearchModal({ function SearchModal({
history, history,
isOpen, isOpen,
...@@ -152,7 +165,7 @@ function SearchModal({ ...@@ -152,7 +165,7 @@ function SearchModal({
otherSelectedTokenAddress, otherSelectedTokenAddress,
otherSelectedText, otherSelectedText,
showCommonBases = false showCommonBases = false
}) { }: SearchModalProps) {
const { t } = useTranslation() const { t } = useTranslation()
const { account, chainId } = useWeb3React() const { account, chainId } = useWeb3React()
const theme = useContext(ThemeContext) const theme = useContext(ThemeContext)
...@@ -168,7 +181,7 @@ function SearchModal({ ...@@ -168,7 +181,7 @@ function SearchModal({
// if the current input is an address, and we don't have the token in context, try to fetch it // if the current input is an address, and we don't have the token in context, try to fetch it
const token = useToken(searchQuery) const token = useToken(searchQuery)
const [temporaryToken, setTemporaryToken] = useState() const [temporaryToken, setTemporaryToken] = useState<Token | null>()
useEffect(() => { useEffect(() => {
const address = isAddress(searchQuery) const address = isAddress(searchQuery)
if (address && !token) { if (address && !token) {
...@@ -180,7 +193,7 @@ function SearchModal({ ...@@ -180,7 +193,7 @@ function SearchModal({
}) })
return () => { return () => {
stale = true stale = true
setTemporaryToken() setTemporaryToken(null)
} }
} }
}, [searchQuery, token, fetchTokenByAddress]) }, [searchQuery, token, fetchTokenByAddress])
...@@ -198,7 +211,7 @@ function SearchModal({ ...@@ -198,7 +211,7 @@ function SearchModal({
const tokenList = useMemo(() => { const tokenList = useMemo(() => {
return Object.keys(allTokens) return Object.keys(allTokens)
.sort((a, b) => { .sort((a, b): number => {
if (allTokens[a].symbol && allTokens[b].symbol) { if (allTokens[a].symbol && allTokens[b].symbol) {
const aSymbol = allTokens[a].symbol.toLowerCase() const aSymbol = allTokens[a].symbol.toLowerCase()
const bSymbol = allTokens[b].symbol.toLowerCase() const bSymbol = allTokens[b].symbol.toLowerCase()
...@@ -211,13 +224,13 @@ function SearchModal({ ...@@ -211,13 +224,13 @@ function SearchModal({
const balanceB = allBalances?.[account]?.[b] const balanceB = allBalances?.[account]?.[b]
if (balanceA && !balanceB) { if (balanceA && !balanceB) {
return sortDirection return sortDirection ? -1 : 1
} }
if (!balanceA && balanceB) { if (!balanceA && balanceB) {
return sortDirection * -1 return sortDirection ? 1 : -1
} }
if (balanceA && balanceB) { if (balanceA && balanceB) {
return sortDirection * parseFloat(balanceA.toExact()) > parseFloat(balanceB.toExact()) ? -1 : 1 return sortDirection && parseFloat(balanceA.toExact()) > parseFloat(balanceB.toExact()) ? -1 : 1
} }
return aSymbol < bSymbol ? -1 : aSymbol > bSymbol ? 1 : 0 return aSymbol < bSymbol ? -1 : aSymbol > bSymbol ? 1 : 0
} else { } else {
...@@ -274,6 +287,7 @@ function SearchModal({ ...@@ -274,6 +287,7 @@ function SearchModal({
// manage focus on modal show // manage focus on modal show
const inputRef = useRef() const inputRef = useRef()
function onInput(event) { function onInput(event) {
const input = event.target.value const input = event.target.value
const checksummedInput = isAddress(input) const checksummedInput = isAddress(input)
...@@ -289,19 +303,19 @@ function SearchModal({ ...@@ -289,19 +303,19 @@ function SearchModal({
const escapeStringRegexp = string => string const escapeStringRegexp = string => string
const sortedPairList = useMemo(() => { const sortedPairList = useMemo(() => {
return Object.keys(allPairs).sort((a, b) => { return Object.keys(allPairs).sort((a, b): number => {
// sort by balance // sort by balance
const balanceA = allBalances?.[account]?.[a] const balanceA = allBalances?.[account]?.[a]
const balanceB = allBalances?.[account]?.[b] const balanceB = allBalances?.[account]?.[b]
if (balanceA && !balanceB) { if (balanceA && !balanceB) {
return sortDirection return sortDirection ? -1 : 1
} }
if (!balanceA && balanceB) { if (!balanceA && balanceB) {
return sortDirection * -1 return sortDirection ? 1 : -1
} }
if (balanceA && balanceB) { if (balanceA && balanceB) {
const order = sortDirection * (parseFloat(balanceA.toExact()) > parseFloat(balanceB.toExact()) ? -1 : 1) const order = sortDirection && (parseFloat(balanceA.toExact()) > parseFloat(balanceB.toExact()) ? -1 : 1)
return order ? 1 : -1 return order ? 1 : -1
} else { } else {
return 0 return 0
...@@ -363,7 +377,7 @@ function SearchModal({ ...@@ -363,7 +377,7 @@ function SearchModal({
}} }}
> >
<RowFixed> <RowFixed>
<DoubleTokenLogo a0={token0?.address || ''} a1={token1?.address || ''} size={24} margin={true} /> <DoubleTokenLogo a0={token0?.address || ''} a1={token1?.address || ''} size={24} margin={true}/>
<Text fontWeight={500} fontSize={16}>{`${token0?.symbol}/${token1?.symbol}`}</Text> <Text fontWeight={500} fontSize={16}>{`${token0?.symbol}/${token1?.symbol}`}</Text>
</RowFixed> </RowFixed>
{/* <Text fontWeight={500} fontSize={16}> {/* <Text fontWeight={500} fontSize={16}>
...@@ -404,7 +418,7 @@ function SearchModal({ ...@@ -404,7 +418,7 @@ function SearchModal({
}} }}
> >
<RowFixed> <RowFixed>
<TokenLogo address={temporaryToken.address} size={'24px'} style={{ marginRight: '14px' }} /> <TokenLogo address={temporaryToken.address} size={'24px'} style={{ marginRight: '14px' }}/>
<Column> <Column>
<Text fontWeight={500}>{temporaryToken.symbol}</Text> <Text fontWeight={500}>{temporaryToken.symbol}</Text>
<FadedSpan>(Found by search)</FadedSpan> <FadedSpan>(Found by search)</FadedSpan>
...@@ -453,12 +467,13 @@ function SearchModal({ ...@@ -453,12 +467,13 @@ function SearchModal({
return ( return (
<MenuItem <MenuItem
key={address} key={address}
onClick={() => (hiddenToken && hiddenToken === address ? () => {} : _onTokenSelect(address))} onClick={() => (hiddenToken && hiddenToken === address ? () => {
} : _onTokenSelect(address))}
disabled={hiddenToken && hiddenToken === address} disabled={hiddenToken && hiddenToken === address}
selected={otherSelectedTokenAddress === address} selected={otherSelectedTokenAddress === address}
> >
<RowFixed> <RowFixed>
<TokenLogo address={address} size={'24px'} style={{ marginRight: '14px' }} /> <TokenLogo address={address} size={'24px'} style={{ marginRight: '14px' }}/>
<Column> <Column>
<Text fontWeight={500}> <Text fontWeight={500}>
{symbol} {symbol}
...@@ -486,7 +501,6 @@ function SearchModal({ ...@@ -486,7 +501,6 @@ function SearchModal({
<Text> <Text>
{zeroBalance && showSendWithSwap ? ( {zeroBalance && showSendWithSwap ? (
<ColumnCenter <ColumnCenter
justify="center"
style={{ backgroundColor: theme.bg2, padding: '8px', borderRadius: '12px' }} style={{ backgroundColor: theme.bg2, padding: '8px', borderRadius: '12px' }}
> >
<Text textAlign="center" fontWeight={500} color={theme.blue1}> <Text textAlign="center" fontWeight={500} color={theme.blue1}>
...@@ -500,7 +514,7 @@ function SearchModal({ ...@@ -500,7 +514,7 @@ function SearchModal({
)} )}
</Text> </Text>
) : account ? ( ) : account ? (
<SpinnerWrapper src={Circle} alt="loader" /> <SpinnerWrapper src={Circle} alt="loader"/>
) : ( ) : (
'-' '-'
)} )}
...@@ -555,7 +569,7 @@ function SearchModal({ ...@@ -555,7 +569,7 @@ function SearchModal({
Import A Token Import A Token
</Text> </Text>
</RowFixed> </RowFixed>
<CloseIcon onClick={onDismiss} /> <CloseIcon onClick={onDismiss}/>
</RowBetween> </RowBetween>
<TYPE.body style={{ marginTop: '10px' }}> <TYPE.body style={{ marginTop: '10px' }}>
To import a custom token, paste token address in the search bar. To import a custom token, paste token address in the search bar.
...@@ -575,7 +589,7 @@ function SearchModal({ ...@@ -575,7 +589,7 @@ function SearchModal({
<Text fontWeight={500} fontSize={16}> <Text fontWeight={500} fontSize={16}>
{filterType === 'tokens' ? 'Select A Token' : 'Select A Pool'} {filterType === 'tokens' ? 'Select A Token' : 'Select A Pool'}
</Text> </Text>
<CloseIcon onClick={onDismiss} /> <CloseIcon onClick={onDismiss}/>
</RowBetween> </RowBetween>
<Input <Input
type={'text'} type={'text'}
...@@ -590,7 +604,7 @@ function SearchModal({ ...@@ -590,7 +604,7 @@ function SearchModal({
<Text fontWeight={500} fontSize={16}> <Text fontWeight={500} fontSize={16}>
Common Bases Common Bases
</Text> </Text>
<QuestionHelper text="These tokens are commonly used in pairs." /> <QuestionHelper text="These tokens are commonly used in pairs."/>
</AutoRow> </AutoRow>
<AutoRow gap="10px"> <AutoRow gap="10px">
{COMMON_BASES[chainId]?.map(token => { {COMMON_BASES[chainId]?.map(token => {
...@@ -601,7 +615,7 @@ function SearchModal({ ...@@ -601,7 +615,7 @@ function SearchModal({
disable={hiddenToken === token.address} disable={hiddenToken === token.address}
key={token.address} key={token.address}
> >
<TokenLogo address={token.address} /> <TokenLogo address={token.address}/>
<Text fontWeight={500} fontSize={16}> <Text fontWeight={500} fontSize={16}>
{token.symbol} {token.symbol}
</Text> </Text>
...@@ -623,16 +637,16 @@ function SearchModal({ ...@@ -623,16 +637,16 @@ function SearchModal({
</RowBetween> </RowBetween>
</PaddedColumn> </PaddedColumn>
)} )}
{!showTokenImport && <div style={{ width: '100%', height: '1px', backgroundColor: theme.bg2 }} />} {!showTokenImport && <div style={{ width: '100%', height: '1px', backgroundColor: theme.bg2 }}/>}
{!showTokenImport && <TokenList>{filterType === 'tokens' ? renderTokenList() : renderPairsList()}</TokenList>} {!showTokenImport && <TokenList>{filterType === 'tokens' ? renderTokenList() : renderPairsList()}</TokenList>}
{!showTokenImport && <div style={{ width: '100%', height: '1px', backgroundColor: theme.bg2 }} />} {!showTokenImport && <div style={{ width: '100%', height: '1px', backgroundColor: theme.bg2 }}/>}
{!showTokenImport && ( {!showTokenImport && (
<Card> <Card>
<AutoRow justify={'center'}> <AutoRow justify={'center'}>
<div> <div>
{filterType !== 'tokens' && ( {filterType !== 'tokens' && (
<Text fontWeight={500}> <Text fontWeight={500}>
{!isMobile && "Don't see a pool? "} {!isMobile && 'Don\'t see a pool? '}
<StyledLink <StyledLink
onClick={() => { onClick={() => {
history.push('/find') history.push('/find')
...@@ -644,7 +658,7 @@ function SearchModal({ ...@@ -644,7 +658,7 @@ function SearchModal({
)} )}
{filterType === 'tokens' && ( {filterType === 'tokens' && (
<Text fontWeight={500} color={theme.text2} fontSize={14}> <Text fontWeight={500} color={theme.text2} fontSize={14}>
{!isMobile && "Don't see a token? "} {!isMobile && 'Don\'t see a token? '}
<StyledLink <StyledLink
onClick={() => { onClick={() => {
......
...@@ -12,7 +12,7 @@ const TOKEN_ICON_API = address => ...@@ -12,7 +12,7 @@ const TOKEN_ICON_API = address =>
)}/logo.png` )}/logo.png`
const BAD_IMAGES = {} const BAD_IMAGES = {}
const Image = styled.img` const Image = styled.img<{ size: string }>`
width: ${({ size }) => size}; width: ${({ size }) => size};
height: ${({ size }) => size}; height: ${({ size }) => size};
background-color: white; background-color: white;
...@@ -20,7 +20,7 @@ const Image = styled.img` ...@@ -20,7 +20,7 @@ const Image = styled.img`
box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.075); box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.075);
` `
const Emoji = styled.span` const Emoji = styled.span<{size?:string}>`
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -30,7 +30,7 @@ const Emoji = styled.span` ...@@ -30,7 +30,7 @@ const Emoji = styled.span`
margin-bottom: -4px; margin-bottom: -4px;
` `
const StyledEthereumLogo = styled(EthereumLogo)` const StyledEthereumLogo = styled(EthereumLogo)<{size: string}>`
width: ${({ size }) => size}; width: ${({ size }) => size};
height: ${({ size }) => size}; height: ${({ size }) => size};
` `
......
import React, { useState, useEffect, useRef } from 'react' import React, { useState } from 'react'
import { Link } from '../../theme/components' import { AlertCircle, CheckCircle } from 'react-feather'
import { TYPE } from '../../theme'
import { AutoColumn } from '../Column'
import { AutoRow } from '../Row'
import { useWeb3React } from '../../hooks' import styled from 'styled-components'
import { getEtherscanLink } from '../../utils'
import { usePopups } from '../../contexts/Application' import { usePopups } from '../../contexts/Application'
import { CheckCircle, AlertCircle } from 'react-feather' import { useWeb3React } from '../../hooks'
import useInterval from '../../hooks/useInterval'
import { TYPE } from '../../theme'
import styled from 'styled-components' import { Link } from '../../theme/components'
import { getEtherscanLink } from '../../utils'
import { AutoColumn } from '../Column'
import { AutoRow } from '../Row'
const Fader = styled.div` const Fader = styled.div<{ count: number }>`
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
left: 0px; left: 0px;
...@@ -23,28 +24,6 @@ const Fader = styled.div` ...@@ -23,28 +24,6 @@ const Fader = styled.div`
transition: width 100ms linear; transition: width 100ms linear;
` `
function useInterval(callback, delay) {
const savedCallback = useRef()
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback
return () => {}
}, [callback])
// Set up the interval.
useEffect(() => {
function tick() {
savedCallback.current()
}
if (delay !== null) {
let id = setInterval(tick, delay)
return () => clearInterval(id)
}
return () => {}
}, [delay])
}
const delay = 100 const delay = 100
export default function TxnPopup({ hash, success, summary, popKey }) { export default function TxnPopup({ hash, success, summary, popKey }) {
...@@ -65,9 +44,9 @@ export default function TxnPopup({ hash, success, summary, popKey }) { ...@@ -65,9 +44,9 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
return ( return (
<AutoRow onMouseEnter={() => setIsRunning(false)} onMouseLeave={() => setIsRunning(true)}> <AutoRow onMouseEnter={() => setIsRunning(false)} onMouseLeave={() => setIsRunning(true)}>
{success ? ( {success ? (
<CheckCircle color={'#27AE60'} size={24} style={{ paddingRight: '24px' }} /> <CheckCircle color={'#27AE60'} size={24} style={{ paddingRight: '24px' }}/>
) : ( ) : (
<AlertCircle color={'#FF6871'} size={24} style={{ paddingRight: '24px' }} /> <AlertCircle color={'#FF6871'} size={24} style={{ paddingRight: '24px' }}/>
)} )}
<AutoColumn gap="8px"> <AutoColumn gap="8px">
<TYPE.body fontWeight={500}> <TYPE.body fontWeight={500}>
...@@ -75,7 +54,7 @@ export default function TxnPopup({ hash, success, summary, popKey }) { ...@@ -75,7 +54,7 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
</TYPE.body> </TYPE.body>
<Link href={getEtherscanLink(chainId, hash, 'transaction')}>View on Etherscan</Link> <Link href={getEtherscanLink(chainId, hash, 'transaction')}>View on Etherscan</Link>
</AutoColumn> </AutoColumn>
<Fader count={count} /> <Fader count={count}/>
</AutoRow> </AutoRow>
) )
} }
...@@ -2,7 +2,7 @@ import React from 'react' ...@@ -2,7 +2,7 @@ import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { Link } from '../../theme' import { Link } from '../../theme'
const InfoCard = styled.button` const InfoCard = styled.button<{ active?: boolean }>`
background-color: ${({ theme, active }) => (active ? theme.bg3 : theme.bg2)}; background-color: ${({ theme, active }) => (active ? theme.bg3 : theme.bg2)};
padding: 1rem; padding: 1rem;
outline: none; outline: none;
...@@ -30,7 +30,7 @@ const OptionCardLeft = styled.div` ...@@ -30,7 +30,7 @@ const OptionCardLeft = styled.div`
height: 100%; height: 100%;
` `
const OptionCardClickable = styled(OptionCard)` const OptionCardClickable = styled(OptionCard)<{ clickable?: boolean }>`
margin-top: 0; margin-top: 0;
&:hover { &:hover {
cursor: ${({ clickable }) => (clickable ? 'pointer' : '')}; cursor: ${({ clickable }) => (clickable ? 'pointer' : '')};
...@@ -73,7 +73,7 @@ const SubHeader = styled.div` ...@@ -73,7 +73,7 @@ const SubHeader = styled.div`
font-size: 12px; font-size: 12px;
` `
const IconWrapper = styled.div` const IconWrapper = styled.div<{ size?: number }>`
${({ theme }) => theme.flexColumnNoWrap}; ${({ theme }) => theme.flexColumnNoWrap};
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -97,7 +97,7 @@ export default function Option({ ...@@ -97,7 +97,7 @@ export default function Option({
subheader = null, subheader = null,
icon, icon,
active = false active = false
}) { }) {
const content = ( const content = (
<OptionCardClickable onClick={onClick} clickable={clickable && !active} active={active}> <OptionCardClickable onClick={onClick} clickable={clickable && !active} active={active}>
<OptionCardLeft> <OptionCardLeft>
...@@ -106,7 +106,7 @@ export default function Option({ ...@@ -106,7 +106,7 @@ export default function Option({
{active ? ( {active ? (
<CircleWrapper> <CircleWrapper>
<GreenCircle> <GreenCircle>
<div /> <div/>
</GreenCircle> </GreenCircle>
</CircleWrapper> </CircleWrapper>
) : ( ) : (
...@@ -116,8 +116,8 @@ export default function Option({ ...@@ -116,8 +116,8 @@ export default function Option({
</HeaderText> </HeaderText>
{subheader && <SubHeader>{subheader}</SubHeader>} {subheader && <SubHeader>{subheader}</SubHeader>}
</OptionCardLeft> </OptionCardLeft>
<IconWrapper size={size} active={active}> <IconWrapper size={size}>
<img src={icon} alt={'Icon'} /> <img src={icon} alt={'Icon'}/>
</IconWrapper> </IconWrapper>
</OptionCardClickable> </OptionCardClickable>
) )
......
...@@ -28,7 +28,7 @@ const SpinnerWrapper = styled(Spinner)` ...@@ -28,7 +28,7 @@ const SpinnerWrapper = styled(Spinner)`
} }
` `
const LoadingMessage = styled.div` const LoadingMessage = styled.div<{ error?: boolean }>`
${({ theme }) => theme.flexRowNoWrap}; ${({ theme }) => theme.flexRowNoWrap};
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
...@@ -71,14 +71,14 @@ const LoadingWrapper = styled.div` ...@@ -71,14 +71,14 @@ const LoadingWrapper = styled.div`
` `
export default function PendingView({ uri = '', size, connector, error = false, setPendingError, tryActivation }) { export default function PendingView({ uri = '', size, connector, error = false, setPendingError, tryActivation }) {
const isMetamask = window.ethereum && window.ethereum.isMetaMask const isMetamask = (window as any).ethereum && (window as any).ethereum.isMetaMask
return ( return (
<PendingSection> <PendingSection>
{!error && connector === walletconnect && <WalletConnectData size={size} uri={uri} />} {!error && connector === walletconnect && <WalletConnectData size={size} uri={uri}/>}
<LoadingMessage error={error}> <LoadingMessage error={error}>
<LoadingWrapper> <LoadingWrapper>
{!error && <SpinnerWrapper src={Circle} />} {!error && <SpinnerWrapper src={Circle}/>}
{error ? ( {error ? (
<ErrorGroup> <ErrorGroup>
<div>Error connecting.</div> <div>Error connecting.</div>
......
...@@ -11,12 +11,17 @@ const QRCodeWrapper = styled.div` ...@@ -11,12 +11,17 @@ const QRCodeWrapper = styled.div`
margin-bottom: 20px; margin-bottom: 20px;
` `
export default function WalletConnectData({ uri = '', size }) { interface WalletConnectDataProps {
uri?: string
size: number
}
export default function WalletConnectData({ uri = '', size }: WalletConnectDataProps) {
const [isDark] = useDarkModeManager() const [isDark] = useDarkModeManager()
return ( return (
<QRCodeWrapper> <QRCodeWrapper>
{uri && ( {uri && (
<QRCode size={size} value={uri} bgColor={isDark ? '#333639' : 'white'} fgColor={isDark ? 'white' : 'black'} /> <QRCode size={size} value={uri} bgColor={isDark ? '#333639' : 'white'} fgColor={isDark ? 'white' : 'black'}/>
)} )}
</QRCodeWrapper> </QRCodeWrapper>
) )
......
...@@ -122,7 +122,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -122,7 +122,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
const [pendingWallet, setPendingWallet] = useState() const [pendingWallet, setPendingWallet] = useState()
const [pendingError, setPendingError] = useState() const [pendingError, setPendingError] = useState<boolean>()
const walletModalOpen = useWalletModalOpen() const walletModalOpen = useWalletModalOpen()
const toggleWalletModal = useWalletModalToggle() const toggleWalletModal = useWalletModalToggle()
...@@ -200,7 +200,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -200,7 +200,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
// get wallets user can switch too, depending on device/browser // get wallets user can switch too, depending on device/browser
function getOptions() { function getOptions() {
const isMetamask = window.ethereum && window.ethereum.isMetaMask const isMetamask = (window as any).ethereum && (window as any).ethereum.isMetaMask
return Object.keys(SUPPORTED_WALLETS).map(key => { return Object.keys(SUPPORTED_WALLETS).map(key => {
const option = SUPPORTED_WALLETS[key] const option = SUPPORTED_WALLETS[key]
// check for mobile options // check for mobile options
...@@ -210,7 +210,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -210,7 +210,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return null return null
} }
if (!window.web3 && !window.ethereum && option.mobile) { if (!(window as any).web3 && !(window as any).ethereum && option.mobile) {
return ( return (
<Option <Option
onClick={() => { onClick={() => {
...@@ -232,7 +232,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -232,7 +232,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
// overwrite injected when needed // overwrite injected when needed
if (option.connector === injected) { if (option.connector === injected) {
// don't show injected if there's no injected provider // don't show injected if there's no injected provider
if (!(window.web3 || window.ethereum)) { if (!((window as any).web3 || (window as any).ethereum)) {
if (option.name === 'MetaMask') { if (option.name === 'MetaMask') {
return ( return (
<Option <Option
...@@ -286,7 +286,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -286,7 +286,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return ( return (
<UpperSection> <UpperSection>
<CloseIcon onClick={toggleWalletModal}> <CloseIcon onClick={toggleWalletModal}>
<CloseColor alt={'close icon'} /> <CloseColor/>
</CloseIcon> </CloseIcon>
<HeaderRow>{error instanceof UnsupportedChainIdError ? 'Wrong Network' : 'Error connecting'}</HeaderRow> <HeaderRow>{error instanceof UnsupportedChainIdError ? 'Wrong Network' : 'Error connecting'}</HeaderRow>
<ContentWrapper> <ContentWrapper>
...@@ -313,7 +313,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -313,7 +313,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return ( return (
<UpperSection> <UpperSection>
<CloseIcon onClick={toggleWalletModal}> <CloseIcon onClick={toggleWalletModal}>
<CloseColor alt={'close icon'} /> <CloseColor/>
</CloseIcon> </CloseIcon>
{walletView !== WALLET_VIEWS.ACCOUNT ? ( {walletView !== WALLET_VIEWS.ACCOUNT ? (
<HeaderRow color="blue"> <HeaderRow color="blue">
...@@ -359,7 +359,6 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions ...@@ -359,7 +359,6 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return ( return (
<Modal <Modal
style={{ userSelect: 'none' }}
isOpen={walletModalOpen} isOpen={walletModalOpen}
onDismiss={toggleWalletModal} onDismiss={toggleWalletModal}
minHeight={null} minHeight={null}
......
import { useEffect, useRef } from 'react'
export default function useInterval(callback: () => void, delay: null | number) {
const savedCallback = useRef<() => void>()
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback
return () => {
}
}, [callback])
// Set up the interval.
useEffect(() => {
function tick() {
savedCallback.current()
}
if (delay !== null) {
let id = setInterval(tick, delay)
return () => clearInterval(id)
}
return () => {
}
}, [delay])
}
\ No newline at end of file
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