From 4b40e05745fa2366cdcb68100e16461c74363217 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 25 Jul 2025 04:42:42 -0700 Subject: [PATCH] Proceed with destroying accounts and wallet while promises are being fulfilled. --- src/lib/account.ts | 15 ++++++++++----- src/lib/wallets/wallet.ts | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/lib/account.ts b/src/lib/account.ts index c8ef4e0..9357288 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -70,16 +70,21 @@ export class Account { * allow garbage collection. */ async destroy (): Promise { - await SafeWorker.request({ - method: 'destroy', - store: 'Account', - [this.publicKey]: this.publicKey - }) this.#frontier = undefined this.#balance = undefined this.#receivable = undefined this.#representative = undefined this.#weight = undefined + try { + await SafeWorker.request({ + method: 'destroy', + store: 'Account', + [this.publicKey]: this.publicKey + }) + } catch (err) { + console.error(err) + throw new Error('failed to destroy account', { cause: err }) + } } /** diff --git a/src/lib/wallets/wallet.ts b/src/lib/wallets/wallet.ts index 36532de..6ce5908 100644 --- a/src/lib/wallets/wallet.ts +++ b/src/lib/wallets/wallet.ts @@ -161,14 +161,14 @@ export abstract class Wallet { */ async destroy (): Promise { try { - for (const a in this.#accounts) { - await this.#accounts[a].destroy() - delete this.#accounts[a] - } this.#m?.destroy() bytes.erase(this.#s) this.#m = undefined this.#s = undefined + for (const a in this.#accounts) { + this.#accounts[a].destroy() + delete this.#accounts[a] + } await SafeWorker.request({ store: 'Wallet', method: 'destroy', -- 2.47.3