Skip to content

Add script to automatically minimize pragma #5740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 25, 2025

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Jun 12, 2025

Follow up to #5730, Replaces #5649

This adds a scripts that finds the minimal pragma that can be used for a given file.

Usage:

npm run pragma # minimize pragma for all solidity files in contracts/ (mocks excluded)
npm run pragma -- -p 'contracts/accounts/**/*.sol' # minimize pragma for a given subfolder
npm run pragma -- -p 'contracts/utils/Address.sol' # minimize pragma for a given file

Running this script is slow, and should probably not be run in CI. It should be a maintenance operation run every now and then. The pragma validity check (yarn test:pragma) already verifies that the pragma are valid.

Copy link

changeset-bot bot commented Jun 12, 2025

⚠️ No Changeset found

Latest commit: d1c964d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@arr00
Copy link
Contributor

arr00 commented Jun 12, 2025

Why are we updating mocks? Aren't they skipped by default?

@Amxx
Copy link
Collaborator Author

Amxx commented Jun 12, 2025

Why are we updating mocks? Aren't they skipped by default?

They are, but just for fun I did run the script on the mocks, and it found two things.

I said "why not" update that ... but if you prefer we can dismiss that.


The thing is, mocks include mocks/docs ... and maybe these should be processed.

@Amxx Amxx requested a review from a team as a code owner June 18, 2025 19:53
arr00
arr00 previously approved these changes Jun 24, 2025
@Amxx Amxx requested a review from arr00 June 25, 2025 08:27
@Amxx Amxx enabled auto-merge (squash) June 25, 2025 08:48
@Amxx Amxx merged commit 387ce69 into OpenZeppelin:master Jun 25, 2025
20 checks passed
@Amxx Amxx deleted the scripts/minimize-pragma branch June 25, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants