Various fixes
This commit is contained in:
parent
beeb79020b
commit
c2cc2fd612
4 changed files with 24 additions and 24 deletions
|
|
@ -317,7 +317,6 @@
|
|||
<p>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.</p>
|
||||
<p *ngIf="!ledgerService.isDesktop && !ledgerService.supportsBluetooth">Bluetooth is currently not supported by your browser, please use Chrome, Edge, Opera or Brave</p>
|
||||
<p *ngIf="ledgerService.isDesktop">
|
||||
<span *ngIf="ledgerService.supportsBluetooth">For Bluetooth, Your Ledger Nano X must already be 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>
|
||||
</p>
|
||||
<p><a href="https://docs.nault.cc/2020/08/04/ledger-guide.html" target="_blank" rel="noopener noreferrer">Ledger/Nault User Guide and Troubleshooting</a></p>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div *ngIf="walletService.isLedgerWallet()">
|
||||
<div class="nav-status-row" *ngIf="ledgerStatus === 'not-connected' || !ledgerStatus">
|
||||
<div class="nav-status-row" *ngIf="ledgerStatus.status === 'not-connected' || !ledgerStatus.status">
|
||||
<div class="status-icon">
|
||||
<span class="uk-text-warning" uk-icon="icon: warning; ratio: 1.2;"></span>
|
||||
</div>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<div class="label secondary"><a (click)="reloadLedger()">Reconnect</a> or <a href="https://docs.nault.cc/2020/08/04/ledger-guide.html#troubleshooting" target="_blank" rel="noopener noreferrer">view Troubleshooting Guide</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-status-row" *ngIf="( ledgerStatus === 'locked' )">
|
||||
<div class="nav-status-row" *ngIf="( ledgerStatus.status === 'locked' )">
|
||||
<div class="status-icon">
|
||||
<span class="uk-text-warning" uk-icon="icon: warning; ratio: 1.2;"></span>
|
||||
</div>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<div class="label secondary">Unlock the device, then <a (click)="reloadLedger()">click here</a> to reconnect</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-status-row interactable" (click)="reloadLedger()" *ngIf="( ledgerStatus === 'ready' )">
|
||||
<div class="nav-status-row interactable" (click)="reloadLedger()" *ngIf="( ledgerStatus.status === 'ready' )">
|
||||
<div class="status-icon">
|
||||
<span class="uk-text-success" uk-icon="icon: bolt; ratio: 1.2;"></span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ import {PowService} from '../../services/pow.service';
|
|||
export class WalletWidgetComponent implements OnInit {
|
||||
wallet = this.walletService.wallet;
|
||||
|
||||
ledgerStatus = 'not-connected';
|
||||
ledgerStatus = {
|
||||
status: 'not-connected',
|
||||
statusText: '',
|
||||
}
|
||||
powAlert = false;
|
||||
|
||||
unlockPassword = '';
|
||||
|
|
@ -36,8 +39,8 @@ export class WalletWidgetComponent implements OnInit {
|
|||
const modal = UIkit.modal(document.getElementById('unlock-wallet-modal'));
|
||||
this.modal = modal;
|
||||
|
||||
this.ledgerService.ledgerStatus$.subscribe((ledgerStatus: any) => {
|
||||
this.ledgerStatus = ledgerStatus.status;
|
||||
this.ledgerService.ledgerStatus$.subscribe((ledgerStatus) => {
|
||||
this.ledgerStatus = ledgerStatus;
|
||||
});
|
||||
// Detect if a PoW is taking too long and alert
|
||||
this.powService.powAlert$.subscribe(async shouldAlert => {
|
||||
|
|
@ -74,7 +77,7 @@ export class WalletWidgetComponent implements OnInit {
|
|||
try {
|
||||
await this.ledgerService.loadLedger();
|
||||
this.notificationService.removeNotification('ledger-status');
|
||||
if (this.ledgerStatus === LedgerStatus.READY) {
|
||||
if (this.ledgerStatus.status === LedgerStatus.READY) {
|
||||
this.notificationService.sendSuccess(`Successfully connected to Ledger device`);
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export class LedgerService {
|
|||
transportMode: 'U2F' | 'USB' | 'HID' | 'Bluetooth' = 'U2F';
|
||||
DynamicTransport = TransportU2F;
|
||||
|
||||
ledgerStatus$: Subject<any> = new Subject();
|
||||
ledgerStatus$: Subject<{ status: string, statusText: string }> = new Subject();
|
||||
desktopMessage$ = new Subject();
|
||||
|
||||
constructor(private api: ApiService,
|
||||
|
|
@ -138,14 +138,8 @@ export class LedgerService {
|
|||
* Detect the optimal USB transport protocol for the current browser and OS
|
||||
*/
|
||||
detectUsbTransport() {
|
||||
const isWindows = window.navigator.platform.includes('Win');
|
||||
|
||||
if (isWindows && this.supportsWebHID) {
|
||||
// Prefer WebHID on Windows due to stability issues with WebUSB
|
||||
this.transportMode = 'HID';
|
||||
this.DynamicTransport = TransportHID;
|
||||
} else if (this.supportsWebUSB) {
|
||||
// Else prefer WebUSB
|
||||
if (this.supportsWebUSB) {
|
||||
// Prefer WebUSB
|
||||
this.transportMode = 'USB';
|
||||
this.DynamicTransport = TransportUSB;
|
||||
} else if (this.supportsWebHID) {
|
||||
|
|
@ -327,6 +321,9 @@ export class LedgerService {
|
|||
console.log(`Error loading ${this.transportMode} transport `, err);
|
||||
this.ledger.status = LedgerStatus.NOT_CONNECTED;
|
||||
this.ledgerStatus$.next({ status: this.ledger.status, statusText: `Unable to load Ledger transport: ${err.message || err}` });
|
||||
if (!hideNotifications) {
|
||||
this.notifications.sendWarning(`Ledger transport failed. Make sure your Ledger is unlocked. Restart the nano app on your Ledger if the error persists`);
|
||||
}
|
||||
}
|
||||
this.resetLedger();
|
||||
resolve(false);
|
||||
|
|
@ -361,13 +358,10 @@ 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` });
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(`App config error: `, err);
|
||||
this.ledger.status = LedgerStatus.NOT_CONNECTED;
|
||||
this.ledgerStatus$.next({ status: this.ledger.status, statusText: `Unable to load Nano App configuration: ${err.message || err}` });
|
||||
if (err.statusText === 'HALTED') {
|
||||
this.resetLedger();
|
||||
}
|
||||
|
|
@ -504,8 +498,12 @@ export class LedgerService {
|
|||
} catch (err) {
|
||||
// Ignore race condition error, which means an action is pending on the ledger (such as block confirmation)
|
||||
if (err.name !== 'TransportRaceCondition') {
|
||||
console.log('Check ledger status failed ', err);
|
||||
this.ledger.status = LedgerStatus.NOT_CONNECTED;
|
||||
console.log('Check ledger status failed ', JSON.stringify(err));
|
||||
if (err.statusCode === STATUS_CODES.SECURITY_STATUS_NOT_SATISFIED) {
|
||||
this.ledger.status = LedgerStatus.LOCKED;
|
||||
} else {
|
||||
this.ledger.status = LedgerStatus.NOT_CONNECTED;
|
||||
}
|
||||
this.pollingLedger = false;
|
||||
this.resetLedger();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue