NetworkConfig

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
    struct Ownable2StepStorage {
        address _pendingOwner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;

    function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
        assembly {
            $.slot := Ownable2StepStorageLocation
        }
    }

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    function __Ownable2Step_init() internal onlyInitializing {
    }

    function __Ownable2Step_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        return $._pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        $._pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        delete $._pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        OwnableStorage storage $ = _getOwnableStorage();
        return $._owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        OwnableStorage storage $ = _getOwnableStorage();
        address oldOwner = $._owner;
        $._owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reinitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
     *
     * NOTE: Consider following the ERC-7201 formula to derive storage locations.
     */
    function _initializableStorageSlot() internal pure virtual returns (bytes32) {
        return INITIALIZABLE_STORAGE;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        bytes32 slot = _initializableStorageSlot();
        assembly {
            $.slot := slot
        }
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
"
    },
    "src/common/UnrenouncableOwnable2Step.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
 * @title UnrenouncableOwnable2Step
 * @dev Contract that extends Ownable2StepUpgradeable but prevents renouncing ownership
 */
contract UnrenouncableOwnable2Step is Ownable2StepUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     * @param initialOwner The address that will be the initial owner
     */
    function __UnrenouncableOwnable2Step_init(address initialOwner) internal onlyInitializing {
        __Ownable_init(initialOwner);  // Initialize OwnableUpgradeable with owner
        __Ownable2Step_init();  // Then initialize Ownable2StepUpgradeable
    }

    /**
     * @dev Prevents renouncing ownership
     */
    function renounceOwnership() public view override onlyOwner {
        revert("UnrenouncableOwnable2Step: cannot renounce ownership");
    }
}"
    },
    "src/l1_management/contracts/NetworkConfig.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

import "../../lib/Storage.sol";
import "../../common/UnrenouncableOwnable2Step.sol";
/**
 * @title NetworkConfig
 * @dev Contract for managing network configuration and addresses
 * Implements a storage mechanism for fixed and dynamic addresses
 * Allows for adding and retrieving additional addresses
 */
