Skip to content

Commit

Permalink
Merge pull request #865 from makerdao/update-dup-delegate-event-check
Browse files Browse the repository at this point in the history
Add unique key to duplicate delegate event check
  • Loading branch information
adamgoth authored Apr 9, 2024
2 parents 46bbe94 + 556bbdd commit f076f62
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pages/api/address/[address]/delegated-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ export default withApiHandler(
delegatedTo = await fetchDelegatedTo(address, network);
}

// filter out duplicate txs
// filter out duplicate txs for the same address
const txHashes = {};
const filtered = delegatedTo.filter(historyItem => {
let duplicateFound = false;
historyItem.events.forEach(event => {
if (txHashes[event.hash]) duplicateFound = true;
txHashes[event.hash] = true;
const uniqueKey = `${event.hash}-${historyItem.address}`;
if (txHashes[uniqueKey]) duplicateFound = true;
txHashes[uniqueKey] = true;
});
return !duplicateFound;
});
Expand Down

0 comments on commit f076f62

Please sign in to comment.