mirror of
https://github.com/oceanprotocol/react.git
synced 2024-11-26 20:39:02 +01:00
config fix
This commit is contained in:
parent
891b1e1f4f
commit
4a7604b4f9
@ -5,7 +5,7 @@ import { useState } from 'react'
|
||||
import { useEffect } from 'react'
|
||||
import shortid from 'shortid'
|
||||
export function AllDdos() {
|
||||
const { accountId, account, ocean } = useOcean()
|
||||
const { accountId,chainId, account, ocean } = useOcean()
|
||||
|
||||
const [ddos, setDdos] = useState<DDO[] | undefined>()
|
||||
|
||||
@ -23,7 +23,7 @@ export function AllDdos() {
|
||||
setDdos(assets.results)
|
||||
}
|
||||
init()
|
||||
}, [ocean, account])
|
||||
}, [ocean, account,chainId])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -6,9 +6,20 @@ import { useEffect } from 'react'
|
||||
export function NetworkMonitor() {
|
||||
const { connect, web3Provider } = useOcean()
|
||||
|
||||
const handleNetworkChanged = () => {
|
||||
const handleNetworkChanged = (chainId: number) => {
|
||||
// const config = getOceanConfig(chainId)
|
||||
const config = new ConfigHelper().getConfig('rinkeby')
|
||||
// temp hack
|
||||
let network = ''
|
||||
switch (chainId) {
|
||||
case 1:
|
||||
{
|
||||
network = 'mainnet'
|
||||
}
|
||||
case 4: {
|
||||
network = 'rinkeby'
|
||||
}
|
||||
}
|
||||
const config = new ConfigHelper().getConfig(network)
|
||||
connect(config)
|
||||
}
|
||||
useEffect(() => {
|
||||
|
@ -28,7 +28,7 @@ interface OceanProviderValue {
|
||||
balance: Balance
|
||||
chainId: number | undefined
|
||||
status: ProviderStatus
|
||||
connect: (config: Config) => Promise<void>
|
||||
connect: (config?: Config) => Promise<void>
|
||||
logout: () => Promise<void>
|
||||
refreshBalance: () => Promise<void>
|
||||
}
|
||||
@ -88,7 +88,7 @@ function OceanProvider({
|
||||
|
||||
async function connect(newConfig?: Config) {
|
||||
try {
|
||||
Logger.log('Connecting ...')
|
||||
Logger.log('Connecting ...',newConfig)
|
||||
|
||||
newConfig && setConfig(newConfig)
|
||||
|
||||
@ -103,8 +103,8 @@ function OceanProvider({
|
||||
setChainId(chainId)
|
||||
Logger.log('chain id ', chainId)
|
||||
|
||||
newConfig.web3Provider = web3
|
||||
const ocean = await Ocean.getInstance(newConfig)
|
||||
config.web3Provider = web3
|
||||
const ocean = await Ocean.getInstance(config)
|
||||
setOcean(ocean)
|
||||
Logger.log('Ocean instance created.', ocean)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user