|
|
@@ -1,14 +1,47 @@
|
|
|
-import {Injectable} from '@angular/core';
|
|
|
-import {HttpClient} from '@angular/common/http';
|
|
|
+import { Injectable } from '@angular/core';
|
|
|
+import { HttpClient } from '@angular/common/http';
|
|
|
+import {
|
|
|
+ CommandService_v1Client as CommandService,
|
|
|
+ QueryService_v1Client as QueryService
|
|
|
+} from 'iroha-helpers/lib/proto/endpoint_pb_service'
|
|
|
+import { queries } from 'iroha-helpers'
|
|
|
|
|
|
-@Injectable({providedIn: 'root'})
|
|
|
+@Injectable({ providedIn: 'root' })
|
|
|
export class BcInfoService {
|
|
|
+
|
|
|
BASE_URL = 'https://chain4all.lesprojekt.cz' as const;
|
|
|
+ IROHA_ADDRESS = "localhost:50051" as const;
|
|
|
+ ASSET = "testcoin#test" as const;
|
|
|
+
|
|
|
user = 'jmacura';
|
|
|
+ userPrivateKey = 'test';
|
|
|
user_balance = -1;
|
|
|
- constructor(public httpClient: HttpClient) {}
|
|
|
-
|
|
|
- getUserBalance() {
|
|
|
- //TODO:
|
|
|
+
|
|
|
+ commandService: CommandService;
|
|
|
+ queryService: QueryService;
|
|
|
+
|
|
|
+ constructor(public httpClient: HttpClient) {
|
|
|
+ this.commandService = new CommandService(this.IROHA_ADDRESS);
|
|
|
+ this.queryService = new QueryService(this.IROHA_ADDRESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ getUserBalance() : any{
|
|
|
+ let queryOptions = {
|
|
|
+ privateKey: this.userPrivateKey,
|
|
|
+ creatorAccountId: this.user,
|
|
|
+ queryService: this.queryService,
|
|
|
+ timeoutLimit: 5000
|
|
|
+ };
|
|
|
+
|
|
|
+ queries.getAccountAssets(queryOptions, {
|
|
|
+ accountId: this.user,
|
|
|
+ firstAssetId: undefined,
|
|
|
+ pageSize: 10
|
|
|
+ })
|
|
|
+ .then((data) => console.log(data))
|
|
|
+ .catch((err) => console.error(err));
|
|
|
+
|
|
|
+ return "test";
|
|
|
+
|
|
|
}
|
|
|
}
|