Skip to content

Commit fc33a9e

Browse files
authored
Merge pull request #1053 from numbersprotocol/feature-show-num-balance
Feature show num balance
2 parents 7887596 + 51cd4bc commit fc33a9e

File tree

5 files changed

+44
-15
lines changed

5 files changed

+44
-15
lines changed

src/app/features/profile/profile.page.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,23 @@
1010
<div *transloco="let t" class="page-content">
1111
<mat-list>
1212
<mat-list-item>
13-
<ion-icon mat-list-icon src="/assets/images/numbers_token.svg"></ion-icon>
14-
<div mat-line>{{ t('balance') }}</div>
15-
<div mat-line>NUM</div>
16-
<div class="capt-balance">
13+
<ion-icon mat-list-icon src="/assets/images/num-icon.svg"></ion-icon>
14+
<div mat-line>NUM {{ t('balance') }}</div>
15+
<div mat-line>ERC20</div>
16+
<div class="num-balance">
1717
<ng-container *ngIf="networkConnected$ | ngrxPush; else offline">
18-
$ {{ captBalance$ | ngrxPush | number: '1.2-2' }}
18+
$ {{ ethNumBalance$ | ngrxPush | number: '1.2-2' }}
19+
</ng-container>
20+
<ng-template #offline> --offline-- </ng-template>
21+
</div>
22+
</mat-list-item>
23+
<mat-list-item>
24+
<ion-icon mat-list-icon src="/assets/images/num-icon.svg"></ion-icon>
25+
<div mat-line>NUM {{ t('balance') }}</div>
26+
<div mat-line>BEP20</div>
27+
<div class="num-balance">
28+
<ng-container *ngIf="networkConnected$ | ngrxPush; else offline">
29+
$ {{ bscNumBalance$ | ngrxPush | number: '1.2-2' }}
1930
</ng-container>
2031
<ng-template #offline> --offline-- </ng-template>
2132
</div>

src/app/features/profile/profile.page.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app-avatar {
2323
color: var(--noir-warn);
2424
}
2525

26-
.capt-balance {
26+
.num-balance {
2727
margin-right: 8px;
2828
}
2929
}

src/app/features/profile/profile.page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class ProfilePage {
3232
readonly privateKey$ = this.webCryptoApiSignatureProvider.privateKey$;
3333
readonly phoneVerified$ = this.diaBackendAuthService.phoneVerified$;
3434
readonly emailVerified$ = this.diaBackendAuthService.emailVerified$;
35-
readonly captBalance$ = this.diaBackendWalletService.captBalance$;
35+
readonly ethNumBalance$ = this.diaBackendWalletService.ethNumBalance$;
36+
readonly bscNumBalance$ = this.diaBackendWalletService.bscNumBalance$;
3637
readonly networkConnected$ = this.diaBackendWalletService.networkConnected$;
3738

3839
constructor(

src/app/shared/dia-backend/wallet/dia-backend-wallet.service.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
3-
import { defer } from 'rxjs';
3+
import { defer, forkJoin } from 'rxjs';
44
import { concatMap } from 'rxjs/operators';
55
import { NetworkService } from '../../network/network.service';
66
import { PreferenceManager } from '../../preference-manager/preference-manager.service';
@@ -15,7 +15,12 @@ export class DiaBackendWalletService {
1515

1616
private readonly preferences = this.preferenceManager.getPreferences(this.id);
1717

18-
readonly captBalance$ = this.preferences.getNumber$(PrefKeys.CAPT_BALANCE);
18+
readonly ethNumBalance$ = this.preferences.getNumber$(
19+
PrefKeys.ETH_NUM_BALANCE
20+
);
21+
readonly bscNumBalance$ = this.preferences.getNumber$(
22+
PrefKeys.BSC_NUM_BALANCE
23+
);
1924

2025
readonly networkConnected$ = this.networkService.connected$;
2126

@@ -63,12 +68,18 @@ export class DiaBackendWalletService {
6368
}
6469

6570
syncCaptBalance$() {
66-
return this.getManagedWallet$().pipe(
71+
return this.getAssetWallet$().pipe(
6772
concatMap(diaBackendWallet =>
68-
this.preferences.setNumber(
69-
PrefKeys.CAPT_BALANCE,
70-
diaBackendWallet.capt_balance
71-
)
73+
forkJoin([
74+
this.preferences.setNumber(
75+
PrefKeys.ETH_NUM_BALANCE,
76+
diaBackendWallet.num_balance.eth_num
77+
),
78+
this.preferences.setNumber(
79+
PrefKeys.BSC_NUM_BALANCE,
80+
diaBackendWallet.num_balance.bsc_num
81+
),
82+
])
7283
)
7384
);
7485
}
@@ -78,12 +89,17 @@ export interface DiaBackendWallet {
7889
id: string;
7990
type: string;
8091
capt_balance: number;
92+
num_balance: {
93+
bsc_num: number;
94+
eth_num: number;
95+
};
8196
address: string;
8297
private_key: string;
8398
created_at: string;
8499
owner: string;
85100
}
86101

87102
const enum PrefKeys {
88-
CAPT_BALANCE = 'CAPT_BALANCE',
103+
ETH_NUM_BALANCE = 'ETH_NUM_BALANCE',
104+
BSC_NUM_BALANCE = 'BSC_NUM_BALANCE',
89105
}

src/assets/images/num-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)