Unlock account before sending transactions

This commit is contained in:
Lyubomir Kiprov 2019-05-20 13:16:46 +03:00
parent 6b704dc1a8
commit cde543bcc9
1 changed files with 4 additions and 2 deletions

View File

@ -4,8 +4,10 @@ import EmbarkJS from '../../../../embarkArtifacts/embarkjs'
const getAccount = async () => {
try {
const account = (await EmbarkJS.Blockchain.Providers.web3.getAccounts())[0]
return account || (await EmbarkJS.enableEthereum())[0]
const account = (await EmbarkJS.enableEthereum())[0]
return (
account || (await EmbarkJS.Blockchain.Providers.web3.getAccounts())[0]
)
} catch (error) {
throw new Error(
'Could not unlock an account. Consider installing Status on your mobile or Metamask extension',