Skip to content

Commit eb81d79

Browse files
f: add CancelAgreementBy.ThirdParty
1 parent 1857e15 commit eb81d79

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

packages/horizon/contracts/interfaces/IRecurringCollector.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
2424
// @notice The party that can cancel an agreement
2525
enum CancelAgreementBy {
2626
ServiceProvider,
27-
Payer
27+
Payer,
28+
ThirdParty
2829
}
2930

3031
/// @notice A representation of a signed Recurring Collection Agreement (RCA)

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ contract SubgraphService is
235235
_allocations.get(allocationId).indexer == indexer,
236236
SubgraphServiceAllocationNotAuthorized(indexer, allocationId)
237237
);
238-
_cancelAllocationIndexingAgreement(allocationId);
238+
_cancelAllocationIndexingAgreement(allocationId, IRecurringCollector.CancelAgreementBy.ServiceProvider);
239239
_closeAllocation(allocationId, false);
240240
emit ServiceStopped(indexer, data);
241241
}
@@ -319,7 +319,7 @@ contract SubgraphService is
319319
Allocation.State memory allocation = _allocations.get(allocationId);
320320
require(allocation.isStale(maxPOIStaleness), SubgraphServiceCannotForceCloseAllocation(allocationId));
321321
require(!allocation.isAltruistic(), SubgraphServiceAllocationIsAltruistic(allocationId));
322-
_cancelAllocationIndexingAgreement(allocationId);
322+
_cancelAllocationIndexingAgreement(allocationId, IRecurringCollector.CancelAgreementBy.ThirdParty);
323323
_closeAllocation(allocationId, true);
324324
}
325325

@@ -553,8 +553,11 @@ contract SubgraphService is
553553
return address(_graphStaking());
554554
}
555555

556-
function _cancelAllocationIndexingAgreement(address _allocationId) internal {
557-
IndexingAgreement._getStorageManager().cancelForAllocation(_allocationId);
556+
function _cancelAllocationIndexingAgreement(
557+
address _allocationId,
558+
IRecurringCollector.CancelAgreementBy _by
559+
) internal {
560+
IndexingAgreement._getStorageManager().cancelForAllocation(_allocationId, _by);
558561
}
559562

560563
/**

packages/subgraph-service/contracts/libraries/IndexingAgreement.sol

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ library IndexingAgreement {
350350
);
351351
}
352352

353-
function cancelForAllocation(StorageManager storage self, address _allocationId) external {
353+
function cancelForAllocation(
354+
StorageManager storage self,
355+
address _allocationId,
356+
IRecurringCollector.CancelAgreementBy by
357+
) external {
354358
bytes16 agreementId = self.allocationToActiveAgreementId[_allocationId];
355359
if (agreementId == bytes16(0)) {
356360
return;
@@ -361,13 +365,7 @@ library IndexingAgreement {
361365
return;
362366
}
363367

364-
_cancel(
365-
self,
366-
agreementId,
367-
wrapper.agreement,
368-
wrapper.collectorAgreement,
369-
IRecurringCollector.CancelAgreementBy.ServiceProvider
370-
);
368+
_cancel(self, agreementId, wrapper.agreement, wrapper.collectorAgreement, by);
371369
}
372370

373371
function cancelByPayer(StorageManager storage self, bytes16 agreementId) external {

0 commit comments

Comments
 (0)