mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
format
This commit is contained in:
parent
69d0b14903
commit
881c4c4ae0
@ -5,31 +5,31 @@ import { useEffect } from 'react'
|
||||
import { getOceanConfig } from './wrapRootElement'
|
||||
|
||||
export function NetworkMonitor() {
|
||||
const { connect, web3Provider } = useOcean()
|
||||
const { connect, web3Provider } = useOcean()
|
||||
|
||||
const handleNetworkChanged = (chainId: number) => {
|
||||
// temp hack
|
||||
let network = ''
|
||||
switch (chainId) {
|
||||
case 1: {
|
||||
network = 'mainnet'
|
||||
}
|
||||
case 4: {
|
||||
network = 'rinkeby'
|
||||
}
|
||||
}
|
||||
const config = getOceanConfig(network)
|
||||
connect(config)
|
||||
const handleNetworkChanged = (chainId: number) => {
|
||||
// temp hack
|
||||
let network = ''
|
||||
switch (chainId) {
|
||||
case 1: {
|
||||
network = 'mainnet'
|
||||
}
|
||||
case 4: {
|
||||
network = 'rinkeby'
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (!web3Provider) return
|
||||
const config = getOceanConfig(network)
|
||||
connect(config)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (!web3Provider) return
|
||||
|
||||
web3Provider.on('chainChanged', handleNetworkChanged)
|
||||
web3Provider.on('chainChanged', handleNetworkChanged)
|
||||
|
||||
return () => {
|
||||
web3Provider.removeListener('chainChanged', handleNetworkChanged)
|
||||
}
|
||||
}, [web3Provider])
|
||||
return () => {
|
||||
web3Provider.removeListener('chainChanged', handleNetworkChanged)
|
||||
}
|
||||
}, [web3Provider])
|
||||
|
||||
return (<></>)
|
||||
return <></>
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export default function wrapRootElement({
|
||||
initialConfig={oceanInitialConfig}
|
||||
web3ModalOpts={web3ModalOpts}
|
||||
>
|
||||
<NetworkMonitor/>
|
||||
<NetworkMonitor />
|
||||
{element}
|
||||
</OceanProvider>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user