@@ -35,8 +35,10 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
35
35
/// @notice Authorization details for payer-signer pairs
36
36
mapping (address signer = > PayerAuthorization authorizedSigner ) public authorizedSigners;
37
37
38
- /// @notice Tracks the amount of tokens already collected by a data service from a payer to a receiver
39
- mapping (address dataService = > mapping (address receiver = > mapping (address payer = > uint256 tokens )))
38
+ /// @notice Tracks the amount of tokens already collected by a data service from a payer to a receiver.
39
+ /// @dev The collectionId provides a secondary key for grouping payment tracking if needed. Data services that do not require
40
+ /// grouping can use the same collectionId for all payments (0x00 or some other default value).
41
+ mapping (address dataService = > mapping (bytes32 collectionId = > mapping (address receiver = > mapping (address payer = > uint256 tokens ))))
40
42
public tokensCollected;
41
43
42
44
/// @notice The duration (in seconds) in which a signer is thawing before they can be revoked
@@ -182,6 +184,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
182
184
address payer = authorizedSigners[signer].payer;
183
185
require (signedRAV.rav.payer == payer, TAPCollectorInvalidRAVPayer (payer, signedRAV.rav.payer));
184
186
187
+ bytes32 collectionId = signedRAV.rav.collectionId;
185
188
address dataService = signedRAV.rav.dataService;
186
189
address receiver = signedRAV.rav.serviceProvider;
187
190
@@ -199,7 +202,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
199
202
uint256 tokensToCollect = 0 ;
200
203
{
201
204
uint256 tokensRAV = signedRAV.rav.valueAggregate;
202
- uint256 tokensAlreadyCollected = tokensCollected[dataService][receiver][payer];
205
+ uint256 tokensAlreadyCollected = tokensCollected[dataService][collectionId][ receiver][payer];
203
206
require (
204
207
tokensRAV > tokensAlreadyCollected,
205
208
TAPCollectorInconsistentRAVTokens (tokensRAV, tokensAlreadyCollected)
@@ -217,20 +220,24 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector {
217
220
}
218
221
219
222
if (tokensToCollect > 0 ) {
220
- tokensCollected[dataService][receiver][payer] += tokensToCollect;
223
+ tokensCollected[dataService][collectionId][ receiver][payer] += tokensToCollect;
221
224
_graphPaymentsEscrow ().collect (_paymentType, payer, receiver, tokensToCollect, dataService, dataServiceCut);
222
225
}
223
226
224
- emit PaymentCollected (_paymentType, payer, receiver, dataService, tokensToCollect);
227
+ emit PaymentCollected (_paymentType, collectionId, payer, receiver, dataService, tokensToCollect);
228
+
229
+ // This event is emitted to allow reconstructing RAV history with onchain data.
225
230
emit RAVCollected (
231
+ collectionId,
226
232
payer,
227
- dataService,
228
233
receiver,
234
+ dataService,
229
235
signedRAV.rav.timestampNs,
230
236
signedRAV.rav.valueAggregate,
231
237
signedRAV.rav.metadata,
232
238
signedRAV.signature
233
239
);
240
+
234
241
return tokensToCollect;
235
242
}
236
243
0 commit comments