Skip to content

Commit

Permalink
feat: improving abstractions and populating op amb adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Aug 20, 2024
1 parent 9a2f7fc commit 4a4807a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 9 additions & 4 deletions solidity/contracts/bridges/OptimismReceiverAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();
_;
}
}
5 changes: 5 additions & 0 deletions solidity/interfaces/bridges/IBridgeReceiverAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
7 changes: 1 addition & 6 deletions solidity/interfaces/bridges/IConnextReceiverAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 4a4807a

Please sign in to comment.