@@ -39,39 +39,33 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
39
39
State
40
40
//////////////////////////////////////////////////////////////*/
41
41
42
+ /// @notice EIP 4337 factory for this contract.
43
+ address public immutable factory;
44
+
42
45
/// @notice EIP 4337 Entrypoint contract.
43
46
IEntryPoint private immutable entrypointContract;
44
47
45
48
/*///////////////////////////////////////////////////////////////
46
49
Constructor, Initializer, Modifiers
47
50
//////////////////////////////////////////////////////////////*/
48
51
49
- constructor (IEntryPoint _entrypoint ) EIP712 ("Account " , "1 " ) {
52
+ constructor (IEntryPoint _entrypoint , address _factory ) EIP712 ("Account " , "1 " ) {
50
53
_disableInitializers ();
54
+ factory = _factory;
51
55
entrypointContract = _entrypoint;
52
56
}
53
57
54
58
/// @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 {
60
60
// This is passed as data in the `_registerOnFactory()` call in `AccountExtension` / `Account`.
61
61
AccountCoreStorage.data ().creationSalt = _generateSalt (_defaultAdmin, _data);
62
- AccountCoreStorage.data ().factory = _factory;
63
62
_setAdmin (_defaultAdmin, true );
64
63
}
65
64
66
65
/*///////////////////////////////////////////////////////////////
67
66
View functions
68
67
//////////////////////////////////////////////////////////////*/
69
68
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
-
75
69
/// @notice Returns the EIP 4337 entrypoint contract.
76
70
function entryPoint () public view virtual override returns (IEntryPoint) {
77
71
address entrypointOverride = AccountCoreStorage.data ().entrypointOverride;
@@ -241,22 +235,19 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
241
235
/// @notice Makes the given account an admin.
242
236
function _setAdmin (address _account , bool _isAdmin ) internal virtual override {
243
237
super ._setAdmin (_account, _isAdmin);
244
-
245
- address factoryAddr = factory ();
246
- if (factoryAddr.code.length > 0 ) {
238
+ if (factory.code.length > 0 ) {
247
239
if (_isAdmin) {
248
- BaseAccountFactory (factoryAddr ).onSignerAdded (_account, AccountCoreStorage.data ().creationSalt);
240
+ BaseAccountFactory (factory ).onSignerAdded (_account, AccountCoreStorage.data ().creationSalt);
249
241
} else {
250
- BaseAccountFactory (factoryAddr ).onSignerRemoved (_account, AccountCoreStorage.data ().creationSalt);
242
+ BaseAccountFactory (factory ).onSignerRemoved (_account, AccountCoreStorage.data ().creationSalt);
251
243
}
252
244
}
253
245
}
254
246
255
247
/// @notice Runs after every `changeRole` run.
256
248
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);
260
251
}
261
252
}
262
253
}
0 commit comments