Fix indexed event decoding for non-dynamic topic values#955
Open
Copilot wants to merge 4 commits into
Open
Conversation
* Initial plan * Remove fisco-bcos.org URL, replace with GitHub repo URL in build.gradle Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ContractCodec.decodeIndexedEvent for non-dynamic indexed params
Fix indexed event decoding for non-dynamic topic values
Jun 16, 2026
kyonRay
approved these changes
Jun 17, 2026
There was a problem hiding this comment.
Pull request overview
This pull request fixes decoding of non-dynamic indexed event parameters (e.g., address indexed, uint256 indexed) in ContractCodec.decodeIndexedEvent(...), ensuring the by-interface event decode APIs correctly return indexed values instead of dropping/failing on them.
Changes:
- Decode non-dynamic indexed
VALUEparameters directly from the 32-byte topic payload using the ABI decode path. - Add a regression test covering indexed
address+ indexeduint256acrossdecodeIndexedEvent(...),decodeEventByInterface(...), anddecodeEventByInterfaceToString(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/main/java/org/fisco/bcos/sdk/v3/codec/ContractCodec.java |
Fixes decodeIndexedEvent to properly decode non-dynamic indexed VALUE params from topic bytes. |
src/test/java/org/fisco/bcos/sdk/v3/test/codec/abi/ABIEventTest.java |
Adds a focused regression test for indexed address/uint256 event decoding across multiple decode entry points. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1043
to
+1047
| } else if (indexedObject.getType() == ABIObject.ObjectType.VALUE) { | ||
| ABIObject decodedIndexedObject = | ||
| ContractCodecTools.decode( | ||
| indexedObject, Hex.decode(log.getTopics().get(i)), isWasm); | ||
| topics.add(contractCodecJsonWrapper.decode(decodedIndexedObject).asText()); |
Comment on lines
+3
to
+7
| import java.math.BigInteger; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import org.fisco.bcos.sdk.v3.codec.abi.TypeEncoder; | ||
| import org.fisco.bcos.sdk.v3.codec.abi.tools.TopicTools; |
Comment on lines
+51
to
+58
| List<String> topics = new ArrayList<>(); | ||
| topics.add(Numeric.toHexString(abiCodec.getFunctionEncoder().buildMethodId(eventSignature))); | ||
| TopicTools topicTools = new TopicTools(TestUtils.getCryptoSuite()); | ||
| topics.add(topicTools.addressToTopic(from)); | ||
| topics.add(topicTools.integerToTopic(id)); | ||
|
|
||
| EventLog log = new EventLog(Numeric.toHexString(TypeEncoder.encode(new Uint256(value))), topics); | ||
| ABIDefinition abiDefinition = TestUtils.getContractABIDefinition(indexedAbi).getEvents().get("Transfer").get(0); |
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



ContractCodec.decodeIndexedEvent(log, abiDefinition)mishandled non-dynamic indexed event params such asaddress indexedanduint256 indexed. The by-interface event decode path could drop or fail on common event shapes because bare VALUE topics were routed through the JSON struct decoder.Decoder path correction
VALUEparams directly from the 32-byte topic payload via the existing ABI decode path.Behavioral impact
address,uintN, and other static value types.decodeEventByInterface(...)/decodeIndexedEvent(...)for standard transfer-style events.Regression coverage
addressand indexeduint256.decodeIndexedEvent(...)decodeEventByInterface(...)decodeEventByInterfaceToString(...)Example shape covered by the regression test:
Before this change, the indexed topics for
from/idcould fail in the by-interface decode path; after this change, they decode to their expected values.