File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -306,8 +306,10 @@ export class Wallet {
306306 newCredentials,
307307 } ) ;
308308 this . userCredentials = newCredentials ;
309- // TODO: we need "updateWalletStore" to re-encrypt the record even if it's not changed
310- await this . updateWalletStore ( this . record ) ;
309+
310+ const { encryptionKey } = this . userCredentials ;
311+ await this . walletStore . encryptAndSave ( this . id , encryptionKey , this . record ) ;
312+
311313 this . setExpirationForSeedPhraseEncryptionKey ( 1000 * 120 ) ;
312314 }
313315
Original file line number Diff line number Diff line change @@ -41,10 +41,12 @@ export class WalletStore extends PersistentStore<WalletStoreState> {
4141 return this . lastRecord ;
4242 }
4343
44- async save ( id : string , encryptionKey : string , record : WalletRecord ) {
45- if ( this . lastRecord === record ) {
46- return ;
47- }
44+ /** Prefer WalletStore['save'] unless necessary */
45+ async encryptAndSave (
46+ id : string ,
47+ encryptionKey : string ,
48+ record : WalletRecord
49+ ) {
4850 const encryptedRecord = await Model . encryptRecord ( encryptionKey , record ) ;
4951 this . setState ( ( state ) =>
5052 produce ( state , ( draft ) => {
@@ -54,6 +56,13 @@ export class WalletStore extends PersistentStore<WalletStoreState> {
5456 this . lastRecord = record ;
5557 }
5658
59+ async save ( id : string , encryptionKey : string , record : WalletRecord ) {
60+ if ( this . lastRecord === record ) {
61+ return ;
62+ }
63+ await this . encryptAndSave ( id , encryptionKey , record ) ;
64+ }
65+
5766 deleteMany ( keys : string [ ] ) {
5867 this . setState ( ( state ) =>
5968 produce ( state , ( draft ) => {
You can’t perform that action at this time.
0 commit comments