]> git.codecow.com Git - libnemo.git/commitdiff
Proceed with destroying accounts and wallet while promises are being fulfilled.
authorChris Duncan <chris@zoso.dev>
Fri, 25 Jul 2025 11:42:42 +0000 (04:42 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 25 Jul 2025 11:42:42 +0000 (04:42 -0700)
src/lib/account.ts
src/lib/wallets/wallet.ts

index c8ef4e0c1b7666864f0a2f82f9447e7ff3a76ab5..935728854d1db17da59f461266e8e47db54816d5 100644 (file)
@@ -70,16 +70,21 @@ export class Account {
        * allow garbage collection.\r
        */\r
        async destroy (): Promise<void> {\r
-               await SafeWorker.request({\r
-                       method: 'destroy',\r
-                       store: 'Account',\r
-                       [this.publicKey]: this.publicKey\r
-               })\r
                this.#frontier = undefined\r
                this.#balance = undefined\r
                this.#receivable = undefined\r
                this.#representative = undefined\r
                this.#weight = undefined\r
+               try {\r
+                       await SafeWorker.request<boolean>({\r
+                               method: 'destroy',\r
+                               store: 'Account',\r
+                               [this.publicKey]: this.publicKey\r
+                       })\r
+               } catch (err) {\r
+                       console.error(err)\r
+                       throw new Error('failed to destroy account', { cause: err })\r
+               }\r
        }\r
 \r
        /**\r
index 36532de66fb7dd5f9d6eb9b13077581e2eb11e21..6ce59086105eeca0e1a1fee6135903d89b1cb939 100644 (file)
@@ -161,14 +161,14 @@ export abstract class Wallet {
        */\r
        async destroy (): Promise<void> {\r
                try {\r
-                       for (const a in this.#accounts) {\r
-                               await this.#accounts[a].destroy()\r
-                               delete this.#accounts[a]\r
-                       }\r
                        this.#m?.destroy()\r
                        bytes.erase(this.#s)\r
                        this.#m = undefined\r
                        this.#s = undefined\r
+                       for (const a in this.#accounts) {\r
+                               this.#accounts[a].destroy()\r
+                               delete this.#accounts[a]\r
+                       }\r
                        await SafeWorker.request<boolean>({\r
                                store: 'Wallet',\r
                                method: 'destroy',\r