Skip to content

Commit a2eba38

Browse files
f: rename RCV
1 parent d0a4db2 commit a2eba38

File tree

12 files changed

+386
-386
lines changed

12 files changed

+386
-386
lines changed

packages/horizon/contracts/interfaces/IRecurringCollector.sol

+28-28
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ import { IAuthorizable } from "./IAuthorizable.sol";
1313
* recurrent payments.
1414
*/
1515
interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
16-
/// @notice A representation of a signed Recurrent Collection Voucher (RCV)
17-
struct SignedRCV {
18-
// The RCV
19-
RecurrentCollectionVoucher rcv;
16+
/// @notice A representation of a signed Recurring Collection Agreement (RCA)
17+
struct SignedRCA {
18+
// The RCA
19+
RecurringCollectionAgreement rca;
2020
// Signature - 65 bytes: r (32 Bytes) || s (32 Bytes) || v (1 Byte)
2121
bytes signature;
2222
}
2323

24-
/// @notice The Recurrent Collection Voucher (RCV)
25-
struct RecurrentCollectionVoucher {
26-
// The agreement ID of the RCV
24+
/// @notice The Recurring Collection Agreement (RCA)
25+
struct RecurringCollectionAgreement {
26+
// The agreement ID of the RCA
2727
bytes16 agreementId;
28-
// The deadline for accepting the RCV
28+
// The deadline for accepting the RCA
2929
uint256 acceptDeadline;
30-
// The duration of the RCV in seconds
30+
// The duration of the RCA in seconds
3131
uint256 duration;
32-
// The address of the payer the RCV was issued by
32+
// The address of the payer the RCA was issued by
3333
address payer;
34-
// The address of the data service the RCV was issued to
34+
// The address of the data service the RCA was issued to
3535
address dataService;
36-
// The address of the service provider the RCV was issued to
36+
// The address of the service provider the RCA was issued to
3737
address serviceProvider;
3838
// The maximum amount of tokens that can be collected in the first collection
3939
// on top of the amount allowed for subsequent collections
@@ -96,12 +96,12 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
9696
}
9797

9898
/**
99-
* @notice Emitted when an RCV is collected
99+
* @notice Emitted when an RCA is collected
100100
* @param dataService The address of the data service
101101
* @param payer The address of the payer
102102
* @param serviceProvider The address of the service provider
103103
*/
104-
event RCVCollected(
104+
event RCACollected(
105105
address indexed dataService,
106106
address indexed payer,
107107
address indexed serviceProvider,
@@ -117,9 +117,9 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
117117
error RecurringCollectorAgreementAcceptanceElapsed(uint256 elapsedAt);
118118

119119
/**
120-
* Thrown when the RCV signer is invalid
120+
* Thrown when the RCA signer is invalid
121121
*/
122-
error RecurringCollectorInvalidRCVSigner();
122+
error RecurringCollectorInvalidRCASigner();
123123

124124
/**
125125
* Thrown when the payment type is not IndexingFee
@@ -128,7 +128,7 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
128128
error RecurringCollectorInvalidPaymentType(IGraphPayments.PaymentTypes paymentType);
129129

130130
/**
131-
* Thrown when the caller is not the data service the RCV was issued to
131+
* Thrown when the caller is not the data service the RCA was issued to
132132
* @param caller The address of the caller
133133
* @param dataService The address of the data service
134134
*/
@@ -192,9 +192,9 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
192192

193193
/**
194194
* @dev Accept an indexing agreement.
195-
* @param signedRCV The signed Recurrent Collection Voucher which is to be accepted.
195+
* @param signedRCA The signed Recurring Collection Agreement which is to be accepted.
196196
*/
197-
function accept(SignedRCV memory signedRCV) external;
197+
function accept(SignedRCA memory signedRCA) external;
198198

199199
/**
200200
* @dev Cancel an indexing agreement.
@@ -207,21 +207,21 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
207207
/**
208208
* @dev Upgrade an indexing agreement.
209209
* @param oldAgreementId The agreement ID of the old agreement.
210-
* @param signedRCV The signed Recurrent Collection Voucher of the new agreement.
210+
* @param signedRCA The signed Recurring Collection Agreement of the new agreement.
211211
*/
212-
function upgrade(bytes16 oldAgreementId, SignedRCV memory signedRCV) external;
212+
function upgrade(bytes16 oldAgreementId, SignedRCA memory signedRCA) external;
213213

214214
/**
215-
* @dev Computes the hash of a RecurrentCollectionVoucher (RCV).
216-
* @param rcv The RCV for which to compute the hash.
217-
* @return The hash of the RCV.
215+
* @dev Computes the hash of a RecurringCollectionAgreement (RCA).
216+
* @param rca The RCA for which to compute the hash.
217+
* @return The hash of the RCA.
218218
*/
219-
function encodeRCV(RecurrentCollectionVoucher calldata rcv) external view returns (bytes32);
219+
function encodeRCA(RecurringCollectionAgreement calldata rca) external view returns (bytes32);
220220

221221
/**
222-
* @dev Recovers the signer address of a signed RecurrentCollectionVoucher (RCV).
223-
* @param signedRCV The SignedRCV containing the RCV and its signature.
222+
* @dev Recovers the signer address of a signed RecurringCollectionAgreement (RCA).
223+
* @param signedRCA The SignedRCA containing the RCA and its signature.
224224
* @return The address of the signer.
225225
*/
226-
function recoverRCVSigner(SignedRCV calldata signedRCV) external view returns (address);
226+
function recoverRCASigner(SignedRCA calldata signedRCA) external view returns (address);
227227
}

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

+54-54
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import { PPMMath } from "../../libraries/PPMMath.sol";
1313
/**
1414
* @title RecurringCollector contract
1515
* @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).
1717
* @custom:security-contact Please email [email protected] if you find any
1818
* bugs. We may have an active bug bounty program.
1919
*/
2020
contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringCollector {
2121
using PPMMath for uint256;
2222

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)");
2626

2727
/// @notice Sentinel value to indicate an agreement has been canceled
2828
uint256 private constant CANCELED = type(uint256).max;
@@ -57,7 +57,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
5757
/**
5858
* @notice Initiate a payment collection through the payments protocol.
5959
* 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.
6161
*/
6262
function collect(IGraphPayments.PaymentTypes paymentType, bytes calldata data) external returns (uint256) {
6363
require(
@@ -74,10 +74,10 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
7474
/**
7575
* @notice Accept an indexing agreement.
7676
* 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.
7878
*/
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);
8181
}
8282

8383
/**
@@ -92,26 +92,26 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
9292
/**
9393
* @notice Upgrade an indexing agreement.
9494
* 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.
9696
*/
9797
function upgrade(
9898
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);
103103
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,
107107
agreementId: oldAgreementId
108108
});
109109
AgreementData memory oldAgreement = _getAgreement(oldKey);
110110
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
115115
});
116116
AgreementData storage agreement = _getForUpdateAgreement(key);
117117
agreement.acceptedAt = oldAgreement.acceptedAt;
@@ -120,17 +120,17 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
120120
}
121121

122122
/**
123-
* @notice See {IRecurringCollector.recoverRCVSigner}
123+
* @notice See {IRecurringCollector.recoverRCASigner}
124124
*/
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);
127127
}
128128

129129
/**
130-
* @notice See {IRecurringCollector.encodeRCV}
130+
* @notice See {IRecurringCollector.encodeRCA}
131131
*/
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);
134134
}
135135

136136
/**
@@ -142,9 +142,9 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
142142

143143
/**
144144
* @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.
146146
*
147-
* Emits {PaymentCollected} and {RCVCollected} events.
147+
* Emits {PaymentCollected} and {RCACollected} events.
148148
*
149149
* @param _params The decoded parameters for the collection
150150
* @return The amount of tokens collected
@@ -170,7 +170,7 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
170170
_params.tokens
171171
);
172172

173-
emit RCVCollected(
173+
emit RCACollected(
174174
_params.key.dataService,
175175
_params.key.payer,
176176
_params.key.serviceProvider,
@@ -185,20 +185,20 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
185185
/**
186186
* @notice See {IRecurringCollector.accept}
187187
*/
188-
function _accept(SignedRCV memory _signedRCV) private {
188+
function _accept(SignedRCA memory _signedRCA) private {
189189
require(
190-
_signedRCV.rcv.acceptDeadline >= block.timestamp,
191-
RecurringCollectorAgreementAcceptanceElapsed(_signedRCV.rcv.acceptDeadline)
190+
_signedRCA.rca.acceptDeadline >= block.timestamp,
191+
RecurringCollectorAgreementAcceptanceElapsed(_signedRCA.rca.acceptDeadline)
192192
);
193193

194194
// check that the voucher is signed by the payer (or proxy)
195-
_requireAuthorizedRCVSigner(_signedRCV);
195+
_requireAuthorizedRCASigner(_signedRCA);
196196

197197
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
202202
});
203203
AgreementData storage agreement = _getForUpdateAgreement(key);
204204
// check that the agreement is not already accepted
@@ -207,11 +207,11 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
207207
// accept the agreement
208208
agreement.acceptedAt = block.timestamp;
209209
// 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;
215215
}
216216

217217
/**
@@ -265,32 +265,32 @@ contract RecurringCollector is EIP712, GraphDirectory, Authorizable, IRecurringC
265265
}
266266

267267
/**
268-
* @notice See {IRecurringCollector.recoverRCVSigner}
268+
* @notice See {IRecurringCollector.recoverRCASigner}
269269
*/
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);
273273
}
274274

275275
/**
276-
* @notice See {IRecurringCollector.encodeRCV}
276+
* @notice See {IRecurringCollector.encodeRCA}
277277
*/
278-
function _encodeRCV(RecurrentCollectionVoucher memory _rcv) private view returns (bytes32) {
278+
function _encodeRCA(RecurringCollectionAgreement memory _rca) private view returns (bytes32) {
279279
return
280280
_hashTypedDataV4(
281281
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))
283283
)
284284
);
285285
}
286286

287287
/**
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.
290290
*/
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());
294294

295295
return signer;
296296
}

0 commit comments

Comments
 (0)