\r
get ledger () { return this.#ledger }\r
\r
- constructor (ledger: Ledger) {\r
+ constructor (ledger: Ledger, id?: string) {\r
if (!LedgerWallet.#isInternal) {\r
throw new Error(`LedgerWallet cannot be instantiated directly. Use 'await LedgerWallet.create()' instead.`)\r
}\r
- super()\r
+ super(undefined, undefined, id)\r
this.#ledger = ledger\r
LedgerWallet.#isInternal = false\r
}\r
return new this(l)\r
}\r
\r
+ /**\r
+ * Retrieves an existing Ledger wallet from session storage using its ID.\r
+ *\r
+ * @param {string} id - Generated when the wallet was initially created\r
+ * @returns {LedgerWallet} Restored LedgerWallet\r
+ */\r
+ static async restore (id: string): Promise<LedgerWallet> {\r
+ LedgerWallet.#isInternal = true\r
+ if (typeof id !== 'string' || id === '') {\r
+ throw new TypeError('Wallet ID is required to restore')\r
+ }\r
+ const { Ledger } = await import('./ledger.js')\r
+ const l = await Ledger.init()\r
+ return new this(l, id)\r
+ }\r
+\r
/**\r
* Gets the public key for an account from the Ledger device.\r
*\r