Commit 0c7e1844 authored by ninabreznik's avatar ninabreznik

Ask To Confirm Transaction - first draft

parent defb1c8f
...@@ -46,14 +46,20 @@ TxRunner.prototype.execute = function (args, callback) { ...@@ -46,14 +46,20 @@ TxRunner.prototype.execute = function (args, callback) {
} }
if (args.useCall) { if (args.useCall) {
tx.gas = gasLimit tx.gas = gasLimit
modalDialog('Confirm transaction', remixdDialog(tx),
{ label: 'Confirm',
fn: () => {
executionContext.web3().eth.call(tx, function (error, result) { executionContext.web3().eth.call(tx, function (error, result) {
callback(error, { callback(error, {
result: result, result: result,
transactionHash: result.transactionHash transactionHash: result.transactionHash
}) })
}) })
askToConfirmTx(tx) }})
} else { } else {
modalDialog('Confirm transaction', remixdDialog(tx),
{ label: 'Confirm',
fn: () => {
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)
...@@ -84,8 +90,8 @@ TxRunner.prototype.execute = function (args, callback) { ...@@ -84,8 +90,8 @@ TxRunner.prototype.execute = function (args, callback) {
return callback(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `) return callback(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
} }
}) })
}})
} }
askToConfirmTx(tx)
} else { } else {
try { try {
var account = self.vmaccounts[from] var account = self.vmaccounts[from]
...@@ -168,16 +174,11 @@ function run (self, tx, stamp, callback) { ...@@ -168,16 +174,11 @@ function run (self, tx, stamp, callback) {
} }
} }
function askToConfirmTx (tx) {
var title = `Executing transaction on the main network` function remixdDialog (tx) {
var el = yo` return yo`
<div>
<div> <div>
You are connected to the main network, which means your transaction will <div>You are trying to execute transaction on the main network. Please, click confirm to continue!</div>
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.
</div>
<div> <div>
<div>from: ${tx.from}</div> <div>from: ${tx.from}</div>
<div>to: ${tx.from}</div> <div>to: ${tx.from}</div>
...@@ -188,7 +189,9 @@ var title = `Executing transaction on the main network` ...@@ -188,7 +189,9 @@ var title = `Executing transaction on the main network`
</div> </div>
</div> </div>
` `
modalDialog(title, el, {label: ''}, {label: 'Confirm'}) // PROMPT!
} }
module.exports = TxRunner module.exports = TxRunner
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment