1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-02-14 21:10:38 +01:00

put web3modal options into local state

This commit is contained in:
Matthias Kretschmann 2020-07-20 13:37:34 +02:00
parent c5a273eac4
commit 99e541d08b
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -70,10 +70,12 @@ function OceanProvider({
async function connect(opts?: Partial<ICoreOptions>) {
Logger.log('Connecting ....')
if (opts === undefined) {
opts = await getDefaultProviders()
}
setWeb3ModalOpts(opts)
const instance = new Web3Modal(opts)
setWeb3Modal(instance)
Logger.log('Web3Modal instance created.', instance)
@ -83,6 +85,7 @@ function OceanProvider({
const web3 = new Web3(provider)
setWeb3(web3)
Logger.log('Web3 created.', web3)
const chainId = web3 && (await web3.eth.getChainId())
setChainId(chainId)
@ -90,10 +93,9 @@ function OceanProvider({
config.web3Provider = web3
const ocean = await Ocean.getInstance(config)
setOcean(ocean)
Logger.log('Ocean instance created.', ocean)
Logger.log('Web3 created.', web3)
setStatus(ProviderStatus.CONNECTED)
const account = (await ocean.accounts.list())[0]