@@ -20,18 +20,20 @@ use tap_core::{
2020 manager:: { adapters:: ReceiptStore , Manager } ,
2121 receipt:: Context ,
2222} ;
23- use tap_graph:: { ReceiptAggregateVoucher , SignedReceipt } ;
23+ use tap_graph:: ReceiptAggregateVoucher ;
2424use tower_http:: auth:: AsyncAuthorizeRequest ;
2525
26- use crate :: { error:: IndexerServiceError , middleware:: prometheus_metrics:: MetricLabels } ;
26+ use crate :: {
27+ error:: IndexerServiceError , middleware:: prometheus_metrics:: MetricLabels , tap:: TapReceipt ,
28+ } ;
2729
2830/// Middleware to verify and store TAP receipts
2931///
3032/// It also optionally updates a failed receipt metric if Labels are provided
3133///
32- /// Requires SignedReceipt , MetricLabels and Arc<Context> extensions
34+ /// Requires TapReceipt , MetricLabels and Arc<Context> extensions
3335pub fn tap_receipt_authorize < T , B > (
34- tap_manager : Arc < Manager < T , SignedReceipt , ReceiptAggregateVoucher > > ,
36+ tap_manager : Arc < Manager < T , TapReceipt , ReceiptAggregateVoucher > > ,
3537 failed_receipt_metric : & ' static prometheus:: CounterVec ,
3638) -> impl AsyncAuthorizeRequest <
3739 B ,
@@ -41,11 +43,11 @@ pub fn tap_receipt_authorize<T, B>(
4143> + Clone
4244 + Send
4345where
44- T : ReceiptStore < SignedReceipt > + Sync + Send + ' static ,
46+ T : ReceiptStore < TapReceipt > + Sync + Send + ' static ,
4547 B : Send ,
4648{
47- move |request : Request < B > | {
48- let receipt = request. extensions ( ) . get :: < SignedReceipt > ( ) . cloned ( ) ;
49+ move |mut request : Request < B > | {
50+ let receipt = request. extensions_mut ( ) . remove :: < TapReceipt > ( ) ;
4951 // load labels from previous middlewares
5052 let labels = request. extensions ( ) . get :: < MetricLabels > ( ) . cloned ( ) ;
5153 // load context from previous middlewares
@@ -91,7 +93,6 @@ mod tests {
9193 manager:: Manager ,
9294 receipt:: checks:: { Check , CheckError , CheckList , CheckResult } ,
9395 } ;
94- use tap_graph:: SignedReceipt ;
9596 use test_assets:: {
9697 assert_while_retry, create_signed_receipt, SignedReceiptRequest , TAP_EIP712_DOMAIN ,
9798 } ;
@@ -103,7 +104,7 @@ mod tests {
103104 auth:: tap_receipt_authorize,
104105 prometheus_metrics:: { MetricLabelProvider , MetricLabels } ,
105106 } ,
106- tap:: { CheckingReceipt , IndexerTapContext } ,
107+ tap:: { CheckingReceipt , IndexerTapContext , TapReceipt } ,
107108 } ;
108109
109110 #[ fixture]
@@ -131,13 +132,13 @@ mod tests {
131132
132133 struct MyCheck ;
133134 #[ async_trait:: async_trait]
134- impl Check < SignedReceipt > for MyCheck {
135+ impl Check < TapReceipt > for MyCheck {
135136 async fn check (
136137 & self ,
137138 _: & tap_core:: receipt:: Context ,
138139 receipt : & CheckingReceipt ,
139140 ) -> CheckResult {
140- if receipt. signed_receipt ( ) . message . nonce == FAILED_NONCE {
141+ if receipt. signed_receipt ( ) . nonce ( ) == FAILED_NONCE {
141142 Err ( CheckError :: Failed ( anyhow:: anyhow!( "Failed" ) ) )
142143 } else {
143144 Ok ( ( ) )
@@ -175,7 +176,7 @@ mod tests {
175176
176177 // check with receipt
177178 let mut req = Request :: new ( Body :: default ( ) ) ;
178- req. extensions_mut ( ) . insert ( receipt) ;
179+ req. extensions_mut ( ) . insert ( TapReceipt :: V1 ( receipt) ) ;
179180 let res = service. call ( req) . await . unwrap ( ) ;
180181 assert_eq ! ( res. status( ) , StatusCode :: OK ) ;
181182
@@ -214,7 +215,7 @@ mod tests {
214215 // change the nonce to make the receipt invalid
215216 receipt. message . nonce = FAILED_NONCE ;
216217 let mut req = Request :: new ( Body :: default ( ) ) ;
217- req. extensions_mut ( ) . insert ( receipt) ;
218+ req. extensions_mut ( ) . insert ( TapReceipt :: V1 ( receipt) ) ;
218219 req. extensions_mut ( ) . insert ( labels) ;
219220 let response = service. call ( req) ;
220221
0 commit comments