@@ -39,39 +39,33 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
3939 State
4040 //////////////////////////////////////////////////////////////*/
4141
42+ /// @notice EIP 4337 factory for this contract.
43+ address public immutable factory;
44+
4245 /// @notice EIP 4337 Entrypoint contract.
4346 IEntryPoint private immutable entrypointContract;
4447
4548 /*///////////////////////////////////////////////////////////////
4649 Constructor, Initializer, Modifiers
4750 //////////////////////////////////////////////////////////////*/
4851
49- constructor (IEntryPoint _entrypoint ) EIP712 ("Account " , "1 " ) {
52+ constructor (IEntryPoint _entrypoint , address _factory ) EIP712 ("Account " , "1 " ) {
5053 _disableInitializers ();
54+ factory = _factory;
5155 entrypointContract = _entrypoint;
5256 }
5357
5458 /// @notice Initializes the smart contract wallet.
55- function initialize (
56- address _defaultAdmin ,
57- address _factory ,
58- bytes calldata _data
59- ) public virtual initializer {
59+ function initialize (address _defaultAdmin , bytes calldata _data ) public virtual initializer {
6060 // This is passed as data in the `_registerOnFactory()` call in `AccountExtension` / `Account`.
6161 AccountCoreStorage.data ().creationSalt = _generateSalt (_defaultAdmin, _data);
62- AccountCoreStorage.data ().factory = _factory;
6362 _setAdmin (_defaultAdmin, true );
6463 }
6564
6665 /*///////////////////////////////////////////////////////////////
6766 View functions
6867 //////////////////////////////////////////////////////////////*/
6968
70- /// @notice Returns the address of the account factory.
71- function factory () public view virtual override returns (address ) {
72- return AccountCoreStorage.data ().factory;
73- }
74-
7569 /// @notice Returns the EIP 4337 entrypoint contract.
7670 function entryPoint () public view virtual override returns (IEntryPoint) {
7771 address entrypointOverride = AccountCoreStorage.data ().entrypointOverride;
@@ -241,22 +235,19 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
241235 /// @notice Makes the given account an admin.
242236 function _setAdmin (address _account , bool _isAdmin ) internal virtual override {
243237 super ._setAdmin (_account, _isAdmin);
244-
245- address factoryAddr = factory ();
246- if (factoryAddr.code.length > 0 ) {
238+ if (factory.code.length > 0 ) {
247239 if (_isAdmin) {
248- BaseAccountFactory (factoryAddr ).onSignerAdded (_account, AccountCoreStorage.data ().creationSalt);
240+ BaseAccountFactory (factory ).onSignerAdded (_account, AccountCoreStorage.data ().creationSalt);
249241 } else {
250- BaseAccountFactory (factoryAddr ).onSignerRemoved (_account, AccountCoreStorage.data ().creationSalt);
242+ BaseAccountFactory (factory ).onSignerRemoved (_account, AccountCoreStorage.data ().creationSalt);
251243 }
252244 }
253245 }
254246
255247 /// @notice Runs after every `changeRole` run.
256248 function _afterSignerPermissionsUpdate (SignerPermissionRequest calldata _req ) internal virtual override {
257- address factoryAddr = factory ();
258- if (factoryAddr.code.length > 0 ) {
259- BaseAccountFactory (factoryAddr).onSignerAdded (_req.signer, AccountCoreStorage.data ().creationSalt);
249+ if (factory.code.length > 0 ) {
250+ BaseAccountFactory (factory).onSignerAdded (_req.signer, AccountCoreStorage.data ().creationSalt);
260251 }
261252 }
262253}
0 commit comments