Skip to content

Commit

Permalink
Merge pull request #108 from NazarUsov/testnet/issues
Browse files Browse the repository at this point in the history
Feature "Migrate"
  • Loading branch information
sowle authored Apr 8, 2024
2 parents 49aaf05 + 12fe778 commit 705912e
Show file tree
Hide file tree
Showing 48 changed files with 790 additions and 53 deletions.
13 changes: 13 additions & 0 deletions html_source/src/app/api/models/rpc.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export interface GetBareOutsStats {
expected_total_fee: number;
total_amount: number;
total_bare_outs: number;
txs_count: number;
}

export interface SweepBareOuts {
amount_swept: number;
bare_outs_swept: number;
fee_spent: number;
txs_sent: number;
}
20 changes: 8 additions & 12 deletions html_source/src/app/api/models/swap.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ export interface ProposalDetails {
expiration_time: number;
fee_paid_by_a: number;
mixins: number;
to_initiator: [
{
amount: number | string;
asset_id: string;
}
];
to_finalizer: [
{
amount: number | string;
asset_id: string;
}
];
to_initiator: {
amount: number | string;
asset_id: string;
}[];
to_finalizer: {
amount: number | string;
asset_id: string;
}[];
}
1 change: 1 addition & 0 deletions html_source/src/app/api/models/wallet.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class Wallet {
is_watch_only: boolean;
exclude_mining_txs: boolean;
alias_available: boolean;
has_bare_unspent_outputs = false;

alias?: Partial<Alias>;
wakeAlias?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion html_source/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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';
import { ZanoLoadersService } from '@parts/services/zano-loaders.service';

@Component({
Expand Down Expand Up @@ -184,6 +183,7 @@ export class AppComponent implements OnInit, OnDestroy {
wallet.balances = data.balances;
wallet.mined_total = data.minied_total;
wallet.alias_available = data.is_alias_operations_available;
wallet.has_bare_unspent_outputs = data.has_bare_unspent_outputs;
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { FlexLayoutModule } from '@angular/flex-layout';
import { TranslateModule } from '@ngx-translate/core';
import { ReactiveFormsModule } from '@angular/forms';
import { GetAssetInfoPipe } from '@parts/pipes';
import { CopyButtonComponent } from '@parts/components/copy-button.component';

@NgModule({
declarations: [SendModalComponent, SendDetailsModalComponent],
imports: [CommonModule, TranslateModule, FlexLayoutModule, ReactiveFormsModule, GetAssetInfoPipe],
imports: [CommonModule, TranslateModule, FlexLayoutModule, ReactiveFormsModule, GetAssetInfoPipe, CopyButtonComponent],
exports: [SendModalComponent, SendDetailsModalComponent],
})
export class WalletModalsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<div class="label max-w-19-rem w-100">
{{ 'CONFIRM_SWAP.FORM.TABLE.LABELS.LABEL1' | translate }}
</div>
<div *ngFor="let item of proposalDetails.to_initiator" class="text">
{{ item.amount | intToMoney }}
{{ (item.asset_id | getAssetInfo)?.ticker || '???' }}

<div class="text">
<p *ngFor="let item of proposalDetails.to_initiator">{{ item.amount | intToMoney }} {{ (item.asset_id | getAssetInfo)?.ticker || '???' }}</p>
</div>
</div>

Expand All @@ -34,9 +34,11 @@
<div class="label max-w-19-rem w-100">
{{ 'CONFIRM_SWAP.FORM.TABLE.LABELS.LABEL2' | translate }}
</div>
<div *ngFor="let item of proposalDetails.to_finalizer" class="text">
{{ item.amount | intToMoney }}
{{ (item.asset_id | getAssetInfo)?.ticker || '???' }}
<div class="text">
<p *ngFor="let item of proposalDetails.to_finalizer">
{{ item.amount | intToMoney }}
{{ (item.asset_id | getAssetInfo)?.ticker || '???' }}
</p>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions html_source/src/app/pages/wallet/wallet.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { BreadcrumbsComponent } from '@parts/components/breadcrumbs/breadcrumbs.
import { BackButtonComponent } from '@parts/components/back-button/back-button.component';
import { WalletModalsModule } from './tabs/send/modals/wallet-modals.module';
import { GetAssetInfoPipe } from '@parts/pipes/get-asset-info.pipe';
import { MigrateWalletToZarcanumComponent } from './wallet/modals/migrate-wallet-to-zarcanum/migrate-wallet-to-zarcanum.component';
import { SuccessSweepBareOutsComponent } from './wallet/modals/success-sweep-bare-outs/success-sweep-bare-outs.component';

@NgModule({
declarations: [
Expand All @@ -48,6 +50,8 @@ import { GetAssetInfoPipe } from '@parts/pipes/get-asset-info.pipe';
ReceiveComponent,
ExportImportComponent,
SendComponent,
MigrateWalletToZarcanumComponent,
SuccessSweepBareOutsComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="p-2 border-radius-0_8-rem bg-light-blue w-100 max-h-90-vh" fxFlex="0 1 54rem">
<div class="overflow-hidden" fxFlexFill fxLayout="column">
<h3 class="title mb-2" fxFlex="0 0 auto">
{{ 'MIGRATE_WALLET_TO_ZARCANUM.TITLE' | translate }}
</h3>

<div class="details mb-2">
<p class="mb-2 mt-2">
{{ 'MIGRATE_WALLET_TO_ZARCANUM.TEXT1' | translate: {
total_bare_outs: dialogData.total_bare_outs,
total_amount: dialogData.total_amount | intToMoney
} }}
</p>
<p class="text-align-center cursor-pointer mb-2" fxLayout="row" fxLayoutAlign="start center"
(click)="openZarcanumMigration()">
<i class="icon question-circle mr-0_5"></i>
<span class="color-primary">{{ 'MIGRATE_WALLET_TO_ZARCANUM.LINK1' | translate }}</span>
</p>
<hr class="mb-2">
<p class="mb-2">
{{ 'MIGRATE_WALLET_TO_ZARCANUM.TEXT2' | translate: {
txs_count: dialogData.txs_count,
expected_total_fee: dialogData.expected_total_fee | intToMoney
} }}
</p>
</div>

<div class="controls w-100" fxFlex="0 0 auto" fxLayout="row nowrap" fxLayoutGap="1rem">
<button class="primary big w-100" type="button" (click)="migrate()">
{{ 'MIGRATE_WALLET_TO_ZARCANUM.BUTTON1' | translate }}
</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.details {
padding: 0 2rem;
border-radius: 0.8rem;
border: 1px solid #33426E;

hr {
border: none;
border-bottom: 1px solid #ffffff10;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, inject, NgZone } from '@angular/core';
import { GetBareOutsStats, SweepBareOuts } from '@api/models/rpc.models';
import { Dialog, DIALOG_DATA, DialogConfig, DialogRef } from '@angular/cdk/dialog';
import { BackendService } from '@api/services/backend.service';
import { VariablesService } from '@parts/services/variables.service';
import { ParamsCallRpc } from '@api/models/call_rpc.model';
import { ModalService } from '@parts/services/modal.service';
import { SuccessSweepBareOutsComponent } from '../success-sweep-bare-outs/success-sweep-bare-outs.component';
import { ScrollStrategy, ScrollStrategyOptions } from '@angular/cdk/overlay';
import { ZARCANUM_MIGRATION } from '@parts/data/constants';

@Component({
selector: 'app-migrate-wallet-to-zarcanum',
templateUrl: './migrate-wallet-to-zarcanum.component.html',
styleUrls: ['./migrate-wallet-to-zarcanum.component.scss'],
})
export class MigrateWalletToZarcanumComponent {
readonly dialogData: GetBareOutsStats = inject<GetBareOutsStats>(DIALOG_DATA);
private readonly _scrollStrategyOptions: ScrollStrategyOptions = inject(ScrollStrategyOptions);
private readonly _scrollStrategyNoop: ScrollStrategy = this._scrollStrategyOptions.noop();
private readonly _dialog = inject(Dialog);
private readonly _dialogRef = inject(DialogRef);
private readonly _backendService = inject(BackendService);
private readonly _variableService = inject(VariablesService);
private readonly _modalService = inject(ModalService);
private readonly _ngZone = inject(NgZone);

migrate(): void {
const {
currentWallet: { wallet_id },
} = this._variableService;
const params: ParamsCallRpc = { id: 0, jsonrpc: '2.0', method: 'sweep_bare_outs', params: {} };
this._backendService.call_wallet_rpc([wallet_id, params], (status, response_data) => {
this._ngZone.run(() => {
if (response_data?.result) {
const data = response_data.result;

const dialogConfig: DialogConfig<SweepBareOuts> = {
maxWidth: '90vw',
width: '540px',
scrollStrategy: this._scrollStrategyNoop,
data,
};

this._dialog.open(SuccessSweepBareOutsComponent, dialogConfig);
} else {
const message = response_data.error;
this._modalService.prepareModal('error', message);
}

this._dialogRef.close();
});
});
}

openZarcanumMigration(): void {
this._backendService.openUrlInBrowser(ZARCANUM_MIGRATION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<div class="modal p-2 border-radius-0_8-rem bg-light-blue w-100 max-h-100" fxFlex="0 1 54rem">
<div class="wrapper w-100" fxFlex fxLayout="column">
<h3 class="title mb-2" fxFlex="0 0 auto">
{{ 'SEND_DETAILS_MODAL.TITLE1' | translate }}
</h3>

<div class="content mb-2 overflow-x-hidden overflow-y-auto" fxFlex="1 1 auto" fxLayout="column">
<div class="status mb-2" fxFlex="0 0 auto" fxLayout="column" fxLayoutAlign="center center">
<div class="image">
<img alt="success" src="assets/icons/aqua/transaction_success.svg" />
</div>

<p class="color-primary mt-2">
{{
'TOR_LIB_STATE.STATE_SENT_SUCCESS' | translate
}}
</p>
</div>

<div class="details border-radius-0_8-rem overflow-hidden" fxFlex="0 0 auto" fxLayout="column">
<div
(click)="toggleDetails()"
class="header overflow-hidden py-1 px-2 w-100 cursor-pointer"
fxLayout="row"
fxLayoutAlign="space-between center"
[ngStyle]="{'border-radius': (stateDetails$ | async) ? '0.8rem 0.8rem 0 0' : '0.8rem'}"
>
<p class="title text-ellipsis mr-2">
{{ 'SEND_DETAILS_MODAL.TITLE2' | translate }}
</p>
<button fxLayout="row" fxLayoutAlign="center center">
<img
*ngIf="!(stateDetails$ | async)"
alt="dropdown-arrow-down"
src="assets/icons/white/dropdown-arrow-down.svg"
/>
<img *ngIf="stateDetails$ | async" alt="dropdown-arrow-up" src="assets/icons/white/dropdown-arrow-up.svg" />
</button>
</div>
<div
[class.px-2]="stateDetails$ | async"
[class.py-1]="stateDetails$ | async"
[fxHide]="!(stateDetails$ | async)"
[ngStyle]="{'border-radius': (stateDetails$ | async) ? '0 0 0.8rem 0.8rem ' : '0'}"
class="details-wrapper"
fxFlex="1 1 auto"
fxLayout="row"
>
<ul class="details-list scrolled-content">
<li
class="item mb-1"
fxLayout="row nowrap"
fxLayoutAlign=" center"
>
<p>{{ 'SUCCESS_SWEEP_BARE_OUTS.DETAILS' | translate: {
txs_sent: dialogData.txs_sent,
bare_outs_swept: dialogData.bare_outs_swept,
amount_swept: dialogData.amount_swept | intToMoney,
fee_spent: dialogData.fee_spent | intToMoney } }}
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="controls" fxFlex="0 0 auto">
<button class="primary big w-100" (click)="close()">
{{ 'Ok' | translate }}
</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, inject, OnInit } from '@angular/core';
import { SweepBareOuts } from '@api/models/rpc.models';
import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog';
import { BehaviorSubject } from 'rxjs';

@Component({
selector: 'app-success-sweep-bare-outs',
templateUrl: './success-sweep-bare-outs.component.html',
styleUrls: ['./success-sweep-bare-outs.component.scss']
})
export class SuccessSweepBareOutsComponent {
readonly dialogData: SweepBareOuts = inject<SweepBareOuts>(DIALOG_DATA);
private readonly _dialogRef = inject(DialogRef);
stateDetails$ = new BehaviorSubject<boolean>(false);

toggleDetails(): void {
this.stateDetails$.next(!this.stateDetails$.value);
}

close(): void {
this._dialogRef.close();
}
}
Loading

0 comments on commit 705912e

Please sign in to comment.