Skip to content

Remix - Use remappings file instead of import version pins #786

Merged
ericglau merged 26 commits intoOpenZeppelin:masterfrom
ericglau:remixremappings
Apr 2, 2026
Merged

Remix - Use remappings file instead of import version pins #786
ericglau merged 26 commits intoOpenZeppelin:masterfrom
ericglau:remixremappings

Conversation

@ericglau
Copy link
Copy Markdown
Member

@ericglau ericglau commented Mar 27, 2026

Update "Open in Remix" to pass remappings in the Remix URL instead of rewriting generated imports with version pins, so Remix can write the remappings to remappings.txt.

Makes use of remix-project-org/remix-project#6454

High-level changes:

  • Solidity, Confidential, and Uniswap Hooks now open generated source in Remix with remappings encoded in the URL.
  • Confidential no longer asks users to manually copy remappings or create remappings.txt.
  • Uniswap Hooks now supports opening in Remix, including remapping @openzeppelin/uniswap-hooks to its src/ directory for compatibility with current import paths.
  • Added package APIs for retrieving versioned remappings across Solidity, Confidential, and Uniswap Hooks, and exposed them on the Confidential and Hooks contract APIs for consistency.
  • Removed the old internal print-versioned path in favor of remappings-based Remix loading.

@ericglau ericglau requested review from a team as code owners March 27, 2026 18:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0606fede-04a6-4b4a-a85c-72aa8fb0b5b5

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 PR removes the printContractVersioned function and associated entry points from the confidential and solidity packages, replacing it with a new getVersionedRemappings() API that returns remapping strings instead of versioned contract code. The function is added to confidential, solidity, and uniswap-hooks packages with tests. UI components are updated to compute remappings separately and pass them to the Remix URL builder instead of generating versioned contracts dynamically.

Changes

Cohort / File(s) Summary
Entry Point Removals
packages/core/confidential/print-versioned.js, packages/core/confidential/print-versioned.ts, packages/core/solidity/print-versioned.js, packages/core/solidity/print-versioned.ts
Removed barrel export entry points that re-exported ./dist/print-versioned or ./src/print-versioned modules.
getVersionedRemappings Implementation (Confidential)
packages/core/confidential/src/get-versioned-remappings.ts, packages/core/confidential/src/get-versioned-remappings.test.ts, packages/core/confidential/src/get-versioned-remappings.test.ts.md
Added new getVersionedRemappings function returning three remapping strings for @openzeppelin/contracts, @openzeppelin/confidential-contracts, and @fhevm/solidity with pinned versions, including AVA test suite and snapshot.
getVersionedRemappings Implementation (Uniswap Hooks)
packages/core/uniswap-hooks/src/get-versioned-remappings.ts, packages/core/uniswap-hooks/src/get-versioned-remappings.test.ts, packages/core/uniswap-hooks/src/get-versioned-remappings.test.ts.md
Added new getVersionedRemappings function returning two remapping strings for @openzeppelin/contracts and @openzeppelin/uniswap-hooks with compatible version constraints, including tests and snapshot.
printContractVersioned Removal
packages/core/confidential/src/print-versioned.ts, packages/core/confidential/src/print-versioned.test.ts, packages/core/confidential/src/print-versioned.test.ts.md, packages/core/solidity/src/print-versioned.ts
Removed the printContractVersioned function implementation and associated test cases that performed import path transformation with version suffixes.
API and Index Updates
packages/core/confidential/src/api.ts, packages/core/confidential/src/index.ts, packages/core/solidity/src/index.ts, packages/core/uniswap-hooks/src/index.ts, packages/core/uniswap-hooks/src/api.ts
Added getVersionedRemappings exports to public API surfaces; confidential api.ts imports WizardContractAPI from @openzeppelin/wizard and removes local interface definition.
Package Configuration
packages/core/uniswap-hooks/package.json, packages/core/uniswap-hooks/remappings.txt
Removed @uniswap/v4-periphery dev dependency and updated Solidity remapping for @openzeppelin/uniswap-hooks/ to point to src directory.
Remix URL Refactoring
packages/ui/src/solidity/remix.ts, packages/ui/src/solidity/remix.test.ts
Extended remixURL function signature to accept optional remappings parameter; refactored URL encoding to use hash parameters with base64 encoding for code and remaps; updated tests to parse hash instead of searchParams.
UI Consumer Updates (Confidential & Uniswap Hooks)
packages/ui/src/confidential/App.svelte, packages/ui/src/uniswap-hooks/App.svelte
Removed dynamic printContractVersioned imports and remappings copy functionality; updated remixHandler to call getVersionedRemappings() and pass remappings to remixURL; simplified tooltip UI for Remix button.
UI Consumer Updates (Solidity)
packages/ui/src/solidity/App.svelte
Updated imports to add getVersionedRemappings; refactored remixHandler to compute remappings via getVersionedRemappings(opts) instead of dynamically importing and calling printContractVersioned; removed versioned code path from Remix URL generation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • CoveMB
  • ernestognw
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main architectural change: switching from embedding version pins in imports to using remappings files passed via URL to Remix.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the removal of print-versioned functions and the addition of getVersionedRemappings APIs to pass remappings in Remix URLs instead of rewriting imports.

✏️ 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.

@ericglau
Copy link
Copy Markdown
Member Author

ericglau commented Mar 27, 2026

Changeset is not needed since these are internal-facing changes in the core packages.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 27, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@ericglau ericglau requested review from ernestognw and gonzaotc March 27, 2026 21:30
Copy link
Copy Markdown
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Looking good

Copy link
Copy Markdown
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Thanks @ericglau !

@ericglau
Copy link
Copy Markdown
Member Author

@SocketSecurity ignore-all
MCP SDK to be handled by #789
The other high CVEs are dev dependencies.

@ericglau ericglau enabled auto-merge (squash) April 2, 2026 15:11
Copy link
Copy Markdown

@pasevin pasevin left a comment

Choose a reason for hiding this comment

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

LGTM!

@ericglau ericglau merged commit 234ab40 into OpenZeppelin:master Apr 2, 2026
21 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
@ericglau ericglau deleted the remixremappings branch April 2, 2026 15:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants