Skip to content
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

fix: linting warnings and initializer logic #46

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

huaweigu
Copy link
Contributor

@huaweigu huaweigu commented Nov 15, 2024

Summary

This PR addresses the linting warnings and corrects the logic in WalletStorageInitializable.

Detail

Changeset

  • Resolve all warnings (thanks to Ashutosh!)
  • Correct the logic in the unused code within WalletStorageInitializable
  • Eliminate redundant calls in SingleOwnerMSCA constructor
  • Add a sanity check != address(0) in SingleOwnerMSCA

Checklist

  • Did you add new tests and confirm all tests pass? (yarn test)
  • Did you update relevant docs? (docs are found in the docs folder)
  • Do your commits follow the Conventional Commits standard?
  • Does your PR title also follow the Conventional Commits standard?
  • If you have a breaking change, is it correctly reflected in your commit message? (e.g. feat!: breaking change)
  • Did you run lint (yarn lint) and fix any issues?
  • Did you run formatter (yarn format:check) and fix any issues (yarn format:write)?

Testing

  • No new tests have been added for style changes.
  • New tests have been included for the fixes:
    • For the walletStorageInitializer fix, I have forked the OZ JavaScript tests and rewritten them using Foundry.
    • The remaining two changes are already covered by existing tests (we don't allow installing address(0) and testInitializeSingleOwnerMSCAWithRuntimeValidation).

Documentation

n/a

@@ -43,7 +43,23 @@ abstract contract WalletStorageInitializable {
* Emits an {WalletStorageInitialized} event.
*/
modifier walletStorageInitializer() {
bool isTopLevelCall = _setWalletStorageInitializing();
bool isTopLevelCall = !WalletStorageV1Lib.getLayout().initializing;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original logic expression !initialSetup || deploying was incorrect due to missing parentheses. The intended logic should have been !(initialSetup || deploying). This corrected expression is logically equivalent to !initialSetup && !deploying.
To break it down:

  • The original (incorrect): !initialSetup || deploying
  • The corrected version: !(initialSetup || deploying)
  • The equivalent expression: !initialSetup && !deploying

}

/// @inheritdoc IERC1271
function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4) {
address owner = WalletStorageV1Lib.getLayout().owner;
if (owner == address(0)) {
ExecutionDetail storage executionDetail =
WalletStorageV1Lib.getLayout().executionDetails[IERC1271.isValidSignature.selector];
// this is a sanity check only, as using address(0) as a plugin is not permitted during installation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor fix to check plugin != address(0) even if it should not happen

@@ -99,10 +96,7 @@ contract SingleOwnerMSCA is BaseMSCA, DefaultCallbackHandler, UUPSUpgradeable, I

constructor(IEntryPoint _newEntryPoint, PluginManager _newPluginManager)
BaseMSCA(_newEntryPoint, _newPluginManager)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove the redundant check as it's done in BaseMSCA

@huaweigu huaweigu changed the title chore: sync to the latest code fix: linting warnings and initializer logic Nov 15, 2024
@huaweigu huaweigu requested a review from ZhiyuCircle November 15, 2024 16:33
@huaweigu huaweigu force-pushed the chore/sync branch 2 times, most recently from 1356bf3 to 616b1c1 Compare November 15, 2024 20:02
@huaweigu huaweigu changed the title fix: linting warnings and initializer logic fix: linting warnings and initializer logic Nov 15, 2024
@huaweigu huaweigu merged commit d4080da into circlefin:entry-point-v0.6 Nov 15, 2024
6 checks passed
@huaweigu huaweigu deleted the chore/sync branch November 15, 2024 20:26
huaweigu added a commit that referenced this pull request Dec 6, 2024
## Summary
Parallel PR of
#46. This PR
addresses the linting warnings and corrects the logic in
`WalletStorageInitializable` for 6900 v0.7 and 6900 v0.8 accounts (both
on entry point v0.7).

## Detail
### Changeset
* Resolve all warnings (thanks to Ashutosh!)
* Correct the logic in the unused code within
`WalletStorageInitializable`
* Eliminate redundant calls in `SingleOwnerMSCA` constructor
* Add a sanity check `!= address(0)` in `SingleOwnerMSCA`

### Checklist
- [x] Did you add new tests and confirm all tests pass? (`yarn test`)
- [ ] Did you update relevant docs? (docs are found in the `docs`
folder)
- [x] Do your commits follow the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard?
- [x] Does your PR title also follow the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard?
- [ ] If you have a breaking change, is it [correctly reflected in your
commit
message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g.
`feat!: breaking change`)
- [x] Did you run lint (`yarn lint`) and fix any issues?
- [x] Did you run formatter (`yarn format:check`) and fix any issues
(`yarn format:write`)?

## Testing
* No new tests have been added for style changes.
* New tests have been included for the fixes:
* For the `walletStorageInitializer` fix, I have forked the OZ
JavaScript tests and rewritten them using Foundry.
* The remaining two changes are already covered by existing tests (we
don't allow installing `address(0)` and
`testInitializeSingleOwnerMSCAWithRuntimeValidation`).

## Documentation
n/a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants