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/isms/routing/InterchainAccountIsm.sol

38 lines
1.3 KiB

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
// ============ Internal Imports ============
import {AbstractRoutingIsm} from "./AbstractRoutingIsm.sol";
import {IMailbox} from "../../interfaces/IMailbox.sol";
import {IInterchainSecurityModule} from "../../interfaces/IInterchainSecurityModule.sol";
import {Message} from "../../libs/Message.sol";
import {InterchainAccountMessage} from "../../middleware/libs/InterchainAccountMessage.sol";
/**
* @title InterchainAccountIsm
*/
contract InterchainAccountIsm is AbstractRoutingIsm {
IMailbox private immutable mailbox;
// ============ Constructor ============
constructor(address _mailbox) {
mailbox = IMailbox(_mailbox);
}
// ============ Public Functions ============
/**
* @notice Returns the ISM responsible for verifying _message
* @param _message Formatted Hyperlane message (see Message.sol).
* @return module The ISM to use to verify _message
*/
function route(
bytes calldata _message
) public view virtual override returns (IInterchainSecurityModule) {
address _ism = InterchainAccountMessage.ism(Message.body(_message));
if (_ism == address(0)) {
return mailbox.defaultIsm();
} else {
return IInterchainSecurityModule(_ism);
}
}
}