@@ -88,6 +88,19 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
88
88
// check that the voucher is signed by the payer (or proxy)
89
89
_requireAuthorizedRCASigner (signedRCA);
90
90
91
+ require (
92
+ signedRCA.rca.dataService != address (0 ) &&
93
+ signedRCA.rca.payer != address (0 ) &&
94
+ signedRCA.rca.serviceProvider != address (0 ),
95
+ RecurringCollectorAgreementAddressNotSet ()
96
+ );
97
+
98
+ _requireValidCollectionWindowParams (
99
+ signedRCA.rca.endsAt,
100
+ signedRCA.rca.minSecondsPerCollection,
101
+ signedRCA.rca.maxSecondsPerCollection
102
+ );
103
+
91
104
AgreementData storage agreement = _getAgreementStorage (signedRCA.rca.agreementId);
92
105
// check that the agreement is not already accepted
93
106
require (
@@ -106,7 +119,6 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
106
119
agreement.maxOngoingTokensPerSecond = signedRCA.rca.maxOngoingTokensPerSecond;
107
120
agreement.minSecondsPerCollection = signedRCA.rca.minSecondsPerCollection;
108
121
agreement.maxSecondsPerCollection = signedRCA.rca.maxSecondsPerCollection;
109
- _requireValidAgreement (agreement);
110
122
111
123
emit AgreementAccepted (
112
124
agreement.dataService,
@@ -178,13 +190,18 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
178
190
// check that the voucher is signed by the payer (or proxy)
179
191
_requireAuthorizedRCAUSigner (signedRCAU, agreement.payer);
180
192
193
+ _requireValidCollectionWindowParams (
194
+ signedRCAU.rcau.endsAt,
195
+ signedRCAU.rcau.minSecondsPerCollection,
196
+ signedRCAU.rcau.maxSecondsPerCollection
197
+ );
198
+
181
199
// update the agreement
182
200
agreement.endsAt = signedRCAU.rcau.endsAt;
183
201
agreement.maxInitialTokens = signedRCAU.rcau.maxInitialTokens;
184
202
agreement.maxOngoingTokensPerSecond = signedRCAU.rcau.maxOngoingTokensPerSecond;
185
203
agreement.minSecondsPerCollection = signedRCAU.rcau.minSecondsPerCollection;
186
204
agreement.maxSecondsPerCollection = signedRCAU.rcau.maxSecondsPerCollection;
187
- _requireValidAgreement (agreement);
188
205
189
206
emit AgreementUpdated (
190
207
agreement.dataService,
@@ -306,38 +323,31 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
306
323
return tokensToCollect;
307
324
}
308
325
309
- function _requireValidAgreement (AgreementData memory _agreement ) private view {
310
- require (
311
- _agreement.dataService != address (0 ) &&
312
- _agreement.payer != address (0 ) &&
313
- _agreement.serviceProvider != address (0 ),
314
- RecurringCollectorAgreementAddressNotSet ()
315
- );
316
-
326
+ function _requireValidCollectionWindowParams (
327
+ uint64 _endsAt ,
328
+ uint32 _minSecondsPerCollection ,
329
+ uint32 _maxSecondsPerCollection
330
+ ) private view {
317
331
// Agreement needs to end in the future
318
- require (
319
- _agreement.endsAt > block .timestamp ,
320
- RecurringCollectorAgreementElapsedEndsAt (block .timestamp , _agreement.endsAt)
321
- );
332
+ require (_endsAt > block .timestamp , RecurringCollectorAgreementElapsedEndsAt (block .timestamp , _endsAt));
322
333
323
334
// Collection window needs to be at least MIN_SECONDS_COLLECTION_WINDOW
324
335
require (
325
- _agreement.maxSecondsPerCollection > _agreement.minSecondsPerCollection &&
326
- (_agreement.maxSecondsPerCollection - _agreement.minSecondsPerCollection >=
327
- MIN_SECONDS_COLLECTION_WINDOW),
336
+ _maxSecondsPerCollection > _minSecondsPerCollection &&
337
+ (_maxSecondsPerCollection - _minSecondsPerCollection >= MIN_SECONDS_COLLECTION_WINDOW),
328
338
RecurringCollectorAgreementInvalidCollectionWindow (
329
339
MIN_SECONDS_COLLECTION_WINDOW,
330
- _agreement.minSecondsPerCollection ,
331
- _agreement.maxSecondsPerCollection
340
+ _minSecondsPerCollection ,
341
+ _maxSecondsPerCollection
332
342
)
333
343
);
334
344
335
345
// Agreement needs to last at least one min collection window
336
346
require (
337
- _agreement.endsAt - block .timestamp >= _agreement.minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
347
+ _endsAt - block .timestamp >= _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
338
348
RecurringCollectorAgreementInvalidDuration (
339
- _agreement.minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
340
- _agreement.endsAt - block .timestamp
349
+ _minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
350
+ _endsAt - block .timestamp
341
351
)
342
352
);
343
353
}
0 commit comments