2
2
pragma solidity 0.8.27 ;
3
3
4
4
import { IGraphPayments } from "../../interfaces/IGraphPayments.sol " ;
5
- import { ITAPCollector } from "../../interfaces/ITAPCollector .sol " ;
5
+ import { IGraphTallyCollector } from "../../interfaces/IGraphTallyCollector .sol " ;
6
6
7
7
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol " ;
8
8
import { PPMMath } from "../../libraries/PPMMath.sol " ;
@@ -12,9 +12,9 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
12
12
import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol " ;
13
13
14
14
/**
15
- * @title TAPCollector contract
16
- * @dev Implements the {ITAPCollector } and {IPaymentCollector} interfaces.
17
- * @notice A payments collector contract that can be used to collect payments using a TAP RAV (Receipt Aggregate Voucher).
15
+ * @title GraphTallyCollector contract
16
+ * @dev Implements the {IGraphTallyCollector } and {IPaymentCollector} interfaces.
17
+ * @notice A payments collector contract that can be used to collect payments using a GraphTally RAV (Receipt Aggregate Voucher).
18
18
* @dev Note that the contract expects the RAV aggregate value to be monotonically increasing, each successive RAV for the same
19
19
* (data service-payer-receiver) tuple should have a value greater than the previous one. The contract will keep track of the tokens
20
20
* already collected and calculate the difference to collect.
@@ -23,7 +23,7 @@ import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/Mes
23
23
* @custom:security-contact Please email [email protected] if you find any
24
24
* bugs. We may have an active bug bounty program.
25
25
*/
26
- contract TAPCollector is EIP712 , GraphDirectory , ITAPCollector {
26
+ contract GraphTallyCollector is EIP712 , GraphDirectory , IGraphTallyCollector {
27
27
using PPMMath for uint256 ;
28
28
29
29
/// @notice The EIP712 typehash for the ReceiptAggregateVoucher struct
@@ -45,7 +45,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
45
45
uint256 public immutable REVOKE_SIGNER_THAWING_PERIOD;
46
46
47
47
/**
48
- * @notice Constructs a new instance of the TAPVerifier contract.
48
+ * @notice Constructs a new instance of the GraphTallyCollector contract.
49
49
* @param eip712Name The name of the EIP712 domain.
50
50
* @param eip712Version The version of the EIP712 domain.
51
51
* @param controller The address of the Graph controller.
@@ -61,12 +61,12 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
61
61
}
62
62
63
63
/**
64
- * See {ITAPCollector .authorizeSigner}.
64
+ * See {IGraphTallyCollector .authorizeSigner}.
65
65
*/
66
66
function authorizeSigner (address signer , uint256 proofDeadline , bytes calldata proof ) external override {
67
67
require (
68
68
authorizedSigners[signer].payer == address (0 ),
69
- TAPCollectorSignerAlreadyAuthorized (authorizedSigners[signer].payer, signer)
69
+ GraphTallyCollectorSignerAlreadyAuthorized (authorizedSigners[signer].payer, signer)
70
70
);
71
71
72
72
_verifyAuthorizedSignerProof (proof, proofDeadline, signer);
@@ -77,46 +77,46 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
77
77
}
78
78
79
79
/**
80
- * See {ITAPCollector .thawSigner}.
80
+ * See {IGraphTallyCollector .thawSigner}.
81
81
*/
82
82
function thawSigner (address signer ) external override {
83
83
PayerAuthorization storage authorization = authorizedSigners[signer];
84
84
85
- require (authorization.payer == msg .sender , TAPCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
86
- require (! authorization.revoked, TAPCollectorAuthorizationAlreadyRevoked (msg .sender , signer));
85
+ require (authorization.payer == msg .sender , GraphTallyCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
86
+ require (! authorization.revoked, GraphTallyCollectorAuthorizationAlreadyRevoked (msg .sender , signer));
87
87
require (
88
88
authorization.thawEndTimestamp == 0 ,
89
- TAPCollectorSignerAlreadyThawing (signer, authorization.thawEndTimestamp)
89
+ GraphTallyCollectorSignerAlreadyThawing (signer, authorization.thawEndTimestamp)
90
90
);
91
91
92
92
authorization.thawEndTimestamp = block .timestamp + REVOKE_SIGNER_THAWING_PERIOD;
93
93
emit SignerThawing (msg .sender , signer, authorization.thawEndTimestamp);
94
94
}
95
95
96
96
/**
97
- * See {ITAPCollector .cancelThawSigner}.
97
+ * See {IGraphTallyCollector .cancelThawSigner}.
98
98
*/
99
99
function cancelThawSigner (address signer ) external override {
100
100
PayerAuthorization storage authorization = authorizedSigners[signer];
101
101
102
- require (authorization.payer == msg .sender , TAPCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
103
- require (authorization.thawEndTimestamp > 0 , TAPCollectorSignerNotThawing (signer));
102
+ require (authorization.payer == msg .sender , GraphTallyCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
103
+ require (authorization.thawEndTimestamp > 0 , GraphTallyCollectorSignerNotThawing (signer));
104
104
105
105
authorization.thawEndTimestamp = 0 ;
106
106
emit SignerThawCanceled (msg .sender , signer, 0 );
107
107
}
108
108
109
109
/**
110
- * See {ITAPCollector .revokeAuthorizedSigner}.
110
+ * See {IGraphTallyCollector .revokeAuthorizedSigner}.
111
111
*/
112
112
function revokeAuthorizedSigner (address signer ) external override {
113
113
PayerAuthorization storage authorization = authorizedSigners[signer];
114
114
115
- require (authorization.payer == msg .sender , TAPCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
116
- require (authorization.thawEndTimestamp > 0 , TAPCollectorSignerNotThawing (signer));
115
+ require (authorization.payer == msg .sender , GraphTallyCollectorSignerNotAuthorizedByPayer (msg .sender , signer));
116
+ require (authorization.thawEndTimestamp > 0 , GraphTallyCollectorSignerNotThawing (signer));
117
117
require (
118
118
authorization.thawEndTimestamp <= block .timestamp ,
119
- TAPCollectorSignerStillThawing (block .timestamp , authorization.thawEndTimestamp)
119
+ GraphTallyCollectorSignerStillThawing (block .timestamp , authorization.thawEndTimestamp)
120
120
);
121
121
122
122
authorization.revoked = true ;
@@ -145,21 +145,21 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
145
145
}
146
146
147
147
/**
148
- * @notice See {ITAPCollector .recoverRAVSigner}
148
+ * @notice See {IGraphTallyCollector .recoverRAVSigner}
149
149
*/
150
150
function recoverRAVSigner (SignedRAV calldata signedRAV ) external view override returns (address ) {
151
151
return _recoverRAVSigner (signedRAV);
152
152
}
153
153
154
154
/**
155
- * @notice See {ITAPCollector .encodeRAV}
155
+ * @notice See {IGraphTallyCollector .encodeRAV}
156
156
*/
157
157
function encodeRAV (ReceiptAggregateVoucher calldata rav ) external view returns (bytes32 ) {
158
158
return _encodeRAV (rav);
159
159
}
160
160
161
161
/**
162
- * @notice See {ITAPCollector .collect}
162
+ * @notice See {IGraphTallyCollector .collect}
163
163
*/
164
164
function _collect (
165
165
IGraphPayments.PaymentTypes _paymentType ,
@@ -171,19 +171,19 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
171
171
// Ensure caller is the RAV data service
172
172
require (
173
173
signedRAV.rav.dataService == msg .sender ,
174
- TAPCollectorCallerNotDataService (msg .sender , signedRAV.rav.dataService)
174
+ GraphTallyCollectorCallerNotDataService (msg .sender , signedRAV.rav.dataService)
175
175
);
176
176
177
177
// Ensure RAV signer is authorized for a payer
178
178
address signer = _recoverRAVSigner (signedRAV);
179
179
require (
180
180
authorizedSigners[signer].payer != address (0 ) && ! authorizedSigners[signer].revoked,
181
- TAPCollectorInvalidRAVSigner ()
181
+ GraphTallyCollectorInvalidRAVSigner ()
182
182
);
183
183
184
184
// Ensure RAV payer matches the authorized payer
185
185
address payer = authorizedSigners[signer].payer;
186
- require (signedRAV.rav.payer == payer, TAPCollectorInvalidRAVPayer (payer, signedRAV.rav.payer));
186
+ require (signedRAV.rav.payer == payer, GraphTallyCollectorInvalidRAVPayer (payer, signedRAV.rav.payer));
187
187
188
188
bytes32 collectionId = signedRAV.rav.collectionId;
189
189
address dataService = signedRAV.rav.dataService;
@@ -197,7 +197,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
197
197
signedRAV.rav.serviceProvider,
198
198
signedRAV.rav.dataService
199
199
);
200
- require (tokensAvailable > 0 , TAPCollectorUnauthorizedDataService (signedRAV.rav.dataService));
200
+ require (tokensAvailable > 0 , GraphTallyCollectorUnauthorizedDataService (signedRAV.rav.dataService));
201
201
}
202
202
203
203
uint256 tokensToCollect = 0 ;
@@ -206,15 +206,18 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
206
206
uint256 tokensAlreadyCollected = tokensCollected[dataService][collectionId][receiver][payer];
207
207
require (
208
208
tokensRAV > tokensAlreadyCollected,
209
- TAPCollectorInconsistentRAVTokens (tokensRAV, tokensAlreadyCollected)
209
+ GraphTallyCollectorInconsistentRAVTokens (tokensRAV, tokensAlreadyCollected)
210
210
);
211
211
212
212
if (_tokensToCollect == 0 ) {
213
213
tokensToCollect = tokensRAV - tokensAlreadyCollected;
214
214
} else {
215
215
require (
216
216
_tokensToCollect <= tokensRAV - tokensAlreadyCollected,
217
- TAPCollectorInvalidTokensToCollectAmount (_tokensToCollect, tokensRAV - tokensAlreadyCollected)
217
+ GraphTallyCollectorInvalidTokensToCollectAmount (
218
+ _tokensToCollect,
219
+ tokensRAV - tokensAlreadyCollected
220
+ )
218
221
);
219
222
tokensToCollect = _tokensToCollect;
220
223
}
@@ -243,15 +246,15 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
243
246
}
244
247
245
248
/**
246
- * @notice See {ITAPCollector .recoverRAVSigner}
249
+ * @notice See {IGraphTallyCollector .recoverRAVSigner}
247
250
*/
248
251
function _recoverRAVSigner (SignedRAV memory _signedRAV ) private view returns (address ) {
249
252
bytes32 messageHash = _encodeRAV (_signedRAV.rav);
250
253
return ECDSA.recover (messageHash, _signedRAV.signature);
251
254
}
252
255
253
256
/**
254
- * @notice See {ITAPCollector .encodeRAV}
257
+ * @notice See {IGraphTallyCollector .encodeRAV}
255
258
*/
256
259
function _encodeRAV (ReceiptAggregateVoucher memory _rav ) private view returns (bytes32 ) {
257
260
return
@@ -280,7 +283,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
280
283
// Verify that the proofDeadline has not passed
281
284
require (
282
285
_proofDeadline > block .timestamp ,
283
- TAPCollectorInvalidSignerProofDeadline (_proofDeadline, block .timestamp )
286
+ GraphTallyCollectorInvalidSignerProofDeadline (_proofDeadline, block .timestamp )
284
287
);
285
288
286
289
// Generate the hash of the payer's address
@@ -290,6 +293,6 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
290
293
bytes32 digest = MessageHashUtils.toEthSignedMessageHash (messageHash);
291
294
292
295
// Verify that the recovered signer matches the expected signer
293
- require (ECDSA.recover (digest, _proof) == _signer, TAPCollectorInvalidSignerProof ());
296
+ require (ECDSA.recover (digest, _proof) == _signer, GraphTallyCollectorInvalidSignerProof ());
294
297
}
295
298
}
0 commit comments