@aztec/node-lib 0.0.1-fake-c83136db25 → 0.0.1-private.d0bedffd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum';
1
+ import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum/l1-tx-utils';
2
2
  import { jsonStringify } from '@aztec/foundation/json-rpc';
3
3
  import type { Logger } from '@aztec/foundation/log';
4
4
  import { createLogger } from '@aztec/foundation/log';
@@ -231,11 +231,18 @@ export class L1TxStore implements IL1TxStore {
231
231
  * @param account - The sender account address
232
232
  * @param stateId - The state ID to delete
233
233
  */
234
- public async deleteState(account: string, stateId: number): Promise<void> {
235
- const key = this.makeKey(account, stateId);
236
- await this.states.delete(key);
237
- await this.blobs.delete(key);
238
- this.log.debug(`Deleted state ${stateId} for account ${account}`);
234
+ public async deleteState(account: string, ...stateIds: number[]): Promise<void> {
235
+ if (stateIds.length === 0) {
236
+ return;
237
+ }
238
+
239
+ await this.store.transactionAsync(async () => {
240
+ for (const stateId of stateIds) {
241
+ const key = this.makeKey(account, stateId);
242
+ await this.states.delete(key);
243
+ await this.blobs.delete(key);
244
+ }
245
+ });
239
246
  }
240
247
 
241
248
  /**
@@ -243,14 +250,16 @@ export class L1TxStore implements IL1TxStore {
243
250
  * @param account - The sender account address
244
251
  */
245
252
  public async clearStates(account: string): Promise<void> {
246
- const states = await this.loadStates(account);
253
+ await this.store.transactionAsync(async () => {
254
+ const states = await this.loadStates(account);
247
255
 
248
- for (const state of states) {
249
- await this.deleteState(account, state.id);
250
- }
256
+ for (const state of states) {
257
+ await this.deleteState(account, state.id);
258
+ }
251
259
 
252
- await this.stateIdCounter.delete(account);
253
- this.log.info(`Cleared all tx states for account ${account}`);
260
+ await this.stateIdCounter.delete(account);
261
+ this.log.info(`Cleared all tx states for account ${account}`);
262
+ });
254
263
  }
255
264
 
256
265
  /**