From b6d8512316fbbe7ebb18fcaf08c456063d402e92 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 16 Feb 2021 08:36:54 +0000 Subject: [PATCH] Fix code style issues with ESLint --- cypress/integration/swap.test.ts | 22 ++- cypress/support/commands.js | 2 +- src/components/AccountDetails/index.tsx | 8 +- src/components/AddressInputPanel/index.tsx | 4 +- src/components/Confetti/index.tsx | 2 +- src/components/CurrencyInputPanel/index.tsx | 4 +- src/components/CurrencyLogo/index.tsx | 2 +- src/components/DoubleLogo/index.tsx | 2 +- .../FormattedCurrencyAmount/index.tsx | 2 +- src/components/Header/index.tsx | 8 +- src/components/LineChart/data.ts | 2 +- src/components/LineChart/index.tsx | 28 +-- src/components/ListLogo/index.tsx | 2 +- src/components/Logo/index.tsx | 4 +- src/components/Modal/index.tsx | 20 +- src/components/ModalViews/index.tsx | 2 +- src/components/NavigationTabs/index.tsx | 2 +- src/components/NumericalInput/index.tsx | 2 +- src/components/Popover/index.tsx | 8 +- src/components/Popups/ClaimPopup.tsx | 2 +- src/components/Popups/ListUpdatePopup.tsx | 4 +- src/components/Popups/PopupItem.tsx | 8 +- src/components/Popups/TransactionPopup.tsx | 2 +- src/components/Popups/index.tsx | 4 +- src/components/PositionCard/index.tsx | 4 +- src/components/SearchModal/CommonBases.tsx | 2 +- src/components/SearchModal/CurrencyList.tsx | 6 +- src/components/SearchModal/CurrencySearch.tsx | 6 +- .../SearchModal/CurrencySearchModal.tsx | 4 +- src/components/SearchModal/ImportList.tsx | 6 +- src/components/SearchModal/ImportRow.tsx | 2 +- src/components/SearchModal/ImportToken.tsx | 4 +- src/components/SearchModal/Manage.tsx | 2 +- src/components/SearchModal/ManageLists.tsx | 28 +-- src/components/SearchModal/ManageTokens.tsx | 8 +- src/components/SearchModal/SortButton.tsx | 2 +- src/components/SearchModal/filtering.ts | 14 +- src/components/SearchModal/styleds.tsx | 4 +- src/components/Settings/index.tsx | 2 +- src/components/Slider/index.tsx | 2 +- src/components/TokenWarningModal/index.tsx | 2 +- .../TransactionConfirmationModal/index.tsx | 6 +- src/components/TransactionSettings/index.tsx | 10 +- src/components/WalletModal/Option.tsx | 4 +- src/components/WalletModal/PendingView.tsx | 4 +- src/components/WalletModal/index.tsx | 14 +- src/components/Web3Status/index.tsx | 6 +- src/components/claim/AddressClaimModal.tsx | 4 +- src/components/claim/ClaimModal.tsx | 2 +- src/components/earn/ClaimRewardModal.tsx | 2 +- src/components/earn/StakingModal.tsx | 20 +- src/components/earn/UnstakingModal.tsx | 2 +- src/components/swap/BetterTradeLink.tsx | 8 +- src/components/swap/ConfirmSwapModal.tsx | 4 +- src/components/swap/SwapModalFooter.tsx | 8 +- src/components/swap/SwapModalHeader.tsx | 4 +- .../swap/UnsupportedCurrencyFooter.tsx | 6 +- src/components/vote/DelegateModal.tsx | 2 +- src/components/vote/VoteModal.tsx | 4 +- src/connectors/Fortmatic.ts | 6 +- src/connectors/NetworkConnector.ts | 12 +- src/connectors/index.ts | 12 +- src/constants/index.ts | 42 ++-- src/constants/lists.ts | 2 +- src/constants/multicall/index.ts | 2 +- src/constants/v1/index.ts | 2 +- src/data/Allowances.ts | 2 +- src/data/Reserves.ts | 6 +- src/data/V1.ts | 10 +- src/hooks/Tokens.ts | 4 +- src/hooks/Trades.ts | 8 +- src/hooks/index.ts | 6 +- src/hooks/useAddTokenToMetamask.ts | 8 +- src/hooks/useApproveCallback.ts | 6 +- src/hooks/useColor.ts | 8 +- src/hooks/useContract.ts | 2 +- src/hooks/useCopyClipboard.ts | 2 +- src/hooks/useENS.ts | 2 +- src/hooks/useENSAddress.ts | 2 +- src/hooks/useENSContentHash.ts | 2 +- src/hooks/useENSName.ts | 2 +- src/hooks/useFetchListCallback.ts | 4 +- src/hooks/useLast.ts | 2 +- src/hooks/useSwapCallback.ts | 34 ++-- src/hooks/useToggle.ts | 2 +- src/hooks/useToggledVersion.ts | 2 +- src/hooks/useTransactionDeadline.ts | 2 +- src/hooks/useWindowSize.ts | 2 +- src/hooks/useWrapCallback.ts | 6 +- src/i18n.ts | 6 +- src/index.tsx | 10 +- .../AddLiquidity/ConfirmAddModalBottom.tsx | 2 +- src/pages/AddLiquidity/PoolPriceBar.tsx | 2 +- src/pages/AddLiquidity/index.tsx | 35 ++-- src/pages/AddLiquidity/redirects.tsx | 8 +- src/pages/App.tsx | 2 +- src/pages/Earn/Countdown.tsx | 2 +- src/pages/Earn/Manage.tsx | 4 +- src/pages/Earn/index.tsx | 4 +- src/pages/MigrateV1/MigrateV1Exchange.tsx | 22 ++- src/pages/MigrateV1/RemoveV1Exchange.tsx | 10 +- src/pages/MigrateV1/index.tsx | 10 +- src/pages/Pool/index.tsx | 20 +- src/pages/PoolFinder/index.tsx | 2 +- src/pages/RemoveLiquidity/index.tsx | 59 +++--- src/pages/RemoveLiquidity/redirects.tsx | 4 +- src/pages/Swap/index.tsx | 40 ++-- src/pages/Swap/redirects.tsx | 6 +- src/pages/Vote/VotePage.tsx | 4 +- src/react-app-env.d.ts | 2 +- src/state/application/actions.ts | 2 +- src/state/application/hooks.ts | 2 +- src/state/application/reducer.test.ts | 6 +- src/state/application/reducer.ts | 12 +- src/state/application/updater.ts | 6 +- src/state/burn/actions.ts | 2 +- src/state/burn/hooks.ts | 10 +- src/state/burn/reducer.ts | 6 +- src/state/claim/hooks.ts | 16 +- src/state/governance/hooks.ts | 18 +- src/state/index.ts | 4 +- src/state/lists/actions.ts | 2 +- src/state/lists/hooks.ts | 20 +- src/state/lists/reducer.test.ts | 182 +++++++++--------- src/state/lists/reducer.ts | 28 +-- src/state/lists/updater.ts | 10 +- src/state/mint/actions.ts | 2 +- src/state/mint/hooks.ts | 16 +- src/state/mint/reducer.test.ts | 2 +- src/state/mint/reducer.ts | 10 +- src/state/multicall/actions.test.ts | 10 +- src/state/multicall/actions.ts | 2 +- src/state/multicall/hooks.ts | 38 ++-- src/state/multicall/reducer.test.ts | 136 ++++++------- src/state/multicall/reducer.ts | 20 +- src/state/multicall/updater.test.ts | 54 +++--- src/state/multicall/updater.tsx | 28 ++- src/state/stake/hooks.ts | 22 +-- src/state/swap/actions.ts | 2 +- src/state/swap/hooks.test.ts | 16 +- src/state/swap/hooks.ts | 32 +-- src/state/swap/reducer.test.ts | 6 +- src/state/swap/reducer.ts | 24 +-- src/state/transactions/hooks.tsx | 8 +- src/state/transactions/reducer.test.ts | 30 +-- src/state/transactions/reducer.ts | 4 +- src/state/transactions/updater.tsx | 18 +- src/state/user/hooks.tsx | 28 +-- src/state/user/reducer.test.ts | 2 +- src/state/user/reducer.ts | 10 +- src/state/wallet/hooks.ts | 14 +- src/theme/DarkModeQueryParamReader.tsx | 2 +- src/theme/components.tsx | 2 +- src/theme/index.tsx | 12 +- src/utils/chunkArray.test.ts | 6 +- src/utils/chunkArray.ts | 2 +- src/utils/index.test.ts | 10 +- src/utils/index.ts | 4 +- src/utils/prices.test.ts | 2 +- src/utils/prices.ts | 2 +- src/utils/resolveENSContentHash.ts | 24 +-- src/utils/retry.ts | 4 +- src/utils/uriToHttp.test.ts | 4 +- src/utils/useUSDCPrice.ts | 4 +- src/utils/v1SwapArgument.test.ts | 12 +- src/utils/v1SwapArguments.ts | 14 +- 166 files changed, 889 insertions(+), 885 deletions(-) diff --git a/cypress/integration/swap.test.ts b/cypress/integration/swap.test.ts index c8e2c4b9e6..06cedb3f55 100644 --- a/cypress/integration/swap.test.ts +++ b/cypress/integration/swap.test.ts @@ -3,23 +3,33 @@ describe('Swap', () => { cy.visit('/swap') }) it('can enter an amount into input', () => { - cy.get('#swap-currency-input .token-amount-input').type('0.001', { delay: 200 }).should('have.value', '0.001') + cy.get('#swap-currency-input .token-amount-input') + .type('0.001', { delay: 200 }) + .should('have.value', '0.001') }) it('zero swap amount', () => { - cy.get('#swap-currency-input .token-amount-input').type('0.0', { delay: 200 }).should('have.value', '0.0') + cy.get('#swap-currency-input .token-amount-input') + .type('0.0', { delay: 200 }) + .should('have.value', '0.0') }) it('invalid swap amount', () => { - cy.get('#swap-currency-input .token-amount-input').type('\\', { delay: 200 }).should('have.value', '') + cy.get('#swap-currency-input .token-amount-input') + .type('\\', { delay: 200 }) + .should('have.value', '') }) it('can enter an amount into output', () => { - cy.get('#swap-currency-output .token-amount-input').type('0.001', { delay: 200 }).should('have.value', '0.001') + cy.get('#swap-currency-output .token-amount-input') + .type('0.001', { delay: 200 }) + .should('have.value', '0.001') }) it('zero output amount', () => { - cy.get('#swap-currency-output .token-amount-input').type('0.0', { delay: 200 }).should('have.value', '0.0') + cy.get('#swap-currency-output .token-amount-input') + .type('0.0', { delay: 200 }) + .should('have.value', '0.0') }) it('can swap ETH for DAI', () => { @@ -39,7 +49,7 @@ describe('Swap', () => { describe('expert mode', () => { beforeEach(() => { - cy.window().then((win) => { + cy.window().then(win => { cy.stub(win, 'prompt').returns('confirm') }) cy.get('#open-settings-dialog-button').click() diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 8e4316a27a..a2c0deb52f 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -77,6 +77,6 @@ Cypress.Commands.overwrite('visit', (original, url, options) => { const provider = new JsonRpcProvider('https://rinkeby.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 4) const signer = new Wallet(PRIVATE_KEY_TEST_NEVER_USE, provider) win.ethereum = new CustomizedBridge(signer, provider) - }, + } }) }) diff --git a/src/components/AccountDetails/index.tsx b/src/components/AccountDetails/index.tsx index 408f499998..a7d185a810 100644 --- a/src/components/AccountDetails/index.tsx +++ b/src/components/AccountDetails/index.tsx @@ -26,7 +26,7 @@ const HeaderRow = styled.div` ${({ theme }) => theme.flexRowNoWrap}; padding: 1rem 1rem; font-weight: 500; - color: ${(props) => (props.color === 'blue' ? ({ theme }) => theme.primary1 : 'inherit')}; + color: ${props => (props.color === 'blue' ? ({ theme }) => theme.primary1 : 'inherit')}; ${({ theme }) => theme.mediaWidth.upToMedium` padding: 1rem; `}; @@ -223,7 +223,7 @@ export default function AccountDetails({ pendingTransactions, confirmedTransactions, ENSName, - openOptions, + openOptions }: AccountDetailsProps) { const { chainId, account, connector } = useActiveWeb3React() const theme = useContext(ThemeContext) @@ -234,10 +234,10 @@ export default function AccountDetails({ const isMetaMask = !!(ethereum && ethereum.isMetaMask) const name = Object.keys(SUPPORTED_WALLETS) .filter( - (k) => + k => SUPPORTED_WALLETS[k].connector === connector && (connector !== injected || isMetaMask === (k === 'METAMASK')) ) - .map((k) => SUPPORTED_WALLETS[k].name)[0] + .map(k => SUPPORTED_WALLETS[k].name)[0] return Connected with {name} } diff --git a/src/components/AddressInputPanel/index.tsx b/src/components/AddressInputPanel/index.tsx index f55b18911b..f98a923969 100644 --- a/src/components/AddressInputPanel/index.tsx +++ b/src/components/AddressInputPanel/index.tsx @@ -68,7 +68,7 @@ const Input = styled.input<{ error?: boolean }>` export default function AddressInputPanel({ id, value, - onChange, + onChange }: { id?: string // the typed string value @@ -82,7 +82,7 @@ export default function AddressInputPanel({ const { address, loading, name } = useENS(value) const handleInput = useCallback( - (event) => { + event => { const input = event.target.value const withoutSpaces = input.replace(/\s+/g, '') onChange(withoutSpaces) diff --git a/src/components/Confetti/index.tsx b/src/components/Confetti/index.tsx index 5a9f22cd96..a8c63a9987 100644 --- a/src/components/Confetti/index.tsx +++ b/src/components/Confetti/index.tsx @@ -20,7 +20,7 @@ export default function Confetti({ start, variant }: { start: boolean; variant?: h: height, w: width, x: 0, - y: _variant === 'top' ? height * 0.25 : _variant === 'bottom' ? height * 0.75 : height * 0.5, + y: _variant === 'top' ? height * 0.25 : _variant === 'bottom' ? height * 0.75 : height * 0.5 }} initialVelocityX={15} initialVelocityY={30} diff --git a/src/components/CurrencyInputPanel/index.tsx b/src/components/CurrencyInputPanel/index.tsx index f563948046..86af0c7ade 100644 --- a/src/components/CurrencyInputPanel/index.tsx +++ b/src/components/CurrencyInputPanel/index.tsx @@ -147,7 +147,7 @@ export default function CurrencyInputPanel({ otherCurrency, id, showCommonBases, - customBalanceText, + customBalanceText }: CurrencyInputPanelProps) { const { t } = useTranslation() @@ -191,7 +191,7 @@ export default function CurrencyInputPanel({ { + onUserInput={val => { onUserInput(val) }} /> diff --git a/src/components/CurrencyLogo/index.tsx b/src/components/CurrencyLogo/index.tsx index 36b3562e2a..a4bd991e60 100644 --- a/src/components/CurrencyLogo/index.tsx +++ b/src/components/CurrencyLogo/index.tsx @@ -28,7 +28,7 @@ const StyledLogo = styled(Logo)<{ size: string }>` export default function CurrencyLogo({ currency, size = '24px', - style, + style }: { currency?: Currency size?: string diff --git a/src/components/DoubleLogo/index.tsx b/src/components/DoubleLogo/index.tsx index a6da21a756..0e19ccf3ae 100644 --- a/src/components/DoubleLogo/index.tsx +++ b/src/components/DoubleLogo/index.tsx @@ -29,7 +29,7 @@ export default function DoubleCurrencyLogo({ currency0, currency1, size = 16, - margin = false, + margin = false }: DoubleCurrencyLogoProps) { return ( diff --git a/src/components/FormattedCurrencyAmount/index.tsx b/src/components/FormattedCurrencyAmount/index.tsx index 425c4eab97..0bd2a4516f 100644 --- a/src/components/FormattedCurrencyAmount/index.tsx +++ b/src/components/FormattedCurrencyAmount/index.tsx @@ -5,7 +5,7 @@ const CURRENCY_AMOUNT_MIN = new Fraction(JSBI.BigInt(1), JSBI.BigInt(1000000)) export default function FormattedCurrencyAmount({ currencyAmount, - significantDigits = 4, + significantDigits = 4 }: { currencyAmount: CurrencyAmount significantDigits?: number diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 09d9dccce0..c936dfa098 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -201,7 +201,7 @@ const UniIcon = styled.div` const activeClassName = 'ACTIVE' const StyledNavLink = styled(NavLink).attrs({ - activeClassName, + activeClassName })` ${({ theme }) => theme.flexRowNoWrap} align-items: left; @@ -228,7 +228,7 @@ const StyledNavLink = styled(NavLink).attrs({ ` const StyledExternalLink = styled(ExternalLink).attrs({ - activeClassName, + activeClassName })<{ isActive?: boolean }>` ${({ theme }) => theme.flexRowNoWrap} align-items: left; @@ -291,7 +291,7 @@ const NETWORK_LABELS: { [chainId in ChainId]?: string } = { [ChainId.RINKEBY]: 'Rinkeby', [ChainId.ROPSTEN]: 'Ropsten', [ChainId.GÖRLI]: 'Görli', - [ChainId.KOVAN]: 'Kovan', + [ChainId.KOVAN]: 'Kovan' } export default function Header() { @@ -380,7 +380,7 @@ export default function Header() { (0) - const src: string | undefined = srcs.find((src) => !BAD_SRCS[src]) + const src: string | undefined = srcs.find(src => !BAD_SRCS[src]) if (src) { return ( @@ -24,7 +24,7 @@ export default function Logo({ srcs, alt, ...rest }: LogoProps) { src={src} onError={() => { if (src) BAD_SRCS[src] = true - refresh((i) => i + 1) + refresh(i => i + 1) }} /> ) diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index c1c027ed68..d10b4d2a35 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -29,7 +29,7 @@ const AnimatedDialogContent = animated(DialogContent) const StyledDialogContent = styled(({ minHeight, maxHeight, mobile, isOpen, ...rest }) => ( )).attrs({ - 'aria-label': 'dialog', + 'aria-label': 'dialog' })` overflow-y: ${({ mobile }) => (mobile ? 'scroll' : 'hidden')}; @@ -63,15 +63,13 @@ const StyledDialogContent = styled(({ minHeight, maxHeight, mobile, isOpen, ...r `} ${({ theme, mobile }) => theme.mediaWidth.upToSmall` width: 85vw; - ${ - mobile && + ${mobile && css` width: 100vw; border-radius: 20px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; - ` - } + `} `} } ` @@ -91,25 +89,25 @@ export default function Modal({ minHeight = false, maxHeight = 90, initialFocusRef, - children, + children }: ModalProps) { const fadeTransition = useTransition(isOpen, null, { config: { duration: 200 }, from: { opacity: 0 }, enter: { opacity: 1 }, - leave: { opacity: 0 }, + leave: { opacity: 0 } }) const [{ y }, set] = useSpring(() => ({ y: 0, config: { mass: 1, tension: 210, friction: 20 } })) const bind = useGesture({ - onDrag: (state) => { + onDrag: state => { set({ - y: state.down ? state.movement[1] : 0, + y: state.down ? state.movement[1] : 0 }) if (state.movement[1] > 300 || (state.velocity > 3 && state.direction[1] > 0)) { onDismiss() } - }, + } }) return ( @@ -122,7 +120,7 @@ export default function Modal({ {...(isMobile ? { ...bind(), - style: { transform: y.interpolate((y) => `translateY(${y > 0 ? y : 0}px)`) }, + style: { transform: y.interpolate(y => `translateY(${y > 0 ? y : 0}px)`) } } : {})} aria-label="dialog content" diff --git a/src/components/ModalViews/index.tsx b/src/components/ModalViews/index.tsx index a1b384c623..ad841d3108 100644 --- a/src/components/ModalViews/index.tsx +++ b/src/components/ModalViews/index.tsx @@ -41,7 +41,7 @@ export function LoadingView({ children, onDismiss }: { children: any; onDismiss: export function SubmittedView({ children, onDismiss, - hash, + hash }: { children: any onDismiss: () => void diff --git a/src/components/NavigationTabs/index.tsx b/src/components/NavigationTabs/index.tsx index 0eadd62db1..eda9706265 100644 --- a/src/components/NavigationTabs/index.tsx +++ b/src/components/NavigationTabs/index.tsx @@ -22,7 +22,7 @@ const Tabs = styled.div` const activeClassName = 'ACTIVE' const StyledNavLink = styled(NavLink).attrs({ - activeClassName, + activeClassName })` ${({ theme }) => theme.flexRowNoWrap} align-items: center; diff --git a/src/components/NumericalInput/index.tsx b/src/components/NumericalInput/index.tsx index 37d7c20c16..3fcb1a1778 100644 --- a/src/components/NumericalInput/index.tsx +++ b/src/components/NumericalInput/index.tsx @@ -61,7 +61,7 @@ export const Input = React.memo(function InnerInput({ { + onChange={event => { // replace commas with periods, because uniswap exclusively uses period as the decimal separator enforcer(event.target.value.replace(/,/g, '.')) }} diff --git a/src/components/Popover/index.tsx b/src/components/Popover/index.tsx index 933b1d87ab..623f2051eb 100644 --- a/src/components/Popover/index.tsx +++ b/src/components/Popover/index.tsx @@ -9,8 +9,8 @@ import Portal from '@reach/portal' const PopoverContainer = styled.div<{ show: boolean }>` z-index: 9999; - visibility: ${(props) => (props.show ? 'visible' : 'hidden')}; - opacity: ${(props) => (props.show ? 1 : 0)}; + visibility: ${props => (props.show ? 'visible' : 'hidden')}; + opacity: ${props => (props.show ? 1 : 0)}; transition: visibility 150ms linear, opacity 150ms linear; background: ${({ theme }) => theme.bg2}; @@ -91,8 +91,8 @@ export default function Popover({ content, show, children, placement = 'auto' }: strategy: 'fixed', modifiers: [ { name: 'offset', options: { offset: [8, 8] } }, - { name: 'arrow', options: { element: arrowElement } }, - ], + { name: 'arrow', options: { element: arrowElement } } + ] }) const updateCallback = useCallback(() => { update && update() diff --git a/src/components/Popups/ClaimPopup.tsx b/src/components/Popups/ClaimPopup.tsx index 7998707deb..938483ca86 100644 --- a/src/components/Popups/ClaimPopup.tsx +++ b/src/components/Popups/ClaimPopup.tsx @@ -10,7 +10,7 @@ import { useModalOpen, useShowClaimPopup, useToggleSelfClaimModal, - useToggleShowClaimPopup, + useToggleShowClaimPopup } from '../../state/application/hooks' import { useUserHasAvailableClaim, useUserUnclaimedAmount } from '../../state/claim/hooks' diff --git a/src/components/Popups/ListUpdatePopup.tsx b/src/components/Popups/ListUpdatePopup.tsx index a25dd33931..57a2bb7d2e 100644 --- a/src/components/Popups/ListUpdatePopup.tsx +++ b/src/components/Popups/ListUpdatePopup.tsx @@ -23,7 +23,7 @@ export default function ListUpdatePopup({ listUrl, oldList, newList, - auto, + auto }: { popKey: string listUrl: string @@ -40,7 +40,7 @@ export default function ListUpdatePopup({ ReactGA.event({ category: 'Lists', action: 'Update List from Popup', - label: listUrl, + label: listUrl }) dispatch(acceptListUpdate(listUrl)) removeThisPopup() diff --git a/src/components/Popups/PopupItem.tsx b/src/components/Popups/PopupItem.tsx index 26e8b3e369..895fd6e427 100644 --- a/src/components/Popups/PopupItem.tsx +++ b/src/components/Popups/PopupItem.tsx @@ -49,7 +49,7 @@ const AnimatedFader = animated(Fader) export default function PopupItem({ removeAfterMs, content, - popKey, + popKey }: { removeAfterMs: number | null content: PopupContent @@ -74,12 +74,12 @@ export default function PopupItem({ let popupContent if ('txn' in content) { const { - txn: { hash, success, summary }, + txn: { hash, success, summary } } = content popupContent = } else if ('listUpdate' in content) { const { - listUpdate: { listUrl, oldList, newList, auto }, + listUpdate: { listUrl, oldList, newList, auto } } = content popupContent = } @@ -87,7 +87,7 @@ export default function PopupItem({ const faderStyle = useSpring({ from: { width: '100%' }, to: { width: '0%' }, - config: { duration: removeAfterMs ?? undefined }, + config: { duration: removeAfterMs ?? undefined } }) return ( diff --git a/src/components/Popups/TransactionPopup.tsx b/src/components/Popups/TransactionPopup.tsx index d19d148c3e..ab8d8dfdcf 100644 --- a/src/components/Popups/TransactionPopup.tsx +++ b/src/components/Popups/TransactionPopup.tsx @@ -15,7 +15,7 @@ const RowNoFlex = styled(AutoRow)` export default function TransactionPopup({ hash, success, - summary, + summary }: { hash: string success?: boolean diff --git a/src/components/Popups/index.tsx b/src/components/Popups/index.tsx index 935fdc28b2..5490a81b4c 100644 --- a/src/components/Popups/index.tsx +++ b/src/components/Popups/index.tsx @@ -54,7 +54,7 @@ export default function Popups() { <> - {activePopups.map((item) => ( + {activePopups.map(item => ( ))} @@ -63,7 +63,7 @@ export default function Popups() { {activePopups // reverse so new items up front .slice(0) .reverse() - .map((item) => ( + .map(item => ( ))} diff --git a/src/components/PositionCard/index.tsx b/src/components/PositionCard/index.tsx index 5166dc2bee..733822d13c 100644 --- a/src/components/PositionCard/index.tsx +++ b/src/components/PositionCard/index.tsx @@ -75,7 +75,7 @@ export function MinimalPositionCard({ pair, showUnwrapped = false, border }: Pos JSBI.greaterThanOrEqual(totalPoolTokens.raw, userPoolBalance.raw) ? [ pair.getLiquidityValue(pair.token0, totalPoolTokens, userPoolBalance, false), - pair.getLiquidityValue(pair.token1, totalPoolTokens, userPoolBalance, false), + pair.getLiquidityValue(pair.token1, totalPoolTokens, userPoolBalance, false) ] : [undefined, undefined] @@ -186,7 +186,7 @@ export default function FullPositionCard({ pair, border, stakedBalance }: Positi JSBI.greaterThanOrEqual(totalPoolTokens.raw, userPoolBalance.raw) ? [ pair.getLiquidityValue(pair.token0, totalPoolTokens, userPoolBalance, false), - pair.getLiquidityValue(pair.token1, totalPoolTokens, userPoolBalance, false), + pair.getLiquidityValue(pair.token1, totalPoolTokens, userPoolBalance, false) ] : [undefined, undefined] diff --git a/src/components/SearchModal/CommonBases.tsx b/src/components/SearchModal/CommonBases.tsx index 30c7e9b4f1..25b28af401 100644 --- a/src/components/SearchModal/CommonBases.tsx +++ b/src/components/SearchModal/CommonBases.tsx @@ -28,7 +28,7 @@ const BaseWrapper = styled.div<{ disable?: boolean }>` export default function CommonBases({ chainId, onSelect, - selectedCurrency, + selectedCurrency }: { chainId?: ChainId selectedCurrency?: Currency | null diff --git a/src/components/SearchModal/CurrencyList.tsx b/src/components/SearchModal/CurrencyList.tsx index 4dd1ae176b..56c70ce9a4 100644 --- a/src/components/SearchModal/CurrencyList.tsx +++ b/src/components/SearchModal/CurrencyList.tsx @@ -102,7 +102,7 @@ function CurrencyRow({ onSelect, isSelected, otherSelected, - style, + style }: { currency: Currency onSelect: () => void @@ -153,7 +153,7 @@ export default function CurrencyList({ showETH, showImportView, setImportToken, - breakIndex, + breakIndex }: { height: number currencies: Currency[] @@ -241,7 +241,7 @@ export default function CurrencyList({ setImportToken, showImportView, breakIndex, - theme.text1, + theme.text1 ] ) diff --git a/src/components/SearchModal/CurrencySearch.tsx b/src/components/SearchModal/CurrencySearch.tsx index a55763b0fd..2cfa06911a 100644 --- a/src/components/SearchModal/CurrencySearch.tsx +++ b/src/components/SearchModal/CurrencySearch.tsx @@ -61,7 +61,7 @@ export function CurrencySearch({ isOpen, showManageView, showImportView, - setImportToken, + setImportToken }: CurrencySearchProps) { const { t } = useTranslation() const { chainId } = useActiveWeb3React() @@ -87,7 +87,7 @@ export function CurrencySearch({ ReactGA.event({ category: 'Currency Select', action: 'Search by address', - label: isAddressSearch, + label: isAddressSearch }) } }, [isAddressSearch]) @@ -124,7 +124,7 @@ export function CurrencySearch({ // manage focus on modal show const inputRef = useRef() - const handleInput = useCallback((event) => { + const handleInput = useCallback(event => { const input = event.target.value const checksummedInput = isAddress(input) setSearchQuery(checksummedInput || input) diff --git a/src/components/SearchModal/CurrencySearchModal.tsx b/src/components/SearchModal/CurrencySearchModal.tsx index f27bc8e1e1..ba71295037 100644 --- a/src/components/SearchModal/CurrencySearchModal.tsx +++ b/src/components/SearchModal/CurrencySearchModal.tsx @@ -22,7 +22,7 @@ export enum CurrencyModalView { search, manage, importToken, - importList, + importList } export default function CurrencySearchModal({ @@ -31,7 +31,7 @@ export default function CurrencySearchModal({ onCurrencySelect, selectedCurrency, otherSelectedCurrency, - showCommonBases = false, + showCommonBases = false }: CurrencySearchModalProps) { const [modalView, setModalView] = useState(CurrencyModalView.manage) const lastOpen = useLast(isOpen) diff --git a/src/components/SearchModal/ImportList.tsx b/src/components/SearchModal/ImportList.tsx index 2d15195a47..042ba5a3a7 100644 --- a/src/components/SearchModal/ImportList.tsx +++ b/src/components/SearchModal/ImportList.tsx @@ -56,7 +56,7 @@ export function ImportList({ listURL, list, setModalView, onDismiss }: ImportPro ReactGA.event({ category: 'Lists', action: 'Add List', - label: listURL, + label: listURL }) // turn list on @@ -64,11 +64,11 @@ export function ImportList({ listURL, list, setModalView, onDismiss }: ImportPro // go back to lists setModalView(CurrencyModalView.manage) }) - .catch((error) => { + .catch(error => { ReactGA.event({ category: 'Lists', action: 'Add List Failed', - label: listURL, + label: listURL }) setAddError(error.message) dispatch(removeList(listURL)) diff --git a/src/components/SearchModal/ImportRow.tsx b/src/components/SearchModal/ImportRow.tsx index 097ee15f57..7d6a8cc9a0 100644 --- a/src/components/SearchModal/ImportRow.tsx +++ b/src/components/SearchModal/ImportRow.tsx @@ -45,7 +45,7 @@ export default function ImportRow({ style, dim, showImportView, - setImportToken, + setImportToken }: { token: Token style?: CSSProperties diff --git a/src/components/SearchModal/ImportToken.tsx b/src/components/SearchModal/ImportToken.tsx index 4e79f155ce..5f720b51d2 100644 --- a/src/components/SearchModal/ImportToken.tsx +++ b/src/components/SearchModal/ImportToken.tsx @@ -74,7 +74,7 @@ export function ImportToken({ tokens, onBack, onDismiss, handleCurrencySelect }: - {tokens.map((token) => { + {tokens.map(token => { const list = chainId && inactiveTokenList?.[chainId]?.[token.address]?.list return ( @@ -151,7 +151,7 @@ export function ImportToken({ tokens, onBack, onDismiss, handleCurrencySelect }: borderRadius="20px" padding="10px 1rem" onClick={() => { - tokens.map((token) => addToken(token)) + tokens.map(token => addToken(token)) handleCurrencySelect && handleCurrencySelect(tokens[0]) }} className=".token-dismiss-button" diff --git a/src/components/SearchModal/Manage.tsx b/src/components/SearchModal/Manage.tsx index 4f6e66445e..4ff353470b 100644 --- a/src/components/SearchModal/Manage.tsx +++ b/src/components/SearchModal/Manage.tsx @@ -46,7 +46,7 @@ export default function Manage({ setModalView, setImportList, setImportToken, - setListUrl, + setListUrl }: { onDismiss: () => void setModalView: (view: CurrencyModalView) => void diff --git a/src/components/SearchModal/ManageLists.tsx b/src/components/SearchModal/ManageLists.tsx index d011ca98ed..ff3fea44f5 100644 --- a/src/components/SearchModal/ManageLists.tsx +++ b/src/components/SearchModal/ManageLists.tsx @@ -42,8 +42,8 @@ const UnpaddedLinkStyledButton = styled(LinkStyledButton)` const PopoverContainer = styled.div<{ show: boolean }>` z-index: 100; - visibility: ${(props) => (props.show ? 'visible' : 'hidden')}; - opacity: ${(props) => (props.show ? 1 : 0)}; + visibility: ${props => (props.show ? 'visible' : 'hidden')}; + opacity: ${props => (props.show ? 1 : 0)}; transition: visibility 150ms linear, opacity 150ms linear; background: ${({ theme }) => theme.bg2}; border: 1px solid ${({ theme }) => theme.bg3}; @@ -93,7 +93,7 @@ function listUrlRowHTMLId(listUrl: string) { } const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { - const listsByUrl = useSelector((state) => state.lists.byUrl) + const listsByUrl = useSelector(state => state.lists.byUrl) const dispatch = useDispatch() const { current: list, pendingUpdate: pending } = listsByUrl[listUrl] @@ -109,7 +109,7 @@ const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: 'auto', strategy: 'fixed', - modifiers: [{ name: 'offset', options: { offset: [8, 8] } }], + modifiers: [{ name: 'offset', options: { offset: [8, 8] } }] }) useOnClickOutside(node, open ? toggle : undefined) @@ -119,7 +119,7 @@ const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { ReactGA.event({ category: 'Lists', action: 'Update List from List Select', - label: listUrl, + label: listUrl }) dispatch(acceptListUpdate(listUrl)) }, [dispatch, listUrl, pending]) @@ -128,13 +128,13 @@ const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { ReactGA.event({ category: 'Lists', action: 'Start Remove List', - label: listUrl, + label: listUrl }) if (window.prompt(`Please confirm you would like to remove this list by typing REMOVE`) === `REMOVE`) { ReactGA.event({ category: 'Lists', action: 'Confirm Remove List', - label: listUrl, + label: listUrl }) dispatch(removeList(listUrl)) } @@ -144,7 +144,7 @@ const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { ReactGA.event({ category: 'Lists', action: 'Enable List', - label: listUrl, + label: listUrl }) dispatch(enableList(listUrl)) }, [dispatch, listUrl]) @@ -153,7 +153,7 @@ const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { ReactGA.event({ category: 'Lists', action: 'Disable List', - label: listUrl, + label: listUrl }) dispatch(disableList(listUrl)) }, [dispatch, listUrl]) @@ -216,7 +216,7 @@ const ListContainer = styled.div` export function ManageLists({ setModalView, setImportList, - setListUrl, + setListUrl }: { setModalView: (view: CurrencyModalView) => void setImportList: (list: TokenList) => void @@ -237,7 +237,7 @@ export function ManageLists({ } }, [activeCopy, activeListUrls]) - const handleInput = useCallback((e) => { + const handleInput = useCallback(e => { setListUrlInput(e.target.value) }, []) @@ -250,7 +250,7 @@ export function ManageLists({ const sortedLists = useMemo(() => { const listUrls = Object.keys(lists) return listUrls - .filter((listUrl) => { + .filter(listUrl => { // only show loaded lists, hide unsupported lists return Boolean(lists[listUrl].current) && !Boolean(UNSUPPORTED_LIST_URLS.includes(listUrl)) }) @@ -286,7 +286,7 @@ export function ManageLists({ useEffect(() => { async function fetchTempList() { fetchList(listUrlInput, false) - .then((list) => setTempList(list)) + .then(list => setTempList(list)) .catch(() => setAddError('Error importing list')) } // if valid url, fetch details for card @@ -367,7 +367,7 @@ export function ManageLists({ - {sortedLists.map((listUrl) => ( + {sortedLists.map(listUrl => ( ))} diff --git a/src/components/SearchModal/ManageTokens.tsx b/src/components/SearchModal/ManageTokens.tsx index 816bef5f43..6db13af423 100644 --- a/src/components/SearchModal/ManageTokens.tsx +++ b/src/components/SearchModal/ManageTokens.tsx @@ -37,7 +37,7 @@ const Footer = styled.div` export default function ManageTokens({ setModalView, - setImportToken, + setImportToken }: { setModalView: (view: CurrencyModalView) => void setImportToken: (token: Token) => void @@ -49,7 +49,7 @@ export default function ManageTokens({ // manage focus on modal show const inputRef = useRef() - const handleInput = useCallback((event) => { + const handleInput = useCallback(event => { const input = event.target.value const checksummedInput = isAddress(input) setSearchQuery(checksummedInput || input) @@ -65,7 +65,7 @@ export default function ManageTokens({ const handleRemoveAll = useCallback(() => { if (chainId && userAddedTokens) { - userAddedTokens.map((token) => { + userAddedTokens.map(token => { return removeToken(chainId, token.address) }) } @@ -74,7 +74,7 @@ export default function ManageTokens({ const tokenList = useMemo(() => { return ( chainId && - userAddedTokens.map((token) => ( + userAddedTokens.map(token => ( diff --git a/src/components/SearchModal/SortButton.tsx b/src/components/SearchModal/SortButton.tsx index 9d2742e5d2..939eeb1d70 100644 --- a/src/components/SearchModal/SortButton.tsx +++ b/src/components/SearchModal/SortButton.tsx @@ -19,7 +19,7 @@ export const FilterWrapper = styled(RowFixed)` export default function SortButton({ toggleSortOrder, - ascending, + ascending }: { toggleSortOrder: () => void ascending: boolean diff --git a/src/components/SearchModal/filtering.ts b/src/components/SearchModal/filtering.ts index 8e2cadf5c5..889b39f915 100644 --- a/src/components/SearchModal/filtering.ts +++ b/src/components/SearchModal/filtering.ts @@ -8,13 +8,13 @@ export function filterTokens(tokens: Token[], search: string): Token[] { const searchingAddress = isAddress(search) if (searchingAddress) { - return tokens.filter((token) => token.address === searchingAddress) + return tokens.filter(token => token.address === searchingAddress) } const lowerSearchParts = search .toLowerCase() .split(/\s+/) - .filter((s) => s.length > 0) + .filter(s => s.length > 0) if (lowerSearchParts.length === 0) { return tokens @@ -24,12 +24,12 @@ export function filterTokens(tokens: Token[], search: string): Token[] { const sParts = s .toLowerCase() .split(/\s+/) - .filter((s) => s.length > 0) + .filter(s => s.length > 0) - return lowerSearchParts.every((p) => p.length === 0 || sParts.some((sp) => sp.startsWith(p) || sp.endsWith(p))) + return lowerSearchParts.every(p => p.length === 0 || sParts.some(sp => sp.startsWith(p) || sp.endsWith(p))) } - return tokens.filter((token) => { + return tokens.filter(token => { const { symbol, name } = token return (symbol && matchesSearch(symbol)) || (name && matchesSearch(name)) }) @@ -44,7 +44,7 @@ export function useSortedTokensByQuery(tokens: Token[] | undefined, searchQuery: const symbolMatch = searchQuery .toLowerCase() .split(/\s+/) - .filter((s) => s.length > 0) + .filter(s => s.length > 0) if (symbolMatch.length > 1) { return tokens @@ -55,7 +55,7 @@ export function useSortedTokensByQuery(tokens: Token[] | undefined, searchQuery: const rest: Token[] = [] // sort tokens by exact match -> subtring on symbol match -> rest - tokens.map((token) => { + tokens.map(token => { if (token.symbol?.toLowerCase() === symbolMatch[0]) { return exactMatches.push(token) } else if (token.symbol?.toLowerCase().startsWith(searchQuery.toLowerCase().trim())) { diff --git a/src/components/SearchModal/styleds.tsx b/src/components/SearchModal/styleds.tsx index 52fe477c17..a117d72625 100644 --- a/src/components/SearchModal/styleds.tsx +++ b/src/components/SearchModal/styleds.tsx @@ -21,8 +21,8 @@ export const StyledMenu = styled.div` export const PopoverContainer = styled.div<{ show: boolean }>` z-index: 100; - visibility: ${(props) => (props.show ? 'visible' : 'hidden')}; - opacity: ${(props) => (props.show ? 1 : 0)}; + visibility: ${props => (props.show ? 'visible' : 'hidden')}; + opacity: ${props => (props.show ? 1 : 0)}; transition: visibility 150ms linear, opacity 150ms linear; background: ${({ theme }) => theme.bg2}; border: 1px solid ${({ theme }) => theme.bg3}; diff --git a/src/components/Settings/index.tsx b/src/components/Settings/index.tsx index 60978e7a34..1ffe643989 100644 --- a/src/components/Settings/index.tsx +++ b/src/components/Settings/index.tsx @@ -9,7 +9,7 @@ import { useExpertModeManager, useUserTransactionTTL, useUserSlippageTolerance, - useUserSingleHopOnly, + useUserSingleHopOnly } from '../../state/user/hooks' import { TYPE } from '../../theme' import { ButtonError } from '../Button' diff --git a/src/components/Slider/index.tsx b/src/components/Slider/index.tsx index 11f5b5cc39..f2f2d41af7 100644 --- a/src/components/Slider/index.tsx +++ b/src/components/Slider/index.tsx @@ -98,7 +98,7 @@ interface InputSliderProps { export default function Slider({ value, onChange, min = 0, step = 1, max = 100, size = 28 }: InputSliderProps) { const changeCallback = useCallback( - (e) => { + e => { onChange(parseInt(e.target.value)) }, [onChange] diff --git a/src/components/TokenWarningModal/index.tsx b/src/components/TokenWarningModal/index.tsx index d2277a3250..ce9fc86907 100644 --- a/src/components/TokenWarningModal/index.tsx +++ b/src/components/TokenWarningModal/index.tsx @@ -6,7 +6,7 @@ import { ImportToken } from 'components/SearchModal/ImportToken' export default function TokenWarningModal({ isOpen, tokens, - onConfirm, + onConfirm }: { isOpen: boolean tokens: Token[] diff --git a/src/components/TransactionConfirmationModal/index.tsx b/src/components/TransactionConfirmationModal/index.tsx index 978a4a9469..cc8d72471e 100644 --- a/src/components/TransactionConfirmationModal/index.tsx +++ b/src/components/TransactionConfirmationModal/index.tsx @@ -71,7 +71,7 @@ function TransactionSubmittedContent({ onDismiss, chainId, hash, - currencyToAdd, + currencyToAdd }: { onDismiss: () => void hash: string | undefined @@ -134,7 +134,7 @@ export function ConfirmationModalContent({ title, bottomContent, onDismiss, - topContent, + topContent }: { title: string onDismiss: () => void @@ -199,7 +199,7 @@ export default function TransactionConfirmationModal({ hash, pendingText, content, - currencyToAdd, + currencyToAdd }: ConfirmationModalProps) { const { chainId } = useActiveWeb3React() diff --git a/src/components/TransactionSettings/index.tsx b/src/components/TransactionSettings/index.tsx index 918ce4f334..998943073a 100644 --- a/src/components/TransactionSettings/index.tsx +++ b/src/components/TransactionSettings/index.tsx @@ -11,11 +11,11 @@ import { darken } from 'polished' enum SlippageError { InvalidInput = 'InvalidInput', RiskyLow = 'RiskyLow', - RiskyHigh = 'RiskyHigh', + RiskyHigh = 'RiskyHigh' } enum DeadlineError { - InvalidInput = 'InvalidInput', + InvalidInput = 'InvalidInput' } const FancyButton = styled.button` @@ -199,7 +199,7 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se onBlur={() => { parseCustomSlippage((rawSlippage / 100).toFixed(2)) }} - onChange={(e) => parseCustomSlippage(e.target.value)} + onChange={e => parseCustomSlippage(e.target.value)} color={!slippageInputIsValid ? 'red' : ''} /> % @@ -211,7 +211,7 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se style={{ fontSize: '14px', paddingTop: '7px', - color: slippageError === SlippageError.InvalidInput ? 'red' : '#F3841E', + color: slippageError === SlippageError.InvalidInput ? 'red' : '#F3841E' }} > {slippageError === SlippageError.InvalidInput @@ -239,7 +239,7 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se }} placeholder={(deadline / 60).toString()} value={deadlineInput} - onChange={(e) => parseCustomDeadline(e.target.value)} + onChange={e => parseCustomDeadline(e.target.value)} /> diff --git a/src/components/WalletModal/Option.tsx b/src/components/WalletModal/Option.tsx index d9a46a3d0a..51bc3425cf 100644 --- a/src/components/WalletModal/Option.tsx +++ b/src/components/WalletModal/Option.tsx @@ -62,7 +62,7 @@ const CircleWrapper = styled.div` const HeaderText = styled.div` ${({ theme }) => theme.flexRowNoWrap}; - color: ${(props) => (props.color === 'blue' ? ({ theme }) => theme.primary1 : ({ theme }) => theme.text1)}; + color: ${props => (props.color === 'blue' ? ({ theme }) => theme.primary1 : ({ theme }) => theme.text1)}; font-size: 1rem; font-weight: 500; ` @@ -97,7 +97,7 @@ export default function Option({ subheader = null, icon, active = false, - id, + id }: { link?: string | null clickable?: boolean diff --git a/src/components/WalletModal/PendingView.tsx b/src/components/WalletModal/PendingView.tsx index d228ceb69f..512f454e60 100644 --- a/src/components/WalletModal/PendingView.tsx +++ b/src/components/WalletModal/PendingView.tsx @@ -67,7 +67,7 @@ export default function PendingView({ connector, error = false, setPendingError, - tryActivation, + tryActivation }: { connector?: AbstractConnector error?: boolean @@ -100,7 +100,7 @@ export default function PendingView({ )} - {Object.keys(SUPPORTED_WALLETS).map((key) => { + {Object.keys(SUPPORTED_WALLETS).map(key => { const option = SUPPORTED_WALLETS[key] if (option.connector === connector) { if (option.connector === injected) { diff --git a/src/components/WalletModal/index.tsx b/src/components/WalletModal/index.tsx index b916780f02..e64f2a0c42 100644 --- a/src/components/WalletModal/index.tsx +++ b/src/components/WalletModal/index.tsx @@ -47,7 +47,7 @@ const HeaderRow = styled.div` ${({ theme }) => theme.flexRowNoWrap}; padding: 1rem 1rem; font-weight: 500; - color: ${(props) => (props.color === 'blue' ? ({ theme }) => theme.primary1 : 'inherit')}; + color: ${props => (props.color === 'blue' ? ({ theme }) => theme.primary1 : 'inherit')}; ${({ theme }) => theme.mediaWidth.upToMedium` padding: 1rem; `}; @@ -113,13 +113,13 @@ const WALLET_VIEWS = { OPTIONS: 'options', OPTIONS_SECONDARY: 'options_secondary', ACCOUNT: 'account', - PENDING: 'pending', + PENDING: 'pending' } export default function WalletModal({ pendingTransactions, confirmedTransactions, - ENSName, + ENSName }: { pendingTransactions: string[] // hashes of pending confirmedTransactions: string[] // hashes of confirmed @@ -165,7 +165,7 @@ export default function WalletModal({ const tryActivation = async (connector: AbstractConnector | undefined) => { let name = '' - Object.keys(SUPPORTED_WALLETS).map((key) => { + Object.keys(SUPPORTED_WALLETS).map(key => { if (connector === SUPPORTED_WALLETS[key].connector) { return (name = SUPPORTED_WALLETS[key].name) } @@ -175,7 +175,7 @@ export default function WalletModal({ ReactGA.event({ category: 'Wallet', action: 'Change Wallet', - label: name, + label: name }) setPendingWallet(connector) // set wallet for pending view setWalletView(WALLET_VIEWS.PENDING) @@ -186,7 +186,7 @@ export default function WalletModal({ } connector && - activate(connector, undefined, true).catch((error) => { + activate(connector, undefined, true).catch(error => { if (error instanceof UnsupportedChainIdError) { activate(connector) // a little janky...can't use setError because the connector isn't set } else { @@ -205,7 +205,7 @@ export default function WalletModal({ // get wallets user can switch too, depending on device/browser function getOptions() { const isMetamask = window.ethereum && window.ethereum.isMetaMask - return Object.keys(SUPPORTED_WALLETS).map((key) => { + return Object.keys(SUPPORTED_WALLETS).map(key => { const option = SUPPORTED_WALLETS[key] // check for mobile options if (isMobile) { diff --git a/src/components/Web3Status/index.tsx b/src/components/Web3Status/index.tsx index b3bac3cd3c..dbc2f5bcfe 100644 --- a/src/components/Web3Status/index.tsx +++ b/src/components/Web3Status/index.tsx @@ -174,7 +174,7 @@ function Web3StatusInner() { return txs.filter(isTransactionRecent).sort(newTransactionsFirst) }, [allTransactions]) - const pending = sortedRecentTransactions.filter((tx) => !tx.receipt).map((tx) => tx.hash) + const pending = sortedRecentTransactions.filter(tx => !tx.receipt).map(tx => tx.hash) const hasPendingTransactions = !!pending.length const hasSocks = useHasSocks() @@ -225,8 +225,8 @@ export default function Web3Status() { return txs.filter(isTransactionRecent).sort(newTransactionsFirst) }, [allTransactions]) - const pending = sortedRecentTransactions.filter((tx) => !tx.receipt).map((tx) => tx.hash) - const confirmed = sortedRecentTransactions.filter((tx) => tx.receipt).map((tx) => tx.hash) + const pending = sortedRecentTransactions.filter(tx => !tx.receipt).map(tx => tx.hash) + const confirmed = sortedRecentTransactions.filter(tx => tx.receipt).map(tx => tx.hash) if (!contextNetwork.active && !active) { return null diff --git a/src/components/claim/AddressClaimModal.tsx b/src/components/claim/AddressClaimModal.tsx index a9d88ffd5b..05b326da52 100644 --- a/src/components/claim/AddressClaimModal.tsx +++ b/src/components/claim/AddressClaimModal.tsx @@ -75,11 +75,11 @@ export default function AddressClaimModal({ isOpen, onDismiss }: { isOpen: boole function onClaim() { setAttempting(true) claimCallback() - .then((hash) => { + .then(hash => { setHash(hash) }) // reset modal and log error - .catch((error) => { + .catch(error => { setAttempting(false) console.log(error) }) diff --git a/src/components/claim/ClaimModal.tsx b/src/components/claim/ClaimModal.tsx index 84529d7c5e..690f8531c3 100644 --- a/src/components/claim/ClaimModal.tsx +++ b/src/components/claim/ClaimModal.tsx @@ -67,7 +67,7 @@ export default function ClaimModal() { setAttempting(true) claimCallback() // reset modal and log error - .catch((error) => { + .catch(error => { setAttempting(false) console.log(error) }) diff --git a/src/components/earn/ClaimRewardModal.tsx b/src/components/earn/ClaimRewardModal.tsx index d030f66fd7..868d663256 100644 --- a/src/components/earn/ClaimRewardModal.tsx +++ b/src/components/earn/ClaimRewardModal.tsx @@ -46,7 +46,7 @@ export default function ClaimRewardModal({ isOpen, onDismiss, stakingInfo }: Sta .getReward({ gasLimit: 350000 }) .then((response: TransactionResponse) => { addTransaction(response, { - summary: `Claim accumulated UNI rewards`, + summary: `Claim accumulated UNI rewards` }) setHash(response.hash) }) diff --git a/src/components/earn/StakingModal.tsx b/src/components/earn/StakingModal.tsx index 5343ee58ff..11619d3ea8 100644 --- a/src/components/earn/StakingModal.tsx +++ b/src/components/earn/StakingModal.tsx @@ -97,7 +97,7 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui ) .then((response: TransactionResponse) => { addTransaction(response, { - summary: `Deposit liquidity`, + summary: `Deposit liquidity` }) setHash(response.hash) }) @@ -141,50 +141,50 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, + { name: 'verifyingContract', type: 'address' } ] const domain = { name: 'Uniswap V2', version: '1', chainId: chainId, - verifyingContract: pairContract.address, + verifyingContract: pairContract.address } const Permit = [ { name: 'owner', type: 'address' }, { name: 'spender', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, - { name: 'deadline', type: 'uint256' }, + { name: 'deadline', type: 'uint256' } ] const message = { owner: account, spender: stakingInfo.stakingRewardAddress, value: liquidityAmount.raw.toString(), nonce: nonce.toHexString(), - deadline: deadline.toNumber(), + deadline: deadline.toNumber() } const data = JSON.stringify({ types: { EIP712Domain, - Permit, + Permit }, domain, primaryType: 'Permit', - message, + message }) library .send('eth_signTypedData_v4', [account, data]) .then(splitSignature) - .then((signature) => { + .then(signature => { setSignatureData({ v: signature.v, r: signature.r, s: signature.s, - deadline: deadline.toNumber(), + deadline: deadline.toNumber() }) }) - .catch((error) => { + .catch(error => { // for all errors other than 4001 (EIP-1193 user rejected request), fall back to manual approve if (error?.code !== 4001) { approveCallback() diff --git a/src/components/earn/UnstakingModal.tsx b/src/components/earn/UnstakingModal.tsx index 8d01c32366..fa19c99a5a 100644 --- a/src/components/earn/UnstakingModal.tsx +++ b/src/components/earn/UnstakingModal.tsx @@ -47,7 +47,7 @@ export default function UnstakingModal({ isOpen, onDismiss, stakingInfo }: Staki .exit({ gasLimit: 300000 }) .then((response: TransactionResponse) => { addTransaction(response, { - summary: `Withdraw deposited liquidity`, + summary: `Withdraw deposited liquidity` }) setHash(response.hash) }) diff --git a/src/components/swap/BetterTradeLink.tsx b/src/components/swap/BetterTradeLink.tsx index c0840085be..eaa538cb76 100644 --- a/src/components/swap/BetterTradeLink.tsx +++ b/src/components/swap/BetterTradeLink.tsx @@ -33,8 +33,8 @@ export default function BetterTradeLink({ version }: { version: Version }) { ...location, search: `?${stringify({ ...search, - use: version !== DEFAULT_VERSION ? version : undefined, - })}`, + use: version !== DEFAULT_VERSION ? version : undefined + })}` } }, [location, search, version]) @@ -58,8 +58,8 @@ export function DefaultVersionLink() { ...location, search: `?${stringify({ ...search, - use: DEFAULT_VERSION, - })}`, + use: DEFAULT_VERSION + })}` } }, [location, search]) diff --git a/src/components/swap/ConfirmSwapModal.tsx b/src/components/swap/ConfirmSwapModal.tsx index bc7ec1ed62..400bfe510a 100644 --- a/src/components/swap/ConfirmSwapModal.tsx +++ b/src/components/swap/ConfirmSwapModal.tsx @@ -2,7 +2,7 @@ import { currencyEquals, Trade } from '@uniswap/sdk' import React, { useCallback, useMemo } from 'react' import TransactionConfirmationModal, { ConfirmationModalContent, - TransactionErrorContent, + TransactionErrorContent } from '../TransactionConfirmationModal' import SwapModalFooter from './SwapModalFooter' import SwapModalHeader from './SwapModalHeader' @@ -33,7 +33,7 @@ export default function ConfirmSwapModal({ swapErrorMessage, isOpen, attemptingTxn, - txHash, + txHash }: { isOpen: boolean trade: Trade | undefined diff --git a/src/components/swap/SwapModalFooter.tsx b/src/components/swap/SwapModalFooter.tsx index 9604de9f21..369ff88b03 100644 --- a/src/components/swap/SwapModalFooter.tsx +++ b/src/components/swap/SwapModalFooter.tsx @@ -9,7 +9,7 @@ import { computeSlippageAdjustedAmounts, computeTradePriceBreakdown, formatExecutionPrice, - warningSeverity, + warningSeverity } from '../../utils/prices' import { ButtonError } from '../Button' import { AutoColumn } from '../Column' @@ -23,7 +23,7 @@ export default function SwapModalFooter({ onConfirm, allowedSlippage, swapErrorMessage, - disabledConfirm, + disabledConfirm }: { trade: Trade allowedSlippage: number @@ -35,7 +35,7 @@ export default function SwapModalFooter({ const theme = useContext(ThemeContext) const slippageAdjustedAmounts = useMemo(() => computeSlippageAdjustedAmounts(trade, allowedSlippage), [ allowedSlippage, - trade, + trade ]) const { priceImpactWithoutFee, realizedLPFee } = useMemo(() => computeTradePriceBreakdown(trade), [trade]) const severity = warningSeverity(priceImpactWithoutFee) @@ -56,7 +56,7 @@ export default function SwapModalFooter({ alignItems: 'center', display: 'flex', textAlign: 'right', - paddingLeft: '10px', + paddingLeft: '10px' }} > {formatExecutionPrice(trade, showInverted)} diff --git a/src/components/swap/SwapModalHeader.tsx b/src/components/swap/SwapModalHeader.tsx index 0a1c94c3af..e82e51ad08 100644 --- a/src/components/swap/SwapModalHeader.tsx +++ b/src/components/swap/SwapModalHeader.tsx @@ -18,7 +18,7 @@ export default function SwapModalHeader({ allowedSlippage, recipient, showAcceptChanges, - onAcceptChanges, + onAcceptChanges }: { trade: Trade allowedSlippage: number @@ -28,7 +28,7 @@ export default function SwapModalHeader({ }) { const slippageAdjustedAmounts = useMemo(() => computeSlippageAdjustedAmounts(trade, allowedSlippage), [ trade, - allowedSlippage, + allowedSlippage ]) const { priceImpactWithoutFee } = useMemo(() => computeTradePriceBreakdown(trade), [trade]) const priceImpactSeverity = warningSeverity(priceImpactWithoutFee) diff --git a/src/components/swap/UnsupportedCurrencyFooter.tsx b/src/components/swap/UnsupportedCurrencyFooter.tsx index b270a9958c..84e6982299 100644 --- a/src/components/swap/UnsupportedCurrencyFooter.tsx +++ b/src/components/swap/UnsupportedCurrencyFooter.tsx @@ -40,7 +40,7 @@ const AddressText = styled(TYPE.blue)` export default function UnsupportedCurrencyFooter({ show, - currencies, + currencies }: { show: boolean currencies: (Currency | undefined)[] @@ -50,7 +50,7 @@ export default function UnsupportedCurrencyFooter({ const tokens = chainId && currencies - ? currencies.map((currency) => { + ? currencies.map(currency => { return wrappedCurrency(currency, chainId) }) : [] @@ -67,7 +67,7 @@ export default function UnsupportedCurrencyFooter({ setShowDetails(false)} /> - {tokens.map((token) => { + {tokens.map(token => { return ( token && unsupportedTokens && diff --git a/src/components/vote/DelegateModal.tsx b/src/components/vote/DelegateModal.tsx index d867ec443e..cf27dfdc64 100644 --- a/src/components/vote/DelegateModal.tsx +++ b/src/components/vote/DelegateModal.tsx @@ -77,7 +77,7 @@ export default function DelegateModal({ isOpen, onDismiss, title }: VoteModalPro if (!delegateCallback) return // try delegation and store hash - const hash = await delegateCallback(parsedAddress ?? undefined)?.catch((error) => { + const hash = await delegateCallback(parsedAddress ?? undefined)?.catch(error => { setAttempting(false) console.log(error) }) diff --git a/src/components/vote/VoteModal.tsx b/src/components/vote/VoteModal.tsx index 5390f871dd..f299b12312 100644 --- a/src/components/vote/VoteModal.tsx +++ b/src/components/vote/VoteModal.tsx @@ -44,7 +44,7 @@ interface VoteModalProps { export default function VoteModal({ isOpen, onDismiss, proposalId, support }: VoteModalProps) { const { chainId } = useActiveWeb3React() const { - voteCallback, + voteCallback }: { voteCallback: (proposalId: string | undefined, support: boolean) => Promise | undefined } = useVoteCallback() @@ -71,7 +71,7 @@ export default function VoteModal({ isOpen, onDismiss, proposalId, support }: Vo if (!voteCallback) return // try delegation and store hash - const hash = await voteCallback(proposalId, support)?.catch((error) => { + const hash = await voteCallback(proposalId, support)?.catch(error => { setAttempting(false) console.log(error) }) diff --git a/src/connectors/Fortmatic.ts b/src/connectors/Fortmatic.ts index 11862e6251..8d2b9c140c 100644 --- a/src/connectors/Fortmatic.ts +++ b/src/connectors/Fortmatic.ts @@ -9,7 +9,7 @@ const CHAIN_ID_NETWORK_ARGUMENT: { readonly [chainId in FormaticSupportedChains] [ChainId.MAINNET]: undefined, [ChainId.ROPSTEN]: 'ropsten', [ChainId.RINKEBY]: 'rinkeby', - [ChainId.KOVAN]: 'kovan', + [ChainId.KOVAN]: 'kovan' } export class FortmaticConnector extends FortmaticConnectorCore { @@ -27,7 +27,7 @@ export class FortmaticConnector extends FortmaticConnectorCore { const provider = this.fortmatic.getProvider() - const pollForOverlayReady = new Promise((resolve) => { + const pollForOverlayReady = new Promise(resolve => { const interval = setInterval(() => { if (provider.overlayReady) { clearInterval(interval) @@ -39,7 +39,7 @@ export class FortmaticConnector extends FortmaticConnectorCore { const [account] = await Promise.all([ provider.enable().then((accounts: string[]) => accounts[0]), - pollForOverlayReady, + pollForOverlayReady ]) return { provider: this.fortmatic.getProvider(), chainId: (this as any).chainId, account } diff --git a/src/connectors/NetworkConnector.ts b/src/connectors/NetworkConnector.ts index ddf7e1fac3..fca6e0dced 100644 --- a/src/connectors/NetworkConnector.ts +++ b/src/connectors/NetworkConnector.ts @@ -60,7 +60,7 @@ class MiniRpcProvider implements AsyncSendable { response = await fetch(this.url, { method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json' }, - body: JSON.stringify(batch.map((item) => item.request)), + body: JSON.stringify(batch.map(item => item.request)) }) } catch (error) { batch.forEach(({ reject }) => reject(new Error('Failed to send batch call'))) @@ -87,7 +87,7 @@ class MiniRpcProvider implements AsyncSendable { const { resolve, reject, - request: { method }, + request: { method } } = byKey[result.id] if (resolve && reject) { if ('error' in result) { @@ -111,8 +111,8 @@ class MiniRpcProvider implements AsyncSendable { callback: (error: any, response: any) => void ): void => { this.request(request.method, request.params) - .then((result) => callback(null, { jsonrpc: '2.0', id: request.id, result })) - .catch((error) => callback(error, null)) + .then(result => callback(null, { jsonrpc: '2.0', id: request.id, result })) + .catch(error => callback(error, null)) } public readonly request = async ( @@ -131,10 +131,10 @@ class MiniRpcProvider implements AsyncSendable { jsonrpc: '2.0', id: this.nextId++, method, - params, + params }, resolve, - reject, + reject }) }) this.batchTimeoutId = this.batchTimeoutId ?? setTimeout(this.clearBatch, this.batchWaitTimeMs) diff --git a/src/connectors/index.ts b/src/connectors/index.ts index 0817c78a8b..5216b83a02 100644 --- a/src/connectors/index.ts +++ b/src/connectors/index.ts @@ -18,7 +18,7 @@ if (typeof NETWORK_URL === 'undefined') { } export const network = new NetworkConnector({ - urls: { [NETWORK_CHAIN_ID]: NETWORK_URL }, + urls: { [NETWORK_CHAIN_ID]: NETWORK_URL } }) let networkLibrary: Web3Provider | undefined @@ -27,7 +27,7 @@ export function getNetworkLibrary(): Web3Provider { } export const injected = new InjectedConnector({ - supportedChainIds: [1, 3, 4, 5, 42], + supportedChainIds: [1, 3, 4, 5, 42] }) // mainnet only @@ -35,19 +35,19 @@ export const walletconnect = new WalletConnectConnector({ rpc: { 1: NETWORK_URL }, bridge: 'https://bridge.walletconnect.org', qrcode: true, - pollingInterval: 15000, + pollingInterval: 15000 }) // mainnet only export const fortmatic = new FortmaticConnector({ apiKey: FORMATIC_KEY ?? '', - chainId: 1, + chainId: 1 }) // mainnet only export const portis = new PortisConnector({ dAppId: PORTIS_ID ?? '', - networks: [1], + networks: [1] }) // mainnet only @@ -55,5 +55,5 @@ export const walletlink = new WalletLinkConnector({ url: NETWORK_URL, appName: 'Uniswap', appLogoUrl: - 'https://mpng.pngfly.com/20181202/bex/kisspng-emoji-domain-unicorn-pin-badges-sticker-unicorn-tumblr-emoji-unicorn-iphoneemoji-5c046729264a77.5671679315437924251569.jpg', + 'https://mpng.pngfly.com/20181202/bex/kisspng-emoji-domain-unicorn-pin-badges-sticker-unicorn-tumblr-emoji-unicorn-iphoneemoji-5c046729264a77.5671679315437924251569.jpg' }) diff --git a/src/constants/index.ts b/src/constants/index.ts index e11a228024..f445f63dc3 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -37,18 +37,18 @@ export const UNI: { [chainId in ChainId]: Token } = { [ChainId.RINKEBY]: new Token(ChainId.RINKEBY, UNI_ADDRESS, 18, 'UNI', 'Uniswap'), [ChainId.ROPSTEN]: new Token(ChainId.ROPSTEN, UNI_ADDRESS, 18, 'UNI', 'Uniswap'), [ChainId.GÖRLI]: new Token(ChainId.GÖRLI, UNI_ADDRESS, 18, 'UNI', 'Uniswap'), - [ChainId.KOVAN]: new Token(ChainId.KOVAN, UNI_ADDRESS, 18, 'UNI', 'Uniswap'), + [ChainId.KOVAN]: new Token(ChainId.KOVAN, UNI_ADDRESS, 18, 'UNI', 'Uniswap') } export const COMMON_CONTRACT_NAMES: { [address: string]: string } = { [UNI_ADDRESS]: 'UNI', [GOVERNANCE_ADDRESS]: 'Governance', - [TIMELOCK_ADDRESS]: 'Timelock', + [TIMELOCK_ADDRESS]: 'Timelock' } // TODO: specify merkle distributor for mainnet export const MERKLE_DISTRIBUTOR_ADDRESS: { [chainId in ChainId]?: string } = { - [ChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e', + [ChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e' } const WETH_ONLY: ChainTokenList = { @@ -56,13 +56,13 @@ const WETH_ONLY: ChainTokenList = { [ChainId.ROPSTEN]: [WETH[ChainId.ROPSTEN]], [ChainId.RINKEBY]: [WETH[ChainId.RINKEBY]], [ChainId.GÖRLI]: [WETH[ChainId.GÖRLI]], - [ChainId.KOVAN]: [WETH[ChainId.KOVAN]], + [ChainId.KOVAN]: [WETH[ChainId.KOVAN]] } // used to construct intermediary pairs for trading export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ...WETH_ONLY, - [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, COMP, MKR, WBTC], + [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, COMP, MKR, WBTC] } /** @@ -71,31 +71,31 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { */ export const CUSTOM_BASES: { [chainId in ChainId]?: { [tokenAddress: string]: Token[] } } = { [ChainId.MAINNET]: { - [AMPL.address]: [DAI, WETH[ChainId.MAINNET]], - }, + [AMPL.address]: [DAI, WETH[ChainId.MAINNET]] + } } // used for display in the default list when adding liquidity export const SUGGESTED_BASES: ChainTokenList = { ...WETH_ONLY, - [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, WBTC], + [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, WBTC] } // used to construct the list of all pairs we consider by default in the frontend export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { ...WETH_ONLY, - [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, WBTC], + [ChainId.MAINNET]: [...WETH_ONLY[ChainId.MAINNET], DAI, USDC, USDT, WBTC] } export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = { [ChainId.MAINNET]: [ [ new Token(ChainId.MAINNET, '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643', 8, 'cDAI', 'Compound Dai'), - new Token(ChainId.MAINNET, '0x39AA39c021dfbaE8faC545936693aC917d5E7563', 8, 'cUSDC', 'Compound USD Coin'), + new Token(ChainId.MAINNET, '0x39AA39c021dfbaE8faC545936693aC917d5E7563', 8, 'cUSDC', 'Compound USD Coin') ], [USDC, USDT], - [DAI, USDT], - ], + [DAI, USDT] + ] } export interface WalletInfo { @@ -118,7 +118,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { description: 'Injected web3 provider.', href: null, color: '#010101', - primary: true, + primary: true }, METAMASK: { connector: injected, @@ -126,7 +126,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { iconName: 'metamask.png', description: 'Easy-to-use browser extension.', href: null, - color: '#E8831D', + color: '#E8831D' }, WALLET_CONNECT: { connector: walletconnect, @@ -135,7 +135,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { description: 'Connect to Trust Wallet, Rainbow Wallet and more...', href: null, color: '#4196FC', - mobile: true, + mobile: true }, WALLET_LINK: { connector: walletlink, @@ -143,7 +143,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { iconName: 'coinbaseWalletIcon.svg', description: 'Use Coinbase Wallet app on mobile device', href: null, - color: '#315CF5', + color: '#315CF5' }, COINBASE_LINK: { name: 'Open in Coinbase Wallet', @@ -152,7 +152,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { href: 'https://go.cb-w.com/mtUDhEZPy1', color: '#315CF5', mobile: true, - mobileOnly: true, + mobileOnly: true }, FORTMATIC: { connector: fortmatic, @@ -161,7 +161,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { description: 'Login using Fortmatic hosted wallet', href: null, color: '#6748FF', - mobile: true, + mobile: true }, Portis: { connector: portis, @@ -170,8 +170,8 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = { description: 'Login using Portis hosted wallet', href: null, color: '#4A6C9B', - mobile: true, - }, + mobile: true + } } export const NetworkContextName = 'NETWORK' @@ -210,5 +210,5 @@ export const BLOCKED_ADDRESSES: string[] = [ '0x7F367cC41522cE07553e823bf3be79A889DEbe1B', '0xd882cFc20F52f2599D84b8e8D58C7FB62cfE344b', '0x901bb9583b24D97e995513C6778dc6888AB6870e', - '0xA7e5d5A720f06526557c513402f2e6B5fA20b008', + '0xA7e5d5A720f06526557c513402f2e6B5fA20b008' ] diff --git a/src/constants/lists.ts b/src/constants/lists.ts index 9e6bab8c6f..7081fc89ad 100644 --- a/src/constants/lists.ts +++ b/src/constants/lists.ts @@ -33,7 +33,7 @@ export const DEFAULT_LIST_OF_LISTS: string[] = [ CMC_STABLECOIN, KLEROS_LIST, GEMINI_LIST, - ...UNSUPPORTED_LIST_URLS, // need to load unsupported tokens as well + ...UNSUPPORTED_LIST_URLS // need to load unsupported tokens as well ] // default lists to be 'active' aka searched across diff --git a/src/constants/multicall/index.ts b/src/constants/multicall/index.ts index f3215377c0..b759543491 100644 --- a/src/constants/multicall/index.ts +++ b/src/constants/multicall/index.ts @@ -6,7 +6,7 @@ const MULTICALL_NETWORKS: { [chainId in ChainId]: string } = { [ChainId.ROPSTEN]: '0x53C43764255c17BD724F74c4eF150724AC50a3ed', [ChainId.KOVAN]: '0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A', [ChainId.RINKEBY]: '0x42Ad527de7d4e9d9d011aC45B31D8551f8Fe9821', - [ChainId.GÖRLI]: '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e', + [ChainId.GÖRLI]: '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e' } export { MULTICALL_ABI, MULTICALL_NETWORKS } diff --git a/src/constants/v1/index.ts b/src/constants/v1/index.ts index 9adf780bf1..38e0f219fc 100644 --- a/src/constants/v1/index.ts +++ b/src/constants/v1/index.ts @@ -8,7 +8,7 @@ const V1_FACTORY_ADDRESSES: { [chainId in ChainId]: string } = { [ChainId.ROPSTEN]: '0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351', [ChainId.RINKEBY]: '0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36', [ChainId.GÖRLI]: '0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA', - [ChainId.KOVAN]: '0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30', + [ChainId.KOVAN]: '0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30' } const V1_FACTORY_INTERFACE = new Interface(V1_FACTORY_ABI) diff --git a/src/data/Allowances.ts b/src/data/Allowances.ts index 3acee34c42..0591e57692 100644 --- a/src/data/Allowances.ts +++ b/src/data/Allowances.ts @@ -12,6 +12,6 @@ export function useTokenAllowance(token?: Token, owner?: string, spender?: strin return useMemo(() => (token && allowance ? new TokenAmount(token, allowance.toString()) : undefined), [ token, - allowance, + allowance ]) } diff --git a/src/data/Reserves.ts b/src/data/Reserves.ts index 27fd364932..09cb21d31f 100644 --- a/src/data/Reserves.ts +++ b/src/data/Reserves.ts @@ -13,7 +13,7 @@ export enum PairState { LOADING, NOT_EXISTS, EXISTS, - INVALID, + INVALID } export function usePairs(currencies: [Currency | undefined, Currency | undefined][]): [PairState, Pair | null][] { @@ -23,7 +23,7 @@ export function usePairs(currencies: [Currency | undefined, Currency | undefined () => currencies.map(([currencyA, currencyB]) => [ wrappedCurrency(currencyA, chainId), - wrappedCurrency(currencyB, chainId), + wrappedCurrency(currencyB, chainId) ]), [chainId, currencies] ) @@ -51,7 +51,7 @@ export function usePairs(currencies: [Currency | undefined, Currency | undefined const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA] return [ PairState.EXISTS, - new Pair(new TokenAmount(token0, reserve0.toString()), new TokenAmount(token1, reserve1.toString())), + new Pair(new TokenAmount(token0, reserve0.toString()), new TokenAmount(token1, reserve1.toString())) ] }) }, [results, tokens]) diff --git a/src/data/V1.ts b/src/data/V1.ts index 74ecec018f..7829c7c0fa 100644 --- a/src/data/V1.ts +++ b/src/data/V1.ts @@ -11,7 +11,7 @@ import { TokenAmount, Trade, TradeType, - WETH, + WETH } from '@uniswap/sdk' import { useMemo } from 'react' import { useActiveWeb3React } from '../hooks' @@ -53,7 +53,7 @@ function useMockV1Pair(inputCurrency?: Currency): MockV1Pair | undefined { export function useAllTokenV1Exchanges(): { [exchangeAddress: string]: Token } { const allTokens = useAllTokens() const factory = useV1FactoryContract() - const args = useMemo(() => Object.keys(allTokens).map((tokenAddress) => [tokenAddress]), [allTokens]) + const args = useMemo(() => Object.keys(allTokens).map(tokenAddress => [tokenAddress]), [allTokens]) const data = useSingleContractMultipleData(factory, 'getExchange', args, NEVER_RELOAD) @@ -77,7 +77,7 @@ export function useUserHasLiquidityInAllTokens(): boolean | undefined { const v1ExchangeLiquidityTokens = useMemo( () => - chainId ? Object.keys(exchanges).map((address) => new Token(chainId, address, 18, 'UNI-V1', 'Uniswap V1')) : [], + chainId ? Object.keys(exchanges).map(address => new Token(chainId, address, 18, 'UNI-V1', 'Uniswap V1')) : [], [chainId, exchanges] ) @@ -85,7 +85,7 @@ export function useUserHasLiquidityInAllTokens(): boolean | undefined { return useMemo( () => - Object.keys(balances).some((tokenAddress) => { + Object.keys(balances).some(tokenAddress => { const b = balances[tokenAddress]?.raw return b && JSBI.greaterThan(b, JSBI.BigInt(0)) }), @@ -135,7 +135,7 @@ export function useV1Trade( } export function getTradeVersion(trade?: Trade): Version | undefined { - const isV1 = trade?.route?.pairs?.some((pair) => pair instanceof MockV1Pair) + const isV1 = trade?.route?.pairs?.some(pair => pair instanceof MockV1Pair) if (isV1) return Version.v1 if (isV1 === false) return Version.v2 return undefined diff --git a/src/hooks/Tokens.ts b/src/hooks/Tokens.ts index ccae45b9c0..0f98652de9 100644 --- a/src/hooks/Tokens.ts +++ b/src/hooks/Tokens.ts @@ -113,7 +113,7 @@ export function useIsUserAddedToken(currency: Currency | undefined | null): bool return false } - return !!userAddedTokens.find((token) => currencyEquals(currency, token)) + return !!userAddedTokens.find(token => currencyEquals(currency, token)) } // parse a name or symbol from a token response @@ -177,7 +177,7 @@ export function useToken(tokenAddress?: string): Token | undefined | null { token, tokenName.loading, tokenName.result, - tokenNameBytes32.result, + tokenNameBytes32.result ]) } diff --git a/src/hooks/Trades.ts b/src/hooks/Trades.ts index 32b7cba54e..0179995615 100644 --- a/src/hooks/Trades.ts +++ b/src/hooks/Trades.ts @@ -22,7 +22,7 @@ function useAllCommonPairs(currencyA?: Currency, currencyB?: Currency): Pair[] { const basePairs: [Token, Token][] = useMemo( () => - flatMap(bases, (base): [Token, Token][] => bases.map((otherBase) => [base, otherBase])).filter( + flatMap(bases, (base): [Token, Token][] => bases.map(otherBase => [base, otherBase])).filter( ([t0, t1]) => t0.address !== t1.address ), [bases] @@ -39,7 +39,7 @@ function useAllCommonPairs(currencyA?: Currency, currencyB?: Currency): Pair[] { // token B against all bases ...bases.map((base): [Token, Token] => [tokenB, base]), // each base against all bases - ...basePairs, + ...basePairs ] .filter((tokens): tokens is [Token, Token] => Boolean(tokens[0] && tokens[1])) .filter(([t0, t1]) => t0.address !== t1.address) @@ -53,8 +53,8 @@ function useAllCommonPairs(currencyA?: Currency, currencyB?: Currency): Pair[] { if (!customBasesA && !customBasesB) return true - if (customBasesA && !customBasesA.find((base) => tokenB.equals(base))) return false - if (customBasesB && !customBasesB.find((base) => tokenA.equals(base))) return false + if (customBasesA && !customBasesA.find(base => tokenB.equals(base))) return false + if (customBasesB && !customBasesB.find(base => tokenA.equals(base))) return false return true }) diff --git a/src/hooks/index.ts b/src/hooks/index.ts index d23a9d1501..f20f9f10f7 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -18,7 +18,7 @@ export function useEagerConnect() { const [tried, setTried] = useState(false) useEffect(() => { - injected.isAuthorized().then((isAuthorized) => { + injected.isAuthorized().then(isAuthorized => { if (isAuthorized) { activate(injected, undefined, true).catch(() => { setTried(true) @@ -58,7 +58,7 @@ export function useInactiveListener(suppress = false) { if (ethereum && ethereum.on && !active && !error && !suppress) { const handleChainChanged = () => { // eat errors - activate(injected, undefined, true).catch((error) => { + activate(injected, undefined, true).catch(error => { console.error('Failed to activate after chain changed', error) }) } @@ -66,7 +66,7 @@ export function useInactiveListener(suppress = false) { const handleAccountsChanged = (accounts: string[]) => { if (accounts.length > 0) { // eat errors - activate(injected, undefined, true).catch((error) => { + activate(injected, undefined, true).catch(error => { console.error('Failed to activate after accounts changed', error) }) } diff --git a/src/hooks/useAddTokenToMetamask.ts b/src/hooks/useAddTokenToMetamask.ts index 1c52eb6555..a8a798017d 100644 --- a/src/hooks/useAddTokenToMetamask.ts +++ b/src/hooks/useAddTokenToMetamask.ts @@ -25,11 +25,11 @@ export default function useAddTokenToMetamask( address: token.address, symbol: token.symbol, decimals: token.decimals, - image: getTokenLogoURL(token.address), - }, - }, + image: getTokenLogoURL(token.address) + } + } }) - .then((success) => { + .then(success => { setSuccess(success) }) .catch(() => setSuccess(false)) diff --git a/src/hooks/useApproveCallback.ts b/src/hooks/useApproveCallback.ts index 90396d51d1..0e235ab269 100644 --- a/src/hooks/useApproveCallback.ts +++ b/src/hooks/useApproveCallback.ts @@ -17,7 +17,7 @@ export enum ApprovalState { UNKNOWN, NOT_APPROVED, PENDING, - APPROVED, + APPROVED } // returns a variable indicating the state of the approval and a function which approves if necessary or early returns @@ -82,12 +82,12 @@ export function useApproveCallback( return tokenContract .approve(spender, useExact ? amountToApprove.raw.toString() : MaxUint256, { - gasLimit: calculateGasMargin(estimatedGas), + gasLimit: calculateGasMargin(estimatedGas) }) .then((response: TransactionResponse) => { addTransaction(response, { summary: 'Approve ' + amountToApprove.currency.symbol, - approval: { tokenAddress: token.address, spender: spender }, + approval: { tokenAddress: token.address, spender: spender } }) }) .catch((error: Error) => { diff --git a/src/hooks/useColor.ts b/src/hooks/useColor.ts index bad8cfd922..54da29bf41 100644 --- a/src/hooks/useColor.ts +++ b/src/hooks/useColor.ts @@ -14,7 +14,7 @@ async function getColorFromToken(token: Token): Promise { return Vibrant.from(path) .getPalette() - .then((palette) => { + .then(palette => { if (palette?.Vibrant) { let detectedHex = palette.Vibrant.hex let AAscore = hex(detectedHex, '#FFF') @@ -34,7 +34,7 @@ async function getColorFromUriPath(uri: string): Promise { return Vibrant.from(formattedPath) .getPalette() - .then((palette) => { + .then(palette => { if (palette?.Vibrant) { return palette.Vibrant.hex } @@ -50,7 +50,7 @@ export function useColor(token?: Token) { let stale = false if (token) { - getColorFromToken(token).then((tokenColor) => { + getColorFromToken(token).then(tokenColor => { if (!stale && tokenColor !== null) { setColor(tokenColor) } @@ -73,7 +73,7 @@ export function useListColor(listImageUri?: string) { let stale = false if (listImageUri) { - getColorFromUriPath(listImageUri).then((color) => { + getColorFromUriPath(listImageUri).then(color => { if (!stale && color !== null) { setColor(color) } diff --git a/src/hooks/useContract.ts b/src/hooks/useContract.ts index a4f85ae307..f22a67af2e 100644 --- a/src/hooks/useContract.ts +++ b/src/hooks/useContract.ts @@ -9,7 +9,7 @@ import { useMemo } from 'react' import { GOVERNANCE_ADDRESS, MERKLE_DISTRIBUTOR_ADDRESS, UNI } from '../constants' import { ARGENT_WALLET_DETECTOR_ABI, - ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS, + ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS } from '../constants/abis/argent-wallet-detector' import ENS_PUBLIC_RESOLVER_ABI from '../constants/abis/ens-public-resolver.json' import ENS_ABI from '../constants/abis/ens-registrar.json' diff --git a/src/hooks/useCopyClipboard.ts b/src/hooks/useCopyClipboard.ts index 2317753f7e..67aefcd2e1 100644 --- a/src/hooks/useCopyClipboard.ts +++ b/src/hooks/useCopyClipboard.ts @@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from 'react' export default function useCopyClipboard(timeout = 500): [boolean, (toCopy: string) => void] { const [isCopied, setIsCopied] = useState(false) - const staticCopy = useCallback((text) => { + const staticCopy = useCallback(text => { const didCopy = copy(text) setIsCopied(didCopy) }, []) diff --git a/src/hooks/useENS.ts b/src/hooks/useENS.ts index 857ce6da1d..b556546e8a 100644 --- a/src/hooks/useENS.ts +++ b/src/hooks/useENS.ts @@ -16,6 +16,6 @@ export default function useENS( return { loading: reverseLookup.loading || lookup.loading, address: validated ? validated : lookup.address, - name: reverseLookup.ENSName ? reverseLookup.ENSName : !validated && lookup.address ? nameOrAddress || null : null, + name: reverseLookup.ENSName ? reverseLookup.ENSName : !validated && lookup.address ? nameOrAddress || null : null } } diff --git a/src/hooks/useENSAddress.ts b/src/hooks/useENSAddress.ts index 1fa19efa8e..37bab9e628 100644 --- a/src/hooks/useENSAddress.ts +++ b/src/hooks/useENSAddress.ts @@ -30,6 +30,6 @@ export default function useENSAddress(ensName?: string | null): { loading: boole const changed = debouncedName !== ensName return { address: changed ? null : addr.result?.[0] ?? null, - loading: changed || resolverAddress.loading || addr.loading, + loading: changed || resolverAddress.loading || addr.loading } } diff --git a/src/hooks/useENSContentHash.ts b/src/hooks/useENSContentHash.ts index 2dd1da521c..2ed78158a9 100644 --- a/src/hooks/useENSContentHash.ts +++ b/src/hooks/useENSContentHash.ts @@ -27,6 +27,6 @@ export default function useENSContentHash(ensName?: string | null): { loading: b return { contenthash: contenthash.result?.[0] ?? null, - loading: resolverAddressResult.loading || contenthash.loading, + loading: resolverAddressResult.loading || contenthash.loading } } diff --git a/src/hooks/useENSName.ts b/src/hooks/useENSName.ts index ee5e235f48..ee15377149 100644 --- a/src/hooks/useENSName.ts +++ b/src/hooks/useENSName.ts @@ -32,6 +32,6 @@ export default function useENSName(address?: string): { ENSName: string | null; const changed = debouncedAddress !== address return { ENSName: changed ? null : name.result?.[0] ?? null, - loading: changed || resolverAddress.loading || name.loading, + loading: changed || resolverAddress.loading || name.loading } } diff --git a/src/hooks/useFetchListCallback.ts b/src/hooks/useFetchListCallback.ts index 1df6fb2d7d..c3e1224e83 100644 --- a/src/hooks/useFetchListCallback.ts +++ b/src/hooks/useFetchListCallback.ts @@ -36,11 +36,11 @@ export function useFetchListCallback(): (listUrl: string, sendDispatch?: boolean const requestId = nanoid() sendDispatch && dispatch(fetchTokenList.pending({ requestId, url: listUrl })) return getTokenList(listUrl, ensResolver) - .then((tokenList) => { + .then(tokenList => { sendDispatch && dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList, requestId })) return tokenList }) - .catch((error) => { + .catch(error => { console.debug(`Failed to get list at url ${listUrl}`, error) sendDispatch && dispatch(fetchTokenList.rejected({ url: listUrl, requestId, errorMessage: error.message })) throw error diff --git a/src/hooks/useLast.ts b/src/hooks/useLast.ts index 6f83116215..6260997b83 100644 --- a/src/hooks/useLast.ts +++ b/src/hooks/useLast.ts @@ -11,7 +11,7 @@ export default function useLast( ): T | null | undefined { const [last, setLast] = useState(filterFn && filterFn(value) ? value : undefined) useEffect(() => { - setLast((last) => { + setLast(last => { const shouldUse: boolean = filterFn ? filterFn(value) : true if (shouldUse) return value return last diff --git a/src/hooks/useSwapCallback.ts b/src/hooks/useSwapCallback.ts index 124de14698..ca94d593c3 100644 --- a/src/hooks/useSwapCallback.ts +++ b/src/hooks/useSwapCallback.ts @@ -17,7 +17,7 @@ import { Version } from './useToggledVersion' export enum SwapCallbackState { INVALID, LOADING, - VALID, + VALID } interface SwapCall { @@ -75,7 +75,7 @@ function useSwapCallArguments( feeOnTransfer: false, allowedSlippage: new Percent(JSBI.BigInt(allowedSlippage), BIPS_BASE), recipient, - deadline: deadline.toNumber(), + deadline: deadline.toNumber() }) ) @@ -85,7 +85,7 @@ function useSwapCallArguments( feeOnTransfer: true, allowedSlippage: new Percent(JSBI.BigInt(allowedSlippage), BIPS_BASE), recipient, - deadline: deadline.toNumber(), + deadline: deadline.toNumber() }) ) } @@ -95,12 +95,12 @@ function useSwapCallArguments( v1SwapArguments(trade, { allowedSlippage: new Percent(JSBI.BigInt(allowedSlippage), BIPS_BASE), recipient, - deadline: deadline.toNumber(), + deadline: deadline.toNumber() }) ) break } - return swapMethods.map((parameters) => ({ parameters, contract })) + return swapMethods.map(parameters => ({ parameters, contract })) }, [account, allowedSlippage, chainId, deadline, library, recipient, trade, v1Exchange]) } @@ -138,29 +138,29 @@ export function useSwapCallback( state: SwapCallbackState.VALID, callback: async function onSwap(): Promise { const estimatedCalls: EstimatedSwapCall[] = await Promise.all( - swapCalls.map((call) => { + swapCalls.map(call => { const { parameters: { methodName, args, value }, - contract, + contract } = call const options = !value || isZero(value) ? {} : { value } return contract.estimateGas[methodName](...args, options) - .then((gasEstimate) => { + .then(gasEstimate => { return { call, - gasEstimate, + gasEstimate } }) - .catch((gasError) => { + .catch(gasError => { console.debug('Gas estimate failed, trying eth_call to extract error', call) return contract.callStatic[methodName](...args, options) - .then((result) => { + .then(result => { console.debug('Unexpected successful call after failed estimate gas', call, gasError, result) return { call, error: new Error('Unexpected issue with estimating the gas. Please try again.') } }) - .catch((callError) => { + .catch(callError => { console.debug('Call threw error', call, callError) let errorMessage: string switch (callError.reason) { @@ -193,14 +193,14 @@ export function useSwapCallback( const { call: { contract, - parameters: { methodName, args, value }, + parameters: { methodName, args, value } }, - gasEstimate, + gasEstimate } = successfulEstimation return contract[methodName](...args, { gasLimit: calculateGasMargin(gasEstimate), - ...(value && !isZero(value) ? { value, from: account } : { from: account }), + ...(value && !isZero(value) ? { value, from: account } : { from: account }) }) .then((response: any) => { const inputSymbol = trade.inputAmount.currency.symbol @@ -222,7 +222,7 @@ export function useSwapCallback( tradeVersion === Version.v2 ? withRecipient : `${withRecipient} on ${(tradeVersion as any).toUpperCase()}` addTransaction(response, { - summary: withVersion, + summary: withVersion }) return response.hash @@ -238,7 +238,7 @@ export function useSwapCallback( } }) }, - error: null, + error: null } }, [trade, library, account, chainId, recipient, recipientAddressOrName, swapCalls, addTransaction]) } diff --git a/src/hooks/useToggle.ts b/src/hooks/useToggle.ts index 2da340a46b..a8bfca7d29 100644 --- a/src/hooks/useToggle.ts +++ b/src/hooks/useToggle.ts @@ -2,6 +2,6 @@ import { useCallback, useState } from 'react' export default function useToggle(initialState = false): [boolean, () => void] { const [state, setState] = useState(initialState) - const toggle = useCallback(() => setState((state) => !state), []) + const toggle = useCallback(() => setState(state => !state), []) return [state, toggle] } diff --git a/src/hooks/useToggledVersion.ts b/src/hooks/useToggledVersion.ts index 3d8d71f5f3..28956bba9e 100644 --- a/src/hooks/useToggledVersion.ts +++ b/src/hooks/useToggledVersion.ts @@ -2,7 +2,7 @@ import useParsedQueryString from './useParsedQueryString' export enum Version { v1 = 'v1', - v2 = 'v2', + v2 = 'v2' } export const DEFAULT_VERSION: Version = Version.v2 diff --git a/src/hooks/useTransactionDeadline.ts b/src/hooks/useTransactionDeadline.ts index 1e369901b7..0f6e888c53 100644 --- a/src/hooks/useTransactionDeadline.ts +++ b/src/hooks/useTransactionDeadline.ts @@ -6,7 +6,7 @@ import useCurrentBlockTimestamp from './useCurrentBlockTimestamp' // combines the block timestamp with the user setting to give the deadline that should be used for any submitted transaction export default function useTransactionDeadline(): BigNumber | undefined { - const ttl = useSelector((state) => state.user.userDeadline) + const ttl = useSelector(state => state.user.userDeadline) const blockTimestamp = useCurrentBlockTimestamp() return useMemo(() => { if (blockTimestamp && ttl) return blockTimestamp.add(ttl) diff --git a/src/hooks/useWindowSize.ts b/src/hooks/useWindowSize.ts index e497064a07..231c6335fd 100644 --- a/src/hooks/useWindowSize.ts +++ b/src/hooks/useWindowSize.ts @@ -5,7 +5,7 @@ const isClient = typeof window === 'object' function getSize() { return { width: isClient ? window.innerWidth : undefined, - height: isClient ? window.innerHeight : undefined, + height: isClient ? window.innerHeight : undefined } } diff --git a/src/hooks/useWrapCallback.ts b/src/hooks/useWrapCallback.ts index 5e7b228720..46a4f8e2d3 100644 --- a/src/hooks/useWrapCallback.ts +++ b/src/hooks/useWrapCallback.ts @@ -9,7 +9,7 @@ import { useWETHContract } from './useContract' export enum WrapType { NOT_APPLICABLE, WRAP, - UNWRAP, + UNWRAP } const NOT_APPLICABLE = { wrapType: WrapType.NOT_APPLICABLE } @@ -50,7 +50,7 @@ export default function useWrapCallback( } } : undefined, - inputError: sufficientBalance ? undefined : 'Insufficient ETH balance', + inputError: sufficientBalance ? undefined : 'Insufficient ETH balance' } } else if (currencyEquals(WETH[chainId], inputCurrency) && outputCurrency === ETHER) { return { @@ -66,7 +66,7 @@ export default function useWrapCallback( } } : undefined, - inputError: sufficientBalance ? undefined : 'Insufficient WETH balance', + inputError: sufficientBalance ? undefined : 'Insufficient WETH balance' } } else { return NOT_APPLICABLE diff --git a/src/i18n.ts b/src/i18n.ts index b0ec539f83..1a77dc1f7e 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -9,15 +9,15 @@ i18next .use(initReactI18next) .init({ backend: { - loadPath: `./locales/{{lng}}.json`, + loadPath: `./locales/{{lng}}.json` }, react: { - useSuspense: true, + useSuspense: true }, fallbackLng: 'en', preload: ['en'], keySeparator: false, - interpolation: { escapeValue: false }, + interpolation: { escapeValue: false } }) export default i18next diff --git a/src/index.tsx b/src/index.tsx index f4d9ca8559..b7f4450ae1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -29,20 +29,16 @@ const GOOGLE_ANALYTICS_ID: string | undefined = process.env.REACT_APP_GOOGLE_ANA if (typeof GOOGLE_ANALYTICS_ID === 'string') { ReactGA.initialize(GOOGLE_ANALYTICS_ID) ReactGA.set({ - customBrowserType: !isMobile - ? 'desktop' - : 'web3' in window || 'ethereum' in window - ? 'mobileWeb3' - : 'mobileRegular', + customBrowserType: !isMobile ? 'desktop' : 'web3' in window || 'ethereum' in window ? 'mobileWeb3' : 'mobileRegular' }) } else { ReactGA.initialize('test', { testMode: true, debug: true }) } -window.addEventListener('error', (error) => { +window.addEventListener('error', error => { ReactGA.exception({ description: `${error.message} @ ${error.filename}:${error.lineno}:${error.colno}`, - fatal: true, + fatal: true }) }) diff --git a/src/pages/AddLiquidity/ConfirmAddModalBottom.tsx b/src/pages/AddLiquidity/ConfirmAddModalBottom.tsx index e833433a75..2ca63a8e92 100644 --- a/src/pages/AddLiquidity/ConfirmAddModalBottom.tsx +++ b/src/pages/AddLiquidity/ConfirmAddModalBottom.tsx @@ -13,7 +13,7 @@ export function ConfirmAddModalBottom({ currencies, parsedAmounts, poolTokenPercentage, - onAdd, + onAdd }: { noLiquidity?: boolean price?: Fraction diff --git a/src/pages/AddLiquidity/PoolPriceBar.tsx b/src/pages/AddLiquidity/PoolPriceBar.tsx index a3690f0a71..9d2f920be3 100644 --- a/src/pages/AddLiquidity/PoolPriceBar.tsx +++ b/src/pages/AddLiquidity/PoolPriceBar.tsx @@ -12,7 +12,7 @@ export function PoolPriceBar({ currencies, noLiquidity, poolTokenPercentage, - price, + price }: { currencies: { [field in Field]?: Currency } noLiquidity?: boolean diff --git a/src/pages/AddLiquidity/index.tsx b/src/pages/AddLiquidity/index.tsx index 4f4be0e871..ac57040f28 100644 --- a/src/pages/AddLiquidity/index.tsx +++ b/src/pages/AddLiquidity/index.tsx @@ -43,9 +43,9 @@ import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter export default function AddLiquidity({ match: { - params: { currencyIdA, currencyIdB }, + params: { currencyIdA, currencyIdB } }, - history, + history }: RouteComponentProps<{ currencyIdA?: string; currencyIdB?: string }>) { const { account, chainId, library } = useActiveWeb3React() const theme = useContext(ThemeContext) @@ -76,7 +76,7 @@ export default function AddLiquidity({ noLiquidity, liquidityMinted, poolTokenPercentage, - error, + error } = useDerivedMintInfo(currencyA ?? undefined, currencyB ?? undefined) const { onFieldAInput, onFieldBInput } = useMintActionHandlers(noLiquidity) @@ -95,7 +95,7 @@ export default function AddLiquidity({ // get formatted amounts const formattedAmounts = { [independentField]: typedValue, - [dependentField]: noLiquidity ? otherTypedValue : parsedAmounts[dependentField]?.toSignificant(6) ?? '', + [dependentField]: noLiquidity ? otherTypedValue : parsedAmounts[dependentField]?.toSignificant(6) ?? '' } // get the max amounts user can add @@ -103,7 +103,7 @@ export default function AddLiquidity({ (accumulator, field) => { return { ...accumulator, - [field]: maxAmountSpend(currencyBalances[field]), + [field]: maxAmountSpend(currencyBalances[field]) } }, {} @@ -113,7 +113,7 @@ export default function AddLiquidity({ (accumulator, field) => { return { ...accumulator, - [field]: maxAmounts[field]?.equalTo(parsedAmounts[field] ?? '0'), + [field]: maxAmounts[field]?.equalTo(parsedAmounts[field] ?? '0') } }, {} @@ -136,7 +136,7 @@ export default function AddLiquidity({ const amountsMin = { [Field.CURRENCY_A]: calculateSlippageAmount(parsedAmountA, noLiquidity ? 0 : allowedSlippage)[0], - [Field.CURRENCY_B]: calculateSlippageAmount(parsedAmountB, noLiquidity ? 0 : allowedSlippage)[0], + [Field.CURRENCY_B]: calculateSlippageAmount(parsedAmountB, noLiquidity ? 0 : allowedSlippage)[0] } let estimate, @@ -153,7 +153,7 @@ export default function AddLiquidity({ amountsMin[tokenBIsETH ? Field.CURRENCY_A : Field.CURRENCY_B].toString(), // token min amountsMin[tokenBIsETH ? Field.CURRENCY_B : Field.CURRENCY_A].toString(), // eth min account, - deadline.toHexString(), + deadline.toHexString() ] value = BigNumber.from((tokenBIsETH ? parsedAmountB : parsedAmountA).raw.toString()) } else { @@ -167,18 +167,18 @@ export default function AddLiquidity({ amountsMin[Field.CURRENCY_A].toString(), amountsMin[Field.CURRENCY_B].toString(), account, - deadline.toHexString(), + deadline.toHexString() ] value = null } setAttemptingTxn(true) await estimate(...args, value ? { value } : {}) - .then((estimatedGasLimit) => + .then(estimatedGasLimit => method(...args, { ...(value ? { value } : {}), - gasLimit: calculateGasMargin(estimatedGasLimit), - }).then((response) => { + gasLimit: calculateGasMargin(estimatedGasLimit) + }).then(response => { setAttemptingTxn(false) addTransaction(response, { @@ -190,7 +190,7 @@ export default function AddLiquidity({ ' and ' + parsedAmounts[Field.CURRENCY_B]?.toSignificant(3) + ' ' + - currencies[Field.CURRENCY_B]?.symbol, + currencies[Field.CURRENCY_B]?.symbol }) setTxHash(response.hash) @@ -198,11 +198,11 @@ export default function AddLiquidity({ ReactGA.event({ category: 'Liquidity', action: 'Add', - label: [currencies[Field.CURRENCY_A]?.symbol, currencies[Field.CURRENCY_B]?.symbol].join('/'), + label: [currencies[Field.CURRENCY_A]?.symbol, currencies[Field.CURRENCY_B]?.symbol].join('/') }) }) ) - .catch((error) => { + .catch(error => { setAttemptingTxn(false) // we only care if the error is something _other_ than the user rejected the tx if (error?.code !== 4001) { @@ -245,9 +245,8 @@ export default function AddLiquidity({ - {`Output is estimated. If the price changes by more than ${ - allowedSlippage / 100 - }% your transaction will revert.`} + {`Output is estimated. If the price changes by more than ${allowedSlippage / + 100}% your transaction will revert.`} ) diff --git a/src/pages/AddLiquidity/redirects.tsx b/src/pages/AddLiquidity/redirects.tsx index af30bcddd3..d794eaea0b 100644 --- a/src/pages/AddLiquidity/redirects.tsx +++ b/src/pages/AddLiquidity/redirects.tsx @@ -10,8 +10,8 @@ const OLD_PATH_STRUCTURE = /^(0x[a-fA-F0-9]{40})-(0x[a-fA-F0-9]{40})$/ export function RedirectOldAddLiquidityPathStructure(props: RouteComponentProps<{ currencyIdA: string }>) { const { match: { - params: { currencyIdA }, - }, + params: { currencyIdA } + } } = props const match = currencyIdA.match(OLD_PATH_STRUCTURE) if (match?.length) { @@ -24,8 +24,8 @@ export function RedirectOldAddLiquidityPathStructure(props: RouteComponentProps< export function RedirectDuplicateTokenIds(props: RouteComponentProps<{ currencyIdA: string; currencyIdB: string }>) { const { match: { - params: { currencyIdA, currencyIdB }, - }, + params: { currencyIdA, currencyIdB } + } } = props if (currencyIdA.toLowerCase() === currencyIdB.toLowerCase()) { return diff --git a/src/pages/App.tsx b/src/pages/App.tsx index 3e96230f87..a9d7fcddb9 100644 --- a/src/pages/App.tsx +++ b/src/pages/App.tsx @@ -15,7 +15,7 @@ import AddLiquidity from './AddLiquidity' import { RedirectDuplicateTokenIds, RedirectOldAddLiquidityPathStructure, - RedirectToAddLiquidity, + RedirectToAddLiquidity } from './AddLiquidity/redirects' import Earn from './Earn' import Manage from './Earn/Manage' diff --git a/src/pages/Earn/Countdown.tsx b/src/pages/Earn/Countdown.tsx index 3aded4da0f..e7088a77cc 100644 --- a/src/pages/Earn/Countdown.tsx +++ b/src/pages/Earn/Countdown.tsx @@ -10,7 +10,7 @@ const REWARDS_DURATION = DAY * REWARDS_DURATION_DAYS export function Countdown({ exactEnd }: { exactEnd?: Date }) { // get end/beginning times const end = useMemo(() => (exactEnd ? Math.floor(exactEnd.getTime() / 1000) : STAKING_GENESIS + REWARDS_DURATION), [ - exactEnd, + exactEnd ]) const begin = useMemo(() => end - REWARDS_DURATION, [end]) diff --git a/src/pages/Earn/Manage.tsx b/src/pages/Earn/Manage.tsx index 69972a59fe..9e1ac4cb47 100644 --- a/src/pages/Earn/Manage.tsx +++ b/src/pages/Earn/Manage.tsx @@ -89,8 +89,8 @@ const DataRow = styled(RowBetween)` export default function Manage({ match: { - params: { currencyIdA, currencyIdB }, - }, + params: { currencyIdA, currencyIdB } + } }: RouteComponentProps<{ currencyIdA: string; currencyIdB: string }>) { const { account, chainId } = useActiveWeb3React() diff --git a/src/pages/Earn/index.tsx b/src/pages/Earn/index.tsx index 25f6897328..326b8954d3 100644 --- a/src/pages/Earn/index.tsx +++ b/src/pages/Earn/index.tsx @@ -48,7 +48,7 @@ export default function Earn() { * only show staking cards with balance * @todo only account for this if rewards are inactive */ - const stakingInfosWithBalance = stakingInfos?.filter((s) => JSBI.greaterThan(s.stakedAmount.raw, BIG_INT_ZERO)) + const stakingInfosWithBalance = stakingInfos?.filter(s => JSBI.greaterThan(s.stakedAmount.raw, BIG_INT_ZERO)) // toggle copy if rewards are inactive const stakingRewardsExist = Boolean(typeof chainId === 'number' && (STAKING_REWARDS_INFO[chainId]?.length ?? 0) > 0) @@ -97,7 +97,7 @@ export default function Earn() { ) : stakingInfos?.length !== 0 && stakingInfosWithBalance.length === 0 ? ( No active pools ) : ( - stakingInfosWithBalance?.map((stakingInfo) => { + stakingInfosWithBalance?.map(stakingInfo => { // need to sort by added liquidity here return }) diff --git a/src/pages/MigrateV1/MigrateV1Exchange.tsx b/src/pages/MigrateV1/MigrateV1Exchange.tsx index 1a6878ea49..3a26b8f513 100644 --- a/src/pages/MigrateV1/MigrateV1Exchange.tsx +++ b/src/pages/MigrateV1/MigrateV1Exchange.tsx @@ -39,7 +39,7 @@ export function V1LiquidityInfo({ token, liquidityTokenAmount, tokenWorth, - ethWorth, + ethWorth }: { token: Token liquidityTokenAmount: TokenAmount @@ -118,7 +118,12 @@ function V1PairMigration({ liquidityTokenAmount, token }: { liquidityTokenAmount : null const priceDifferenceFraction: Fraction | undefined = - v1SpotPrice && v2SpotPrice ? v1SpotPrice.divide(v2SpotPrice).multiply('100').subtract('100') : undefined + v1SpotPrice && v2SpotPrice + ? v1SpotPrice + .divide(v2SpotPrice) + .multiply('100') + .subtract('100') + : undefined const priceDifferenceAbs: Fraction | undefined = priceDifferenceFraction?.lessThan(ZERO) ? priceDifferenceFraction?.multiply('-1') @@ -126,7 +131,10 @@ function V1PairMigration({ liquidityTokenAmount, token }: { liquidityTokenAmount const minAmountETH: JSBI | undefined = v2SpotPrice && tokenWorth - ? tokenWorth.divide(v2SpotPrice).multiply(WEI_DENOM).multiply(ALLOWED_OUTPUT_MIN_PERCENT).quotient + ? tokenWorth + .divide(v2SpotPrice) + .multiply(WEI_DENOM) + .multiply(ALLOWED_OUTPUT_MIN_PERCENT).quotient : ethWorth?.numerator const minAmountToken: JSBI | undefined = @@ -157,11 +165,11 @@ function V1PairMigration({ liquidityTokenAmount, token }: { liquidityTokenAmount ReactGA.event({ category: 'Migrate', action: 'V1->V2', - label: token?.symbol, + label: token?.symbol }) addTransaction(response, { - summary: `Migrate ${token.symbol} liquidity to V2`, + summary: `Migrate ${token.symbol} liquidity to V2` }) setPendingMigrationHash(response.hash) }) @@ -305,8 +313,8 @@ function V1PairMigration({ liquidityTokenAmount, token }: { liquidityTokenAmount export default function MigrateV1Exchange({ history, match: { - params: { address }, - }, + params: { address } + } }: RouteComponentProps<{ address: string }>) { const validatedAddress = isAddress(address) const { chainId, account } = useActiveWeb3React() diff --git a/src/pages/MigrateV1/RemoveV1Exchange.tsx b/src/pages/MigrateV1/RemoveV1Exchange.tsx index 63f1354be1..6b58d96d6f 100644 --- a/src/pages/MigrateV1/RemoveV1Exchange.tsx +++ b/src/pages/MigrateV1/RemoveV1Exchange.tsx @@ -33,7 +33,7 @@ const ZERO_FRACTION = new Fraction(ZERO, ONE) function V1PairRemoval({ exchangeContract, liquidityTokenAmount, - token, + token }: { exchangeContract: Contract liquidityTokenAmount: TokenAmount @@ -75,11 +75,11 @@ function V1PairRemoval({ ReactGA.event({ category: 'Remove', action: 'V1', - label: token?.symbol, + label: token?.symbol }) addTransaction(response, { - summary: `Remove ${chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}/ETH V1 liquidity`, + summary: `Remove ${chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}/ETH V1 liquidity` }) setPendingRemovalHash(response.hash) }) @@ -128,8 +128,8 @@ function V1PairRemoval({ export default function RemoveV1Exchange({ match: { - params: { address }, - }, + params: { address } + } }: RouteComponentProps<{ address: string }>) { const validatedAddress = isAddress(address) const { chainId, account } = useActiveWeb3React() diff --git a/src/pages/MigrateV1/index.tsx b/src/pages/MigrateV1/index.tsx index 3ced6836cf..1e15daa13e 100644 --- a/src/pages/MigrateV1/index.tsx +++ b/src/pages/MigrateV1/index.tsx @@ -24,7 +24,7 @@ export default function MigrateV1() { const { account, chainId } = useActiveWeb3React() const [tokenSearch, setTokenSearch] = useState('') - const handleTokenSearchChange = useCallback((e) => setTokenSearch(e.target.value), [setTokenSearch]) + const handleTokenSearchChange = useCallback(e => setTokenSearch(e.target.value), [setTokenSearch]) // automatically add the search token const token = useToken(tokenSearch) @@ -42,19 +42,17 @@ export default function MigrateV1() { const V1Exchanges = useAllTokenV1Exchanges() const V1LiquidityTokens: Token[] = useMemo(() => { return chainId - ? Object.keys(V1Exchanges).map( - (exchangeAddress) => new Token(chainId, exchangeAddress, 18, 'UNI-V1', 'Uniswap V1') - ) + ? Object.keys(V1Exchanges).map(exchangeAddress => new Token(chainId, exchangeAddress, 18, 'UNI-V1', 'Uniswap V1')) : [] }, [chainId, V1Exchanges]) const [V1LiquidityBalances, V1LiquidityBalancesLoading] = useTokenBalancesWithLoadingIndicator( account ?? undefined, V1LiquidityTokens ) - const allV1PairsWithLiquidity = V1LiquidityTokens.filter((V1LiquidityToken) => { + const allV1PairsWithLiquidity = V1LiquidityTokens.filter(V1LiquidityToken => { const balance = V1LiquidityBalances?.[V1LiquidityToken.address] return balance && JSBI.greaterThan(balance.raw, JSBI.BigInt(0)) - }).map((V1LiquidityToken) => { + }).map(V1LiquidityToken => { const balance = V1LiquidityBalances[V1LiquidityToken.address] return balance ? ( trackedTokenPairs.map((tokens) => ({ liquidityToken: toV2LiquidityToken(tokens), tokens })), + () => trackedTokenPairs.map(tokens => ({ liquidityToken: toV2LiquidityToken(tokens), tokens })), [trackedTokenPairs] ) - const liquidityTokens = useMemo(() => tokenPairsWithLiquidityTokens.map((tpwlt) => tpwlt.liquidityToken), [ - tokenPairsWithLiquidityTokens, + const liquidityTokens = useMemo(() => tokenPairsWithLiquidityTokens.map(tpwlt => tpwlt.liquidityToken), [ + tokenPairsWithLiquidityTokens ]) const [v2PairsBalances, fetchingV2PairBalances] = useTokenBalancesWithLoadingIndicator( account ?? undefined, @@ -103,7 +103,7 @@ export default function Pool() { const v2Pairs = usePairs(liquidityTokensWithBalances.map(({ tokens }) => tokens)) const v2IsLoading = - fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some((V2Pair) => !V2Pair) + fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some(V2Pair => !V2Pair) const allV2PairsWithLiquidity = v2Pairs.map(([, pair]) => pair).filter((v2Pair): v2Pair is Pair => Boolean(v2Pair)) @@ -111,15 +111,15 @@ export default function Pool() { // show liquidity even if its deposited in rewards contract const stakingInfo = useStakingInfo() - const stakingInfosWithBalance = stakingInfo?.filter((pool) => JSBI.greaterThan(pool.stakedAmount.raw, BIG_INT_ZERO)) - const stakingPairs = usePairs(stakingInfosWithBalance?.map((stakingInfo) => stakingInfo.tokens)) + const stakingInfosWithBalance = stakingInfo?.filter(pool => JSBI.greaterThan(pool.stakedAmount.raw, BIG_INT_ZERO)) + const stakingPairs = usePairs(stakingInfosWithBalance?.map(stakingInfo => stakingInfo.tokens)) // remove any pairs that also are included in pairs with stake in mining pool - const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter((v2Pair) => { + const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter(v2Pair => { return ( stakingPairs - ?.map((stakingPair) => stakingPair[1]) - .filter((stakingPair) => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0 + ?.map(stakingPair => stakingPair[1]) + .filter(stakingPair => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0 ) }) @@ -201,7 +201,7 @@ export default function Pool() { - {v2PairsWithoutStakedAmount.map((v2Pair) => ( + {v2PairsWithoutStakedAmount.map(v2Pair => ( ))} {stakingPairs.map( diff --git a/src/pages/PoolFinder/index.tsx b/src/pages/PoolFinder/index.tsx index 46593460b9..bc7c003186 100644 --- a/src/pages/PoolFinder/index.tsx +++ b/src/pages/PoolFinder/index.tsx @@ -23,7 +23,7 @@ import { TYPE } from '../../theme' enum Fields { TOKEN0 = 0, - TOKEN1 = 1, + TOKEN1 = 1 } export default function PoolFinder() { diff --git a/src/pages/RemoveLiquidity/index.tsx b/src/pages/RemoveLiquidity/index.tsx index 5323c28c12..7515c6c7c5 100644 --- a/src/pages/RemoveLiquidity/index.tsx +++ b/src/pages/RemoveLiquidity/index.tsx @@ -47,15 +47,15 @@ import { BigNumber } from '@ethersproject/bignumber' export default function RemoveLiquidity({ history, match: { - params: { currencyIdA, currencyIdB }, - }, + params: { currencyIdA, currencyIdB } + } }: RouteComponentProps<{ currencyIdA: string; currencyIdB: string }>) { const [currencyA, currencyB] = [useCurrency(currencyIdA) ?? undefined, useCurrency(currencyIdB) ?? undefined] const { account, chainId, library } = useActiveWeb3React() const [tokenA, tokenB] = useMemo(() => [wrappedCurrency(currencyA, chainId), wrappedCurrency(currencyB, chainId)], [ currencyA, currencyB, - chainId, + chainId ]) const theme = useContext(ThemeContext) @@ -90,7 +90,7 @@ export default function RemoveLiquidity({ [Field.CURRENCY_A]: independentField === Field.CURRENCY_A ? typedValue : parsedAmounts[Field.CURRENCY_A]?.toSignificant(6) ?? '', [Field.CURRENCY_B]: - independentField === Field.CURRENCY_B ? typedValue : parsedAmounts[Field.CURRENCY_B]?.toSignificant(6) ?? '', + independentField === Field.CURRENCY_B ? typedValue : parsedAmounts[Field.CURRENCY_B]?.toSignificant(6) ?? '' } const atMaxAmount = parsedAmounts[Field.LIQUIDITY_PERCENT]?.equalTo(new Percent('1')) @@ -120,50 +120,50 @@ export default function RemoveLiquidity({ { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, + { name: 'verifyingContract', type: 'address' } ] const domain = { name: 'Uniswap V2', version: '1', chainId: chainId, - verifyingContract: pair.liquidityToken.address, + verifyingContract: pair.liquidityToken.address } const Permit = [ { name: 'owner', type: 'address' }, { name: 'spender', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, - { name: 'deadline', type: 'uint256' }, + { name: 'deadline', type: 'uint256' } ] const message = { owner: account, spender: ROUTER_ADDRESS, value: liquidityAmount.raw.toString(), nonce: nonce.toHexString(), - deadline: deadline.toNumber(), + deadline: deadline.toNumber() } const data = JSON.stringify({ types: { EIP712Domain, - Permit, + Permit }, domain, primaryType: 'Permit', - message, + message }) library .send('eth_signTypedData_v4', [account, data]) .then(splitSignature) - .then((signature) => { + .then(signature => { setSignatureData({ v: signature.v, r: signature.r, s: signature.s, - deadline: deadline.toNumber(), + deadline: deadline.toNumber() }) }) - .catch((error) => { + .catch(error => { // for all errors other than 4001 (EIP-1193 user rejected request), fall back to manual approve if (error?.code !== 4001) { approveCallback() @@ -181,13 +181,13 @@ export default function RemoveLiquidity({ ) const onLiquidityInput = useCallback((typedValue: string): void => onUserInput(Field.LIQUIDITY, typedValue), [ - onUserInput, + onUserInput ]) const onCurrencyAInput = useCallback((typedValue: string): void => onUserInput(Field.CURRENCY_A, typedValue), [ - onUserInput, + onUserInput ]) const onCurrencyBInput = useCallback((typedValue: string): void => onUserInput(Field.CURRENCY_B, typedValue), [ - onUserInput, + onUserInput ]) // tx sending @@ -202,7 +202,7 @@ export default function RemoveLiquidity({ const amountsMin = { [Field.CURRENCY_A]: calculateSlippageAmount(currencyAmountA, allowedSlippage)[0], - [Field.CURRENCY_B]: calculateSlippageAmount(currencyAmountB, allowedSlippage)[0], + [Field.CURRENCY_B]: calculateSlippageAmount(currencyAmountB, allowedSlippage)[0] } if (!currencyA || !currencyB) throw new Error('missing tokens') @@ -226,7 +226,7 @@ export default function RemoveLiquidity({ amountsMin[currencyBIsETH ? Field.CURRENCY_A : Field.CURRENCY_B].toString(), amountsMin[currencyBIsETH ? Field.CURRENCY_B : Field.CURRENCY_A].toString(), account, - deadline.toHexString(), + deadline.toHexString() ] } // removeLiquidity @@ -239,7 +239,7 @@ export default function RemoveLiquidity({ amountsMin[Field.CURRENCY_A].toString(), amountsMin[Field.CURRENCY_B].toString(), account, - deadline.toHexString(), + deadline.toHexString() ] } } @@ -258,7 +258,7 @@ export default function RemoveLiquidity({ false, signatureData.v, signatureData.r, - signatureData.s, + signatureData.s ] } // removeLiquidityETHWithPermit @@ -275,7 +275,7 @@ export default function RemoveLiquidity({ false, signatureData.v, signatureData.r, - signatureData.s, + signatureData.s ] } } else { @@ -283,17 +283,17 @@ export default function RemoveLiquidity({ } const safeGasEstimates: (BigNumber | undefined)[] = await Promise.all( - methodNames.map((methodName) => + methodNames.map(methodName => router.estimateGas[methodName](...args) .then(calculateGasMargin) - .catch((error) => { + .catch(error => { console.error(`estimateGas failed`, methodName, args, error) return undefined }) ) ) - const indexOfSuccessfulEstimation = safeGasEstimates.findIndex((safeGasEstimate) => + const indexOfSuccessfulEstimation = safeGasEstimates.findIndex(safeGasEstimate => BigNumber.isBigNumber(safeGasEstimate) ) @@ -306,7 +306,7 @@ export default function RemoveLiquidity({ setAttemptingTxn(true) await router[methodName](...args, { - gasLimit: safeGasEstimate, + gasLimit: safeGasEstimate }) .then((response: TransactionResponse) => { setAttemptingTxn(false) @@ -320,7 +320,7 @@ export default function RemoveLiquidity({ ' and ' + parsedAmounts[Field.CURRENCY_B]?.toSignificant(3) + ' ' + - currencyB?.symbol, + currencyB?.symbol }) setTxHash(response.hash) @@ -328,7 +328,7 @@ export default function RemoveLiquidity({ ReactGA.event({ category: 'Liquidity', action: 'Remove', - label: [currencyA?.symbol, currencyB?.symbol].join('/'), + label: [currencyA?.symbol, currencyB?.symbol].join('/') }) }) .catch((error: Error) => { @@ -369,9 +369,8 @@ export default function RemoveLiquidity({ - {`Output is estimated. If the price changes by more than ${ - allowedSlippage / 100 - }% your transaction will revert.`} + {`Output is estimated. If the price changes by more than ${allowedSlippage / + 100}% your transaction will revert.`} ) diff --git a/src/pages/RemoveLiquidity/redirects.tsx b/src/pages/RemoveLiquidity/redirects.tsx index 32c3e6b1d9..9a9538d40c 100644 --- a/src/pages/RemoveLiquidity/redirects.tsx +++ b/src/pages/RemoveLiquidity/redirects.tsx @@ -5,8 +5,8 @@ const OLD_PATH_STRUCTURE = /^(0x[a-fA-F0-9]{40})-(0x[a-fA-F0-9]{40})$/ export function RedirectOldRemoveLiquidityPathStructure({ match: { - params: { tokens }, - }, + params: { tokens } + } }: RouteComponentProps<{ tokens: string }>) { if (!OLD_PATH_STRUCTURE.test(tokens)) { return diff --git a/src/pages/Swap/index.tsx b/src/pages/Swap/index.tsx index 5a33fc62a7..5466e3ddb0 100644 --- a/src/pages/Swap/index.tsx +++ b/src/pages/Swap/index.tsx @@ -36,7 +36,7 @@ import { useDefaultsFromURLSearch, useDerivedSwapInfo, useSwapActionHandlers, - useSwapState, + useSwapState } from '../../state/swap/hooks' import { useExpertModeManager, useUserSlippageTolerance, useUserSingleHopOnly } from '../../state/user/hooks' import { LinkStyledButton, TYPE } from '../../theme' @@ -55,7 +55,7 @@ export default function Swap() { // token warning stuff const [loadedInputCurrency, loadedOutputCurrency] = [ useCurrency(loadedUrlParams?.inputCurrencyId), - useCurrency(loadedUrlParams?.outputCurrencyId), + useCurrency(loadedUrlParams?.outputCurrencyId) ] const [dismissTokenWarning, setDismissTokenWarning] = useState(false) const urlLoadedTokens: Token[] = useMemo( @@ -95,7 +95,7 @@ export default function Swap() { currencyBalances, parsedAmount, currencies, - inputError: swapInputError, + inputError: swapInputError } = useDerivedSwapInfo() const { wrapType, execute: onWrap, inputError: wrapInputError } = useWrapCallback( currencies[Field.INPUT], @@ -107,7 +107,7 @@ export default function Swap() { const toggledVersion = useToggledVersion() const tradesByVersion = { [Version.v1]: v1Trade, - [Version.v2]: v2Trade, + [Version.v2]: v2Trade } const trade = showWrap ? undefined : tradesByVersion[toggledVersion] const defaultTrade = showWrap ? undefined : tradesByVersion[DEFAULT_VERSION] @@ -118,11 +118,11 @@ export default function Swap() { const parsedAmounts = showWrap ? { [Field.INPUT]: parsedAmount, - [Field.OUTPUT]: parsedAmount, + [Field.OUTPUT]: parsedAmount } : { [Field.INPUT]: independentField === Field.INPUT ? parsedAmount : trade?.inputAmount, - [Field.OUTPUT]: independentField === Field.OUTPUT ? parsedAmount : trade?.outputAmount, + [Field.OUTPUT]: independentField === Field.OUTPUT ? parsedAmount : trade?.outputAmount } const { onSwitchTokens, onCurrencySelection, onUserInput, onChangeRecipient } = useSwapActionHandlers() @@ -154,14 +154,14 @@ export default function Swap() { tradeToConfirm: undefined, attemptingTxn: false, swapErrorMessage: undefined, - txHash: undefined, + txHash: undefined }) const formattedAmounts = { [independentField]: typedValue, [dependentField]: showWrap ? parsedAmounts[independentField]?.toExact() ?? '' - : parsedAmounts[dependentField]?.toSignificant(6) ?? '', + : parsedAmounts[dependentField]?.toSignificant(6) ?? '' } const route = trade?.route @@ -202,7 +202,7 @@ export default function Swap() { } setSwapState({ attemptingTxn: true, tradeToConfirm, showConfirm, swapErrorMessage: undefined, txHash: undefined }) swapCallback() - .then((hash) => { + .then(hash => { setSwapState({ attemptingTxn: false, tradeToConfirm, showConfirm, swapErrorMessage: undefined, txHash: hash }) ReactGA.event({ @@ -216,22 +216,22 @@ export default function Swap() { label: [ trade?.inputAmount?.currency?.symbol, trade?.outputAmount?.currency?.symbol, - getTradeVersion(trade), - ].join('/'), + getTradeVersion(trade) + ].join('/') }) ReactGA.event({ category: 'Routing', - action: singleHopOnly ? 'Swap with multihop disabled' : 'Swap with multihop enabled', + action: singleHopOnly ? 'Swap with multihop disabled' : 'Swap with multihop enabled' }) }) - .catch((error) => { + .catch(error => { setSwapState({ attemptingTxn: false, tradeToConfirm, showConfirm, swapErrorMessage: error.message, - txHash: undefined, + txHash: undefined }) }) }, [ @@ -243,7 +243,7 @@ export default function Swap() { recipientAddress, account, trade, - singleHopOnly, + singleHopOnly ]) // errors @@ -274,7 +274,7 @@ export default function Swap() { }, [attemptingTxn, showConfirm, swapErrorMessage, trade, txHash]) const handleInputSelect = useCallback( - (inputCurrency) => { + inputCurrency => { setApprovalSubmitted(false) // reset 2 step UI for approvals onCurrencySelection(Field.INPUT, inputCurrency) }, @@ -285,8 +285,8 @@ export default function Swap() { maxAmountInput && onUserInput(Field.INPUT, maxAmountInput.toExact()) }, [maxAmountInput, onUserInput]) - const handleOutputSelect = useCallback((outputCurrency) => onCurrencySelection(Field.OUTPUT, outputCurrency), [ - onCurrencySelection, + const handleOutputSelect = useCallback(outputCurrency => onCurrencySelection(Field.OUTPUT, outputCurrency), [ + onCurrencySelection ]) const swapIsUnsupported = useIsTransactionUnsupported(currencies?.INPUT, currencies?.OUTPUT) @@ -447,7 +447,7 @@ export default function Swap() { attemptingTxn: false, swapErrorMessage: undefined, showConfirm: true, - txHash: undefined, + txHash: undefined }) } }} @@ -476,7 +476,7 @@ export default function Swap() { attemptingTxn: false, swapErrorMessage: undefined, showConfirm: true, - txHash: undefined, + txHash: undefined }) } }} diff --git a/src/pages/Swap/redirects.tsx b/src/pages/Swap/redirects.tsx index 6e12bd5668..8bea2adebf 100644 --- a/src/pages/Swap/redirects.tsx +++ b/src/pages/Swap/redirects.tsx @@ -14,8 +14,8 @@ export function RedirectToSwap(props: RouteComponentProps<{ outputCurrency: stri const { location: { search }, match: { - params: { outputCurrency }, - }, + params: { outputCurrency } + } } = props return ( @@ -26,7 +26,7 @@ export function RedirectToSwap(props: RouteComponentProps<{ outputCurrency: stri search: search && search.length > 1 ? `${search}&outputCurrency=${outputCurrency}` - : `?outputCurrency=${outputCurrency}`, + : `?outputCurrency=${outputCurrency}` }} /> ) diff --git a/src/pages/Vote/VotePage.tsx b/src/pages/Vote/VotePage.tsx index a517b51d69..e4c156c0f4 100644 --- a/src/pages/Vote/VotePage.tsx +++ b/src/pages/Vote/VotePage.tsx @@ -105,8 +105,8 @@ const ProposerAddressLink = styled(ExternalLink)` export default function VotePage({ match: { - params: { id }, - }, + params: { id } + } }: RouteComponentProps<{ id: string }>) { const { chainId, account } = useActiveWeb3React() diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 5f4909a8c0..a08716b6e1 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -1,7 +1,7 @@ /// declare module 'jazzicon' { - export default function (diameter: number, seed: number): HTMLElement + export default function(diameter: number, seed: number): HTMLElement } declare module 'fortmatic' diff --git a/src/state/application/actions.ts b/src/state/application/actions.ts index dbed730f30..8576d1326c 100644 --- a/src/state/application/actions.ts +++ b/src/state/application/actions.ts @@ -26,7 +26,7 @@ export enum ApplicationModal { CLAIM_POPUP, MENU, DELEGATE, - VOTE, + VOTE } export const updateBlockNumber = createAction<{ chainId: number; blockNumber: number }>('application/updateBlockNumber') diff --git a/src/state/application/hooks.ts b/src/state/application/hooks.ts index 51f1b7cfca..6427574742 100644 --- a/src/state/application/hooks.ts +++ b/src/state/application/hooks.ts @@ -85,5 +85,5 @@ export function useRemovePopup(): (key: string) => void { // get the list of active popups export function useActivePopups(): AppState['application']['popupList'] { const list = useSelector((state: AppState) => state.application.popupList) - return useMemo(() => list.filter((item) => item.show), [list]) + return useMemo(() => list.filter(item => item.show), [list]) } diff --git a/src/state/application/reducer.test.ts b/src/state/application/reducer.test.ts index df2b99b838..6336e5cc4f 100644 --- a/src/state/application/reducer.test.ts +++ b/src/state/application/reducer.test.ts @@ -10,9 +10,9 @@ describe('application reducer', () => { store = createStore(reducer, { popupList: [], blockNumber: { - [ChainId.MAINNET]: 3, + [ChainId.MAINNET]: 3 }, - openModal: null, + openModal: null }) }) @@ -65,7 +65,7 @@ describe('application reducer', () => { store.dispatch(updateBlockNumber({ chainId: ChainId.ROPSTEN, blockNumber: 2 })) expect(store.getState().blockNumber).toEqual({ [ChainId.MAINNET]: 3, - [ChainId.ROPSTEN]: 2, + [ChainId.ROPSTEN]: 2 }) }) }) diff --git a/src/state/application/reducer.ts b/src/state/application/reducer.ts index c397ca4747..4d077831c5 100644 --- a/src/state/application/reducer.ts +++ b/src/state/application/reducer.ts @@ -12,10 +12,10 @@ export interface ApplicationState { const initialState: ApplicationState = { blockNumber: {}, popupList: [], - openModal: null, + openModal: null } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase(updateBlockNumber, (state, action) => { const { chainId, blockNumber } = action.payload @@ -29,17 +29,17 @@ export default createReducer(initialState, (builder) => state.openModal = action.payload }) .addCase(addPopup, (state, { payload: { content, key, removeAfterMs = 15000 } }) => { - state.popupList = (key ? state.popupList.filter((popup) => popup.key !== key) : state.popupList).concat([ + state.popupList = (key ? state.popupList.filter(popup => popup.key !== key) : state.popupList).concat([ { key: key || nanoid(), show: true, content, - removeAfterMs, - }, + removeAfterMs + } ]) }) .addCase(removePopup, (state, { payload: { key } }) => { - state.popupList.forEach((p) => { + state.popupList.forEach(p => { if (p.key === key) { p.show = false } diff --git a/src/state/application/updater.ts b/src/state/application/updater.ts index 525b1f3c7e..79765d67fd 100644 --- a/src/state/application/updater.ts +++ b/src/state/application/updater.ts @@ -13,12 +13,12 @@ export default function Updater(): null { const [state, setState] = useState<{ chainId: number | undefined; blockNumber: number | null }>({ chainId, - blockNumber: null, + blockNumber: null }) const blockNumberCallback = useCallback( (blockNumber: number) => { - setState((state) => { + setState(state => { if (chainId === state.chainId) { if (typeof state.blockNumber !== 'number') return { chainId, blockNumber } return { chainId, blockNumber: Math.max(blockNumber, state.blockNumber) } @@ -38,7 +38,7 @@ export default function Updater(): null { library .getBlockNumber() .then(blockNumberCallback) - .catch((error) => console.error(`Failed to get block number for chainId: ${chainId}`, error)) + .catch(error => console.error(`Failed to get block number for chainId: ${chainId}`, error)) library.on('block', blockNumberCallback) return () => { diff --git a/src/state/burn/actions.ts b/src/state/burn/actions.ts index e746699fb7..3217b6ccc5 100644 --- a/src/state/burn/actions.ts +++ b/src/state/burn/actions.ts @@ -4,7 +4,7 @@ export enum Field { LIQUIDITY_PERCENT = 'LIQUIDITY_PERCENT', LIQUIDITY = 'LIQUIDITY', CURRENCY_A = 'CURRENCY_A', - CURRENCY_B = 'CURRENCY_B', + CURRENCY_B = 'CURRENCY_B' } export const typeInput = createAction<{ field: Field; typedValue: string }>('burn/typeInputBurn') diff --git a/src/state/burn/hooks.ts b/src/state/burn/hooks.ts index d2989dd7f6..963e83020b 100644 --- a/src/state/burn/hooks.ts +++ b/src/state/burn/hooks.ts @@ -12,7 +12,7 @@ import { useTokenBalances } from '../wallet/hooks' import { Field, typeInput } from './actions' export function useBurnState(): AppState['burn'] { - return useSelector((state) => state.burn) + return useSelector(state => state.burn) } export function useDerivedBurnInfo( @@ -43,7 +43,7 @@ export function useDerivedBurnInfo( const tokens = { [Field.CURRENCY_A]: tokenA, [Field.CURRENCY_B]: tokenB, - [Field.LIQUIDITY]: pair?.liquidityToken, + [Field.LIQUIDITY]: pair?.liquidityToken } // liquidity values @@ -68,7 +68,7 @@ export function useDerivedBurnInfo( : undefined const liquidityValues: { [Field.CURRENCY_A]?: TokenAmount; [Field.CURRENCY_B]?: TokenAmount } = { [Field.CURRENCY_A]: liquidityValueA, - [Field.CURRENCY_B]: liquidityValueB, + [Field.CURRENCY_B]: liquidityValueB } let percentToRemove: Percent = new Percent('0', '100') @@ -114,7 +114,7 @@ export function useDerivedBurnInfo( [Field.CURRENCY_B]: tokenB && percentToRemove && percentToRemove.greaterThan('0') && liquidityValueB ? new TokenAmount(tokenB, percentToRemove.multiply(liquidityValueB.raw).quotient) - : undefined, + : undefined } let error: string | undefined @@ -142,6 +142,6 @@ export function useBurnActionHandlers(): { ) return { - onUserInput, + onUserInput } } diff --git a/src/state/burn/reducer.ts b/src/state/burn/reducer.ts index b7c1e34646..0fc7cb4796 100644 --- a/src/state/burn/reducer.ts +++ b/src/state/burn/reducer.ts @@ -8,15 +8,15 @@ export interface BurnState { const initialState: BurnState = { independentField: Field.LIQUIDITY_PERCENT, - typedValue: '0', + typedValue: '0' } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder.addCase(typeInput, (state, { payload: { field, typedValue } }) => { return { ...state, independentField: field, - typedValue, + typedValue } }) ) diff --git a/src/state/claim/hooks.ts b/src/state/claim/hooks.ts index 050ee7daff..4f23509bb5 100644 --- a/src/state/claim/hooks.ts +++ b/src/state/claim/hooks.ts @@ -30,7 +30,7 @@ function fetchClaim(account: string, chainId: ChainId): Promise { + .then(res => { if (res.status === 200) { return res.json() } else { @@ -38,7 +38,7 @@ function fetchClaim(account: string, chainId: ChainId): Promise { + .catch(error => { console.error('Failed to get claim data', error) })) } @@ -53,11 +53,11 @@ export function useUserClaimData(account: string | null | undefined): UserClaimD useEffect(() => { if (!account || !chainId) return - fetchClaim(account, chainId).then((accountClaimInfo) => - setClaimInfo((claimInfo) => { + fetchClaim(account, chainId).then(accountClaimInfo => + setClaimInfo(claimInfo => { return { ...claimInfo, - [key]: accountClaimInfo, + [key]: accountClaimInfo } }) ) @@ -102,18 +102,18 @@ export function useClaimCallback( const addTransaction = useTransactionAdder() const distributorContract = useMerkleDistributorContract() - const claimCallback = async function () { + const claimCallback = async function() { if (!claimData || !account || !library || !chainId || !distributorContract) return const args = [claimData.index, account, claimData.amount, claimData.proof] - return distributorContract.estimateGas['claim'](...args, {}).then((estimatedGasLimit) => { + return distributorContract.estimateGas['claim'](...args, {}).then(estimatedGasLimit => { return distributorContract .claim(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) }) .then((response: TransactionResponse) => { addTransaction(response, { summary: `Claimed ${unClaimedAmount?.toSignificant(4)} UNI`, - claim: { recipient: account }, + claim: { recipient: account } }) return response.hash }) diff --git a/src/state/governance/hooks.ts b/src/state/governance/hooks.ts index 7a5b38b8af..e2833161c6 100644 --- a/src/state/governance/hooks.ts +++ b/src/state/governance/hooks.ts @@ -63,7 +63,7 @@ export function useDataFromEventLogs() { const pastEvents = await library?.getLogs(filter) // reverse events to get them from newest to odlest const formattedEventData = pastEvents - ?.map((event) => { + ?.map(event => { const eventParsed = eventParser.parseLog(event).args return { description: eventParsed.description, @@ -77,9 +77,9 @@ export function useDataFromEventLogs() { return { target, functionSig: name, - callData: decoded.join(', '), + callData: decoded.join(', ') } - }), + }) } }) .reverse() @@ -132,7 +132,7 @@ export function useAllProposalData() { againstCount: parseFloat(ethers.utils.formatUnits(allProposals[i]?.result?.againstVotes.toString(), 18)), startBlock: parseInt(allProposals[i]?.result?.startBlock?.toString()), endBlock: parseInt(allProposals[i]?.result?.endBlock?.toString()), - details: formattedEvents[i].details, + details: formattedEvents[i].details } return formattedProposal }) @@ -143,7 +143,7 @@ export function useAllProposalData() { export function useProposalData(id: string): ProposalData | undefined { const allProposalData = useAllProposalData() - return allProposalData?.find((p) => p.id === id) + return allProposalData?.find(p => p.id === id) } // get the users delegatee if it exists @@ -188,12 +188,12 @@ export function useDelegateCallback(): (delegatee: string | undefined) => undefi if (!library || !chainId || !account || !isAddress(delegatee ?? '')) return undefined const args = [delegatee] if (!uniContract) throw new Error('No UNI Contract!') - return uniContract.estimateGas.delegate(...args, {}).then((estimatedGasLimit) => { + return uniContract.estimateGas.delegate(...args, {}).then(estimatedGasLimit => { return uniContract .delegate(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) }) .then((response: TransactionResponse) => { addTransaction(response, { - summary: `Delegated votes`, + summary: `Delegated votes` }) return response.hash }) @@ -215,12 +215,12 @@ export function useVoteCallback(): { (proposalId: string | undefined, support: boolean) => { if (!account || !govContract || !proposalId) return const args = [proposalId, support] - return govContract.estimateGas.castVote(...args, {}).then((estimatedGasLimit) => { + return govContract.estimateGas.castVote(...args, {}).then(estimatedGasLimit => { return govContract .castVote(...args, { value: null, gasLimit: calculateGasMargin(estimatedGasLimit) }) .then((response: TransactionResponse) => { addTransaction(response, { - summary: `Voted ${support ? 'for ' : 'against'} proposal ${proposalId}`, + summary: `Voted ${support ? 'for ' : 'against'} proposal ${proposalId}` }) return response.hash }) diff --git a/src/state/index.ts b/src/state/index.ts index f88ab03074..12f195ff38 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -22,10 +22,10 @@ const store = configureStore({ mint, burn, multicall, - lists, + lists }, middleware: [...getDefaultMiddleware({ thunk: false }), save({ states: PERSISTED_KEYS })], - preloadedState: load({ states: PERSISTED_KEYS }), + preloadedState: load({ states: PERSISTED_KEYS }) }) store.dispatch(updateVersion()) diff --git a/src/state/lists/actions.ts b/src/state/lists/actions.ts index a64724c3ac..c2c4e898bc 100644 --- a/src/state/lists/actions.ts +++ b/src/state/lists/actions.ts @@ -8,7 +8,7 @@ export const fetchTokenList: Readonly<{ }> = { pending: createAction('lists/fetchTokenList/pending'), fulfilled: createAction('lists/fetchTokenList/fulfilled'), - rejected: createAction('lists/fetchTokenList/rejected'), + rejected: createAction('lists/fetchTokenList/rejected') } // add and remove from list options export const addList = createAction('lists/addList') diff --git a/src/state/lists/hooks.ts b/src/state/lists/hooks.ts index 5ecf75abda..796e1438ef 100644 --- a/src/state/lists/hooks.ts +++ b/src/state/lists/hooks.ts @@ -41,7 +41,7 @@ const EMPTY_LIST: TokenAddressMap = { [ChainId.RINKEBY]: {}, [ChainId.ROPSTEN]: {}, [ChainId.GÖRLI]: {}, - [ChainId.MAINNET]: {}, + [ChainId.MAINNET]: {} } const listCache: WeakMap | null = @@ -55,7 +55,7 @@ export function listToTokenMap(list: TokenList): TokenAddressMap { (tokenMap, tokenInfo) => { const tags: TagInfo[] = tokenInfo.tags - ?.map((tagId) => { + ?.map(tagId => { if (!list.tags?.[tagId]) return undefined return { ...list.tags[tagId], id: tagId } }) @@ -68,9 +68,9 @@ export function listToTokenMap(list: TokenList): TokenAddressMap { ...tokenMap[token.chainId], [token.address]: { token, - list: list, - }, - }, + list: list + } + } } }, { ...EMPTY_LIST } @@ -87,7 +87,7 @@ export function useAllLists(): { readonly error: string | null } } { - return useSelector((state) => state.lists.byUrl) + return useSelector(state => state.lists.byUrl) } function combineMaps(map1: TokenAddressMap, map2: TokenAddressMap): TokenAddressMap { @@ -96,7 +96,7 @@ function combineMaps(map1: TokenAddressMap, map2: TokenAddressMap): TokenAddress 3: { ...map1[3], ...map2[3] }, 4: { ...map1[4], ...map2[4] }, 5: { ...map1[5], ...map2[5] }, - 42: { ...map1[42], ...map2[42] }, + 42: { ...map1[42], ...map2[42] } } } @@ -129,15 +129,15 @@ function useCombinedTokenMapFromUrls(urls: string[] | undefined): TokenAddressMa // filter out unsupported lists export function useActiveListUrls(): string[] | undefined { - return useSelector((state) => state.lists.activeListUrls)?.filter( - (url) => !UNSUPPORTED_LIST_URLS.includes(url) + return useSelector(state => state.lists.activeListUrls)?.filter( + url => !UNSUPPORTED_LIST_URLS.includes(url) ) } export function useInactiveListUrls(): string[] { const lists = useAllLists() const allActiveListUrls = useActiveListUrls() - return Object.keys(lists).filter((url) => !allActiveListUrls?.includes(url) && !UNSUPPORTED_LIST_URLS.includes(url)) + return Object.keys(lists).filter(url => !allActiveListUrls?.includes(url) && !UNSUPPORTED_LIST_URLS.includes(url)) } // get all the tokens from active lists, combine with local default tokens diff --git a/src/state/lists/reducer.test.ts b/src/state/lists/reducer.test.ts index 635abb1b2c..82b1769609 100644 --- a/src/state/lists/reducer.test.ts +++ b/src/state/lists/reducer.test.ts @@ -9,20 +9,20 @@ const STUB_TOKEN_LIST = { name: '', timestamp: '', version: { major: 1, minor: 1, patch: 1 }, - tokens: [], + tokens: [] } const PATCHED_STUB_LIST = { ...STUB_TOKEN_LIST, - version: { ...STUB_TOKEN_LIST.version, patch: STUB_TOKEN_LIST.version.patch + 1 }, + version: { ...STUB_TOKEN_LIST.version, patch: STUB_TOKEN_LIST.version.patch + 1 } } const MINOR_UPDATED_STUB_LIST = { ...STUB_TOKEN_LIST, - version: { ...STUB_TOKEN_LIST.version, minor: STUB_TOKEN_LIST.version.minor + 1 }, + version: { ...STUB_TOKEN_LIST.version, minor: STUB_TOKEN_LIST.version.minor + 1 } } const MAJOR_UPDATED_STUB_LIST = { ...STUB_TOKEN_LIST, - version: { ...STUB_TOKEN_LIST.version, major: STUB_TOKEN_LIST.version.major + 1 }, + version: { ...STUB_TOKEN_LIST.version, major: STUB_TOKEN_LIST.version.major + 1 } } describe('list reducer', () => { @@ -31,7 +31,7 @@ describe('list reducer', () => { beforeEach(() => { store = createStore(reducer, { byUrl: {}, - activeListUrls: undefined, + activeListUrls: undefined }) }) @@ -45,10 +45,10 @@ describe('list reducer', () => { error: null, loadingRequestId: 'request-id', current: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - selectedListUrl: undefined, + selectedListUrl: undefined }) }) @@ -59,10 +59,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, pendingUpdate: null, - loadingRequestId: null, - }, + loadingRequestId: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(fetchTokenList.pending({ requestId: 'request-id', url: 'fake-url' })) @@ -72,10 +72,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: 'request-id', - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) }) @@ -91,10 +91,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) @@ -111,10 +111,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) @@ -132,10 +132,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) it('does not save to current if list is newer minor version', () => { @@ -152,10 +152,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: MINOR_UPDATED_STUB_LIST, - }, + pendingUpdate: MINOR_UPDATED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) it('does not save to pending if list is newer major version', () => { @@ -172,10 +172,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: MAJOR_UPDATED_STUB_LIST, - }, + pendingUpdate: MAJOR_UPDATED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) }) @@ -185,7 +185,7 @@ describe('list reducer', () => { store.dispatch(fetchTokenList.rejected({ requestId: 'request-id', errorMessage: 'abcd', url: 'fake-url' })) expect(store.getState()).toEqual({ byUrl: {}, - activeListUrls: undefined, + activeListUrls: undefined }) }) @@ -196,10 +196,10 @@ describe('list reducer', () => { error: null, current: null, loadingRequestId: 'request-id', - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(fetchTokenList.rejected({ requestId: 'request-id', errorMessage: 'abcd', url: 'fake-url' })) expect(store.getState()).toEqual({ @@ -208,10 +208,10 @@ describe('list reducer', () => { error: 'abcd', current: null, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) }) @@ -226,10 +226,10 @@ describe('list reducer', () => { error: null, current: null, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) it('no op for existing list', () => { @@ -239,10 +239,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(addList('fake-url')) expect(store.getState()).toEqual({ @@ -251,10 +251,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) }) @@ -267,10 +267,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(acceptListUpdate('fake-url')) expect(store.getState()).toEqual({ @@ -279,10 +279,10 @@ describe('list reducer', () => { error: null, current: PATCHED_STUB_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) }) }) @@ -295,15 +295,15 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(removeList('fake-url')) expect(store.getState()).toEqual({ byUrl: {}, - activeListUrls: undefined, + activeListUrls: undefined }) }) it('Removes from active lists if active list is removed', () => { @@ -313,15 +313,15 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: ['fake-url'], + activeListUrls: ['fake-url'] }) store.dispatch(removeList('fake-url')) expect(store.getState()).toEqual({ byUrl: {}, - activeListUrls: [], + activeListUrls: [] }) }) }) @@ -334,10 +334,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(enableList('fake-url')) expect(store.getState()).toEqual({ @@ -346,10 +346,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: ['fake-url'], + activeListUrls: ['fake-url'] }) }) it('adds to url keys if not present already on enable', () => { @@ -359,10 +359,10 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, - }, + pendingUpdate: PATCHED_STUB_LIST + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(enableList('fake-url-invalid')) expect(store.getState()).toEqual({ @@ -371,16 +371,16 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: PATCHED_STUB_LIST, + pendingUpdate: PATCHED_STUB_LIST }, 'fake-url-invalid': { error: null, current: null, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: ['fake-url-invalid'], + activeListUrls: ['fake-url-invalid'] }) }) it('enable works if list already added', () => { @@ -390,10 +390,10 @@ describe('list reducer', () => { error: null, current: null, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(enableList('fake-url')) expect(store.getState()).toEqual({ @@ -402,10 +402,10 @@ describe('list reducer', () => { error: null, current: null, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: ['fake-url'], + activeListUrls: ['fake-url'] }) }) }) @@ -419,16 +419,16 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null }, 'https://unpkg.com/@uniswap/default-token-list@latest': { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, - activeListUrls: undefined, + activeListUrls: undefined }) store.dispatch(updateVersion()) }) @@ -445,12 +445,12 @@ describe('list reducer', () => { }) it('all lists are empty', () => { const s = store.getState() - Object.keys(s.byUrl).forEach((url) => { + Object.keys(s.byUrl).forEach(url => { expect(s.byUrl[url]).toEqual({ error: null, current: null, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null }) }) }) @@ -469,17 +469,17 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null }, 'https://unpkg.com/@uniswap/default-token-list@latest': { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, - }, + pendingUpdate: null + } }, activeListUrls: undefined, - lastInitializedDefaultListOfLists: ['https://unpkg.com/@uniswap/default-token-list@latest'], + lastInitializedDefaultListOfLists: ['https://unpkg.com/@uniswap/default-token-list@latest'] }) store.dispatch(updateVersion()) }) @@ -491,7 +491,7 @@ describe('list reducer', () => { error: null, current: STUB_TOKEN_LIST, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null }) }) it('removes lists in the last initialized list of lists', () => { @@ -502,13 +502,13 @@ describe('list reducer', () => { const byUrl = store.getState().byUrl // note we don't expect the uniswap default list to be prepopulated // this is ok. - Object.keys(byUrl).forEach((url) => { + Object.keys(byUrl).forEach(url => { if (url !== 'https://unpkg.com/@uniswap/default-token-list@latest/uniswap-default.tokenlist.json') { expect(byUrl[url]).toEqual({ error: null, current: null, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null }) } }) diff --git a/src/state/lists/reducer.ts b/src/state/lists/reducer.ts index 3ac05fecbd..24f55b9344 100644 --- a/src/state/lists/reducer.ts +++ b/src/state/lists/reducer.ts @@ -28,7 +28,7 @@ const NEW_LIST_STATE: ListState = { error: null, current: null, loadingRequestId: null, - pendingUpdate: null, + pendingUpdate: null } type Mutable = { -readonly [P in keyof T]: T[P] extends ReadonlyArray ? U[] : T[P] } @@ -39,12 +39,12 @@ const initialState: ListsState = { ...DEFAULT_LIST_OF_LISTS.reduce>((memo, listUrl) => { memo[listUrl] = NEW_LIST_STATE return memo - }, {}), + }, {}) }, - activeListUrls: DEFAULT_ACTIVE_LIST_URLS, + activeListUrls: DEFAULT_ACTIVE_LIST_URLS } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase(fetchTokenList.pending, (state, { payload: { requestId, url } }) => { state.byUrl[url] = { @@ -52,7 +52,7 @@ export default createReducer(initialState, (builder) => pendingUpdate: null, ...state.byUrl[url], loadingRequestId: requestId, - error: null, + error: null } }) .addCase(fetchTokenList.fulfilled, (state, { payload: { requestId, tokenList, url } }) => { @@ -70,7 +70,7 @@ export default createReducer(initialState, (builder) => loadingRequestId: null, error: null, current: current, - pendingUpdate: tokenList, + pendingUpdate: tokenList } } } else { @@ -84,7 +84,7 @@ export default createReducer(initialState, (builder) => loadingRequestId: null, error: null, current: tokenList, - pendingUpdate: null, + pendingUpdate: null } } }) @@ -99,7 +99,7 @@ export default createReducer(initialState, (builder) => loadingRequestId: null, error: errorMessage, current: null, - pendingUpdate: null, + pendingUpdate: null } }) .addCase(addList, (state, { payload: url }) => { @@ -113,7 +113,7 @@ export default createReducer(initialState, (builder) => } // remove list from active urls if needed if (state.activeListUrls && state.activeListUrls.includes(url)) { - state.activeListUrls = state.activeListUrls.filter((u) => u !== url) + state.activeListUrls = state.activeListUrls.filter(u => u !== url) } }) .addCase(enableList, (state, { payload: url }) => { @@ -131,7 +131,7 @@ export default createReducer(initialState, (builder) => }) .addCase(disableList, (state, { payload: url }) => { if (state.activeListUrls && state.activeListUrls.includes(url)) { - state.activeListUrls = state.activeListUrls.filter((u) => u !== url) + state.activeListUrls = state.activeListUrls.filter(u => u !== url) } }) .addCase(acceptListUpdate, (state, { payload: url }) => { @@ -141,10 +141,10 @@ export default createReducer(initialState, (builder) => state.byUrl[url] = { ...state.byUrl[url], pendingUpdate: null, - current: state.byUrl[url].pendingUpdate, + current: state.byUrl[url].pendingUpdate } }) - .addCase(updateVersion, (state) => { + .addCase(updateVersion, state => { // state loaded from localStorage, but new lists have never been initialized if (!state.lastInitializedDefaultListOfLists) { state.byUrl = initialState.byUrl @@ -156,13 +156,13 @@ export default createReducer(initialState, (builder) => ) const newListOfListsSet = DEFAULT_LIST_OF_LISTS.reduce>((s, l) => s.add(l), new Set()) - DEFAULT_LIST_OF_LISTS.forEach((listUrl) => { + DEFAULT_LIST_OF_LISTS.forEach(listUrl => { if (!lastInitializedSet.has(listUrl)) { state.byUrl[listUrl] = NEW_LIST_STATE } }) - state.lastInitializedDefaultListOfLists.forEach((listUrl) => { + state.lastInitializedDefaultListOfLists.forEach(listUrl => { if (!newListOfListsSet.has(listUrl)) { delete state.byUrl[listUrl] } diff --git a/src/state/lists/updater.ts b/src/state/lists/updater.ts index 3baef3c31c..e1ba9411d0 100644 --- a/src/state/lists/updater.ts +++ b/src/state/lists/updater.ts @@ -26,8 +26,8 @@ export default function Updater(): null { const fetchList = useFetchListCallback() const fetchAllListsCallback = useCallback(() => { if (!isWindowVisible) return - Object.keys(lists).forEach((url) => - fetchList(url).catch((error) => console.debug('interval list fetching error', error)) + Object.keys(lists).forEach(url => + fetchList(url).catch(error => console.debug('interval list fetching error', error)) ) }, [fetchList, isWindowVisible, lists]) @@ -36,17 +36,17 @@ export default function Updater(): null { // whenever a list is not loaded and not loading, try again to load it useEffect(() => { - Object.keys(lists).forEach((listUrl) => { + Object.keys(lists).forEach(listUrl => { const list = lists[listUrl] if (!list.current && !list.loadingRequestId && !list.error) { - fetchList(listUrl).catch((error) => console.debug('list added fetching error', error)) + fetchList(listUrl).catch(error => console.debug('list added fetching error', error)) } }) }, [dispatch, fetchList, library, lists]) // automatically update lists if versions are minor/patch useEffect(() => { - Object.keys(lists).forEach((listUrl) => { + Object.keys(lists).forEach(listUrl => { const list = lists[listUrl] if (list.current && list.pendingUpdate) { const bump = getVersionUpgrade(list.current.version, list.pendingUpdate.version) diff --git a/src/state/mint/actions.ts b/src/state/mint/actions.ts index 4fcd912c51..0dd105c3c0 100644 --- a/src/state/mint/actions.ts +++ b/src/state/mint/actions.ts @@ -2,7 +2,7 @@ import { createAction } from '@reduxjs/toolkit' export enum Field { CURRENCY_A = 'CURRENCY_A', - CURRENCY_B = 'CURRENCY_B', + CURRENCY_B = 'CURRENCY_B' } export const typeInput = createAction<{ field: Field; typedValue: string; noLiquidity: boolean }>('mint/typeInputMint') diff --git a/src/state/mint/hooks.ts b/src/state/mint/hooks.ts index 2f7d2776fb..ff07e536a4 100644 --- a/src/state/mint/hooks.ts +++ b/src/state/mint/hooks.ts @@ -14,7 +14,7 @@ import { Field, typeInput } from './actions' const ZERO = JSBI.BigInt(0) export function useMintState(): AppState['mint'] { - return useSelector((state) => state.mint) + return useSelector(state => state.mint) } export function useMintActionHandlers( @@ -40,7 +40,7 @@ export function useMintActionHandlers( return { onFieldAInput, - onFieldBInput, + onFieldBInput } } @@ -70,7 +70,7 @@ export function useDerivedMintInfo( const currencies: { [field in Field]?: Currency } = useMemo( () => ({ [Field.CURRENCY_A]: currencyA ?? undefined, - [Field.CURRENCY_B]: currencyB ?? undefined, + [Field.CURRENCY_B]: currencyB ?? undefined }), [currencyA, currencyB] ) @@ -85,11 +85,11 @@ export function useDerivedMintInfo( // balances const balances = useCurrencyBalances(account ?? undefined, [ currencies[Field.CURRENCY_A], - currencies[Field.CURRENCY_B], + currencies[Field.CURRENCY_B] ]) const currencyBalances: { [field in Field]?: CurrencyAmount } = { [Field.CURRENCY_A]: balances[0], - [Field.CURRENCY_B]: balances[1], + [Field.CURRENCY_B]: balances[1] } // amounts @@ -119,7 +119,7 @@ export function useDerivedMintInfo( }, [noLiquidity, otherTypedValue, currencies, dependentField, independentAmount, currencyA, chainId, currencyB, pair]) const parsedAmounts: { [field in Field]: CurrencyAmount | undefined } = { [Field.CURRENCY_A]: independentField === Field.CURRENCY_A ? independentAmount : dependentAmount, - [Field.CURRENCY_B]: independentField === Field.CURRENCY_A ? dependentAmount : independentAmount, + [Field.CURRENCY_B]: independentField === Field.CURRENCY_A ? dependentAmount : independentAmount } const price = useMemo(() => { @@ -140,7 +140,7 @@ export function useDerivedMintInfo( const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = parsedAmounts const [tokenAmountA, tokenAmountB] = [ wrappedCurrencyAmount(currencyAAmount, chainId), - wrappedCurrencyAmount(currencyBAmount, chainId), + wrappedCurrencyAmount(currencyBAmount, chainId) ] if (pair && totalSupply && tokenAmountA && tokenAmountB) { return pair.getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) @@ -191,6 +191,6 @@ export function useDerivedMintInfo( noLiquidity, liquidityMinted, poolTokenPercentage, - error, + error } } diff --git a/src/state/mint/reducer.test.ts b/src/state/mint/reducer.test.ts index 92abd42277..ae25c3374e 100644 --- a/src/state/mint/reducer.test.ts +++ b/src/state/mint/reducer.test.ts @@ -10,7 +10,7 @@ describe('mint reducer', () => { store = createStore(reducer, { independentField: Field.CURRENCY_A, typedValue: '', - otherTypedValue: '', + otherTypedValue: '' }) }) diff --git a/src/state/mint/reducer.ts b/src/state/mint/reducer.ts index c92462c88d..4c4a7877ca 100644 --- a/src/state/mint/reducer.ts +++ b/src/state/mint/reducer.ts @@ -10,10 +10,10 @@ export interface MintState { const initialState: MintState = { independentField: Field.CURRENCY_A, typedValue: '', - otherTypedValue: '', + otherTypedValue: '' } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase(resetMintState, () => initialState) .addCase(typeInput, (state, { payload: { field, typedValue, noLiquidity } }) => { @@ -23,7 +23,7 @@ export default createReducer(initialState, (builder) => return { ...state, independentField: field, - typedValue, + typedValue } } // they're typing into a new field, store the other value @@ -32,7 +32,7 @@ export default createReducer(initialState, (builder) => ...state, independentField: field, typedValue, - otherTypedValue: state.typedValue, + otherTypedValue: state.typedValue } } } else { @@ -40,7 +40,7 @@ export default createReducer(initialState, (builder) => ...state, independentField: field, typedValue, - otherTypedValue: '', + otherTypedValue: '' } } }) diff --git a/src/state/multicall/actions.test.ts b/src/state/multicall/actions.test.ts index 8d2b816cbb..79570f7ffe 100644 --- a/src/state/multicall/actions.test.ts +++ b/src/state/multicall/actions.test.ts @@ -8,7 +8,7 @@ describe('actions', () => { it('does not throw for invalid calldata', () => { expect(parseCallKey('0x6b175474e89094c44da98b954eedeac495271d0f-abc')).toEqual({ address: '0x6b175474e89094c44da98b954eedeac495271d0f', - callData: 'abc', + callData: 'abc' }) }) it('throws for invalid format', () => { @@ -17,13 +17,13 @@ describe('actions', () => { it('throws for uppercase calldata', () => { expect(parseCallKey('0x6b175474e89094c44da98b954eedeac495271d0f-0xabcD')).toEqual({ address: '0x6b175474e89094c44da98b954eedeac495271d0f', - callData: '0xabcD', + callData: '0xabcD' }) }) it('parses pieces into address', () => { expect(parseCallKey('0x6b175474e89094c44da98b954eedeac495271d0f-0xabcd')).toEqual({ address: '0x6b175474e89094c44da98b954eedeac495271d0f', - callData: '0xabcd', + callData: '0xabcd' }) }) }) @@ -36,7 +36,7 @@ describe('actions', () => { expect(() => toCallKey({ address: '0x6b175474e89094c44da98b954eedeac495271d0f', - callData: 'abc', + callData: 'abc' }) ).toThrow('Invalid hex: abc') }) @@ -44,7 +44,7 @@ describe('actions', () => { expect(() => toCallKey({ address: '0x6b175474e89094c44da98b954eedeac495271d0f', - callData: '0xabcD', + callData: '0xabcD' }) ).toThrow('Invalid hex: 0xabcD') }) diff --git a/src/state/multicall/actions.ts b/src/state/multicall/actions.ts index 883fa7f81d..dabd49eb9a 100644 --- a/src/state/multicall/actions.ts +++ b/src/state/multicall/actions.ts @@ -24,7 +24,7 @@ export function parseCallKey(callKey: string): Call { } return { address: pcs[0], - callData: pcs[1], + callData: pcs[1] } } diff --git a/src/state/multicall/hooks.ts b/src/state/multicall/hooks.ts index 163f859d37..62d64dc69a 100644 --- a/src/state/multicall/hooks.ts +++ b/src/state/multicall/hooks.ts @@ -12,7 +12,7 @@ import { removeMulticallListeners, parseCallKey, toCallKey, - ListenerOptions, + ListenerOptions } from './actions' export interface Result extends ReadonlyArray { @@ -31,7 +31,7 @@ function isMethodArg(x: unknown): x is MethodArg { function isValidMethodArgs(x: unknown): x is MethodArgs | undefined { return ( x === undefined || - (Array.isArray(x) && x.every((xi) => isMethodArg(xi) || (Array.isArray(xi) && xi.every(isMethodArg)))) + (Array.isArray(x) && x.every(xi => isMethodArg(xi) || (Array.isArray(xi) && xi.every(isMethodArg)))) ) } @@ -45,15 +45,13 @@ const INVALID_RESULT: CallResult = { valid: false, blockNumber: undefined, data: // use this options object export const NEVER_RELOAD: ListenerOptions = { - blocksPerFetch: Infinity, + blocksPerFetch: Infinity } // the lowest level call for subscribing to contract data function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): CallResult[] { const { chainId } = useActiveWeb3React() - const callResults = useSelector( - (state) => state.multicall.callResults - ) + const callResults = useSelector(state => state.multicall.callResults) const dispatch = useDispatch() const serializedCallKeys: string = useMemo( @@ -71,12 +69,12 @@ function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): C useEffect(() => { const callKeys: string[] = JSON.parse(serializedCallKeys) if (!chainId || callKeys.length === 0) return undefined - const calls = callKeys.map((key) => parseCallKey(key)) + const calls = callKeys.map(key => parseCallKey(key)) dispatch( addMulticallListeners({ chainId, calls, - options, + options }) ) @@ -85,7 +83,7 @@ function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): C removeMulticallListeners({ chainId, calls, - options, + options }) ) } @@ -93,7 +91,7 @@ function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): C return useMemo( () => - calls.map((call) => { + calls.map(call => { if (!chainId || !call) return INVALID_RESULT const result = callResults[chainId]?.[toCallKey(call)] @@ -147,7 +145,7 @@ function toCallState( loading: false, error: true, syncing, - result, + result } } } @@ -156,7 +154,7 @@ function toCallState( loading: false, syncing, result: result, - error: !success, + error: !success } } @@ -171,10 +169,10 @@ export function useSingleContractMultipleData( const calls = useMemo( () => contract && fragment && callInputs && callInputs.length > 0 - ? callInputs.map((inputs) => { + ? callInputs.map(inputs => { return { address: contract.address, - callData: contract.interface.encodeFunctionData(fragment, inputs), + callData: contract.interface.encodeFunctionData(fragment, inputs) } }) : [], @@ -186,7 +184,7 @@ export function useSingleContractMultipleData( const latestBlockNumber = useBlockNumber() return useMemo(() => { - return results.map((result) => toCallState(result, contract?.interface, fragment, latestBlockNumber)) + return results.map(result => toCallState(result, contract?.interface, fragment, latestBlockNumber)) }, [fragment, contract, results, latestBlockNumber]) } @@ -209,11 +207,11 @@ export function useMultipleContractSingleData( const calls = useMemo( () => fragment && addresses && addresses.length > 0 && callData - ? addresses.map((address) => { + ? addresses.map(address => { return address && callData ? { address, - callData, + callData } : undefined }) @@ -226,7 +224,7 @@ export function useMultipleContractSingleData( const latestBlockNumber = useBlockNumber() return useMemo(() => { - return results.map((result) => toCallState(result, contractInterface, fragment, latestBlockNumber)) + return results.map(result => toCallState(result, contractInterface, fragment, latestBlockNumber)) }, [fragment, results, contractInterface, latestBlockNumber]) } @@ -243,8 +241,8 @@ export function useSingleCallResult( ? [ { address: contract.address, - callData: contract.interface.encodeFunctionData(fragment, inputs), - }, + callData: contract.interface.encodeFunctionData(fragment, inputs) + } ] : [] }, [contract, fragment, inputs]) diff --git a/src/state/multicall/reducer.test.ts b/src/state/multicall/reducer.test.ts index 1d19852a29..88a6616b7d 100644 --- a/src/state/multicall/reducer.test.ts +++ b/src/state/multicall/reducer.test.ts @@ -3,7 +3,7 @@ import { errorFetchingMulticallResults, fetchingMulticallResults, removeMulticallListeners, - updateMulticallResults, + updateMulticallResults } from './actions' import reducer, { MulticallState } from './reducer' import { Store, createStore } from '@reduxjs/toolkit' @@ -29,20 +29,20 @@ describe('multicall reducer', () => { calls: [ { address: DAI_ADDRESS, - callData: '0x', - }, - ], + callData: '0x' + } + ] }) ) expect(store.getState()).toEqual({ callListeners: { [1]: { [`${DAI_ADDRESS}-0x`]: { - [1]: 1, - }, - }, + [1]: 1 + } + } }, - callResults: {}, + callResults: {} }) }) }) @@ -54,10 +54,10 @@ describe('multicall reducer', () => { calls: [ { address: DAI_ADDRESS, - callData: '0x', - }, + callData: '0x' + } ], - chainId: 1, + chainId: 1 }) ) expect(store.getState()).toEqual({ callResults: {}, callListeners: {} }) @@ -69,9 +69,9 @@ describe('multicall reducer', () => { calls: [ { address: DAI_ADDRESS, - callData: '0x', - }, - ], + callData: '0x' + } + ] }) ) store.dispatch( @@ -79,15 +79,15 @@ describe('multicall reducer', () => { calls: [ { address: DAI_ADDRESS, - callData: '0x', - }, + callData: '0x' + } ], - chainId: 1, + chainId: 1 }) ) expect(store.getState()).toEqual({ callResults: {}, - callListeners: { [1]: { [`${DAI_ADDRESS}-0x`]: {} } }, + callListeners: { [1]: { [`${DAI_ADDRESS}-0x`]: {} } } }) }) }) @@ -99,8 +99,8 @@ describe('multicall reducer', () => { chainId: 1, blockNumber: 1, results: { - abc: '0x', - }, + abc: '0x' + } }) ) expect(store.getState()).toEqual({ @@ -108,10 +108,10 @@ describe('multicall reducer', () => { [1]: { abc: { blockNumber: 1, - data: '0x', - }, - }, - }, + data: '0x' + } + } + } }) }) it('updates old data', () => { @@ -120,8 +120,8 @@ describe('multicall reducer', () => { chainId: 1, blockNumber: 1, results: { - abc: '0x', - }, + abc: '0x' + } }) ) store.dispatch( @@ -129,8 +129,8 @@ describe('multicall reducer', () => { chainId: 1, blockNumber: 2, results: { - abc: '0x2', - }, + abc: '0x2' + } }) ) expect(store.getState()).toEqual({ @@ -138,10 +138,10 @@ describe('multicall reducer', () => { [1]: { abc: { blockNumber: 2, - data: '0x2', - }, - }, - }, + data: '0x2' + } + } + } }) }) it('ignores late updates', () => { @@ -150,8 +150,8 @@ describe('multicall reducer', () => { chainId: 1, blockNumber: 2, results: { - abc: '0x2', - }, + abc: '0x2' + } }) ) store.dispatch( @@ -159,8 +159,8 @@ describe('multicall reducer', () => { chainId: 1, blockNumber: 1, results: { - abc: '0x1', - }, + abc: '0x1' + } }) ) expect(store.getState()).toEqual({ @@ -168,10 +168,10 @@ describe('multicall reducer', () => { [1]: { abc: { blockNumber: 2, - data: '0x2', - }, - }, - }, + data: '0x2' + } + } + } }) }) }) @@ -181,15 +181,15 @@ describe('multicall reducer', () => { fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ callResults: { [1]: { - [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 2 }, - }, - }, + [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 2 } + } + } }) }) @@ -198,22 +198,22 @@ describe('multicall reducer', () => { fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) store.dispatch( fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 3, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ callResults: { [1]: { - [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 3 }, - }, - }, + [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 3 } + } + } }) }) @@ -222,22 +222,22 @@ describe('multicall reducer', () => { fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) store.dispatch( fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 1, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ callResults: { [1]: { - [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 2 }, - }, - }, + [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 2 } + } + } }) }) }) @@ -248,13 +248,13 @@ describe('multicall reducer', () => { errorFetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 1, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ callResults: { - [1]: {}, - }, + [1]: {} + } }) }) it('updates block number if we were fetching', () => { @@ -262,14 +262,14 @@ describe('multicall reducer', () => { fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) store.dispatch( errorFetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ @@ -278,10 +278,10 @@ describe('multicall reducer', () => { [`${DAI_ADDRESS}-0x0`]: { blockNumber: 2, // null data indicates error - data: null, - }, - }, - }, + data: null + } + } + } }) }) it('does nothing if not errored on latest block', () => { @@ -289,22 +289,22 @@ describe('multicall reducer', () => { fetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 3, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) store.dispatch( errorFetchingMulticallResults({ chainId: 1, fetchingBlockNumber: 2, - calls: [{ address: DAI_ADDRESS, callData: '0x0' }], + calls: [{ address: DAI_ADDRESS, callData: '0x0' }] }) ) expect(store.getState()).toEqual({ callResults: { [1]: { - [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 3 }, - }, - }, + [`${DAI_ADDRESS}-0x0`]: { fetchingBlockNumber: 3 } + } + } }) }) }) diff --git a/src/state/multicall/reducer.ts b/src/state/multicall/reducer.ts index 36225746b8..09d4639204 100644 --- a/src/state/multicall/reducer.ts +++ b/src/state/multicall/reducer.ts @@ -5,7 +5,7 @@ import { fetchingMulticallResults, removeMulticallListeners, toCallKey, - updateMulticallResults, + updateMulticallResults } from './actions' export interface MulticallState { @@ -32,17 +32,17 @@ export interface MulticallState { } const initialState: MulticallState = { - callResults: {}, + callResults: {} } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase(addMulticallListeners, (state, { payload: { calls, chainId, options: { blocksPerFetch = 1 } = {} } }) => { const listeners: MulticallState['callListeners'] = state.callListeners ? state.callListeners : (state.callListeners = {}) listeners[chainId] = listeners[chainId] ?? {} - calls.forEach((call) => { + calls.forEach(call => { const callKey = toCallKey(call) listeners[chainId][callKey] = listeners[chainId][callKey] ?? {} listeners[chainId][callKey][blocksPerFetch] = (listeners[chainId][callKey][blocksPerFetch] ?? 0) + 1 @@ -56,7 +56,7 @@ export default createReducer(initialState, (builder) => : (state.callListeners = {}) if (!listeners[chainId]) return - calls.forEach((call) => { + calls.forEach(call => { const callKey = toCallKey(call) if (!listeners[chainId][callKey]) return if (!listeners[chainId][callKey][blocksPerFetch]) return @@ -71,12 +71,12 @@ export default createReducer(initialState, (builder) => ) .addCase(fetchingMulticallResults, (state, { payload: { chainId, fetchingBlockNumber, calls } }) => { state.callResults[chainId] = state.callResults[chainId] ?? {} - calls.forEach((call) => { + calls.forEach(call => { const callKey = toCallKey(call) const current = state.callResults[chainId][callKey] if (!current) { state.callResults[chainId][callKey] = { - fetchingBlockNumber, + fetchingBlockNumber } } else { if ((current.fetchingBlockNumber ?? 0) >= fetchingBlockNumber) return @@ -86,7 +86,7 @@ export default createReducer(initialState, (builder) => }) .addCase(errorFetchingMulticallResults, (state, { payload: { fetchingBlockNumber, chainId, calls } }) => { state.callResults[chainId] = state.callResults[chainId] ?? {} - calls.forEach((call) => { + calls.forEach(call => { const callKey = toCallKey(call) const current = state.callResults[chainId][callKey] if (!current) return // only should be dispatched if we are already fetching @@ -99,12 +99,12 @@ export default createReducer(initialState, (builder) => }) .addCase(updateMulticallResults, (state, { payload: { chainId, results, blockNumber } }) => { state.callResults[chainId] = state.callResults[chainId] ?? {} - Object.keys(results).forEach((callKey) => { + Object.keys(results).forEach(callKey => { const current = state.callResults[chainId][callKey] if ((current?.blockNumber ?? 0) > blockNumber) return state.callResults[chainId][callKey] = { data: results[callKey], - blockNumber, + blockNumber } }) }) diff --git a/src/state/multicall/updater.test.ts b/src/state/multicall/updater.test.ts index 0110b9b262..064f8e2ba7 100644 --- a/src/state/multicall/updater.test.ts +++ b/src/state/multicall/updater.test.ts @@ -9,14 +9,14 @@ describe('multicall updater', () => { [1]: { ['abc']: { 4: 2, // 2 listeners care about 4 block old data - 1: 0, // 0 listeners care about 1 block old data - }, - }, + 1: 0 // 0 listeners care about 1 block old data + } + } }, 1 ) ).toEqual({ - abc: 4, + abc: 4 }) }) it('applies min', () => { @@ -27,14 +27,14 @@ describe('multicall updater', () => { ['abc']: { 4: 2, // 2 listeners care about 4 block old data 3: 1, // 1 listener cares about 3 block old data - 1: 0, // 0 listeners care about 1 block old data - }, - }, + 1: 0 // 0 listeners care about 1 block old data + } + } }, 1 ) ).toEqual({ - abc: 3, + abc: 3 }) }) it('works for infinity', () => { @@ -44,18 +44,18 @@ describe('multicall updater', () => { [1]: { ['abc']: { 4: 2, // 2 listeners care about 4 block old data - 1: 0, // 0 listeners care about 1 block old data + 1: 0 // 0 listeners care about 1 block old data }, ['def']: { - Infinity: 2, - }, - }, + Infinity: 2 + } + } }, 1 ) ).toEqual({ abc: 4, - def: Infinity, + def: Infinity }) }) it('multiple keys', () => { @@ -65,19 +65,19 @@ describe('multicall updater', () => { [1]: { ['abc']: { 4: 2, // 2 listeners care about 4 block old data - 1: 0, // 0 listeners care about 1 block old data + 1: 0 // 0 listeners care about 1 block old data }, ['def']: { 2: 1, - 5: 2, - }, - }, + 5: 2 + } + } }, 1 ) ).toEqual({ abc: 4, - def: 2, + def: 2 }) }) it('ignores negative numbers', () => { @@ -88,14 +88,14 @@ describe('multicall updater', () => { ['abc']: { 4: 2, 1: -1, - [-3]: 4, - }, - }, + [-3]: 4 + } + } }, 1 ) ).toEqual({ - abc: 4, + abc: 4 }) }) it('applies min to infinity', () => { @@ -106,14 +106,14 @@ describe('multicall updater', () => { ['abc']: { Infinity: 2, // 2 listeners care about any data 4: 2, // 2 listeners care about 4 block old data - 1: 0, // 0 listeners care about 1 block old data - }, - }, + 1: 0 // 0 listeners care about 1 block old data + } + } }, 1 ) ).toEqual({ - abc: 4, + abc: 4 }) }) }) @@ -136,7 +136,7 @@ describe('multicall updater', () => { expect( outdatedListeningKeys( { - [1]: { abc: { data: '0x', blockNumber: 2 }, def: { fetchingBlockNumber: 2 } }, + [1]: { abc: { data: '0x', blockNumber: 2 }, def: { fetchingBlockNumber: 2 } } }, { abc: 1, def: 1 }, 1, diff --git a/src/state/multicall/updater.tsx b/src/state/multicall/updater.tsx index d15ec59e93..67d935eb09 100644 --- a/src/state/multicall/updater.tsx +++ b/src/state/multicall/updater.tsx @@ -13,7 +13,7 @@ import { errorFetchingMulticallResults, fetchingMulticallResults, parseCallKey, - updateMulticallResults, + updateMulticallResults } from './actions' // chunk calls so we do not exceed the gas limit @@ -33,9 +33,7 @@ async function fetchChunk( console.debug('Fetching chunk', multicallContract, chunk, minBlockNumber) let resultsBlockNumber, returnData try { - ;[resultsBlockNumber, returnData] = await multicallContract.aggregate( - chunk.map((obj) => [obj.address, obj.callData]) - ) + ;[resultsBlockNumber, returnData] = await multicallContract.aggregate(chunk.map(obj => [obj.address, obj.callData])) } catch (error) { console.debug('Failed to fetch chunk inside retry', error) throw error @@ -65,7 +63,7 @@ export function activeListeningKeys( const keyListeners = listeners[callKey] memo[callKey] = Object.keys(keyListeners) - .filter((key) => { + .filter(key => { const blocksPerFetch = parseInt(key) if (blocksPerFetch <= 0) return false return keyListeners[blocksPerFetch] > 0 @@ -95,7 +93,7 @@ export function outdatedListeningKeys( // no results at all, load everything if (!results) return Object.keys(listeningKeys) - return Object.keys(listeningKeys).filter((callKey) => { + return Object.keys(listeningKeys).filter(callKey => { const blocksPerFetch = listeningKeys[callKey] const data = callResults[chainId][callKey] @@ -114,7 +112,7 @@ export function outdatedListeningKeys( export default function Updater(): null { const dispatch = useDispatch() - const state = useSelector((state) => state.multicall) + const state = useSelector(state => state.multicall) // wait for listeners to settle before triggering updates const debouncedListeners = useDebounce(state.callListeners, 100) const latestBlockNumber = useBlockNumber() @@ -131,7 +129,7 @@ export default function Updater(): null { }, [chainId, state.callResults, listeningKeys, latestBlockNumber]) const serializedOutdatedCallKeys = useMemo(() => JSON.stringify(unserializedOutdatedCallKeys.sort()), [ - unserializedOutdatedCallKeys, + unserializedOutdatedCallKeys ]) useEffect(() => { @@ -139,19 +137,19 @@ export default function Updater(): null { const outdatedCallKeys: string[] = JSON.parse(serializedOutdatedCallKeys) if (outdatedCallKeys.length === 0) return - const calls = outdatedCallKeys.map((key) => parseCallKey(key)) + const calls = outdatedCallKeys.map(key => parseCallKey(key)) const chunkedCalls = chunkArray(calls, CALL_CHUNK_SIZE) if (cancellations.current?.blockNumber !== latestBlockNumber) { - cancellations.current?.cancellations?.forEach((c) => c()) + cancellations.current?.cancellations?.forEach(c => c()) } dispatch( fetchingMulticallResults({ calls, chainId, - fetchingBlockNumber: latestBlockNumber, + fetchingBlockNumber: latestBlockNumber }) ) @@ -161,7 +159,7 @@ export default function Updater(): null { const { cancel, promise } = retry(() => fetchChunk(multicallContract, chunk, latestBlockNumber), { n: Infinity, minWait: 2500, - maxWait: 3500, + maxWait: 3500 }) promise .then(({ results: returnData, blockNumber: fetchBlockNumber }) => { @@ -180,7 +178,7 @@ export default function Updater(): null { memo[callKey] = returnData[i] ?? null return memo }, {}), - blockNumber: fetchBlockNumber, + blockNumber: fetchBlockNumber }) ) }) @@ -194,12 +192,12 @@ export default function Updater(): null { errorFetchingMulticallResults({ calls: chunk, chainId, - fetchingBlockNumber: latestBlockNumber, + fetchingBlockNumber: latestBlockNumber }) ) }) return cancel - }), + }) } }, [chainId, multicallContract, dispatch, serializedOutdatedCallKeys, latestBlockNumber]) diff --git a/src/state/stake/hooks.ts b/src/state/stake/hooks.ts index 2c8e03e5a2..fa91cfca4a 100644 --- a/src/state/stake/hooks.ts +++ b/src/state/stake/hooks.ts @@ -21,21 +21,21 @@ export const STAKING_REWARDS_INFO: { [ChainId.MAINNET]: [ { tokens: [WETH[ChainId.MAINNET], DAI], - stakingRewardAddress: '0xa1484C3aa22a66C62b77E0AE78E15258bd0cB711', + stakingRewardAddress: '0xa1484C3aa22a66C62b77E0AE78E15258bd0cB711' }, { tokens: [WETH[ChainId.MAINNET], USDC], - stakingRewardAddress: '0x7FBa4B8Dc5E7616e59622806932DBea72537A56b', + stakingRewardAddress: '0x7FBa4B8Dc5E7616e59622806932DBea72537A56b' }, { tokens: [WETH[ChainId.MAINNET], USDT], - stakingRewardAddress: '0x6C3e4cb2E96B01F4b866965A91ed4437839A121a', + stakingRewardAddress: '0x6C3e4cb2E96B01F4b866965A91ed4437839A121a' }, { tokens: [WETH[ChainId.MAINNET], WBTC], - stakingRewardAddress: '0xCA35e32e7926b96A9988f61d510E038108d8068e', - }, - ], + stakingRewardAddress: '0xCA35e32e7926b96A9988f61d510E038108d8068e' + } + ] } export interface StakingInfo { @@ -76,7 +76,7 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] { const info = useMemo( () => chainId - ? STAKING_REWARDS_INFO[chainId]?.filter((stakingRewardInfo) => + ? STAKING_REWARDS_INFO[chainId]?.filter(stakingRewardInfo => pairToFilterBy === undefined ? true : pairToFilterBy === null @@ -193,7 +193,7 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] { stakedAmount: stakedAmount, totalStakedAmount: totalStakedAmount, getHypotheticalRewardRate, - active, + active }) } return memo @@ -208,7 +208,7 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] { rewardRates, rewardsAddresses, totalSupplies, - uni, + uni ]) } @@ -256,7 +256,7 @@ export function useDerivedStakeInfo( return { parsedAmount, - error, + error } } @@ -284,6 +284,6 @@ export function useDerivedUnstakeInfo( return { parsedAmount, - error, + error } } diff --git a/src/state/swap/actions.ts b/src/state/swap/actions.ts index 19d0fdcfeb..5af19bb20a 100644 --- a/src/state/swap/actions.ts +++ b/src/state/swap/actions.ts @@ -2,7 +2,7 @@ import { createAction } from '@reduxjs/toolkit' export enum Field { INPUT = 'INPUT', - OUTPUT = 'OUTPUT', + OUTPUT = 'OUTPUT' } export const selectCurrency = createAction<{ field: Field; currencyId: string }>('swap/selectCurrency') diff --git a/src/state/swap/hooks.test.ts b/src/state/swap/hooks.test.ts index 056627da7b..08336b5ea2 100644 --- a/src/state/swap/hooks.test.ts +++ b/src/state/swap/hooks.test.ts @@ -17,7 +17,7 @@ describe('hooks', () => { [Field.INPUT]: { currencyId: 'ETH' }, typedValue: '20.5', independentField: Field.OUTPUT, - recipient: null, + recipient: null }) }) @@ -29,7 +29,7 @@ describe('hooks', () => { [Field.OUTPUT]: { currencyId: 'ETH' }, typedValue: '', independentField: Field.INPUT, - recipient: null, + recipient: null }) }) @@ -43,7 +43,7 @@ describe('hooks', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '20.5', independentField: Field.INPUT, - recipient: null, + recipient: null }) }) @@ -57,7 +57,7 @@ describe('hooks', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '20.5', independentField: Field.INPUT, - recipient: null, + recipient: null }) }) @@ -66,7 +66,7 @@ describe('hooks', () => { queryParametersToSwapState( parse('?outputCurrency=eth&exactAmount=20.5&recipient=0x0fF2D1eFd7A57B7562b2bf27F3f37899dB27F4a5', { parseArrays: false, - ignoreQueryPrefix: true, + ignoreQueryPrefix: true }) ) ).toEqual({ @@ -74,7 +74,7 @@ describe('hooks', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '20.5', independentField: Field.INPUT, - recipient: '0x0fF2D1eFd7A57B7562b2bf27F3f37899dB27F4a5', + recipient: '0x0fF2D1eFd7A57B7562b2bf27F3f37899dB27F4a5' }) }) test('accepts any recipient', () => { @@ -82,7 +82,7 @@ describe('hooks', () => { queryParametersToSwapState( parse('?outputCurrency=eth&exactAmount=20.5&recipient=bob.argent.xyz', { parseArrays: false, - ignoreQueryPrefix: true, + ignoreQueryPrefix: true }) ) ).toEqual({ @@ -90,7 +90,7 @@ describe('hooks', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '20.5', independentField: Field.INPUT, - recipient: 'bob.argent.xyz', + recipient: 'bob.argent.xyz' }) }) }) diff --git a/src/state/swap/hooks.ts b/src/state/swap/hooks.ts index 86f593c758..9bc3c06f01 100644 --- a/src/state/swap/hooks.ts +++ b/src/state/swap/hooks.ts @@ -20,7 +20,7 @@ import { useUserSlippageTolerance } from '../user/hooks' import { computeSlippageAdjustedAmounts } from '../../utils/prices' export function useSwapState(): AppState['swap'] { - return useSelector((state) => state.swap) + return useSelector(state => state.swap) } export function useSwapActionHandlers(): { @@ -35,7 +35,7 @@ export function useSwapActionHandlers(): { dispatch( selectCurrency({ field, - currencyId: currency instanceof Token ? currency.address : currency === ETHER ? 'ETH' : '', + currencyId: currency instanceof Token ? currency.address : currency === ETHER ? 'ETH' : '' }) ) }, @@ -64,7 +64,7 @@ export function useSwapActionHandlers(): { onSwitchTokens, onCurrencySelection, onUserInput, - onChangeRecipient, + onChangeRecipient } } @@ -91,7 +91,7 @@ export function tryParseAmount(value?: string, currency?: Currency): CurrencyAmo const BAD_RECIPIENT_ADDRESSES: string[] = [ '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', // v2 factory '0xf164fC0Ec4E93095b804a4795bBe1e041497b92a', // v2 router 01 - '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', // v2 router 02 + '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D' // v2 router 02 ] /** @@ -101,8 +101,8 @@ const BAD_RECIPIENT_ADDRESSES: string[] = [ */ function involvesAddress(trade: Trade, checksummedAddress: string): boolean { return ( - trade.route.path.some((token) => token.address === checksummedAddress) || - trade.route.pairs.some((pair) => pair.liquidityToken.address === checksummedAddress) + trade.route.path.some(token => token.address === checksummedAddress) || + trade.route.pairs.some(pair => pair.liquidityToken.address === checksummedAddress) ) } @@ -124,7 +124,7 @@ export function useDerivedSwapInfo(): { typedValue, [Field.INPUT]: { currencyId: inputCurrencyId }, [Field.OUTPUT]: { currencyId: outputCurrencyId }, - recipient, + recipient } = useSwapState() const inputCurrency = useCurrency(inputCurrencyId) @@ -134,7 +134,7 @@ export function useDerivedSwapInfo(): { const relevantTokenBalances = useCurrencyBalances(account ?? undefined, [ inputCurrency ?? undefined, - outputCurrency ?? undefined, + outputCurrency ?? undefined ]) const isExactIn: boolean = independentField === Field.INPUT @@ -147,12 +147,12 @@ export function useDerivedSwapInfo(): { const currencyBalances = { [Field.INPUT]: relevantTokenBalances[0], - [Field.OUTPUT]: relevantTokenBalances[1], + [Field.OUTPUT]: relevantTokenBalances[1] } const currencies: { [field in Field]?: Currency } = { [Field.INPUT]: inputCurrency ?? undefined, - [Field.OUTPUT]: outputCurrency ?? undefined, + [Field.OUTPUT]: outputCurrency ?? undefined } // get link to trade on v1, if a better rate exists @@ -200,7 +200,7 @@ export function useDerivedSwapInfo(): { : null : slippageAdjustedAmounts ? slippageAdjustedAmounts[Field.INPUT] - : null, + : null ] if (balanceIn && amountIn && balanceIn.lessThan(amountIn)) { @@ -213,7 +213,7 @@ export function useDerivedSwapInfo(): { parsedAmount, v2Trade: v2Trade ?? undefined, inputError, - v1Trade, + v1Trade } } @@ -261,14 +261,14 @@ export function queryParametersToSwapState(parsedQs: ParsedQs): SwapState { return { [Field.INPUT]: { - currencyId: inputCurrency, + currencyId: inputCurrency }, [Field.OUTPUT]: { - currencyId: outputCurrency, + currencyId: outputCurrency }, typedValue: parseTokenAmountURLParameter(parsedQs.exactAmount), independentField: parseIndependentFieldURLParameter(parsedQs.exactField), - recipient, + recipient } } @@ -293,7 +293,7 @@ export function useDefaultsFromURLSearch(): field: parsed.independentField, inputCurrencyId: parsed[Field.INPUT].currencyId, outputCurrencyId: parsed[Field.OUTPUT].currencyId, - recipient: parsed.recipient, + recipient: parsed.recipient }) ) diff --git a/src/state/swap/reducer.test.ts b/src/state/swap/reducer.test.ts index 56e5a7b7c4..c7f48147ac 100644 --- a/src/state/swap/reducer.test.ts +++ b/src/state/swap/reducer.test.ts @@ -11,7 +11,7 @@ describe('swap reducer', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '', independentField: Field.INPUT, - recipient: null, + recipient: null }) }) @@ -20,7 +20,7 @@ describe('swap reducer', () => { store.dispatch( selectCurrency({ field: Field.OUTPUT, - currencyId: '0x0000', + currencyId: '0x0000' }) ) @@ -29,7 +29,7 @@ describe('swap reducer', () => { [Field.INPUT]: { currencyId: '' }, typedValue: '', independentField: Field.INPUT, - recipient: null, + recipient: null }) }) }) diff --git a/src/state/swap/reducer.ts b/src/state/swap/reducer.ts index 19fb30410a..ec74eeb0d1 100644 --- a/src/state/swap/reducer.ts +++ b/src/state/swap/reducer.ts @@ -18,29 +18,29 @@ const initialState: SwapState = { independentField: Field.INPUT, typedValue: '', [Field.INPUT]: { - currencyId: '', + currencyId: '' }, [Field.OUTPUT]: { - currencyId: '', + currencyId: '' }, - recipient: null, + recipient: null } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase( replaceSwapState, (state, { payload: { typedValue, recipient, field, inputCurrencyId, outputCurrencyId } }) => { return { [Field.INPUT]: { - currencyId: inputCurrencyId, + currencyId: inputCurrencyId }, [Field.OUTPUT]: { - currencyId: outputCurrencyId, + currencyId: outputCurrencyId }, independentField: field, typedValue: typedValue, - recipient, + recipient } } ) @@ -52,29 +52,29 @@ export default createReducer(initialState, (builder) => ...state, independentField: state.independentField === Field.INPUT ? Field.OUTPUT : Field.INPUT, [field]: { currencyId: currencyId }, - [otherField]: { currencyId: state[field].currencyId }, + [otherField]: { currencyId: state[field].currencyId } } } else { // the normal case return { ...state, - [field]: { currencyId: currencyId }, + [field]: { currencyId: currencyId } } } }) - .addCase(switchCurrencies, (state) => { + .addCase(switchCurrencies, state => { return { ...state, independentField: state.independentField === Field.INPUT ? Field.OUTPUT : Field.INPUT, [Field.INPUT]: { currencyId: state[Field.OUTPUT].currencyId }, - [Field.OUTPUT]: { currencyId: state[Field.INPUT].currencyId }, + [Field.OUTPUT]: { currencyId: state[Field.INPUT].currencyId } } }) .addCase(typeInput, (state, { payload: { field, typedValue } }) => { return { ...state, independentField: field, - typedValue, + typedValue } }) .addCase(setRecipient, (state, { payload: { recipient } }) => { diff --git a/src/state/transactions/hooks.tsx b/src/state/transactions/hooks.tsx index c971609324..4d8fb21078 100644 --- a/src/state/transactions/hooks.tsx +++ b/src/state/transactions/hooks.tsx @@ -21,7 +21,7 @@ export function useTransactionAdder(): ( { summary, approval, - claim, + claim }: { summary?: string; claim?: { recipient: string }; approval?: { tokenAddress: string; spender: string } } = {} ) => { if (!account) return @@ -41,7 +41,7 @@ export function useTransactionAdder(): ( export function useAllTransactions(): { [txHash: string]: TransactionDetails } { const { chainId } = useActiveWeb3React() - const state = useSelector((state) => state.transactions) + const state = useSelector(state => state.transactions) return chainId ? state[chainId] ?? {} : {} } @@ -69,7 +69,7 @@ export function useHasPendingApproval(tokenAddress: string | undefined, spender: () => typeof tokenAddress === 'string' && typeof spender === 'string' && - Object.keys(allTransactions).some((hash) => { + Object.keys(allTransactions).some(hash => { const tx = allTransactions[hash] if (!tx) return false if (tx.receipt) { @@ -93,7 +93,7 @@ export function useUserHasSubmittedClaim( // get the txn if it has been submitted const claimTxn = useMemo(() => { - const txnIndex = Object.keys(allTransactions).find((hash) => { + const txnIndex = Object.keys(allTransactions).find(hash => { const tx = allTransactions[hash] return tx.claim && tx.claim.recipient === account }) diff --git a/src/state/transactions/reducer.test.ts b/src/state/transactions/reducer.test.ts index 35292b673b..941d48c7a3 100644 --- a/src/state/transactions/reducer.test.ts +++ b/src/state/transactions/reducer.test.ts @@ -19,7 +19,7 @@ describe('transaction reducer', () => { summary: 'hello world', hash: '0x0', approval: { tokenAddress: 'abc', spender: 'def' }, - from: 'abc', + from: 'abc' }) ) const txs = store.getState() @@ -49,8 +49,8 @@ describe('transaction reducer', () => { from: '0x0', contractAddress: '0x0', blockHash: '0x0', - blockNumber: 1, - }, + blockNumber: 1 + } }) ) expect(store.getState()).toEqual({}) @@ -62,7 +62,7 @@ describe('transaction reducer', () => { chainId: ChainId.RINKEBY, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', - from: '0x0', + from: '0x0' }) ) const beforeTime = new Date().getTime() @@ -78,8 +78,8 @@ describe('transaction reducer', () => { from: '0x0', contractAddress: '0x0', blockHash: '0x0', - blockNumber: 1, - }, + blockNumber: 1 + } }) ) const tx = store.getState()[ChainId.RINKEBY]?.['0x0'] @@ -93,7 +93,7 @@ describe('transaction reducer', () => { from: '0x0', contractAddress: '0x0', blockHash: '0x0', - blockNumber: 1, + blockNumber: 1 }) }) }) @@ -104,7 +104,7 @@ describe('transaction reducer', () => { checkedTransaction({ chainId: ChainId.RINKEBY, hash: '0x0', - blockNumber: 1, + blockNumber: 1 }) ) expect(store.getState()).toEqual({}) @@ -116,14 +116,14 @@ describe('transaction reducer', () => { chainId: ChainId.RINKEBY, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', - from: '0x0', + from: '0x0' }) ) store.dispatch( checkedTransaction({ chainId: ChainId.RINKEBY, hash: '0x0', - blockNumber: 1, + blockNumber: 1 }) ) const tx = store.getState()[ChainId.RINKEBY]?.['0x0'] @@ -136,21 +136,21 @@ describe('transaction reducer', () => { chainId: ChainId.RINKEBY, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', - from: '0x0', + from: '0x0' }) ) store.dispatch( checkedTransaction({ chainId: ChainId.RINKEBY, hash: '0x0', - blockNumber: 3, + blockNumber: 3 }) ) store.dispatch( checkedTransaction({ chainId: ChainId.RINKEBY, hash: '0x0', - blockNumber: 1, + blockNumber: 1 }) ) const tx = store.getState()[ChainId.RINKEBY]?.['0x0'] @@ -166,7 +166,7 @@ describe('transaction reducer', () => { summary: 'hello world', hash: '0x0', approval: { tokenAddress: 'abc', spender: 'def' }, - from: 'abc', + from: 'abc' }) ) store.dispatch( @@ -175,7 +175,7 @@ describe('transaction reducer', () => { summary: 'hello world', hash: '0x1', approval: { tokenAddress: 'abc', spender: 'def' }, - from: 'abc', + from: 'abc' }) ) expect(Object.keys(store.getState())).toHaveLength(2) diff --git a/src/state/transactions/reducer.ts b/src/state/transactions/reducer.ts index 3553567252..fd2a66f047 100644 --- a/src/state/transactions/reducer.ts +++ b/src/state/transactions/reducer.ts @@ -4,7 +4,7 @@ import { checkedTransaction, clearAllTransactions, finalizeTransaction, - SerializableTransactionReceipt, + SerializableTransactionReceipt } from './actions' const now = () => new Date().getTime() @@ -29,7 +29,7 @@ export interface TransactionState { export const initialState: TransactionState = {} -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder .addCase(addTransaction, (transactions, { payload: { chainId, from, hash, approval, summary, claim } }) => { if (transactions[chainId]?.[hash]) { diff --git a/src/state/transactions/updater.tsx b/src/state/transactions/updater.tsx index b57df76ea2..732049fc44 100644 --- a/src/state/transactions/updater.tsx +++ b/src/state/transactions/updater.tsx @@ -35,7 +35,7 @@ export default function Updater(): null { const lastBlockNumber = useBlockNumber() const dispatch = useDispatch() - const state = useSelector((state) => state.transactions) + const state = useSelector(state => state.transactions) const transactions = chainId ? state[chainId] ?? {} : {} @@ -46,11 +46,11 @@ export default function Updater(): null { if (!chainId || !library || !lastBlockNumber) return Object.keys(transactions) - .filter((hash) => shouldCheck(lastBlockNumber, transactions[hash])) - .forEach((hash) => { + .filter(hash => shouldCheck(lastBlockNumber, transactions[hash])) + .forEach(hash => { library .getTransactionReceipt(hash) - .then((receipt) => { + .then(receipt => { if (receipt) { dispatch( finalizeTransaction({ @@ -64,8 +64,8 @@ export default function Updater(): null { status: receipt.status, to: receipt.to, transactionHash: receipt.transactionHash, - transactionIndex: receipt.transactionIndex, - }, + transactionIndex: receipt.transactionIndex + } }) ) @@ -74,8 +74,8 @@ export default function Updater(): null { txn: { hash, success: receipt.status === 1, - summary: transactions[hash]?.summary, - }, + summary: transactions[hash]?.summary + } }, hash ) @@ -83,7 +83,7 @@ export default function Updater(): null { dispatch(checkedTransaction({ chainId, hash, blockNumber: lastBlockNumber })) } }) - .catch((error) => { + .catch(error => { console.error(`failed to check transaction hash: ${hash}`, error) }) }) diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index f3a2fe14e4..178cfbd665 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -19,7 +19,7 @@ import { updateUserExpertMode, updateUserSlippageTolerance, toggleURLWarning, - updateUserSingleHopOnly, + updateUserSingleHopOnly } from './actions' function serializeToken(token: Token): SerializedToken { @@ -28,7 +28,7 @@ function serializeToken(token: Token): SerializedToken { address: token.address, decimals: token.decimals, symbol: token.symbol, - name: token.name, + name: token.name } } @@ -49,7 +49,7 @@ export function useIsDarkMode(): boolean { >( ({ user: { matchesDarkMode, userDarkMode } }) => ({ userDarkMode, - matchesDarkMode, + matchesDarkMode }), shallowEqual ) @@ -69,7 +69,7 @@ export function useDarkModeManager(): [boolean, () => void] { } export function useIsExpertMode(): boolean { - return useSelector((state) => state.user.userExpertMode) + return useSelector(state => state.user.userExpertMode) } export function useExpertModeManager(): [boolean, () => void] { @@ -87,14 +87,14 @@ export function useUserSingleHopOnly(): [boolean, (newSingleHopOnly: boolean) => const dispatch = useDispatch() const singleHopOnly = useSelector( - (state) => state.user.userSingleHopOnly + state => state.user.userSingleHopOnly ) const setSingleHopOnly = useCallback( (newSingleHopOnly: boolean) => { ReactGA.event({ category: 'Routing', - action: newSingleHopOnly ? 'enable single hop' : 'disable single hop', + action: newSingleHopOnly ? 'enable single hop' : 'disable single hop' }) dispatch(updateUserSingleHopOnly({ userSingleHopOnly: newSingleHopOnly })) }, @@ -106,7 +106,7 @@ export function useUserSingleHopOnly(): [boolean, (newSingleHopOnly: boolean) => export function useUserSlippageTolerance(): [number, (slippage: number) => void] { const dispatch = useDispatch() - const userSlippageTolerance = useSelector((state) => { + const userSlippageTolerance = useSelector(state => { return state.user.userSlippageTolerance }) @@ -122,7 +122,7 @@ export function useUserSlippageTolerance(): [number, (slippage: number) => void] export function useUserTransactionTTL(): [number, (slippage: number) => void] { const dispatch = useDispatch() - const userDeadline = useSelector((state) => { + const userDeadline = useSelector(state => { return state.user.userDeadline }) @@ -169,7 +169,7 @@ export function useUserAddedTokens(): Token[] { function serializePair(pair: Pair): SerializedPair { return { token0: serializeToken(pair.token0), - token1: serializeToken(pair.token1), + token1: serializeToken(pair.token1) } } @@ -216,14 +216,14 @@ export function useTrackedTokenPairs(): [Token, Token][] { const generatedPairs: [Token, Token][] = useMemo( () => chainId - ? flatMap(Object.keys(tokens), (tokenAddress) => { + ? flatMap(Object.keys(tokens), tokenAddress => { const token = tokens[tokenAddress] // for each token on the current chain, return ( // loop though all bases on the current chain (BASES_TO_TRACK_LIQUIDITY_FOR[chainId] ?? []) // to construct pairs of the given token with each base - .map((base) => { + .map(base => { if (base.address === token.address) { return null } else { @@ -245,7 +245,7 @@ export function useTrackedTokenPairs(): [Token, Token][] { const forChain = savedSerializedPairs[chainId] if (!forChain) return [] - return Object.keys(forChain).map((pairId) => { + return Object.keys(forChain).map(pairId => { return [deserializeToken(forChain[pairId].token0), deserializeToken(forChain[pairId].token1)] }) }, [savedSerializedPairs, chainId]) @@ -253,7 +253,7 @@ export function useTrackedTokenPairs(): [Token, Token][] { const combinedList = useMemo(() => userPairs.concat(generatedPairs).concat(pinnedPairs), [ generatedPairs, pinnedPairs, - userPairs, + userPairs ]) return useMemo(() => { @@ -266,6 +266,6 @@ export function useTrackedTokenPairs(): [Token, Token][] { return memo }, {}) - return Object.keys(keyed).map((key) => keyed[key]) + return Object.keys(keyed).map(key => keyed[key]) }, [combinedList]) } diff --git a/src/state/user/reducer.test.ts b/src/state/user/reducer.test.ts index 535c42bd91..bf2e55cf41 100644 --- a/src/state/user/reducer.test.ts +++ b/src/state/user/reducer.test.ts @@ -23,7 +23,7 @@ describe('swap reducer', () => { store = createStore(reducer, { ...initialState, userDeadline: undefined, - userSlippageTolerance: undefined, + userSlippageTolerance: undefined } as any) store.dispatch(updateVersion()) expect(store.getState().userDeadline).toEqual(DEFAULT_DEADLINE_FROM_NOW) diff --git a/src/state/user/reducer.ts b/src/state/user/reducer.ts index 7b1f675cc5..e1a8cf11b9 100644 --- a/src/state/user/reducer.ts +++ b/src/state/user/reducer.ts @@ -14,7 +14,7 @@ import { updateUserSlippageTolerance, updateUserDeadline, toggleURLWarning, - updateUserSingleHopOnly, + updateUserSingleHopOnly } from './actions' const currentTimestamp = () => new Date().getTime() @@ -67,12 +67,12 @@ export const initialState: UserState = { tokens: {}, pairs: {}, timestamp: currentTimestamp(), - URLWarningVisible: true, + URLWarningVisible: true } -export default createReducer(initialState, (builder) => +export default createReducer(initialState, builder => builder - .addCase(updateVersion, (state) => { + .addCase(updateVersion, state => { // slippage isnt being tracked in local storage, reset to default // noinspection SuspiciousTypeOfGuard if (typeof state.userSlippageTolerance !== 'number') { @@ -139,7 +139,7 @@ export default createReducer(initialState, (builder) => } state.timestamp = currentTimestamp() }) - .addCase(toggleURLWarning, (state) => { + .addCase(toggleURLWarning, state => { state.URLWarningVisible = !state.URLWarningVisible }) ) diff --git a/src/state/wallet/hooks.ts b/src/state/wallet/hooks.ts index e19409c4e7..c952916b1f 100644 --- a/src/state/wallet/hooks.ts +++ b/src/state/wallet/hooks.ts @@ -32,7 +32,7 @@ export function useETHBalances( const results = useSingleContractMultipleData( multicallContract, 'getEthBalance', - addresses.map((address) => [address]) + addresses.map(address => [address]) ) return useMemo( @@ -58,11 +58,11 @@ export function useTokenBalancesWithLoadingIndicator( [tokens] ) - const validatedTokenAddresses = useMemo(() => validatedTokens.map((vt) => vt.address), [validatedTokens]) + const validatedTokenAddresses = useMemo(() => validatedTokens.map(vt => vt.address), [validatedTokens]) const balances = useMultipleContractSingleData(validatedTokenAddresses, ERC20_INTERFACE, 'balanceOf', [address]) - const anyLoading: boolean = useMemo(() => balances.some((callState) => callState.loading), [balances]) + const anyLoading: boolean = useMemo(() => balances.some(callState => callState.loading), [balances]) return [ useMemo( @@ -79,7 +79,7 @@ export function useTokenBalancesWithLoadingIndicator( : {}, [address, validatedTokens, balances] ), - anyLoading, + anyLoading ] } @@ -102,16 +102,16 @@ export function useCurrencyBalances( currencies?: (Currency | undefined)[] ): (CurrencyAmount | undefined)[] { const tokens = useMemo(() => currencies?.filter((currency): currency is Token => currency instanceof Token) ?? [], [ - currencies, + currencies ]) const tokenBalances = useTokenBalances(account, tokens) - const containsETH: boolean = useMemo(() => currencies?.some((currency) => currency === ETHER) ?? false, [currencies]) + const containsETH: boolean = useMemo(() => currencies?.some(currency => currency === ETHER) ?? false, [currencies]) const ethBalance = useETHBalances(containsETH ? [account] : []) return useMemo( () => - currencies?.map((currency) => { + currencies?.map(currency => { if (!account || !currency) return undefined if (currency instanceof Token) return tokenBalances[currency.address] if (currency === ETHER) return ethBalance[account] diff --git a/src/theme/DarkModeQueryParamReader.tsx b/src/theme/DarkModeQueryParamReader.tsx index 89693913a0..9571464dd0 100644 --- a/src/theme/DarkModeQueryParamReader.tsx +++ b/src/theme/DarkModeQueryParamReader.tsx @@ -14,7 +14,7 @@ export default function DarkModeQueryParamReader({ location: { search } }: Route const parsed = parse(search, { parseArrays: false, - ignoreQueryPrefix: true, + ignoreQueryPrefix: true }) const theme = parsed.theme diff --git a/src/theme/components.tsx b/src/theme/components.tsx index 55ead6ea12..bc736952b0 100644 --- a/src/theme/components.tsx +++ b/src/theme/components.tsx @@ -24,7 +24,7 @@ export const ButtonText = styled.button` ` export const Button = styled.button.attrs<{ warning: boolean }, { backgroundColor: string }>(({ warning, theme }) => ({ - backgroundColor: warning ? theme.red1 : theme.primary1, + backgroundColor: warning ? theme.red1 : theme.primary1 }))` padding: 1rem 2rem 1rem 2rem; border-radius: 3rem; diff --git a/src/theme/index.tsx b/src/theme/index.tsx index 28a5d10f33..83d9668d0b 100644 --- a/src/theme/index.tsx +++ b/src/theme/index.tsx @@ -4,7 +4,7 @@ import styled, { ThemeProvider as StyledComponentsThemeProvider, createGlobalStyle, css, - DefaultTheme, + DefaultTheme } from 'styled-components' import { useIsDarkMode } from '../state/user/hooks' import { Text, TextProps } from 'rebass' @@ -16,7 +16,7 @@ const MEDIA_WIDTHS = { upToExtraSmall: 500, upToSmall: 720, upToMedium: 960, - upToLarge: 1280, + upToLarge: 1280 } const mediaWidthTemplates: { [width in keyof typeof MEDIA_WIDTHS]: typeof css } = Object.keys(MEDIA_WIDTHS).reduce( @@ -80,7 +80,7 @@ export function colors(darkMode: boolean): Colors { green1: '#27AE60', yellow1: '#FFE270', yellow2: '#F3841E', - blue1: '#2172E5', + blue1: '#2172E5' // dont wanna forget these blue yet // blue4: darkMode ? '#153d6f70' : '#C4D9F8', @@ -95,7 +95,7 @@ export function theme(darkMode: boolean): DefaultTheme { grids: { sm: 8, md: 12, - lg: 24, + lg: 24 }, //shadows @@ -112,7 +112,7 @@ export function theme(darkMode: boolean): DefaultTheme { flexRowNoWrap: css` display: flex; flex-flow: row nowrap; - `, + ` } } @@ -173,7 +173,7 @@ export const TYPE = { }, error({ error, ...props }: { error: boolean } & TextProps) { return - }, + } } export const FixedGlobalStyle = createGlobalStyle` diff --git a/src/utils/chunkArray.test.ts b/src/utils/chunkArray.test.ts index 34b9bc5698..38e5520f83 100644 --- a/src/utils/chunkArray.test.ts +++ b/src/utils/chunkArray.test.ts @@ -14,7 +14,7 @@ describe('#chunkArray', () => { it('size exact half', () => { expect(chunkArray([1, 2, 3, 4], 2)).toEqual([ [1, 2], - [3, 4], + [3, 4] ]) }) it('evenly distributes', () => { @@ -22,8 +22,8 @@ describe('#chunkArray', () => { expect(chunked).toEqual([ [...Array(34).keys()], - [...Array(34).keys()].map((i) => i + 34), - [...Array(32).keys()].map((i) => i + 68), + [...Array(34).keys()].map(i => i + 34), + [...Array(32).keys()].map(i => i + 68) ]) expect(chunked[0][0]).toEqual(0) diff --git a/src/utils/chunkArray.ts b/src/utils/chunkArray.ts index 19eab29d38..8dabba5806 100644 --- a/src/utils/chunkArray.ts +++ b/src/utils/chunkArray.ts @@ -7,5 +7,5 @@ export default function chunkArray(items: T[], maxChunkSize: number): T[][] { const numChunks: number = Math.ceil(items.length / maxChunkSize) const chunkSize = Math.ceil(items.length / numChunks) - return [...Array(numChunks).keys()].map((ix) => items.slice(ix * chunkSize, ix * chunkSize + chunkSize)) + return [...Array(numChunks).keys()].map(ix => items.slice(ix * chunkSize, ix * chunkSize + chunkSize)) } diff --git a/src/utils/index.test.ts b/src/utils/index.test.ts index 713bb856f1..59c7730a4e 100644 --- a/src/utils/index.test.ts +++ b/src/utils/index.test.ts @@ -8,7 +8,7 @@ import { isAddress, shortenAddress, calculateGasMargin, - basisPointsToPercent, + basisPointsToPercent } from '.' describe('utils', () => { @@ -37,10 +37,10 @@ describe('utils', () => { it('bounds are correct', () => { const tokenAmount = new TokenAmount(new Token(ChainId.MAINNET, AddressZero, 0), '100') expect(() => calculateSlippageAmount(tokenAmount, -1)).toThrow() - expect(calculateSlippageAmount(tokenAmount, 0).map((bound) => bound.toString())).toEqual(['100', '100']) - expect(calculateSlippageAmount(tokenAmount, 100).map((bound) => bound.toString())).toEqual(['99', '101']) - expect(calculateSlippageAmount(tokenAmount, 200).map((bound) => bound.toString())).toEqual(['98', '102']) - expect(calculateSlippageAmount(tokenAmount, 10000).map((bound) => bound.toString())).toEqual(['0', '200']) + expect(calculateSlippageAmount(tokenAmount, 0).map(bound => bound.toString())).toEqual(['100', '100']) + expect(calculateSlippageAmount(tokenAmount, 100).map(bound => bound.toString())).toEqual(['99', '101']) + expect(calculateSlippageAmount(tokenAmount, 200).map(bound => bound.toString())).toEqual(['98', '102']) + expect(calculateSlippageAmount(tokenAmount, 10000).map(bound => bound.toString())).toEqual(['0', '200']) expect(() => calculateSlippageAmount(tokenAmount, 10001)).toThrow() }) }) diff --git a/src/utils/index.ts b/src/utils/index.ts index d0dc75145f..7281e09662 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,7 +22,7 @@ const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = { 3: 'ropsten.', 4: 'rinkeby.', 5: 'goerli.', - 42: 'kovan.', + 42: 'kovan.' } export function getEtherscanLink( @@ -74,7 +74,7 @@ export function calculateSlippageAmount(value: CurrencyAmount, slippage: number) } return [ JSBI.divide(JSBI.multiply(value.raw, JSBI.BigInt(10000 - slippage)), JSBI.BigInt(10000)), - JSBI.divide(JSBI.multiply(value.raw, JSBI.BigInt(10000 + slippage)), JSBI.BigInt(10000)), + JSBI.divide(JSBI.multiply(value.raw, JSBI.BigInt(10000 + slippage)), JSBI.BigInt(10000)) ] } diff --git a/src/utils/prices.test.ts b/src/utils/prices.test.ts index 9e8cbac59c..e519ab75c7 100644 --- a/src/utils/prices.test.ts +++ b/src/utils/prices.test.ts @@ -13,7 +13,7 @@ describe('prices', () => { it('returns undefined for undefined', () => { expect(computeTradePriceBreakdown(undefined)).toEqual({ priceImpactWithoutFee: undefined, - realizedLPFee: undefined, + realizedLPFee: undefined }) }) diff --git a/src/utils/prices.ts b/src/utils/prices.ts index 16e5eb7f67..0412d47b8a 100644 --- a/src/utils/prices.ts +++ b/src/utils/prices.ts @@ -50,7 +50,7 @@ export function computeSlippageAdjustedAmounts( const pct = basisPointsToPercent(allowedSlippage) return { [Field.INPUT]: trade?.maximumAmountIn(pct), - [Field.OUTPUT]: trade?.minimumAmountOut(pct), + [Field.OUTPUT]: trade?.minimumAmountOut(pct) } } diff --git a/src/utils/resolveENSContentHash.ts b/src/utils/resolveENSContentHash.ts index f8ee805090..2c2619aad4 100644 --- a/src/utils/resolveENSContentHash.ts +++ b/src/utils/resolveENSContentHash.ts @@ -8,20 +8,20 @@ const REGISTRAR_ABI = [ inputs: [ { name: 'node', - type: 'bytes32', - }, + type: 'bytes32' + } ], name: 'resolver', outputs: [ { name: 'resolverAddress', - type: 'address', - }, + type: 'address' + } ], payable: false, stateMutability: 'view', - type: 'function', - }, + type: 'function' + } ] const REGISTRAR_ADDRESS = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' @@ -32,21 +32,21 @@ const RESOLVER_ABI = [ { internalType: 'bytes32', name: 'node', - type: 'bytes32', - }, + type: 'bytes32' + } ], name: 'contenthash', outputs: [ { internalType: 'bytes', name: '', - type: 'bytes', - }, + type: 'bytes' + } ], payable: false, stateMutability: 'view', - type: 'function', - }, + type: 'function' + } ] // cache the resolver contracts since most of them are the public resolver diff --git a/src/utils/retry.ts b/src/utils/retry.ts index 0adaf859a0..e2d8530287 100644 --- a/src/utils/retry.ts +++ b/src/utils/retry.ts @@ -1,5 +1,5 @@ function wait(ms: number): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)) + return new Promise(resolve => setTimeout(resolve, ms)) } function waitRandom(min: number, max: number): Promise { @@ -64,6 +64,6 @@ export function retry( if (completed) return completed = true rejectCancelled(new CancelledError()) - }, + } } } diff --git a/src/utils/uriToHttp.test.ts b/src/utils/uriToHttp.test.ts index 2e922cf9fa..dc37266896 100644 --- a/src/utils/uriToHttp.test.ts +++ b/src/utils/uriToHttp.test.ts @@ -13,13 +13,13 @@ describe('uriToHttp', () => { it('returns ipfs gateways for ipfs:// urls', () => { expect(uriToHttp('ipfs://QmV8AfDE8GFSGQvt3vck8EwAzsPuNTmtP8VcQJE3qxRPaZ')).toEqual([ 'https://cloudflare-ipfs.com/ipfs/QmV8AfDE8GFSGQvt3vck8EwAzsPuNTmtP8VcQJE3qxRPaZ/', - 'https://ipfs.io/ipfs/QmV8AfDE8GFSGQvt3vck8EwAzsPuNTmtP8VcQJE3qxRPaZ/', + 'https://ipfs.io/ipfs/QmV8AfDE8GFSGQvt3vck8EwAzsPuNTmtP8VcQJE3qxRPaZ/' ]) }) it('returns ipns gateways for ipns:// urls', () => { expect(uriToHttp('ipns://app.uniswap.org')).toEqual([ 'https://cloudflare-ipfs.com/ipns/app.uniswap.org/', - 'https://ipfs.io/ipns/app.uniswap.org/', + 'https://ipfs.io/ipns/app.uniswap.org/' ]) }) it('returns empty array for invalid scheme', () => { diff --git a/src/utils/useUSDCPrice.ts b/src/utils/useUSDCPrice.ts index 745ac42a14..883e7d321d 100644 --- a/src/utils/useUSDCPrice.ts +++ b/src/utils/useUSDCPrice.ts @@ -16,10 +16,10 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined { () => [ [ chainId && wrapped && currencyEquals(WETH[chainId], wrapped) ? undefined : currency, - chainId ? WETH[chainId] : undefined, + chainId ? WETH[chainId] : undefined ], [wrapped?.equals(USDC) ? undefined : wrapped, chainId === ChainId.MAINNET ? USDC : undefined], - [chainId ? WETH[chainId] : undefined, chainId === ChainId.MAINNET ? USDC : undefined], + [chainId ? WETH[chainId] : undefined, chainId === ChainId.MAINNET ? USDC : undefined] ], [chainId, currency, wrapped] ) diff --git a/src/utils/v1SwapArgument.test.ts b/src/utils/v1SwapArgument.test.ts index eeef9df607..6bde233880 100644 --- a/src/utils/v1SwapArgument.test.ts +++ b/src/utils/v1SwapArgument.test.ts @@ -15,7 +15,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 20 * 60, + deadline: 20 * 60 }) expect(result.methodName).toEqual('ethToTokenTransferInput') expect(result.args).toEqual(['0x62', '0x4b0', TEST_RECIPIENT_ADDRESS]) @@ -26,7 +26,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 40 * 60, + deadline: 40 * 60 }) expect(result.methodName).toEqual('tokenToEthTransferInput') expect(result.args[0]).toEqual('0x64') @@ -40,7 +40,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 20 * 60, + deadline: 20 * 60 }) expect(result.methodName).toEqual('tokenToTokenTransferInput') expect(result.args[0]).toEqual('0x64') @@ -56,7 +56,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 20 * 60, + deadline: 20 * 60 }) expect(result.methodName).toEqual('ethToTokenTransferOutput') expect(result.args[0]).toEqual('0x64') @@ -69,7 +69,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 20 * 60, + deadline: 20 * 60 }) expect(result.methodName).toEqual('tokenToEthTransferOutput') expect(result.args[0]).toEqual('0x64') @@ -83,7 +83,7 @@ describe('v1SwapArguments', () => { const result = v1SwapArguments(trade, { recipient: TEST_RECIPIENT_ADDRESS, allowedSlippage: new Percent('1', '100'), - deadline: 20 * 60, + deadline: 20 * 60 }) expect(result.methodName).toEqual('tokenToTokenTransferOutput') expect(result.args[0]).toEqual('0x64') diff --git a/src/utils/v1SwapArguments.ts b/src/utils/v1SwapArguments.ts index 8bafa43950..560501ccee 100644 --- a/src/utils/v1SwapArguments.ts +++ b/src/utils/v1SwapArguments.ts @@ -34,13 +34,13 @@ export default function v1SwapArguments( return { methodName: 'ethToTokenTransferInput', args: [minimumAmountOut, deadline, options.recipient], - value: maximumAmountIn, + value: maximumAmountIn } } else if (outputETH) { return { methodName: 'tokenToEthTransferInput', args: [maximumAmountIn, minimumAmountOut, deadline, options.recipient], - value: '0x0', + value: '0x0' } } else { const outputToken = trade.outputAmount.currency @@ -51,7 +51,7 @@ export default function v1SwapArguments( return { methodName: 'tokenToTokenTransferInput', args: [maximumAmountIn, minimumAmountOut, '0x1', deadline, options.recipient, outputToken.address], - value: '0x0', + value: '0x0' } } } else { @@ -59,13 +59,13 @@ export default function v1SwapArguments( return { methodName: 'ethToTokenTransferOutput', args: [minimumAmountOut, deadline, options.recipient], - value: maximumAmountIn, + value: maximumAmountIn } } else if (outputETH) { return { methodName: 'tokenToEthTransferOutput', args: [minimumAmountOut, maximumAmountIn, deadline, options.recipient], - value: '0x0', + value: '0x0' } } else { const output = trade.outputAmount.currency @@ -81,9 +81,9 @@ export default function v1SwapArguments( MaxUint256.toHexString(), deadline, options.recipient, - output.address, + output.address ], - value: '0x0', + value: '0x0' } } }