mirror of
https://github.com/oceanprotocol/react.git
synced 2024-12-23 01:29:49 +01:00
add networkId
This commit is contained in:
parent
dc8831d78c
commit
1576bd3e90
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user