contract NetworkConfig is Initializable, UnrenouncableOwnable2Step {

    /**
     * @dev Struct for system addresses that we don't expect to change
     */
    struct FixedAddresses {
        address crossChain;
        address messageBus;
        address networkEnclaveRegistry;
        address dataAvailabilityRegistry;
    }

    /**
     * @dev Struct for named addresses
     */
    struct NamedAddress {
        string name;
        address addr;
    }

    /**
     * @dev Struct for all addresses
     */
    struct Addresses {
        address crossChain;
        address messageBus;
        address networkEnclaveRegistry;
        address dataAvailabilityRegistry;
        address l1Bridge;
        address l2Bridge;
        address l1CrossChainMessenger;
        address l2CrossChainMessenger;
        NamedAddress[] additionalContracts;  // Dynamic address storage
    }

    /**
     * @dev Struct for contract version information
     */
    struct ContractVersion {
        string name;
        string version;
        address implementation;
    }

    // storage slots for fixed contracts
    bytes32 public constant CROSS_CHAIN_SLOT = bytes32(uint256(keccak256("networkconfig.crossChain")) - 1);
    bytes32 public constant MESSAGE_BUS_SLOT = bytes32(uint256(keccak256("networkconfig.messageBus")) - 1);
    bytes32 public constant NETWORK_ENCLAVE_REGISTRY_SLOT = bytes32(uint256(keccak256("networkconfig.networkEnclaveRegistry")) - 1);
    bytes32 public constant DATA_AVAILABILITY_REGISTRY_SLOT = bytes32(uint256(keccak256("networkconfig.dataAvailabilityRegistry")) - 1);

    // storage slots for contracts that may need to be redeployed 
    bytes32 public constant L1_BRIDGE_SLOT = bytes32(uint256(keccak256("networkconfig.l1Bridge")) - 1);
    bytes32 public constant L2_BRIDGE_SLOT = bytes32(uint256(keccak256("networkconfig.l2Bridge")) - 1);
    bytes32 public constant L1_CROSS_CHAIN_MESSENGER = bytes32(uint256(keccak256("networkconfig.l1CrossChainMessenger")) - 1);
    bytes32 public constant L2_CROSS_CHAIN_MESSENGER = bytes32(uint256(keccak256("networkconfig.l2CrossChainMessenger")) - 1);

    // simple storage for additional addresses
    string[] public addressNames;
    mapping(string contractName => address contractAddress) public additionalAddresses;

    /**
     * @dev Storage slot for the fork manager
     */
    bytes32 public constant FORK_MANAGER_SLOT = bytes32(uint256(keccak256("networkconfig.forkManager")) - 1);

    /**
     * @dev Event emitted when a network contract address is added
     * @param name The name of the contract
     * @param addr The address of the contract
     */
    event NetworkContractAddressAdded(string name, address addr);
    
    /**
     * @dev Event emitted when an additional contract address is added
     * @param name The name of the contract
     * @param addr The address of the contract
     */
    event AdditionalContractAddressAdded(string name, address addr);

    /**
     * @dev Event emitted when an additional contract address is removed
     * @param name The name of the contract
     */
    event AdditionalContractAddressRemoved(string name);

    /**
     * @dev Event emitted when a feature is upgraded - for example gas pricing model from static to dynamic.
     * @param featureName The name of the feature that was upgraded
     * @param featureData The data of the feature that was upgraded - to be forwarded to it for initialization.
     */
    event Upgraded(string featureName, bytes featureData);

    /**
     * @dev Initializes the contract with addresses and owner
     * @param _addresses The fixed addresses
     * @param _owner Address of the contract owner
     */
    function initialize(NetworkConfig.FixedAddresses memory _addresses, address _owner) public initializer {
        require(_owner != address(0), "Owner cannot be 0x0");   
        require(_addresses.crossChain != address(0), "Cross chain cannot be 0x0");
        require(_addresses.messageBus != address(0), "Message bus cannot be 0x0");
        require(_addresses.networkEnclaveRegistry != address(0), "Network enclave registry cannot be 0x0");
        require(_addresses.dataAvailabilityRegistry != address(0), "Data availability registry cannot be 0x0");

        __UnrenouncableOwnable2Step_init(_owner);
        Storage.setAddress(CROSS_CHAIN_SLOT, _addresses.crossChain);
        Storage.setAddress(MESSAGE_BUS_SLOT, _addresses.messageBus);
        Storage.setAddress(NETWORK_ENCLAVE_REGISTRY_SLOT, _addresses.networkEnclaveRegistry);
        Storage.setAddress(DATA_AVAILABILITY_REGISTRY_SLOT, _addresses.dataAvailabilityRegistry);
    }

    /**
     * @dev Gets the cross chain contract address
     */
    function crossChainContractAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(CROSS_CHAIN_SLOT);
    }

    /**
     * @dev Gets the message bus contract address
     */
    function messageBusContractAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(MESSAGE_BUS_SLOT);
    }

    /**
     * @dev Gets the network enclave registry contract address
     */
    function networkEnclaveRegistryContractAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(NETWORK_ENCLAVE_REGISTRY_SLOT);
    }

    /**
     * @dev Gets the data availability registry contract address
     */     
    function daRegistryContractAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(DATA_AVAILABILITY_REGISTRY_SLOT);
    }

    /**
     * @dev Gets the L1 bridge contract address
     */
    function l1BridgeAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(L1_BRIDGE_SLOT);
    }

    /**
     * @dev Gets the L2 bridge contract address
     */
    function l2BridgeAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(L2_BRIDGE_SLOT);
    }

    /**
     * @dev Gets the L1 cross chain messenger contract address
     */
    function l1CrossChainMessengerAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(L1_CROSS_CHAIN_MESSENGER);
    }

    /**
     * @dev Gets the L2 cross chain messenger contract address
     */
    function l2CrossChainMessengerAddress() public view returns (address addr_) {
        addr_ = Storage.getAddress(L2_CROSS_CHAIN_MESSENGER);
    }

    /**
     * @dev Sets the L1 bridge contract address
     * @param _addr The address of the L1 bridge contract
     */
    function setL1BridgeAddress(address _addr) external onlyOwner {
        require(_addr != address(0), "Invalid address");
        Storage.setAddress(L1_BRIDGE_SLOT, _addr);
        emit NetworkContractAddressAdded("l1Bridge", _addr);
    }

    /**
     * @dev Sets the L2 bridge contract address
     * @param _addr The address of the L2 bridge contract
     */
    function setL2BridgeAddress(address _addr) external onlyOwner {
        require(_addr != address(0), "Invalid address");
        Storage.setAddress(L2_BRIDGE_SLOT, _addr);
        emit NetworkContractAddressAdded("l2Bridge", _addr);
    }

    /**
     * @dev Sets the L1 cross chain messenger contract address
     * @param _addr The address of the L1 cross chain messenger contract
     */
    function setL1CrossChainMessengerAddress(address _addr) external onlyOwner {
        require(_addr != address(0), "Invalid address");
        Storage.setAddress(L1_CROSS_CHAIN_MESSENGER, _addr);
        emit NetworkContractAddressAdded("l1CrossChainMessenger", _addr);
    }

    /**
     * @dev Sets the L2 cross chain messenger contract address
     * @param _addr The address of the L2 cross chain messenger contract
     */
    function setL2CrossChainMessengerAddress(address _addr) external onlyOwner {
        require(_addr != address(0), "Invalid address");
        Storage.setAddress(L2_CROSS_CHAIN_MESSENGER, _addr);
        emit NetworkContractAddressAdded("l2CrossChainMessenger", _addr);
    }

    /**
     * @dev Adds an additional contract address
     * @param name The name of the contract
     * @param addr The address of the contract
     */
    function addAdditionalAddress(string calldata name, address addr) external onlyOwner {
        require(addr != address(0), "Invalid address");
        require(additionalAddresses[name] == address(0), "Address already exists");
        require(bytes(name).length > 0, "Name cannot be empty");
        if (additionalAddresses[name] == address(0)) {
            addressNames.push(name);
        }
        additionalAddresses[name] = addr;
        emit AdditionalContractAddressAdded(name, addr);
    }

    function removeAdditionalAddress(string calldata name) external onlyOwner {
        require(additionalAddresses[name] != address(0), "Address does not exist");
        delete additionalAddresses[name];
        emit AdditionalContractAddressRemoved(name);
    }

    
    /**
     * @dev Gets the additional contract names
     * @return string[] The names of the additional contracts
     */
    function getAdditionalContractNames() public view returns (string[] memory) {
        return addressNames;
    }

    /**
     * @dev Gets all stored addresses
     * @return Addresses The addresses
     */
    function addresses() external view returns (Addresses memory) {
        NamedAddress[] memory additional = new NamedAddress[](addressNames.length);
        for(uint i = 0; i < addressNames.length; i++) {
            additional[i] = NamedAddress({
                name: addressNames[i],
                addr: additionalAddresses[addressNames[i]]
            });
        }

        return Addresses({
            networkEnclaveRegistry: networkEnclaveRegistryContractAddress(),
            crossChain: crossChainContractAddress(),
            messageBus: messageBusContractAddress(),
            dataAvailabilityRegistry: daRegistryContractAddress(),
            l1Bridge: l1BridgeAddress(),
            l2Bridge: l2BridgeAddress(),
            l1CrossChainMessenger: l1CrossChainMessengerAddress(),
            l2CrossChainMessenger: l2CrossChainMessengerAddress(),
            additionalContracts: additional
        });
    }

    /**
     * @dev Upgrades a feature of the network - The event emitted is used by the node go code to modify network behaviour after a given
     * l1 block. The feature data is forwarded to the feature for initialization.
     * @param featureName The name of the feature that was upgraded
     * @param featureData The data of the feature that was upgraded - to be forwarded to it for initialization.
     */
    function upgradeFeature(string calldata featureName, bytes calldata featureData) external onlyOwner {
        emit Upgraded(featureName, featureData);
    }
}"
    },
    "src/lib/Storage.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Storage
 * @dev Library for managing storage slots in upgradeable contracts
 * This pattern prevents storage collisions between different versions of a contract
 * by using explicit storage slots for each variable
 */
