move second passsword modal out of udapp logic

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent 17fcf93094
commit 8a4dc66dde
  1. 8
      src/app/tabs/run-tab.js
  2. 6
      src/recorder.js
  3. 9
      src/universal-dapp-ui.js
  4. 17
      src/universal-dapp.js

@ -474,6 +474,9 @@ function contractDropdown (events, self) {
continueTxExecution() continueTxExecution()
} }
}, },
function (okCb, cancelCb) {
modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb)
},
(error, txResult) => { (error, txResult) => {
if (!error) { if (!error) {
var isVM = executionContext.isVM() var isVM = executionContext.isVM()
@ -521,7 +524,6 @@ function contractDropdown (events, self) {
}, (data, runTxCallback) => { }, (data, runTxCallback) => {
// called for libraries deployment // called for libraries deployment
self._deps.udapp.runTx(data, self._deps.udapp.runTx(data,
(network, tx, gasEstimation, continueTxExecution, cancelCb) => { (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
if (network.name !== 'Main') { if (network.name !== 'Main') {
return continueTxExecution(null) 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) runTxCallback)
}) })
} else { } else {

@ -9,8 +9,9 @@ var typeConversion = remixLib.execution.typeConversion
var async = require('async') var async = require('async')
var modal = require('./app/ui/modal-dialog-custom') var modal = require('./app/ui/modal-dialog-custom')
var modalDialog = require('./app/ui/modaldialog')
var confirmDialog = require('./app/execution/confirmDialog') 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. * Record transaction as long as the user create them.
@ -319,6 +320,9 @@ class Recorder {
continueTxExecution() continueTxExecution()
} }
}, },
function (okCb, cancelCb) {
modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb)
},
function (err, txResult) { function (err, txResult) {
if (err) { if (err) {
console.error(err) console.error(err)

@ -16,8 +16,9 @@ var txFormat = remixLib.execution.txFormat
var executionContext = require('./execution-context') var executionContext = require('./execution-context')
var modalDialog = require('./app/ui/modaldialog')
var confirmDialog = require('./app/execution/confirmDialog') 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') var TreeView = require('./app/ui/TreeView')
function UniversalDAppUI (udapp, opts = {}) { function UniversalDAppUI (udapp, opts = {}) {
@ -208,6 +209,10 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
outputOverride.appendChild(decoded) 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 // 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) => { txFormat.buildData(args.contractName, args.contractAbi, self.udapp.data.contractsDetails, false, args.funABI, args.funABI.type !== 'fallback' ? value : '', (error, data) => {
if (!error) { if (!error) {
@ -217,7 +222,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
self.udapp._deps.logCallback(`${logMsg}`) self.udapp._deps.logCallback(`${logMsg}`)
} }
if (args.funABI.type === 'fallback') data.dataHex = value 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) { if (!error) {
var isVM = executionContext.isVM() var isVM = executionContext.isVM()
if (isVM) { if (isVM) {

@ -13,8 +13,6 @@ var txHelper = remixLib.execution.txHelper
var executionContext = require('./execution-context') var executionContext = require('./execution-context')
var globalRegistry = require('./global/registry') var globalRegistry = require('./global/registry')
var modalCustom = require('./app/ui/modal-dialog-custom')
function UniversalDApp () { function UniversalDApp () {
this.event = new EventManager() this.event = new EventManager()
var self = this 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 {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Function} callback - callback. * @param {Function} callback - callback.
*/ */
UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, callback) { UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, promptCb, callback) {
this.runTx({data: data, useCall: false}, confirmationCb, continueCb, (error, txResult) => { 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) // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult) 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 {Object} funAbi - abi definition of the function to call.
* @param {Function} callback - callback. * @param {Function} callback - callback.
*/ */
UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, callback) { UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, promptCb, callback) {
this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, (error, txResult) => { 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) // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult) callback(error, txResult)
}) })
@ -242,7 +240,7 @@ UniversalDApp.prototype.silentRunTx = function (tx, cb) {
cb) cb)
} }
UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, cb) { UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, promptCb, cb) {
const self = this const self = this
async.waterfall([ async.waterfall([
function getGasLimit (next) { function getGasLimit (next) {
@ -288,10 +286,7 @@ UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, cb)
var timestamp = Date.now() var timestamp = Date.now()
self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
self.txRunner.rawRun(tx, confirmationCb, continueCb, self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb,
function (okCb, cancelCb) {
modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account ' + tx.from, '', okCb, cancelCb)
},
function (error, result) { function (error, result) {
let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted') let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted')
self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad]) self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])

Loading…
Cancel
Save