openzeppelin-contracts icon indicating copy to clipboard operation
openzeppelin-contracts copied to clipboard

Add script to automatically minimize pragma

Open Amxx opened this issue 7 months ago • 3 comments

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.

Amxx avatar Jun 12 '25 08:06 Amxx

⚠️ No Changeset found

Latest commit: d1c964dfe2e81366b5a29c85cf157ef69245491e

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

changeset-bot[bot] avatar Jun 12 '25 08:06 changeset-bot[bot]

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

arr00 avatar Jun 12 '25 13:06 arr00

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 avatar Jun 12 '25 17:06 Amxx