Implement seed word confirmation page.

Remove logs.
Move HD render files to ui/app.
feature/default_network_editable
Kevin Serrano 8 years ago
parent 6fc498f8a0
commit 96643c222a
No known key found for this signature in database
GPG Key ID: 7CC862A58D2889B4
  1. 18
      app/scripts/keyring-controller.js
  2. 15
      app/scripts/lib/config-manager.js
  3. 5
      app/scripts/lib/idStore-migrator.js
  4. 1
      app/scripts/metamask-controller.js
  5. 16
      ui/app/actions.js
  6. 7
      ui/app/app.js
  7. 3
      ui/app/keychains/hd/create-vault-complete.js
  8. 0
      ui/app/keychains/hd/recover-seed/confirmation.js
  9. 0
      ui/app/keychains/hd/restore-vault.js

@ -47,6 +47,7 @@ module.exports = class KeyringController extends EventEmitter {
getState() { getState() {
return { return {
seedWords: this.configManager.getSeedWords(),
isInitialized: !!this.configManager.getVault(), isInitialized: !!this.configManager.getVault(),
isUnlocked: !!this.key, isUnlocked: !!this.key,
isConfirmed: true, // AUDIT this.configManager.getConfirmed(), isConfirmed: true, // AUDIT this.configManager.getConfirmed(),
@ -90,10 +91,14 @@ module.exports = class KeyringController extends EventEmitter {
this.configManager.setVault(encryptedString) this.configManager.setVault(encryptedString)
if (!serialized) { if (!serialized) {
// TEMPORARY SINGLE-KEYRING CONFIG: this.addNewKeyring('HD Key Tree', null, (err, newState) => {
return this.addNewKeyring('HD Key Tree', null, (err, newState) => { const firstKeyring = this.keyrings[0]
const firstAccount = this.keyrings[0].getAccounts()[0] const firstAccount = firstKeyring.getAccounts()[0]
autoFaucet(ethUtil.addHexPrefix(firstAccount)) const hexAccount = ethUtil.addHexPrefix(firstAccount)
const seedWords = firstKeyring.serialize().mnemonic
this.configManager.setSelectedAccount(hexAccount)
this.configManager.setSeedWords(seedWords)
autoFaucet(hexAccount)
cb(err, newState) cb(err, newState)
}) })
} else { } else {
@ -470,6 +475,11 @@ module.exports = class KeyringController extends EventEmitter {
return ethUtil.addHexPrefix(result.toString(16)) return ethUtil.addHexPrefix(result.toString(16))
} }
clearSeedWordCache(cb) {
this.configManager.setSeedWords(null)
cb(null, this.configManager.getSelectedAccount())
}
} }
function noop () {} function noop () {}

@ -2,6 +2,7 @@ const Migrator = require('pojo-migrator')
const MetamaskConfig = require('../config.js') const MetamaskConfig = require('../config.js')
const migrations = require('./migrations') const migrations = require('./migrations')
const rp = require('request-promise') const rp = require('request-promise')
const ethUtil = require('ethereumjs-util')
const TESTNET_RPC = MetamaskConfig.network.testnet const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet const MAINNET_RPC = MetamaskConfig.network.mainnet
@ -138,7 +139,7 @@ ConfigManager.prototype.getSelectedAccount = function () {
ConfigManager.prototype.setSelectedAccount = function (address) { ConfigManager.prototype.setSelectedAccount = function (address) {
var config = this.getConfig() var config = this.getConfig()
config.selectedAccount = address config.selectedAccount = ethUtil.addHexPrefix(address)
this.setConfig(config) this.setConfig(config)
} }
@ -153,11 +154,23 @@ ConfigManager.prototype.setShowSeedWords = function (should) {
this.setData(data) this.setData(data)
} }
ConfigManager.prototype.getShouldShowSeedWords = function () { ConfigManager.prototype.getShouldShowSeedWords = function () {
var data = this.migrator.getData() var data = this.migrator.getData()
return data.showSeedWords return data.showSeedWords
} }
ConfigManager.prototype.setSeedWords = function (words) {
var data = this.getData()
data.seedWords = words
this.setData(data)
}
ConfigManager.prototype.getSeedWords = function () {
var data = this.getData()
return ('seedWords' in data) && data.seedWords
}
ConfigManager.prototype.getCurrentRpcAddress = function () { ConfigManager.prototype.getCurrentRpcAddress = function () {
var provider = this.getProvider() var provider = this.getProvider()
if (!provider) return null if (!provider) return null

@ -11,9 +11,6 @@ module.exports = class IdentityStoreMigrator {
oldSeedForPassword( password ) { oldSeedForPassword( password ) {
const isOldVault = this.hasOldVault() const isOldVault = this.hasOldVault()
if (!isOldVault) { if (!isOldVault) {
console.log('does not seem to have old vault')
console.log('THE DATA:')
console.log(this.configManager.getData())
return Promise.resolve(null) return Promise.resolve(null)
} }
@ -31,7 +28,6 @@ module.exports = class IdentityStoreMigrator {
serializeVault() { serializeVault() {
const mnemonic = this.idStore._idmgmt.getSeed() const mnemonic = this.idStore._idmgmt.getSeed()
console.dir(this.idStore._idmgmt)
const n = this.idStore._getAddresses().length const n = this.idStore._getAddresses().length
return { return {
@ -42,7 +38,6 @@ module.exports = class IdentityStoreMigrator {
hasOldVault() { hasOldVault() {
const wallet = this.configManager.getWallet() const wallet = this.configManager.getWallet()
console.log('found old wallet: ' + wallet)
return wallet return wallet
} }
} }

@ -60,6 +60,7 @@ module.exports = class MetamaskController {
// forward directly to keyringController // forward directly to keyringController
createNewVault: keyringController.createNewVault.bind(keyringController), createNewVault: keyringController.createNewVault.bind(keyringController),
clearSeedWordCache: keyringController.clearSeedWordCache.bind(keyringController),
addNewKeyring: keyringController.addNewKeyring.bind(keyringController), addNewKeyring: keyringController.addNewKeyring.bind(keyringController),
addNewAccount: keyringController.addNewAccount.bind(keyringController), addNewAccount: keyringController.addNewAccount.bind(keyringController),
submitPassword: keyringController.submitPassword.bind(keyringController), submitPassword: keyringController.submitPassword.bind(keyringController),

@ -80,6 +80,7 @@ var actions = {
viewPendingTx: viewPendingTx, viewPendingTx: viewPendingTx,
VIEW_PENDING_TX: 'VIEW_PENDING_TX', VIEW_PENDING_TX: 'VIEW_PENDING_TX',
// app messages // app messages
confirmSeedWords: confirmSeedWords,
showAccountDetail: showAccountDetail, showAccountDetail: showAccountDetail,
BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL', BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL',
backToAccountDetail: backToAccountDetail, backToAccountDetail: backToAccountDetail,
@ -172,6 +173,21 @@ function tryUnlockMetamask (password) {
} }
} }
function confirmSeedWords () {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
background.clearSeedWordCache((err, account) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.showWarning(err.message))
}
console.log('Seed word cache cleared. ' + account)
dispatch(actions.showAccountDetail(account))
})
}
}
function createNewVault (password, entropy) { function createNewVault (password, entropy) {
return (dispatch) => { return (dispatch) => {
// dispatch(actions.createNewVaultInProgress()) // dispatch(actions.createNewVaultInProgress())

@ -27,6 +27,8 @@ const NetworkIndicator = require('./components/network')
const Tooltip = require('./components/tooltip') const Tooltip = require('./components/tooltip')
const BuyView = require('./components/buy-button-subview') const BuyView = require('./components/buy-button-subview')
const QrView = require('./components/qr-code') const QrView = require('./components/qr-code')
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
module.exports = connect(mapStateToProps)(App) module.exports = connect(mapStateToProps)(App)
inherits(App, Component) inherits(App, Component)
@ -35,6 +37,7 @@ function App () { Component.call(this) }
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
// state from plugin // state from plugin
seedWords: state.metamask.seedWords,
isLoading: state.appState.isLoading, isLoading: state.appState.isLoading,
isConfirmed: state.metamask.isConfirmed, isConfirmed: state.metamask.isConfirmed,
isInitialized: state.metamask.isInitialized, isInitialized: state.metamask.isInitialized,
@ -392,6 +395,10 @@ App.prototype.renderPrimary = function () {
return h(DisclaimerScreen, {key: 'disclaimerScreen'}) return h(DisclaimerScreen, {key: 'disclaimerScreen'})
} }
if (props.seedWords) {
return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'})
}
// show initialize screen // show initialize screen
if (!props.isInitialized || props.forgottenPassword) { if (!props.isInitialized || props.forgottenPassword) {

@ -2,7 +2,7 @@ const inherits = require('util').inherits
const Component = require('react').Component const Component = require('react').Component
const connect = require('react-redux').connect const connect = require('react-redux').connect
const h = require('react-hyperscript') const h = require('react-hyperscript')
const actions = require('../actions') const actions = require('../../actions')
module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen) module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen)
@ -71,4 +71,3 @@ CreateVaultCompleteScreen.prototype.render = function () {
CreateVaultCompleteScreen.prototype.confirmSeedWords = function () { CreateVaultCompleteScreen.prototype.confirmSeedWords = function () {
this.props.dispatch(actions.confirmSeedWords()) this.props.dispatch(actions.confirmSeedWords())
} }
Loading…
Cancel
Save