Skip to content

Commit 1fe2660

Browse files
add better testnet support (Uniswap#446)
* add rinkeby support * add client-side routing link
1 parent 1349085 commit 1fe2660

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Rename `.env.local.example` to `.env.local` and fill in the appropriate variable
3232
yarn start
3333
```
3434

35-
To run on a testnet, simply update the `.env.local` file appropriately.
35+
To run on a testnet, make a copy of `.env.local.example` named `.env.local`, change `REACT_APP_NETWORK_ID` to `"{yourNetworkId}"`, and change `REACT_APP_NETWORK_URL` to e.g. `"https://{yourNetwork}.infura.io/v3/{yourKey}"`.
36+
37+
If deploying with Github Pages, be aware that there's some [tricky client-side routing behavior with `create-react-app`](https://create-react-app.dev/docs/deployment#notes-on-client-side-routing).
3638

3739
## Contributions
3840

src/NetworkOnlyConnector.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ import { Connectors } from 'web3-react'
44
const { Connector } = Connectors
55

66
function getFallbackProvider(providerURL) {
7-
const etherscan = new ethers.providers.EtherscanProvider()
8-
const infura = new ethers.providers.JsonRpcProvider(providerURL)
7+
if (Number(process.env.REACT_APP_NETWORK_ID) === 1) {
8+
const etherscan = new ethers.providers.EtherscanProvider()
9+
const infura = new ethers.providers.JsonRpcProvider(providerURL)
910

10-
const providers = [infura, etherscan]
11+
const providers = [infura, etherscan]
1112

12-
return new ethers.providers.FallbackProvider(providers)
13+
return new ethers.providers.FallbackProvider(providers)
14+
} else {
15+
const infura = new ethers.providers.JsonRpcProvider(providerURL)
16+
17+
const providers = [infura]
18+
19+
return new ethers.providers.FallbackProvider(providers)
20+
}
1321
}
1422

1523
export default class NetworkOnlyConnector extends Connector {

src/components/TokenLogo/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const Image = styled.img`
1515
`
1616

1717
const Emoji = styled.span`
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
1821
width: ${({ size }) => size};
1922
height: ${({ size }) => size};
2023
`

src/contexts/Application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function Updater() {
8282

8383
// update usd price
8484
useEffect(() => {
85-
if (library) {
85+
if (library && networkId === 1) {
8686
let stale = false
8787

8888
getUSDPrice(library)

src/contexts/Tokens.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ const INITIAL_TOKENS_CONTEXT = {
395395
[DECIMALS]: 18,
396396
[EXCHANGE_ADDRESS]: '0xaE76c84C9262Cdb9abc0C2c8888e62Db8E22A0bF'
397397
}
398+
},
399+
4: {
400+
'0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa': {
401+
[NAME]: 'Dai',
402+
[SYMBOL]: 'DAI',
403+
[DECIMALS]: 18,
404+
[EXCHANGE_ADDRESS]: '0xaF51BaAA766b65E8B3Ee0C2c33186325ED01eBD5'
405+
}
398406
}
399407
}
400408

0 commit comments

Comments
 (0)