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:
parent
c5a273eac4
commit
99e541d08b
@ -70,10 +70,12 @@ function OceanProvider({
|
|||||||
|
|
||||||
async function connect(opts?: Partial<ICoreOptions>) {
|
async function connect(opts?: Partial<ICoreOptions>) {
|
||||||
Logger.log('Connecting ....')
|
Logger.log('Connecting ....')
|
||||||
|
|
||||||
if (opts === undefined) {
|
if (opts === undefined) {
|
||||||
opts = await getDefaultProviders()
|
opts = await getDefaultProviders()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setWeb3ModalOpts(opts)
|
||||||
const instance = new Web3Modal(opts)
|
const instance = new Web3Modal(opts)
|
||||||
setWeb3Modal(instance)
|
setWeb3Modal(instance)
|
||||||
Logger.log('Web3Modal instance created.', instance)
|
Logger.log('Web3Modal instance created.', instance)
|
||||||
@ -83,6 +85,7 @@ function OceanProvider({
|
|||||||
|
|
||||||
const web3 = new Web3(provider)
|
const web3 = new Web3(provider)
|
||||||
setWeb3(web3)
|
setWeb3(web3)
|
||||||
|
Logger.log('Web3 created.', web3)
|
||||||
|
|
||||||
const chainId = web3 && (await web3.eth.getChainId())
|
const chainId = web3 && (await web3.eth.getChainId())
|
||||||
setChainId(chainId)
|
setChainId(chainId)
|
||||||
@ -90,10 +93,9 @@ function OceanProvider({
|
|||||||
|
|
||||||
config.web3Provider = web3
|
config.web3Provider = web3
|
||||||
const ocean = await Ocean.getInstance(config)
|
const ocean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
setOcean(ocean)
|
setOcean(ocean)
|
||||||
Logger.log('Ocean instance created.', ocean)
|
Logger.log('Ocean instance created.', ocean)
|
||||||
Logger.log('Web3 created.', web3)
|
|
||||||
setStatus(ProviderStatus.CONNECTED)
|
setStatus(ProviderStatus.CONNECTED)
|
||||||
|
|
||||||
const account = (await ocean.accounts.list())[0]
|
const account = (await ocean.accounts.list())[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user