From 85327645c2a600b8beabbea02324128e1edf6f8b Mon Sep 17 00:00:00 2001 From: ninabreznik Date: Wed, 3 Jan 2018 22:59:39 +0800 Subject: [PATCH] Move modal dialog for Injected Web3 --- src/app/execution/txRunner.js | 43 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/app/execution/txRunner.js b/src/app/execution/txRunner.js index 5a49c0ce8a..3f0312a51a 100644 --- a/src/app/execution/txRunner.js +++ b/src/app/execution/txRunner.js @@ -68,26 +68,26 @@ TxRunner.prototype.execute = function (args, callback) { }) }}) } else { - modalDialog('Confirm transaction', remixdDialog(tx), - { label: 'Confirm', - fn: () => { - executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) { - if (err) { - return callback(err, gasEstimation) - } - var blockGasLimit = executionContext.currentblockGasLimit() - // NOTE: estimateGas very likely will return a large limit if execution of the code failed - // we want to be able to run the code in order to debug and find the cause for the failure + executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) { + if (err) { + return callback(err, gasEstimation) + } + var blockGasLimit = executionContext.currentblockGasLimit() + // NOTE: estimateGas very likely will return a large limit if execution of the code failed + // we want to be able to run the code in order to debug and find the cause for the failure - var warnEstimation = ' An important gas estimation might also be the sign of a problem in the contract code. Please check loops and be sure you did not sent value to a non payable function (that\'s also the reason of strong gas estimation).' - if (gasEstimation > gasLimit) { - return callback('Gas required exceeds limit: ' + gasLimit + '. ' + warnEstimation) - } - if (gasEstimation > blockGasLimit) { - return callback('Gas required exceeds block gas limit: ' + gasLimit + '. ' + warnEstimation) - } + var warnEstimation = ' An important gas estimation might also be the sign of a problem in the contract code. Please check loops and be sure you did not sent value to a non payable function (that\'s also the reason of strong gas estimation).' + if (gasEstimation > gasLimit) { + return callback('Gas required exceeds limit: ' + gasLimit + '. ' + warnEstimation) + } + if (gasEstimation > blockGasLimit) { + return callback('Gas required exceeds block gas limit: ' + gasLimit + '. ' + warnEstimation) + } - tx.gas = gasEstimation + tx.gas = gasEstimation + modalDialog('Confirm transaction', remixdDialog(tx), + { label: 'Confirm', + fn: () => { var sendTransaction = self.personalMode ? executionContext.web3().personal.sendTransaction : executionContext.web3().eth.sendTransaction try { sendTransaction(tx, function (err, resp) { @@ -100,8 +100,8 @@ TxRunner.prototype.execute = function (args, callback) { } catch (e) { return callback(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `) } - }) }}) + }) } } else { try { @@ -188,13 +188,12 @@ function run (self, tx, stamp, callback) { function remixdDialog (tx) { return yo`
-
You are trying to execute transaction on the main network. Please, click confirm to continue!
+
You are trying to execute transaction on the main network. Click confirm if you want to continue!
from: ${tx.from}
to: ${tx.from}
tx value: ${tx.value}
-
gas limit: ${tx.gasLimit}
-
gas price: ${tx.gasEstimation}
+
gas limit: ${tx.gas}
data: ${helper.shortenHexData(tx.data)}