@@ -5,7 +5,7 @@ pragma solidity ^0.8.20;
55
66import {IInstallationCallback} from "./interface/IInstallationCallback.sol " ;
77import {IModularCore} from "./interface/IModularCore.sol " ;
8- import {IModularExtension } from "./interface/IModularExtension .sol " ;
8+ import {IModularModule } from "./interface/IModularModule .sol " ;
99
1010// Utils
1111import {Role} from "./Role.sol " ;
@@ -21,7 +21,7 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
2121 TYPES
2222 //////////////////////////////////////////////////////////////*/
2323
24- /// @dev The type of function callable on extension contracts.
24+ /// @dev The type of function callable on module contracts.
2525 enum FunctionType {
2626 CALLBACK,
2727 FALLBACK
@@ -38,20 +38,20 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
3838 EVENTS
3939 //////////////////////////////////////////////////////////////*/
4040
41- /// @notice Emitted when an extension is installed.
42- event ExtensionInstalled (address caller , address implementation , address installedExtension );
41+ /// @notice Emitted when an module is installed.
42+ event ModuleInstalled (address caller , address implementation , address installedModule );
4343
44- /// @notice Emitted when an extension is uninstalled.
45- event ExtensionUninstalled (address caller , address implementation , address installedExtension );
44+ /// @notice Emitted when an module is uninstalled.
45+ event ModuleUninstalled (address caller , address implementation , address installedModule );
4646
4747 /*//////////////////////////////////////////////////////////////
4848 STORAGE
4949 //////////////////////////////////////////////////////////////*/
5050
51- /// @dev The set of addresses of installed extensions .
52- EnumerableSetLib.AddressSet private extensions ;
51+ /// @dev The set of addresses of installed modules .
52+ EnumerableSetLib.AddressSet private modules ;
5353
54- /// @dev interface ID => counter of extensions supporting the interface.
54+ /// @dev interface ID => counter of modules supporting the interface.
5555 mapping (bytes4 => uint256 ) private supportedInterfaceRefCounter;
5656
5757 /// @dev function selector => function data.
@@ -61,9 +61,9 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
6161 ERRORS
6262 //////////////////////////////////////////////////////////////*/
6363
64- error ExtensionOutOfSync ();
65- error ExtensionNotInstalled ();
66- error ExtensionAlreadyInstalled ();
64+ error ModuleOutOfSync ();
65+ error ModuleNotInstalled ();
66+ error ModuleAlreadyInstalled ();
6767
6868 error CallbackFunctionRequired ();
6969 error CallbackExecutionReverted ();
@@ -74,23 +74,23 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
7474 error FallbackFunctionAlreadyInstalled ();
7575 error FallbackFunctionNotInstalled ();
7676
77- error ExtensionInterfaceNotCompatible (bytes4 requiredInterfaceId );
77+ error ModuleInterfaceNotCompatible (bytes4 requiredInterfaceId );
7878
7979 /*//////////////////////////////////////////////////////////////
8080 FALLBACK FUNCTION
8181 //////////////////////////////////////////////////////////////*/
8282
83- /// @notice Routes a call to the appropriate extension contract.
83+ /// @notice Routes a call to the appropriate module contract.
8484 fallback () external payable {
85- // Get extension function data.
85+ // Get module function data.
8686 InstalledFunction memory fn = functionData_[msg .sig ];
8787
88- // Check: extension function data exists.
88+ // Check: module function data exists.
8989 if (fn.implementation == address (0 )) {
9090 revert FallbackFunctionNotInstalled ();
9191 }
9292
93- // Check: authorized to call permissioned extension function
93+ // Check: authorized to call permissioned module function
9494 if (fn.fnType == FunctionType.CALLBACK) {
9595 if (msg .sender != address (this )) {
9696 revert CallbackFunctionUnauthorizedCall ();
@@ -106,19 +106,19 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
106106 VIEW FUNCTIONS
107107 //////////////////////////////////////////////////////////////*/
108108
109- /// @notice Returns the list of all callback functions called on some extension contract.
109+ /// @notice Returns the list of all callback functions called on some module contract.
110110 function getSupportedCallbackFunctions () public pure virtual returns (SupportedCallbackFunction[] memory );
111111
112- /// @notice Returns a list of addresess and respective extension configs of all installed extensions .
113- function getInstalledExtensions () external view returns (InstalledExtension [] memory _installedExtensions ) {
114- uint256 totalInstalled = extensions .length ();
115- _installedExtensions = new InstalledExtension [](totalInstalled);
112+ /// @notice Returns a list of addresess and respective module configs of all installed modules .
113+ function getInstalledModules () external view returns (InstalledModule [] memory _installedModules ) {
114+ uint256 totalInstalled = modules .length ();
115+ _installedModules = new InstalledModule [](totalInstalled);
116116
117117 for (uint256 i = 0 ; i < totalInstalled; i++ ) {
118- address implementation = extensions .at (i);
119- _installedExtensions [i] = InstalledExtension ({
118+ address implementation = modules .at (i);
119+ _installedModules [i] = InstalledModule ({
120120 implementation: implementation,
121- config: IModularExtension (implementation).getExtensionConfig ()
121+ config: IModularModule (implementation).getModuleConfig ()
122122 });
123123 }
124124 }
@@ -127,24 +127,24 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
127127 EXTERNAL FUNCTIONS
128128 //////////////////////////////////////////////////////////////*/
129129
130- /// @notice Installs an extension contract.
131- function installExtension (address _extension , bytes calldata _data )
130+ /// @notice Installs an module contract.
131+ function installModule (address _module , bytes calldata _data )
132132 external
133133 payable
134134 onlyOwnerOrRoles (Role._INSTALLER_ROLE)
135135 {
136- // Install extension .
137- _installExtension (_extension , _data);
136+ // Install module .
137+ _installModule (_module , _data);
138138 }
139139
140- /// @notice Uninstalls an extension contract.
141- function uninstallExtension (address _extension , bytes calldata _data )
140+ /// @notice Uninstalls an module contract.
141+ function uninstallModule (address _module , bytes calldata _data )
142142 external
143143 payable
144144 onlyOwnerOrRoles (Role._INSTALLER_ROLE)
145145 {
146- // Uninstall extension .
147- _uninstallExtension (_extension , _data);
146+ // Uninstall module .
147+ _uninstallModule (_module , _data);
148148 }
149149
150150 /// @notice Returns whether a given interface is implemented by the contract.
@@ -163,7 +163,7 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
163163 //////////////////////////////////////////////////////////////*/
164164
165165 /// @notice Returns whether a given interface is implemented by the contract.
166- function _supportsInterfaceViaExtensions (bytes4 interfaceId ) internal view virtual returns (bool ) {
166+ function _supportsInterfaceViaModules (bytes4 interfaceId ) internal view virtual returns (bool ) {
167167 if (interfaceId == 0xffffffff ) {
168168 return false ;
169169 }
@@ -173,25 +173,25 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
173173 return false ;
174174 }
175175
176- /// @dev Installs an extension contract.
177- function _installExtension (address _extension , bytes memory _data ) internal {
178- if (! extensions .add (_extension )) {
179- revert ExtensionAlreadyInstalled ();
176+ /// @dev Installs an module contract.
177+ function _installModule (address _module , bytes memory _data ) internal {
178+ if (! modules .add (_module )) {
179+ revert ModuleAlreadyInstalled ();
180180 }
181181
182- // Get extension config.
183- ExtensionConfig memory config = IModularExtension (_extension). getExtensionConfig ();
182+ // Get module config.
183+ ModuleConfig memory config = IModularModule (_module). getModuleConfig ();
184184
185- // Check: ModularCore supports interface required by extension .
185+ // Check: ModularCore supports interface required by module .
186186 if (config.requiredInterfaces.length != 0 ) {
187187 for (uint256 i = 0 ; i < config.requiredInterfaces.length ; i++ ) {
188188 if (! supportsInterface (config.requiredInterfaces[i])) {
189- revert ExtensionInterfaceNotCompatible (config.requiredInterfaces[i]);
189+ revert ModuleInterfaceNotCompatible (config.requiredInterfaces[i]);
190190 }
191191 }
192192 }
193193
194- // Store interface support inherited via extension installation.
194+ // Store interface support inherited via module installation.
195195 uint256 supportedInterfaceLength = config.supportedInterfaces.length ;
196196 for (uint256 i = 0 ; i < supportedInterfaceLength; i++ ) {
197197 supportedInterfaceRefCounter[config.supportedInterfaces[i]] += 1 ;
@@ -223,55 +223,55 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
223223 }
224224
225225 functionData_[callbackFunction.selector ] =
226- InstalledFunction ({implementation: _extension , permissionBits: 0 , fnType: FunctionType.CALLBACK});
226+ InstalledFunction ({implementation: _module , permissionBits: 0 , fnType: FunctionType.CALLBACK});
227227 }
228228
229- // Store extension function data.
229+ // Store module function data.
230230 uint256 functionLength = config.fallbackFunctions.length ;
231231 for (uint256 i = 0 ; i < functionLength; i++ ) {
232232 FallbackFunction memory ext = config.fallbackFunctions[i];
233233
234- // Check: extension function data not already stored.
234+ // Check: module function data not already stored.
235235 if (functionData_[ext.selector ].implementation != address (0 )) {
236236 revert FallbackFunctionAlreadyInstalled ();
237237 }
238238
239239 functionData_[ext.selector ] = InstalledFunction ({
240- implementation: _extension ,
240+ implementation: _module ,
241241 permissionBits: ext.permissionBits,
242242 fnType: FunctionType.FALLBACK
243243 });
244244 }
245245
246- // Call `onInstall` callback function if extension has registered installation callback.
246+ // Call `onInstall` callback function if module has registered installation callback.
247247 if (config.registerInstallationCallback) {
248248 (bool success , bytes memory returndata ) =
249- _extension .delegatecall (abi.encodeCall (IInstallationCallback.onInstall, (_data)));
249+ _module .delegatecall (abi.encodeCall (IInstallationCallback.onInstall, (_data)));
250250 if (! success) {
251251 _revert (returndata, CallbackExecutionReverted.selector );
252252 }
253253 }
254254
255- emit ExtensionInstalled (msg .sender , _extension, _extension );
255+ emit ModuleInstalled (msg .sender , _module, _module );
256256 }
257257
258- /// @notice Uninstalls an extension contract.
259- function _uninstallExtension (address _extension , bytes memory _data ) internal {
260- // Check: remove and check if the extension is installed
261- if (! extensions .remove (_extension )) {
262- revert ExtensionNotInstalled ();
258+ /// @notice Uninstalls an module contract.
259+ function _uninstallModule (address _module , bytes memory _data ) internal {
260+ // Check: remove and check if the module is installed
261+ if (! modules .remove (_module )) {
262+ revert ModuleNotInstalled ();
263263 }
264264
265- // Get extension config.
266- ExtensionConfig memory config = IModularExtension (_extension). getExtensionConfig ();
265+ // Get module config.
266+ ModuleConfig memory config = IModularModule (_module). getModuleConfig ();
267267
268268 uint256 supportedInterfaceLength = config.supportedInterfaces.length ;
269269 for (uint256 i = 0 ; i < supportedInterfaceLength; i++ ) {
270- // Note: This should not underflow because extension needs to be installed before uninstalling. getExtensionConfig should returns the same value during installation and uninstallation.
270+ // Note: This should not underflow because module needs to be installed before uninstalling. getModuleConfig should returns the same value during installation and uninstallation.
271271 supportedInterfaceRefCounter[config.supportedInterfaces[i]] -= 1 ;
272272 }
273273
274- // Remove extension function data
274+ // Remove module function data
275275 uint256 functionLength = config.fallbackFunctions.length ;
276276 for (uint256 i = 0 ; i < functionLength; i++ ) {
277277 delete functionData_[config.fallbackFunctions[i].selector ];
@@ -284,13 +284,13 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
284284 }
285285
286286 if (config.registerInstallationCallback) {
287- _extension .delegatecall (abi.encodeCall (IInstallationCallback.onUninstall, (_data)));
287+ _module .delegatecall (abi.encodeCall (IInstallationCallback.onUninstall, (_data)));
288288 }
289289
290- emit ExtensionUninstalled (msg .sender , _extension, _extension );
290+ emit ModuleUninstalled (msg .sender , _module, _module );
291291 }
292292
293- /// @dev Calls an extension callback function and checks whether it is optional or required.
293+ /// @dev Calls an module callback function and checks whether it is optional or required.
294294 function _executeCallbackFunction (bytes4 _selector , bytes memory _abiEncodedCalldata )
295295 internal
296296 nonReentrant
@@ -325,7 +325,7 @@ abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
325325 }
326326 }
327327
328- /// @dev Calls an extension callback function and checks whether it is optional or required.
328+ /// @dev Calls an module callback function and checks whether it is optional or required.
329329 function _executeCallbackFunctionView (bytes4 _selector , bytes memory _abiEncodedCalldata )
330330 internal
331331 view
0 commit comments