Commit 36213223 authored by Maxim Bogdanov's avatar Maxim Bogdanov 🙉

Fixes and inprovements to work with destream network.

parent cc4ae9ee
......@@ -53,6 +53,9 @@ export class CoinNotationPipe implements PipeTransform {
case "TuSTRAT":
temp = value / 100;
return temp.toFixed(this.decimalLimit);
case "DST":
temp = value / 100000000;
return temp.toFixed(this.decimalLimit);
}
}
}
......
......@@ -19,5 +19,5 @@ export class NavigationService {
navigation$.filter(x => x === `${this.navBase}/destream-wallet`).subscribe(_ => this.pageSubject.next(Page.DeStream));
}
public pageSubject = new ReplaySubject(1);
public pageSubject = new ReplaySubject(0);
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import 'rxjs/add/observable/empty';
import { GlobalService } from '../../shared/services/global.service';
import { NavigationService, Page } from '../../shared/services/navigation.service';
class dateRequest {
constructor(public date: Date){}
constructor(public date: Date) { }
}
@Injectable()
export class AdvancedService {
private urlPrefix = '';
private readonly walletName;
private readonly accountName = 'account 0';
private headers = new HttpHeaders({'Content-Type': 'application/json'});
constructor(private httpClient: HttpClient, private globalService: GlobalService, navigationService: NavigationService) {
this.walletName = this.globalService.getWalletName();
navigationService.pageSubject.subscribe(x => this.urlPrefix = `http://localhost:3722${x}/api/Wallet/`);
}
public getExtPubKey(): Observable<string> {
const url = this.makeUrl(`extpubkey?WalletName=${this.walletName}&AccountName=${this.accountName}`);
return this.httpClient.get(url).map(x => x.toString());
}
public generateAddresses(count: number): Observable<string[]> {
const url = this.makeUrl(`unusedaddresses?WalletName=${this.walletName}&AccountName=${this.accountName}&Count=${count}`);
return this.httpClient.get(url).map(x => this.processAddresses(x));
private urlPrefix = '';
private readonly walletName;
private readonly accountName = 'account 0';
private headers = new HttpHeaders({ 'Content-Type': 'application/json' });
constructor(private httpClient: HttpClient, private globalService: GlobalService, navigationService: NavigationService) {
this.walletName = this.globalService.getWalletName();
this.urlPrefix = "http://localhost:56864/api/Wallet/";
}
public getExtPubKey(): Observable<string> {
console.info(this.urlPrefix);
const url = this.makeUrl(`extpubkey?WalletName=${this.walletName}&AccountName=${this.accountName}`);
return this.httpClient.get(url).map(x => x.toString());
}
public generateAddresses(count: number): Observable<string[]> {
const url = this.makeUrl(`unusedaddresses?WalletName=${this.walletName}&AccountName=${this.accountName}&Count=${count}`);
return this.httpClient.get(url).map(x => this.processAddresses(x));
}
public resyncFromDate(date: Date): Observable<any> {
date = new Date(date.getFullYear(), date.getMonth(), date.getDate()); //<- Strip any time values
const url = this.makeUrl('syncfromdate');
const data = JSON.stringify(new dateRequest(date));
return this.httpClient.post(url, data, { headers: this.headers }).map((x: Response) => x);
}
private processAddresses(response: any): string[] {
const addresses = new Array<string>();
for (const address of response) {
addresses.push(address);
}
return addresses;
}
public resyncFromDate(date: Date): Observable<any> {
date = new Date(date.getFullYear(), date.getMonth(), date.getDate()); //<- Strip any time values
const url = this.makeUrl('syncfromdate');
const data = JSON.stringify(new dateRequest(date));
return this.httpClient.post(url, data, {headers: this.headers}).map((x: Response) => x);
}
private processAddresses(response: any): string[] {
const addresses = new Array<string>();
for (const address of response) {
addresses.push(address);
}
return addresses;
}
private makeUrl(urlPostfix: string): string {
return `${this.urlPrefix}${urlPostfix}`;
}
private makeUrl(urlPostfix: string): string {
return `${this.urlPrefix}${urlPostfix}`;
}
}
......@@ -49,8 +49,8 @@ export class HistoryComponent {
response => {
if (response.status >= 200 && response.status < 400) {
const json = response.json();
if (json && json.transactionsHistory) {
historyResponse = json.transactionsHistory;
if (json && json.history.length) {
historyResponse = json.history[0].transactionsHistory;
this.getTransactionInfo(historyResponse);
}
}
......
......@@ -24,7 +24,7 @@ export class SidebarComponent implements OnInit {
ngOnInit() {
}
public loadDestreamWallet() {
public loadDeStreamWallet() {
this.globalService.setCoinName("DeStreamCoin");
this.globalService.setCoinUnit("DST");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment