@@ -21,27 +21,6 @@ import "./TWDynamicAccount.sol";
2121// \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
2222// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/
2323
24- /*///////////////////////////////////////////////////////////////
25- Storage layout
26- //////////////////////////////////////////////////////////////*/
27-
28- library TWDynamicAccountFactoryStorage {
29- bytes32 internal constant DYNAMIC_ACCOUNT_FACTORY_STORAGE_POSITION =
30- keccak256 ("tw.dynamic.account.factory.storage " );
31-
32- struct Data {
33- TWStringSet.Set allAccounts;
34- mapping (address => TWStringSet.Set) accountsOfSigner;
35- }
36-
37- function factoryStorage () internal pure returns (Data storage dynamicAccountFactoryData ) {
38- bytes32 position = DYNAMIC_ACCOUNT_FACTORY_STORAGE_POSITION;
39- assembly {
40- dynamicAccountFactoryData.slot := position
41- }
42- }
43- }
44-
4524contract TWDynamicAccountFactory is ITWAccountFactory , Multicall {
4625 using TWStringSet for TWStringSet.Set;
4726
@@ -77,8 +56,6 @@ contract TWDynamicAccountFactory is ITWAccountFactory, Multicall {
7756
7857 TWAccount (payable (account)).initialize (_admin);
7958
80- _setupAccount (_admin, _accountId);
81-
8259 emit AccountCreated (account, _admin, _accountId);
8360
8461 return account;
@@ -98,38 +75,4 @@ contract TWDynamicAccountFactory is ITWAccountFactory, Multicall {
9875 bytes32 salt = keccak256 (abi.encode (_accountId));
9976 return Clones.predictDeterministicAddress (address (_accountImplementation), salt);
10077 }
101-
102- /// @notice Returns the list of accounts created by a signer.
103- function getAccountsOfSigner (address _signer ) external view returns (AccountInfo[] memory ) {
104- TWDynamicAccountFactoryStorage.Data storage data = TWDynamicAccountFactoryStorage.factoryStorage ();
105- return _formatAccounts (data.accountsOfSigner[_signer].values ());
106- }
107-
108- /// @notice Returns the list of all accounts.
109- function getAllAccounts () external view returns (AccountInfo[] memory accounts ) {
110- TWDynamicAccountFactoryStorage.Data storage data = TWDynamicAccountFactoryStorage.factoryStorage ();
111- return _formatAccounts (data.allAccounts.values ());
112- }
113-
114- /*///////////////////////////////////////////////////////////////
115- Internal functions
116- //////////////////////////////////////////////////////////////*/
117-
118- /// @dev Formats a list of accountIds to a list of `AccountInfo` (account id + account address).
119- function _formatAccounts (string [] memory _accountIds ) internal view returns (AccountInfo[] memory accounts ) {
120- uint256 len = _accountIds.length ;
121- accounts = new AccountInfo [](len);
122- for (uint256 i = 0 ; i < len; i += 1 ) {
123- string memory accountId = _accountIds[i];
124- address account = getAddress (accountId);
125- accounts[i] = AccountInfo (accountId, account);
126- }
127- }
128-
129- /// @dev Adds an account to the list of accounts created by a signer.
130- function _setupAccount (address _signer , string memory _accountId ) internal {
131- TWDynamicAccountFactoryStorage.Data storage data = TWDynamicAccountFactoryStorage.factoryStorage ();
132- data.allAccounts.add (_accountId);
133- data.accountsOfSigner[_signer].add (_accountId);
134- }
13578}
0 commit comments