22pragma solidity 0.8.27 ;
33
44import { IGraphPayments } from "../../interfaces/IGraphPayments.sol " ;
5- import { ITAPCollector } from "../../interfaces/ITAPCollector .sol " ;
5+ import { IGraphTallyCollector } from "../../interfaces/IGraphTallyCollector .sol " ;
66
77import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol " ;
88import { PPMMath } from "../../libraries/PPMMath.sol " ;
@@ -12,9 +12,9 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
1212import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol " ;
1313
1414/**
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).
1818 * @dev Note that the contract expects the RAV aggregate value to be monotonically increasing, each successive RAV for the same
1919 * (data service-payer-receiver) tuple should have a value greater than the previous one. The contract will keep track of the tokens
2020 * already collected and calculate the difference to collect.
@@ -23,7 +23,7 @@ import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/Mes
2323 * @custom:security-contact Please email [email protected] if you find any 2424 * bugs. We may have an active bug bounty program.
2525 */
26- contract TAPCollector is EIP712 , GraphDirectory , ITAPCollector {
26+ contract GraphTallyCollector is EIP712 , GraphDirectory , IGraphTallyCollector {
2727 using PPMMath for uint256 ;
2828
2929 /// @notice The EIP712 typehash for the ReceiptAggregateVoucher struct
@@ -45,7 +45,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
4545 uint256 public immutable REVOKE_SIGNER_THAWING_PERIOD;
4646
4747 /**
48- * @notice Constructs a new instance of the TAPVerifier contract.
48+ * @notice Constructs a new instance of the GraphTallyCollector contract.
4949 * @param eip712Name The name of the EIP712 domain.
5050 * @param eip712Version The version of the EIP712 domain.
5151 * @param controller The address of the Graph controller.
@@ -61,12 +61,12 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
6161 }
6262
6363 /**
64- * See {ITAPCollector .authorizeSigner}.
64+ * See {IGraphTallyCollector .authorizeSigner}.
6565 */
6666 function authorizeSigner (address signer , uint256 proofDeadline , bytes calldata proof ) external override {
6767 require (
6868 authorizedSigners[signer].payer == address (0 ),
69- TAPCollectorSignerAlreadyAuthorized (authorizedSigners[signer].payer, signer)
69+ GraphTallyCollectorSignerAlreadyAuthorized (authorizedSigners[signer].payer, signer)
7070 );
7171
7272 _verifyAuthorizedSignerProof (proof, proofDeadline, signer);
@@ -77,46 +77,46 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
7777 }
7878
7979 /**
80- * See {ITAPCollector .thawSigner}.
80+ * See {IGraphTallyCollector .thawSigner}.
8181 */
8282 function thawSigner (address signer ) external override {
8383 PayerAuthorization storage authorization = authorizedSigners[signer];
8484
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));
8787 require (
8888 authorization.thawEndTimestamp == 0 ,
89- TAPCollectorSignerAlreadyThawing (signer, authorization.thawEndTimestamp)
89+ GraphTallyCollectorSignerAlreadyThawing (signer, authorization.thawEndTimestamp)
9090 );
9191
9292 authorization.thawEndTimestamp = block .timestamp + REVOKE_SIGNER_THAWING_PERIOD;
9393 emit SignerThawing (msg .sender , signer, authorization.thawEndTimestamp);
9494 }
9595
9696 /**
97- * See {ITAPCollector .cancelThawSigner}.
97+ * See {IGraphTallyCollector .cancelThawSigner}.
9898 */
9999 function cancelThawSigner (address signer ) external override {
100100 PayerAuthorization storage authorization = authorizedSigners[signer];
101101
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));
104104
105105 authorization.thawEndTimestamp = 0 ;
106106 emit SignerThawCanceled (msg .sender , signer, 0 );
107107 }
108108
109109 /**
110- * See {ITAPCollector .revokeAuthorizedSigner}.
110+ * See {IGraphTallyCollector .revokeAuthorizedSigner}.
111111 */
112112 function revokeAuthorizedSigner (address signer ) external override {
113113 PayerAuthorization storage authorization = authorizedSigners[signer];
114114
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));
117117 require (
118118 authorization.thawEndTimestamp <= block .timestamp ,
119- TAPCollectorSignerStillThawing (block .timestamp , authorization.thawEndTimestamp)
119+ GraphTallyCollectorSignerStillThawing (block .timestamp , authorization.thawEndTimestamp)
120120 );
121121
122122 authorization.revoked = true ;
@@ -145,21 +145,21 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
145145 }
146146
147147 /**
148- * @notice See {ITAPCollector .recoverRAVSigner}
148+ * @notice See {IGraphTallyCollector .recoverRAVSigner}
149149 */
150150 function recoverRAVSigner (SignedRAV calldata signedRAV ) external view override returns (address ) {
151151 return _recoverRAVSigner (signedRAV);
152152 }
153153
154154 /**
155- * @notice See {ITAPCollector .encodeRAV}
155+ * @notice See {IGraphTallyCollector .encodeRAV}
156156 */
157157 function encodeRAV (ReceiptAggregateVoucher calldata rav ) external view returns (bytes32 ) {
158158 return _encodeRAV (rav);
159159 }
160160
161161 /**
162- * @notice See {ITAPCollector .collect}
162+ * @notice See {IGraphTallyCollector .collect}
163163 */
164164 function _collect (
165165 IGraphPayments.PaymentTypes _paymentType ,
@@ -171,19 +171,19 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
171171 // Ensure caller is the RAV data service
172172 require (
173173 signedRAV.rav.dataService == msg .sender ,
174- TAPCollectorCallerNotDataService (msg .sender , signedRAV.rav.dataService)
174+ GraphTallyCollectorCallerNotDataService (msg .sender , signedRAV.rav.dataService)
175175 );
176176
177177 // Ensure RAV signer is authorized for a payer
178178 address signer = _recoverRAVSigner (signedRAV);
179179 require (
180180 authorizedSigners[signer].payer != address (0 ) && ! authorizedSigners[signer].revoked,
181- TAPCollectorInvalidRAVSigner ()
181+ GraphTallyCollectorInvalidRAVSigner ()
182182 );
183183
184184 // Ensure RAV payer matches the authorized payer
185185 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));
187187
188188 bytes32 collectionId = signedRAV.rav.collectionId;
189189 address dataService = signedRAV.rav.dataService;
@@ -197,7 +197,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
197197 signedRAV.rav.serviceProvider,
198198 signedRAV.rav.dataService
199199 );
200- require (tokensAvailable > 0 , TAPCollectorUnauthorizedDataService (signedRAV.rav.dataService));
200+ require (tokensAvailable > 0 , GraphTallyCollectorUnauthorizedDataService (signedRAV.rav.dataService));
201201 }
202202
203203 uint256 tokensToCollect = 0 ;
@@ -206,15 +206,18 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
206206 uint256 tokensAlreadyCollected = tokensCollected[dataService][collectionId][receiver][payer];
207207 require (
208208 tokensRAV > tokensAlreadyCollected,
209- TAPCollectorInconsistentRAVTokens (tokensRAV, tokensAlreadyCollected)
209+ GraphTallyCollectorInconsistentRAVTokens (tokensRAV, tokensAlreadyCollected)
210210 );
211211
212212 if (_tokensToCollect == 0 ) {
213213 tokensToCollect = tokensRAV - tokensAlreadyCollected;
214214 } else {
215215 require (
216216 _tokensToCollect <= tokensRAV - tokensAlreadyCollected,
217- TAPCollectorInvalidTokensToCollectAmount (_tokensToCollect, tokensRAV - tokensAlreadyCollected)
217+ GraphTallyCollectorInvalidTokensToCollectAmount (
218+ _tokensToCollect,
219+ tokensRAV - tokensAlreadyCollected
220+ )
218221 );
219222 tokensToCollect = _tokensToCollect;
220223 }
@@ -243,15 +246,15 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
243246 }
244247
245248 /**
246- * @notice See {ITAPCollector .recoverRAVSigner}
249+ * @notice See {IGraphTallyCollector .recoverRAVSigner}
247250 */
248251 function _recoverRAVSigner (SignedRAV memory _signedRAV ) private view returns (address ) {
249252 bytes32 messageHash = _encodeRAV (_signedRAV.rav);
250253 return ECDSA.recover (messageHash, _signedRAV.signature);
251254 }
252255
253256 /**
254- * @notice See {ITAPCollector .encodeRAV}
257+ * @notice See {IGraphTallyCollector .encodeRAV}
255258 */
256259 function _encodeRAV (ReceiptAggregateVoucher memory _rav ) private view returns (bytes32 ) {
257260 return
@@ -280,7 +283,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
280283 // Verify that the proofDeadline has not passed
281284 require (
282285 _proofDeadline > block .timestamp ,
283- TAPCollectorInvalidSignerProofDeadline (_proofDeadline, block .timestamp )
286+ GraphTallyCollectorInvalidSignerProofDeadline (_proofDeadline, block .timestamp )
284287 );
285288
286289 // Generate the hash of the payer's address
@@ -290,6 +293,6 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
290293 bytes32 digest = MessageHashUtils.toEthSignedMessageHash (messageHash);
291294
292295 // 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 ());
294297 }
295298}
0 commit comments