mirror of
https://github.com/mempool/mempool.git
synced 2025-03-15 12:20:28 +01:00
Handle empty and invalid addresses
This commit is contained in:
parent
0b23e5bcd3
commit
03316f99d1
1 changed files with 16 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { ElectrsApiService } from '../../services/electrs-api.service';
|
import { ElectrsApiService } from '../../services/electrs-api.service';
|
||||||
import { switchMap, filter } from 'rxjs/operators';
|
import { switchMap, filter, catchError } from 'rxjs/operators';
|
||||||
import { Address, Transaction } from '../../interfaces/electrs.interface';
|
import { Address, Transaction } from '../../interfaces/electrs.interface';
|
||||||
import { WebsocketService } from 'src/app/services/websocket.service';
|
import { WebsocketService } from 'src/app/services/websocket.service';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
|
@ -68,11 +68,21 @@ export class AddressComponent implements OnInit, OnDestroy {
|
||||||
.pipe(filter((state) => state === 2 && this.transactions && this.transactions.length > 0))
|
.pipe(filter((state) => state === 2 && this.transactions && this.transactions.length > 0))
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(() => this.electrsApiService.getAddress$(this.addressString))
|
switchMap(() => this.electrsApiService.getAddress$(this.addressString)
|
||||||
|
.pipe(
|
||||||
|
catchError((err) => {
|
||||||
|
this.isLoadingAddress = false;
|
||||||
|
this.error = err;
|
||||||
|
console.log(err);
|
||||||
|
return of(null);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
|
filter((address) => !!address),
|
||||||
switchMap((address) => {
|
switchMap((address) => {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.updateChainStats();
|
this.updateChainStats();
|
||||||
|
@ -83,8 +93,10 @@ export class AddressComponent implements OnInit, OnDestroy {
|
||||||
}),
|
}),
|
||||||
switchMap((transactions) => {
|
switchMap((transactions) => {
|
||||||
this.tempTransactions = transactions;
|
this.tempTransactions = transactions;
|
||||||
|
if (transactions.length) {
|
||||||
this.lastTransactionTxId = transactions[transactions.length - 1].txid;
|
this.lastTransactionTxId = transactions[transactions.length - 1].txid;
|
||||||
this.loadedConfirmedTxCount += transactions.filter((tx) => tx.status.confirmed).length;
|
this.loadedConfirmedTxCount += transactions.filter((tx) => tx.status.confirmed).length;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchTxs: string[] = [];
|
const fetchTxs: string[] = [];
|
||||||
this.timeTxIndexes = [];
|
this.timeTxIndexes = [];
|
||||||
|
|
Loading…
Add table
Reference in a new issue