Skip to content

with_components support for ERC721Consecutive#1660

Merged
immrsd merged 3 commits intomainfrom
macros-support-erc721-consecutive
Mar 10, 2026
Merged

with_components support for ERC721Consecutive#1660
immrsd merged 3 commits intomainfrom
macros-support-erc721-consecutive

Conversation

@immrsd
Copy link
Copy Markdown
Collaborator

@immrsd immrsd commented Mar 5, 2026

Summary by CodeRabbit

  • New Features

    • Added support for ERC721Consecutive component extension with immutable configuration capabilities.
  • Validation & Warnings

    • Added validation checks to ensure required hooks are properly configured for ERC721Consecutive.
    • Added constraints preventing incompatible component combinations.
  • Tests

    • Added comprehensive test coverage for ERC721Consecutive functionality and component compatibility scenarios.

@immrsd immrsd requested review from bidzyyys and ericnordelo March 5, 2026 09:31
@immrsd immrsd self-assigned this Mar 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6740a604-1e33-4eb7-ae51-8bc6bd96541a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This pull request adds support for the ERC721Consecutive component extension to the macro system by introducing a new AllowedComponents variant, wiring it through deserialization and component registry, adding validation logic for required hooks, and including comprehensive tests.

Changes

Cohort / File(s) Summary
Component Registration
packages/macros/src/attribute/with_components/components.rs
Introduces ERC721Consecutive as a new AllowedComponents variant and registers it with ComponentInfo containing name, path, storage, event, and configuration properties.
Diagnostics and Warnings
packages/macros/src/attribute/with_components/diagnostics.rs
Adds ERC721_CONSECUTIVE_HOOKS_MISSING warning constant describing the requirement to call both before_update and after_update hooks for ERC721Consecutive.
Validation Logic
packages/macros/src/attribute/with_components/parser.rs
Extends checks for ERC721Enumerable and ERC721Consecutive to examine module body text, adds per-component hook validation to warn when before_update/after_update are missing for ERC721Consecutive, and updates immutable config check comment.
Tests
packages/macros/src/tests/test_with_components.rs
Adds comprehensive test coverage for ERC721Consecutive including basic usage, configuration variants, and incompatibility assertions with ERC721Enumerable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bidzyyys

Poem

🐰 A new component hops into view,
ERC721Consecutive through and through!
Hooks must pair, before and after too,
Tests verify the macro's magic brew. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding ERC721Consecutive support to the with_components macro system.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch macros-support-erc721-consecutive

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/macros/src/attribute/with_components/components.rs`:
- Around line 218-225: The ERC721Consecutive ComponentInfo entry uses a path
that omits the erc721_consecutive submodule, causing immutable-config validation
to generate a bad DefaultConfig import; update the ComponentInfo for
AllowedComponents::ERC721Consecutive (the entry with name
"ERC721ConsecutiveComponent" and path currently
"openzeppelin_token::erc721::extensions::ERC721ConsecutiveComponent") so its
path includes the erc721_consecutive submodule (so the immutable-config logic
will resolve DefaultConfig as
"openzeppelin_token::erc721::extensions::erc721_consecutive::DefaultConfig") —
adjust the `path` string in that ComponentInfo accordingly.

In `@packages/macros/src/attribute/with_components/parser.rs`:
- Around line 153-160: The hard-fail check in uses_erc721_enumerable /
uses_erc721_consecutive is too broad because body_code.contains(...) matches
comments/strings; change the secondary check to detect real component usage
patterns instead (e.g., look for the component! macro or concrete symbol tokens)
rather than raw substrings: update the condition that currently uses
body_code.contains("ERC721Enumerable") / body_code.contains("ERC721Consecutive")
to a scoped pattern match (for example a regex or simple string scan that
recognizes "component!(" with an ERC721... identifier, or better, inspect the
parsed tokens/AST for Ident/component! invocation) so only true component usage
flips the flag while leaving components_info.iter().any(|c| matches!(c.kind(),
AllowedComponents::...)) as is; reference functions/variables:
uses_erc721_enumerable, uses_erc721_consecutive, components_info,
AllowedComponents::ERC721Enumerable, AllowedComponents::ERC721Consecutive, and
body_code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55fc55f1-970f-4b9b-9268-af50ed388d49

📥 Commits

Reviewing files that changed from the base of the PR and between 2ce56dd and 379bc4a.

⛔ Files ignored due to path filters (5)
  • packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__cannot_use_erc721_consecutive_with_manual_erc721_enumerable.snap is excluded by !**/*.snap
  • packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__cannot_use_erc721_enumerable_with_manual_erc721_consecutive.snap is excluded by !**/*.snap
  • packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_consecutive.snap is excluded by !**/*.snap
  • packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_consecutive_custom_immutable_config.snap is excluded by !**/*.snap
  • packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_consecutive_no_config.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • packages/macros/src/attribute/with_components/components.rs
  • packages/macros/src/attribute/with_components/diagnostics.rs
  • packages/macros/src/attribute/with_components/parser.rs
  • packages/macros/src/tests/test_with_components.rs

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.18%. Comparing base (2ce56dd) to head (57f5b8f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1660      +/-   ##
==========================================
+ Coverage   94.01%   94.18%   +0.16%     
==========================================
  Files          96       96              
  Lines        2391     2391              
==========================================
+ Hits         2248     2252       +4     
+ Misses        143      139       -4     

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ce56dd...57f5b8f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 5, 2026

🧪 Cairo Contract Size Benchmark Diff

BYTECODE SIZE (felts) (limit: 81,920 felts)

No changes in felts.

SIERRA CONTRACT CLASS SIZE (bytes) (limit: 4,089,446 bytes)

Contract Old New Δ Note
ERC721ConsecutiveMock 265912 265914 🟢 +2
ERC721ConsecutiveMultiBatchMock 265702 265703 🟢 +1

This comment was generated automatically from benchmark diffs.

Copy link
Copy Markdown
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

Looks good to me, but make sure to resolve AI review comments.

Copy link
Copy Markdown
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

LGTM!

@immrsd immrsd merged commit 315a00a into main Mar 10, 2026
13 checks passed
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.

3 participants