@@ -62,7 +62,7 @@ contract PaymentsGatewayTest is Test {
62
62
63
63
function setUp () public {
64
64
owner = payable (vm.addr (1 ));
65
- operator = payable (vm.addr (0x0000000000000000000000000000000000000000000000000000000000000002 ));
65
+ operator = payable (vm.addr (2 ));
66
66
sender = payable (vm.addr (3 ));
67
67
receiver = payable (vm.addr (4 ));
68
68
client = payable (vm.addr (5 ));
@@ -98,7 +98,7 @@ contract PaymentsGatewayTest is Test {
98
98
// EIP712
99
99
typehashPayoutInfo = keccak256 ("PayoutInfo(bytes32 clientId,address payoutAddress,uint256 feeBPS) " );
100
100
typehashPayRequest = keccak256 (
101
- "PayRequest(bytes32 clientId,bytes32 transactionId,address tokenAddress,uint256 tokenAmount,PayoutInfo[] payouts,address forwardAddress,bytes data)PayoutInfo(bytes32 clientId,address payoutAddress,uint256 feeBPS) "
101
+ "PayRequest(bytes32 clientId,bytes32 transactionId,address tokenAddress,uint256 tokenAmount,uint256 expirationTimestamp, PayoutInfo[] payouts,address forwardAddress,bytes data)PayoutInfo(bytes32 clientId,address payoutAddress,uint256 feeBPS) "
102
102
);
103
103
nameHash = keccak256 (bytes ("PaymentsGateway " ));
104
104
versionHash = keccak256 (bytes ("1 " ));
@@ -125,10 +125,10 @@ contract PaymentsGatewayTest is Test {
125
125
function _hashPayoutInfo (PaymentsGateway.PayoutInfo[] memory _payouts ) private view returns (bytes32 ) {
126
126
bytes32 payoutHash = typehashPayoutInfo;
127
127
128
- bytes32 [] memory payoutsHashes = new bytes32 [](payouts .length );
128
+ bytes32 [] memory payoutsHashes = new bytes32 [](_payouts .length );
129
129
for (uint i = 0 ; i < payouts.length ; i++ ) {
130
130
payoutsHashes[i] = keccak256 (
131
- abi.encode (payoutHash, payouts [i].clientId, payouts [i].payoutAddress, payouts [i].feeBPS)
131
+ abi.encode (payoutHash, _payouts [i].clientId, _payouts [i].payoutAddress, _payouts [i].feeBPS)
132
132
);
133
133
}
134
134
return keccak256 (abi.encodePacked (payoutsHashes));
@@ -147,6 +147,7 @@ contract PaymentsGatewayTest is Test {
147
147
req.transactionId,
148
148
req.tokenAddress,
149
149
req.tokenAmount,
150
+ req.expirationTimestamp,
150
151
_payoutsHash,
151
152
req.forwardAddress,
152
153
keccak256 (req.data)
@@ -184,12 +185,13 @@ contract PaymentsGatewayTest is Test {
184
185
req.tokenAddress = address (mockERC20);
185
186
req.tokenAmount = sendValue;
186
187
req.forwardAddress = payable (address (mockTarget));
188
+ req.expirationTimestamp = 1000 ;
187
189
req.data = targetCalldata;
188
190
req.payouts = payouts;
189
191
190
192
// generate signature
191
193
bytes memory _signature = _prepareAndSignData (
192
- 0x0000000000000000000000000000000000000000000000000000000000000002 , // sign with operator private key, i.e. 2
194
+ 2 , // sign with operator private key, i.e. 2
193
195
req
194
196
);
195
197
@@ -224,6 +226,7 @@ contract PaymentsGatewayTest is Test {
224
226
req.tokenAddress = address (0 );
225
227
req.tokenAmount = sendValue;
226
228
req.forwardAddress = payable (address (mockTarget));
229
+ req.expirationTimestamp = 1000 ;
227
230
req.data = targetCalldata;
228
231
req.payouts = payouts;
229
232
@@ -235,7 +238,7 @@ contract PaymentsGatewayTest is Test {
235
238
236
239
// generate signature
237
240
bytes memory _signature = _prepareAndSignData (
238
- 0x0000000000000000000000000000000000000000000000000000000000000002 , // sign with operator private key, i.e. 2
241
+ 2 , // sign with operator private key, i.e. 2
239
242
req
240
243
);
241
244
@@ -277,12 +280,13 @@ contract PaymentsGatewayTest is Test {
277
280
req.tokenAddress = address (mockERC20);
278
281
req.tokenAmount = sendValue;
279
282
req.forwardAddress = payable (address (mockTarget));
283
+ req.expirationTimestamp = 1000 ;
280
284
req.data = targetCalldata;
281
285
req.payouts = payouts;
282
286
283
287
// generate signature
284
288
bytes memory _signature = _prepareAndSignData (
285
- 0x0000000000000000000000000000000000000000000000000000000000000002 , // sign with operator private key, i.e. 2
289
+ 2 , // sign with operator private key, i.e. 2
286
290
req
287
291
);
288
292
@@ -311,6 +315,7 @@ contract PaymentsGatewayTest is Test {
311
315
req.tokenAddress = address (mockERC20);
312
316
req.tokenAmount = sendValue;
313
317
req.forwardAddress = payable (address (mockTarget));
318
+ req.expirationTimestamp = 1000 ;
314
319
req.data = targetCalldata;
315
320
req.payouts = payouts;
316
321
@@ -326,6 +331,35 @@ contract PaymentsGatewayTest is Test {
326
331
gateway.startTransfer (req, _signature);
327
332
}
328
333
334
+ function test_revert_startTransfer_requestExpired () public {
335
+ uint256 sendValue = 1 ether ;
336
+ bytes memory targetCalldata = "" ;
337
+
338
+ // create pay request
339
+ PaymentsGateway.PayRequest memory req;
340
+ bytes32 _transactionId = keccak256 ("transaction ID " );
341
+
342
+ req.clientId = clientId;
343
+ req.transactionId = _transactionId;
344
+ req.tokenAddress = address (mockERC20);
345
+ req.tokenAmount = sendValue;
346
+ req.forwardAddress = payable (address (mockTarget));
347
+ req.expirationTimestamp = 1000 ;
348
+ req.data = targetCalldata;
349
+ req.payouts = payouts;
350
+
351
+ // generate signature
352
+ bytes memory _signature = _prepareAndSignData (2 , req);
353
+
354
+ vm.warp (req.expirationTimestamp + 1 );
355
+ // send transaction
356
+ vm.prank (sender);
357
+ vm.expectRevert (
358
+ abi.encodeWithSelector (PaymentsGateway.PaymentsGatewayRequestExpired.selector , req.expirationTimestamp)
359
+ );
360
+ gateway.startTransfer (req, _signature);
361
+ }
362
+
329
363
// /*///////////////////////////////////////////////////////////////
330
364
// Test `endTransfer`
331
365
// //////////////////////////////////////////////////////////////*/
0 commit comments