@@ -32,14 +32,15 @@ export async function validatePassword(password: string) {
32
32
let rawWalletTimeoutPid : number | undefined
33
33
let rawWallet : ethers . Wallet | undefined
34
34
35
- function setRawWallet ( wallet : ethers . Wallet ) {
35
+ function setRawWallet ( wallet : ethers . Wallet | undefined ) {
36
36
rawWallet = wallet
37
37
rawWalletTimeoutPid = setTimeout ( ( ) => {
38
38
rawWallet = undefined
39
39
} , 15 * 60 * 60 * 1000 ) as unknown as number
40
40
}
41
41
42
42
export async function setKeystore ( keystore : string ) {
43
+ setRawWallet ( undefined )
43
44
await store . setItem ( "encKeystore" , keystore )
44
45
}
45
46
@@ -67,13 +68,15 @@ async function generateL1(): Promise<ethers.Wallet> {
67
68
68
69
let recoverPromise : Promise < ethers . Wallet > | undefined
69
70
export async function getL1 ( password : string ) : Promise < ethers . Wallet > {
71
+ console . log ( "getL1" , rawWallet , await existsL1 ( ) )
70
72
if ( rawWallet ) {
71
73
return rawWallet
72
74
} else if ( await existsL1 ( ) ) {
73
75
if ( ! recoverPromise ) recoverPromise = recoverL1 ( password )
74
76
const recoveredWallet = await recoverPromise
75
77
setRawWallet ( recoveredWallet )
76
78
const encKeyPair = JSON . parse ( ( await store . getItem ( "encKeystore" ) ) || "{}" )
79
+ console . log ( "Set wallets" , encKeyPair )
77
80
store . setItem ( "wallets" , encKeyPair . wallets ?? [ ] )
78
81
if (
79
82
( await selectedWalletStore . getItem ( "SELECTED_WALLET" ) ) . address === "" &&
@@ -169,3 +172,8 @@ export async function createAccount(password: string, networkId: string) {
169
172
wallets,
170
173
}
171
174
}
175
+
176
+ export async function resetAll ( ) {
177
+ setRawWallet ( undefined )
178
+ await browser . storage . local . clear ( )
179
+ }
0 commit comments