Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting formatic wallet and fixing tests #517

Merged
merged 4 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
unit-tests:
Expand Down
3 changes: 1 addition & 2 deletions src/components/auction/OrderPlacement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState } from 'react'
import styled from 'styled-components'
import { Fraction, TokenAmount } from 'uniswap-xdai-sdk'

import { EASY_AUCTION_NETWORKS } from '../../../constants'
import { useActiveWeb3React } from '../../../hooks'
import { ApprovalState, useApproveCallback } from '../../../hooks/useApproveCallback'
import { useAuctionDetails } from '../../../hooks/useAuctionDetails'
Expand All @@ -21,7 +20,7 @@ import { AuctionIdentifier } from '../../../state/orderPlacement/reducer'
import { useOrderState } from '../../../state/orders/hooks'
import { OrderState } from '../../../state/orders/reducer'
import { useTokenBalancesTreatWETHAsETHonXDAI } from '../../../state/wallet/hooks'
import { ChainId, getTokenDisplay } from '../../../utils'
import { ChainId, EASY_AUCTION_NETWORKS, getTokenDisplay } from '../../../utils'
import { getChainName } from '../../../utils/tools'
import { Button } from '../../buttons/Button'
import { ButtonType } from '../../buttons/buttonStylingTypes'
Expand Down
9 changes: 1 addition & 8 deletions src/components/modals/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { URI_AVAILABLE } from '@anxolin/walletconnect-connector'
import { UnsupportedChainIdError, useWeb3React } from '@web3-react/core'
import ReactGA from 'react-ga'

import { fortmatic, injected, walletconnect } from '../../../connectors'
import { OVERLAY_READY } from '../../../connectors/Fortmatic'
import { injected, walletconnect } from '../../../connectors'
import { SUPPORTED_WALLETS } from '../../../constants'
import usePrevious from '../../../hooks/usePrevious'
import { useWalletModalOpen, useWalletModalToggle } from '../../../state/application/hooks'
Expand Down Expand Up @@ -180,12 +179,6 @@ const WalletModal: React.FC = () => {
}
}

useEffect(() => {
fortmatic.on(OVERLAY_READY, () => {
toggleWalletModal()
})
}, [toggleWalletModal])

const getOptions = () => {
const isMetamask = window.ethereum && window.ethereum.isMetaMask

Expand Down
54 changes: 0 additions & 54 deletions src/connectors/Fortmatic.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import { WalletLinkConnector } from '@web3-react/walletlink-connector'

import {
CHAIN_ID,
FORTMATIC_KEY,
NETWORK_URL_MAINNET,
NETWORK_URL_RINKEBY,
NETWORK_URL_XDAI,
PORTIS_ID,
} from '../constants/config'
import { FortmaticConnector } from './Fortmatic'

interface NetworkConnectorArguments {
urls: { [chainId: number]: string }
Expand Down Expand Up @@ -66,12 +64,6 @@ export const walletconnect = {
}),
}

// mainnet only
export const fortmatic = new FortmaticConnector({
apiKey: FORTMATIC_KEY,
chainId: 1,
})

// mainnet only
export const portis = new PortisConnector({
dAppId: PORTIS_ID,
Expand Down
25 changes: 1 addition & 24 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,18 @@ import { JSBI, Percent } from 'uniswap-xdai-sdk'

import ArrowRightIcon from '../assets/images/arrow-right.svg'
import CoinbaseWalletIcon from '../assets/images/coinbaseWalletIcon.svg'
import FortmaticIcon from '../assets/images/fortmaticIcon.png'
import MetamaskIcon from '../assets/images/metamask.svg'
import PortisIcon from '../assets/images/portisIcon.png'
import TrustWalletIcon from '../assets/images/trustWallet.png'
import WalletConnectIcon from '../assets/images/wallet-connect.svg'
import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'
import { ChainId } from '../utils'
import { injected, portis, walletconnect, walletlink } from '../connectors'

export const chainNames = {
1: 'mainnet',
4: 'rinkeby',
100: 'xdai',
}

export const EASY_AUCTION_NETWORKS: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
[ChainId.RINKEBY]: '0xC5992c0e0A3267C7F75493D0F717201E26BE35f7',
[ChainId.XDAI]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
}

export const DEPOSIT_AND_PLACE_ORDER: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: '0x10D15DEA67f7C95e2F9Fe4eCC245a8862b9B5B96',
[ChainId.RINKEBY]: '0x8624fbDf455D51B967ff40aaB4019281A855f008',
[ChainId.XDAI]: '0x845AbED0734e39614FEC4245F3F3C88E2da98157',
}

