Skip to content

Commit dabdc15

Browse files
authored
Merge pull request #211 from qubic/fix/ipo-place-bid-balance-check
fix(ipo): use walletService.getSeeds() for balance check in place-bid
2 parents 58c7dce + 6b224ae commit dabdc15

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/app/ipo/place-bid/place-bid.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<ng-container *transloco="let t">
22
<div class="content_container">
33
<h1>{{ t("ipoComponent.place-bid.title") }}</h1>
4-
<div *ngIf="balances.length <= 0">
4+
<div *ngIf="!hasSeeds()">
55
{{ t("ipoComponent.place-bid.needBalance") }}
66
</div>
7-
<div *ngIf="!ipoContract">
7+
<div *ngIf="hasSeeds() && !ipoContract">
88
{{ t("ipoComponent.place-bid.noContract") }}<br><br>
99
<a [routerLink]="['/ipo']">{{ t("ipoComponent.place-bid.noContract.gotoIpoLabel") }}</a>
1010
</div>
11-
<div *ngIf="balances.length > 0 && ipoContract">
11+
<div *ngIf="hasSeeds() && ipoContract">
1212
<form [formGroup]="ipoForm" novalidate (ngSubmit)="onSubmit()">
1313
<mat-card class="transfer-card">
1414
<mat-card-content>

src/app/ipo/place-bid/place-bid.component.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WalletService } from '../../services/wallet.service';
44
import { MatDialog } from '@angular/material/dialog';
55
import { MatSnackBar } from '@angular/material/snack-bar';
66
import { TranslocoService } from '@ngneat/transloco';
7-
import { BalanceResponse, ContractDto, ProposalDto, Transaction } from '../../services/api.model';
7+
import { ContractDto, Transaction } from '../../services/api.model';
88
import { FormBuilder, FormControl, Validators } from '@angular/forms';
99
import { UpdaterService } from '../../services/updater-service';
1010
import { ActivatedRoute, Router } from '@angular/router';
@@ -36,7 +36,6 @@ export class PlaceBidComponent implements OnInit, OnDestroy {
3636
public currentTick = 0;
3737
public contractIndex: number | undefined;
3838
private sub: any;
39-
public balances: BalanceResponse[] = [];
4039
public tickOverwrite = false;
4140
public maxAmount: number = 0;
4241
public ipoContract: ContractDto | undefined;
@@ -78,9 +77,6 @@ export class PlaceBidComponent implements OnInit, OnDestroy {
7877
}
7978

8079
init(): void {
81-
this.us.currentBalance.pipe(takeUntil(this.destroy$)).subscribe(s => {
82-
this.balances = s;
83-
});
8480
this.us.currentTick.pipe(takeUntil(this.destroy$)).subscribe(tick => {
8581
this.currentTick = tick;
8682
this.ipoForm.controls.tick.addValidators(Validators.min(tick));
@@ -142,13 +138,7 @@ export class PlaceBidComponent implements OnInit, OnDestroy {
142138
}
143139

144140
getMaxAmount(publicId: string) {
145-
this.us.currentBalance.pipe(takeUntil(this.destroy$)).subscribe(s => {
146-
if (s && s.length > 0 && s.find(f => f.publicId == publicId)) {
147-
this.maxAmount = s.find(f => f.publicId == publicId)?.currentEstimatedAmount ?? s.find(f => f.publicId == publicId)?.epochBaseAmount ?? 0;
148-
} else {
149-
this.maxAmount = 0;
150-
}
151-
});
141+
this.maxAmount = this.walletService.getSeed(publicId)?.balance ?? 0;
152142
}
153143

154144
setAmounToMax(addAmount: number = 0) {

0 commit comments

Comments
 (0)