Compare commits
1 Commits
b799686cd4
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
256acbeeec |
@@ -153,9 +153,14 @@ async function fetchRecentTransactions(address, blockscoutUrl, count = 25) {
|
||||
|
||||
// When a token transfer shares a hash with a normal tx, the normal tx
|
||||
// is the contract call (0 ETH) and the token transfer has the real
|
||||
// amount and symbol. Replace the normal tx with the token transfer,
|
||||
// but preserve contract call metadata (direction, label, method) so
|
||||
// swaps and other contract interactions display correctly.
|
||||
// amount and symbol. Preserve contract call metadata (direction, label,
|
||||
// method) so swaps and other contract interactions display correctly.
|
||||
//
|
||||
// A single tx hash can produce multiple token transfers (e.g. a swap
|
||||
// sends token A and receives token B). Use a composite key
|
||||
// (hash:contractAddress) so every transfer is preserved. The original
|
||||
// normal-tx entry (keyed by bare hash) is removed when at least one
|
||||
// token transfer replaces it.
|
||||
for (const tt of ttJson.items || []) {
|
||||
const parsed = parseTokenTransfer(tt, addrLower);
|
||||
const existing = txsByHash.get(parsed.hash);
|
||||
@@ -164,8 +169,12 @@ async function fetchRecentTransactions(address, blockscoutUrl, count = 25) {
|
||||
parsed.directionLabel = existing.directionLabel;
|
||||
parsed.isContractCall = true;
|
||||
parsed.method = existing.method;
|
||||
// Remove the bare-hash normal tx so it isn't duplicated
|
||||
txsByHash.delete(parsed.hash);
|
||||
}
|
||||
txsByHash.set(parsed.hash, parsed);
|
||||
// Use composite key so multiple token transfers per tx are kept
|
||||
const compositeKey = parsed.hash + ":" + (parsed.contractAddress || "");
|
||||
txsByHash.set(compositeKey, parsed);
|
||||
}
|
||||
|
||||
const txs = [...txsByHash.values()];
|
||||
|
||||
Reference in New Issue
Block a user