Skip to content

Commit

Permalink
Merge pull request #135 from NazarUsov/fix-alias-fetching-on-send
Browse files Browse the repository at this point in the history
Fix alias fetching for remote_node
  • Loading branch information
sowle authored Dec 11, 2024
2 parents f6e3e06 + 55b86ef commit 0b182ce
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 49 deletions.
5 changes: 5 additions & 0 deletions html_source/src/app/api/services/backend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export enum Commands {
call_wallet_rpc = 'call_wallet_rpc',
setup_jwt_wallet_rpc = 'setup_jwt_wallet_rpc',
show_notification = 'show_notification',
is_remnotenode_mode_preconfigured = 'is_remnotenode_mode_preconfigured',
}

@Injectable({
Expand Down Expand Up @@ -689,6 +690,10 @@ export class BackendService {
});
}

isRemnoteNodeModePreconfigured(callback): void {
this.runCommand(Commands.is_remnotenode_mode_preconfigured, {}, callback);
}

setLogLevel(level): void {
this.runCommand(Commands.set_log_level, { v: level });
}
Expand Down
4 changes: 4 additions & 0 deletions html_source/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,10 @@ export class AppComponent implements OnInit, OnDestroy {

this.getInfo();

this.backendService.isRemnoteNodeModePreconfigured((is_remote_node: boolean) => {
this.variablesService.is_remote_node = is_remote_node;
});

setTimeout(() => {
this.backendService.getOptions();
this._getZanoCurrentSupply();
Expand Down
29 changes: 17 additions & 12 deletions html_source/src/app/pages/wallet/tabs/send/send.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
/>

<mat-autocomplete #auto="matAutocomplete" class="zano-autocomplete-panel">
<mat-option *ngIf="vm.loading" class="loading" disabled>
<zano-loader class="mx-auto" style="display: block; width: fit-content"></zano-loader>
</mat-option>
<ng-container *ngIf="!variablesService.is_remote_node">
<mat-option *ngIf="vm.loading" class="loading" disabled>
<zano-loader class="mx-auto" style="display: block; width: fit-content"></zano-loader>
</mat-option>


<mat-option
*ngIf="form.controls.address.value[0] === '@' && vm.items?.length === 0 && !vm.loading"
disabled>
<span class="pl-1"> Not found aliases </span>
</mat-option>
<mat-option
*ngIf="form.controls.address.value[0] === '@' && vm.items?.length === 0 && !vm.loading"
disabled>
<span class="pl-1"> Not found aliases </span>
</mat-option>
</ng-container>

<ng-container *ngIf="!vm.loading">
<mat-option *ngFor="let item of vm.items; trackBy: trackByFn" [value]="item">
Expand Down Expand Up @@ -116,7 +119,7 @@
</div>

<ng-container *ngIf="isVisibleError(form.controls.amount) || isVisibleError(form)">
<div class="error" *ngIf="errorMessages['amount'] as message">
<div *ngIf="errorMessages['amount'] as message" class="error">
{{ message | translate }}
</div>
</ng-container>
Expand Down Expand Up @@ -190,7 +193,7 @@
formControlName="asset_id"
>
<ng-template let-asset="item" ng-label-tmp ng-option-tmp>
<div class="token-logo" [innerHTML]="asset.asset_info | getLogoByAssetInfo"></div>
<div [innerHTML]="asset.asset_info | getLogoByAssetInfo" class="token-logo"></div>
{{ asset.asset_info.full_name ?? '***' }}
<ng-container *appVisibilityBalance>
({{ asset.total | intToMoney : asset.asset_info.decimal_point }} {{ asset.asset_info.ticker }})
Expand Down Expand Up @@ -279,10 +282,12 @@
<!--</div>-->

<!-- PUSH -->
<app-checkbox [label]="'SEND.INCLUDE_SENDER_ADDRESS' | translate" class="mt-1" formControlName="push_payer"></app-checkbox>
<app-checkbox [label]="'SEND.INCLUDE_SENDER_ADDRESS' | translate" class="mt-1"
formControlName="push_payer"></app-checkbox>

<!-- HIDE -->
<app-checkbox [label]="'SEND.HIDE' | translate" class="mt-1" formControlName="hide_receiver"></app-checkbox>
<app-checkbox [label]="'SEND.HIDE' | translate" class="mt-1"
formControlName="hide_receiver"></app-checkbox>
</div>
</div>

Expand Down
13 changes: 1 addition & 12 deletions html_source/src/app/pages/wallet/tabs/send/send.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,9 @@ export class SendComponent implements OnDestroy {
}

if (address.indexOf('@') === 0) {
const aliasName = address;
const { aliases } = this.variablesService;
const alias = aliases.find(({ name }) => name === aliasName);

if (!alias) {
this.form.controls.address.setErrors({
alias_not_found: true,
});
return;
}

sendMoneyParams = {
...sendMoneyParams,
address: alias.address,
address: this.aliasAddress,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<ng-container *ngSwitchCase="form.controls.sending.controls.amount.hasError('zero')">
{{ 'SEND.FORM_ERRORS.AMOUNT_ZERO' | translate }}
</ng-container>
<ng-container *ngSwitchCase="form.controls.sending.controls.amount.hasError('required') && !form.controls.sending.hasError('assetHasNotBeenAddedToWallet')">
<ng-container
*ngSwitchCase="form.controls.sending.controls.amount.hasError('required') && !form.controls.sending.hasError('assetHasNotBeenAddedToWallet')">
{{ 'ERRORS.REQUIRED' | translate }}
</ng-container>
<ng-container *ngSwitchCase="form.controls.sending.hasError('greater_than_maximum_amount')">
Expand Down Expand Up @@ -54,7 +55,7 @@
formControlName="asset_id"
>
<ng-template let-item="item" ng-label-tmp ng-option-tmp>
<div class="token-logo" [innerHTML]="item | getLogoByAssetInfo"></div>
<div [innerHTML]="item | getLogoByAssetInfo" class="token-logo"></div>
{{ item.full_name || '---' }}
</ng-template>
</ng-select>
Expand Down Expand Up @@ -90,7 +91,8 @@
class="error"
>
<ng-container [ngSwitch]="true">
<ng-container *ngSwitchCase="form.controls.receiving.controls.amount.hasError('required') && !form.controls.receiving.hasError('assetHasNotBeenAddedToWallet')">
<ng-container
*ngSwitchCase="form.controls.receiving.controls.amount.hasError('required') && !form.controls.receiving.hasError('assetHasNotBeenAddedToWallet')">
{{ 'ERRORS.REQUIRED' | translate }}
</ng-container>
<ng-container *ngSwitchCase="form.controls.receiving.controls.amount.hasError('zero')">
Expand All @@ -117,7 +119,7 @@
formControlName="asset_id"
>
<ng-template let-item="item" ng-label-tmp ng-option-tmp>
<div class="token-logo" [innerHTML]="item | getLogoByAssetInfo"></div>
<div [innerHTML]="item | getLogoByAssetInfo" class="token-logo"></div>
{{ item.full_name || '---' }}
</ng-template>
</ng-select>
Expand Down Expand Up @@ -161,20 +163,24 @@
[placeholder]="'PLACEHOLDERS.ADDRESS_PLACEHOLDER' | translate"
class="form__field--input"
formControlName="receiverAddress"
id="address"
lowerCase
matAutocompletePosition="below"
type="text"
id="address"
/>

<mat-autocomplete #auto="matAutocomplete" class="zano-autocomplete-panel">
<mat-option *ngIf="vm.loading" class="loading" disabled>
<zano-loader class="mx-auto" style="display: block; width: fit-content"></zano-loader>
</mat-option>
<ng-container *ngIf="!variablesService.is_remote_node">
<mat-option *ngIf="vm.loading" class="loading" disabled>
<zano-loader class="mx-auto" style="display: block; width: fit-content"></zano-loader>
</mat-option>

<mat-option *ngIf="form.controls.receiverAddress.value[0] === '@' && vm.items?.length === 0 && !vm.loading" disabled>
<span class="pl-1"> Not found aliases </span>
</mat-option>
<mat-option
*ngIf="form.controls.receiverAddress.value[0] === '@' && vm.items?.length === 0 && !vm.loading"
disabled>
<span class="pl-1"> Not found aliases </span>
</mat-option>
</ng-container>

<ng-container *ngIf="!vm.loading">
<mat-option *ngFor="let item of vm.items; trackBy: trackByFn" [value]="item">
Expand Down Expand Up @@ -210,10 +216,12 @@

<div class="actions">
<button [disabled]="form.invalid || (loading$ | async)" class="btn primary big w-100" type="submit">
<ng-container *ngIf="!(loading$ | async)">{{ 'CREATE_SWAP.FORM.BUTTONS.BUTTON1' | translate }} </ng-container>
<ng-container *ngIf="!(loading$ | async)">{{ 'CREATE_SWAP.FORM.BUTTONS.BUTTON1' | translate }}
</ng-container>
<zano-loader *ngIf="loading$ | async" [type]="'circle'"></zano-loader>
</button>
<a class="btn outline big w-100" routerLink="/wallet/swap">{{ 'CREATE_SWAP.FORM.BUTTONS.BUTTON2' | translate }}</a>
<a class="btn outline big w-100"
routerLink="/wallet/swap">{{ 'CREATE_SWAP.FORM.BUTTONS.BUTTON2' | translate }}</a>
</div>

<div *ngIf="errorRpc" class="error mt-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,7 @@ export class CreateSwapComponent implements OnDestroy {
};

if (receiverAddress.indexOf('@') === 0) {
const aliasName = receiverAddress;
const { aliases } = this.variablesService;
const alias = aliases.find(({ name }) => name === aliasName);

if (!alias) {
this.form.controls.receiverAddress.setErrors({
alias_not_found: true,
});
return;
}

params2.params['destination_address'] = alias.address;
params2.params['destination_address'] = this.aliasAddress;
} else {
params2.params['destination_address'] = receiverAddress;
}
Expand Down
2 changes: 2 additions & 0 deletions html_source/src/app/parts/services/variables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class VariablesService implements OnDestroy {

rpc_port!: number;

is_remote_node = false;

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

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

0 comments on commit 0b182ce

Please sign in to comment.