2
2
pragma solidity ^ 0.8.12 ;
3
3
4
4
// Utils
5
+ import "./BaseAccountFactoryStorage.sol " ;
5
6
import "../../../extension/Multicall.sol " ;
6
7
import "../../../external-deps/openzeppelin/proxy/Clones.sol " ;
7
8
import "../../../external-deps/openzeppelin/utils/structs/EnumerableSet.sol " ;
@@ -32,9 +33,6 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
32
33
address public immutable accountImplementation;
33
34
address public immutable entrypoint;
34
35
35
- EnumerableSet.AddressSet private allAccounts;
36
- mapping (address => EnumerableSet.AddressSet) internal accountsOfSigner;
37
-
38
36
/*///////////////////////////////////////////////////////////////
39
37
Constructor
40
38
//////////////////////////////////////////////////////////////*/
@@ -61,7 +59,10 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
61
59
account = Clones.cloneDeterministic (impl, salt);
62
60
63
61
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
+ );
65
66
}
66
67
67
68
_initializeAccount (account, _admin, _data);
@@ -76,14 +77,14 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
76
77
address account = msg .sender ;
77
78
require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
78
79
79
- require (allAccounts.add (account), "AccountFactory: account already registered " );
80
+ require (_baseAccountFactoryStorage (). allAccounts.add (account), "AccountFactory: account already registered " );
80
81
}
81
82
82
83
function onSignerAdded (address _signer , bytes32 _salt ) external {
83
84
address account = msg .sender ;
84
85
require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
85
86
86
- bool isNewSigner = accountsOfSigner[_signer].add (account);
87
+ bool isNewSigner = _baseAccountFactoryStorage (). accountsOfSigner[_signer].add (account);
87
88
88
89
if (isNewSigner) {
89
90
emit SignerAdded (account, _signer);
@@ -95,7 +96,7 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
95
96
address account = msg .sender ;
96
97
require (_isAccountOfFactory (account, _salt), "AccountFactory: not an account. " );
97
98
98
- bool isAccount = accountsOfSigner[_signer].remove (account);
99
+ bool isAccount = _baseAccountFactoryStorage (). accountsOfSigner[_signer].remove (account);
99
100
100
101
if (isAccount) {
101
102
emit SignerRemoved (account, _signer);
@@ -108,12 +109,12 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
108
109
109
110
/// @notice Returns whether an account is registered on this factory.
110
111
function isRegistered (address _account ) external view returns (bool ) {
111
- return allAccounts.contains (_account);
112
+ return _baseAccountFactoryStorage (). allAccounts.contains (_account);
112
113
}
113
114
114
115
/// @notice Returns all accounts created on the factory.
115
116
function getAllAccounts () external view returns (address [] memory ) {
116
- return allAccounts.values ();
117
+ return _baseAccountFactoryStorage (). allAccounts.values ();
117
118
}
118
119
119
120
/// @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 {
124
125
125
126
/// @notice Returns all accounts that the given address is a signer of.
126
127
function getAccountsOfSigner (address signer ) external view returns (address [] memory accounts ) {
127
- return accountsOfSigner[signer].values ();
128
+ return _baseAccountFactoryStorage (). accountsOfSigner[signer].values ();
128
129
}
129
130
130
131
/*///////////////////////////////////////////////////////////////
@@ -147,6 +148,11 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
147
148
return keccak256 (abi.encode (_admin, _data));
148
149
}
149
150
151
+ /// @dev Returns the BaseAccountFactory contract's storage.
152
+ function _baseAccountFactoryStorage () internal pure returns (BaseAccountFactoryStorage.Data storage ) {
153
+ return BaseAccountFactoryStorage.data ();
154
+ }
155
+
150
156
/// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
151
157
function _initializeAccount (
152
158
address _account ,
0 commit comments