Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Fast Bridge #36

Merged
merged 9 commits into from
Feb 8, 2022
17 changes: 11 additions & 6 deletions contracts/src/bridge/FastBridgeSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,36 @@ import "./interfaces/IFastBridgeSender.sol";
import "./interfaces/IFastBridgeReceiver.sol";

contract FastBridgeSender is IFastBridgeSender {
ISafeBridge safebridge;
IFastBridgeReceiver fastBridgeReceiver;
ISafeBridge public safebridge;
IFastBridgeReceiver public fastBridgeReceiver;
address public fastSender;

/**
* The bridgers need to watch for these events and
* relay the messageHash on the FastBridgeReceiver.
*/
event OutboxMessage(address target, bytes32 messageHash, bytes messagePreImage);

constructor(ISafeBridge _safebridge, IFastBridgeReceiver _fastBridgeReceiver) {
constructor(
ISafeBridge _safebridge,
IFastBridgeReceiver _fastBridgeReceiver,
address _fastSender
) {
safebridge = _safebridge;
fastBridgeReceiver = _fastBridgeReceiver;
fastSender = _fastSender;
}

/**
* Sends an arbitrary message from one domain to another
* via the fast bridge mechanism
*
* TODO: probably needs some access control either on the sender side
* or the receiver side
*
* @param _receiver The L1 contract address who will receive the calldata
* @param _calldata The receiving domain encoded message data.
*/
function sendFast(address _receiver, bytes memory _calldata) external {
require(msg.sender == fastSender, "Access not allowed: Fast Sender only.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't add this initially was to make the fast bridge app-agnostic.


// Encode the receiver address with the function signature + arguments i.e calldata
bytes memory encodedData = abi.encode(_receiver, _calldata);

Expand Down