library Storage {
    /**
     * @dev Reads an address from a specific storage slot
     * @param _slot The storage slot to read from, typically calculated as keccak256(variable_name) - 1
     * @return addr_ The address stored in the slot
     * @notice Uses assembly for direct storage access which is more gas efficient
     */
    function getAddress(bytes32 _slot) internal view returns (address addr_) {
        assembly {
            addr_ := sload(_slot)
        }
    }

    /**
     * @dev Writes an address to a specific storage slot
     * @param _slot The storage slot to write to
     * @param _address The address to store
     * @notice Storage slots should be unique and deterministic to avoid collisions
     * @notice Formula for slot calculation: bytes32(uint256(keccak256("variable_name")) - 1)
     */
    function setAddress(bytes32 _slot, address _address) internal {
        assembly {
            sstore(_slot, _address)
        }
    }
}"
    }
  },
  "settings": {
    "viaIR": false,
    "optimizer": {
      "enabled": true,
      "runs": 1000,
      "details": {
        "yulDetails": {
          "optimizerSteps": "u"
        }
      }
    },
    "evmVersion": "cancun",
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}}

Tags:
Multisig, Upgradeable, Multi-Signature, Factory|addr:0xb3135d91e46776ffab1d7c811a1bfd0d4a2ddf3f|verified:true|block:23431822|tx:0xa58f1987e2edcca0164eecf6f55ee4add3aa2484effe269418cd4cdb61eea0f7|first_check:1758735031

Submitted on: 2025-09-24 19:30:31

Comments

Log in to comment.

No comments yet.