Skip to content

Conversation

ciaranightingale
Copy link
Contributor

No description provided.

@ciaranightingale ciaranightingale marked this pull request as draft April 29, 2023 22:05
@@ -20,10 +20,12 @@ import "lib/dynamic-contracts/src/core/Router.sol";
contract ManagedAccount is AccountCore, Router {
address public factory;

constructor(IEntryPoint _entrypoint) AccountCore(_entrypoint) {}
constructor(IEntryPoint _entrypoint) AccountCore(_entrypoint) {
_disableInitializers();
Copy link
Member

Choose a reason for hiding this comment

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

what does this do? is to prevent initializing the implementation itself?

isnt that already handled by the initializer modifier?

Copy link
Contributor

Choose a reason for hiding this comment

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

The _disableInitializer function has a different job than the initializer modifier.

You call the _disableInitializer function inside the constructor of the implementation smart contract instance to make sure that no one can call the initialize function on the implementation and mutate its state.

From reading the code -- calling _disableInitializer inside the implementation contract's constructor is a good practice and a recommendation in the code comments, but not doing this does not affect the proxy contracts that point at it.

Code comments for _disableInitializer:

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */

// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

abstract contract BaseAccountFactory is IAccountFactory, Multicall {
Copy link
Member

Choose a reason for hiding this comment

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

nice de-duping here, thanks for refactoring that

@nkrishang nkrishang marked this pull request as ready for review May 1, 2023 01:41
@nkrishang nkrishang merged commit 30adb10 into main May 1, 2023
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