]> git.codecow.com Git - libnemo.git/commitdiff
Alphabetize methods.
authorChris Duncan <chris@zoso.dev>
Fri, 11 Jul 2025 06:02:06 +0000 (23:02 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 11 Jul 2025 06:02:06 +0000 (23:02 -0700)
src/lib/wallets/ledger-wallet.ts

index 492a4ad8e7ee02b5b3f049b81b730bd9c06b7c4b..dbf630d09ff79be7c8c1c10e294a7676954b9c94 100644 (file)
@@ -198,6 +198,22 @@ export class LedgerWallet extends Wallet {
                }\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
@@ -228,22 +244,6 @@ export class LedgerWallet extends Wallet {
                }\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
@@ -348,35 +348,6 @@ export class LedgerWallet extends Wallet {
                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
@@ -529,6 +500,35 @@ export class LedgerWallet extends Wallet {
                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