Assets support WIP

refs #37
This commit is contained in:
softsimon
2020-05-02 12:36:35 +07:00
parent b2d2fd225c
commit 11b1d9bbd3
12 changed files with 110 additions and 41 deletions

View File

@@ -70,10 +70,22 @@
</ng-template>
</td>
<td class="text-right nowrap">
<app-amount [satoshis]="vout.value"></app-amount>
<ng-template [ngIf]="vout.asset && vout.scriptpubkey_type === 'op_return' && vout.asset !== nativeAssetId" [ngIfElse]="defaultOutput">
<div *ngIf="assetsMinimal && assetsMinimal[vout.asset]">
{{ vout.value / 100000000 | number: '1.0-' + assetsMinimal[vout.asset][3] }} {{ assetsMinimal[vout.asset][1] }}
<br>
{{ assetsMinimal[vout.asset][0] }}
<br>
<a [routerLink]="['/asset/', vout.asset]">{{ vout.asset | shortenString : 13 }}</a>
<br><br>
</div>
</ng-template>
<ng-template #defaultOutput>
<app-amount [satoshis]="vout.value"></app-amount>
</ng-template>
</td>
<td class="pl-1 arrow-td">
<i *ngIf="!outspends[i]; else outspend" class="arrow grey"></i>
<i *ngIf="!outspends[i] || vout.scriptpubkey_type === 'op_return' || vout.scriptpubkey_type === 'fee' ; else outspend" class="arrow grey"></i>
<ng-template #outspend>
<i *ngIf="!outspends[i][vindex] || !outspends[i][vindex].spent; else spent" class="arrow green"></i>
<ng-template #spent>
@@ -97,7 +109,10 @@
&nbsp;
</span>
<button type="button" class="btn btn-sm btn-primary mt-3" (click)="switchCurrency()">
<app-amount [satoshis]="getTotalTxOutput(tx)"></app-amount>
<ng-template [ngIf]="network === 'liquid'" [ngIfElse]="defaultAmount">Confidential</ng-template>
<ng-template #defaultAmount>
<app-amount [satoshis]="getTotalTxOutput(tx)"></app-amount>
</ng-template>
</button>
</td>
</tr>

View File

@@ -3,6 +3,8 @@ import { StateService } from '../../services/state.service';
import { Observable, forkJoin } from 'rxjs';
import { Block, Outspend, Transaction } from '../../interfaces/electrs.interface';
import { ElectrsApiService } from '../../services/electrs-api.service';
import { environment } from 'src/environments/environment';
import { AssetsService } from 'src/app/services/assets.service';
@Component({
selector: 'app-transactions-list',
@@ -11,6 +13,9 @@ import { ElectrsApiService } from '../../services/electrs-api.service';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TransactionsListComponent implements OnInit, OnChanges {
network = environment.network;
nativeAssetId = environment.nativeAssetId;
@Input() transactions: Transaction[];
@Input() showConfirmations = false;
@Input() transactionPage = false;
@@ -19,15 +24,20 @@ export class TransactionsListComponent implements OnInit, OnChanges {
latestBlock$: Observable<Block>;
outspends: Outspend[] = [];
assetsMinimal: any;
constructor(
private stateService: StateService,
private electrsApiService: ElectrsApiService,
private assetsService: AssetsService,
private ref: ChangeDetectorRef,
) { }
ngOnInit() {
this.latestBlock$ = this.stateService.blocks$;
this.assetsService.assetsMinimal$.subscribe((assets) => {
this.assetsMinimal = assets;
});
}
ngOnChanges() {
@@ -66,6 +76,9 @@ export class TransactionsListComponent implements OnInit, OnChanges {
}
switchCurrency() {
if (this.network === 'liquid') {
return;
}
const oldvalue = !this.stateService.viewFiat$.value;
this.stateService.viewFiat$.next(oldvalue);
}