@@ -37,10 +37,13 @@ import routes from '../constants/routes.json';
37
37
export type SetKeysAction = { type : 'SET_KEYS' } & AccountKeys ;
38
38
export const SET_KEYS = 'SET_KEYS' ;
39
39
40
- export function setAccount ( privateKey : string ) : Thunk < SetKeysAction > {
40
+ export function setAccount (
41
+ privateKey : string ,
42
+ spendingPassword : ?string
43
+ ) : Thunk < SetKeysAction > {
41
44
return function setAccountThunk ( dispatch ) {
42
- return getAccountFromPrivateKey ( privateKey ) . then (
43
- curry ( initializeKeysAndRedirect ) ( dispatch )
45
+ return getAccountFromPrivateKey ( privateKey ) . then ( keys =>
46
+ curry ( initializeKeysAndRedirect ) ( dispatch , keys , spendingPassword )
44
47
) ;
45
48
} ;
46
49
}
@@ -84,16 +87,15 @@ export function setAccountFromPrivateKey(
84
87
const initializeKeysAndRedirect = (
85
88
dispatch : Dispatch ,
86
89
keys : AccountKeys ,
87
- saveAccount ? : boolean = true
90
+ spendingPassword : ? string = ''
88
91
) => {
89
92
dispatch ( {
90
93
type : SET_KEYS ,
91
94
...keys
92
95
} ) ;
93
- if ( saveAccount ) {
94
- saveSpendingPassword ( 'manteca' ) ;
95
- saveAccountInfoInDEN ( 'manteca' , keys ) ;
96
- }
96
+
97
+ saveSpendingPassword ( spendingPassword ) ;
98
+ saveAccountInfoInDEN ( spendingPassword , keys ) ;
97
99
98
100
return Promise . all ( [
99
101
dispatch ( updateAccountTransactions ( ) ) ,
@@ -109,13 +111,14 @@ const initializeKeysAndRedirect = (
109
111
110
112
export function setAccountFromMnemonic (
111
113
mnemonicPhrase : string ,
112
- mnemonicPassword ?: string
114
+ mnemonicPassword : string ,
115
+ spendingPassword : ?string
113
116
) : Thunk < SetKeysAction > {
114
117
if ( isValidMnemonic ( mnemonicPhrase ) ) {
115
118
const seed = createSeedFromMnemonic ( mnemonicPhrase , mnemonicPassword ) ;
116
119
return function setAccountThunk ( dispatch ) {
117
- return getAccountFromSeed ( seed ) . then (
118
- curry ( initializeKeysAndRedirect ) ( dispatch )
120
+ return getAccountFromSeed ( seed ) . then ( keys =>
121
+ curry ( initializeKeysAndRedirect ) ( dispatch , keys , spendingPassword )
119
122
) ;
120
123
} ;
121
124
}
0 commit comments