@@ -8,31 +8,42 @@ import "../../bridge/arbitrum/L1Bridge.sol";
88import "../IHomeGateway.sol " ;
99import "../IForeignGateway.sol " ;
1010
11- contract EthereumGateway is IForeignGateway {
11+ import "../IForeignEvidence.sol " ;
12+
13+ contract EthereumGateway is IForeignGateway , IForeignEvidence {
1214 // L1 bridge with the HomeGateway as the l2target
1315 L1Bridge internal l1bridge;
14- uint256 localDisputeID;
15- uint256 chainID;
16+ uint256 internal localDisputeID;
1617
1718 // For now this is just a constant, but we'd probably need to
1819 // implement the same arbitrationCost calculation code we'll have
1920 // in the V2 court.
2021 uint256 internal internalArbitrationCost;
2122
22- struct Dispute {
23+ struct DisputeData {
2324 uint256 id;
2425 address arbitrable;
2526 }
26- mapping (bytes32 => Dispute) disputeHashtoDisputeData;
27+ mapping (uint256 => bytes32 ) public disputeIDtoHash;
28+ mapping (bytes32 => DisputeData) public disputeHashtoDisputeData;
29+
30+ IHomeGateway public homeGateway;
31+ uint256 public chainID;
2732
2833 modifier onlyFromL2 () {
2934 l1bridge.onlyAuthorized (msg .sender );
3035 _;
3136 }
3237
33- constructor (uint256 _arbitrationCost , L1Bridge _l1bridge ) {
38+ constructor (
39+ uint256 _arbitrationCost ,
40+ L1Bridge _l1bridge ,
41+ IHomeGateway _homeGateway
42+ ) {
3443 internalArbitrationCost = _arbitrationCost;
3544 l1bridge = _l1bridge;
45+ homeGateway = _homeGateway;
46+
3647 uint256 id;
3748 assembly {
3849 id := chainid ()
@@ -54,7 +65,8 @@ contract EthereumGateway is IForeignGateway {
5465 _extraData
5566 )
5667 );
57- disputeHashtoDisputeData[disputeHash] = Dispute ({id: disputeID, arbitrable: msg .sender });
68+ disputeIDtoHash[disputeID] = disputeHash;
69+ disputeHashtoDisputeData[disputeHash] = DisputeData ({id: disputeID, arbitrable: msg .sender });
5870
5971 bytes4 methodSelector = IHomeGateway.relayCreateDispute.selector ;
6072 bytes memory data = abi.encodeWithSelector (methodSelector, disputeHash, _choices, _extraData);
@@ -94,9 +106,28 @@ contract EthereumGateway is IForeignGateway {
94106 * Relay the rule call from the home gateway to the arbitrable.
95107 */
96108 function relayRule (bytes32 _disputeHash , uint256 _ruling ) external onlyFromL2 {
97- Dispute memory dispute = disputeHashtoDisputeData[_disputeHash];
109+ DisputeData memory dispute = disputeHashtoDisputeData[_disputeHash];
98110
99111 IArbitrable arbitrable = IArbitrable (dispute.arbitrable);
100112 arbitrable.rule (dispute.id, _ruling);
101113 }
114+
115+ function foreignDisputeHashToID (bytes32 _disputeHash ) external view returns (uint256 ) {
116+ return disputeHashtoDisputeData[_disputeHash].id;
117+ }
118+
119+ function disputeID (uint256 _foreignDisputeID ) external view returns (uint256 ) {
120+ bytes32 disputeHash = disputeIDtoHash[_foreignDisputeID];
121+ require (disputeHash != 0 , "Dispute does not exist " );
122+
123+ return homeGateway.homeDisputeHashToID (disputeHash);
124+ }
125+
126+ function homeChainID (uint256 _disputeID ) external view returns (uint256 ) {
127+ return homeGateway.chainID ();
128+ }
129+
130+ function homeBridge (uint256 _disputeID ) external view returns (address ) {
131+ return address (homeGateway);
132+ }
102133}
0 commit comments