@@ -8,7 +8,7 @@ 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 , primitives:: { Address , FixedBytes } , signers:: local:: PrivateKeySigner ,
1212 sol_types:: SolStruct ,
1313} ;
1414
@@ -39,65 +39,65 @@ pub fn check_and_aggregate_receipts(
3939 check_receipt_timestamps ( receipts, previous_rav. as_ref ( ) ) ?;
4040
4141 // 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 ( ) {
42+ let ( collection_id , payer, data_service, service_provider) = match receipts. first ( ) {
4343 Some ( receipt) => (
44- receipt. message . allocation_id ,
44+ receipt. message . collection_id ,
4545 receipt. message . payer ,
4646 receipt. message . data_service ,
4747 receipt. message . service_provider ,
4848 ) ,
4949 None => return Err ( tap_core:: Error :: NoValidReceiptsForRavRequest . into ( ) ) ,
5050 } ;
5151
52- // Check that the receipts all have the same allocation id
53- check_allocation_id (
52+ // Check that the receipts all have the same collection id
53+ check_collection_id (
5454 receipts,
55- allocation_id ,
55+ collection_id ,
5656 payer,
5757 data_service,
5858 service_provider,
5959 ) ?;
6060
6161 // Check that the rav has the correct allocation id
6262 if let Some ( previous_rav) = & previous_rav {
63- let prev_id = previous_rav. message . allocationId ;
63+ let prev_id = previous_rav. message . collectionId ;
6464 let prev_payer = previous_rav. message . payer ;
6565 let prev_data_service = previous_rav. message . dataService ;
6666 let prev_service_provider = previous_rav. message . serviceProvider ;
67- if prev_id != allocation_id {
67+ if prev_id != collection_id {
6868 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
6969 prev_id : format ! ( "{prev_id:#X}" ) ,
70- new_id : format ! ( "{allocation_id :#X}" ) ,
70+ new_id : format ! ( "{collection_id :#X}" ) ,
7171 }
7272 . into ( ) ) ;
7373 }
7474 if prev_payer != payer {
7575 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
7676 prev_id : format ! ( "{prev_id:#X}" ) ,
77- new_id : format ! ( "{allocation_id :#X}" ) ,
77+ new_id : format ! ( "{collection_id :#X}" ) ,
7878 }
7979 . into ( ) ) ;
8080 }
8181
8282 if prev_data_service != data_service {
8383 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
8484 prev_id : format ! ( "{prev_id:#X}" ) ,
85- new_id : format ! ( "{allocation_id :#X}" ) ,
85+ new_id : format ! ( "{collection_id :#X}" ) ,
8686 }
8787 . into ( ) ) ;
8888 }
8989 if prev_service_provider != service_provider {
9090 return Err ( tap_core:: Error :: RavAllocationIdMismatch {
9191 prev_id : format ! ( "{prev_id:#X}" ) ,
92- new_id : format ! ( "{allocation_id :#X}" ) ,
92+ new_id : format ! ( "{collection_id :#X}" ) ,
9393 }
9494 . into ( ) ) ;
9595 }
9696 }
9797
9898 // Aggregate the receipts
9999 let rav = ReceiptAggregateVoucher :: aggregate_receipts (
100- allocation_id ,
100+ collection_id ,
101101 payer,
102102 data_service,
103103 service_provider,
@@ -123,16 +123,16 @@ fn check_signature_is_from_one_of_addresses<M: SolStruct>(
123123 Ok ( ( ) )
124124}
125125
126- fn check_allocation_id (
126+ fn check_collection_id (
127127 receipts : & [ Eip712SignedMessage < Receipt > ] ,
128- allocation_id : Address ,
128+ collection_id : FixedBytes < 32 > ,
129129 payer : Address ,
130130 data_service : Address ,
131131 service_provider : Address ,
132132) -> Result < ( ) > {
133133 for receipt in receipts. iter ( ) {
134134 let receipt = & receipt. message ;
135- if receipt. allocation_id != allocation_id {
135+ if receipt. collection_id != collection_id {
136136 return Err ( tap_core:: Error :: RavAllocationIdNotUniform . into ( ) ) ;
137137 }
138138 if receipt. payer != payer {
@@ -190,7 +190,7 @@ mod tests {
190190 use tap_graph:: v2:: { Receipt , ReceiptAggregateVoucher } ;
191191 use thegraph_core:: alloy:: {
192192 dyn_abi:: Eip712Domain ,
193- primitives:: { address, Address , Bytes } ,
193+ primitives:: { address, fixed_bytes , Address , Bytes , FixedBytes } ,
194194 signers:: local:: PrivateKeySigner ,
195195 } ;
196196
@@ -202,8 +202,8 @@ mod tests {
202202 }
203203
204204 #[ fixture]
205- fn allocation_id ( ) -> Address {
206- address ! ( "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef " )
205+ fn collection_id ( ) -> FixedBytes < 32 > {
206+ fixed_bytes ! ( "deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead " )
207207 }
208208
209209 #[ fixture]
@@ -222,8 +222,8 @@ mod tests {
222222 }
223223
224224 #[ fixture]
225- fn other_address ( ) -> Address {
226- address ! ( "1234567890abcdef1234567890abcdef12345678 " )
225+ fn other_collection_id ( ) -> FixedBytes < 32 > {
226+ fixed_bytes ! ( "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef " )
227227 }
228228 #[ fixture]
229229 fn domain_separator ( ) -> Eip712Domain {
@@ -234,7 +234,7 @@ mod tests {
234234 #[ test]
235235 fn check_signatures_unique_fail (
236236 keys : ( PrivateKeySigner , Address ) ,
237- allocation_id : Address ,
237+ collection_id : FixedBytes < 32 > ,
238238 payer : Address ,
239239 data_service : Address ,
240240 service_provider : Address ,
@@ -244,7 +244,7 @@ mod tests {
244244 let mut receipts = Vec :: new ( ) ;
245245 let receipt = Eip712SignedMessage :: new (
246246 & domain_separator,
247- Receipt :: new ( allocation_id , payer, data_service, service_provider, 42 ) . unwrap ( ) ,
247+ Receipt :: new ( collection_id , payer, data_service, service_provider, 42 ) . unwrap ( ) ,
248248 & keys. 0 ,
249249 )
250250 . unwrap ( ) ;
@@ -259,7 +259,7 @@ mod tests {
259259 #[ test]
260260 fn check_signatures_unique_ok (
261261 keys : ( PrivateKeySigner , Address ) ,
262- allocation_id : Address ,
262+ collection_id : FixedBytes < 32 > ,
263263 payer : Address ,
264264 data_service : Address ,
265265 service_provider : Address ,
@@ -269,13 +269,13 @@ mod tests {
269269 let receipts = vec ! [
270270 Eip712SignedMessage :: new(
271271 & domain_separator,
272- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
272+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
273273 & keys. 0 ,
274274 )
275275 . unwrap( ) ,
276276 Eip712SignedMessage :: new(
277277 & domain_separator,
278- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
278+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
279279 & keys. 0 ,
280280 )
281281 . unwrap( ) ,
@@ -290,7 +290,7 @@ mod tests {
290290 /// Test that a receipt with a timestamp greater than the rav timestamp passes
291291 fn check_receipt_timestamps (
292292 keys : ( PrivateKeySigner , Address ) ,
293- allocation_id : Address ,
293+ collection_id : FixedBytes < 32 > ,
294294 payer : Address ,
295295 data_service : Address ,
296296 service_provider : Address ,
@@ -304,7 +304,7 @@ mod tests {
304304 Eip712SignedMessage :: new (
305305 & domain_separator,
306306 Receipt {
307- allocation_id ,
307+ collection_id ,
308308 payer,
309309 data_service,
310310 service_provider,
@@ -322,7 +322,7 @@ mod tests {
322322 let rav = Eip712SignedMessage :: new (
323323 & domain_separator,
324324 ReceiptAggregateVoucher {
325- allocationId : allocation_id ,
325+ collectionId : collection_id ,
326326 dataService : data_service,
327327 payer,
328328 serviceProvider : service_provider,
@@ -340,7 +340,7 @@ mod tests {
340340 let rav = Eip712SignedMessage :: new (
341341 & domain_separator,
342342 ReceiptAggregateVoucher {
343- allocationId : allocation_id ,
343+ collectionId : collection_id ,
344344 dataService : data_service,
345345 payer,
346346 serviceProvider : service_provider,
@@ -358,7 +358,7 @@ mod tests {
358358 let rav = Eip712SignedMessage :: new (
359359 & domain_separator,
360360 ReceiptAggregateVoucher {
361- allocationId : allocation_id ,
361+ collectionId : collection_id ,
362362 dataService : data_service,
363363 payer,
364364 serviceProvider : service_provider,
@@ -378,37 +378,37 @@ mod tests {
378378 /// and 1 receipt that has the wrong allocation id
379379 fn check_allocation_id_fail (
380380 keys : ( PrivateKeySigner , Address ) ,
381- allocation_id : Address ,
381+ collection_id : FixedBytes < 32 > ,
382382 payer : Address ,
383383 data_service : Address ,
384384 service_provider : Address ,
385- other_address : Address ,
385+ other_collection_id : FixedBytes < 32 > ,
386386 domain_separator : Eip712Domain ,
387387 ) {
388388 let receipts = vec ! [
389389 Eip712SignedMessage :: new(
390390 & domain_separator,
391- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
391+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
392392 & keys. 0 ,
393393 )
394394 . unwrap( ) ,
395395 Eip712SignedMessage :: new(
396396 & domain_separator,
397- Receipt :: new( allocation_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
397+ Receipt :: new( collection_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
398398 & keys. 0 ,
399399 )
400400 . unwrap( ) ,
401401 Eip712SignedMessage :: new(
402402 & domain_separator,
403- Receipt :: new( other_address , payer, data_service, service_provider, 44 ) . unwrap( ) ,
403+ Receipt :: new( other_collection_id , payer, data_service, service_provider, 44 ) . unwrap( ) ,
404404 & keys. 0 ,
405405 )
406406 . unwrap( ) ,
407407 ] ;
408408
409- let res = super :: check_allocation_id (
409+ let res = super :: check_collection_id (
410410 & receipts,
411- allocation_id ,
411+ collection_id ,
412412 payer,
413413 data_service,
414414 service_provider,
@@ -422,7 +422,7 @@ mod tests {
422422 /// Test check_allocation_id with 3 receipts that have the correct allocation id
423423 fn check_allocation_id_ok (
424424 keys : ( PrivateKeySigner , Address ) ,
425- allocation_id : Address ,
425+ collection_id : FixedBytes < 32 > ,
426426 payer : Address ,
427427 data_service : Address ,
428428 service_provider : Address ,
@@ -431,27 +431,27 @@ mod tests {
431431 let receipts = vec ! [
432432 Eip712SignedMessage :: new(
433433 & domain_separator,
434- Receipt :: new( allocation_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
434+ Receipt :: new( collection_id , payer, data_service, service_provider, 42 ) . unwrap( ) ,
435435 & keys. 0 ,
436436 )
437437 . unwrap( ) ,
438438 Eip712SignedMessage :: new(
439439 & domain_separator,
440- Receipt :: new( allocation_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
440+ Receipt :: new( collection_id , payer, data_service, service_provider, 43 ) . unwrap( ) ,
441441 & keys. 0 ,
442442 )
443443 . unwrap( ) ,
444444 Eip712SignedMessage :: new(
445445 & domain_separator,
446- Receipt :: new( allocation_id , payer, data_service, service_provider, 44 ) . unwrap( ) ,
446+ Receipt :: new( collection_id , payer, data_service, service_provider, 44 ) . unwrap( ) ,
447447 & keys. 0 ,
448448 )
449449 . unwrap( ) ,
450450 ] ;
451451
452- let res = super :: check_allocation_id (
452+ let res = super :: check_collection_id (
453453 & receipts,
454- allocation_id ,
454+ collection_id ,
455455 payer,
456456 data_service,
457457 service_provider,
0 commit comments