diff --git a/solidity/contracts/bridges/OptimismReceiverAdapter.sol b/solidity/contracts/bridges/OptimismReceiverAdapter.sol index 577505e..e2035bb 100644 --- a/solidity/contracts/bridges/OptimismReceiverAdapter.sol +++ b/solidity/contracts/bridges/OptimismReceiverAdapter.sol @@ -7,12 +7,17 @@ import {ICrossDomainMessenger} from '../../interfaces/bridges/ICrossDomainMessen import {IOracleSidechain} from '../../interfaces/IOracleSidechain.sol'; contract OptimismReceiverAdapter is BridgeReceiverAdapter { + ICrossDomainMessenger public immutable messenger; + address public immutable source; + constructor( IDataReceiver _dataReceiver, - address _source, - uint32 _originDomain + address _messenger, + address _source ) BridgeReceiverAdapter(_dataReceiver) { - if (false) revert ZeroAddress(); + if (_messenger == address(0) || _source == address(0)) revert ZeroAddress(); + messenger = ICrossDomainMessenger(_messenger); + source = _source; } function addObservations( @@ -24,7 +29,7 @@ contract OptimismReceiverAdapter is BridgeReceiverAdapter { } modifier onlyExecutor() { - // if (msg.sender != address(connext) || _originSender != source || _originDomain != originDomain) revert UnauthorizedCaller(); + if (msg.sender != address(messenger) || messenger.xDomainMessageSender() != source) revert UnauthorizedCaller(); _; } } diff --git a/solidity/interfaces/bridges/IBridgeReceiverAdapter.sol b/solidity/interfaces/bridges/IBridgeReceiverAdapter.sol index d1c4f5a..9823a92 100644 --- a/solidity/interfaces/bridges/IBridgeReceiverAdapter.sol +++ b/solidity/interfaces/bridges/IBridgeReceiverAdapter.sol @@ -13,4 +13,9 @@ interface IBridgeReceiverAdapter is IBaseErrors { function dataReceiver() external view returns (IDataReceiver _dataReceiver); /* NOTE: callback methods should be here declared */ + + // ERRORS + + /// @notice Thrown if a caller is not authorized + error UnauthorizedCaller(); } diff --git a/solidity/interfaces/bridges/IConnextReceiverAdapter.sol b/solidity/interfaces/bridges/IConnextReceiverAdapter.sol index 0717f33..7a40fd1 100644 --- a/solidity/interfaces/bridges/IConnextReceiverAdapter.sol +++ b/solidity/interfaces/bridges/IConnextReceiverAdapter.sol @@ -12,16 +12,11 @@ interface IConnextReceiverAdapter is IXReceiver, IBridgeReceiverAdapter { /// @return _connext Address of the ConnextHandler contract function connext() external view returns (IConnext _connext); - /// @notice Gets the DAO that is expected as the xcaller + /// @notice Gets the contract address that is expected as the xcaller /// @return _originContract Address of the xcaller contract function source() external view returns (address _originContract); /// @notice Gets the origin domain id /// @return _originDomain The origin domain id function originDomain() external view returns (uint32 _originDomain); - - // ERRORS - - /// @notice Thrown if a caller is not authorized - error UnauthorizedCaller(); }