1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-23 02:00:27 +01:00

add networkId

This commit is contained in:
Matthias Kretschmann 2020-10-02 12:45:51 +02:00
parent dc8831d78c
commit 1576bd3e90
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -29,6 +29,7 @@ interface OceanProviderValue {
accountId: string
balance: Balance
chainId: number | undefined
networkId: number | undefined
status: ProviderStatus
connect: (config?: Config) => Promise<void>
logout: () => Promise<void>
@ -51,6 +52,7 @@ function OceanProvider({
const [ocean, setOcean] = useState<Ocean | undefined>()
const [web3Modal, setWeb3Modal] = useState<Web3Modal>()
const [chainId, setChainId] = useState<number | undefined>()
const [networkId, setNetworkId] = useState<number | undefined>()
const [account, setAccount] = useState<Account | undefined>()
const [accountId, setAccountId] = useState<string | undefined>()
const [config, setConfig] = useState<Config>(initialConfig)
@ -95,6 +97,10 @@ function OceanProvider({
setChainId(chainId)
Logger.log('chain id ', chainId)
const networkId = web3 && (await web3.eth.net.getId())
setNetworkId(networkId)
Logger.log('network id ', networkId)
config.web3Provider = web3
const ocean = await Ocean.getInstance(config)
setOcean(ocean)
@ -172,6 +178,7 @@ function OceanProvider({
accountId,
balance,
chainId,
networkId,
status,
config,
connect,