@@ -13,16 +13,16 @@ import { PPMMath } from "../../libraries/PPMMath.sol";
13
13
/**
14
14
* @title RecurringCollector contract
15
15
* @dev Implements the {IRecurringCollector} interface.
16
- * @notice A payments collector contract that can be used to collect payments using a RCV (Recurrent Collection Voucher ).
16
+ * @notice A payments collector contract that can be used to collect payments using a RCA (Recurring Collection Agreement ).
17
17
* @custom:security-contact Please email [email protected] if you find any
18
18
* bugs. We may have an active bug bounty program.
19
19
*/
20
20
contract RecurringCollector is EIP712 , GraphDirectory , Authorizable , IRecurringCollector {
21
21
using PPMMath for uint256 ;
22
22
23
- /// @notice The EIP712 typehash for the RecurrentCollectionVoucher struct
24
- bytes32 private constant EIP712_RCV_TYPEHASH =
25
- keccak256 ("RecurrentCollectionVoucher (address dataService,address serviceProvider,bytes metadata) " );
23
+ /// @notice The EIP712 typehash for the RecurringCollectionAgreement struct
24
+ bytes32 private constant EIP712_RCA_TYPEHASH =
25
+ keccak256 ("RecurringCollectionAgreement (address dataService,address serviceProvider,bytes metadata) " );
26
26
27
27
/// @notice Sentinel value to indicate an agreement has been canceled
28
28
uint256 private constant CANCELED = type (uint256 ).max;
@@ -57,7 +57,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
57
57
/**
58
58
* @notice Initiate a payment collection through the payments protocol.
59
59
* See {IGraphPayments.collect}.
60
- * @dev Caller must be the data service the RCV was issued to.
60
+ * @dev Caller must be the data service the RCA was issued to.
61
61
*/
62
62
function collect (IGraphPayments.PaymentTypes paymentType , bytes calldata data ) external returns (uint256 ) {
63
63
require (
@@ -74,10 +74,10 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
74
74
/**
75
75
* @notice Accept an indexing agreement.
76
76
* See {IRecurringCollector.accept}.
77
- * @dev Caller must be the data service the RCV was issued to.
77
+ * @dev Caller must be the data service the RCA was issued to.
78
78
*/
79
- function accept (SignedRCV memory signedRCV ) external onlyDataService (signedRCV.rcv .dataService) {
80
- _accept (signedRCV );
79
+ function accept (SignedRCA memory signedRCA ) external onlyDataService (signedRCA.rca .dataService) {
80
+ _accept (signedRCA );
81
81
}
82
82
83
83
/**
@@ -92,26 +92,26 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
92
92
/**
93
93
* @notice Upgrade an indexing agreement.
94
94
* See {IRecurringCollector.upgrade}.
95
- * @dev Caller must be the data service the RCV was issued to.
95
+ * @dev Caller must be the data service the RCA was issued to.
96
96
*/
97
97
function upgrade (
98
98
bytes16 oldAgreementId ,
99
- SignedRCV memory signedRCV
100
- ) external onlyDataService (signedRCV.rcv .dataService) {
101
- _cancel (signedRCV.rcv .dataService, signedRCV.rcv .payer, signedRCV.rcv .serviceProvider, oldAgreementId);
102
- _accept (signedRCV );
99
+ SignedRCA memory signedRCA
100
+ ) external onlyDataService (signedRCA.rca .dataService) {
101
+ _cancel (signedRCA.rca .dataService, signedRCA.rca .payer, signedRCA.rca .serviceProvider, oldAgreementId);
102
+ _accept (signedRCA );
103
103
AgreementKey memory oldKey = AgreementKey ({
104
- dataService: signedRCV.rcv .dataService,
105
- payer: signedRCV.rcv .payer,
106
- serviceProvider: signedRCV.rcv .serviceProvider,
104
+ dataService: signedRCA.rca .dataService,
105
+ payer: signedRCA.rca .payer,
106
+ serviceProvider: signedRCA.rca .serviceProvider,
107
107
agreementId: oldAgreementId
108
108
});
109
109
AgreementData memory oldAgreement = _getAgreement (oldKey);
110
110
AgreementKey memory key = AgreementKey ({
111
- dataService: signedRCV.rcv .dataService,
112
- payer: signedRCV.rcv .payer,
113
- serviceProvider: signedRCV.rcv .serviceProvider,
114
- agreementId: signedRCV.rcv .agreementId
111
+ dataService: signedRCA.rca .dataService,
112
+ payer: signedRCA.rca .payer,
113
+ serviceProvider: signedRCA.rca .serviceProvider,
114
+ agreementId: signedRCA.rca .agreementId
115
115
});
116
116
AgreementData storage agreement = _getForUpdateAgreement (key);
117
117
agreement.acceptedAt = oldAgreement.acceptedAt;
@@ -120,17 +120,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
120
120
}
121
121
122
122
/**
123
- * @notice See {IRecurringCollector.recoverRCVSigner }
123
+ * @notice See {IRecurringCollector.recoverRCASigner }
124
124
*/
125
- function recoverRCVSigner (SignedRCV calldata signedRCV ) external view returns (address ) {
126
- return _recoverRCVSigner (signedRCV );
125
+ function recoverRCASigner (SignedRCA calldata signedRCA ) external view returns (address ) {
126
+ return _recoverRCASigner (signedRCA );
127
127
}
128
128
129
129
/**
130
- * @notice See {IRecurringCollector.encodeRCV }
130
+ * @notice See {IRecurringCollector.encodeRCA }
131
131
*/
132
- function encodeRCV (RecurrentCollectionVoucher calldata rcv ) external view returns (bytes32 ) {
133
- return _encodeRCV (rcv );
132
+ function encodeRCA (RecurringCollectionAgreement calldata rca ) external view returns (bytes32 ) {
133
+ return _encodeRCA (rca );
134
134
}
135
135
136
136
/**
@@ -142,9 +142,9 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
142
142
143
143
/**
144
144
* @notice Collect payment through the payments protocol.
145
- * @dev Caller must be the data service the RCV was issued to.
145
+ * @dev Caller must be the data service the RCA was issued to.
146
146
*
147
- * Emits {PaymentCollected} and {RCVCollected } events.
147
+ * Emits {PaymentCollected} and {RCACollected } events.
148
148
*
149
149
* @param _params The decoded parameters for the collection
150
150
* @return The amount of tokens collected
@@ -170,7 +170,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
170
170
_params.tokens
171
171
);
172
172
173
- emit RCVCollected (
173
+ emit RCACollected (
174
174
_params.key.dataService,
175
175
_params.key.payer,
176
176
_params.key.serviceProvider,
@@ -185,20 +185,20 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
185
185
/**
186
186
* @notice See {IRecurringCollector.accept}
187
187
*/
188
- function _accept (SignedRCV memory _signedRCV ) private {
188
+ function _accept (SignedRCA memory _signedRCA ) private {
189
189
require (
190
- _signedRCV.rcv .acceptDeadline >= block .timestamp ,
191
- RecurringCollectorAgreementAcceptanceElapsed (_signedRCV.rcv .acceptDeadline)
190
+ _signedRCA.rca .acceptDeadline >= block .timestamp ,
191
+ RecurringCollectorAgreementAcceptanceElapsed (_signedRCA.rca .acceptDeadline)
192
192
);
193
193
194
194
// check that the voucher is signed by the payer (or proxy)
195
- _requireAuthorizedRCVSigner (_signedRCV );
195
+ _requireAuthorizedRCASigner (_signedRCA );
196
196
197
197
AgreementKey memory key = AgreementKey ({
198
- dataService: _signedRCV.rcv .dataService,
199
- payer: _signedRCV.rcv .payer,
200
- serviceProvider: _signedRCV.rcv .serviceProvider,
201
- agreementId: _signedRCV.rcv .agreementId
198
+ dataService: _signedRCA.rca .dataService,
199
+ payer: _signedRCA.rca .payer,
200
+ serviceProvider: _signedRCA.rca .serviceProvider,
201
+ agreementId: _signedRCA.rca .agreementId
202
202
});
203
203
AgreementData storage agreement = _getForUpdateAgreement (key);
204
204
// check that the agreement is not already accepted
@@ -207,11 +207,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
207
207
// accept the agreement
208
208
agreement.acceptedAt = block .timestamp ;
209
209
// FIX-ME: These need to be validated to something that makes sense for the contract
210
- agreement.duration = _signedRCV.rcv .duration;
211
- agreement.maxInitialTokens = _signedRCV.rcv .maxInitialTokens;
212
- agreement.maxOngoingTokensPerSecond = _signedRCV.rcv .maxOngoingTokensPerSecond;
213
- agreement.minSecondsPerCollection = _signedRCV.rcv .minSecondsPerCollection;
214
- agreement.maxSecondsPerCollection = _signedRCV.rcv .maxSecondsPerCollection;
210
+ agreement.duration = _signedRCA.rca .duration;
211
+ agreement.maxInitialTokens = _signedRCA.rca .maxInitialTokens;
212
+ agreement.maxOngoingTokensPerSecond = _signedRCA.rca .maxOngoingTokensPerSecond;
213
+ agreement.minSecondsPerCollection = _signedRCA.rca .minSecondsPerCollection;
214
+ agreement.maxSecondsPerCollection = _signedRCA.rca .maxSecondsPerCollection;
215
215
}
216
216
217
217
/**
@@ -265,32 +265,32 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
265
265
}
266
266
267
267
/**
268
- * @notice See {IRecurringCollector.recoverRCVSigner }
268
+ * @notice See {IRecurringCollector.recoverRCASigner }
269
269
*/
270
- function _recoverRCVSigner (SignedRCV memory _signedRCV ) private view returns (address ) {
271
- bytes32 messageHash = _encodeRCV (_signedRCV.rcv );
272
- return ECDSA.recover (messageHash, _signedRCV .signature);
270
+ function _recoverRCASigner (SignedRCA memory _signedRCA ) private view returns (address ) {
271
+ bytes32 messageHash = _encodeRCA (_signedRCA.rca );
272
+ return ECDSA.recover (messageHash, _signedRCA .signature);
273
273
}
274
274
275
275
/**
276
- * @notice See {IRecurringCollector.encodeRCV }
276
+ * @notice See {IRecurringCollector.encodeRCA }
277
277
*/
278
- function _encodeRCV (RecurrentCollectionVoucher memory _rcv ) private view returns (bytes32 ) {
278
+ function _encodeRCA (RecurringCollectionAgreement memory _rca ) private view returns (bytes32 ) {
279
279
return
280
280
_hashTypedDataV4 (
281
281
keccak256 (
282
- abi.encode (EIP712_RCV_TYPEHASH, _rcv .dataService, _rcv .serviceProvider, keccak256 (_rcv .metadata))
282
+ abi.encode (EIP712_RCA_TYPEHASH, _rca .dataService, _rca .serviceProvider, keccak256 (_rca .metadata))
283
283
)
284
284
);
285
285
}
286
286
287
287
/**
288
- * @notice Requires that the signer for the RCV is authorized
289
- * by the payer of the RCV .
288
+ * @notice Requires that the signer for the RCA is authorized
289
+ * by the payer of the RCA .
290
290
*/
291
- function _requireAuthorizedRCVSigner (SignedRCV memory _signedRCV ) private view returns (address ) {
292
- address signer = _recoverRCVSigner (_signedRCV );
293
- require (_isAuthorized (_signedRCV.rcv .payer, signer), RecurringCollectorInvalidRCVSigner ());
291
+ function _requireAuthorizedRCASigner (SignedRCA memory _signedRCA ) private view returns (address ) {
292
+ address signer = _recoverRCASigner (_signedRCA );
293
+ require (_isAuthorized (_signedRCA.rca .payer, signer), RecurringCollectorInvalidRCASigner ());
294
294
295
295
return signer;
296
296
}
0 commit comments