View on GitHub
File Changes

                      
export default class WalletBackupActions {
  startWalletBackup: Action<any> = new Action();
-
  initiateWalletBackup: Action<{ recoveryPhrase: string[] }> = new Action();
+
  initiateWalletBackup: Action<{
+
    recoveryPhrase: Array<string>,
+
  }> = new Action();
  acceptPrivacyNoticeForWalletBackup: Action<any> = new Action();
  continueToRecoveryPhraseForWalletBackup: Action<any> = new Action();
  addWordToWalletBackupVerification: Action<{
  restartWalletBackup: Action<any> = new Action();
  cancelWalletBackup: Action<any> = new Action();
  finishWalletBackup: Action<any> = new Action();
+
  // Recovery phrase confirmation dialog actions
+
  checkRecoveryPhrase: Action<{ recoveryPhrase: Array<string> }> = new Action();
+
  resetRecoveryPhraseCheck: Action<any> = new Action();
}
// @flow
import { observable, action, computed } from 'mobx';
import Store from './lib/Store';
+
import Request from './lib/LocalizedRequest';
import WalletBackupDialog from '../components/wallet/WalletBackupDialog';
import { WALLET_BACKUP_STEPS } from '../types/walletBackupTypes';
import type {
  RecoveryPhraseWord,
  walletBackupStep,
} from '../types/walletBackupTypes';
+
import type { WalletIdAndBalance } from '../api/wallets/types';

                      
export default class WalletBackupStore extends Store {
  @observable inProgress = false;
  @observable isTermRecoveryAccepted = false;
  @observable countdownRemaining = 0;

                      
+
  // Recovery phrase confirmation dialog observables ---
+
  @observable isRecoveryPhraseMatching = null;
+
  @observable
+
  getWalletIdAndBalanceRequest: Request<WalletIdAndBalance> = new Request(
+
    this.api.ada.getWalletIdAndBalance
+
  );
+

                      
  countdownTimerInterval: ?IntervalID = null;

                      
  setup() {
    a.cancelWalletBackup.listen(this._cancelWalletBackup);
    a.finishWalletBackup.listen(this._finishWalletBackup);
    this.actions.app.initAppEnvironment.listen(() => {});
+
    // Recovery phrase confirmation dialog actions
+
    a.checkRecoveryPhrase.listen(this._checkRecoveryPhrase);
+
    a.resetRecoveryPhraseCheck.listen(this._resetRecoveryPhraseCheck);
  }

                      
  @action _initiateWalletBackup = (params: {
    );
  };

                      
+
  @action _checkRecoveryPhrase = async (params: {
+
    recoveryPhrase: Array<string>,
+
  }) => {
+
    const activeWallet = this.stores.wallets.active;
+
    if (!activeWallet)
+
      throw new Error(
+
        'Active wallet required before checking recovery phrase.'
+
      );
+
    const {
+
      walletId,
+
    }: WalletIdAndBalance = await this.getWalletIdAndBalanceRequest.execute(
+
      params
+
    ).promise;
+
    this.isRecoveryPhraseMatching = walletId === activeWallet.id;
+
  };
+

                      
+
  @action _resetRecoveryPhraseCheck = () => {
+
    this.getWalletIdAndBalanceRequest.reset();
+
    this.isRecoveryPhraseMatching = null;
+
  };
+

                      
  @computed get isRecoveryPhraseValid(): boolean {
    return (
      this.recoveryPhraseWords.reduce((words, { word }) => words + word, '') ===