[refactoring] move servics related api calls to its own service
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
||||
import { CpfpInfo, OptimizedMempoolStats, AddressInformation, LiquidPegs, ITranslators,
|
||||
PoolStat, BlockExtended, TransactionStripped, RewardStats, AuditScore, BlockSizesAndWeights, RbfTree, BlockAudit, Acceleration, AccelerationHistoryParams } from '../interfaces/node-api.interface';
|
||||
PoolStat, BlockExtended, TransactionStripped, RewardStats, AuditScore, BlockSizesAndWeights, RbfTree, BlockAudit } from '../interfaces/node-api.interface';
|
||||
import { BehaviorSubject, Observable, catchError, filter, of, shareReplay, take, tap } from 'rxjs';
|
||||
import { StateService } from './state.service';
|
||||
import { IBackendInfo, WebsocketResponse } from '../interfaces/websocket.interface';
|
||||
import { Outspend, Transaction } from '../interfaces/electrs.interface';
|
||||
import { Transaction } from '../interfaces/electrs.interface';
|
||||
import { Conversion } from './price.service';
|
||||
import { MenuGroup } from '../interfaces/services.interface';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
// Todo - move to config.json
|
||||
const SERVICES_API_PREFIX = `/api/v1/services`;
|
||||
import { WebsocketResponse } from '../interfaces/websocket.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -38,12 +34,6 @@ export class ApiService {
|
||||
}
|
||||
this.apiBasePath = network ? '/' + network : '';
|
||||
});
|
||||
|
||||
if (this.stateService.env.GIT_COMMIT_HASH_MEMPOOL_SPACE) {
|
||||
this.getServicesBackendInfo$().subscribe(version => {
|
||||
this.stateService.servicesBackendInfo$.next(version);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private generateCacheKey(functionName: string, params: any[]): string {
|
||||
@@ -378,62 +368,4 @@ export class ApiService {
|
||||
(timestamp ? `?timestamp=${timestamp}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
|
||||
getNodeOwner$(publicKey: string): Observable<any> {
|
||||
let params = new HttpParams()
|
||||
.set('node_public_key', publicKey);
|
||||
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/lightning/claim/current`, { params, observe: 'response' });
|
||||
}
|
||||
|
||||
getUserMenuGroups$(): Observable<MenuGroup[]> {
|
||||
const auth = this.storageService.getAuth();
|
||||
if (!auth) {
|
||||
return of(null);
|
||||
}
|
||||
|
||||
return this.httpClient.get<MenuGroup[]>(`${SERVICES_API_PREFIX}/account/menu`);
|
||||
}
|
||||
|
||||
getUserInfo$(): Observable<any> {
|
||||
const auth = this.storageService.getAuth();
|
||||
if (!auth) {
|
||||
return of(null);
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/account`);
|
||||
}
|
||||
|
||||
logout$(): Observable<any> {
|
||||
const auth = this.storageService.getAuth();
|
||||
if (!auth) {
|
||||
return of(null);
|
||||
}
|
||||
|
||||
localStorage.removeItem('auth');
|
||||
return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, {});
|
||||
}
|
||||
|
||||
getServicesBackendInfo$(): Observable<IBackendInfo> {
|
||||
return this.httpClient.get<IBackendInfo>(`${SERVICES_API_PREFIX}/version`);
|
||||
}
|
||||
|
||||
estimate$(txInput: string) {
|
||||
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
|
||||
}
|
||||
|
||||
accelerate$(txInput: string, userBid: number) {
|
||||
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate`, { txInput: txInput, userBid: userBid });
|
||||
}
|
||||
|
||||
getAccelerations$(): Observable<Acceleration[]> {
|
||||
return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations`);
|
||||
}
|
||||
|
||||
getAccelerationHistory$(params: AccelerationHistoryParams): Observable<Acceleration[]> {
|
||||
return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user