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/hooks/DomainRoutingHook.sol

28 lines
852 B

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {AbstractHook} from "./AbstractHook.sol";
import {Message} from "../libs/Message.sol";
import {IPostDispatchHook} from "../interfaces/hooks/IPostDispatchHook.sol";
contract DomainRoutingHook is AbstractHook, Ownable {
using Message for bytes;
mapping(uint32 => IPostDispatchHook) public hooks;
constructor(address _mailbox, address _owner) AbstractHook(_mailbox) {
_transferOwnership(_owner);
}
function setHook(uint32 destination, address hook) external onlyOwner {
hooks[destination] = IPostDispatchHook(hook);
}
function _postDispatch(bytes calldata message) internal override {
hooks[message.destination()].postDispatch{value: msg.value}(message);
}
}