fix: filter contract events by address before decoding#6224
Merged
Conversation
ap211unitech
approved these changes
Nov 18, 2025
TarikGul
approved these changes
Nov 19, 2025
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #5583
Description
When a contract calls another contract, both emit ContractEmitted events. The current implementation attempts to decode all events using only the calling contract's ABI, resulting in errors like:
This occurs because the decoder tries to interpret events from Contract B using Contract A's ABI, as mentioned in #5583 (comment).
This PR filters events by contract address before decoding. Each contract instance now only decodes events where
event.data[0](the emitting contract address) matchesthis.address. Events from other contracts are skipped andlogged at the debug level for visibility.
Impact on Different Ink Contract Metadata Versions
ink! v4 (metadata v4): Uses index-based event lookup. This fix is critical as it prevents
Unable to find event with index Xerrors when cross-contract calls occur.ink! v5+ (metadata v5/v6): Uses signature topics for event matching, which provides better event discrimination. However, this fix is still beneficial because it eliminates error logs when signature topics don't match between contracts