WIP: Bisq DAO support. Transactions list and details.

This commit is contained in:
softsimon
2020-07-03 23:45:19 +07:00
parent 2ebdb27dcb
commit c21dad88bf
59 changed files with 926 additions and 38 deletions

View File

@@ -1,8 +1,9 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { OptimizedMempoolStats } from '../interfaces/node-api.interface';
import { Observable } from 'rxjs';
import { StateService } from './state.service';
import { BisqTransaction, BisqBlock } from '../interfaces/bisq.interfaces';
const API_BASE_URL = '/api{network}/v1';
@@ -18,6 +19,9 @@ export class ApiService {
) {
this.apiBaseUrl = API_BASE_URL.replace('{network}', '');
this.stateService.networkChanged$.subscribe((network) => {
if (network === 'bisq') {
network = '';
}
this.apiBaseUrl = API_BASE_URL.replace('{network}', network ? '/' + network : '');
});
}
@@ -57,4 +61,16 @@ export class ApiService {
});
return this.httpClient.get<number[]>(this.apiBaseUrl + '/transaction-times', { params });
}
getBisqTransaction$(txId: string): Observable<BisqTransaction> {
return this.httpClient.get<BisqTransaction>(this.apiBaseUrl + '/bisq/tx/' + txId);
}
listBisqTransactions$(start: number, length: number): Observable<HttpResponse<BisqTransaction[]>> {
return this.httpClient.get<BisqTransaction[]>(this.apiBaseUrl + `/bisq/txs/${start}/${length}`, { observe: 'response' });
}
getBisqBlock$(hash: string): Observable<BisqBlock> {
return this.httpClient.get<BisqBlock>(this.apiBaseUrl + '/bisq/block/' + hash);
}
}

View File

@@ -18,6 +18,9 @@ export class ElectrsApiService {
) {
this.apiBaseUrl = API_BASE_URL;
this.stateService.networkChanged$.subscribe((network) => {
if (network === 'bisq') {
network = '';
}
this.apiBaseUrl = API_BASE_URL + '/' + network;
});
}

View File

@@ -64,6 +64,12 @@ export class StateService {
this.networkChanged$.next('testnet');
}
return;
case 'bisq':
if (this.network !== 'bisq') {
this.network = 'bisq';
this.networkChanged$.next('bisq');
}
return;
default:
if (this.network !== '') {
this.network = '';

View File

@@ -29,11 +29,14 @@ export class WebsocketService {
constructor(
private stateService: StateService,
) {
this.network = this.stateService.network;
this.network = this.stateService.network === 'bisq' ? '' : this.stateService.network;
this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL + '/' + this.network);
this.startSubscription();
this.stateService.networkChanged$.subscribe((network) => {
if (network === 'bisq') {
network = '';
}
if (network === this.network) {
return;
}