From 2334ef8d360ab259dcebc3ce0dd52808858f9d54 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 26 Dec 2018 10:25:29 -0500 Subject: [PATCH] move second passsword modal out of udapp logic --- src/app/tabs/run-tab.js | 8 ++++++-- src/recorder.js | 6 +++++- src/universal-dapp-ui.js | 9 +++++++-- src/universal-dapp.js | 17 ++++++----------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index d865c785d8..ae6129d33d 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -474,6 +474,9 @@ function contractDropdown (events, self) { continueTxExecution() } }, + function (okCb, cancelCb) { + modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) + }, (error, txResult) => { if (!error) { var isVM = executionContext.isVM() @@ -521,7 +524,6 @@ function contractDropdown (events, self) { }, (data, runTxCallback) => { // called for libraries deployment self._deps.udapp.runTx(data, - (network, tx, gasEstimation, continueTxExecution, cancelCb) => { if (network.name !== 'Main') { return continueTxExecution(null) @@ -575,7 +577,9 @@ function contractDropdown (events, self) { } }) }, - + function (okCb, cancelCb) { + modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) + }, runTxCallback) }) } else { diff --git a/src/recorder.js b/src/recorder.js index 28b5ca2ad7..a12bc9fa22 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -9,8 +9,9 @@ var typeConversion = remixLib.execution.typeConversion var async = require('async') var modal = require('./app/ui/modal-dialog-custom') -var modalDialog = require('./app/ui/modaldialog') var confirmDialog = require('./app/execution/confirmDialog') +var modalCustom = require('./app/ui/modal-dialog-custom') +var modalDialog = require('./app/ui/modaldialog') /** * Record transaction as long as the user create them. @@ -319,6 +320,9 @@ class Recorder { continueTxExecution() } }, + function (okCb, cancelCb) { + modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) + }, function (err, txResult) { if (err) { console.error(err) diff --git a/src/universal-dapp-ui.js b/src/universal-dapp-ui.js index 711b1b32bb..a6162057a0 100644 --- a/src/universal-dapp-ui.js +++ b/src/universal-dapp-ui.js @@ -16,8 +16,9 @@ var txFormat = remixLib.execution.txFormat var executionContext = require('./execution-context') -var modalDialog = require('./app/ui/modaldialog') var confirmDialog = require('./app/execution/confirmDialog') +var modalCustom = require('./app/ui/modal-dialog-custom') +var modalDialog = require('./app/ui/modaldialog') var TreeView = require('./app/ui/TreeView') function UniversalDAppUI (udapp, opts = {}) { @@ -208,6 +209,10 @@ UniversalDAppUI.prototype.getCallButton = function (args) { outputOverride.appendChild(decoded) } + var promptCb = (okCb, cancelCb) => { + modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) + } + // contractsDetails is used to resolve libraries txFormat.buildData(args.contractName, args.contractAbi, self.udapp.data.contractsDetails, false, args.funABI, args.funABI.type !== 'fallback' ? value : '', (error, data) => { if (!error) { @@ -217,7 +222,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) { self.udapp._deps.logCallback(`${logMsg}`) } if (args.funABI.type === 'fallback') data.dataHex = value - self.udapp.callFunction(args.address, data, args.funABI, confirmationCb, continueCb, (error, txResult) => { + self.udapp.callFunction(args.address, data, args.funABI, confirmationCb, continueCb, promptCb, (error, txResult) => { if (!error) { var isVM = executionContext.isVM() if (isVM) { diff --git a/src/universal-dapp.js b/src/universal-dapp.js index e917525514..4e1bdd38c2 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -13,8 +13,6 @@ var txHelper = remixLib.execution.txHelper var executionContext = require('./execution-context') var globalRegistry = require('./global/registry') -var modalCustom = require('./app/ui/modal-dialog-custom') - function UniversalDApp () { this.event = new EventManager() var self = this @@ -184,8 +182,8 @@ UniversalDApp.prototype.pendingTransactionsCount = function () { * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ). * @param {Function} callback - callback. */ -UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, callback) { - this.runTx({data: data, useCall: false}, confirmationCb, continueCb, (error, txResult) => { +UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, promptCb, callback) { + this.runTx({data: data, useCall: false}, confirmationCb, continueCb, promptCb, (error, txResult) => { // see universaldapp.js line 660 => 700 to check possible values of txResult (error case) callback(error, txResult) }) @@ -199,8 +197,8 @@ UniversalDApp.prototype.createContract = function (data, confirmationCb, continu * @param {Object} funAbi - abi definition of the function to call. * @param {Function} callback - callback. */ -UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, callback) { - this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, (error, txResult) => { +UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, promptCb, callback) { + this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, promptCb, (error, txResult) => { // see universaldapp.js line 660 => 700 to check possible values of txResult (error case) callback(error, txResult) }) @@ -242,7 +240,7 @@ UniversalDApp.prototype.silentRunTx = function (tx, cb) { cb) } -UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, cb) { +UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, promptCb, cb) { const self = this async.waterfall([ function getGasLimit (next) { @@ -288,10 +286,7 @@ UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, cb) var timestamp = Date.now() self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) - self.txRunner.rawRun(tx, confirmationCb, continueCb, - function (okCb, cancelCb) { - modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account ' + tx.from, '', okCb, cancelCb) - }, + self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, function (error, result) { let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted') self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])