diff --git a/src/app/execution/txRunner.js b/src/app/execution/txRunner.js index 51b8fbddb0..d5f3b2009b 100644 --- a/src/app/execution/txRunner.js +++ b/src/app/execution/txRunner.js @@ -46,46 +46,52 @@ TxRunner.prototype.execute = function (args, callback) { } if (args.useCall) { tx.gas = gasLimit - executionContext.web3().eth.call(tx, function (error, result) { - callback(error, { - result: result, - transactionHash: result.transactionHash - }) - }) - askToConfirmTx(tx) + modalDialog('Confirm transaction', remixdDialog(tx), + { label: 'Confirm', + fn: () => { + executionContext.web3().eth.call(tx, function (error, result) { + callback(error, { + result: result, + transactionHash: result.transactionHash + }) + }) + }}) } else { - 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 + 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 - 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 - 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. `) - } - }) + tx.gas = gasEstimation + 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. `) + } + }) + }}) } - askToConfirmTx(tx) } else { try { var account = self.vmaccounts[from] @@ -168,27 +174,24 @@ function run (self, tx, stamp, callback) { } } -function askToConfirmTx (tx) { -var title = `Executing transaction on the main network` - var el = yo` + +function remixdDialog (tx) { + return yo` +
+
You are trying to execute transaction on the main network. Please, click confirm to continue!
-
- You are connected to the main network, which means your transaction will - be performed using real currency. Check out the details of the transaction you want - to run and click confirm if you are sure you want to continue with its - exectution on the main network. -
-
from: ${tx.from}
to: ${tx.from}
tx value: ${tx.value}
gas limit: ${tx.gasLimit}
gas price: ${tx.gasEstimation}
data: ${tx.data}
-
+
` - modalDialog(title, el, {label: ''}, {label: 'Confirm'}) // PROMPT! + } + + module.exports = TxRunner