From 8b366aaaccede1fb402e867321325ab4a08be418 Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Fri, 12 Jan 2018 06:25:59 +0800 Subject: [PATCH] Standard JS fixes --- src/app/execution/txRunner.js | 70 ++++++++++++++++------------------- src/app/tabs/settings-tab.js | 4 +- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/app/execution/txRunner.js b/src/app/execution/txRunner.js index 99d1d3a289..52753dbbdb 100644 --- a/src/app/execution/txRunner.js +++ b/src/app/execution/txRunner.js @@ -60,21 +60,28 @@ 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) => { + 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', - fn: () => { - execute() - }}) + { label: 'Confirm', + fn: () => { + execute() + }}) } else { execute() } @@ -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,18 +124,16 @@ TxRunner.prototype.execute = function (args, callback) { tx.gas = gasEstimation if (!self.config.get('doNotShowAgain')) { - - self.detectNetwork((err,network) => { + 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', - fn: () => { - execute() - }}) + { label: 'Confirm', + fn: () => { + execute() + }}) } else { execute() } @@ -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 diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index d1820c1ae1..52ef578c38 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -107,7 +107,7 @@ function SettingsTab (container, appAPI, appEvents, opts) { Always use Ethereum VM at Load
-
+
Don't show confirmation popup when MainNet is selected
@@ -150,7 +150,7 @@ function SettingsTab (container, appAPI, appEvents, opts) {
` - function popupWhenMainNetSelected () { + function askToConfirmTx () { appAPI.config.set('doNotShowAgain', !appAPI.config.get('doNotShowAgain')) }