@@ -49,17 +49,16 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
49
49
// ************************************* //
50
50
51
51
modifier onlyFromVea (address _messageSender ) {
52
- require (
53
- veaOutbox == msg .sender ||
54
- (block .timestamp < deprecatedVeaOutboxExpiration && deprecatedVeaOutbox == msg .sender ),
55
- "Access not allowed: Vea Outbox only. "
56
- );
57
- require (_messageSender == homeGateway, "Access not allowed: HomeGateway only. " );
52
+ if (
53
+ veaOutbox != msg .sender &&
54
+ (block .timestamp >= deprecatedVeaOutboxExpiration || deprecatedVeaOutbox != msg .sender )
55
+ ) revert VeaOutboxOnly ();
56
+ if (_messageSender != homeGateway) revert HomeGatewayMessageSenderOnly ();
58
57
_;
59
58
}
60
59
61
60
modifier onlyByGovernor () {
62
- require (governor == msg .sender , " Access not allowed: Governor only. " );
61
+ if (governor != msg .sender ) revert GovernorOnly ( );
63
62
_;
64
63
}
65
64
@@ -105,7 +104,7 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
105
104
/// @dev Changes the governor.
106
105
/// @param _governor The address of the new governor.
107
106
function changeGovernor (address _governor ) external {
108
- require (governor == msg .sender , " Access not allowed: Governor only. " );
107
+ if (governor != msg .sender ) revert GovernorOnly ( );
109
108
governor = _governor;
110
109
}
111
110
@@ -122,7 +121,7 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
122
121
/// @dev Changes the home gateway.
123
122
/// @param _homeGateway The address of the new home gateway.
124
123
function changeHomeGateway (address _homeGateway ) external {
125
- require (governor == msg .sender , " Access not allowed: Governor only. " );
124
+ if (governor != msg .sender ) revert GovernorOnly ( );
126
125
homeGateway = _homeGateway;
127
126
}
128
127
@@ -143,7 +142,7 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
143
142
uint256 _choices ,
144
143
bytes calldata _extraData
145
144
) external payable override returns (uint256 disputeID ) {
146
- require (msg .value >= arbitrationCost (_extraData), " Not paid enough for arbitration " );
145
+ if (msg .value < arbitrationCost (_extraData)) revert ArbitrationFeesNotEnough ( );
147
146
148
147
disputeID = localDisputeID++ ;
149
148
uint256 chainID;
@@ -206,8 +205,8 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
206
205
) external override onlyFromVea (_messageSender) {
207
206
DisputeData storage dispute = disputeHashtoDisputeData[_disputeHash];
208
207
209
- require (dispute.id != 0 , " Dispute does not exist " );
210
- require ( ! dispute.ruled, " Cannot rule twice " );
208
+ if (dispute.id == 0 ) revert DisputeDoesNotExist ( );
209
+ if ( dispute.ruled) revert CannotRuleTwice ( );
211
210
212
211
dispute.ruled = true ;
213
212
dispute.relayer = _relayer;
@@ -219,8 +218,8 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
219
218
/// @inheritdoc IForeignGateway
220
219
function withdrawFees (bytes32 _disputeHash ) external override {
221
220
DisputeData storage dispute = disputeHashtoDisputeData[_disputeHash];
222
- require (dispute.id != 0 , " Dispute does not exist " );
223
- require ( dispute.ruled, " Not ruled yet " );
221
+ if (dispute.id == 0 ) revert DisputeDoesNotExist ( );
222
+ if ( ! dispute.ruled) revert NotRuledYet ( );
224
223
225
224
uint256 amount = dispute.paid;
226
225
dispute.paid = 0 ;
@@ -247,9 +246,9 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
247
246
revert ("Not supported " );
248
247
}
249
248
250
- // ************************ //
251
- // * Internal * //
252
- // ************************ //
249
+ // ************************************* //
250
+ // * Internal * //
251
+ // ************************************* //
253
252
254
253
function extraDataToCourtIDMinJurors (
255
254
bytes memory _extraData
@@ -268,4 +267,16 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable {
268
267
minJurors = DEFAULT_NB_OF_JURORS;
269
268
}
270
269
}
270
+
271
+ // ************************************* //
272
+ // * Errors * //
273
+ // ************************************* //
274
+
275
+ error GovernorOnly ();
276
+ error HomeGatewayMessageSenderOnly ();
277
+ error VeaOutboxOnly ();
278
+ error ArbitrationFeesNotEnough ();
279
+ error DisputeDoesNotExist ();
280
+ error CannotRuleTwice ();
281
+ error NotRuledYet ();
271
282
}
0 commit comments