Skip to content

Commit

Permalink
chore: update examples with the latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
aboutlo committed Mar 22, 2021
1 parent ce904a6 commit d9a6b07
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/helloworld/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react'
import { Web3ReactProvider, useWeb3React } from '@web3-react/core'
import { Web3Provider } from '@ethersproject/providers'
import {
ExternalProvider,
JsonRpcFetchFunc,
Web3Provider
} from '@ethersproject/providers'
import { InjectedConnector } from '@web3-react/injected-connector'
import { BigNumber } from 'ethers'
import { Zero } from '@ethersproject/constants'
import { formatEther, formatUnits } from '@ethersproject/units'
import useEtherSWR, { EthSWRConfig } from 'ether-swr'
import useEtherSWR, { EtherSWRConfig } from 'ether-swr'
import ERC20ABI from './ERC20.abi.json'
import useEtherSWR from 'ether-swr/esm'

export const Networks = {
MainNet: 1,
Expand Down Expand Up @@ -79,7 +82,9 @@ export const injectedConnector = new InjectedConnector({
]
})

function getLibrary(provider: any): Web3Provider {
function getLibrary(
provider: ExternalProvider | JsonRpcFetchFunc
): Web3Provider {
const library = new Web3Provider(provider)
library.pollingInterval = 12000
return library
Expand Down Expand Up @@ -211,7 +216,7 @@ export const Wallet = () => {
</button>
)}
{active && chainId && (
<EthSWRConfig
<EtherSWRConfig
value={{
provider: library,
ABIs: new Map(ABIs(chainId)),
Expand All @@ -220,7 +225,7 @@ export const Wallet = () => {
>
<EthBalance />
<TokenList chainId={chainId} />
</EthSWRConfig>
</EtherSWRConfig>
)}
</div>
)
Expand Down

0 comments on commit d9a6b07

Please sign in to comment.