move second passsword modal out of udapp logic

pull/3094/head
Iuri Matias 6 years ago committed by yann300
parent 13f8f07306
commit 2334ef8d36
  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()
}
},
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 {

@ -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)

@ -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) {

@ -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])

Loading…
Cancel
Save