* allow garbage collection.\r
*/\r
async destroy (): Promise<void> {\r
- let i = 0\r
- for (const a in this.#accounts) {\r
- await this.#accounts[a].destroy()\r
- delete this.#accounts[a]\r
- i++\r
+ try {\r
+ for (const a in this.#accounts) {\r
+ await this.#accounts[a].destroy()\r
+ delete this.#accounts[a]\r
+ }\r
+ bytes.erase(this.#s)\r
+ this.#s = null\r
+ this.#m = null\r
+ await SafeWorker.assign<boolean>({\r
+ store: 'Wallet',\r
+ method: 'destroy',\r
+ [this.id]: this.id\r
+ })\r
+ } catch (err) {\r
+ console.error(err)\r
+ throw new Error('failed to destroy wallet', { cause: err })\r
}\r
- this.#m = null\r
- bytes.erase(this.#s)\r
- this.#s = null\r
- await SafeWorker.assign({\r
- store: 'Wallet',\r
- method: 'destroy',\r
- [this.id]: this.id\r
- })\r
}\r
\r
/**\r