Skip to content

Commit

Permalink
refactor: use isSameAddress in log utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Nov 11, 2024
1 parent 5a8c853 commit 1501333
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/sdk-router/src/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Log, Provider } from '@ethersproject/abstract-provider'
import { Contract } from '@ethersproject/contracts'
import { Interface } from '@ethersproject/abi'

import { isSameAddress } from './addressUtils'

/**
* Extracts the first log from a transaction receipt that matches
* the provided contract and any of the provided event names.
Expand All @@ -26,7 +28,10 @@ export const getMatchingTxLog = async (
const topics = getEventTopics(contract.interface, eventNames)
// Find the log with the correct contract address and topic matching any of the provided topics
const matchingLog = txReceipt.logs.find((log) => {
return log.address === contract.address && topics.includes(log.topics[0])
return (
isSameAddress(log.address, contract.address) &&
topics.includes(log.topics[0])
)
})
if (!matchingLog) {
// Throw an error and include the event names in the message
Expand Down

0 comments on commit 1501333

Please sign in to comment.