@@ -78,7 +78,7 @@ pub struct ExternalBundlerSendResult {
78
78
// --- Policy Error Structure ---
79
79
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
80
80
#[ serde( rename_all = "camelCase" ) ]
81
- pub struct PaymasterPolicyError {
81
+ pub struct PaymasterPolicyResponse {
82
82
pub policy_id : String ,
83
83
pub reason : String ,
84
84
}
@@ -578,20 +578,9 @@ where
578
578
// --- Error Mapping Helpers ---
579
579
580
580
/// Attempts to parse a policy error from an error message/body
581
- fn try_parse_policy_error ( error_body : & str ) -> Option < PaymasterPolicyError > {
582
- // Try to parse the error body as JSON containing policy error
583
- if let Ok ( policy_error) = serde_json:: from_str :: < PaymasterPolicyError > ( error_body) {
584
- return Some ( policy_error) ;
585
- }
586
-
587
- // Also check if the error message contains policy error information
588
- if error_body. contains ( "policyId" ) && error_body. contains ( "reason" ) {
589
- if let Ok ( policy_error) = serde_json:: from_str :: < PaymasterPolicyError > ( error_body) {
590
- return Some ( policy_error) ;
591
- }
592
- }
593
-
594
- None
581
+ fn try_parse_policy_error ( error_body : & str ) -> Option < PaymasterPolicyResponse > {
582
+ // Try to parse the error body as JSON containing policy error response
583
+ serde_json:: from_str :: < PaymasterPolicyResponse > ( error_body) . ok ( )
595
584
}
596
585
597
586
fn map_build_error (
@@ -604,10 +593,10 @@ fn map_build_error(
604
593
if let EngineError :: PaymasterError { kind, .. } = engine_error {
605
594
match kind {
606
595
RpcErrorKind :: TransportHttpError { body, .. } => {
607
- if let Some ( policy_error ) = try_parse_policy_error ( body) {
596
+ if let Some ( policy_response ) = try_parse_policy_error ( body) {
608
597
return ExternalBundlerSendError :: PolicyRestriction {
609
- policy_id : policy_error . policy_id ,
610
- reason : policy_error . reason ,
598
+ policy_id : policy_response . policy_id ,
599
+ reason : policy_response . reason ,
611
600
} ;
612
601
}
613
602
}
0 commit comments