mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
add networkId
This commit is contained in:
parent
dc8831d78c
commit
1576bd3e90
@ -29,6 +29,7 @@ interface OceanProviderValue {
|
|||||||
accountId: string
|
accountId: string
|
||||||
balance: Balance
|
balance: Balance
|
||||||
chainId: number | undefined
|
chainId: number | undefined
|
||||||
|
networkId: number | undefined
|
||||||
status: ProviderStatus
|
status: ProviderStatus
|
||||||
connect: (config?: Config) => Promise<void>
|
connect: (config?: Config) => Promise<void>
|
||||||
logout: () => Promise<void>
|
logout: () => Promise<void>
|
||||||
@ -51,6 +52,7 @@ function OceanProvider({
|
|||||||
const [ocean, setOcean] = useState<Ocean | undefined>()
|
const [ocean, setOcean] = useState<Ocean | undefined>()
|
||||||
const [web3Modal, setWeb3Modal] = useState<Web3Modal>()
|
const [web3Modal, setWeb3Modal] = useState<Web3Modal>()
|
||||||
const [chainId, setChainId] = useState<number | undefined>()
|
const [chainId, setChainId] = useState<number | undefined>()
|
||||||
|
const [networkId, setNetworkId] = useState<number | undefined>()
|
||||||
const [account, setAccount] = useState<Account | undefined>()
|
const [account, setAccount] = useState<Account | undefined>()
|
||||||
const [accountId, setAccountId] = useState<string | undefined>()
|
const [accountId, setAccountId] = useState<string | undefined>()
|
||||||
const [config, setConfig] = useState<Config>(initialConfig)
|
const [config, setConfig] = useState<Config>(initialConfig)
|
||||||
@ -95,6 +97,10 @@ function OceanProvider({
|
|||||||
setChainId(chainId)
|
setChainId(chainId)
|
||||||
Logger.log('chain id ', chainId)
|
Logger.log('chain id ', chainId)
|
||||||
|
|
||||||
|
const networkId = web3 && (await web3.eth.net.getId())
|
||||||
|
setNetworkId(networkId)
|
||||||
|
Logger.log('network id ', networkId)
|
||||||
|
|
||||||
config.web3Provider = web3
|
config.web3Provider = web3
|
||||||
const ocean = await Ocean.getInstance(config)
|
const ocean = await Ocean.getInstance(config)
|
||||||
setOcean(ocean)
|
setOcean(ocean)
|
||||||
@ -172,6 +178,7 @@ function OceanProvider({
|
|||||||
accountId,
|
accountId,
|
||||||
balance,
|
balance,
|
||||||
chainId,
|
chainId,
|
||||||
|
networkId,
|
||||||
status,
|
status,
|
||||||
config,
|
config,
|
||||||
connect,
|
connect,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user