mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +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 { useEffect } from 'react'
|
||||||
import shortid from 'shortid'
|
import shortid from 'shortid'
|
||||||
export function AllDdos() {
|
export function AllDdos() {
|
||||||
const { accountId, account, ocean } = useOcean()
|
const { accountId,chainId, account, ocean } = useOcean()
|
||||||
|
|
||||||
const [ddos, setDdos] = useState<DDO[] | undefined>()
|
const [ddos, setDdos] = useState<DDO[] | undefined>()
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ export function AllDdos() {
|
|||||||
setDdos(assets.results)
|
setDdos(assets.results)
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
}, [ocean, account])
|
}, [ocean, account,chainId])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -6,9 +6,20 @@ import { useEffect } from 'react'
|
|||||||
export function NetworkMonitor() {
|
export function NetworkMonitor() {
|
||||||
const { connect, web3Provider } = useOcean()
|
const { connect, web3Provider } = useOcean()
|
||||||
|
|
||||||
const handleNetworkChanged = () => {
|
const handleNetworkChanged = (chainId: number) => {
|
||||||
// const config = getOceanConfig(chainId)
|
// 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)
|
connect(config)
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,7 +28,7 @@ interface OceanProviderValue {
|
|||||||
balance: Balance
|
balance: Balance
|
||||||
chainId: number | undefined
|
chainId: number | undefined
|
||||||
status: ProviderStatus
|
status: ProviderStatus
|
||||||
connect: (config: Config) => Promise<void>
|
connect: (config?: Config) => Promise<void>
|
||||||
logout: () => Promise<void>
|
logout: () => Promise<void>
|
||||||
refreshBalance: () => Promise<void>
|
refreshBalance: () => Promise<void>
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ function OceanProvider({
|
|||||||
|
|
||||||
async function connect(newConfig?: Config) {
|
async function connect(newConfig?: Config) {
|
||||||
try {
|
try {
|
||||||
Logger.log('Connecting ...')
|
Logger.log('Connecting ...',newConfig)
|
||||||
|
|
||||||
newConfig && setConfig(newConfig)
|
newConfig && setConfig(newConfig)
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ function OceanProvider({
|
|||||||
setChainId(chainId)
|
setChainId(chainId)
|
||||||
Logger.log('chain id ', chainId)
|
Logger.log('chain id ', chainId)
|
||||||
|
|
||||||
newConfig.web3Provider = web3
|
config.web3Provider = web3
|
||||||
const ocean = await Ocean.getInstance(newConfig)
|
const ocean = await Ocean.getInstance(config)
|
||||||
setOcean(ocean)
|
setOcean(ocean)
|
||||||
Logger.log('Ocean instance created.', ocean)
|
Logger.log('Ocean instance created.', ocean)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user