Standard JS fixes

pull/1/head
ninabreznik 7 years ago
parent dcc3ee9e9a
commit 8b366aaacc
  1. 50
      src/app/execution/txRunner.js
  2. 4
      src/app/tabs/settings-tab.js

@ -60,15 +60,22 @@ TxRunner.prototype.execute = function (args, callback) {
data: data,
value: value
}
if (args.useCall) {
function execute () {
executionContext.web3().eth.call(tx, function (error, result) {
callback(error, {
result: result,
transactionHash: result.transactionHash
})
})
}
tx.gas = gasLimit
if (!self.config.get('doNotShowAgain')) {
self.detectNetwork((err, network) => {
if (err) {
console.log(err)
} else {
console.log(network.name)
if (network.name === 'Ropsten') {
modalDialog('Confirm transaction', remixdDialog(tx, self),
{ label: 'Confirm',
@ -83,16 +90,21 @@ TxRunner.prototype.execute = function (args, callback) {
} else {
execute()
}
} else {
function execute () {
executionContext.web3().eth.call(tx, function (error, result) {
callback(error, {
result: result,
transactionHash: result.transactionHash
})
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 {
executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) {
if (err) {
return callback(err, gasEstimation)
@ -112,12 +124,10 @@ TxRunner.prototype.execute = function (args, callback) {
tx.gas = gasEstimation
if (!self.config.get('doNotShowAgain')) {
self.detectNetwork((err, network) => {
if (err) {
console.log(err)
} else {
console.log(network.name)
if (network.name === 'Ropsten') {
modalDialog('Confirm transaction', remixdDialog(tx, self),
{ label: 'Confirm',
@ -132,24 +142,8 @@ TxRunner.prototype.execute = function (args, callback) {
} else {
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 {
try {
var account = self.vmaccounts[from]
@ -253,7 +247,7 @@ function remixdDialog (tx, self) {
function updateConfig (self) {
self.config.set('doNotShowAgain', !self.config.get('doNotShowAgain'))
document.querySelector("#mainNetCheckbox").setAttribute('checked', true)
document.querySelector('#askToConfirm').setAttribute('checked', true)
}
module.exports = TxRunner

@ -107,7 +107,7 @@ function SettingsTab (container, appAPI, appEvents, opts) {
<span class="${css.checkboxText}">Always use Ethereum VM at Load</span>
</div>
<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>
</div>
<div class="${css.crow}">
@ -150,7 +150,7 @@ function SettingsTab (container, appAPI, appEvents, opts) {
</div>
`
function popupWhenMainNetSelected () {
function askToConfirmTx () {
appAPI.config.set('doNotShowAgain', !appAPI.config.get('doNotShowAgain'))
}

Loading…
Cancel
Save