From 101feb4eb7ea25804c8e8f0d965741e51b39ad29 Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 6 Apr 2021 11:13:49 +0200 Subject: [PATCH] JS error catched for getAccounts --- apps/remix-ide/src/app/tabs/runTab/settings.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/runTab/settings.js b/apps/remix-ide/src/app/tabs/runTab/settings.js index d03e58f6ea..dd94ff9727 100644 --- a/apps/remix-ide/src/app/tabs/runTab/settings.js +++ b/apps/remix-ide/src/app/tabs/runTab/settings.js @@ -390,14 +390,15 @@ class SettingsUI { } // TODO: unclear what's the goal of accountListCallId, feels like it can be simplified - fillAccountsList () { + async fillAccountsList () { this.accountListCallId++ - var callid = this.accountListCallId - var txOrigin = this.el.querySelector('#txorigin') - this.blockchain.getAccounts((err, accounts) => { + const callid = this.accountListCallId + const txOrigin = this.el.querySelector('#txorigin') + try { + let accounts = await this.blockchain.getAccounts() if (this.accountListCallId > callid) return this.accountListCallId++ - if (err) { addTooltip(`Cannot get account list: ${err}`) } + if (!accounts) accounts = [] for (var loadedaddress in this.loadedAccounts) { if (accounts.indexOf(loadedaddress) === -1) { txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]')) @@ -405,14 +406,16 @@ class SettingsUI { } } for (var i in accounts) { - var address = accounts[i] + const address = accounts[i] if (!this.loadedAccounts[address]) { txOrigin.appendChild(yo``) this.loadedAccounts[address] = 1 } } txOrigin.setAttribute('value', accounts[0]) - }) + } catch (e) { + addTooltip(`Cannot get account list: ${e}`) + } } }