From: Chris Duncan Date: Fri, 25 Jul 2025 11:42:42 +0000 (-0700) Subject: Proceed with destroying accounts and wallet while promises are being fulfilled. X-Git-Tag: v0.10.5~50^2~21^2~7 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=4b40e05745fa2366cdcb68100e16461c74363217;p=libnemo.git Proceed with destroying accounts and wallet while promises are being fulfilled. --- 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',