ModuleManagerBase_v1.sol

Git Sourcearrow-up-right

Inherits: IModuleManagerBase_v1, Initializablearrow-up-right, ERC2771ContextUpgradeablearrow-up-right, ERC165Upgradeablearrow-up-right

Author: Inverter Network Adapted from Gnosis Safe

A contract to manage Inverter Network modules. It allows for adding and removing modules in a local registry for reference. Additional functionality includes the execution of calls from this contract. The transaction execution and module management is copied from Gnosis Safe's ModuleManagerarrow-up-right.

State Variables

MAX_MODULE_AMOUNT

Marks the maximum amount of Modules a {Orchestrator_v1}arrow-up-right can have to avoid out-of-gas risk.

uint private constant MAX_MODULE_AMOUNT = 128;

MODULE_UPDATE_TIMELOCK

Timelock used between initiating adding or removing a module and executing it.

uint public constant MODULE_UPDATE_TIMELOCK = 72 hours;

moduleFactory

{ModuleFactory_v1}arrow-up-right.

address public moduleFactory;

_modules

List of modules.

_isModule

Mapping to keep track of whether a module is used in the {Orchestrator_v1}arrow-up-right address => isModule.

moduleAddressToTimelock

Mapping to keep track of active timelocks for updating modules module => timelock.

__gap

Storage gap for future upgrades.

Functions

supportsInterface

See {IERC165-supportsInterface}arrow-up-right.

__ModuleManager_onlyAuthorized

Modifier to guarantee function is only callable by authorized address.

onlyModule

Modifier to guarantee that the caller is a module.

validModule

Modifier to guarantee that the given module is a valid module.

isModule_

Modifier to guarantee that the given module is a registered module.

isNotModule

Modifier to guarantee that the given module is not a registered module.

moduleLimitNotExceeded

Modifier to guarantee that the number of modules is not exceeded.

updatingModuleAlreadyStarted

Modifier to guarantee that the given module is not already being updated.

timelockExpired

Modifier to guarantee that the timelock for the given module is expired.

constructor

__ModuleManager_init

Initialization function.

Only callable during initialization.

Parameters

Name
Type
Description

_moduleFactory

address

The address of the module factory.

modules

address[]

The addresses of the modules used in the orchestrator.

__ModuleManager_addModule

Adds address module as module.

Parameters

Name
Type
Description

module

address

The module address to add.

__ModuleManager_isAuthorized

Returns whether address who is authorized to mutate module manager's state.

MUST be overridden in downstream contract.

Parameters

Name
Type
Description

who

address

The address to check.

Returns

Name
Type
Description

<none>

bool

True if the address is authorized, false otherwise.

isModule

Returns whether the address module is added as module.

Parameters

Name
Type
Description

module

address

The module to check.

Returns

Name
Type
Description

<none>

bool

True if module added, false otherwise.

listModules

Returns the list of all modules.

Returns

Name
Type
Description

<none>

address[]

List of all modules.

modulesSize

Returns the number of modules.

Returns

Name
Type
Description

<none>

uint8

The number of modules.

_cancelModuleUpdate

Cancels an initiated update for a module.

Only callable by authorized address.

Fails if module update has not been initiated.

Parameters

Name
Type
Description

module

address

The module address to remove.

_initiateAddModuleWithTimelock

Initiates adding of a module to the {Orchestrator_v1}arrow-up-right on a timelock.

Only callable by authorized address.

Fails of adding module exeeds max modules limit.

Fails if address invalid or address already added as module.

Parameters

Name
Type
Description

module

address

The module address to add.

_initiateRemoveModuleWithTimelock

Initiates removing of a module from the {Orchestrator_v1}arrow-up-right on a timelock.

Only callable by authorized address.

Fails if address not added as module.

Parameters

Name
Type
Description

module

address

The module address to remove.

_executeAddModule

Executes adding of a module to the {Orchestrator_v1}arrow-up-right.

Only callable by authorized address.

Fails if adding of module has not been initiated.

Fails if timelock has not been expired yet.

Parameters

Name
Type
Description

module

address

The module address to add.

_executeRemoveModule

Executes removing of a module from the {Orchestrator_v1}arrow-up-right.

Only callable by authorized address.

Fails if removing of module has not been initiated.

Fails if timelock has not been expired yet.

Parameters

Name
Type
Description

module

address

The module address to remove.

_commitAddModule

Expects module to be valid module address.

Expects module to not be enabled module.

Parameters

Name
Type
Description

module

address

The module address to add.

_commitRemoveModule

Expects address arguments to be consecutive in the modules list.

Expects address module to be enabled module.

Parameters

Name
Type
Description

module

address

The module address to remove.

_ensureValidModule

Ensures that the given module is a valid module.

Reverts if the module is invalid.

Parameters

Name
Type
Description

module

address

The module address to check.

_ensureNotModule

Ensures that the given module is not a registered module.

Reverts if the module is registered.

Parameters

Name
Type
Description

module

address

The module address to check.

_startModuleUpdateTimelock

Starts the timelock for the given module.

Parameters

Name
Type
Description

_module

address

The module address to start the timelock for.

isTrustedForwarder

Returns wether the given address is the trusted forwarder or not.

Exposes the ERC2771 isTrusted Forwarder.

Parameters

Name
Type
Description

forwarder

address

The address to check.

Returns

Name
Type
Description

<none>

bool

True if the address is the trusted forwarder, false otherwise.

trustedForwarder

Returns the trusted forwarder for metatransactions.

Exposes the ERC2771 isTrusted Forwarder.

Returns

Name
Type
Description

<none>

address

The trusted forwarder address.

Last updated