Skip to content

Commit

Permalink
Merge pull request #101 from NazarUsov/testnet/issues
Browse files Browse the repository at this point in the history
Change view by flag is_hardfok_active
  • Loading branch information
cryptozoidberg authored Feb 23, 2024
2 parents f040b10 + 0172a64 commit e8531f5
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 74 deletions.
3 changes: 1 addition & 2 deletions html_source/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true,
"standalone": true
"skipTests": true
}
},
"architect": {
Expand Down
2 changes: 1 addition & 1 deletion html_source/src/app/api/services/backend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export class BackendService {
}

// Use for call rpc-api https://docs.zano.org/docs/build/rpc-api
call_rpc(params: ParamsCallRpc, callback?: (status: boolean, response_data: any) => void): void {
call_rpc(params: Partial<ParamsCallRpc>, callback?: (status: boolean, response_data: any) => void): void {
this.runCommand(Commands.call_rpc, params, callback);
}

Expand Down
19 changes: 19 additions & 0 deletions html_source/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { takeUntil } from 'rxjs/operators';
import { paths, pathsChildrenAuth } from './pages/paths';
import { hasOwnProperty } from '@parts/functions/hasOwnProperty';
import { Dialog } from '@angular/cdk/dialog';
import { ParamsCallRpc } from '@api/models/call_rpc.model';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -710,6 +711,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.backendService.handleCurrentActionState();

this.getVersion();

this.getInfo();
},
error: error => {
console.log(error);
Expand Down Expand Up @@ -845,4 +848,20 @@ export class AppComponent implements OnInit, OnDestroy {
});
});
}

getInfo(): void {
const updateTime = 60 * 1000;
const getInfo = () => {
const params = {
jsonrpc: '2.0',
method: 'getinfo',
};

this.backendService.call_rpc(params, (status, response_data) => {
this.variablesService.info$.next(response_data.result);
});
};
getInfo();
setInterval(getInfo, updateTime);
}
}
24 changes: 13 additions & 11 deletions html_source/src/app/pages/wallet/tabs/assets/assets.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,22 @@ import { defaultImgSrc, zanoAssetInfo } from '@parts/data/assets';
</button>
</li>
<li class="item">
<a routerLink="/wallet/send" [state]="{ asset: currentAsset }" class="w-100 px-2 py-1">
<i class="icon arrow-up-square mr-1"></i>
<span>{{ 'Send' | translate }}</span>
</a>
</li>
<ng-container *ngIf="false">
<ng-container *ngIf="variablesService.currentWallet.loaded && variablesService.daemon_state === 2 && !variablesService.currentWallet.is_auditable && !variablesService.currentWallet.is_watch_only && !variablesService.currentWallet.isEmpty">
<li class="item">
<a routerLink="/wallet/create-swap" [state]="{ asset: currentAsset }" class="w-100 px-2 py-1">
<i class="icon swap mr-1"></i>
<span>{{ 'Swap' | translate }}</span>
<a routerLink="/wallet/send" [state]="{ asset: currentAsset }" class="w-100 px-2 py-1">
<i class="icon arrow-up-square mr-1"></i>
<span>{{ 'Send' | translate }}</span>
</a>
</li>
<ng-container *ngIf="(variablesService.is_hardfok_active$ | async)">
<li class="item">
<a routerLink="/wallet/create-swap" [state]="{ asset: currentAsset }" class="w-100 px-2 py-1">
<i class="icon swap mr-1"></i>
<span>{{ 'Swap' | translate }}</span>
</a>
</li>
</ng-container>
</ng-container>
<ng-container *ngIf="currentAsset.asset_info.ticker !== 'ZANO'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ import { zanoAssetInfo } from '@parts/data/assets';
</ng-container>
<ng-container
*ngSwitchCase="!(transaction.remote_addresses?.length || transaction.remote_aliases?.length) && transaction.tx_type !== 5"
*ngSwitchCase="!(transaction.remote_addresses?.length || transaction.remote_aliases?.length) && ![4,5,6,7,8,10,11,12].includes(transaction.tx_type)"
>
{{ 'HISTORY.HIDDEN' | translate }}
</ng-container>
Expand Down
19 changes: 17 additions & 2 deletions html_source/src/app/pages/wallet/wallet/wallet.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const objTabs: { [key in TabNameKeys]: Tab } = {
<span>{{ 'WALLET_DETAILS.WALLET_OPTIONS' | translate }}</span>
</button>
</li>
<ng-container *ngIf="false">
<ng-container *ngIf="variablesService.is_hardfok_active$ | async">
<li class="item">
<button
(click)="addCustomToken()"
Expand Down Expand Up @@ -348,10 +348,19 @@ export class WalletComponent implements OnInit, OnDestroy {
next: (wallet: Wallet) => {
this.createTabs(wallet);

const disabled = wallet.isEmpty;
const disabled = wallet.isEmpty || this.variablesService.daemon_state !== 2 || !this.walletLoaded;
this.setDisabledTabs(['send', 'swap', 'staking'], disabled);
},
});

this.variablesService.is_hardfok_active$.pipe(
takeUntil(this.destroy$)
).subscribe({
next: (value) => {
const hidden = !value;
this.setHiddenTabs(['swap'], hidden);
}
});
}

createTabs({ is_auditable, is_watch_only }: Wallet): void {
Expand Down Expand Up @@ -526,6 +535,12 @@ export class WalletComponent implements OnInit, OnDestroy {
});
}

setHiddenTabs(ids: string[], hidden: boolean): void {
this.tabs
.filter(({ id }) => ids.includes(id))
.forEach(tab => (tab.hidden = hidden));
}

