2019-08-02 05:57:26 +02:00
|
|
|
const ObservableStore = require('obs-store')
|
|
|
|
const extend = require('xtend')
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {Object} InitState
|
|
|
|
* @property {Boolean} seedPhraseBackedUp Indicates whether the user has completed the seed phrase backup challenge
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {Object} OnboardingOptions
|
|
|
|
* @property {InitState} initState The initial controller state
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller responsible for maintaining
|
|
|
|
* a cache of account balances in local storage
|
|
|
|
*/
|
|
|
|
class OnboardingController {
|
|
|
|
/**
|
|
|
|
* Creates a new controller instance
|
|
|
|
*
|
|
|
|
* @param {OnboardingOptions} [opts] Controller configuration parameters
|
|
|
|
*/
|
|
|
|
constructor (opts = {}) {
|
|
|
|
const initState = extend({
|
2019-08-08 13:38:41 +02:00
|
|
|
seedPhraseBackedUp: true,
|
2019-08-02 05:57:26 +02:00
|
|
|
}, opts.initState)
|
|
|
|
this.store = new ObservableStore(initState)
|
|
|
|
}
|
|
|
|
|
|
|
|
setSeedPhraseBackedUp (newSeedPhraseBackUpState) {
|
|
|
|
this.store.updateState({
|
|
|
|
seedPhraseBackedUp: newSeedPhraseBackUpState,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
getSeedPhraseBackedUp () {
|
|
|
|
return this.store.getState().seedPhraseBackedUp
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = OnboardingController
|