This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,20 @@ class WalletAction {
235235 await this . unlockWallet ( { walletPassword : password } ) ;
236236 }
237237
238+ /**
239+ * Initialize the wallet with the password input the seed that was already
240+ * inputted, and the default recovery window.
241+ * @return {Promise<undefined> }
242+ */
243+ async restoreWallet ( ) {
244+ const { password, restoreSeed } = this . _store . wallet ;
245+ await this . initWallet ( {
246+ walletPassword : password ,
247+ seedMnemonic : restoreSeed . toJSON ( ) ,
248+ recoveryWindow : RECOVERY_WINDOW ,
249+ } ) ;
250+ }
251+
238252 /**
239253 * Unlock the wallet by calling the grpc api with the user chosen password.
240254 * @param {string } options.walletPassword The password used to encrypt the wallet
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import NotificationAction from '../../../src/action/notification';
77import * as logger from '../../../src/action/log' ;
88import nock from 'nock' ;
99import 'isomorphic-fetch' ;
10+ import { RECOVERY_WINDOW } from '../../../src/config' ;
1011
1112describe ( 'Action Wallet Unit Tests' , ( ) => {
1213 let store ;
@@ -275,6 +276,24 @@ describe('Action Wallet Unit Tests', () => {
275276 } ) ;
276277 } ) ;
277278
279+ describe ( 'restoreWallet()' , ( ) => {
280+ beforeEach ( ( ) => {
281+ sandbox . stub ( wallet , 'initWallet' ) ;
282+ } ) ;
283+
284+ it ( 'calls initWallet with password and restoreSeed' , async ( ) => {
285+ wallet . setPassword ( { password : 'secret123' } ) ;
286+ const seed = Array ( 24 ) . fill ( 'foo' ) ;
287+ store . wallet . restoreSeed = seed ;
288+ await wallet . restoreWallet ( ) ;
289+ expect ( wallet . initWallet , 'was called with' , {
290+ walletPassword : 'secret123' ,
291+ seedMnemonic : seed ,
292+ recoveryWindow : RECOVERY_WINDOW ,
293+ } ) ;
294+ } ) ;
295+ } ) ;
296+
278297 describe ( 'unlockWallet()' , ( ) => {
279298 it ( 'should unlock wallet' , async ( ) => {
280299 grpc . sendUnlockerCommand . withArgs ( 'UnlockWallet' ) . resolves ( ) ;
You can’t perform that action at this time.
0 commit comments