Skip to content

Fixed: Use named imports across Compact contracts - #769

Open
eminence-technology wants to merge 1 commit into
OpenZeppelin:mainfrom
eminence-technology:feat/named-imports-406
Open

Fixed: Use named imports across Compact contracts #769
eminence-technology wants to merge 1 commit into
OpenZeppelin:mainfrom
eminence-technology:feat/named-imports-406

Conversation

@eminence-technology

@eminence-technology eminence-technology commented Aug 7, 2026

Copy link
Copy Markdown

Types of changes

What types of changes does your code introduce to OpenZeppelin Midnight Contracts?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #406

Convert blanket prefixed imports to named imports of used symbols only, keeping prefixes and call sites unchanged.
Before:

import "../security/Initializable" prefix Initializable_;

After:

import { initialize, assertInitialized } from "../security/Initializable" prefix Initializable_;

This follows the approach confirmed in #406: named imports for clarity, prefixes retained for readability without LSP “go to definition.”

Also:

Remove an unused Utils_ import from ShieldedAccessControl
Update NatSpec import examples in AccessControl and ShieldedAccessControl
Scope: 58 .compact files. No circuit logic or call-site changes.

PR Checklist

 I have read the [Contributing Guide](vscode-file://vscode-app/usr/share/cursor/resources/app/out/vs/code/electron-sandbox/CONTRIBUTING.md#your-first-code-contribution)

 I have added tests that prove my fix is effective or that my feature works. See [GUIDELINES.md#testing](vscode-file://vscode-app/usr/share/cursor/resources/app/out/vs/code/electron-sandbox/GUIDELINES.md#testing) for more information.

 I have added documentation for new methods or changes to existing method behavior. See [GUIDELINES.md#documentation](vscode-file://vscode-app/usr/share/cursor/resources/app/out/vs/code/electron-sandbox/GUIDELINES.md#documentation) for more information.

CI Workflows Are Passing
Further comments
No new tests were added: this is an import-only change with identical runtime behavior. Verified locally with yarn compile, **yarn test** and **yarn test:live** with docker for those 20 skipped one (1476 passed, 20 skipped live-only), and yarn lint. Will check CI Workflows Are Passing once GitHub Actions is green.

Notes:
- Pulled latest code before creating PR.
- Leave CI unchecked until checks pass, then edit the PR and tick it.
- Suggested title: **Use named imports across Compact contracts**.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Refactor**
  * Streamlined internal module usage across contract, token, security, multisignature, and cryptographic components.
  * Reduced unnecessary imports while preserving existing functionality and interfaces.
  * Updated test support components and integration fixtures to use only the functionality they require.

* **Bug Fixes**
  * No user-facing behavior or public contract declarations changed.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Convert blanket prefixed imports to named imports of used symbols only,
keeping prefixes and call sites unchanged. Fixes OpenZeppelin#406.
@eminence-technology
eminence-technology requested review from a team as code owners August 7, 2026 12:02
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b9a2e0e-a1c8-4256-a62d-dd323289be73

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9d659 and 7eab542.

📒 Files selected for processing (58)
  • contracts/src/access/AccessControl.compact
  • contracts/src/access/Ownable.compact
  • contracts/src/access/ShieldedAccessControl.compact
  • contracts/src/access/test/mocks/MockAccessControl.compact
  • contracts/src/access/test/mocks/MockOwnable.compact
  • contracts/src/access/test/mocks/MockShieldedAccessControl.compact
  • contracts/src/access/test/mocks/MockZOwnablePK.compact
  • contracts/src/archive/ShieldedToken.compact
  • contracts/src/archive/test/mocks/MockShieldedToken.compact
  • contracts/src/crypto/test/mocks/MockEcdhMask.compact
  • contracts/src/crypto/test/mocks/MockElGamal.compact
  • contracts/src/multisig/ForwarderPrivate.compact
  • contracts/src/multisig/ForwarderShielded.compact
  • contracts/src/multisig/presets/ShieldedMultiSig.compact
  • contracts/src/multisig/presets/ShieldedMultiSigV2.compact
  • contracts/src/multisig/presets/ShieldedMultiSigV3.compact
  • contracts/src/multisig/presets/forwarder/ForwarderPrivate.compact
  • contracts/src/multisig/presets/forwarder/ForwarderShielded.compact
  • contracts/src/multisig/presets/forwarder/ForwarderUnshielded.compact
  • contracts/src/multisig/test/mocks/MockForwarderPrivate.compact
  • contracts/src/multisig/test/mocks/MockForwarderShielded.compact
  • contracts/src/multisig/test/mocks/MockForwarderUnshielded.compact
  • contracts/src/multisig/test/mocks/MockProposalManager.compact
  • contracts/src/multisig/test/mocks/MockShieldedTreasury.compact
  • contracts/src/multisig/test/mocks/MockShieldedTreasuryStateless.compact
  • contracts/src/multisig/test/mocks/MockSigner.compact
  • contracts/src/multisig/test/mocks/MockUnshieldedTreasury.compact
  • contracts/src/security/test/mocks/MockAllowlist.compact
  • contracts/src/security/test/mocks/MockBlocklist.compact
  • contracts/src/security/test/mocks/MockInitializable.compact
  • contracts/src/security/test/mocks/MockPausable.compact
  • contracts/src/token/ConfidentialFungibleToken.compact
  • contracts/src/token/FungibleToken.compact
  • contracts/src/token/MultiToken.compact
  • contracts/src/token/NativeShieldedToken.compact
  • contracts/src/token/NativeShieldedTokenCore.compact
  • contracts/src/token/NativeShieldedTokenFamily.compact
  • contracts/src/token/NonFungibleToken.compact
  • contracts/src/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact
  • contracts/src/token/extensions/NativeShieldedTokenPublicSupply.compact
  • contracts/src/token/extensions/NativeShieldedTokenPublicSupplyCore.compact
  • contracts/src/token/test/mocks/MockConfidentialFungibleToken.compact
  • contracts/src/token/test/mocks/MockConfidentialFungibleTokenPublicSupply.compact
  • contracts/src/token/test/mocks/MockFungibleToken.compact
  • contracts/src/token/test/mocks/MockMultiToken.compact
  • contracts/src/token/test/mocks/MockNativeShieldedToken.compact
  • contracts/src/token/test/mocks/MockNativeShieldedTokenCore.compact
  • contracts/src/token/test/mocks/MockNativeShieldedTokenDerivedNonce.compact
  • contracts/src/token/test/mocks/MockNativeShieldedTokenFamily.compact
  • contracts/src/token/test/mocks/MockNativeShieldedTokenFamilyPublicSupply.compact
  • contracts/src/token/test/mocks/MockNativeShieldedTokenPublicSupply.compact
  • contracts/src/token/test/mocks/MockNonFungibleToken.compact
  • contracts/src/utils/test/mocks/MockUtils.compact
  • contracts/test/integration/_mocks/ComposedTokens.compact
  • contracts/test/integration/_mocks/ConfidentialFungibleTokenPublicSupply.compact
  • contracts/test/integration/_mocks/SharedInitCollision.compact
  • contracts/test/integration/_mocks/sharedInit/ModuleA.compact
  • contracts/test/integration/_mocks/sharedInit/ModuleB.compact

Walkthrough

The PR replaces whole-module and side-effect imports with explicit named imports across Compact contracts and mocks. Existing prefixes, references, exported entities, and runtime behavior remain unchanged.

Changes

Access, security, and support imports

Layer / File(s) Summary
Access, security, and support imports
contracts/src/access/*, contracts/src/archive/*, contracts/src/crypto/test/mocks/*, contracts/src/security/test/mocks/*, contracts/src/utils/test/mocks/*
Imports now enumerate the symbols used by access-control, security, archive, crypto mock, and utility mock contracts. Existing prefixes remain unchanged.

Multisig module imports

Layer / File(s) Summary
Multisig module imports
contracts/src/multisig/*
Forwarders, presets, treasuries, proposal managers, signers, and mocks now use explicit named imports.

Token and extension imports

Layer / File(s) Summary
Token and extension imports
contracts/src/token/*
Token implementations, extensions, cryptographic dependencies, and token mocks now import only referenced symbols.

Integration mock imports

Layer / File(s) Summary
Integration mock imports
contracts/test/integration/_mocks/*
Integration mocks now explicitly import the token, initialization, and collision-test symbols they use.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: 0xisk, andrew-fleming

Poem

A rabbit trims imports with care,
Named symbols hop from everywhere.
Prefixes stay, the calls remain,
No runtime paths are changed by rain.
“Less to load!” the rabbit sings,
While Compact tidies module strings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: replacing blanket imports with named imports across Compact contracts.
Linked Issues check ✅ Passed The changes implement issue #406 by converting Compact module imports to explicit named imports while preserving prefixes and call sites.
Out of Scope Changes check ✅ Passed All changes support the named-import migration, including removal of an unused import and related import examples.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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.

Use named imports across all Compact contracts

1 participant