Skip to content

Commit

Permalink
[FIX] Filter irrelevant effects for ERC token transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbazan7 committed Nov 18, 2024
1 parent 2ab2214 commit 50c46c2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/store/wallet/effects/transactions/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,19 @@ const ProcessTx =
];
}

// New data structure for ERC20 token transactions
if (tx.effects?.[0] && IsERCToken(tx.coin, tx.chain)) {
tx.amount = tx.effects.reduce(
(total, {amount}) => total + Number(amount),
0,
tx.effects = tx.effects.filter(
(effect: any) =>
effect?.contractAddress?.toLowerCase() ===
wallet?.tokenAddress?.toLowerCase(),
);
tokenAddress = tx.effects[0].contractAddress?.toLowerCase();
if (tx.effects[0]) {
tx.amount = tx.effects.reduce(
(total, {amount}) => total + Number(amount),
0,
);
tokenAddress = tx.effects[0].contractAddress?.toLowerCase();
}
}

if (tx.coin === wallet.currencyAbbreviation) {
Expand Down

0 comments on commit 50c46c2

Please sign in to comment.