Skip to content

Commit 19a4270

Browse files
f: remove RecurringCollectorAgreementInvalidParameters
1 parent 03ed657 commit 19a4270

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

packages/horizon/contracts/interfaces/IRecurringCollector.sol

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,35 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
282282
error RecurringCollectorAgreementIncorrectState(bytes16 agreementId, AgreementState incorrectState);
283283

284284
/**
285-
* Thrown when accepting or upgrading an agreement with invalid parameters
286-
* @param message A descriptive error message
285+
* Thrown when accepting an agreement with an address that is not set
287286
*/
288-
error RecurringCollectorAgreementInvalidParameters(string message);
287+
error RecurringCollectorAgreementAddressNotSet();
288+
289+
/**
290+
* Thrown when accepting or upgrading an agreement with an elapsed endsAt
291+
* @param currentTimestamp The current timestamp
292+
* @param endsAt The agreement end timestamp
293+
*/
294+
error RecurringCollectorAgreementElapsedEndsAt(uint256 currentTimestamp, uint64 endsAt);
295+
296+
/**
297+
* Thrown when accepting or upgrading an agreement with an elapsed endsAt
298+
* @param allowedMinCollectionWindow The allowed minimum collection window
299+
* @param minSecondsPerCollection The minimum seconds per collection
300+
* @param maxSecondsPerCollection The maximum seconds per collection
301+
*/
302+
error RecurringCollectorAgreementInvalidCollectionWindow(
303+
uint32 allowedMinCollectionWindow,
304+
uint32 minSecondsPerCollection,
305+
uint32 maxSecondsPerCollection
306+
);
307+
308+
/**
309+
* Thrown when accepting or upgrading an agreement with an invalid duration
310+
* @param requiredMinDuration The required minimum duration
311+
* @param invalidDuration The invalid duration
312+
*/
313+
error RecurringCollectorAgreementInvalidDuration(uint32 requiredMinDuration, uint256 invalidDuration);
289314

290315
/**
291316
* Thrown when calling collect() on an elapsed agreement

packages/horizon/contracts/payments/collectors/RecurringCollector.sol

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,27 +311,34 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
311311
_agreement.dataService != address(0) &&
312312
_agreement.payer != address(0) &&
313313
_agreement.serviceProvider != address(0),
314-
RecurringCollectorAgreementInvalidParameters("zero address")
314+
RecurringCollectorAgreementAddressNotSet()
315315
);
316316

317317
// Agreement needs to end in the future
318318
require(
319319
_agreement.endsAt > block.timestamp,
320-
RecurringCollectorAgreementInvalidParameters("endsAt not in future")
320+
RecurringCollectorAgreementElapsedEndsAt(block.timestamp, _agreement.endsAt)
321321
);
322322

323323
// Collection window needs to be at least MIN_SECONDS_COLLECTION_WINDOW
324324
require(
325325
_agreement.maxSecondsPerCollection > _agreement.minSecondsPerCollection &&
326326
(_agreement.maxSecondsPerCollection - _agreement.minSecondsPerCollection >=
327327
MIN_SECONDS_COLLECTION_WINDOW),
328-
RecurringCollectorAgreementInvalidParameters("too small collection window")
328+
RecurringCollectorAgreementInvalidCollectionWindow(
329+
MIN_SECONDS_COLLECTION_WINDOW,
330+
_agreement.minSecondsPerCollection,
331+
_agreement.maxSecondsPerCollection
332+
)
329333
);
330334

331335
// Agreement needs to last at least one min collection window
332336
require(
333337
_agreement.endsAt - block.timestamp >= _agreement.minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
334-
RecurringCollectorAgreementInvalidParameters("too small agreement window")
338+
RecurringCollectorAgreementInvalidDuration(
339+
_agreement.minSecondsPerCollection + MIN_SECONDS_COLLECTION_WINDOW,
340+
_agreement.endsAt - block.timestamp
341+
)
335342
);
336343
}
337344

0 commit comments

Comments
 (0)