Unverified Commit dd760475 authored by Valentine Wallace's avatar Valentine Wallace Committed by Tankred Hase

Remove redundant restoreSeed field from store in favor of re-using seedMnemonic.

parent f3575b8e
......@@ -53,7 +53,7 @@ class WalletAction {
* @param {number} options.index The seed index
*/
setRestoreSeed({ word, index }) {
this._store.wallet.restoreSeed[index] = word;
this._store.seedMnemonic[index] = word;
}
/**
......@@ -221,9 +221,7 @@ class WalletAction {
await this.initWallet({
walletPassword: newPassword,
recoveryWindow: this._store.settings.restoring ? RECOVERY_WINDOW : 0,
seedMnemonic: this._store.settings.restoring
? this._store.wallet.restoreSeed.toJSON()
: this._store.seedMnemonic.toJSON(),
seedMnemonic: this._store.seedMnemonic.toJSON(),
});
}
......@@ -322,6 +320,7 @@ class WalletAction {
* @return {undefined}
*/
initRestoreWallet() {
this._store.seedMnemonic = Array(24).fill('');
this._store.wallet.restoreIndex = 0;
this._nav.goRestoreSeed();
}
......
......@@ -52,7 +52,6 @@ export class Store {
seedIndex: 0,
restoreIndex: 0,
focusedRestoreInd: 0,
restoreSeed: Array(24).fill(''),
},
transactions: [],
selectedTransaction: null,
......
......@@ -67,7 +67,7 @@ class RestoreSeedView extends Component {
{store.restoreVerifyIndexes.map((seedIndex, i) => (
<SeedEntry
seedIndex={seedIndex}
value={store.wallet.restoreSeed[seedIndex - 1]}
value={store.seedMnemonic[seedIndex - 1]}
onChangeText={word =>
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
}
......
......@@ -47,7 +47,7 @@ const RestoreSeedView = ({ store, wallet }) => (
{store.restoreVerifyIndexes.map((seedIndex, i) => (
<SeedEntry
seedIndex={seedIndex}
value={store.wallet.restoreSeed[seedIndex - 1]}
value={store.seedMnemonic[seedIndex - 1]}
onChangeText={word =>
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
}
......
......@@ -240,11 +240,10 @@ describe('Action Wallet Unit Tests', () => {
store.settings.restoring = true;
wallet.setNewPassword({ password: 'secret123' });
wallet.setPasswordVerify({ password: 'secret123' });
store.wallet.restoreSeed = ['beep', 'bop', 'boop'];
await wallet.checkNewPassword();
expect(wallet.initWallet, 'was called with', {
walletPassword: 'secret123',
seedMnemonic: ['beep', 'bop', 'boop'],
seedMnemonic: ['foo', 'bar', 'baz'],
recoveryWindow: RECOVERY_WINDOW,
});
});
......@@ -368,16 +367,20 @@ describe('Action Wallet Unit Tests', () => {
it('should clear attributes and navigate to view', () => {
store.wallet.restoreIndex = 42;
wallet.initRestoreWallet();
expect(store.wallet.restoreSeed.length, 'to equal', 24);
expect(store.seedMnemonic.length, 'to equal', 24);
expect(store.wallet.restoreIndex, 'to equal', 0);
expect(nav.goRestoreSeed, 'was called once');
});
});
describe('setRestoreSeed()', () => {
beforeEach(() => {
store.seedMnemonic = Array(24).fill('');
});
it('should clear attributes', () => {
wallet.setRestoreSeed({ word: 'foo', index: 1 });
expect(store.wallet.restoreSeed[1], 'to equal', 'foo');
expect(store.seedMnemonic[1], 'to equal', 'foo');
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment