all files / contracts/modules/ Installer.sol

100% Statements 18/18
100% Branches 8/8
100% Functions 6/6
100% Lines 19/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                      74× 74× 71×                         66× 539× 539× 537×   537×   537× 234× 233×     536×        
// SPDX-License-Identifier: GPL-2.0-or-later
 
pragma solidity ^0.8.0;
 
import "../BaseModule.sol";
 
 
contract Installer is BaseModule {
    constructor(bytes32 moduleGitCommit_) BaseModule(MODULEID__INSTALLER, moduleGitCommit_) {}
 
    modifier adminOnly {
        address msgSender = unpackTrailingParamMsgSender();
        require(msgSender == upgradeAdmin, "e/installer/unauthorized");
        _;
    }
 
    function getUpgradeAdmin() external view returns (address) {
        return upgradeAdmin;
    }
 
    function setUpgradeAdmin(address newUpgradeAdmin) external nonReentrant adminOnly {
        require(newUpgradeAdmin != address(0), "e/installer/bad-admin-addr");
        upgradeAdmin = newUpgradeAdmin;
        emit InstallerSetUpgradeAdmin(newUpgradeAdmin);
    }
 
    function setGovernorAdmin(address newGovernorAdmin) external nonReentrant adminOnly {
        require(newGovernorAdmin != address(0), "e/installer/bad-gov-addr");
        governorAdmin = newGovernorAdmin;
        emit InstallerSetGovernorAdmin(newGovernorAdmin);
    }
 
    function installModules(address[] memory moduleAddrs) external nonReentrant adminOnly {
        for (uint i = 0; i < moduleAddrs.length; ++i) {
            address moduleAddr = moduleAddrs[i];
            uint newModuleId = BaseModule(moduleAddr).moduleId();
            bytes32 moduleGitCommit = BaseModule(moduleAddr).moduleGitCommit();
 
            moduleLookup[newModuleId] = moduleAddr;
 
            if (newModuleId <= MAX_EXTERNAL_SINGLE_PROXY_MODULEID) {
                address proxyAddr = _createProxy(newModuleId);
                trustedSenders[proxyAddr].moduleImpl = moduleAddr;
            }
 
            emit InstallerInstallModule(newModuleId, moduleAddr, moduleGitCommit);
        }
    }
}