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

Commit f4c5f32

Browse files
valentinewallacetanx
authored andcommitted
Adapt the checkNewPassword helper for wallet restore case.
Since we use the flow during wallet recovery now, we need to change checkNewPassword to detect whether we're doing a wallet recovery, and initialize the wallet accordingly.
1 parent a91eea4 commit f4c5f32

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/action/wallet.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ class WalletAction {
212212
}
213213
await this.initWallet({
214214
walletPassword: newPassword,
215-
seedMnemonic: this._store.seedMnemonic.toJSON(),
215+
recoveryWindow: this._store.settings.restoring ? RECOVERY_WINDOW : 0,
216+
seedMnemonic: this._store.settings.restoring
217+
? this._store.wallet.restoreSeed.toJSON()
218+
: this._store.seedMnemonic.toJSON(),
216219
});
217220
}
218221

test/unit/action/wallet.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ describe('Action Wallet Unit Tests', () => {
214214
expect(wallet.initWallet, 'was called with', {
215215
walletPassword: 'secret123',
216216
seedMnemonic: ['foo', 'bar', 'baz'],
217+
recoveryWindow: 0,
217218
});
218219
});
219220

@@ -234,6 +235,19 @@ describe('Action Wallet Unit Tests', () => {
234235
expect(wallet.initSetPassword, 'was called once');
235236
expect(notification.display, 'was called once');
236237
});
238+
239+
it('init wallet correctly during restore', async () => {
240+
store.settings.restoring = true;
241+
wallet.setNewPassword({ password: 'secret123' });
242+
wallet.setPasswordVerify({ password: 'secret123' });
243+
store.wallet.restoreSeed = ['beep', 'bop', 'boop'];
244+
await wallet.checkNewPassword();
245+
expect(wallet.initWallet, 'was called with', {
246+
walletPassword: 'secret123',
247+
seedMnemonic: ['beep', 'bop', 'boop'],
248+
recoveryWindow: RECOVERY_WINDOW,
249+
});
250+
});
237251
});
238252

239253
describe('checkResetPassword()', () => {

0 commit comments

Comments
 (0)