setDisabledTabs(ids: string[], disabled: boolean): void {
this.tabs
.filter(({ id }) => ids.includes(id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class AssetDetailsComponent implements OnInit {

ngZone = inject(NgZone);

zano_current_supply = null;
zano_current_supply = 'Unknown';

constructor(
public variablesService: VariablesService,
Expand Down Expand Up @@ -144,10 +144,10 @@ export class AssetDetailsComponent implements OnInit {
};

this.backendService.call_rpc(params1, (status1, response_data1) => {
if (response_data1.result.status === 'OK') {
if (response_data1?.result?.status === 'OK') {
this.backendService.call_rpc(params2, (status2, response_data2) => {
this.ngZone.run(() => {
this.zano_current_supply = response_data2?.['result']?.['total_coins'] ?? null;
this.zano_current_supply = response_data2?.['result']?.['total_coins'] ?? 'Unknown';
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class HistoryTypeMessagesPipe implements PipeTransform {
case 5:
return this.translate.instant('HISTORY.TYPE_MESSAGES.UPDATE_ALIAS');
case 6:
return item.td['spn'] && item.td['spn'].length
return item.td?.['spn']?.length
? this.translate.instant('HISTORY.TYPE_MESSAGES.POS_REWARD')
: this.translate.instant('HISTORY.TYPE_MESSAGES.POW_REWARD');
case 7:
Expand Down
81 changes: 28 additions & 53 deletions html_source/src/app/parts/services/variables.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Injectable, NgZone } from '@angular/core';
import { DeeplinkParams, Wallet } from '@api/models/wallet.model';
import { Contact } from '@api/models/contact.model';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { Idle } from 'idlejs/dist';
import { Router } from '@angular/router';
import { ContextMenuComponent, ContextMenuService } from '@perfectmemory/ngx-contextmenu';
import { BigNumber } from 'bignumber.js';
import { Aliases } from '@api/models/alias.model';
import { distinctUntilChanged, map, startWith } from 'rxjs/operators';

@Injectable({
providedIn: 'root',
Expand All @@ -16,6 +17,12 @@ export class VariablesService {

use_debug_mode$ = new BehaviorSubject<boolean>(false);

info$ = new BehaviorSubject<any>({});

is_hardfok_active$: Observable<boolean> = this.info$.pipe(map((info) => {
return info?.['is_hardfok_active']?.[3] ?? false;
}), distinctUntilChanged());

stop_paginate = {};

sync_started = false;
Expand Down Expand Up @@ -62,34 +69,13 @@ export class VariablesService {
};

public sync_wallets: { [wallet_id: number]: boolean } = {};

get isCurrentWalletSync(): boolean {
if (this.currentWallet) {
const { wallet_id } = this.currentWallet;
return this.sync_wallets[wallet_id] || false;
}
return false;
}

get isCurrentWalletLoaded(): boolean {
if (this.currentWallet) {
const { loaded } = this.currentWallet;
return loaded;
}
return false;
}

download = {
progress_value: 0,
progress_value_text: '0',
};

get_recent_transfers = false; // avoid of execute function before callback complete

default_fee = '0.010000000000';

default_fee_big = new BigNumber('10000000000');

settings = {
appLockTime: 15,
appLog: 0,
Expand All @@ -101,57 +87,29 @@ export class VariablesService {
notViewedContracts: [],
wallets: [],
};

count = 40;

maxPages = 5;

testnet = false;

networkType = ''; // testnet of mainnet

wallets: Array<Wallet> = [];

get walletNamesForComparisons(): string[] {
return this.wallets.map(({ name }) => name) ?? [];
}

currentWallet: Wallet;

aliases: Aliases = [];

aliasesChecked: any = {};

enableAliasSearch = false;

maxWalletNameLength = 25;

maxCommentLength = 255;

dataIsLoaded = false;

contacts: Array<Contact> = [];

pattern = '^[a-zA-Z0-9_.\\]*|~!?@#$%^&+{}()<>:;"\'-=/,[\\\\]*$';

after_sync_request: any = {};

getExpMedTsEvent = new BehaviorSubject(null);

getHeightAppEvent = new BehaviorSubject(null);

getHeightMaxEvent = new BehaviorSubject(null);

getDownloadedAppEvent = new BehaviorSubject(null);

getTotalEvent = new BehaviorSubject(null);

getRefreshStackingEvent = new BehaviorSubject(null);

getAliasChangedEvent = new BehaviorSubject(null);

currentWalletChangedEvent = new BehaviorSubject<Wallet>(null);

idle = new Idle().whenNotInteractive().do(async () => {
if (this.appPass === '') {
this.stopCountdown();
Expand All @@ -166,15 +124,32 @@ export class VariablesService {
});
}
});

allContextMenu: ContextMenuComponent<any>;

onlyCopyContextMenu: ContextMenuComponent<any>;

pasteSelectContextMenu: ContextMenuComponent<any>;

constructor(private router: Router, private ngZone: NgZone, private contextMenuService: ContextMenuService<any>) {}

get isCurrentWalletSync(): boolean {
if (this.currentWallet) {
const { wallet_id } = this.currentWallet;
return this.sync_wallets[wallet_id] || false;
}
return false;
}

get isCurrentWalletLoaded(): boolean {
if (this.currentWallet) {
const { loaded } = this.currentWallet;
return loaded;
}
return false;
}

get walletNamesForComparisons(): string[] {
return this.wallets.map(({ name }) => name) ?? [];
}

setExpMedTs(timestamp: number): void {
if (timestamp !== this.exp_med_ts) {
this.exp_med_ts = timestamp;
Expand Down

0 comments on commit e8531f5

Please sign in to comment.