Display tx data on bisq transaction page.

This commit is contained in:
softsimon 2020-07-19 15:28:27 +07:00
parent cca69556d0
commit ee6108ccec
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 50 additions and 14 deletions

View File

@ -27,17 +27,37 @@
<i> (<app-time-since [time]="bisqTx.time / 1000" [fastRender]="true"></app-time-since> ago)</i> <i> (<app-time-since [time]="bisqTx.time / 1000" [fastRender]="true"></app-time-since> ago)</i>
</td> </td>
</tr> </tr>
<tr>
<td class="td-width">Features</td>
<td>
<app-tx-features *ngIf="tx; else loadingTx" [tx]="tx"></app-tx-features>
<ng-template #loadingTx>
<span class="skeleton-loader"></span>
</ng-template>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="col-sm"> <div class="col-sm">
<table class="table table-borderless table-striped"> <table class="table table-borderless table-striped">
<tbody> <tbody>
<tr> <tr>
<td class="td-width">Burnt</td> <td class="td-width">Burnt</td>
<td> <td>
{{ bisqTx.burntFee / 100 | number: '1.2-2' }} BSQ (<app-bsq-amount [bsq]="bisqTx.burntFee" [forceFiat]="true" [green]="true"></app-bsq-amount>) {{ bisqTx.burntFee / 100 | number: '1.2-2' }} BSQ (<app-bsq-amount [bsq]="bisqTx.burntFee" [forceFiat]="true" [green]="true"></app-bsq-amount>)
</tr> </tr>
<tr>
<td>Fee per vByte</td>
<td *ngIf="!isLoadingTx; else loadingTxFee">
{{ tx.fee / (tx.weight / 4) | number : '1.1-1' }} sat/vB
&nbsp;
<app-tx-fee-rating [tx]="tx"></app-tx-fee-rating>
</td>
<ng-template #loadingTxFee>
<td><span class="skeleton-loader"></span></td>
</ng-template>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -4,7 +4,7 @@ import { BisqTransaction } from 'src/app/bisq/bisq.interfaces';
import { switchMap, map, catchError } from 'rxjs/operators'; import { switchMap, map, catchError } from 'rxjs/operators';
import { of, Observable, Subscription } from 'rxjs'; import { of, Observable, Subscription } from 'rxjs';
import { StateService } from 'src/app/services/state.service'; import { StateService } from 'src/app/services/state.service';
import { Block } from 'src/app/interfaces/electrs.interface'; import { Block, Transaction } from 'src/app/interfaces/electrs.interface';
import { BisqApiService } from '../bisq-api.service'; import { BisqApiService } from '../bisq-api.service';
import { SeoService } from 'src/app/services/seo.service'; import { SeoService } from 'src/app/services/seo.service';
import { ElectrsApiService } from 'src/app/services/electrs-api.service'; import { ElectrsApiService } from 'src/app/services/electrs-api.service';
@ -17,10 +17,12 @@ import { HttpErrorResponse } from '@angular/common/http';
}) })
export class BisqTransactionComponent implements OnInit, OnDestroy { export class BisqTransactionComponent implements OnInit, OnDestroy {
bisqTx: BisqTransaction; bisqTx: BisqTransaction;
tx: Transaction;
latestBlock$: Observable<Block>; latestBlock$: Observable<Block>;
txId: string; txId: string;
price: number; price: number;
isLoading = true; isLoading = true;
isLoadingTx = true;
error = null; error = null;
subscription: Subscription; subscription: Subscription;
@ -37,6 +39,7 @@ export class BisqTransactionComponent implements OnInit, OnDestroy {
this.subscription = this.route.paramMap.pipe( this.subscription = this.route.paramMap.pipe(
switchMap((params: ParamMap) => { switchMap((params: ParamMap) => {
this.isLoading = true; this.isLoading = true;
this.isLoadingTx = true;
this.error = null; this.error = null;
document.body.scrollTo(0, 0); document.body.scrollTo(0, 0);
this.txId = params.get('id') || ''; this.txId = params.get('id') || '';
@ -71,21 +74,31 @@ export class BisqTransactionComponent implements OnInit, OnDestroy {
return of(null); return of(null);
}) })
); );
}) }),
switchMap((tx) => {
if (!tx) {
return of(null);
}
if (tx.version) {
this.router.navigate(['/tx/', this.txId], { state: { data: tx, bsqTx: true }});
return of(null);
}
this.bisqTx = tx;
this.isLoading = false;
return this.electrsApiService.getTransaction$(this.txId);
}),
) )
.subscribe((tx) => { .subscribe((tx) => {
this.isLoading = false; this.isLoadingTx = false;
if (!tx) { if (!tx) {
return; return;
} }
if (tx.version) { this.tx = tx;
this.router.navigate(['/tx/', this.txId], { state: { data: tx, bsqTx: true }});
return;
}
this.bisqTx = tx;
}, },
(error) => { (error) => {
this.error = error; this.error = error;

View File

@ -21,6 +21,9 @@ export class TxFeaturesComponent implements OnChanges {
constructor() { } constructor() { }
ngOnChanges() { ngOnChanges() {
if (!this.tx) {
return;
}
this.segwitGains = calcSegwitFeeGains(this.tx); this.segwitGains = calcSegwitFeeGains(this.tx);
this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe); this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe);
} }