mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
parent
19eb296ab2
commit
942b542e8b
@ -75,11 +75,11 @@ function OceanProvider({
|
|||||||
opts = await getDefaultProviders()
|
opts = await getDefaultProviders()
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = new Web3Modal(opts)
|
const instance = web3Modal || new Web3Modal(opts)
|
||||||
setWeb3Modal(instance)
|
setWeb3Modal(instance)
|
||||||
Logger.log('Web3Modal instance created.', instance)
|
Logger.log('Web3Modal instance created.', instance)
|
||||||
|
|
||||||
const provider = await instance.connect()
|
const provider = web3Provider || (await instance.connect())
|
||||||
setWeb3Provider(provider)
|
setWeb3Provider(provider)
|
||||||
|
|
||||||
const web3 = new Web3(provider)
|
const web3 = new Web3(provider)
|
||||||
@ -137,16 +137,8 @@ function OceanProvider({
|
|||||||
|
|
||||||
const handleAccountsChanged = async (accounts: string[]) => {
|
const handleAccountsChanged = async (accounts: string[]) => {
|
||||||
console.debug("Handling 'accountsChanged' event with payload", accounts)
|
console.debug("Handling 'accountsChanged' event with payload", accounts)
|
||||||
if (status === ProviderStatus.CONNECTED) {
|
// if (status === ProviderStatus.CONNECTED) {
|
||||||
connect(web3ModalOpts)
|
connect(web3ModalOpts)
|
||||||
}
|
|
||||||
// if (accounts.length > 0) {
|
|
||||||
// setAccountId(accounts[0])
|
|
||||||
|
|
||||||
// if (web3) {
|
|
||||||
// const balance = await getBalance(web3, accounts[0])
|
|
||||||
// setBalance(balance)
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,9 +149,9 @@ function OceanProvider({
|
|||||||
networkId,
|
networkId,
|
||||||
status
|
status
|
||||||
)
|
)
|
||||||
if (status === ProviderStatus.CONNECTED) {
|
// if (status === ProviderStatus.CONNECTED) {
|
||||||
connect(web3ModalOpts)
|
connect(web3ModalOpts)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user