Skip to content

Commit 3beb5ce

Browse files
authored
Implement fleet ID support in EIP-7702 execution options (#73)
* Implement fleet ID support in EIP-7702 execution options - Added `fleet_id` field to `Eip7702OwnerExecution` and `Eip7702SessionKeyExecution` structs to allow routing transactions to specific bundler fleets. - Introduced `fleet_id` method in `Eip7702ExecutionOptions` for retrieving the fleet ID. - Updated bundler client creation in the executor to include the optional `fleet_id` header when present, enhancing transaction routing capabilities. * dont clone * add directly to chain auth headers
1 parent 6c601d8 commit 3beb5ce

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

core/src/execution_options/eip7702.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,27 @@ pub enum Eip7702ExecutionOptions {
1414
SessionKey(Eip7702SessionKeyExecution),
1515
}
1616

17+
impl Eip7702ExecutionOptions {
18+
/// Get the fleet ID if present
19+
pub fn fleet_id(&self) -> Option<&str> {
20+
match self {
21+
Eip7702ExecutionOptions::Owner(o) => o.fleet_id.as_deref(),
22+
Eip7702ExecutionOptions::SessionKey(s) => s.fleet_id.as_deref(),
23+
}
24+
}
25+
}
26+
1727
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
1828
#[schema(title = "EIP-7702 Owner Execution")]
1929
#[serde(rename_all = "camelCase")]
2030
pub struct Eip7702OwnerExecution {
2131
#[schema(value_type = AddressDef)]
2232
/// The delegated EOA address
2333
pub from: Address,
34+
35+
/// Optional fleet ID to route the transaction to a specific bundler fleet
36+
#[serde(skip_serializing_if = "Option::is_none")]
37+
pub fleet_id: Option<String>,
2438
}
2539

2640
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
@@ -30,7 +44,12 @@ pub struct Eip7702SessionKeyExecution {
3044
#[schema(value_type = AddressDef)]
3145
/// The session key address is your server wallet, which has been granted a session key to the `account_address`
3246
pub session_key_address: Address,
47+
3348
#[schema(value_type = AddressDef)]
3449
/// The account address is the address of a delegated account you want to execute the transaction on. This account has granted a session key to the `session_key_address`
3550
pub account_address: Address,
51+
52+
/// Optional fleet ID to route the transaction to a specific bundler fleet
53+
#[serde(skip_serializing_if = "Option::is_none")]
54+
pub fleet_id: Option<String>,
3655
}

executors/src/eip7702_executor/send.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,27 @@ where
192192
})
193193
.map_err_fail()?;
194194

195-
let chain_auth_headers = job_data
195+
let mut chain_auth_headers = job_data
196196
.rpc_credentials
197197
.to_header_map()
198198
.map_err(|e| Eip7702SendError::InvalidRpcCredentials {
199199
message: e.to_string(),
200200
})
201201
.map_err_fail()?;
202202

203+
// Add optional fleet_id header for bundler routing
204+
if let Some(fleet_id) = job_data.execution_options.fleet_id() {
205+
chain_auth_headers.insert(
206+
"x-executor-fleet-id",
207+
fleet_id
208+
.parse()
209+
.map_err(|e| Eip7702SendError::InvalidRpcCredentials {
210+
message: format!("Invalid fleet_id value: {e}"),
211+
})
212+
.map_err_fail()?,
213+
);
214+
}
215+
203216
let chain = chain.with_new_default_headers(chain_auth_headers);
204217

205218
let owner_address = match &job_data.execution_options {
@@ -230,7 +243,7 @@ where
230243
let mapped_error = Eip7702SendError::DelegationCheckFailed {
231244
inner_error: e.clone(),
232245
};
233-
246+
234247
// Retry only if the error is retryable (network issues, 5xx, etc.)
235248
// Client errors (4xx) like "Invalid chain" or auth errors fail immediately
236249
if is_build_error_retryable(&e) {

0 commit comments

Comments
 (0)