Skip to content

Commit 876709b

Browse files
f: more natSpec
1 parent 5857ca4 commit 876709b

File tree

6 files changed

+68
-14
lines changed

6 files changed

+68
-14
lines changed

packages/horizon/contracts/interfaces/IRecurringCollector.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import { IAuthorizable } from "./IAuthorizable.sol";
1313
* recurrent payments.
1414
*/
1515
interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
16+
// @notice The state of an agreement
1617
enum AgreementState {
1718
NotAccepted,
1819
Accepted,
1920
CanceledByServiceProvider,
2021
CanceledByPayer
2122
}
2223

24+
// @notice The party that can cancel an agreement
2325
enum CancelAgreementBy {
2426
ServiceProvider,
2527
Payer
@@ -69,6 +71,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
6971
bytes signature;
7072
}
7173

74+
/// @notice The Recurring Collection Agreement Update (RCAU)
7275
struct RecurringCollectionAgreementUpdate {
7376
// The agreement ID
7477
bytes16 agreementId;
@@ -206,6 +209,10 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
206209
* @param dataService The address of the data service
207210
* @param payer The address of the payer
208211
* @param serviceProvider The address of the service provider
212+
* @param agreementId The agreement ID
213+
* @param collectionId The collection ID
214+
* @param tokens The amount of tokens collected
215+
* @param dataServiceCut The tokens cut for the data service
209216
*/
210217
event RCACollected(
211218
address indexed dataService,
@@ -276,6 +283,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
276283

277284
/**
278285
* Thrown when accepting or upgrading an agreement with invalid parameters
286+
* @param message A descriptive error message
279287
*/
280288
error RecurringCollectorAgreementInvalidParameters(string message);
281289

@@ -317,6 +325,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
317325

318326
/**
319327
* @dev Update an indexing agreement.
328+
* @param signedRCAU The signed Recurring Collection Agreement Update which is to be applied.
320329
*/
321330
function update(SignedRCAU calldata signedRCAU) external;
322331

@@ -350,6 +359,8 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
350359

351360
/**
352361
* @notice Gets an agreement.
362+
* @param agreementId The ID of the agreement to retrieve.
363+
* @return The AgreementData struct containing the agreement's data.
353364
*/
354365
function getAgreement(bytes16 agreementId) external view returns (AgreementData memory);
355366
}

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ contract SubgraphService is
420420

421421
/**
422422
* @notice Accept an indexing agreement.
423-
* See {ISubgraphService.acceptIndexingAgreement}.
423+
* See {ISubgraphServiceExtended.acceptIndexingAgreement}.
424424
*
425425
* Requirements:
426426
* - The agreement's indexer must be registered

packages/subgraph-service/contracts/SubgraphServiceExtension.sol

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ import { ISubgraphServiceExtension } from "./interfaces/ISubgraphServiceExtensio
1313
contract SubgraphServiceExtension is PausableUpgradeable, ISubgraphServiceExtension {
1414
using IndexingAgreement for IndexingAgreement.Manager;
1515

16+
/**
17+
* @notice Checks that an indexer is valid
18+
* @param indexer The address of the indexer
19+
*
20+
* Requirements:
21+
* - The caller must be authorized by the indexer
22+
* - The provision must be valid according to the subgraph service rules
23+
* - The indexer must be registered
24+
*
25+
*/
1626
modifier onlyValid(address indexer) {
1727
ProvisionManagerLib.requireAuthorizedForProvision(
1828
IHorizonStaking(_getBase().getGraphStaking()),
@@ -25,6 +35,17 @@ contract SubgraphServiceExtension is PausableUpgradeable, ISubgraphServiceExtens
2535
_;
2636
}
2737

38+
/**
39+
* @notice Update an indexing agreement.
40+
* See {IndexingAgreement.update}.
41+
*
42+
* Requirements:
43+
* - The contract must not be paused
44+
* - The indexer must be valid
45+
*
46+
* @param indexer The indexer address
47+
* @param signedRCAU The signed Recurring Collection Agreement Update
48+
*/
2849
function updateIndexingAgreement(
2950
address indexer,
3051
IRecurringCollector.SignedRCAU calldata signedRCAU
@@ -34,18 +55,15 @@ contract SubgraphServiceExtension is PausableUpgradeable, ISubgraphServiceExtens
3455

3556
/**
3657
* @notice Cancel an indexing agreement by indexer / operator.
37-
* See {ISubgraphService.cancelIndexingAgreement}.
58+
* See {IndexingAgreement.cancel}.
3859
*
3960
* @dev Can only be canceled on behalf of a valid indexer.
4061
*
4162
* Requirements:
42-
* - The indexer must be registered
43-
* - The caller must be authorized by the indexer
44-
* - The provision must be valid according to the subgraph service rules
45-
* - The agreement must be active
46-
*
47-
* Emits {IndexingAgreementCanceled} event
63+
* - The contract must not be paused
64+
* - The indexer must be valid
4865
*
66+
* @param indexer The indexer address
4967
* @param agreementId The id of the agreement
5068
*/
5169
function cancelIndexingAgreement(address indexer, bytes16 agreementId) external whenNotPaused onlyValid(indexer) {

packages/subgraph-service/contracts/interfaces/ISubgraphService.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ interface ISubgraphService is IDataServiceFees {
261261

262262
/**
263263
* @notice Accept an indexing agreement.
264-
* @dev Emits a {IndexingAgreement.IndexingAgreementAccepted} event
265264
* @param allocationId The id of the allocation
266265
* @param signedRCA The signed recurring collector agreement (RCA) that the indexer accepts
267266
*/

packages/subgraph-service/contracts/interfaces/ISubgraphServiceExtension.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces
66
import { IndexingAgreement } from "../libraries/IndexingAgreement.sol";
77

88
interface ISubgraphServiceExtension {
9-
/**
10-
* @notice Accept an indexing agreement.
11-
*/
12-
// function acceptIndexingAgreement(address allocationId, IRecurringCollector.SignedRCA calldata signedRCA) external;
13-
149
/**
1510
* @notice Update an indexing agreement.
1611
*/
@@ -26,6 +21,9 @@ interface ISubgraphServiceExtension {
2621
*/
2722
function cancelIndexingAgreementByPayer(bytes16 agreementId) external;
2823

24+
/**
25+
* @notice Get the indexing agreement for a given agreement ID.
26+
*/
2927
function getIndexingAgreement(
3028
bytes16 agreementId
3129
) external view returns (IndexingAgreement.AgreementWrapper memory);

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,21 @@ library IndexingAgreement {
273273
_directory().recurringCollector().accept(signedRCA);
274274
}
275275

276+
/**
277+
* @notice Update an indexing agreement.
278+
*
279+
* Requirements:
280+
* - Agreement must be active
281+
* - The indexer must be the service provider of the agreement
282+
*
283+
* @dev signedRCA.rcau.metadata is an encoding of {IndexingAgreement.UpdateIndexingAgreementMetadata}
284+
*
285+
* Emits {IndexingAgreementUpdated} event
286+
*
287+
* @param self The indexing agreement manager storage
288+
* @param indexer The indexer address
289+
* @param signedRCAU The signed Recurring Collection Agreement Update
290+
*/
276291
function update(
277292
Manager storage self,
278293
address indexer,
@@ -304,6 +319,19 @@ library IndexingAgreement {
304319
_directory().recurringCollector().update(signedRCAU);
305320
}
306321

322+
/**
323+
* @notice Cancel an indexing agreement.
324+
*
325+
* Requirements:
326+
* - Agreement must be active
327+
* - The indexer must be the service provider of the agreement
328+
*
329+
* Emits {IndexingAgreementCanceled} event
330+
*
331+
* @param self The indexing agreement manager storage
332+
* @param indexer The indexer address
333+
* @param agreementId The id of the agreement to cancel
334+
*/
307335
function cancel(Manager storage self, address indexer, bytes16 agreementId) external {
308336
AgreementWrapper memory wrapper = _get(self, agreementId);
309337
require(_isActive(wrapper), IndexingAgreementNotActive(agreementId));

0 commit comments

Comments
 (0)