From 1576bd3e90cfd4e5a38867451bf48f00e6ba306d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 2 Oct 2020 12:45:51 +0200 Subject: [PATCH] add networkId --- src/providers/OceanProvider/OceanProvider.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/providers/OceanProvider/OceanProvider.tsx b/src/providers/OceanProvider/OceanProvider.tsx index d64ed9d..90181a5 100644 --- a/src/providers/OceanProvider/OceanProvider.tsx +++ b/src/providers/OceanProvider/OceanProvider.tsx @@ -29,6 +29,7 @@ interface OceanProviderValue { accountId: string balance: Balance chainId: number | undefined + networkId: number | undefined status: ProviderStatus connect: (config?: Config) => Promise logout: () => Promise @@ -51,6 +52,7 @@ function OceanProvider({ const [ocean, setOcean] = useState() const [web3Modal, setWeb3Modal] = useState() const [chainId, setChainId] = useState() + const [networkId, setNetworkId] = useState() const [account, setAccount] = useState() const [accountId, setAccountId] = useState() const [config, setConfig] = useState(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,