]> git.codecow.com Git - libnemo.git/commitdiff
Fix ledger environment check.
authorChris Duncan <chris@zoso.dev>
Sat, 26 Jul 2025 07:58:48 +0000 (00:58 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 26 Jul 2025 07:58:48 +0000 (00:58 -0700)
src/lib/wallets/ledger-wallet.ts

index ce1b009e9afdb88d9a3199e6448251333802f0fe..e9f01cdc131b2f59dd6d7d33ddf4c5bae6b7ef15 100644 (file)
@@ -27,7 +27,7 @@ export class LedgerWallet extends Wallet {
                ...dec.toBytes(BIP44_COIN_NANO + HARDENED_OFFSET, 4)\r
        ])\r
 \r
-       static DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID = this.checkBrowserSupport()\r
+       static DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID\r
        static get listenTimeout (): 30000 { return 30000 }\r
        static get openTimeout (): 3000 { return 3000 }\r
 \r
@@ -35,20 +35,17 @@ export class LedgerWallet extends Wallet {
        * Check which transport protocols are supported by the browser and return the\r
        * transport type according to the following priorities: Bluetooth, USB, HID.\r
        */\r
-       static checkBrowserSupport (): typeof TransportBLE | typeof TransportUSB | typeof TransportHID {\r
+       static checkBrowserSupport (): void {\r
                console.log('Checking browser Ledger support...')\r
-               try {\r
-                       if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') {\r
-                               return TransportBLE\r
-                       }\r
-                       if (typeof globalThis.navigator?.usb?.getDevices === 'function') {\r
-                               return TransportUSB\r
-                       }\r
-                       if (typeof globalThis.navigator?.hid?.getDevices === 'function') {\r
-                               return TransportHID\r
-                       }\r
-               } catch { }\r
-               throw new Error('Unsupported browser')\r
+               if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') {\r
+                       this.DynamicTransport = TransportBLE\r
+               }\r
+               if (typeof globalThis.navigator?.usb?.getDevices === 'function') {\r
+                       this.DynamicTransport = TransportUSB\r
+               }\r
+               if (typeof globalThis.navigator?.hid?.getDevices === 'function') {\r
+                       this.DynamicTransport = TransportHID\r
+               }\r
        }\r
 \r
        /**\r