|
|
@@ -8,9 +8,6 @@ import { queries, commands } from 'iroha-helpers'
|
|
|
import { AppConfigService, BcConfig } from '../app.config.service';
|
|
|
import { Buffer } from 'buffer';
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Injectable({ providedIn: 'root' })
|
|
|
export class BcInfoService {
|
|
|
private readonly commandService: CommandService;
|
|
|
@@ -20,7 +17,7 @@ export class BcInfoService {
|
|
|
private readonly _bcConfig: BcConfig;
|
|
|
|
|
|
user = 'kunickyd@test';
|
|
|
- // userPrivateKey = 'ecb7f22887b0b45d1923fcd147d34bb6fd79f56eb54ed5af42c9d70c7808a9d8';
|
|
|
+ userPrivateKey = '5ee90333f04f42f457f2d10f1cbd7ec870b041184074dce2b744aa17e67b1e9a';
|
|
|
userBalance = -1;
|
|
|
price = -1;
|
|
|
paymentHash = "";
|
|
|
@@ -38,25 +35,11 @@ export class BcInfoService {
|
|
|
this.commandService = new CommandService(this._bcConfig.IROHA_ADDRESS);
|
|
|
this.queryService = new QueryService(this._bcConfig.IROHA_ADDRESS);
|
|
|
|
|
|
-
|
|
|
- this.getUserBalance();
|
|
|
- this.getPrice(this.extent).then(price => this.price = price);
|
|
|
-
|
|
|
this.basicAuthHeaders = new HttpHeaders();
|
|
|
-
|
|
|
- this.basicAuthHeaders.append("Authorization", "Basic " + Buffer.from("admin:password", 'base64'));
|
|
|
- }
|
|
|
-
|
|
|
- async getUserBalance(): Promise<any> {
|
|
|
- this.userBalance = await this.getUserBalanceFromIroha(this.user, "ecb7f22887b0b45d1923fcd147d34bb6fd79f56eb54ed5af42c9d70c7808a9d8", this._bcConfig.ASSET);
|
|
|
- }
|
|
|
-
|
|
|
- async pay(): Promise<any> {
|
|
|
- this.paymentHash = await this.transferAssets(this.user, "ecb7f22887b0b45d1923fcd147d34bb6fd79f56eb54ed5af42c9d70c7808a9d8", this._bcConfig.ASSET, JSON.stringify({ extent: this.extent }), this.price);
|
|
|
- this.dataUrl = await this.requestData(this.paymentHash, this.user);
|
|
|
+ this.basicAuthHeaders = this.basicAuthHeaders.append("Authorization", "Basic " + Buffer.from("admin:superPasswd").toString("base64"));
|
|
|
}
|
|
|
|
|
|
- async getUserBalanceFromIroha(user: string, userPrivateKey: string, assetId: string): Promise<number> {
|
|
|
+ async getUserBalance(user: string, userPrivateKey: string, assetId: string): Promise<number> {
|
|
|
|
|
|
let queryOptions = {
|
|
|
privateKey: userPrivateKey,
|