Skip to content

Commit dd2e735

Browse files
committed
chore: rename TAPCollector to GraphTallyCollector
Signed-off-by: Tomás Migone <[email protected]>
1 parent f6923b9 commit dd2e735

29 files changed

+394
-389
lines changed

packages/horizon/contracts/interfaces/ITAPCollector.sol renamed to packages/horizon/contracts/interfaces/IGraphTallyCollector.sol

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { IPaymentsCollector } from "./IPaymentsCollector.sol";
55
import { IGraphPayments } from "./IGraphPayments.sol";
66

77
/**
8-
* @title Interface for the {TAPCollector} contract
8+
* @title Interface for the {GraphTallyCollector} contract
99
* @dev Implements the {IPaymentCollector} interface as defined by the Graph
1010
* Horizon payments protocol.
1111
* @notice Implements a payments collector contract that can be used to collect
12-
* payments using a TAP RAV (Receipt Aggregate Voucher).
12+
* payments using a GraphTally RAV (Receipt Aggregate Voucher).
1313
*/
14-
interface ITAPCollector is IPaymentsCollector {
14+
interface IGraphTallyCollector is IPaymentsCollector {
1515
/// @notice Details for a payer-signer pair
1616
/// @dev Signers can be removed only after a thawing period
1717
struct PayerAuthorization {
@@ -33,7 +33,7 @@ interface ITAPCollector is IPaymentsCollector {
3333
address serviceProvider;
3434
// The address of the data service the RAV was issued to
3535
address dataService;
36-
// The RAV timestamp, indicating the latest TAP Receipt in the RAV
36+
// The RAV timestamp, indicating the latest GraphTally Receipt in the RAV
3737
uint64 timestampNs;
3838
// Total amount owed to the service provider since the beginning of the
3939
// payer-service provider relationship, including all debt that is already paid for.
@@ -107,92 +107,92 @@ interface ITAPCollector is IPaymentsCollector {
107107
* @param authorizingPayer The address of the payer authorizing the signer
108108
* @param signer The address of the signer
109109
*/
110-
error TAPCollectorSignerAlreadyAuthorized(address authorizingPayer, address signer);
110+
error GraphTallyCollectorSignerAlreadyAuthorized(address authorizingPayer, address signer);
111111

112112
/**
113113
* Thrown when the signer proof deadline is invalid
114114
* @param proofDeadline The deadline for the proof provided by the signer
115115
* @param currentTimestamp The current timestamp
116116
*/
117-
error TAPCollectorInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp);
117+
error GraphTallyCollectorInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp);
118118

119119
/**
120120
* Thrown when the signer proof is invalid
121121
*/
122-
error TAPCollectorInvalidSignerProof();
122+
error GraphTallyCollectorInvalidSignerProof();
123123

124124
/**
125125
* Thrown when the signer is not authorized by the payer
126126
* @param payer The address of the payer
127127
* @param signer The address of the signer
128128
*/
129-
error TAPCollectorSignerNotAuthorizedByPayer(address payer, address signer);
129+
error GraphTallyCollectorSignerNotAuthorizedByPayer(address payer, address signer);
130130

131131
/**
132132
* Thrown when the attempting to revoke a signer that was already revoked
133133
* @param signer The address of the signer
134134
*/
135-
error TAPCollectorAuthorizationAlreadyRevoked(address payer, address signer);
135+
error GraphTallyCollectorAuthorizationAlreadyRevoked(address payer, address signer);
136136

137137
/**
138138
* Thrown when attempting to thaw a signer that is already thawing
139139
* @param signer The address of the signer
140140
* @param thawEndTimestamp The timestamp at which the thawing period ends
141141
*/
142-
error TAPCollectorSignerAlreadyThawing(address signer, uint256 thawEndTimestamp);
142+
error GraphTallyCollectorSignerAlreadyThawing(address signer, uint256 thawEndTimestamp);
143143

144144
/**
145145
* Thrown when the signer is not thawing
146146
* @param signer The address of the signer
147147
*/
148-
error TAPCollectorSignerNotThawing(address signer);
148+
error GraphTallyCollectorSignerNotThawing(address signer);
149149

150150
/**
151151
* Thrown when the signer is still thawing
152152
* @param currentTimestamp The current timestamp
153153
* @param thawEndTimestamp The timestamp at which the thawing period ends
154154
*/
155-
error TAPCollectorSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp);
155+
error GraphTallyCollectorSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp);
156156

157157
/**
158158
* Thrown when the RAV signer is invalid
159159
*/
160-
error TAPCollectorInvalidRAVSigner();
160+
error GraphTallyCollectorInvalidRAVSigner();
161161

162162
/**
163163
* Thrown when the RAV payer does not match the signers authorized payer
164164
* @param authorizedPayer The address of the authorized payer
165165
* @param ravPayer The address of the RAV payer
166166
*/
167-
error TAPCollectorInvalidRAVPayer(address authorizedPayer, address ravPayer);
167+
error GraphTallyCollectorInvalidRAVPayer(address authorizedPayer, address ravPayer);
168168

169169
/**
170170
* Thrown when the RAV is for a data service the service provider has no provision for
171171
* @param dataService The address of the data service
172172
*/
173-
error TAPCollectorUnauthorizedDataService(address dataService);
173+
error GraphTallyCollectorUnauthorizedDataService(address dataService);
174174

175175
/**
176176
* Thrown when the caller is not the data service the RAV was issued to
177177
* @param caller The address of the caller
178178
* @param dataService The address of the data service
179179
*/
180-
error TAPCollectorCallerNotDataService(address caller, address dataService);
180+
error GraphTallyCollectorCallerNotDataService(address caller, address dataService);
181181

182182
/**
183183
* @notice Thrown when the tokens collected are inconsistent with the collection history
184184
* Each RAV should have a value greater than the previous one
185185
* @param tokens The amount of tokens in the RAV
186186
* @param tokensCollected The amount of tokens already collected
187187
*/
188-
error TAPCollectorInconsistentRAVTokens(uint256 tokens, uint256 tokensCollected);
188+
error GraphTallyCollectorInconsistentRAVTokens(uint256 tokens, uint256 tokensCollected);
189189

190190
/**
191191
* Thrown when the attempting to collect more tokens than what it's owed
192192
* @param tokensToCollect The amount of tokens to collect
193193
* @param maxTokensToCollect The maximum amount of tokens to collect
194194
*/
195-
error TAPCollectorInvalidTokensToCollectAmount(uint256 tokensToCollect, uint256 maxTokensToCollect);
195+
error GraphTallyCollectorInvalidTokensToCollectAmount(uint256 tokensToCollect, uint256 maxTokensToCollect);
196196

197197
/**
198198
* @notice Authorize a signer to sign on behalf of the payer.

packages/horizon/contracts/payments/collectors/TAPCollector.sol renamed to packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity 0.8.27;
33

44
import { IGraphPayments } from "../../interfaces/IGraphPayments.sol";
5-
import { ITAPCollector } from "../../interfaces/ITAPCollector.sol";
5+
import { IGraphTallyCollector } from "../../interfaces/IGraphTallyCollector.sol";
66

77
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
88
import { PPMMath } from "../../libraries/PPMMath.sol";
@@ -12,9 +12,9 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
1212
import { 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
}

packages/horizon/ignition/configs/horizon-migrate.default.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"PaymentsEscrow": {
2626
"withdrawEscrowThawingPeriod": 10000
2727
},
28-
"TAPCollector": {
29-
"eip712Name": "TAPCollector",
28+
"GraphTallyCollector": {
29+
"eip712Name": "GraphTallyCollector",
3030
"eip712Version": "1",
3131
"revokeSignerThawingPeriod": 10000
3232
},

packages/horizon/ignition/configs/horizon-migrate.horizon-virtualArbitrumOne.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"PaymentsEscrow": {
2626
"withdrawEscrowThawingPeriod": 10000
2727
},
28-
"TAPCollector": {
29-
"eip712Name": "TAPCollector",
28+
"GraphTallyCollector": {
29+
"eip712Name": "GraphTallyCollector",
3030
"eip712Version": "1",
3131
"revokeSignerThawingPeriod": 10000
3232
},

packages/horizon/ignition/configs/horizon.default.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"PaymentsEscrow": {
2929
"withdrawEscrowThawingPeriod": 10000
3030
},
31-
"TAPCollector": {
32-
"eip712Name": "TAPCollector",
31+
"GraphTallyCollector": {
32+
"eip712Name": "GraphTallyCollector",
3333
"eip712Version": "1",
3434
"revokeSignerThawingPeriod": 10000
3535
}

0 commit comments

Comments
 (0)