Handle incompatible hardware
This commit is contained in:
parent
ee724db27e
commit
5e6257f012
3 changed files with 18 additions and 18 deletions
|
|
@ -52,10 +52,6 @@ export class LedgerService {
|
|||
};
|
||||
|
||||
constructor() {
|
||||
(TransportNodeBle.availability as Observable<boolean>).subscribe(available => {
|
||||
console.log('availability changed', available);
|
||||
this.ledgerMessage$.next({ event: 'bluetooth-ready', data: available });
|
||||
})
|
||||
}
|
||||
|
||||
// Reset connection to the ledger device, update the status
|
||||
|
|
@ -84,7 +80,7 @@ export class LedgerService {
|
|||
error: (e) => reject(e),
|
||||
complete: () => {
|
||||
if (!found) {
|
||||
reject('No device found');
|
||||
reject(new Error('No device found'));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -121,10 +117,10 @@ export class LedgerService {
|
|||
}
|
||||
|
||||
let resolved = false;
|
||||
if (this.ledger.status === LedgerStatus.READY) {
|
||||
this.ledgerStatus$.next({ status: this.ledger.status, statusText: 'Ledger device already ready' });
|
||||
return true; // Already ready?
|
||||
}
|
||||
// if (this.ledger.status === LedgerStatus.READY) {
|
||||
// this.ledgerStatus$.next({ status: this.ledger.status, statusText: 'Ledger device already ready' });
|
||||
// return true; // Already ready?
|
||||
// }
|
||||
|
||||
setTimeout(() => {
|
||||
if (resolved || this.ledger.status === LedgerStatus.READY) return;
|
||||
|
|
|
|||
|
|
@ -314,7 +314,12 @@
|
|||
<div class="uk-width-1-1">
|
||||
<h3>Use Ledger Hardware Wallet</h3>
|
||||
<p *ngIf="ledger.status === ledgerStatus.NOT_CONNECTED">
|
||||
Make sure you have the nano app installed and running on your Ledger, then click one of the buttons below to connect via either USB or Bluetooth.<br>
|
||||
Make sure you have the nano app installed and running on your Ledger, then click one of the buttons below to connect via either USB or Bluetooth.<br>
|
||||
<span *ngIf="!ledgerService.isDesktop && !ledgerService.supportsBluetooth">Bluetooth is currently not supported by your browser, please use Chrome, Edge, Opera or Brave</span><br>
|
||||
<span *ngIf="ledgerService.isDesktop">
|
||||
<span *ngIf="ledgerService.supportsBluetooth">For Bluetooth, make sure your Ledger Nano X is already paired to your computer before clicking connect.</span>
|
||||
<span *ngIf="ledgerService.supportsBluetooth">No compatible Bluetooth hardware found. For better compatibility, please try <a href="https://nault.cc" target="_blank" rel="noopener noreferrer">Nault.cc</a> in a browser with Bluetooth support (Chrome, Edge, Opera or Brave).</span>
|
||||
</span><br>
|
||||
<a href="https://docs.nault.cc/2020/08/04/ledger-guide.html" target="_blank" rel="noopener noreferrer">Ledger/Nault User Guide and Troubleshooting</a><br>
|
||||
<br>
|
||||
</p>
|
||||
|
|
@ -338,8 +343,7 @@
|
|||
</div>
|
||||
<p>
|
||||
<b>Ledger Device Not Connected</b><br>
|
||||
Connect your Ledger device and make sure you have the nano app installed and running, then press the button below.<br>
|
||||
<span *ngIf=!ledgerService.supportsBluetooth>Bluetooth is currently not supported by your browser, please use Google Chrome or <a href="https://github.com/Nault/Nault/releases/latest" target="_blank" rel="noopener noreferrer">download the Desktop App</a></span>
|
||||
Make sure you have the nano app installed and running on the device, then press connect.<br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -361,7 +365,7 @@
|
|||
</div>
|
||||
<p>
|
||||
<b>Ledger Device Connected</b><br>
|
||||
Accounts on the Ledger were imported successfully, and the device is ready for use.
|
||||
Accounts imported successfully.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import TransportU2F from '@ledgerhq/hw-transport-u2f';
|
|||
import TransportUSB from '@ledgerhq/hw-transport-webusb';
|
||||
import TransportHID from '@ledgerhq/hw-transport-webhid';
|
||||
import TransportBLE from '@ledgerhq/hw-transport-web-ble';
|
||||
import TransportNodeBLE from '@ledgerhq/hw-transport-node-ble';
|
||||
import Transport from '@ledgerhq/hw-transport';
|
||||
import * as LedgerLogs from '@ledgerhq/logs';
|
||||
import {Observable, Subject} from 'rxjs';
|
||||
|
|
@ -116,11 +115,10 @@ export class LedgerService {
|
|||
case 'sign-block':
|
||||
this.desktopMessage$.next(message);
|
||||
break;
|
||||
case 'bluetooth-ready':
|
||||
this.supportsBluetooth = message.data
|
||||
}
|
||||
});
|
||||
this.supportsUSB = true;
|
||||
this.supportsBluetooth = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -301,6 +299,9 @@ export class LedgerService {
|
|||
const sub = this.ledgerStatus$.subscribe(newStatus => {
|
||||
if (newStatus.status === LedgerStatus.READY) {
|
||||
resolve(true);
|
||||
} else if (newStatus.statusText.includes('No compatible USB Bluetooth 4.0 device found') || newStatus.statusText.includes('Could not start scanning')) {
|
||||
this.supportsBluetooth = false;
|
||||
reject(newStatus.statusText);
|
||||
} else {
|
||||
reject(new Error(newStatus.statusText || `Unable to load desktop Ledger device`));
|
||||
}
|
||||
|
|
@ -360,6 +361,7 @@ export class LedgerService {
|
|||
resolved = true;
|
||||
|
||||
if (!ledgerConfig) return resolve(false);
|
||||
console.log('ledgerConfig', ledgerConfig)
|
||||
if (ledgerConfig && ledgerConfig.version) {
|
||||
this.ledger.status = LedgerStatus.LOCKED;
|
||||
this.ledgerStatus$.next({ status: this.ledger.status, statusText: `Nano app detected, but ledger is locked` });
|
||||
|
|
@ -379,7 +381,6 @@ export class LedgerService {
|
|||
// Attempt to load account 0 - which confirms the app is unlocked and ready
|
||||
try {
|
||||
const accountDetails = await this.getLedgerAccount(0);
|
||||
console.log('accountDetails', accountDetails);
|
||||
this.ledger.status = LedgerStatus.READY;
|
||||
this.ledgerStatus$.next({ status: this.ledger.status, statusText: `Nano Ledger application connected` });
|
||||
|
||||
|
|
@ -499,7 +500,6 @@ export class LedgerService {
|
|||
|
||||
try {
|
||||
const accountDetails = await this.getLedgerAccount(0);
|
||||
console.log('Polling - accountDetails', accountDetails);
|
||||
this.ledger.status = LedgerStatus.READY;
|
||||
} catch (err) {
|
||||
// Ignore race condition error, which means an action is pending on the ledger (such as block confirmation)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue