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}
......
...@@ -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;
...@@ -88,16 +88,16 @@ const IconWrapper = styled.div` ...@@ -88,16 +88,16 @@ const IconWrapper = styled.div`
` `
export default function Option({ export default function Option({
link = null, link = null,
clickable = true, clickable = true,
size = null, size = null,
onClick = null, onClick = null,
color, color,
header, header,
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