From c3206827b3b9aa87badbd752f2b47fd1f3d3917b Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 26 Jul 2025 00:58:48 -0700 Subject: [PATCH] Fix ledger environment check. --- src/lib/wallets/ledger-wallet.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/lib/wallets/ledger-wallet.ts b/src/lib/wallets/ledger-wallet.ts index ce1b009..e9f01cd 100644 --- a/src/lib/wallets/ledger-wallet.ts +++ b/src/lib/wallets/ledger-wallet.ts @@ -27,7 +27,7 @@ export class LedgerWallet extends Wallet { ...dec.toBytes(BIP44_COIN_NANO + HARDENED_OFFSET, 4) ]) - static DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID = this.checkBrowserSupport() + static DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID static get listenTimeout (): 30000 { return 30000 } static get openTimeout (): 3000 { return 3000 } @@ -35,20 +35,17 @@ export class LedgerWallet extends Wallet { * Check which transport protocols are supported by the browser and return the * transport type according to the following priorities: Bluetooth, USB, HID. */ - static checkBrowserSupport (): typeof TransportBLE | typeof TransportUSB | typeof TransportHID { + static checkBrowserSupport (): void { console.log('Checking browser Ledger support...') - try { - if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') { - return TransportBLE - } - if (typeof globalThis.navigator?.usb?.getDevices === 'function') { - return TransportUSB - } - if (typeof globalThis.navigator?.hid?.getDevices === 'function') { - return TransportHID - } - } catch { } - throw new Error('Unsupported browser') + if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') { + this.DynamicTransport = TransportBLE + } + if (typeof globalThis.navigator?.usb?.getDevices === 'function') { + this.DynamicTransport = TransportUSB + } + if (typeof globalThis.navigator?.hid?.getDevices === 'function') { + this.DynamicTransport = TransportHID + } } /** -- 2.47.3