Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions apps/remix-ide/src/app/tabs/runTab/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,33 @@ 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) => {
if (this.accountListCallId > callid) return
this.accountListCallId++
if (err) { addTooltip(`Cannot get account list: ${err}`) }
for (var loadedaddress in this.loadedAccounts) {
if (accounts.indexOf(loadedaddress) === -1) {
txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]'))
delete this.loadedAccounts[loadedaddress]
}
const callid = this.accountListCallId
const txOrigin = this.el.querySelector('#txorigin')
let accounts = []
try {
accounts = await this.blockchain.getAccounts()
} catch (e) {
addTooltip(`Cannot get account list: ${e}`)
}
if (!accounts) accounts = []
if (this.accountListCallId > callid) return
this.accountListCallId++
for (var loadedaddress in this.loadedAccounts) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadedaddress can be let

if (accounts.indexOf(loadedaddress) === -1) {
txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]'))
delete this.loadedAccounts[loadedaddress]
}
for (var i in accounts) {
var address = accounts[i]
if (!this.loadedAccounts[address]) {
txOrigin.appendChild(yo`<option value="${address}" >${address}</option>`)
this.loadedAccounts[address] = 1
}
}
for (var i in accounts) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can be let

const address = accounts[i]
if (!this.loadedAccounts[address]) {
txOrigin.appendChild(yo`<option value="${address}" >${address}</option>`)
this.loadedAccounts[address] = 1
}
txOrigin.setAttribute('value', accounts[0])
})
}
txOrigin.setAttribute('value', accounts[0])
}
}

Expand Down