@@ -8,7 +8,9 @@ use rayon::prelude::*;
88use tap_core:: { receipt:: WithUniqueId , signed_message:: Eip712SignedMessage } ;
99use tap_graph:: v2:: { Receipt , ReceiptAggregateVoucher } ;
1010use thegraph_core:: alloy:: {
11- dyn_abi:: Eip712Domain , primitives:: Address , signers:: local:: PrivateKeySigner ,
11+ dyn_abi:: Eip712Domain ,
12+ primitives:: { Address , FixedBytes } ,
13+ signers:: local:: PrivateKeySigner ,
1214 sol_types:: SolStruct ,
1315} ;
1416
@@ -39,65 +41,65 @@ pub fn check_and_aggregate_receipts(
3941 check_receipt_timestamps ( receipts, previous_rav. as_ref ( ) ) ?;
4042
4143 // Get the allocation id from the first receipt, return error if there are no receipts
42- let ( allocation_id , payer, data_service, service_provider) = match receipts. first ( ) {
44+ let ( collection_id , payer, data_service, service_provider) = match receipts. first ( ) {
4345 Some ( receipt) => (
44- receipt. message . allocation_id ,
46+ receipt. message . collection_id ,
4547 receipt. message . payer ,
4648 receipt. message . data_service ,
4749 receipt. message . service_provider ,
4850 ) ,
4951 None => return Err ( tap_core:: Error :: NoValidReceiptsForRavRequest . into ( ) ) ,
5052 } ;
5153
52- // Check that the receipts all have the same allocation id
53- check_allocation_id (
54+ // Check that the receipts all have the same collection id
55+ check_collection_id (
5456 receipts,
55- allocation_id ,
57+ collection_id ,
5658 payer,
5759 data_service,
5860 service_provider,
5961 ) ?;
6062
6163 // Check that the rav has the correct allocation id
6264 if let Some ( previous_rav) = & previous_rav {
63- let prev_id = previous_rav. message . allocationId ;
65+ let prev_id = previous_rav. message . collectionId ;
6466 let prev_payer = previous_rav. message . payer ;
6567 let prev_data_service = previous_rav. message . dataService ;
6668 let prev_service_provider = previous_rav. message . serviceProvider ;
67- if prev_id != allocation_id {
69+ if prev_id != collection_id {
6870 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
6971 prev_id : format ! ( "{prev_id:#X}" ) ,
70- new_id : format ! ( "{allocation_id :#X}" ) ,
72+ new_id : format ! ( "{collection_id :#X}" ) ,
7173 }
7274 . into ( ) ) ;
7375 }
7476 if prev_payer != payer {
7577 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
7678 prev_id : format ! ( "{prev_id:#X}" ) ,
77- new_id : format ! ( "{allocation_id :#X}" ) ,
79+ new_id : format ! ( "{collection_id :#X}" ) ,
7880 }
7981 . into ( ) ) ;
8082 }
8183
8284 if prev_data_service != data_service {
8385 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
8486 prev_id : format ! ( "{prev_id:#X}" ) ,
85- new_id : format ! ( "{allocation_id :#X}" ) ,
87+ new_id : format ! ( "{collection_id :#X}" ) ,
8688 }
8789 . into ( ) ) ;
8890 }
8991 if prev_service_provider != service_provider {
9092 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
9193 prev_id : format ! ( "{prev_id:#X}" ) ,
92- new_id : format ! ( "{allocation_id :#X}" ) ,
94+ new_id : format ! ( "{collection_id :#X}" ) ,
9395 }
9496 . into ( ) ) ;
9597 }
9698 }
9799
98100 // Aggregate the receipts
99101 let rav = ReceiptAggregateVoucher :: aggregate_receipts (
100- allocation_id ,
102+ collection_id ,
101103 payer,
102104 data_service,
103105 service_provider,
@@ -123,16 +125,16 @@ fn check_signature_is_from_one_of_addresses<M: SolStruct>(
123125 Ok ( ( ) )
124126}
125127
126- fn check_allocation_id (
128+ fn check_collection_id (
127129 receipts : & [ Eip712SignedMessage < Receipt > ] ,
128- allocation_id : Address ,
130+ collection_id : FixedBytes < 32 > ,
129131 payer : Address ,
130132 data_service : Address ,
131133 service_provider : Address ,
132134) -> Result < ( ) > {
133135 for receipt in receipts. iter ( ) {
134136 let receipt = & receipt. message ;
135- if receipt. allocation_id != allocation_id {
137+ if receipt. collection_id != collection_id {
136138 return Err ( tap_core:: Error :: RavAllocationIdNotUniform . into ( ) ) ;
137139 }
138140 if receipt. payer != payer {
@@ -190,7 +192,7 @@ mod tests {
190192 use tap_graph:: v2:: { Receipt , ReceiptAggregateVoucher } ;
191193 use thegraph_core:: alloy:: {
192194 dyn_abi:: Eip712Domain ,
193- primitives:: { address, Address , Bytes } ,
195+ primitives:: { address, fixed_bytes , Address , Bytes , FixedBytes } ,
194196 signers:: local:: PrivateKeySigner ,
195197 } ;
196198
@@ -202,8 +204,8 @@ mod tests {
202204 }
203205
204206 #[ fixture]
205- fn allocation_id ( ) -> Address {
206- address ! ( "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef " )
207+ fn collection_id ( ) -> FixedBytes < 32 > {
208+ fixed_bytes ! ( "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead " )
207209 }
208210
209211 #[ fixture]
@@ -222,8 +224,8 @@ mod tests {
222224 }
223225
224226 #[ fixture]
225- fn other_address ( ) -> Address {
226- address ! ( "1234567890abcdef1234567890abcdef12345678 " )
227+ fn other_collection_id ( ) -> FixedBytes < 32 > {
228+ fixed_bytes ! ( "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef " )
227229 }
228230 #[ fixture]
229231 fn domain_separator ( ) -> Eip712Domain {
@@ -234,7 +236,7 @@ mod tests {
234236 #[ test]
235237 fn check_signatures_unique_fail (
236238 keys : ( PrivateKeySigner , Address ) ,
237- allocation_id : Address ,
239+ collection_id : FixedBytes < 32 > ,
238240 payer : Address ,
239241 data_service : Address ,
240242 service_provider : Address ,
@@ -244,7 +246,7 @@ mod tests {
244246 let mut receipts = Vec :: new ( ) ;
245247 let receipt = Eip712SignedMessage :: new (
246248 & domain_separator,
247- Receipt :: new ( allocation_id , payer, data_service, service_provider, 42 ) . unwrap ( ) ,
249+ Receipt :: new ( collection_id , payer, data_service, service_provider, 42 ) . unwrap ( ) ,
248250 & keys. 0 ,
249251 )
250252 . unwrap ( ) ;
@@ -259,7 +261,7 @@ mod tests {
259261 #[ test]
260262 fn check_signatures_unique_ok (
261263 keys : ( PrivateKeySigner , Address ) ,
262- allocation_id : Address ,
264+ collection_id : FixedBytes < 32 > ,
263265 payer : Address ,
264266 data_service : Address ,
265267 service_provider : Address ,
@@ -269,13 +271,13 @@ mod tests {
269271 let receipts = vec ! [
270272 Eip712SignedMessage :: new(
271273 & domain_separator,
272- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
274+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
273275 & keys. 0 ,
274276 )
275277 . unwrap( ) ,
276278 Eip712SignedMessage :: new(
277279 & domain_separator,
278- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
280+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
279281 & keys. 0 ,
280282 )
281283 . unwrap( ) ,
@@ -290,7 +292,7 @@ mod tests {
290292 /// Test that a receipt with a timestamp greater than the rav timestamp passes
291293 fn check_receipt_timestamps (
292294 keys : ( PrivateKeySigner , Address ) ,
293- allocation_id : Address ,
295+ collection_id : FixedBytes < 32 > ,
294296 payer : Address ,
295297 data_service : Address ,
296298 service_provider : Address ,
@@ -304,7 +306,7 @@ mod tests {
304306 Eip712SignedMessage :: new (
305307 & domain_separator,
306308 Receipt {
307- allocation_id ,
309+ collection_id ,
308310 payer,
309311 data_service,
310312 service_provider,
@@ -322,7 +324,7 @@ mod tests {
322324 let rav = Eip712SignedMessage :: new (
323325 & domain_separator,
324326 ReceiptAggregateVoucher {
325- allocationId : allocation_id ,
327+ collectionId : collection_id ,
326328 dataService : data_service,
327329 payer,
328330 serviceProvider : service_provider,
@@ -340,7 +342,7 @@ mod tests {
340342 let rav = Eip712SignedMessage :: new (
341343 & domain_separator,
342344 ReceiptAggregateVoucher {
343- allocationId : allocation_id ,
345+ collectionId : collection_id ,
344346 dataService : data_service,
345347 payer,
346348 serviceProvider : service_provider,
@@ -358,7 +360,7 @@ mod tests {
358360 let rav = Eip712SignedMessage :: new (
359361 & domain_separator,
360362 ReceiptAggregateVoucher {
361- allocationId : allocation_id ,
363+ collectionId : collection_id ,
362364 dataService : data_service,
363365 payer,
364366 serviceProvider : service_provider,
@@ -378,37 +380,44 @@ mod tests {
378380 /// and 1 receipt that has the wrong allocation id
379381 fn check_allocation_id_fail (
380382 keys : ( PrivateKeySigner , Address ) ,
381- allocation_id : Address ,
383+ collection_id : FixedBytes < 32 > ,
382384 payer : Address ,
383385 data_service : Address ,
384386 service_provider : Address ,
385- other_address : Address ,
387+ other_collection_id : FixedBytes < 32 > ,
386388 domain_separator : Eip712Domain ,
387389 ) {
388390 let receipts = vec ! [
389391 Eip712SignedMessage :: new(
390392 & domain_separator,
391- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
393+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
392394 & keys. 0 ,
393395 )
394396 . unwrap( ) ,
395397 Eip712SignedMessage :: new(
396398 & domain_separator,
397- Receipt :: new( allocation_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
399+ Receipt :: new( collection_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
398400 & keys. 0 ,
399401 )
400402 . unwrap( ) ,
401403 Eip712SignedMessage :: new(
402404 & domain_separator,
403- Receipt :: new( other_address, payer, data_service, service_provider, 44 ) . unwrap( ) ,
405+ Receipt :: new(
406+ other_collection_id,
407+ payer,
408+ data_service,
409+ service_provider,
410+ 44 ,
411+ )
412+ . unwrap( ) ,
404413 & keys. 0 ,
405414 )
406415 . unwrap( ) ,
407416 ] ;
408417
409- let res = super :: check_allocation_id (
418+ let res = super :: check_collection_id (
410419 & receipts,
411- allocation_id ,
420+ collection_id ,
412421 payer,
413422 data_service,
414423 service_provider,
@@ -422,7 +431,7 @@ mod tests {
422431 /// Test check_allocation_id with 3 receipts that have the correct allocation id
423432 fn check_allocation_id_ok (
424433 keys : ( PrivateKeySigner , Address ) ,
425- allocation_id : Address ,
434+ collection_id : FixedBytes < 32 > ,
426435 payer : Address ,
427436 data_service : Address ,
428437 service_provider : Address ,
@@ -431,27 +440,27 @@ mod tests {
431440 let receipts = vec ! [
432441 Eip712SignedMessage :: new(
433442 & domain_separator,
434- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
443+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
435444 & keys. 0 ,
436445 )
437446 . unwrap( ) ,
438447 Eip712SignedMessage :: new(
439448 & domain_separator,
440- Receipt :: new( allocation_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
449+ Receipt :: new( collection_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
441450 & keys. 0 ,
442451 )
443452 . unwrap( ) ,
444453 Eip712SignedMessage :: new(
445454 & domain_separator,
446- Receipt :: new( allocation_id , payer, data_service, service_provider, 44 ) . unwrap( ) ,
455+ Receipt :: new( collection_id , payer, data_service, service_provider, 44 ) . unwrap( ) ,
447456 & keys. 0 ,
448457 )
449458 . unwrap( ) ,
450459 ] ;
451460
452- let res = super :: check_allocation_id (
461+ let res = super :: check_collection_id (
453462 & receipts,
454- allocation_id ,
463+ collection_id ,
455464 payer,
456465 data_service,
457466 service_provider,
0 commit comments