contracts
contracts copied to clipboard
fix(IdRegistry): added contract validation to setStorageRegistry
Motivation
This PR closes #440
setStorageRegistry was missing validation checks for the new address, which could lead to setting invalid contracts or non-contract addresses as the storage registry.
Change Summary
- Added zero address check using revert
- Added contract existence check
- Used revert with custom errors instead of require() for:
- Gas efficiency (4-byte selector vs string storage)
- Better ABI compatibility via custom errors
- Updated registry tests to align with the current implementation
- Fixed
assumeNotPrecompileissue - Ran forge formatting on all modified files in this PR scope
Testing the fix
Fetch this PR branch and from the root:
Add foundry-rs/forge-std
forge install foundry-rs/forge-std
Run test
forge test --match-test testFuzzSetStorageRegistry -vvv
Merge Checklist
Choose all relevant options below by adding an x now or at any time before submitting for review
- [x] The PR title adheres to the conventional commits standard
- [x] The PR has been tagged with change type label(s) (i.e. documentation, feature, bugfix, or chore)
- [x] The PR's changes adhere to all the requirements in the contribution guidelines
- [x] All commits have been signed
PR-Codex overview
This PR focuses on improving function signatures by making them more consistent and readable, particularly by changing certain functions to view. It also includes minor refactoring for clarity and better code organization across various test suites and contracts.
Detailed summary
- Changed several function signatures to
viewinKeyRegistryTestSuite.sol,IdGatewayTestSuite.sol, andIdRegistryTestSuite.sol. - Refactored function parameters for clarity in
IdGateway.solandIdRegistryTestSuite.sol. - Added assumptions in
testFuzzSetStorageRegistryto ensure valid inputs. - Updated the
_signDigestfunction to bepure. - Improved readability by breaking long parameter lists into multiple lines in various functions.
✨ Ask PR-Codex anything about this PR by commenting with
/codex {your question}