Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR aims to prevent bugs and issues created by breaking changes between an old contact and a new one.
If the contract already has clients that use him, changing the ABI of the contract (e.g., while upgrading) can lead to some critical bugs.
Even if we deploy a new version of our contract, we need to be sure that nothing will break in our frontend, backend, or other third-party consumers. If some stuff changes, it would be beneficial to have an auto-generated report that we could give to the relevant consumers.
Breaking changes according to this PR:
We solved this issue by adding a script that checks if there are breaking changes between the old ABI and the new ABI.
This script runs before each deployment and validates that there are no breaking changes between the deployed contracts and the new ones.
By default, if there are some breaking changes, the deployment would fail.
If you still want to deploy the contracts, you need to add the flag "allowBreakingAbiCompatbility".
If you have an artifact whose name is not the same as the contract name, you should add a JSON string with this data to the replace param. e.g.
hardhat deploy --replace '{"contractName": "artifactName"}'
It's also possible to export all the breaking changes to JSON files.
Also, there is a new task: 'validate-abi-compat'. In this task, you can check the ABI compatibility for a specific contract or all of them.
Possible Enhancements
This PR was created with @fullkomnun help 🙏