Skip to content

Commit

Permalink
fix: Transactions send/receive boolean value fixed and the array is s…
Browse files Browse the repository at this point in the history
…orted in reverse
  • Loading branch information
i-asimkhan committed Feb 23, 2024
1 parent b5511c4 commit 7fd7da7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/mirai_web3/lib/services/web_modal_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,22 @@ class Web3ModalService {
]),
)
.then((logs) {
for (FilterEvent l in logs) {
for (FilterEvent l in logs.reversed.toList()) {
final result = transferEvent.decodeResults(l.topics!, l.data!);
final senderAddress = (result[0] as EthereumAddress);
final receiverAddress = (result[1] as EthereumAddress);
final walletAddress = EthereumAddress.fromHex(connectedWalletAddress);

if (result
.contains(EthereumAddress.fromHex(connectedWalletAddress))) {
if (senderAddress.toString() == walletAddress.toString() ||
receiverAddress.toString() == walletAddress.toString()) {
transactions.add(
TransactionDetails(
senderAddress: (result[0] as EthereumAddress).hex,
receiverAddress: (result[1] as EthereumAddress).hex,
senderAddress: senderAddress.hex,
receiverAddress: receiverAddress.hex,
amount: (result[2] as BigInt)
.toAmountInDouble(contractToken.decimals),
received: (result[1] as EthereumAddress).hex ==
connectedWalletAddress,
received:
receiverAddress.toString() == walletAddress.toString(),
tranHash: l.transactionHash ?? '',
tokenAddress: contractToken.address,
tokenName: contractToken.name,
Expand Down

0 comments on commit 7fd7da7

Please sign in to comment.