Skip to content

Commit

Permalink
Better logic for match+decode
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <[email protected]>
  • Loading branch information
peterbroadhurst committed Jun 11, 2024
1 parent 44044d5 commit e3473ae
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/ethereum/get_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,19 @@ func (c *ethConnector) TransactionReceipt(ctx context.Context, req *ffcapi.Trans
extractSigner: req.ExtractSigner,
}
for _, ethLog := range ethReceipt.Logs {
var bestMatch *ffcapi.Event
for _, f := range filters {
event, matches, decoded, err := ee.filterEnrichEthLog(ctx, f, ethLog)
if matches && decoded && err == nil {
receiptResponse.Events = append(receiptResponse.Events, event)
break // don't try any more attempts to decode
// If we matched and decoded, this is our best match (overriding any earlier)
// If we only matched, then don't override a match+decode.
// Example: ERC-20 & ERC-721 ABIs - both match, but only one decodes
if (matches && err == nil) && (decoded || bestMatch == nil) {
bestMatch = event
}
}
if bestMatch != nil {
receiptResponse.Events = append(receiptResponse.Events, bestMatch)
}
}

}
Expand Down

0 comments on commit e3473ae

Please sign in to comment.