Skip to content

Commit 6867b2c

Browse files
cleanup
1 parent 2e54c2c commit 6867b2c

File tree

1 file changed

+7
-18
lines changed
  • executors/src/external_bundler

1 file changed

+7
-18
lines changed

executors/src/external_bundler/send.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct ExternalBundlerSendResult {
7878
// --- Policy Error Structure ---
7979
#[derive(Serialize, Deserialize, Debug, Clone)]
8080
#[serde(rename_all = "camelCase")]
81-
pub struct PaymasterPolicyError {
81+
pub struct PaymasterPolicyResponse {
8282
pub policy_id: String,
8383
pub reason: String,
8484
}
@@ -578,20 +578,9 @@ where
578578
// --- Error Mapping Helpers ---
579579

580580
/// 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()
595584
}
596585

597586
fn map_build_error(
@@ -604,10 +593,10 @@ fn map_build_error(
604593
if let EngineError::PaymasterError { kind, .. } = engine_error {
605594
match kind {
606595
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) {
608597
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,
611600
};
612601
}
613602
}

0 commit comments

Comments
 (0)