From 08cb3b44b219d61688e342a3de16ba3f6e1141ea Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 2 Aug 2025 12:26:36 -0700 Subject: [PATCH] Accept wallet id as optional input instead of reassigning after the fact during import. --- src/lib/wallet.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index 541221d..9b971a2 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -147,8 +147,7 @@ export class Wallet { throw new Error('Invalid wallet type from database') } Wallet.#isInternal = true - const self = new this(type) - self.#id = id + const self = new this(type, id) return self } catch (err) { throw new Error('Failed to restore wallet', { cause: err }) @@ -195,13 +194,13 @@ export class Wallet { } } - constructor (type: WalletType) { + constructor (type: WalletType, id?: string) { if (!Wallet.#isInternal && type !== 'Ledger') { throw new Error(`Wallet cannot be instantiated directly. Use 'await Wallet.create()' instead.`) } Wallet.#isInternal = false this.#accounts = new AccountList() - this.#id = crypto.randomUUID() + this.#id = id ?? crypto.randomUUID() this.#safe = new WorkerQueue(type === 'Ledger' ? '' : SafeWorker) this.#type = type } -- 2.47.3