mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Add reveal of seed words.
This commit is contained in:
parent
f2bfdd7f8c
commit
8f3db0dbc0
@ -132,8 +132,6 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
.then((encryptedString) => {
|
||||
this.configManager.setVault(encryptedString)
|
||||
cb(null, serialized)
|
||||
// NORMAL BEHAVIOR:
|
||||
// return cb(null, this.getState())
|
||||
})
|
||||
.catch((err) => {
|
||||
cb(err)
|
||||
@ -157,6 +155,14 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
placeSeedWords () {
|
||||
const firstKeyring = this.keyrings[0]
|
||||
const seedWords = firstKeyring.serialize().mnemonic
|
||||
this.configManager.setSeedWords(seedWords)
|
||||
}
|
||||
|
||||
|
||||
|
||||
submitPassword(password, cb) {
|
||||
this.loadKey(password)
|
||||
.then((key) => {
|
||||
|
@ -59,6 +59,7 @@ module.exports = class MetamaskController {
|
||||
setGasMultiplier: this.setGasMultiplier.bind(this),
|
||||
|
||||
// forward directly to keyringController
|
||||
placeSeedWords: keyringController.placeSeedWords.bind(keyringController),
|
||||
createNewVaultAndKeychain: keyringController.createNewVaultAndKeychain.bind(keyringController),
|
||||
createNewVaultAndRestore: keyringController.createNewVaultAndRestore.bind(keyringController),
|
||||
clearSeedWordCache: keyringController.clearSeedWordCache.bind(keyringController),
|
||||
|
@ -30,6 +30,10 @@ var actions = {
|
||||
addNewAccount,
|
||||
showNewVaultSeed: showNewVaultSeed,
|
||||
showInfoPage: showInfoPage,
|
||||
// seed recovery actions
|
||||
REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION',
|
||||
revealSeedConfirmation: revealSeedConfirmation,
|
||||
requestRevealSeed: requestRevealSeed,
|
||||
// unlock screen
|
||||
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
||||
UNLOCK_FAILED: 'UNLOCK_FAILED',
|
||||
@ -213,6 +217,25 @@ function createNewVaultAndKeychain (password, entropy) {
|
||||
}
|
||||
}
|
||||
|
||||
function revealSeedConfirmation () {
|
||||
return {
|
||||
type: this.REVEAL_SEED_CONFIRMATION,
|
||||
}
|
||||
}
|
||||
|
||||
function requestRevealSeed (password) {
|
||||
return (dispatch) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
background.submitPassword(password, (err, newState) => {
|
||||
dispatch(actions.hideLoadingIndication())
|
||||
if (err) return dispatch(actions.displayWarning(err.message))
|
||||
background.placeSeedWords()
|
||||
dispatch(actions.showNewVaultSeed())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function addNewKeyring (type, opts) {
|
||||
return (dispatch) => {
|
||||
dispatch(actions.showLoadingIndication())
|
||||
|
@ -28,6 +28,7 @@ const BuyView = require('./components/buy-button-subview')
|
||||
const QrView = require('./components/qr-code')
|
||||
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
|
||||
const HDRestoreVaultScreen = require('./keychains/hd/restore-vault')
|
||||
const RevealSeedConfirmation = require('./keychains/hd/recover-seed/confirmation')
|
||||
|
||||
module.exports = connect(mapStateToProps)(App)
|
||||
|
||||
@ -411,6 +412,9 @@ App.prototype.renderPrimary = function () {
|
||||
case 'config':
|
||||
return h(ConfigScreen, {key: 'config'})
|
||||
|
||||
case 'reveal-seed-conf':
|
||||
return h(RevealSeedConfirmation, {key: 'reveal-seed-conf'})
|
||||
|
||||
case 'info':
|
||||
return h(InfoScreen, {key: 'info'})
|
||||
|
||||
|
@ -77,6 +77,22 @@ ConfigScreen.prototype.render = function () {
|
||||
currentConversionInformation(metamaskState, state),
|
||||
h('hr.horizontal-line'),
|
||||
|
||||
h('div', {
|
||||
style: {
|
||||
marginTop: '20px',
|
||||
},
|
||||
}, [
|
||||
h('button', {
|
||||
style: {
|
||||
alignSelf: 'center',
|
||||
},
|
||||
onClick (event) {
|
||||
event.preventDefault()
|
||||
state.dispatch(actions.revealSeedConfirmation())
|
||||
},
|
||||
}, 'Reveal Seed Words'),
|
||||
]),
|
||||
|
||||
]),
|
||||
]),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user