mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
temporary ddo.chainId typing
This commit is contained in:
parent
064bb2fd69
commit
8ac4f59dee
@ -7,7 +7,13 @@ import React, {
|
|||||||
ReactNode,
|
ReactNode,
|
||||||
useEffect
|
useEffect
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import { Ocean, Logger, Account, ConfigHelperConfig } from '@oceanprotocol/lib'
|
import {
|
||||||
|
Ocean,
|
||||||
|
Logger,
|
||||||
|
Account,
|
||||||
|
ConfigHelperConfig,
|
||||||
|
DDO
|
||||||
|
} from '@oceanprotocol/lib'
|
||||||
|
|
||||||
import { useWeb3 } from './Web3'
|
import { useWeb3 } from './Web3'
|
||||||
import { getDevelopmentConfig, getOceanConfig } from '../utils/ocean'
|
import { getDevelopmentConfig, getOceanConfig } from '../utils/ocean'
|
||||||
@ -22,6 +28,11 @@ interface OceanProviderValue {
|
|||||||
|
|
||||||
const OceanContext = createContext({} as OceanProviderValue)
|
const OceanContext = createContext({} as OceanProviderValue)
|
||||||
|
|
||||||
|
// TODO: remove temporary typing once ddo.chainId is present in ocean.js
|
||||||
|
interface DDO_TEMPORARY extends DDO {
|
||||||
|
chainId: number
|
||||||
|
}
|
||||||
|
|
||||||
function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
||||||
const { web3, accountId } = useWeb3()
|
const { web3, accountId } = useWeb3()
|
||||||
const { ddo } = useAsset()
|
const { ddo } = useAsset()
|
||||||
@ -62,10 +73,10 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
|||||||
// if (!ddo?.chainId) return
|
// if (!ddo?.chainId) return
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
...getOceanConfig(ddo?.chainId || 1),
|
...getOceanConfig((ddo as DDO_TEMPORARY)?.chainId || 1),
|
||||||
|
|
||||||
// add local dev values
|
// add local dev values
|
||||||
...(ddo?.chainId === 8996 && {
|
...((ddo as DDO_TEMPORARY)?.chainId === 8996 && {
|
||||||
...getDevelopmentConfig()
|
...getDevelopmentConfig()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -74,7 +85,7 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
|||||||
await connect(config)
|
await connect(config)
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
}, [connect, ddo?.chainId])
|
}, [connect, ddo])
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Get user info, handle account change from web3
|
// Get user info, handle account change from web3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user