Skip to content

Expose the Pausable ABI as an interface#6559

Open
knoal wants to merge 2 commits into
OpenZeppelin:masterfrom
knoal:refactor/pausable-events-interface-5791
Open

Expose the Pausable ABI as an interface#6559
knoal wants to merge 2 commits into
OpenZeppelin:masterfrom
knoal:refactor/pausable-events-interface-5791

Conversation

@knoal

@knoal knoal commented May 28, 2026

Copy link
Copy Markdown

Summary

  • add IPausable to expose the Pausable events, errors, and paused() getter as a reusable interface artifact
  • make Pausable inherit IPausable so the implementation stays compiler-checked against the extracted ABI surface
  • add a test that validates the IPausable artifact contains only the expected Pausable ABI entries

Testing

  • ./node_modules/.bin/hardhat test test/utils/Pausable.test.js test/utils/IPausable.test.js
  • ./node_modules/.bin/prettier --check contracts/utils/IPausable.sol contracts/utils/Pausable.sol test/utils/IPausable.test.js
  • ./node_modules/.bin/eslint test/utils/IPausable.test.js
  • ./node_modules/.bin/solhint --config solhint.config.js --noPoster contracts/utils/IPausable.sol contracts/utils/Pausable.sol

Closes #5791

@knoal knoal requested a review from a team as a code owner May 28, 2026 13:41
@changeset-bot

changeset-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b0f32b5

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR extracts pause-related events and errors from the Pausable implementation contract into a new IPausable interface. The Pausable contract is updated to import and inherit from IPausable, removing duplicate event and error declarations. A test verifies the ABI correctly exposes the interface elements. A changeset documents that no changelog entry is needed for this ABI surface exposure.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Expose the Pausable ABI as an interface' directly and clearly summarizes the main change—extracting Pausable events/errors into an IPausable interface.
Description check ✅ Passed The description details the three main changes (adding IPausable, making Pausable inherit it, and adding tests) and aligns with the actual changeset modifications.
Linked Issues check ✅ Passed The PR fully satisfies the core requirement from issue #5791: moving Paused/Unpaused events into an IPausable interface and having Pausable implement it for modularity and ABI customization.
Out of Scope Changes check ✅ Passed All changes are directly in scope: IPausable interface created, Pausable updated to inherit it, and test added to validate the ABI surface. No extraneous modifications.
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 unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/utils/IPausable.test.js`:
- Around line 8-16: The test currently uses inclusive assertions which allow
extra ABI entries; update the assertions in IPausable.test.js to assert exact
membership and count by comparing the sorted/unique names array (variable names
from the ABI: abi -> names) to the exact expected list
['Paused','Unpaused','EnforcedPause','ExpectedPause','paused'] and assert the
length matches that list (or use deep equality on sets/arrays) and remove the
includes/does-not-include checks (replace expect(names).to.include/... and
expect(...).to.not.include/... with a single exact equality/length assertion
against the expected entries).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d8a80f1f-1a16-40c3-8d56-9f705c0d915c

📥 Commits

Reviewing files that changed from the base of the PR and between 74edc4b and 1d8a5ff.

📒 Files selected for processing (4)
  • .changeset/wet-mirrors-invent.md
  • contracts/utils/IPausable.sol
  • contracts/utils/Pausable.sol
  • test/utils/IPausable.test.js

Comment thread test/utils/IPausable.test.js Outdated
Comment on lines +8 to +16
const names = abi.map(fragment => fragment.name).filter(Boolean);

expect(names).to.include('Paused');
expect(names).to.include('Unpaused');
expect(names).to.include('EnforcedPause');
expect(names).to.include('ExpectedPause');
expect(names).to.include('paused');
expect(names).to.not.include('pause');
expect(names).to.not.include('unpause');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the ABI assertion exact, not just inclusive.

This test currently allows unexpected extra ABI entries. To match the “only expected entries” objective, assert exact membership (and length).

Suggested tightening
-    const names = abi.map(fragment => fragment.name).filter(Boolean);
-
-    expect(names).to.include('Paused');
-    expect(names).to.include('Unpaused');
-    expect(names).to.include('EnforcedPause');
-    expect(names).to.include('ExpectedPause');
-    expect(names).to.include('paused');
-    expect(names).to.not.include('pause');
-    expect(names).to.not.include('unpause');
+    const names = abi.map(fragment => fragment.name).filter(Boolean).sort();
+    expect(names).to.deep.equal([
+      'EnforcedPause',
+      'ExpectedPause',
+      'Paused',
+      'Unpaused',
+      'paused',
+    ].sort());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const names = abi.map(fragment => fragment.name).filter(Boolean);
expect(names).to.include('Paused');
expect(names).to.include('Unpaused');
expect(names).to.include('EnforcedPause');
expect(names).to.include('ExpectedPause');
expect(names).to.include('paused');
expect(names).to.not.include('pause');
expect(names).to.not.include('unpause');
const names = abi.map(fragment => fragment.name).filter(Boolean).sort();
expect(names).to.deep.equal([
'EnforcedPause',
'ExpectedPause',
'Paused',
'Unpaused',
'paused',
].sort());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/utils/IPausable.test.js` around lines 8 - 16, The test currently uses
inclusive assertions which allow extra ABI entries; update the assertions in
IPausable.test.js to assert exact membership and count by comparing the
sorted/unique names array (variable names from the ABI: abi -> names) to the
exact expected list
['Paused','Unpaused','EnforcedPause','ExpectedPause','paused'] and assert the
length matches that list (or use deep equality on sets/arrays) and remove the
includes/does-not-include checks (replace expect(names).to.include/... and
expect(...).to.not.include/... with a single exact equality/length assertion
against the expected entries).

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.

Move Paused and Unpaused event definitions to an interface

1 participant