// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.6.11; // ============ Internal Imports ============ import {IInterchainGasPaymaster} from "../interfaces/IInterchainGasPaymaster.sol"; import {IMailbox} from "../interfaces/IMailbox.sol"; // ============ External Imports ============ import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; abstract contract HyperlaneConnectionClient is OwnableUpgradeable { // ============ Mutable Storage ============ IMailbox public mailbox; // Interchain Gas Paymaster contract. The relayer associated with this contract // must be willing to relay messages dispatched from the current Outbox contract, // otherwise payments made to the paymaster will not result in relayed messages. IInterchainGasPaymaster public interchainGasPaymaster; uint256[48] private __GAP; // gap for upgrade safety // ============ Events ============ /** * @notice Emitted when a new mailbox is set. * @param mailbox The address of the mailbox contract */ event MailboxSet(address indexed mailbox); /** * @notice Emitted when a new Interchain Gas Paymaster is set. * @param interchainGasPaymaster The address of the Interchain Gas Paymaster. */ event InterchainGasPaymasterSet(address indexed interchainGasPaymaster); // ============ Modifiers ============ /** * @notice Only accept messages from an Hyperlane Mailbox contract */ modifier onlyMailbox() { require(msg.sender == address(mailbox), "!mailbox"); _; } // ======== Initializer ========= function __HyperlaneConnectionClient_initialize(address _mailbox) internal onlyInitializing { _setMailbox(_mailbox); __Ownable_init(); } function __HyperlaneConnectionClient_initialize( address _mailbox, address _interchainGasPaymaster ) internal onlyInitializing { _setInterchainGasPaymaster(_interchainGasPaymaster); __HyperlaneConnectionClient_initialize(_mailbox); } // ============ External functions ============ /** * @notice Sets the address of the application's Mailbox. * @param _mailbox The address of the Mailbox contract. */ function setMailbox(address _mailbox) external virtual onlyOwner { _setMailbox(_mailbox); } /** * @notice Sets the address of the application's InterchainGasPaymaster. * @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract. */ function setInterchainGasPaymaster(address _interchainGasPaymaster) external virtual onlyOwner { _setInterchainGasPaymaster(_interchainGasPaymaster); } // ============ Internal functions ============ /** * @notice Sets the address of the application's InterchainGasPaymaster. * @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract. */ function _setInterchainGasPaymaster(address _interchainGasPaymaster) internal { interchainGasPaymaster = IInterchainGasPaymaster( _interchainGasPaymaster ); emit InterchainGasPaymasterSet(_interchainGasPaymaster); } /** * @notice Modify the contract the Application uses to validate Inbox contracts * @param _mailbox The address of the mailbox contract */ function _setMailbox(address _mailbox) internal { mailbox = IMailbox(_mailbox); emit MailboxSet(_mailbox); } }