aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-11-01 02:35:09 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-11-01 02:35:09 +0800
commit96643c222a74552d98218fe1f9fc81e493a1960f (patch)
tree9e49503ee49ca0bce8c888c286719de5eb27f1e6
parent6fc498f8a030ea00bcef9b8b3400fc527fc4aeed (diff)
downloadtangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar.gz
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar.bz2
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar.lz
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar.xz
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.tar.zst
tangerine-wallet-browser-96643c222a74552d98218fe1f9fc81e493a1960f.zip
Implement seed word confirmation page.
Remove logs. Move HD render files to ui/app.
-rw-r--r--app/scripts/keyring-controller.js18
-rw-r--r--app/scripts/lib/config-manager.js15
-rw-r--r--app/scripts/lib/idStore-migrator.js5
-rw-r--r--app/scripts/metamask-controller.js1
-rw-r--r--ui/app/actions.js16
-rw-r--r--ui/app/app.js7
-rw-r--r--ui/app/keychains/hd/create-vault-complete.js (renamed from keychains/bip44/create-vault-complete.js)3
-rw-r--r--ui/app/keychains/hd/recover-seed/confirmation.js (renamed from keychains/bip44/recover-seed/confirmation.js)0
-rw-r--r--ui/app/keychains/hd/restore-vault.js (renamed from keychains/bip44/restore-vault.js)0
9 files changed, 53 insertions, 12 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index e7b9612bf..ee6445121 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -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 () {}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index abe5dfc87..8f5590738 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -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
diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js
index f8f7cb51a..c81e7ddfe 100644
--- a/app/scripts/lib/idStore-migrator.js
+++ b/app/scripts/lib/idStore-migrator.js
@@ -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
}
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index a7d9a8ec2..48c56d915 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -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),
diff --git a/ui/app/actions.js b/ui/app/actions.js
index a2f59cb3c..5068d1848 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -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())
diff --git a/ui/app/app.js b/ui/app/app.js
index 588aa9896..f3ad8efc3 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -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) {
diff --git a/keychains/bip44/create-vault-complete.js b/ui/app/keychains/hd/create-vault-complete.js
index 2b5413955..7272ebdbd 100644
--- a/keychains/bip44/create-vault-complete.js
+++ b/ui/app/keychains/hd/create-vault-complete.js
@@ -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())
}
-
diff --git a/keychains/bip44/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js
index 55b18025f..55b18025f 100644
--- a/keychains/bip44/recover-seed/confirmation.js
+++ b/ui/app/keychains/hd/recover-seed/confirmation.js
diff --git a/keychains/bip44/restore-vault.js b/ui/app/keychains/hd/restore-vault.js
index 4c1f21008..4c1f21008 100644
--- a/keychains/bip44/restore-vault.js
+++ b/ui/app/keychains/hd/restore-vault.js