Merge branch 'master' into mononaut/accelerator-audit-pools
This commit is contained in:
@@ -268,4 +268,134 @@ export const fiatCurrencies = {
|
||||
code: 'USD',
|
||||
indexed: true,
|
||||
},
|
||||
BGN: {
|
||||
name: 'Bulgarian Lev',
|
||||
code: 'BGN',
|
||||
indexed: true,
|
||||
},
|
||||
BRL: {
|
||||
name: 'Brazilian Real',
|
||||
code: 'BRL',
|
||||
indexed: true,
|
||||
},
|
||||
CNY: {
|
||||
name: 'Chinese Yuan',
|
||||
code: 'CNY',
|
||||
indexed: true,
|
||||
},
|
||||
CZK: {
|
||||
name: 'Czech Koruna',
|
||||
code: 'CZK',
|
||||
indexed: true,
|
||||
},
|
||||
DKK: {
|
||||
name: 'Danish Krone',
|
||||
code: 'DKK',
|
||||
indexed: true,
|
||||
},
|
||||
HKD: {
|
||||
name: 'Hong Kong Dollar',
|
||||
code: 'HKD',
|
||||
indexed: true,
|
||||
},
|
||||
HRK: {
|
||||
name: 'Croatian Kuna',
|
||||
code: 'HRK',
|
||||
indexed: true,
|
||||
},
|
||||
HUF: {
|
||||
name: 'Hungarian Forint',
|
||||
code: 'HUF',
|
||||
indexed: true,
|
||||
},
|
||||
IDR: {
|
||||
name: 'Indonesian Rupiah',
|
||||
code: 'IDR',
|
||||
indexed: true,
|
||||
},
|
||||
ILS: {
|
||||
name: 'Israeli Shekel',
|
||||
code: 'ILS',
|
||||
indexed: true,
|
||||
},
|
||||
INR: {
|
||||
name: 'Indian Rupee',
|
||||
code: 'INR',
|
||||
indexed: true,
|
||||
},
|
||||
ISK: {
|
||||
name: 'Icelandic Krona',
|
||||
code: 'ISK',
|
||||
indexed: true,
|
||||
},
|
||||
KRW: {
|
||||
name: 'South Korean Won',
|
||||
code: 'KRW',
|
||||
indexed: true,
|
||||
},
|
||||
MXN: {
|
||||
name: 'Mexican Peso',
|
||||
code: 'MXN',
|
||||
indexed: true,
|
||||
},
|
||||
MYR: {
|
||||
name: 'Malaysian Ringgit',
|
||||
code: 'MYR',
|
||||
indexed: true,
|
||||
},
|
||||
NOK: {
|
||||
name: 'Norwegian Krone',
|
||||
code: 'NOK',
|
||||
indexed: true,
|
||||
},
|
||||
NZD: {
|
||||
name: 'New Zealand Dollar',
|
||||
code: 'NZD',
|
||||
indexed: true,
|
||||
},
|
||||
PHP: {
|
||||
name: 'Philippine Peso',
|
||||
code: 'PHP',
|
||||
indexed: true,
|
||||
},
|
||||
PLN: {
|
||||
name: 'Polish Zloty',
|
||||
code: 'PLN',
|
||||
indexed: true,
|
||||
},
|
||||
RON: {
|
||||
name: 'Romanian Leu',
|
||||
code: 'RON',
|
||||
indexed: true,
|
||||
},
|
||||
RUB: {
|
||||
name: 'Russian Ruble',
|
||||
code: 'RUB',
|
||||
indexed: true,
|
||||
},
|
||||
SEK: {
|
||||
name: 'Swedish Krona',
|
||||
code: 'SEK',
|
||||
indexed: true,
|
||||
},
|
||||
SGD: {
|
||||
name: 'Singapore Dollar',
|
||||
code: 'SGD',
|
||||
indexed: true,
|
||||
},
|
||||
THB: {
|
||||
name: 'Thai Baht',
|
||||
code: 'THB',
|
||||
indexed: true,
|
||||
},
|
||||
TRY: {
|
||||
name: 'Turkish Lira',
|
||||
code: 'TRY',
|
||||
indexed: true,
|
||||
},
|
||||
ZAR: {
|
||||
name: 'South African Rand',
|
||||
code: 'ZAR',
|
||||
indexed: true,
|
||||
},
|
||||
};
|
||||
@@ -50,9 +50,8 @@
|
||||
</td>
|
||||
<td class="status text-right">
|
||||
<span *ngIf="acceleration.status === 'accelerating'" class="badge badge-warning" i18n="accelerator.pending">Pending</span>
|
||||
<span *ngIf="acceleration.status === 'mined'" class="badge badge-info" i18n="transaction.rbf.mined">Mined</span>
|
||||
<span *ngIf="acceleration.status === 'completed'" class="badge badge-success" i18n="">Completed</span>
|
||||
<span *ngIf="acceleration.status === 'failed'" class="badge badge-danger" i18n="accelerator.canceled">Canceled</span>
|
||||
<span *ngIf="acceleration.status.includes('completed')" class="badge badge-success" i18n="">Completed <span *ngIf="acceleration.status === 'completed_provisional'">🔄</span></span>
|
||||
<span *ngIf="acceleration.status.includes('failed')" class="badge badge-danger" i18n="accelerator.canceled">Failed <span *ngIf="acceleration.status === 'failed_provisional'">🔄</span></span>
|
||||
</td>
|
||||
<td class="date text-right" *ngIf="!this.widget">
|
||||
<app-time kind="since" [time]="acceleration.added" [fastRender]="true"></app-time>
|
||||
|
||||
@@ -74,7 +74,7 @@ export class AcceleratorDashboardComponent implements OnInit {
|
||||
|
||||
this.minedAccelerations$ = this.accelerations$.pipe(
|
||||
map(accelerations => {
|
||||
return accelerations.filter(acc => ['mined', 'completed'].includes(acc.status));
|
||||
return accelerations.filter(acc => ['completed_provisional', 'completed'].includes(acc.status));
|
||||
})
|
||||
);
|
||||
|
||||
@@ -103,7 +103,7 @@ export class AcceleratorDashboardComponent implements OnInit {
|
||||
}
|
||||
const accelerationsByBlock: { [ hash: string ]: Acceleration[] } = {};
|
||||
for (const acceleration of accelerations) {
|
||||
if (['mined', 'completed'].includes(acceleration.status) && acceleration.pools.includes(blockMap[acceleration.blockHash]?.extras.pool.id)) {
|
||||
if (['completed_provisional', 'failed_provisional', 'completed'].includes(acceleration.status) && acceleration.pools.includes(blockMap[acceleration.blockHash]?.extras.pool.id)) {
|
||||
if (!accelerationsByBlock[acceleration.blockHash]) {
|
||||
accelerationsByBlock[acceleration.blockHash] = [];
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<app-transactions-list [transactions]="transactions" [paginated]="true"></app-transactions-list>
|
||||
<app-transactions-list [transactions]="transactions" [paginated]="true" [blockTime]="block.timestamp"></app-transactions-list>
|
||||
|
||||
<ng-template [ngIf]="transactionsError">
|
||||
<div class="text-center">
|
||||
|
||||
@@ -533,9 +533,9 @@ export class BlockComponent implements OnInit, OnDestroy {
|
||||
if (this.priceSubscription) {
|
||||
this.priceSubscription.unsubscribe();
|
||||
}
|
||||
this.priceSubscription = block$.pipe(
|
||||
switchMap((block) => {
|
||||
return this.priceService.getBlockPrice$(block.timestamp).pipe(
|
||||
this.priceSubscription = combineLatest([this.stateService.fiatCurrency$, block$]).pipe(
|
||||
switchMap(([currency, block]) => {
|
||||
return this.priceService.getBlockPrice$(block.timestamp, true, currency).pipe(
|
||||
tap((price) => {
|
||||
this.blockConversion = price;
|
||||
})
|
||||
|
||||
@@ -35,6 +35,11 @@ export class FiatSelectorComponent implements OnInit {
|
||||
this.stateService.fiatCurrency$.subscribe((fiat) => {
|
||||
this.fiatForm.get('fiat')?.setValue(fiat);
|
||||
});
|
||||
if (!this.stateService.env.ADDITIONAL_CURRENCIES) {
|
||||
this.currencies = this.currencies.filter((currency: any) => {
|
||||
return ['AUD', 'CAD', 'EUR', 'JPY', 'GBP', 'CHF', 'USD'].includes(currency[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
changeFiat() {
|
||||
|
||||
@@ -533,7 +533,7 @@
|
||||
<tr *ngIf="isMobile && (network === 'liquid' || network === 'liquidtestnet' || !featuresEnabled || network === '')"></tr>
|
||||
<tr>
|
||||
<td class="td-width" i18n="transaction.fee|Transaction fee">Fee</td>
|
||||
<td>{{ tx.fee | number }} <span class="symbol" i18n="shared.sat|sat">sat</span> <span class="fiat"><app-fiat [blockConversion]="blockConversion" [value]="tx.fee"></app-fiat></span></td>
|
||||
<td>{{ tx.fee | number }} <span class="symbol" i18n="shared.sat|sat">sat</span> <span class="fiat"><app-fiat [blockConversion]="tx.price" [value]="tx.fee"></app-fiat></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td i18n="transaction.fee-rate|Transaction fee rate">Fee rate</td>
|
||||
|
||||
@@ -76,6 +76,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
mempoolBlocksSubscription: Subscription;
|
||||
blocksSubscription: Subscription;
|
||||
miningSubscription: Subscription;
|
||||
currencyChangeSubscription: Subscription;
|
||||
fragmentParams: URLSearchParams;
|
||||
rbfTransaction: undefined | Transaction;
|
||||
replaced: boolean = false;
|
||||
@@ -108,7 +109,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
hideFlow: boolean = this.stateService.hideFlow.value;
|
||||
overrideFlowPreference: boolean = null;
|
||||
flowEnabled: boolean;
|
||||
blockConversion: Price;
|
||||
tooltipPosition: { x: number, y: number };
|
||||
isMobile: boolean;
|
||||
|
||||
@@ -281,7 +281,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
})
|
||||
).subscribe((accelerationHistory) => {
|
||||
for (const acceleration of accelerationHistory) {
|
||||
if (acceleration.txid === this.txId && (acceleration.status === 'completed' || acceleration.status === 'mined') && acceleration.feePaid > 0) {
|
||||
if (acceleration.txid === this.txId && (acceleration.status === 'completed' || acceleration.status === 'completed_provisional')) {
|
||||
acceleration.acceleratedFee = Math.max(acceleration.effectiveFee, acceleration.effectiveFee + acceleration.feePaid - acceleration.baseFee - acceleration.vsizeFee);
|
||||
this.accelerationInfo = acceleration;
|
||||
}
|
||||
@@ -493,10 +493,12 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
this.fetchRbfHistory$.next(this.tx.txid);
|
||||
|
||||
this.priceService.getBlockPrice$(tx.status?.block_time, true).pipe(
|
||||
tap((price) => {
|
||||
this.blockConversion = price;
|
||||
this.currencyChangeSubscription?.unsubscribe();
|
||||
this.currencyChangeSubscription = this.stateService.fiatCurrency$.pipe(
|
||||
switchMap((currency) => {
|
||||
return tx.status.block_time ? this.priceService.getBlockPrice$(tx.status.block_time, true, currency).pipe(
|
||||
tap((price) => tx['price'] = price),
|
||||
) : of(undefined);
|
||||
})
|
||||
).subscribe();
|
||||
|
||||
@@ -518,7 +520,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
block_time: block.timestamp,
|
||||
};
|
||||
this.stateService.markBlock$.next({ blockHeight: block.height });
|
||||
if (this.tx.acceleration || (this.accelerationInfo && ['accelerating', 'mined', 'completed'].includes(this.accelerationInfo.status))) {
|
||||
if (this.tx.acceleration || (this.accelerationInfo && ['accelerating', 'completed_provisional', 'completed'].includes(this.accelerationInfo.status))) {
|
||||
this.audioService.playSound('wind-chimes-harp-ascend');
|
||||
} else {
|
||||
this.audioService.playSound('magic');
|
||||
@@ -810,6 +812,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.mempoolBlocksSubscription.unsubscribe();
|
||||
this.blocksSubscription.unsubscribe();
|
||||
this.miningSubscription?.unsubscribe();
|
||||
this.currencyChangeSubscription?.unsubscribe();
|
||||
this.leaveTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,14 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
@Input() outputIndex: number;
|
||||
@Input() address: string = '';
|
||||
@Input() rowLimit = 12;
|
||||
@Input() blockTime: number = 0; // Used for price calculation if all the transactions are in the same block
|
||||
|
||||
@Output() loadMore = new EventEmitter();
|
||||
|
||||
latestBlock$: Observable<BlockExtended>;
|
||||
outspendsSubscription: Subscription;
|
||||
currencyChangeSubscription: Subscription;
|
||||
currency: string;
|
||||
refreshOutspends$: ReplaySubject<string[]> = new ReplaySubject();
|
||||
refreshChannels$: ReplaySubject<string[]> = new ReplaySubject();
|
||||
showDetails$ = new BehaviorSubject<boolean>(false);
|
||||
@@ -125,6 +128,35 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
)
|
||||
,
|
||||
).subscribe(() => this.ref.markForCheck());
|
||||
|
||||
this.currencyChangeSubscription = this.stateService.fiatCurrency$
|
||||
.subscribe(currency => {
|
||||
this.currency = currency;
|
||||
this.refreshPrice();
|
||||
});
|
||||
}
|
||||
|
||||
refreshPrice(): void {
|
||||
// Loop over all transactions
|
||||
if (!this.transactions || !this.transactions.length || !this.currency) {
|
||||
return;
|
||||
}
|
||||
const confirmedTxs = this.transactions.filter((tx) => tx.status.confirmed).length;
|
||||
if (!this.blockTime) {
|
||||
this.transactions.forEach((tx) => {
|
||||
if (!this.blockTime) {
|
||||
if (tx.status.block_time) {
|
||||
this.priceService.getBlockPrice$(tx.status.block_time, confirmedTxs < 10, this.currency).pipe(
|
||||
tap((price) => tx['price'] = price),
|
||||
).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe(
|
||||
tap((price) => this.transactions.forEach((tx) => tx['price'] = price)),
|
||||
).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes): void {
|
||||
@@ -148,6 +180,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
this.transactionsLength = this.transactions.length;
|
||||
this.cacheService.setTxCache(this.transactions);
|
||||
|
||||
const confirmedTxs = this.transactions.filter((tx) => tx.status.confirmed).length;
|
||||
this.transactions.forEach((tx) => {
|
||||
tx['@voutLimit'] = true;
|
||||
tx['@vinLimit'] = true;
|
||||
@@ -197,10 +230,18 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
this.priceService.getBlockPrice$(tx.status.block_time).pipe(
|
||||
tap((price) => tx['price'] = price)
|
||||
).subscribe();
|
||||
if (!this.blockTime && tx.status.block_time && this.currency) {
|
||||
this.priceService.getBlockPrice$(tx.status.block_time, confirmedTxs < 10, this.currency).pipe(
|
||||
tap((price) => tx['price'] = price),
|
||||
).subscribe();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.blockTime && this.transactions?.length && this.currency) {
|
||||
this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe(
|
||||
tap((price) => this.transactions.forEach((tx) => tx['price'] = price)),
|
||||
).subscribe();
|
||||
}
|
||||
const txIds = this.transactions.filter((tx) => !tx._outspends).map((tx) => tx.txid);
|
||||
if (txIds.length && !this.cached) {
|
||||
this.refreshOutspends$.next(txIds);
|
||||
@@ -308,5 +349,6 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.outspendsSubscription.unsubscribe();
|
||||
this.currencyChangeSubscription?.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, ElementRef, ViewChild, Input, OnChanges, OnInit } from '@angular/core';
|
||||
import { tap } from 'rxjs';
|
||||
import { Subscription, of, switchMap, tap } from 'rxjs';
|
||||
import { Price, PriceService } from '../../services/price.service';
|
||||
import { StateService } from '../../services/state.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
@@ -35,6 +35,7 @@ export class TxBowtieGraphTooltipComponent implements OnChanges {
|
||||
|
||||
tooltipPosition = { x: 0, y: 0 };
|
||||
blockConversion: Price;
|
||||
currencyChangeSubscription: Subscription;
|
||||
|
||||
nativeAssetId = this.stateService.network === 'liquidtestnet' ? environment.nativeTestAssetId : environment.nativeAssetId;
|
||||
|
||||
@@ -47,11 +48,14 @@ export class TxBowtieGraphTooltipComponent implements OnChanges {
|
||||
|
||||
ngOnChanges(changes): void {
|
||||
if (changes.line?.currentValue) {
|
||||
this.priceService.getBlockPrice$(changes.line?.currentValue.timestamp, true).pipe(
|
||||
tap((price) => {
|
||||
this.blockConversion = price;
|
||||
})
|
||||
).subscribe();
|
||||
this.currencyChangeSubscription?.unsubscribe();
|
||||
this.currencyChangeSubscription = this.stateService.fiatCurrency$.pipe(
|
||||
switchMap((currency) => {
|
||||
return changes.line?.currentValue.timestamp ? this.priceService.getBlockPrice$(changes.line?.currentValue.timestamp, true, currency).pipe(
|
||||
tap((price) => this.blockConversion = price),
|
||||
) : of(undefined);
|
||||
})
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
if (changes.cursorPosition && changes.cursorPosition.currentValue) {
|
||||
|
||||
@@ -378,7 +378,7 @@ export interface INode {
|
||||
|
||||
export interface Acceleration {
|
||||
txid: string;
|
||||
status: 'requested' | 'accelerating' | 'mined' | 'completed' | 'failed';
|
||||
status: 'requested' | 'accelerating' | 'completed_provisional' | 'completed' | 'failed' | 'failed_provisional';
|
||||
pools: number[];
|
||||
feePaid: number;
|
||||
added: number; // timestamp
|
||||
|
||||
@@ -405,7 +405,7 @@ export class ApiService {
|
||||
);
|
||||
}
|
||||
|
||||
getHistoricalPrice$(timestamp: number | undefined): Observable<Conversion> {
|
||||
getHistoricalPrice$(timestamp: number | undefined, currency?: string): Observable<Conversion> {
|
||||
if (this.stateService.isAnyTestnet()) {
|
||||
return of({
|
||||
prices: [],
|
||||
@@ -416,12 +416,47 @@ export class ApiService {
|
||||
USDCHF: 0,
|
||||
USDAUD: 0,
|
||||
USDJPY: 0,
|
||||
USDBGN: 0,
|
||||
USDBRL: 0,
|
||||
USDCNY: 0,
|
||||
USDCZK: 0,
|
||||
USDDKK: 0,
|
||||
USDHKD: 0,
|
||||
USDHRK: 0,
|
||||
USDHUF: 0,
|
||||
USDIDR: 0,
|
||||
USDILS: 0,
|
||||
USDINR: 0,
|
||||
USDISK: 0,
|
||||
USDKRW: 0,
|
||||
USDMXN: 0,
|
||||
USDMYR: 0,
|
||||
USDNOK: 0,
|
||||
USDNZD: 0,
|
||||
USDPHP: 0,
|
||||
USDPLN: 0,
|
||||
USDRON: 0,
|
||||
USDRUB: 0,
|
||||
USDSEK: 0,
|
||||
USDSGD: 0,
|
||||
USDTHB: 0,
|
||||
USDTRY: 0,
|
||||
USDZAR: 0,
|
||||
}
|
||||
});
|
||||
}
|
||||
const queryParams = [];
|
||||
|
||||
if (timestamp) {
|
||||
queryParams.push(`timestamp=${timestamp}`);
|
||||
}
|
||||
|
||||
if (currency) {
|
||||
queryParams.push(`currency=${currency}`);
|
||||
}
|
||||
return this.httpClient.get<Conversion>(
|
||||
this.apiBaseUrl + this.apiBasePath + '/api/v1/historical-price' +
|
||||
(timestamp ? `?timestamp=${timestamp}` : '')
|
||||
`${this.apiBaseUrl}${this.apiBasePath}/api/v1/historical-price` +
|
||||
(queryParams.length > 0 ? `?${queryParams.join('&')}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,32 @@ export interface ApiPrice {
|
||||
CHF: number,
|
||||
AUD: number,
|
||||
JPY: number,
|
||||
BGN?: number,
|
||||
BRL?: number,
|
||||
CNY?: number,
|
||||
CZK?: number,
|
||||
DKK?: number,
|
||||
HKD?: number,
|
||||
HRK?: number,
|
||||
HUF?: number,
|
||||
IDR?: number,
|
||||
ILS?: number,
|
||||
INR?: number,
|
||||
ISK?: number,
|
||||
KRW?: number,
|
||||
MXN?: number,
|
||||
MYR?: number,
|
||||
NOK?: number,
|
||||
NZD?: number,
|
||||
PHP?: number,
|
||||
PLN?: number,
|
||||
RON?: number,
|
||||
RUB?: number,
|
||||
SEK?: number,
|
||||
SGD?: number,
|
||||
THB?: number,
|
||||
TRY?: number,
|
||||
ZAR?: number,
|
||||
}
|
||||
export interface ExchangeRates {
|
||||
USDEUR: number,
|
||||
@@ -21,6 +47,32 @@ export interface ExchangeRates {
|
||||
USDCHF: number,
|
||||
USDAUD: number,
|
||||
USDJPY: number,
|
||||
USDBGN?: number,
|
||||
USDBRL?: number,
|
||||
USDCNY?: number,
|
||||
USDCZK?: number,
|
||||
USDDKK?: number,
|
||||
USDHKD?: number,
|
||||
USDHRK?: number,
|
||||
USDHUF?: number,
|
||||
USDIDR?: number,
|
||||
USDILS?: number,
|
||||
USDINR?: number,
|
||||
USDISK?: number,
|
||||
USDKRW?: number,
|
||||
USDMXN?: number,
|
||||
USDMYR?: number,
|
||||
USDNOK?: number,
|
||||
USDNZD?: number,
|
||||
USDPHP?: number,
|
||||
USDPLN?: number,
|
||||
USDRON?: number,
|
||||
USDRUB?: number,
|
||||
USDSEK?: number,
|
||||
USDSGD?: number,
|
||||
USDTHB?: number,
|
||||
USDTRY?: number,
|
||||
USDZAR?: number,
|
||||
}
|
||||
export interface Conversion {
|
||||
prices: ApiPrice[],
|
||||
@@ -46,6 +98,8 @@ export class PriceService {
|
||||
|
||||
lastQueriedTimestamp: number;
|
||||
lastPriceHistoryUpdate: number;
|
||||
lastQueriedCurrency: string;
|
||||
lastQueriedHistoricalCurrency: string;
|
||||
|
||||
historicalPrice: ConversionDict = {
|
||||
prices: null,
|
||||
@@ -60,16 +114,25 @@ export class PriceService {
|
||||
|
||||
getEmptyPrice(): Price {
|
||||
return {
|
||||
price: {
|
||||
price: this.stateService.env.ADDITIONAL_CURRENCIES ? {
|
||||
USD: 0, EUR: 0, GBP: 0, CAD: 0, CHF: 0, AUD: 0, JPY: 0, BGN: 0, BRL: 0, CNY: 0, CZK: 0, DKK: 0, HKD: 0, HRK: 0, HUF: 0, IDR: 0,
|
||||
ILS: 0, INR: 0, ISK: 0, KRW: 0, MXN: 0, MYR: 0, NOK: 0, NZD: 0, PHP: 0, PLN: 0, RON: 0, RUB: 0, SEK: 0, SGD: 0, THB: 0, TRY: 0,
|
||||
ZAR: 0
|
||||
} :
|
||||
{
|
||||
USD: 0, EUR: 0, GBP: 0, CAD: 0, CHF: 0, AUD: 0, JPY: 0,
|
||||
},
|
||||
exchangeRates: {
|
||||
exchangeRates: this.stateService.env.ADDITIONAL_CURRENCIES ? {
|
||||
USDEUR: 0, USDGBP: 0, USDCAD: 0, USDCHF: 0, USDAUD: 0, USDJPY: 0, USDBGN: 0, USDBRL: 0, USDCNY: 0, USDCZK: 0, USDDKK: 0, USDHKD: 0,
|
||||
USDHRK: 0, USDHUF: 0, USDIDR: 0, USDILS: 0, USDINR: 0, USDISK: 0, USDKRW: 0, USDMXN: 0, USDMYR: 0, USDNOK: 0, USDNZD: 0, USDPHP: 0,
|
||||
USDPLN: 0, USDRON: 0, USDRUB: 0, USDSEK: 0, USDSGD: 0, USDTHB: 0, USDTRY: 0, USDZAR: 0
|
||||
} : {
|
||||
USDEUR: 0, USDGBP: 0, USDCAD: 0, USDCHF: 0, USDAUD: 0, USDJPY: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
getBlockPrice$(blockTimestamp: number, singlePrice = false): Observable<Price | undefined> {
|
||||
getBlockPrice$(blockTimestamp: number, singlePrice = false, currency: string): Observable<Price | undefined> {
|
||||
if (this.stateService.env.BASE_MODULE !== 'mempool' || !this.stateService.env.HISTORICAL_PRICE) {
|
||||
return of(undefined);
|
||||
}
|
||||
@@ -81,9 +144,10 @@ export class PriceService {
|
||||
* query a different timestamp than the last one
|
||||
*/
|
||||
if (singlePrice) {
|
||||
if (!this.singlePriceObservable$ || (this.singlePriceObservable$ && blockTimestamp !== this.lastQueriedTimestamp)) {
|
||||
this.singlePriceObservable$ = this.apiService.getHistoricalPrice$(blockTimestamp).pipe(shareReplay());
|
||||
if (!this.singlePriceObservable$ || (this.singlePriceObservable$ && (blockTimestamp !== this.lastQueriedTimestamp || currency !== this.lastQueriedCurrency))) {
|
||||
this.singlePriceObservable$ = this.apiService.getHistoricalPrice$(blockTimestamp, currency).pipe(shareReplay());
|
||||
this.lastQueriedTimestamp = blockTimestamp;
|
||||
this.lastQueriedCurrency = currency;
|
||||
}
|
||||
|
||||
return this.singlePriceObservable$.pipe(
|
||||
@@ -92,7 +156,17 @@ export class PriceService {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
price: {
|
||||
price: this.stateService.env.ADDITIONAL_CURRENCIES ? {
|
||||
USD: conversion.prices[0].USD, EUR: conversion.prices[0].EUR, GBP: conversion.prices[0].GBP, CAD: conversion.prices[0].CAD,
|
||||
CHF: conversion.prices[0].CHF, AUD: conversion.prices[0].AUD, JPY: conversion.prices[0].JPY, BGN: conversion.prices[0].BGN,
|
||||
BRL: conversion.prices[0].BRL, CNY: conversion.prices[0].CNY, CZK: conversion.prices[0].CZK, DKK: conversion.prices[0].DKK,
|
||||
HKD: conversion.prices[0].HKD, HRK: conversion.prices[0].HRK, HUF: conversion.prices[0].HUF, IDR: conversion.prices[0].IDR,
|
||||
ILS: conversion.prices[0].ILS, INR: conversion.prices[0].INR, ISK: conversion.prices[0].ISK, KRW: conversion.prices[0].KRW,
|
||||
MXN: conversion.prices[0].MXN, MYR: conversion.prices[0].MYR, NOK: conversion.prices[0].NOK, NZD: conversion.prices[0].NZD,
|
||||
PHP: conversion.prices[0].PHP, PLN: conversion.prices[0].PLN, RON: conversion.prices[0].RON, RUB: conversion.prices[0].RUB,
|
||||
SEK: conversion.prices[0].SEK, SGD: conversion.prices[0].SGD, THB: conversion.prices[0].THB, TRY: conversion.prices[0].TRY,
|
||||
ZAR: conversion.prices[0].ZAR
|
||||
} : {
|
||||
USD: conversion.prices[0].USD, EUR: conversion.prices[0].EUR, GBP: conversion.prices[0].GBP, CAD: conversion.prices[0].CAD,
|
||||
CHF: conversion.prices[0].CHF, AUD: conversion.prices[0].AUD, JPY: conversion.prices[0].JPY
|
||||
},
|
||||
@@ -106,9 +180,10 @@ export class PriceService {
|
||||
* Query all price history only once. The observable is invalidated after 1 hour
|
||||
*/
|
||||
else {
|
||||
if (!this.priceObservable$ || (this.priceObservable$ && (now - this.lastPriceHistoryUpdate > 3600))) {
|
||||
this.priceObservable$ = this.apiService.getHistoricalPrice$(undefined).pipe(shareReplay());
|
||||
if (!this.priceObservable$ || (this.priceObservable$ && (now - this.lastPriceHistoryUpdate > 3600 || currency !== this.lastQueriedHistoricalCurrency))) {
|
||||
this.priceObservable$ = this.apiService.getHistoricalPrice$(undefined, currency).pipe(shareReplay());
|
||||
this.lastPriceHistoryUpdate = new Date().getTime() / 1000;
|
||||
this.lastQueriedHistoricalCurrency = currency;
|
||||
}
|
||||
|
||||
return this.priceObservable$.pipe(
|
||||
@@ -122,9 +197,15 @@ export class PriceService {
|
||||
exchangeRates: conversion.exchangeRates,
|
||||
};
|
||||
for (const price of conversion.prices) {
|
||||
historicalPrice.prices[price.time] = {
|
||||
USD: price.USD, EUR: price.EUR, GBP: price.GBP, CAD: price.CAD,
|
||||
CHF: price.CHF, AUD: price.AUD, JPY: price.JPY
|
||||
historicalPrice.prices[price.time] = this.stateService.env.ADDITIONAL_CURRENCIES ? {
|
||||
USD: price.USD, EUR: price.EUR, GBP: price.GBP, CAD: price.CAD, CHF: price.CHF, AUD: price.AUD,
|
||||
JPY: price.JPY, BGN: price.BGN, BRL: price.BRL, CNY: price.CNY, CZK: price.CZK, DKK: price.DKK,
|
||||
HKD: price.HKD, HRK: price.HRK, HUF: price.HUF, IDR: price.IDR, ILS: price.ILS, INR: price.INR,
|
||||
ISK: price.ISK, KRW: price.KRW, MXN: price.MXN, MYR: price.MYR, NOK: price.NOK, NZD: price.NZD,
|
||||
PHP: price.PHP, PLN: price.PLN, RON: price.RON, RUB: price.RUB, SEK: price.SEK, SGD: price.SGD,
|
||||
THB: price.THB, TRY: price.TRY, ZAR: price.ZAR
|
||||
} : {
|
||||
USD: price.USD, EUR: price.EUR, GBP: price.GBP, CAD: price.CAD, CHF: price.CHF, AUD: price.AUD, JPY: price.JPY
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface Env {
|
||||
SIGNET_BLOCK_AUDIT_START_HEIGHT: number;
|
||||
HISTORICAL_PRICE: boolean;
|
||||
ACCELERATOR: boolean;
|
||||
ADDITIONAL_CURRENCIES: boolean;
|
||||
GIT_COMMIT_HASH_MEMPOOL_SPACE?: string;
|
||||
PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string;
|
||||
}
|
||||
@@ -82,6 +83,7 @@ const defaultEnv: Env = {
|
||||
'SIGNET_BLOCK_AUDIT_START_HEIGHT': 0,
|
||||
'HISTORICAL_PRICE': true,
|
||||
'ACCELERATOR': false,
|
||||
'ADDITIONAL_CURRENCIES': false,
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
|
||||
@@ -330,8 +330,8 @@ export class WebsocketService {
|
||||
this.stateService.rbfLatest$.next(response.rbfLatest);
|
||||
}
|
||||
|
||||
if (response.rbfLatestSummary) {
|
||||
this.stateService.rbfLatestSummary$.next(response.rbfLatestSummary);
|
||||
if (response.rbfLatestSummary !== undefined) {
|
||||
this.stateService.rbfLatestSummary$.next(response.rbfLatestSummary || []);
|
||||
}
|
||||
|
||||
if (response.txReplaced) {
|
||||
|
||||
Reference in New Issue
Block a user