mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Implement seed word confirmation page.
Remove logs. Move HD render files to ui/app.
This commit is contained in:
parent
6fc498f8a0
commit
96643c222a
@ -47,6 +47,7 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
|
||||
getState() {
|
||||
return {
|
||||
seedWords: this.configManager.getSeedWords(),
|
||||
isInitialized: !!this.configManager.getVault(),
|
||||
isUnlocked: !!this.key,
|
||||
isConfirmed: true, // AUDIT this.configManager.getConfirmed(),
|
||||
@ -90,10 +91,14 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
this.configManager.setVault(encryptedString)
|
||||
|
||||
if (!serialized) {
|
||||
// TEMPORARY SINGLE-KEYRING CONFIG:
|
||||
return this.addNewKeyring('HD Key Tree', null, (err, newState) => {
|
||||
const firstAccount = this.keyrings[0].getAccounts()[0]
|
||||
autoFaucet(ethUtil.addHexPrefix(firstAccount))
|
||||
this.addNewKeyring('HD Key Tree', null, (err, newState) => {
|
||||
const firstKeyring = this.keyrings[0]
|
||||
const firstAccount = firstKeyring.getAccounts()[0]
|
||||
const hexAccount = ethUtil.addHexPrefix(firstAccount)
|
||||
const seedWords = firstKeyring.serialize().mnemonic
|
||||
this.configManager.setSelectedAccount(hexAccount)
|
||||
this.configManager.setSeedWords(seedWords)
|
||||
autoFaucet(hexAccount)
|
||||
cb(err, newState)
|
||||
})
|
||||
} else {
|
||||
@ -470,6 +475,11 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
return ethUtil.addHexPrefix(result.toString(16))
|
||||
}
|
||||
|
||||
clearSeedWordCache(cb) {
|
||||
this.configManager.setSeedWords(null)
|
||||
cb(null, this.configManager.getSelectedAccount())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function noop () {}
|
||||
|
@ -2,6 +2,7 @@ const Migrator = require('pojo-migrator')
|
||||
const MetamaskConfig = require('../config.js')
|
||||
const migrations = require('./migrations')
|
||||
const rp = require('request-promise')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
|
||||
const TESTNET_RPC = MetamaskConfig.network.testnet
|
||||
const MAINNET_RPC = MetamaskConfig.network.mainnet
|
||||
@ -138,7 +139,7 @@ ConfigManager.prototype.getSelectedAccount = function () {
|
||||
|
||||
ConfigManager.prototype.setSelectedAccount = function (address) {
|
||||
var config = this.getConfig()
|
||||
config.selectedAccount = address
|
||||
config.selectedAccount = ethUtil.addHexPrefix(address)
|
||||
this.setConfig(config)
|
||||
}
|
||||
|
||||
@ -153,11 +154,23 @@ ConfigManager.prototype.setShowSeedWords = function (should) {
|
||||
this.setData(data)
|
||||
}
|
||||
|
||||
|
||||
ConfigManager.prototype.getShouldShowSeedWords = function () {
|
||||
var data = this.migrator.getData()
|
||||
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 () {
|
||||
var provider = this.getProvider()
|
||||
if (!provider) return null
|
||||
|
@ -11,9 +11,6 @@ module.exports = class IdentityStoreMigrator {
|
||||
oldSeedForPassword( password ) {
|
||||
const isOldVault = this.hasOldVault()
|
||||
if (!isOldVault) {
|
||||
console.log('does not seem to have old vault')
|
||||
console.log('THE DATA:')
|
||||
console.log(this.configManager.getData())
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
|
||||
@ -31,7 +28,6 @@ module.exports = class IdentityStoreMigrator {
|
||||
|
||||
serializeVault() {
|
||||
const mnemonic = this.idStore._idmgmt.getSeed()
|
||||
console.dir(this.idStore._idmgmt)
|
||||
const n = this.idStore._getAddresses().length
|
||||
|
||||
return {
|
||||
@ -42,7 +38,6 @@ module.exports = class IdentityStoreMigrator {
|
||||
|
||||
hasOldVault() {
|
||||
const wallet = this.configManager.getWallet()
|
||||
console.log('found old wallet: ' + wallet)
|
||||
return wallet
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ module.exports = class MetamaskController {
|
||||
|
||||
// forward directly to keyringController
|
||||
createNewVault: keyringController.createNewVault.bind(keyringController),
|
||||
clearSeedWordCache: keyringController.clearSeedWordCache.bind(keyringController),
|
||||
addNewKeyring: keyringController.addNewKeyring.bind(keyringController),
|
||||
addNewAccount: keyringController.addNewAccount.bind(keyringController),
|
||||
submitPassword: keyringController.submitPassword.bind(keyringController),
|
||||
|
@ -80,6 +80,7 @@ var actions = {
|
||||
viewPendingTx: viewPendingTx,
|
||||
VIEW_PENDING_TX: 'VIEW_PENDING_TX',
|
||||
// app messages
|
||||
confirmSeedWords: confirmSeedWords,
|
||||
showAccountDetail: showAccountDetail,
|
||||
BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL',
|
||||
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) {
|
||||
return (dispatch) => {
|
||||
// dispatch(actions.createNewVaultInProgress())
|
||||
|
@ -27,6 +27,8 @@ const NetworkIndicator = require('./components/network')
|
||||
const Tooltip = require('./components/tooltip')
|
||||
const BuyView = require('./components/buy-button-subview')
|
||||
const QrView = require('./components/qr-code')
|
||||
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
|
||||
|
||||
module.exports = connect(mapStateToProps)(App)
|
||||
|
||||
inherits(App, Component)
|
||||
@ -35,6 +37,7 @@ function App () { Component.call(this) }
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
// state from plugin
|
||||
seedWords: state.metamask.seedWords,
|
||||
isLoading: state.appState.isLoading,
|
||||
isConfirmed: state.metamask.isConfirmed,
|
||||
isInitialized: state.metamask.isInitialized,
|
||||
@ -392,6 +395,10 @@ App.prototype.renderPrimary = function () {
|
||||
return h(DisclaimerScreen, {key: 'disclaimerScreen'})
|
||||
}
|
||||
|
||||
if (props.seedWords) {
|
||||
return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'})
|
||||
}
|
||||
|
||||
// show initialize screen
|
||||
if (!props.isInitialized || props.forgottenPassword) {
|
||||
|
||||
|
@ -2,7 +2,7 @@ const inherits = require('util').inherits
|
||||
const Component = require('react').Component
|
||||
const connect = require('react-redux').connect
|
||||
const h = require('react-hyperscript')
|
||||
const actions = require('../actions')
|
||||
const actions = require('../../actions')
|
||||
|
||||
module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen)
|
||||
|
||||
@ -71,4 +71,3 @@ CreateVaultCompleteScreen.prototype.render = function () {
|
||||
CreateVaultCompleteScreen.prototype.confirmSeedWords = function () {
|
||||
this.props.dispatch(actions.confirmSeedWords())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user