Skip to content

Commit

Permalink
fix: Return false if the web3 connection failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosantangelo committed Feb 2, 2018
1 parent dbb37b7 commit 3aa9b2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ethereum/NodeWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class NodeWallet extends Wallet {

if (!this.account) {
const accounts = await this.getAccounts()
if (accounts.length === 0) {
throw new Error('Could not connect to web3')
}

this.setAccount(accounts[0])
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const eth = {
const { contracts = [], defaultAccount, providerUrl } = options

try {
this.wallet = await this.createWallet(defaultAccount, providerUrl)
this.wallet = await this.connectWallet(defaultAccount, providerUrl)
web3 = this.wallet.getWeb3()

this.setContracts(contracts)
Expand All @@ -49,7 +49,7 @@ export const eth = {
}
},

async createWallet(defaultAccount, providerUrl) {
async connectWallet(defaultAccount, providerUrl) {
let wallet

try {
Expand Down

0 comments on commit 3aa9b2f

Please sign in to comment.