From 97e1a9b86fc88dbb2be5bdcad2bc9d068e257bda Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Tue, 13 Dec 2022 11:16:03 -0600 Subject: [PATCH] fix(contracts): remove payable from relayCalls --- README.md | 2 +- .../EthereumToArbitrumRelayer.sol | 1 - .../EthereumToOptimismRelayer.sol | 1 - .../EthereumToPolygonRelayer.sol | 1 - src/interfaces/ICrossChainRelayer.sol | 7 +-- src/interfaces/ICrossChainRelayerPayable.sol | 47 +++++++++++++++++++ 6 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 src/interfaces/ICrossChainRelayerPayable.sol diff --git a/README.md b/README.md index 707f04f..0f89600 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ To use ERC-5164 to send messages your contract code will need to: - On the sending chain, send a batch of calls to the CrossChainRelayer `relayCalls` function - Listen for calls from the corresponding CrossChainExecutor(s) on the receiving chain. -*The listener will need to be able to unpack the original sender address (it's appended to calldata). We recommend inheriting from the included [`ExecutorAware.sol`](./src/abstract/ExecutorAware.sol) contract.* +_The listener will need to be able to unpack the original sender address (it's appended to calldata). We recommend inheriting from the included [`ExecutorAware.sol`](./src/abstract/ExecutorAware.sol) contract._ **Note** diff --git a/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol b/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol index f88674d..76a8014 100644 --- a/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol +++ b/src/ethereum-arbitrum/EthereumToArbitrumRelayer.sol @@ -66,7 +66,6 @@ contract CrossChainRelayerArbitrum is ICrossChainRelayer { /// @inheritdoc ICrossChainRelayer function relayCalls(CallLib.Call[] calldata _calls, uint256 _gasLimit) external - payable returns (uint256) { uint256 _maxGasLimit = maxGasLimit; diff --git a/src/ethereum-optimism/EthereumToOptimismRelayer.sol b/src/ethereum-optimism/EthereumToOptimismRelayer.sol index ac70501..010e9fa 100644 --- a/src/ethereum-optimism/EthereumToOptimismRelayer.sol +++ b/src/ethereum-optimism/EthereumToOptimismRelayer.sol @@ -48,7 +48,6 @@ contract CrossChainRelayerOptimism is ICrossChainRelayer { /// @inheritdoc ICrossChainRelayer function relayCalls(CallLib.Call[] calldata _calls, uint256 _gasLimit) external - payable returns (uint256) { uint256 _maxGasLimit = maxGasLimit; diff --git a/src/ethereum-polygon/EthereumToPolygonRelayer.sol b/src/ethereum-polygon/EthereumToPolygonRelayer.sol index 2867314..4878ca8 100644 --- a/src/ethereum-polygon/EthereumToPolygonRelayer.sol +++ b/src/ethereum-polygon/EthereumToPolygonRelayer.sol @@ -44,7 +44,6 @@ contract CrossChainRelayerPolygon is ICrossChainRelayer, FxBaseRootTunnel { /// @inheritdoc ICrossChainRelayer function relayCalls(CallLib.Call[] calldata _calls, uint256 _gasLimit) external - payable returns (uint256) { uint256 _maxGasLimit = maxGasLimit; diff --git a/src/interfaces/ICrossChainRelayer.sol b/src/interfaces/ICrossChainRelayer.sol index a29769b..bb5056a 100644 --- a/src/interfaces/ICrossChainRelayer.sol +++ b/src/interfaces/ICrossChainRelayer.sol @@ -7,6 +7,7 @@ import "../libraries/CallLib.sol"; /** * @title CrossChainRelayer interface * @notice CrossChainRelayer interface of the ERC-5164 standard as defined in the EIP. + * @dev Use `ICrossChainRelayerPayable` if the bridge you want to integrate requires a payment in the native currency. */ interface ICrossChainRelayer { /** @@ -35,13 +36,9 @@ interface ICrossChainRelayer { * @notice Relay the calls to the receiving chain. * @dev Must increment a `nonce` so that the batch of calls can be uniquely identified. * @dev Must emit the `RelayedCalls` event when successfully called. - * @dev May require payment. Some bridges may require payment in the native currency, so the function is payable. * @param calls Array of calls being relayed * @param gasLimit Maximum amount of gas required for the `calls` to be executed * @return uint256 Nonce to uniquely idenfity the batch of calls */ - function relayCalls(CallLib.Call[] calldata calls, uint256 gasLimit) - external - payable - returns (uint256); + function relayCalls(CallLib.Call[] calldata calls, uint256 gasLimit) external returns (uint256); } diff --git a/src/interfaces/ICrossChainRelayerPayable.sol b/src/interfaces/ICrossChainRelayerPayable.sol new file mode 100644 index 0000000..83d7a96 --- /dev/null +++ b/src/interfaces/ICrossChainRelayerPayable.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity 0.8.16; + +import "../libraries/CallLib.sol"; + +/** + * @title CrossChainRelayer interface + * @notice CrossChainRelayer interface of the ERC-5164 standard as defined in the EIP. + */ +interface ICrossChainRelayerPayable { + /** + * @notice Custom error emitted if the `gasLimit` passed to `relayCalls` + * is greater than the one provided for free on the receiving chain. + * @param gasLimit Gas limit passed to `relayCalls` + * @param maxGasLimit Gas limit provided for free on the receiving chain + */ + error GasLimitTooHigh(uint256 gasLimit, uint256 maxGasLimit); + + /** + * @notice Emitted when calls have successfully been relayed to the executor chain. + * @param nonce Nonce to uniquely idenfity the batch of calls + * @param sender Address of the sender + * @param calls Array of calls being relayed + * @param gasLimit Maximum amount of gas required for the `calls` to be executed + */ + event RelayedCalls( + uint256 indexed nonce, + address indexed sender, + CallLib.Call[] calls, + uint256 gasLimit + ); + + /** + * @notice Relay the calls to the receiving chain. + * @dev Must increment a `nonce` so that the batch of calls can be uniquely identified. + * @dev Must emit the `RelayedCalls` event when successfully called. + * @dev May require payment. Some bridges requires payment in the native currency, so the function is payable. + * @param calls Array of calls being relayed + * @param gasLimit Maximum amount of gas required for the `calls` to be executed + * @return uint256 Nonce to uniquely idenfity the batch of calls + */ + function relayCalls(CallLib.Call[] calldata calls, uint256 gasLimit) + external + payable + returns (uint256); +}