22pragma solidity ^ 0.8.12 ;
33
44// Utils
5+ import "./BaseAccountFactoryStorage.sol " ;
56import "../../../extension/Multicall.sol " ;
67import "../../../external-deps/openzeppelin/proxy/Clones.sol " ;
78import "../../../external-deps/openzeppelin/utils/structs/EnumerableSet.sol " ;
@@ -32,9 +33,6 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
3233 address public immutable accountImplementation;
3334 address public immutable entrypoint;
3435
35- EnumerableSet.AddressSet private allAccounts;
36- mapping (address => EnumerableSet.AddressSet) internal accountsOfSigner;
37-
3836 /*///////////////////////////////////////////////////////////////
3937 Constructor
4038 //////////////////////////////////////////////////////////////*/
@@ -61,7 +59,10 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
6159 account = Clones.cloneDeterministic (impl, salt);
6260
6361 if (msg .sender != entrypoint) {
64- require (allAccounts.add (account), "AccountFactory: account already registered " );
62+ require (
63+ _baseAccountFactoryStorage ().allAccounts.add (account),
64+ "AccountFactory: account already registered "
65+ );
6566 }
6667
6768 _initializeAccount (account, _admin, _data);
@@ -76,14 +77,14 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
7677 address account = msg .sender ;
7778 require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
7879
79- require (allAccounts.add (account), "AccountFactory: account already registered " );
80+ require (_baseAccountFactoryStorage (). allAccounts.add (account), "AccountFactory: account already registered " );
8081 }
8182
8283 function onSignerAdded (address _signer , bytes32 _salt ) external {
8384 address account = msg .sender ;
8485 require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
8586
86- bool isNewSigner = accountsOfSigner[_signer].add (account);
87+ bool isNewSigner = _baseAccountFactoryStorage (). accountsOfSigner[_signer].add (account);
8788
8889 if (isNewSigner) {
8990 emit SignerAdded (account, _signer);
@@ -95,7 +96,7 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
9596 address account = msg .sender ;
9697 require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
9798
98- bool isAccount = accountsOfSigner[_signer].remove (account);
99+ bool isAccount = _baseAccountFactoryStorage (). accountsOfSigner[_signer].remove (account);
99100
100101 if (isAccount) {
101102 emit SignerRemoved (account, _signer);
@@ -108,12 +109,12 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
108109
109110 /// @notice Returns whether an account is registered on this factory.
110111 function isRegistered (address _account ) external view returns (bool ) {
111- return allAccounts.contains (_account);
112+ return _baseAccountFactoryStorage (). allAccounts.contains (_account);
112113 }
113114
114115 /// @notice Returns all accounts created on the factory.
115116 function getAllAccounts () external view returns (address [] memory ) {
116- return allAccounts.values ();
117+ return _baseAccountFactoryStorage (). allAccounts.values ();
117118 }
118119
119120 /// @notice Returns the address of an Account that would be deployed with the given admin signer.
@@ -124,7 +125,7 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
124125
125126 /// @notice Returns all accounts that the given address is a signer of.
126127 function getAccountsOfSigner (address signer ) external view returns (address [] memory accounts ) {
127- return accountsOfSigner[signer].values ();
128+ return _baseAccountFactoryStorage (). accountsOfSigner[signer].values ();
128129 }
129130
130131 /*///////////////////////////////////////////////////////////////
@@ -147,6 +148,11 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
147148 return keccak256 (abi.encode (_admin, _data));
148149 }
149150
151+ /// @dev Returns the BaseAccountFactory contract's storage.
152+ function _baseAccountFactoryStorage () internal pure returns (BaseAccountFactoryStorage.Data storage ) {
153+ return BaseAccountFactoryStorage.data ();
154+ }
155+
150156 /// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
151157 function _initializeAccount (
152158 address _account ,
0 commit comments