@@ -42,6 +42,7 @@ import {
42
42
import { WorkerPool } from '../workerPool'
43
43
import { DecryptedNote , DecryptNotesItem } from '../workerPool/tasks/decryptNotes'
44
44
import { Account , ACCOUNT_SCHEMA_VERSION } from './account/account'
45
+ import { EncryptedAccount } from './account/encryptedAccount'
45
46
import { AssetBalances } from './assetBalances'
46
47
import {
47
48
DuplicateAccountNameError ,
@@ -94,6 +95,7 @@ export class Wallet {
94
95
readonly onAccountRemoved = new Event < [ account : Account ] > ( )
95
96
96
97
protected readonly accountById = new Map < string , Account > ( )
98
+ protected readonly encryptedAccounts = new Map < string , EncryptedAccount > ( )
97
99
readonly walletDb : WalletDB
98
100
private readonly logger : Logger
99
101
readonly workerPool : WorkerPool
@@ -208,9 +210,17 @@ export class Wallet {
208
210
}
209
211
210
212
private async load ( ) : Promise < void > {
211
- for await ( const accountValue of this . walletDb . loadAccounts ( ) ) {
212
- const account = new Account ( { accountValue, walletDb : this . walletDb } )
213
- this . accountById . set ( account . id , account )
213
+ for await ( const [ id , accountValue ] of this . walletDb . loadAccounts ( ) ) {
214
+ if ( accountValue . encrypted ) {
215
+ const encryptedAccount = new EncryptedAccount ( {
216
+ data : accountValue . data ,
217
+ walletDb : this . walletDb ,
218
+ } )
219
+ this . encryptedAccounts . set ( id , encryptedAccount )
220
+ } else {
221
+ const account = new Account ( { accountValue, walletDb : this . walletDb } )
222
+ this . accountById . set ( account . id , account )
223
+ }
214
224
}
215
225
216
226
const meta = await this . walletDb . loadAccountsMeta ( )
0 commit comments