const MAINNET_WALLETS = {
INJECTED: {
connector: injected,
Expand Down Expand Up @@ -87,15 +73,6 @@ const EXTRA_WALLETS = {
mobile: true,
mobileOnly: true,
},
FORTMATIC: {
connector: fortmatic,
name: 'Fortmatic',
icon: FortmaticIcon,
description: 'Login using Fortmatic hosted wallet',
href: null,
color: '#6748FF',
mobile: true,
},
Portis: {
connector: portis,
name: 'Portis',
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/usePlaceOrderCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { BigNumber } from '@ethersproject/bignumber'
import { Contract } from '@ethersproject/contracts'

import { additionalServiceApi } from '../api'
import { DEPOSIT_AND_PLACE_ORDER, EASY_AUCTION_NETWORKS } from '../constants'
import depositAndPlaceOrderABI from '../constants/abis/easyAuction/depositAndPlaceOrder.json'
import easyAuctionABI from '../constants/abis/easyAuction/easyAuction.json'
import { NUMBER_OF_DIGITS_FOR_INVERSION } from '../constants/config'
Expand All @@ -18,6 +17,8 @@ import { OrderStatus } from '../state/orders/reducer'
import { useTransactionAdder } from '../state/transactions/hooks'
import {
ChainId,
DEPOSIT_AND_PLACE_ORDER,
EASY_AUCTION_NETWORKS,
calculateGasMargin,
getContract,
getEasyAuctionContract,
Expand Down
3 changes: 1 addition & 2 deletions src/state/orderPlacement/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useDispatch, useSelector } from 'react-redux'

import { additionalServiceApi } from '../../api'
import { ClearingPriceAndVolumeData } from '../../api/AdditionalServicesApi'
import { EASY_AUCTION_NETWORKS } from '../../constants'
import easyAuctionABI from '../../constants/abis/easyAuction/easyAuction.json'
import { NUMBER_OF_DIGITS_FOR_INVERSION } from '../../constants/config'
import { useActiveWeb3React } from '../../hooks'
Expand All @@ -18,7 +17,7 @@ import { AuctionInfoDetail, useAuctionDetails } from '../../hooks/useAuctionDeta
import { useGetClaimInfo } from '../../hooks/useClaimOrderCallback'
import { useContract } from '../../hooks/useContract'
import { useClearingPriceInfo } from '../../hooks/useCurrentClearingOrderAndVolumeCallback'
import { ChainId, getTokenDisplay } from '../../utils'
import { ChainId, EASY_AUCTION_NETWORKS, getTokenDisplay } from '../../utils'
import { getLogger } from '../../utils/logger'
import { convertPriceIntoBuyAndSellAmount, getInverse } from '../../utils/prices'
import { AppDispatch, AppState } from '../index'
Expand Down
17 changes: 10 additions & 7 deletions src/state/orderPlacement/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ describe('orderplacement reducer', () => {
beforeEach(() => {
store = createStore(reducer, {
price: '1',
auctionId: 1,
sellAmount: '',
chainId: 1,
showPriceInverted: false,
})
})

describe('setDefaultsFromURL', () => {
test('get auctionId', () => {
store.dispatch(
setDefaultsFromURLSearch({
chainId: 1,
queryString: '?auctionId=2',
queryString: '?chainId=1&auctionId=2',
}),
)

expect(store.getState()).toEqual({
price: '1',
auctionId: 2,
price: '-',
chainId: 1,
sellAmount: '',
showPriceInverted: false,
})
})
})
Expand All @@ -41,8 +42,9 @@ describe('orderplacement reducer', () => {

expect(store.getState()).toEqual({
price: '1',
auctionId: 1,
chainId: 1,
sellAmount: '2',
showPriceInverted: false,
})
})
})
Expand All @@ -57,8 +59,9 @@ describe('orderplacement reducer', () => {

expect(store.getState()).toEqual({
price: '2',
auctionId: 1,
chainId: 1,
sellAmount: '',
showPriceInverted: false,
})
})
})
Expand Down
28 changes: 1 addition & 27 deletions src/utils/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { JSBI, Percent, Token, TokenAmount } from 'uniswap-xdai-sdk'
import { JSBI, Percent } from 'uniswap-xdai-sdk'

import { BigNumber } from '@ethersproject/bignumber'
import { AddressZero } from '@ethersproject/constants'

import {
ChainId,
basisPointsToPercent,
calculateGasMargin,
calculateSlippageAmount,
getExplorerLink,
isAddress,
shortenAddress,
Expand All @@ -31,30 +29,6 @@ describe('utils', () => {
})
})

describe('#calculateSlippageAmount', () => {
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, 10001)).toThrow()
})
})

describe('#isAddress', () => {
it('returns false if not', () => {
expect(isAddress('')).toBe(false)
Expand Down
13 changes: 12 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { JsonRpcSigner, Provider, Web3Provider } from '@ethersproject/providers'
import { parseBytes32String } from '@ethersproject/strings'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'

import { EASY_AUCTION_NETWORKS } from '../constants'
import easyAuctionABI from '../constants/abis/easyAuction/easyAuction.json'
import ERC20_ABI from '../constants/abis/erc20.json'
import ERC20_BYTES32_ABI from '../constants/abis/erc20_bytes32.json'
Expand All @@ -31,6 +30,18 @@ export enum ChainId {
XDAI = 100,
}

export const EASY_AUCTION_NETWORKS: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
[ChainId.RINKEBY]: '0xC5992c0e0A3267C7F75493D0F717201E26BE35f7',
[ChainId.XDAI]: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
}

export const DEPOSIT_AND_PLACE_ORDER: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: '0x10D15DEA67f7C95e2F9Fe4eCC245a8862b9B5B96',
[ChainId.RINKEBY]: '0x8624fbDf455D51B967ff40aaB4019281A855f008',
[ChainId.XDAI]: '0x845AbED0734e39614FEC4245F3F3C88E2da98157',
}

const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {
1: '',
4: 'rinkeby.',
Expand Down