// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable-next-line no-unused-import import {TypeAndVersionInterface} from "../../../interfaces/TypeAndVersionInterface.sol"; // solhint-disable-next-line no-unused-import import {ForwarderInterface} from "../interfaces/ForwarderInterface.sol"; import {DelegateForwarderInterface} from "../interfaces/DelegateForwarderInterface.sol"; import {ArbitrumCrossDomainForwarder} from "./ArbitrumCrossDomainForwarder.sol"; import {Address} from "../../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils/Address.sol"; /** * @title ArbitrumCrossDomainGovernor - L1 xDomain account representation (with delegatecall support) for Arbitrum * @notice L2 Contract which receives messages from a specific L1 address and transparently forwards them to the destination. * @dev Any other L2 contract which uses this contract's address as a privileged position, * can be considered to be simultaneously owned by the `l1Owner` and L2 `owner` */ contract ArbitrumCrossDomainGovernor is DelegateForwarderInterface, ArbitrumCrossDomainForwarder { /** * @notice creates a new Arbitrum xDomain Forwarder contract * @param l1OwnerAddr the L1 owner address that will be allowed to call the forward fn * @dev Empty constructor required due to inheriting from abstract contract CrossDomainForwarder */ constructor(address l1OwnerAddr) ArbitrumCrossDomainForwarder(l1OwnerAddr) {} /** * @notice versions: * * - ArbitrumCrossDomainGovernor 1.0.0: initial release * * @inheritdoc TypeAndVersionInterface */ function typeAndVersion() external pure virtual override returns (string memory) { return "ArbitrumCrossDomainGovernor 1.0.0"; } /** * @dev forwarded only if L2 Messenger calls with `msg.sender` being the L1 owner address, or called by the L2 owner * @inheritdoc ForwarderInterface */ function forward(address target, bytes memory data) external override onlyLocalOrCrossDomainOwner { Address.functionCall(target, data, "Governor call reverted"); } /** * @dev forwarded only if L2 Messenger calls with `msg.sender` being the L1 owner address, or called by the L2 owner * @inheritdoc DelegateForwarderInterface */ function forwardDelegate(address target, bytes memory data) external override onlyLocalOrCrossDomainOwner { Address.functionDelegateCall(target, data, "Governor delegatecall reverted"); } /** * @notice The call MUST come from either the L1 owner (via cross-chain message) or the L2 owner. Reverts otherwise. */ modifier onlyLocalOrCrossDomainOwner() { // solhint-disable-next-line gas-custom-errors require(msg.sender == crossDomainMessenger() || msg.sender == owner(), "Sender is not the L2 messenger or owner"); _; } }