throw new Error('Invalid wallet type from database')\r
}\r
Wallet.#isInternal = true\r
- const self = new this(type)\r
- self.#id = id\r
+ const self = new this(type, id)\r
return self\r
} catch (err) {\r
throw new Error('Failed to restore wallet', { cause: err })\r
}\r
}\r
\r
- constructor (type: WalletType) {\r
+ constructor (type: WalletType, id?: string) {\r
if (!Wallet.#isInternal && type !== 'Ledger') {\r
throw new Error(`Wallet cannot be instantiated directly. Use 'await Wallet.create()' instead.`)\r
}\r
Wallet.#isInternal = false\r
this.#accounts = new AccountList()\r
- this.#id = crypto.randomUUID()\r
+ this.#id = id ?? crypto.randomUUID()\r
this.#safe = new WorkerQueue(type === 'Ledger' ? '' : SafeWorker)\r
this.#type = type\r
}\r