Skip to content

Commit 59a375c

Browse files
committed
only store vault signed access tokens
1 parent 9d577f7 commit 59a375c

File tree

14 files changed

+235
-78
lines changed

14 files changed

+235
-78
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aa-core/src/signer.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::sync::Arc;
22

33
use alloy::{
44
dyn_abi::TypedData,
5-
hex::FromHex,
6-
primitives::{Address, B256, Bytes, hex, keccak256},
5+
primitives::{Address, B256, hex, keccak256},
76
sol,
87
sol_types::{SolCall, SolValue, decode_revert_reason, eip712_domain},
98
};
@@ -71,19 +70,8 @@ impl<C: Chain + Clone> SmartAccountSignerBuilder<C> {
7170

7271
/// Build the signer with computed address and factory pattern detection
7372
pub async fn build(self) -> Result<SmartAccountSigner<C>, EngineError> {
74-
// 1. Parse Account Salt
75-
let salt_data = if self.options.account_salt.starts_with("0x") {
76-
Bytes::from_hex(self.options.account_salt.clone()).map_err(|e| {
77-
EngineError::ValidationError {
78-
message: format!("Failed to parse hex salt: {}", e),
79-
}
80-
})?
81-
} else {
82-
let hex_string = hex::encode(self.options.account_salt.clone());
83-
Bytes::from_hex(hex_string).map_err(|e| EngineError::ValidationError {
84-
message: format!("Failed to encode salt as hex: {}", e),
85-
})?
86-
};
73+
// 1. Parse Account Salt using the helper method
74+
let salt_data = self.options.get_salt_data()?;
8775

8876
// 2. Determine Smart Account
8977
let smart_account = match self.options.smart_account_address {
@@ -269,10 +257,6 @@ impl<C: Chain + Clone> SmartAccountSigner<C> {
269257
let contract =
270258
ERC1271Contract::new(self.smart_account.address, self.chain.provider().clone());
271259

272-
dbg!(self.options.signer_address);
273-
dbg!(hash);
274-
dbg!(signature);
275-
276260
match contract
277261
.isValidSignature(hash, signature_bytes.into())
278262
.call()

aa-core/src/userop/deployment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum DeploymentStatus {
5151
/// Account is currently being deployed by another process
5252
BeingDeployed { stale: bool, lock_id: LockId },
5353

54-
///
54+
/// Account is not deployed
5555
NotDeployed,
5656
}
5757

core/src/execution_options/aa.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::{
22
constants::{DEFAULT_FACTORY_ADDRESS_V0_6, ENTRYPOINT_ADDRESS_V0_6},
33
defs::AddressDef,
4+
error::EngineError,
45
};
5-
use alloy::primitives::Address;
6+
use alloy::{hex::FromHex, primitives::{Address, Bytes}};
67
use schemars::JsonSchema;
78
use serde::{Deserialize, Deserializer, Serialize};
89

@@ -85,6 +86,22 @@ pub struct Erc4337ExecutionOptions {
8586
pub smart_account_address: Option<Address>,
8687
}
8788

89+
impl Erc4337ExecutionOptions {
90+
/// Parse account salt into Bytes, handling both hex and plain string formats
91+
pub fn get_salt_data(&self) -> Result<Bytes, EngineError> {
92+
if self.account_salt.starts_with("0x") {
93+
Bytes::from_hex(&self.account_salt).map_err(|e| EngineError::ValidationError {
94+
message: format!("Failed to parse hex salt: {}", e),
95+
})
96+
} else {
97+
let hex_string = alloy::hex::encode(&self.account_salt);
98+
Bytes::from_hex(hex_string).map_err(|e| EngineError::ValidationError {
99+
message: format!("Failed to encode salt as hex: {}", e),
100+
})
101+
}
102+
}
103+
}
104+
88105
pub fn default_factory_address() -> Address {
89106
DEFAULT_FACTORY_ADDRESS_V0_7
90107
}

core/src/signer.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alloy::{
22
dyn_abi::TypedData,
3-
primitives::{Address, ChainId},
3+
hex::FromHex,
4+
primitives::{Address, Bytes, ChainId},
45
};
56
use serde::{Deserialize, Serialize};
67
use serde_with::{DisplayFromStr, PickFirst, serde_as};
@@ -91,6 +92,22 @@ pub struct Erc4337SigningOptions {
9192
pub chain_id: ChainId,
9293
}
9394

95+
impl Erc4337SigningOptions {
96+
/// Parse account salt into Bytes, handling both hex and plain string formats
97+
pub fn get_salt_data(&self) -> Result<Bytes, EngineError> {
98+
if self.account_salt.starts_with("0x") {
99+
Bytes::from_hex(&self.account_salt).map_err(|e| EngineError::ValidationError {
100+
message: format!("Failed to parse hex salt: {}", e),
101+
})
102+
} else {
103+
let hex_string = alloy::hex::encode(&self.account_salt);
104+
Bytes::from_hex(hex_string).map_err(|e| EngineError::ValidationError {
105+
message: format!("Failed to encode salt as hex: {}", e),
106+
})
107+
}
108+
}
109+
}
110+
94111
/// Configuration options for signing operations
95112
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
96113
#[serde(tag = "type", rename_all = "camelCase")]

executors/src/external_bundler/send.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use alloy::{
2-
hex::FromHex,
3-
primitives::{Address, Bytes, U256},
4-
};
1+
use alloy::primitives::{Address, Bytes, U256};
52
use engine_aa_core::{
63
account_factory::{AccountFactory, get_account_factory},
74
smart_account::{DeterminedSmartAccount, SmartAccount, SmartAccountFromSalt},
@@ -54,6 +51,10 @@ pub struct ExternalBundlerSendJobData {
5451
pub webhook_options: Option<Vec<WebhookOptions>>,
5552

5653
pub rpc_credentials: RpcCredentials,
54+
55+
/// Pregenerated nonce for vault signed tokens
56+
#[serde(skip_serializing_if = "Option::is_none")]
57+
pub pregenerated_nonce: Option<U256>,
5758
}
5859

5960
impl HasWebhookOptions for ExternalBundlerSendJobData {
@@ -262,21 +263,12 @@ where
262263

263264
let chain = chain.with_new_default_headers(chain_auth_headers);
264265

265-
// 2. Parse Account Salt
266-
let salt_data = if job_data.execution_options.account_salt.starts_with("0x") {
267-
Bytes::from_hex(job_data.execution_options.account_salt.clone())
268-
.map_err(|e| ExternalBundlerSendError::InvalidAccountSalt {
269-
message: format!("Failed to parse hex salt: {}", e),
270-
})
271-
.map_err_fail()?
272-
} else {
273-
let hex_string = hex::encode(job_data.execution_options.account_salt.clone());
274-
Bytes::from_hex(hex_string)
266+
// 2. Parse Account Salt using the helper method
267+
let salt_data = job_data.execution_options.get_salt_data()
275268
.map_err(|e| ExternalBundlerSendError::InvalidAccountSalt {
276-
message: format!("Failed to encode salt as hex: {}", e),
269+
message: e.to_string(),
277270
})
278-
.map_err_fail()?
279-
};
271+
.map_err_fail()?;
280272

281273
// 3. Determine Smart Account
282274
let smart_account = match job_data.execution_options.smart_account_address {
@@ -363,15 +355,15 @@ where
363355

364356
tracing::debug!(lock_acquired = ?needs_init_code);
365357

366-
// 5. Get Nonce
367-
let nonce = {
358+
// 5. Get Nonce - use pregenerated nonce if available, otherwise generate random
359+
let nonce = job_data.pregenerated_nonce.unwrap_or_else(|| {
368360
use rand::Rng;
369361
let mut rng = rand::rng();
370362
let limb1: u64 = rng.random();
371363
let limb2: u64 = rng.random();
372364
let limb3: u64 = rng.random();
373365
U256::from_limbs([0, limb1, limb2, limb3])
374-
};
366+
});
375367

376368
// 6. Prepare Init Call Data
377369
let init_call_data = get_account_factory(

0 commit comments

Comments
 (0)