-
Notifications
You must be signed in to change notification settings - Fork 623
fix(wallets): make WalletDB.deleteAccount atomic #25219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb62c6b
a229b2e
445d282
f51c6aa
cad7f30
b97d586
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,19 +121,25 @@ export class WalletDB { | |
| return addresses; | ||
| } | ||
|
|
||
| /** | ||
| * Deletes an account's stored data and its alias atomically. Deletion is local to this store; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not introduced here, but since the doc now promises we delete "its alias": |
||
| * any state the PXE holds for the account is unaffected. | ||
| */ | ||
| async deleteAccount(address: AztecAddress) { | ||
| await Promise.all([ | ||
| this.accounts.delete(accountKey('sk', address)), | ||
| this.accounts.delete(accountKey('salt', address)), | ||
| this.accounts.delete(accountKey('type', address)), | ||
| this.accounts.delete(accountKey('signingKey', address)), | ||
| ]); | ||
| // Clean up alias if one exists | ||
| const aliasesByAddress = await this.#readAccountAliases(); | ||
| const alias = aliasesByAddress.get(address.toString()); | ||
| if (alias) { | ||
| await this.aliases.delete(`accounts:${alias}`); | ||
| } | ||
| await this.store.transactionAsync(async () => { | ||
| await Promise.all([ | ||
| this.accounts.delete(accountKey('sk', address)), | ||
| this.accounts.delete(accountKey('salt', address)), | ||
| this.accounts.delete(accountKey('type', address)), | ||
| this.accounts.delete(accountKey('signingKey', address)), | ||
| ]); | ||
| // Clean up alias if one exists | ||
| const aliasesByAddress = await this.#readAccountAliases(); | ||
|
nventuro marked this conversation as resolved.
|
||
| const alias = aliasesByAddress.get(address.toString()); | ||
| if (alias) { | ||
| await this.aliases.delete(`accounts:${alias}`); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| async close() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny thing: this
dbshadows the one from the outerdescribe. Could we name itseedDbor similar? Otherwise if theconstever gets dropped we'd seed thebeforeEachstore instead and the failure would point somewhere confusing.