Skip to content

Update ERC7984Restricted and ERC7984Rwa to use canTransact#291

Merged
arr00 merged 2 commits intomasterfrom
chore/update-erc20-restricted
Jan 23, 2026
Merged

Update ERC7984Restricted and ERC7984Rwa to use canTransact#291
arr00 merged 2 commits intomasterfrom
chore/update-erc20-restricted

Conversation

@ernestognw
Copy link
Copy Markdown
Member

@ernestognw ernestognw commented Jan 14, 2026

Follow up to OpenZeppelin/openzeppelin-community-contracts#227

Summary by CodeRabbit

  • Refactor

    • Renamed public transaction permission check method from isUserAllowed to canTransact in ERC7984Restricted and ERC7984Rwa contracts. Updated interface definitions and implementation references across the token contracts.
  • Tests

    • Updated all test cases to validate behavior with the renamed method.

✏️ Tip: You can customize this high-level summary in your review settings.

@ernestognw ernestognw requested a review from a team as a code owner January 14, 2026 03:11
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 14, 2026

Deploy Preview for confidential-tokens ready!

Name Link
🔨 Latest commit da8d40a
🔍 Latest deploy log https://app.netlify.com/projects/confidential-tokens/deploys/6967098023000c000863cb19
😎 Deploy Preview https://deploy-preview-291--confidential-tokens.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 14, 2026

Walkthrough

Renames the public method isUserAllowed to canTransact across ERC7984 extension contracts, their interface definitions, and corresponding test files. The rename is applied consistently throughout the contract inheritance hierarchy and test suites without altering functional behavior.

Changes

Cohort / File(s) Summary
Changeset
.changeset/fast-humans-run.md
Added patch note documenting the public method rename from isUserAllowed to canTransact in ERC7984Restricted and ERC7984Rwa under openzeppelin-confidential-contracts.
Interfaces & Implementations
contracts/interfaces/IERC7984Rwa.sol, contracts/token/ERC7984/extensions/ERC7984Restricted.sol, contracts/token/ERC7984/extensions/ERC7984Rwa.sol
Renamed public view function isUserAllowed(address account) to canTransact(address account) in interface and implementations. Updated internal call sites in _checkRestriction to use new method name. Override declarations in ERC7984Rwa updated to target renamed interface method.
Tests
test/token/ERC7984/extensions/ERC7984Restricted.test.ts, test/token/ERC7984/extensions/ERC7984Rwa.test.ts
Updated test invocations from isUserAllowed(...) to canTransact(...) across DEFAULT, ALLOWED, BLOCKED, and permission-state verification tests. No changes to test logic or assertions beyond method name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • arr00
  • james-toussaint

Poem

🐰 A hop, a skip, a method's new name,
From isUserAllowed to canTransact—a cleaner frame!
Interfaces aligned, tests all in sync,
One refactor link, a thoughtful wink!
The rabbit approves with a wiggling nose. ✨

🚥 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 accurately summarizes the main change: renaming isUserAllowed to canTransact across two ERC7984 contracts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/update-erc20-restricted


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7defe3e and da8d40a.

📒 Files selected for processing (6)
  • .changeset/fast-humans-run.md
  • contracts/interfaces/IERC7984Rwa.sol
  • contracts/token/ERC7984/extensions/ERC7984Restricted.sol
  • contracts/token/ERC7984/extensions/ERC7984Rwa.sol
  • test/token/ERC7984/extensions/ERC7984Restricted.test.ts
  • test/token/ERC7984/extensions/ERC7984Rwa.test.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-22T09:21:34.470Z
Learnt from: james-toussaint
Repo: OpenZeppelin/openzeppelin-confidential-contracts PR: 160
File: test/token/ERC7984/extensions/ERC7984Rwa.test.ts:474-479
Timestamp: 2025-09-22T09:21:34.470Z
Learning: In ERC7984Freezable force transfers, the frozen balance is reset to the new balance only when the transferred amount exceeds the available balance (balance - frozen). If the transferred amount is within the available balance, the frozen amount remains unchanged. This is implemented via FHE.select(FHE.gt(encryptedAmount, confidentialAvailable(account)), confidentialBalanceOf(account), frozen).

Applied to files:

  • contracts/token/ERC7984/extensions/ERC7984Rwa.sol
  • contracts/interfaces/IERC7984Rwa.sol
📚 Learning: 2025-09-22T09:21:34.470Z
Learnt from: james-toussaint
Repo: OpenZeppelin/openzeppelin-confidential-contracts PR: 160
File: test/token/ERC7984/extensions/ERC7984Rwa.test.ts:474-479
Timestamp: 2025-09-22T09:21:34.470Z
Learning: For force transfers in ERC7984Freezable, the frozen balance should be reset to the new balance if the transfer amount exceeded the available balance. If the transfer amount was within the available balance, the frozen amount behavior needs clarification from the user.

Applied to files:

  • contracts/token/ERC7984/extensions/ERC7984Rwa.sol
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: boostsecurity - boostsecurityio/semgrep-pro
  • GitHub Check: slither
  • GitHub Check: tests
  • GitHub Check: coverage
🔇 Additional comments (7)
.changeset/fast-humans-run.md (1)

1-5: LGTM!

The changeset correctly documents the public API rename as a patch-level change.

contracts/interfaces/IERC7984Rwa.sol (1)

12-13: LGTM!

The interface correctly reflects the renamed function. The NatSpec comment accurately describes the function's purpose.

contracts/token/ERC7984/extensions/ERC7984Restricted.sol (2)

37-44: LGTM!

The function rename is correctly applied with consistent documentation updates. The logic remains unchanged—blocking only explicitly BLOCKED accounts.


86-89: LGTM!

The internal _checkRestriction correctly calls the renamed canTransact function.

contracts/token/ERC7984/extensions/ERC7984Rwa.sol (1)

206-209: LGTM!

The override correctly implements the renamed function, properly bridging the interface IERC7984Rwa and the parent ERC7984Restricted implementations.

test/token/ERC7984/extensions/ERC7984Rwa.test.ts (1)

99-106: LGTM!

The test correctly verifies the block/unblock lifecycle using the renamed canTransact function. The assertions properly validate the state transitions.

test/token/ERC7984/extensions/ERC7984Restricted.test.ts (1)

27-27: LGTM!

The method rename from isUserAllowed to canTransact is applied consistently across all four test cases in the restriction management suite. Test assertions remain unchanged and correctly verify the expected behavior for DEFAULT (true), ALLOWED (true), BLOCKED (false), and reset-to-DEFAULT (true) scenarios.

Also applies to: 33-33, 39-39, 46-46

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

Copy link
Copy Markdown
Member

@arr00 arr00 left a comment

Choose a reason for hiding this comment

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

Thank you!

@arr00 arr00 merged commit 931d9a5 into master Jan 23, 2026
16 checks passed
@arr00 arr00 deleted the chore/update-erc20-restricted branch January 23, 2026 19:35
@github-actions github-actions bot mentioned this pull request Mar 5, 2026
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
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