Skip to content

Add an optional parameters to the InteroperableAddress parssing functions#6481

Open
Amxx wants to merge 3 commits intoOpenZeppelin:masterfrom
Amxx:feature/InteroperableAddress/failOnExtraBytes
Open

Add an optional parameters to the InteroperableAddress parssing functions#6481
Amxx wants to merge 3 commits intoOpenZeppelin:masterfrom
Amxx:feature/InteroperableAddress/failOnExtraBytes

Conversation

@Amxx
Copy link
Copy Markdown
Collaborator

@Amxx Amxx commented Apr 21, 2026

Requested by MatterLabs

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@Amxx Amxx requested a review from a team as a code owner April 21, 2026 15:23
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: 5c11cc8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Amxx Amxx added this to the 5.7 milestone Apr 21, 2026
@Amxx Amxx requested a review from ernestognw April 21, 2026 15:23
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Walkthrough

This change introduces optional failOnExtraBytes boolean parameters to all parsing functions in the InteroperableAddress utility for ERC-7930 v1 format. New overloads are added for parseV1, parseV1Calldata, tryParseV1, tryParseV1Calldata and their EVM-specific counterparts (parseEvmV1, parseEvmV1Calldata, tryParseEvmV1, tryParseEvmV1Calldata). When failOnExtraBytes is true, parsing inputs with trailing unconsumed bytes now fail; when false (the default for backward compatibility), extra bytes are ignored. Existing function overloads delegate to the new ones with failOnExtraBytes=false. Tests validate both the default ignore-trailing-bytes behavior and the new rejection behavior.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding optional parameters to InteroperableAddress parsing functions. However, it contains a minor typo ('parssing' should be 'parsing').
Description check ✅ Passed The description is directly related to the changeset, noting it was requested by MatterLabs and includes a checklist tracking tests and changesets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.changeset/tall-aliens-matter.md (1)

5-5: Clarify default behavior in the changeset note.

Consider explicitly stating that trailing bytes are still ignored by default for backward compatibility, and only rejected when failOnExtraBytes=true.

✍️ Suggested wording
-`InteroperableAddress`: Add an optional `failOnExtraBytes` parameter to all parsing functions. If enabled, the parsing will reject any input that contains extra bytes.
+`InteroperableAddress`: Add an optional `failOnExtraBytes` parameter to all parsing functions. By default (`false`), trailing bytes are ignored for backward compatibility; when set to `true`, parsing rejects inputs with extra trailing bytes.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/tall-aliens-matter.md at line 5, Update the changeset entry for
InteroperableAddress to explicitly state that all parsing functions gain an
optional failOnExtraBytes parameter which defaults to false for backward
compatibility, meaning trailing/extra bytes are ignored by default; clarify that
only when failOnExtraBytes=true will parsing reject inputs containing extra
bytes. Mention the default behavior and the opt-in nature of failOnExtraBytes so
consumers understand compatibility and the new strict mode.
test/utils/draft-InteroperableAddress.test.js (1)

71-207: Consider extracting helper assertions to reduce repetition.

The new cases are correct, but this block is quite repetitive; a small helper per API family would make future updates safer and easier.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/utils/draft-InteroperableAddress.test.js` around lines 71 - 207, Tests
repeat the same assertion patterns for the V1 and EVM families; extract small
helpers to reduce duplication: create reusable assertion helpers (e.g.,
assertParseFamily(mock, fnNamesArray, input, ignoreTrailing?, expected) and
assertTryParseFamily(...)) and use them for [$parseV1, $parseV1Calldata,
$tryParseV1, $tryParseV1Calldata] and for the EVM variants [$parseEvmV1,
$parseEvmV1Calldata, $tryParseEvmV1, $tryParseEvmV1Calldata, $formatEvmV1],
parameterizing the input (binary, binaryExtra), the ignoreTrailing flag
(ethers.Typed.bool(true/false)), and expected outputs (expected,
[true,...expected], error cases), then replace the duplicated await expect(...)
blocks with calls to these helpers referencing symbols like this.mock,
binaryExtra, expected, reference, address, and ethers.Typed.bool to keep
behavior identical while removing repetition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.changeset/tall-aliens-matter.md:
- Line 5: Update the changeset entry for InteroperableAddress to explicitly
state that all parsing functions gain an optional failOnExtraBytes parameter
which defaults to false for backward compatibility, meaning trailing/extra bytes
are ignored by default; clarify that only when failOnExtraBytes=true will
parsing reject inputs containing extra bytes. Mention the default behavior and
the opt-in nature of failOnExtraBytes so consumers understand compatibility and
the new strict mode.

In `@test/utils/draft-InteroperableAddress.test.js`:
- Around line 71-207: Tests repeat the same assertion patterns for the V1 and
EVM families; extract small helpers to reduce duplication: create reusable
assertion helpers (e.g., assertParseFamily(mock, fnNamesArray, input,
ignoreTrailing?, expected) and assertTryParseFamily(...)) and use them for
[$parseV1, $parseV1Calldata, $tryParseV1, $tryParseV1Calldata] and for the EVM
variants [$parseEvmV1, $parseEvmV1Calldata, $tryParseEvmV1,
$tryParseEvmV1Calldata, $formatEvmV1], parameterizing the input (binary,
binaryExtra), the ignoreTrailing flag (ethers.Typed.bool(true/false)), and
expected outputs (expected, [true,...expected], error cases), then replace the
duplicated await expect(...) blocks with calls to these helpers referencing
symbols like this.mock, binaryExtra, expected, reference, address, and
ethers.Typed.bool to keep behavior identical while removing repetition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4bd56e3d-9c92-4b42-9d90-cd3847283679

📥 Commits

Reviewing files that changed from the base of the PR and between b8c7b9e and 55d06ce.

📒 Files selected for processing (3)
  • .changeset/tall-aliens-matter.md
  • contracts/utils/draft-InteroperableAddress.sol
  • test/utils/draft-InteroperableAddress.test.js

Copy link
Copy Markdown

@MycCellium420 MycCellium420 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean approach — overloading with defaults keeps backward compatibility intact while giving callers strict validation when needed.

A couple of minor things:

Title typo: "parssing" → "parsing"

Nit: The expectedLength extraction in tryParseV1 / tryParseV1Calldata is a nice cleanup — reduces the repeated 0x06 + chainReferenceLength + addrLength calculation even for the non-strict path.

Docs: Checkbox is unchecked — is documentation planned for a follow-up?

Tests look thorough — covers default/explicit-false/true for all memory and calldata variants. LGTM otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants