From: Chris Duncan Date: Sat, 2 Aug 2025 19:26:36 +0000 (-0700) Subject: Accept wallet id as optional input instead of reassigning after the fact during import. X-Git-Tag: v0.10.5~47^2~7 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=08cb3b44b219d61688e342a3de16ba3f6e1141ea;p=libnemo.git Accept wallet id as optional input instead of reassigning after the fact during import. --- 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 }