move passsword modal out of udapp logic

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent d4042d3d93
commit 17fcf93094
  1. 15
      src/app/tabs/run-tab.js
  2. 10
      src/universal-dapp.js

@ -26,6 +26,7 @@ var CompilerAbstract = require('../compiler/compiler-abstract')
var tootip = require('../ui/tooltip') var tootip = require('../ui/tooltip')
var confirmDialog = require('../execution/confirmDialog') var confirmDialog = require('../execution/confirmDialog')
var modalCustom = require('../ui/modal-dialog-custom')
function runTab (opts, localRegistry) { function runTab (opts, localRegistry) {
/* ------------------------- /* -------------------------
@ -814,13 +815,23 @@ function settings (container, self) {
}, 10000) }, 10000)
function newAccount () { function newAccount () {
self._deps.udapp.newAccount('', (error, address) => { self._deps.udapp.newAccount('',
(cb) => {
modalCustom.promptPassphraseCreation((error, passphrase) => {
if (error) {
return modalCustom.alert(error)
}
cb(passphrase)
}, () => {})
},
(error, address) => {
if (!error) { if (!error) {
addTooltip(`account ${address} created`) addTooltip(`account ${address} created`)
} else { } else {
addTooltip('Cannot create an account: ' + error) addTooltip('Cannot create an account: ' + error)
} }
}) }
)
} }
function signMessage (event) { function signMessage (event) {
self._deps.udapp.getAccounts((err, accounts) => { self._deps.udapp.getAccounts((err, accounts) => {

@ -75,18 +75,14 @@ UniversalDApp.prototype.createVMAccount = function (privateKey, balance, cb) {
cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex')) cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
} }
UniversalDApp.prototype.newAccount = function (password, cb) { UniversalDApp.prototype.newAccount = function (password, passwordPromptCb, cb) {
if (!executionContext.isVM()) { if (!executionContext.isVM()) {
if (!this._deps.config.get('settings/personal-mode')) { if (!this._deps.config.get('settings/personal-mode')) {
return cb('Not running in personal mode') return cb('Not running in personal mode')
} }
modalCustom.promptPassphraseCreation((error, passphrase) => { passwordPromptCb((passphrase) => {
if (error) {
modalCustom.alert(error)
} else {
executionContext.web3().personal.newAccount(passphrase, cb) executionContext.web3().personal.newAccount(passphrase, cb)
} })
}, () => {})
} else { } else {
var privateKey var privateKey
do { do {

Loading…
Cancel
Save