The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hyperlane-monorepo/solidity/contracts/client/MailboxClient.sol

38 lines
1023 B

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.6.11;
// ============ Internal Imports ============
import {IMailbox} from "../interfaces/IMailbox.sol";
import {Message} from "../libs/Message.sol";
// ============ External Imports ============
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
abstract contract MailboxClient {
using Message for bytes;
IMailbox immutable mailbox;
constructor(address _mailbox) {
require(Address.isContract(_mailbox), "MailboxClient: invalid mailbox");
mailbox = IMailbox(_mailbox);
}
// ============ Modifiers ============
/**
* @notice Only accept messages from an Hyperlane Mailbox contract
*/
modifier onlyMailbox() {
require(
msg.sender == address(mailbox),
"MailboxClient: sender not mailbox"
);
_;
}
function isLatestDispatched(bytes32 id) internal view returns (bool) {
return mailbox.latestDispatchedId() == id;
}
}