Refactor web3 provider enable() call

This commit is contained in:
Germán Martínez 2019-09-23 12:26:21 +02:00
parent f8ba0c6217
commit 0971e4a929
1 changed files with 8 additions and 1 deletions

View File

@ -76,7 +76,14 @@ export const getProviderInfo: Function = async (): Promise<ProviderProps> => {
if (window.ethereum) { if (window.ethereum) {
web3Provider = window.ethereum web3Provider = window.ethereum
await web3Provider.enable() try {
const accounts = await web3Provider.enable()
if (!accounts) {
console.error('Empty web3 provider')
}
} catch (error) {
console.error('Error when enabling web3 provider', error)
}
} else if (window.web3) { } else if (window.web3) {
web3Provider = window.web3.currentProvider web3Provider = window.web3.currentProvider
} else { } else {