From f466498988174fc5beb4ab07aa5ffc12cc04fa71 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 6 Mar 2022 13:50:01 +0100 Subject: [PATCH] Address page highlight and transfer value --- .../components/address/address.component.html | 2 +- .../components/amount/amount.component.html | 4 ++-- .../app/components/amount/amount.component.ts | 1 + .../transactions-list.component.html | 24 +++++++++++++------ .../transactions-list.component.scss | 12 +++++++++- .../transactions-list.component.ts | 24 +++++++++++++++---- .../src/app/interfaces/electrs.interface.ts | 2 +- 7 files changed, 53 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/components/address/address.component.html b/frontend/src/app/components/address/address.component.html index c61680ff4..0c030f5de 100644 --- a/frontend/src/app/components/address/address.component.html +++ b/frontend/src/app/components/address/address.component.html @@ -62,7 +62,7 @@ - +
diff --git a/frontend/src/app/components/amount/amount.component.html b/frontend/src/app/components/amount/amount.component.html index 07f669a81..c4946ddf8 100644 --- a/frontend/src/app/components/amount/amount.component.html +++ b/frontend/src/app/components/amount/amount.component.html @@ -1,12 +1,12 @@ - {{ conversions.USD * (satoshis / 100000000) | currency:'USD':'symbol':'1.2-2' }} + {{ addPlus && satoshis >= 0 ? '+' : '' }}{{ conversions.USD * (satoshis / 100000000) | currency:'USD':'symbol':'1.2-2' }} Confidential - ‎{{ satoshis / 100000000 | number : digitsInfo }} + ‎{{ addPlus && satoshis >= 0 ? '+' : '' }}{{ satoshis / 100000000 | number : digitsInfo }} L- tL- t diff --git a/frontend/src/app/components/amount/amount.component.ts b/frontend/src/app/components/amount/amount.component.ts index 068acf1a7..f9bba4318 100644 --- a/frontend/src/app/components/amount/amount.component.ts +++ b/frontend/src/app/components/amount/amount.component.ts @@ -18,6 +18,7 @@ export class AmountComponent implements OnInit, OnDestroy { @Input() satoshis: number; @Input() digitsInfo = '1.8-8'; @Input() noFiat = false; + @Input() addPlus = false; constructor( private stateService: StateService, diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.html b/frontend/src/app/components/transactions-list/transactions-list.component.html index 1470e6211..790f38cfc 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.html +++ b/frontend/src/app/components/transactions-list/transactions-list.component.html @@ -21,7 +21,10 @@ - +
@@ -143,7 +146,10 @@ - +
{{ vout.scriptpubkey_address | shortenString : 16 }} @@ -242,13 +248,13 @@ -
+
{{ tx.fee / (tx.weight / 4) | feeRounding }} sat/vB  – {{ tx.fee | number }} sat
- + -   - - + + +
diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.scss b/frontend/src/app/components/transactions-list/transactions-list.component.scss index 5a96d2d3c..4f20be835 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.scss +++ b/frontend/src/app/components/transactions-list/transactions-list.component.scss @@ -1,10 +1,12 @@ .arrow-td { width: 20px; + padding-top: 0; + padding-bottom: 0; } .green, .grey, .red { font-size: 16px; - top: -2px; + top: 1px; position: relative; @media( min-width: 576px){ font-size: 19px; @@ -119,3 +121,11 @@ h2 { line-height: 1; } + +.highlight { + background-color: #181b2d; +} + +.summary { + margin-top: 10px; +} diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.ts b/frontend/src/app/components/transactions-list/transactions-list.component.ts index 7d3c5d0e4..63c5c7367 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.ts +++ b/frontend/src/app/components/transactions-list/transactions-list.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit, Input, ChangeDetectionStrategy, OnChanges, Output, EventEmitter, ChangeDetectorRef } from '@angular/core'; import { StateService } from '../../services/state.service'; -import { Observable, forkJoin, ReplaySubject, BehaviorSubject, merge, of, Subject, Subscription } from 'rxjs'; -import { Outspend, Transaction } from '../../interfaces/electrs.interface'; +import { Observable, forkJoin, ReplaySubject, BehaviorSubject, merge, Subscription } from 'rxjs'; +import { Outspend, Transaction, Vin, Vout } 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'; -import { map, share, switchMap, tap } from 'rxjs/operators'; +import { map, switchMap } from 'rxjs/operators'; import { BlockExtended } from 'src/app/interfaces/node-api.interface'; @Component({ @@ -23,6 +23,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { @Input() transactionPage = false; @Input() errorUnblinded = false; @Input() outputIndex: number; + @Input() address: string = ''; @Output() loadMore = new EventEmitter(); @@ -98,6 +99,21 @@ export class TransactionsListComponent implements OnInit, OnChanges { if (this.outspends[i]) { return; } + + if (this.address) { + const addressIn = tx.vout + .filter((v: Vout) => v.scriptpubkey_address === this.address) + .map((v: Vout) => v.value || 0) + .reduce((a: number, b: number) => a + b, 0); + + const addressOut = tx.vin + .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey_address === this.address) + .map((v: Vin) => v.prevout.value || 0) + .reduce((a: number, b: number) => a + b, 0); + + tx['addressValue'] = addressIn || -addressOut; + } + observableObject[i] = this.electrsApiService.getOutspends$(tx.txid); }); this.refreshOutspends$.next(observableObject); @@ -119,7 +135,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { } getTotalTxOutput(tx: Transaction) { - return tx.vout.map((v: any) => v.value || 0).reduce((a: number, b: number) => a + b); + return tx.vout.map((v: Vout) => v.value || 0).reduce((a: number, b: number) => a + b); } switchCurrency() { diff --git a/frontend/src/app/interfaces/electrs.interface.ts b/frontend/src/app/interfaces/electrs.interface.ts index 803a7227e..ecd0ac598 100644 --- a/frontend/src/app/interfaces/electrs.interface.ts +++ b/frontend/src/app/interfaces/electrs.interface.ts @@ -72,7 +72,7 @@ export interface Vout { scriptpubkey: string; scriptpubkey_asm: string; scriptpubkey_type: string; - scriptpubkey_address: string; + scriptpubkey_address?: string; value: number; // Elements valuecommitment?: number;