Skip to content

Commit

Permalink
Merge pull request #115 from NazarUsov/testnet/issues
Browse files Browse the repository at this point in the history
Update history
  • Loading branch information
sowle authored May 10, 2024
2 parents 6f11b2f + 9695b51 commit 1da7572
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions html_source/src/app/pages/wallet/tabs/history/history.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ import { zanoAssetInfo } from '@parts/data/assets';
<div class="row-divider"></div>
</thead>
<tbody>
<ng-container *ngFor="let transaction of variablesService.currentWallet.history">
<ng-container *ngFor="let transaction of variablesService.currentWallet.history; let i = index">
<tr
(click)="openDetails(transaction.tx_hash)"
[class.locked-transaction]="!transaction.is_mining && transaction.unlock_time > 0"
>
<!--<td>{{ 21 - i }}</td>-->
<!-- Status -->
<td>
<ng-container *ngIf="transaction.subtransfers; else noSubtransfersStatusTemplate">
Expand Down Expand Up @@ -187,18 +188,20 @@ import { zanoAssetInfo } from '@parts/data/assets';
<ng-container
*ngIf="
!subtransfer.is_income
? true
? !subtransfer.amount.eq(transaction.fee ?? 0) || isSelfTransaction(transaction) || (isSwapTransaction(transaction) && isFinalizator(transaction))
: subtransfer.amount.toNumber() !== 0
"
>
<div class="text-ellipsis">
<span *ngIf="!subtransfer.is_income">
<ng-container *ngIf="isInitiator(transaction)">{{ subtransfer.amount.minus(transaction.fee ?? 0).negated() | intToMoney }}</ng-container>
<ng-container *ngIf="isFinalizator(transaction)">{{ subtransfer.amount.negated() | intToMoney }}</ng-container>
</span>
<span *ngIf="!subtransfer.is_income">
<ng-container
*ngIf="isInitiator(transaction)">{{ subtransfer.amount.minus(transaction.fee ?? 0).negated() | intToMoney }}</ng-container>
<ng-container
*ngIf="isFinalizator(transaction)">{{ subtransfer.amount.negated() | intToMoney }}</ng-container>
</span>
<span *ngIf="subtransfer.is_income">
{{ subtransfer.amount | intToMoney }}
</span>
{{ subtransfer.amount | intToMoney }}
</span>
{{ (subtransfer.asset_id | getAssetInfo)?.ticker || '???' }}
</div>
</ng-container>
Expand Down Expand Up @@ -468,6 +471,10 @@ export class HistoryComponent implements OnInit, OnDestroy {
return true;
}

if (asset_id === zanoAssetInfo.asset_id && this.isSwapTransaction(transaction) && this.isFinalizator(transaction)) {
return true;
}

return !(asset_id === zanoAssetInfo.asset_id && is_income === false && amount.eq(fee));

}
Expand All @@ -479,10 +486,28 @@ export class HistoryComponent implements OnInit, OnDestroy {
}));
}

isSwapTransaction(transaction: Transaction): boolean {
const { subtransfers } = transaction;
const arr = subtransfers.map(({ is_income }) => is_income);
const condition1 = arr.some((value) => value);
const condition2 = arr.some((value) => !value);
return condition1 && condition2;
}

isFinalizator(transaction: Transaction): boolean {
return !this.isInitiator(transaction);
}

isSelfTransaction(transaction: Transaction): boolean {
const { remote_addresses, employed_entries: { receive, spent }, subtransfers, fee } = transaction;

const condition1 = remote_addresses?.includes(this.variablesService.currentWallet?.address);
const condition2 = [...receive, ...spent].map(({ asset_id }) => asset_id === zanoAssetInfo.asset_id).every(Boolean);
const condition3 = subtransfers.length === 1 && subtransfers[0].asset_id === zanoAssetInfo.asset_id && subtransfers[0].amount.eq(fee);

return condition1 && condition2 && condition3;
}

init(): void {
let restore = false;
if (hasOwnProperty(this.variablesService.after_sync_request, String(this.variablesService.currentWallet.wallet_id))) {
Expand Down

0 comments on commit 1da7572

Please sign in to comment.