}\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
+ if (typeof id !== 'string' || id === '') {\r
+ throw new TypeError('Wallet ID is required to restore')\r
+ }\r
+ LedgerWallet.#isInternal = true\r
+ const wallet = new this(await Entropy.import(id))\r
+ await wallet.init()\r
+ return wallet\r
+ }\r
+\r
/**\r
* Sign a block with the Ledger device.\r
*\r
}\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
- if (typeof id !== 'string' || id === '') {\r
- throw new TypeError('Wallet ID is required to restore')\r
- }\r
- LedgerWallet.#isInternal = true\r
- const wallet = new this(await Entropy.import(id))\r
- await wallet.init()\r
- return wallet\r
- }\r
-\r
/**\r
* Attempts to connect to the Ledger device.\r
*\r
return new Promise(r => setTimeout(r, 1000, { status: LEDGER_STATUS_CODES[response] }))\r
}\r
\r
- /**\r
- * Get the version of the current process. If a specific app is running, get\r
- * the app version. Otherwise, get the Ledger BOLOS version instead.\r
- *\r
- * https://developers.ledger.com/docs/connectivity/ledgerJS/open-close-info-on-apps#get-information\r
- *\r
- * @returns Status, process name, and version\r
- */\r
- async #version (): Promise<LedgerVersionResponse> {\r
- const transport = await this.DynamicTransport.create(this.openTimeout, this.listenTimeout)\r
- const response = await transport\r
- .send(0xb0, LEDGER_ADPU_CODES.version, LEDGER_ADPU_CODES.paramUnused, LEDGER_ADPU_CODES.paramUnused)\r
- .catch(err => dec.toBytes(err.statusCode)) as Uint8Array\r
- await transport.close()\r
-\r
- const statusCode = bytes.toDec(response.slice(-2)) as number\r
- const status = LEDGER_STATUS_CODES[statusCode] ?? 'UNKNOWN_ERROR'\r
- if (status !== 'OK') {\r
- return { status, name: null, version: null }\r
- }\r
-\r
- const nameLength = response[1]\r
- const name = response.slice(2, 2 + nameLength).toString()\r
- const versionLength = response[2 + nameLength]\r
- const version = response.slice(2 + nameLength + 1, 2 + nameLength + 1 + versionLength).toString()\r
-\r
- return { status, name, version }\r
- }\r
-\r
/**\r
* Request an account at a specific BIP-44 index.\r
*\r
throw new Error('Unexpected byte length from device signature', { cause: response })\r
}\r
\r
+ /**\r
+ * Get the version of the current process. If a specific app is running, get\r
+ * the app version. Otherwise, get the Ledger BOLOS version instead.\r
+ *\r
+ * https://developers.ledger.com/docs/connectivity/ledgerJS/open-close-info-on-apps#get-information\r
+ *\r
+ * @returns Status, process name, and version\r
+ */\r
+ async #version (): Promise<LedgerVersionResponse> {\r
+ const transport = await this.DynamicTransport.create(this.openTimeout, this.listenTimeout)\r
+ const response = await transport\r
+ .send(0xb0, LEDGER_ADPU_CODES.version, LEDGER_ADPU_CODES.paramUnused, LEDGER_ADPU_CODES.paramUnused)\r
+ .catch(err => dec.toBytes(err.statusCode)) as Uint8Array\r
+ await transport.close()\r
+\r
+ const statusCode = bytes.toDec(response.slice(-2)) as number\r
+ const status = LEDGER_STATUS_CODES[statusCode] ?? 'UNKNOWN_ERROR'\r
+ if (status !== 'OK') {\r
+ return { status, name: null, version: null }\r
+ }\r
+\r
+ const nameLength = response[1]\r
+ const name = response.slice(2, 2 + nameLength).toString()\r
+ const versionLength = response[2 + nameLength]\r
+ const version = response.slice(2 + nameLength + 1, 2 + nameLength + 1 + versionLength).toString()\r
+\r
+ return { status, name, version }\r
+ }\r
+\r
/**\r
* Gets the public key for an account from the Ledger device.\r
*\r