Skip to content

Commit 2f0542b

Browse files
committed
refactor(gateway): add {Home,Foreign}Gateway interfaces
1 parent c964c68 commit 2f0542b

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
import "../arbitration/IArbitrator.sol";
6+
7+
interface IForeignGateway is IArbitrator {
8+
/**
9+
* Relay the rule call from the home gateway to the arbitrable.
10+
*
11+
* @param _data The calldata to relay
12+
*/
13+
function relayRule(bytes memory _data) external;
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
import "../arbitration/IArbitrable.sol";
6+
7+
interface IHomeGateway is IArbitrable {
8+
/**
9+
* Relay the createDispute call from the foreign gateway to the arbitrator.
10+
*
11+
* @param _data The calldata to relay
12+
*/
13+
function relayCreateDispute(bytes memory _data) external;
14+
}

contracts/src/gateway/arbitrum/HomeGateway.sol renamed to contracts/src/gateway/arbitrum/ArbitrumGateway.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
pragma solidity ^0.8.0;
44

5-
import "../../arbitration/IArbitrable.sol";
65
import "../../arbitration/IArbitrator.sol";
76
import "../../bridge/arbitrum/L2Bridge.sol";
87

9-
import "./ForeignGateway.sol";
8+
import "../IHomeGateway.sol";
9+
import "../IForeignGateway.sol";
1010

11-
contract HomeGateway is IArbitrable {
11+
contract ArbitrumGateway is IHomeGateway {
1212
// L2 bridge with the ForeignGateway as the l1target
1313
L2Bridge internal l2bridge;
1414
address public arbitrator;
@@ -21,7 +21,7 @@ contract HomeGateway is IArbitrable {
2121
function rule(uint256, uint256) external {
2222
require(msg.sender == arbitrator, "Only Arbitrator");
2323

24-
bytes4 methodSelector = ForeignGateway.relayRule.selector;
24+
bytes4 methodSelector = IForeignGateway.relayRule.selector;
2525
bytes memory data = abi.encodeWithSelector(methodSelector, msg.data);
2626

2727
l2bridge.sendCrossDomainMessage(data);

contracts/src/gateway/arbitrum/ForeignGateway.sol renamed to contracts/src/gateway/arbitrum/EthereumGateway.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
pragma solidity ^0.8.0;
44

55
import "../../arbitration/IArbitrable.sol";
6-
import "../../arbitration/IArbitrator.sol";
76
import "../../bridge/arbitrum/L1Bridge.sol";
87

9-
import "./HomeGateway.sol";
8+
import "../IHomeGateway.sol";
9+
import "../IForeignGateway.sol";
1010

11-
contract ForeignGateway is IArbitrator {
11+
contract EthereumGateway is IForeignGateway {
1212
// L1 bridge with the HomeGateway as the l2target
1313
L1Bridge internal l1bridge;
1414

@@ -25,7 +25,7 @@ contract ForeignGateway is IArbitrator {
2525
function createDispute(uint256 _choices, bytes calldata _extraData) external payable returns (uint256 disputeID) {
2626
require(msg.value >= arbitrationCost(_extraData), "Not paid enough for arbitration");
2727

28-
bytes4 methodSelector = HomeGateway.relayCreateDispute.selector;
28+
bytes4 methodSelector = IHomeGateway.relayCreateDispute.selector;
2929
bytes memory data = abi.encodeWithSelector(methodSelector, msg.data);
3030

3131
uint256 bridgeCost = l1bridge.getSubmissionPrice(data.length);
@@ -43,9 +43,9 @@ contract ForeignGateway is IArbitrator {
4343
// only the calldata.
4444
l1bridge.sendCrossDomainMessage{value: bridgeCost}(data, 0, 0);
4545

46-
disputeId = 0; // TODO: map to the actual disputeID we get from the V2 court
47-
emit DisputeCreation(disputeId, IArbitrable(msg.sender));
48-
return disputeId;
46+
disputeID = 0; // TODO: map to the actual disputeID we get from the V2 court
47+
emit DisputeCreation(disputeID, IArbitrable(msg.sender));
48+
return disputeID;
4949
}
5050

5151
function arbitrationCost(bytes calldata _extraData) public view returns (uint256 cost) {

0 commit comments

Comments
 (0)