Skip to content

Commit

Permalink
EVM - fetch latest swap event
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Sep 5, 2023
1 parent 9188428 commit 20110ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wormhole-connect/src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ export const fetchSwapEvent = async (txData: ParsedRelayerMessage) => {
BigNumber.from(toNativeTokenAmount),
tokenDecimals,
);
const match = events.filter((e: any) => {
return normalized.eq(e.args[3]);
});
return match ? match[0]?.args?.[4] : null;
const matches = events
.sort((a: any, b: any) => b.blockNumber - a.blockNumber)
.filter((e: any) => {
return normalized.eq(e.args[3]);
});
return matches ? matches[0]?.args?.[4] : null;
}
return null;
};

0 comments on commit 20110ce

Please sign in to comment.