Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit dd76047

Browse files
valentinewallacetanx
authored andcommitted
Remove redundant restoreSeed field from store in favor of re-using seedMnemonic.
1 parent f3575b8 commit dd76047

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/action/wallet.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class WalletAction {
5353
* @param {number} options.index The seed index
5454
*/
5555
setRestoreSeed({ word, index }) {
56-
this._store.wallet.restoreSeed[index] = word;
56+
this._store.seedMnemonic[index] = word;
5757
}
5858

5959
/**
@@ -221,9 +221,7 @@ class WalletAction {
221221
await this.initWallet({
222222
walletPassword: newPassword,
223223
recoveryWindow: this._store.settings.restoring ? RECOVERY_WINDOW : 0,
224-
seedMnemonic: this._store.settings.restoring
225-
? this._store.wallet.restoreSeed.toJSON()
226-
: this._store.seedMnemonic.toJSON(),
224+
seedMnemonic: this._store.seedMnemonic.toJSON(),
227225
});
228226
}
229227

@@ -322,6 +320,7 @@ class WalletAction {
322320
* @return {undefined}
323321
*/
324322
initRestoreWallet() {
323+
this._store.seedMnemonic = Array(24).fill('');
325324
this._store.wallet.restoreIndex = 0;
326325
this._nav.goRestoreSeed();
327326
}

src/store.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class Store {
5252
seedIndex: 0,
5353
restoreIndex: 0,
5454
focusedRestoreInd: 0,
55-
restoreSeed: Array(24).fill(''),
5655
},
5756
transactions: [],
5857
selectedTransaction: null,

src/view/restore-seed-mobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RestoreSeedView extends Component {
6767
{store.restoreVerifyIndexes.map((seedIndex, i) => (
6868
<SeedEntry
6969
seedIndex={seedIndex}
70-
value={store.wallet.restoreSeed[seedIndex - 1]}
70+
value={store.seedMnemonic[seedIndex - 1]}
7171
onChangeText={word =>
7272
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
7373
}

src/view/restore-seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const RestoreSeedView = ({ store, wallet }) => (
4747
{store.restoreVerifyIndexes.map((seedIndex, i) => (
4848
<SeedEntry
4949
seedIndex={seedIndex}
50-
value={store.wallet.restoreSeed[seedIndex - 1]}
50+
value={store.seedMnemonic[seedIndex - 1]}
5151
onChangeText={word =>
5252
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
5353
}

test/unit/action/wallet.spec.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,10 @@ describe('Action Wallet Unit Tests', () => {
240240
store.settings.restoring = true;
241241
wallet.setNewPassword({ password: 'secret123' });
242242
wallet.setPasswordVerify({ password: 'secret123' });
243-
store.wallet.restoreSeed = ['beep', 'bop', 'boop'];
244243
await wallet.checkNewPassword();
245244
expect(wallet.initWallet, 'was called with', {
246245
walletPassword: 'secret123',
247-
seedMnemonic: ['beep', 'bop', 'boop'],
246+
seedMnemonic: ['foo', 'bar', 'baz'],
248247
recoveryWindow: RECOVERY_WINDOW,
249248
});
250249
});
@@ -368,16 +367,20 @@ describe('Action Wallet Unit Tests', () => {
368367
it('should clear attributes and navigate to view', () => {
369368
store.wallet.restoreIndex = 42;
370369
wallet.initRestoreWallet();
371-
expect(store.wallet.restoreSeed.length, 'to equal', 24);
370+
expect(store.seedMnemonic.length, 'to equal', 24);
372371
expect(store.wallet.restoreIndex, 'to equal', 0);
373372
expect(nav.goRestoreSeed, 'was called once');
374373
});
375374
});
376375

377376
describe('setRestoreSeed()', () => {
377+
beforeEach(() => {
378+
store.seedMnemonic = Array(24).fill('');
379+
});
380+
378381
it('should clear attributes', () => {
379382
wallet.setRestoreSeed({ word: 'foo', index: 1 });
380-
expect(store.wallet.restoreSeed[1], 'to equal', 'foo');
383+
expect(store.seedMnemonic[1], 'to equal', 'foo');
381384
});
382385
});
383386

0 commit comments

Comments
 (0)