Standard JS fixes

pull/3094/head
ninabreznik 7 years ago
parent f81e02cfb3
commit 200fe68bbb
  1. 70
      src/app/execution/txRunner.js
  2. 4
      src/app/tabs/settings-tab.js

@ -60,21 +60,28 @@ TxRunner.prototype.execute = function (args, callback) {
data: data, data: data,
value: value value: value
} }
if (args.useCall) { if (args.useCall) {
function execute () {
executionContext.web3().eth.call(tx, function (error, result) {
callback(error, {
result: result,
transactionHash: result.transactionHash
})
})
}
tx.gas = gasLimit tx.gas = gasLimit
if (!self.config.get('doNotShowAgain')) { if (!self.config.get('doNotShowAgain')) {
self.detectNetwork((err,network) => { self.detectNetwork((err, network) => {
if (err) { if (err) {
console.log(err) console.log(err)
} else { } else {
console.log(network.name)
if (network.name === 'Ropsten') { if (network.name === 'Ropsten') {
modalDialog('Confirm transaction', remixdDialog(tx, self), modalDialog('Confirm transaction', remixdDialog(tx, self),
{ label: 'Confirm', { label: 'Confirm',
fn: () => { fn: () => {
execute() execute()
}}) }})
} else { } else {
execute() execute()
} }
@ -83,16 +90,21 @@ TxRunner.prototype.execute = function (args, callback) {
} else { } else {
execute() execute()
} }
} else {
function execute () { function execute () {
executionContext.web3().eth.call(tx, function (error, result) { var sendTransaction = self.personalMode ? executionContext.web3().personal.sendTransaction : executionContext.web3().eth.sendTransaction
callback(error, { try {
result: result, sendTransaction(tx, function (err, resp) {
transactionHash: result.transactionHash if (err) {
return callback(err, resp)
}
tryTillResponse(resp, callback)
}) })
}) } catch (e) {
return callback(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
}
} }
} else {
executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) { executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) {
if (err) { if (err) {
return callback(err, gasEstimation) return callback(err, gasEstimation)
@ -112,18 +124,16 @@ TxRunner.prototype.execute = function (args, callback) {
tx.gas = gasEstimation tx.gas = gasEstimation
if (!self.config.get('doNotShowAgain')) { if (!self.config.get('doNotShowAgain')) {
self.detectNetwork((err, network) => {
self.detectNetwork((err,network) => {
if (err) { if (err) {
console.log(err) console.log(err)
} else { } else {
console.log(network.name)
if (network.name === 'Ropsten') { if (network.name === 'Ropsten') {
modalDialog('Confirm transaction', remixdDialog(tx, self), modalDialog('Confirm transaction', remixdDialog(tx, self),
{ label: 'Confirm', { label: 'Confirm',
fn: () => { fn: () => {
execute() execute()
}}) }})
} else { } else {
execute() execute()
} }
@ -132,24 +142,8 @@ TxRunner.prototype.execute = function (args, callback) {
} else { } else {
execute() execute()
} }
}) })
function execute () {
var sendTransaction = self.personalMode ? executionContext.web3().personal.sendTransaction : executionContext.web3().eth.sendTransaction
try {
sendTransaction(tx, function (err, resp) {
if (err) {
return callback(err, resp)
}
tryTillResponse(resp, callback)
})
} catch (e) {
return callback(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
}
}
} }
} else { } else {
try { try {
var account = self.vmaccounts[from] var account = self.vmaccounts[from]
@ -253,7 +247,7 @@ function remixdDialog (tx, self) {
function updateConfig (self) { function updateConfig (self) {
self.config.set('doNotShowAgain', !self.config.get('doNotShowAgain')) self.config.set('doNotShowAgain', !self.config.get('doNotShowAgain'))
document.querySelector("#mainNetCheckbox").setAttribute('checked', true) document.querySelector('#askToConfirm').setAttribute('checked', true)
} }
module.exports = TxRunner module.exports = TxRunner

@ -107,7 +107,7 @@ function SettingsTab (container, appAPI, appEvents, opts) {
<span class="${css.checkboxText}">Always use Ethereum VM at Load</span> <span class="${css.checkboxText}">Always use Ethereum VM at Load</span>
</div> </div>
<div class="${css.crow}"> <div class="${css.crow}">
<div><input id="mainNetCheckbox" onchange=${popupWhenMainNetSelected} type="checkbox"></div> <div><input id="askToConfirm" onchange=${askToConfirmTx} type="checkbox"></div>
<span class="${css.checkboxText}">Don't show confirmation popup when MainNet is selected</span> <span class="${css.checkboxText}">Don't show confirmation popup when MainNet is selected</span>
</div> </div>
<div class="${css.crow}"> <div class="${css.crow}">
@ -150,7 +150,7 @@ function SettingsTab (container, appAPI, appEvents, opts) {
</div> </div>
` `
function popupWhenMainNetSelected () { function askToConfirmTx () {
appAPI.config.set('doNotShowAgain', !appAPI.config.get('doNotShowAgain')) appAPI.config.set('doNotShowAgain', !appAPI.config.get('doNotShowAgain'))
} }

Loading…
Cancel
Save