Skip to content

Commit

Permalink
fix(interfaces): add ISingleMessageDispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed Nov 1, 2023
1 parent c3e9c99 commit 0eac8e4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 27 deletions.
9 changes: 7 additions & 2 deletions src/ethereum-arbitrum/EthereumToArbitrumDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ pragma solidity ^0.8.16;
import { IInbox } from "@arbitrum/nitro-contracts/src/bridge/IInbox.sol";

import { IMessageExecutor } from "../interfaces/IMessageExecutor.sol";
import { IMessageDispatcher, IBatchMessageDispatcher, IMessageDispatcherArbitrum } from "../interfaces/extensions/IMessageDispatcherArbitrum.sol";
import {
IMessageDispatcher,
ISingleMessageDispatcher,
IBatchMessageDispatcher,
IMessageDispatcherArbitrum
} from "../interfaces/extensions/IMessageDispatcherArbitrum.sol";

import { MessageLib } from "../libraries/MessageLib.sol";

Expand Down Expand Up @@ -295,7 +300,7 @@ contract MessageDispatcherArbitrum is IMessageDispatcherArbitrum {
return _getMessageBatchTxHash(_messageId, _from, _messages);
}

/// @inheritdoc IMessageDispatcher
/// @inheritdoc ISingleMessageDispatcher
function getMessageExecutorAddress(uint256 _toChainId) external view returns (address) {
_checkToChainId(_toChainId);
return address(executor);
Expand Down
9 changes: 7 additions & 2 deletions src/ethereum-optimism/EthereumToOptimismDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ pragma solidity ^0.8.16;
import { ICrossDomainMessenger } from "../vendor/optimism/ICrossDomainMessenger.sol";

import { IMessageExecutor } from "../interfaces/IMessageExecutor.sol";
import { IMessageDispatcher, IBatchMessageDispatcher, IMessageDispatcherOptimism } from "../interfaces/extensions/IMessageDispatcherOptimism.sol";
import {
IMessageDispatcher,
ISingleMessageDispatcher,
IBatchMessageDispatcher,
IMessageDispatcherOptimism
} from "../interfaces/extensions/IMessageDispatcherOptimism.sol";

import { MessageLib } from "../libraries/MessageLib.sol";

Expand Down Expand Up @@ -86,7 +91,7 @@ contract MessageDispatcherOptimism is IMessageDispatcherOptimism {
return _dispatchMessageBatch(_toChainId, _messages, _gasLimit);
}

/// @inheritdoc IMessageDispatcher
/// @inheritdoc ISingleMessageDispatcher
function getMessageExecutorAddress(uint256 _toChainId) external view returns (address) {
return _getMessageExecutorAddress(_toChainId);
}
Expand Down
8 changes: 6 additions & 2 deletions src/ethereum-polygon/EthereumToPolygonDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ pragma solidity ^0.8.16;

import { FxBaseRootTunnel } from "@maticnetwork/fx-portal/contracts/tunnel/FxBaseRootTunnel.sol";

import { IMessageDispatcher, IBatchMessageDispatcher } from "../interfaces/extensions/IBatchMessageDispatcher.sol";
import {
IMessageDispatcher,
ISingleMessageDispatcher,
IBatchMessageDispatcher
} from "../interfaces/extensions/IBatchMessageDispatcher.sol";

import { MessageLib } from "../libraries/MessageLib.sol";

Expand Down Expand Up @@ -78,7 +82,7 @@ contract MessageDispatcherPolygon is IBatchMessageDispatcher, FxBaseRootTunnel {
return _messageId;
}

/// @inheritdoc IMessageDispatcher
/// @inheritdoc ISingleMessageDispatcher
function getMessageExecutorAddress(uint256 _chainId) external view returns (address) {
_checkToChainId(_chainId);
return address(fxChildTunnel);
Expand Down
8 changes: 0 additions & 8 deletions src/interfaces/IMessageDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ interface IMessageDispatcher {
address to,
bytes calldata data
) external returns (bytes32);

/**
* @notice Retrieves address of the MessageExecutor contract on the receiving chain.
* @dev Must revert if `toChainId` is not supported.
* @param toChainId ID of the chain with which MessageDispatcher is communicating
* @return MessageExecutor contract address
*/
function getMessageExecutorAddress(uint256 toChainId) external returns (address);
}
9 changes: 4 additions & 5 deletions src/interfaces/extensions/IBatchMessageDispatcher.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.16;

import { IMessageDispatcher } from "../IMessageDispatcher.sol";
import { IMessageDispatcher, ISingleMessageDispatcher } from "./ISingleMessageDispatcher.sol";
import { MessageLib } from "../../libraries/MessageLib.sol";

/**
* @title ERC-5164: Cross-Chain Execution Standard, optional BatchMessageDispatcher extension
* @dev IMessageDispatcher interface extended to support batch messaging.
* @dev See https://eips.ethereum.org/EIPS/eip-5164
* @title BatchMessageDispatcher interface
* @dev ISingleMessageDispatcher interface extended to support batch messaging.
*/
interface IBatchMessageDispatcher is IMessageDispatcher {
interface IBatchMessageDispatcher is ISingleMessageDispatcher {
/**
* @notice Emitted when a batch of messages has successfully been dispatched to the executor chain.
* @param messageId ID uniquely identifying the messages
Expand Down
12 changes: 8 additions & 4 deletions src/interfaces/extensions/IMessageDispatcherArbitrum.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.16;

import { MessageLib, IMessageDispatcher, IBatchMessageDispatcher } from "./IBatchMessageDispatcher.sol";
import {
MessageLib,
IMessageDispatcher,
ISingleMessageDispatcher,
IBatchMessageDispatcher
} from "./IBatchMessageDispatcher.sol";

/**
* @title ERC-5164: Cross-Chain Execution Standard
* @dev IMessageDispatcher interface extended to support Arbitrum two steps message dispatch.
* @dev See https://eips.ethereum.org/EIPS/eip-5164
* @title MessageDispatcherArbitrum interface
* @dev IBatchMessageDispatcher interface extended to support Arbitrum two steps message dispatch.
*/
interface IMessageDispatcherArbitrum is IBatchMessageDispatcher {
/**
Expand Down
12 changes: 8 additions & 4 deletions src/interfaces/extensions/IMessageDispatcherOptimism.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.16;

import { MessageLib, IMessageDispatcher, IBatchMessageDispatcher } from "./IBatchMessageDispatcher.sol";
import {
MessageLib,
IMessageDispatcher,
ISingleMessageDispatcher,
IBatchMessageDispatcher
} from "./IBatchMessageDispatcher.sol";

/**
* @title ERC-5164: Cross-Chain Execution Standard
* @dev IMessageDispatcher interface extended to support a custom gas limit for Optimism.
* @dev See https://eips.ethereum.org/EIPS/eip-5164
* @title MessageDispatcherOptimism interface
* @dev IBatchMessageDispatcher interface extended to support a custom gas limit for Optimism.
*/
interface IMessageDispatcherOptimism is IBatchMessageDispatcher {
/**
Expand Down
18 changes: 18 additions & 0 deletions src/interfaces/extensions/ISingleMessageDispatcher.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.16;

import { IMessageDispatcher } from "../IMessageDispatcher.sol";

/**
* @title SingleMessageDispatcher interface
* @dev IMessageDispatcher interface extended to retrieve the MessageExecutor contract address.
*/
interface ISingleMessageDispatcher is IMessageDispatcher {
/**
* @notice Retrieves address of the MessageExecutor contract on the receiving chain.
* @dev Must revert if `toChainId` is not supported.
* @param toChainId ID of the chain with which MessageDispatcher is communicating
* @return MessageExecutor contract address
*/
function getMessageExecutorAddress(uint256 toChainId) external returns (address);
}

0 comments on commit 0eac8e4

Please sign in to comment.