Skip to content

Commit 837e4c2

Browse files
committed
support deployment transactions (without "to")
1 parent 7af2c63 commit 837e4c2

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

aa-core/src/smart_account/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub trait SmartAccount {
3838
/// Encode a transaction call to the account
3939
fn encode_execute(&self, tx: &InnerTransaction) -> Bytes {
4040
executeCall {
41-
_target: tx.to,
41+
_target: tx.to.unwrap_or(Address::ZERO),
4242
_value: tx.value,
4343
_calldata: tx.data.clone(),
4444
}
@@ -49,7 +49,10 @@ pub trait SmartAccount {
4949
/// Encode a batch transaction call to the account
5050
fn encode_execute_batch(&self, batch: &Vec<InnerTransaction>) -> Bytes {
5151
executeBatchCall {
52-
_target: batch.iter().map(|tx| tx.to).collect(),
52+
_target: batch
53+
.iter()
54+
.map(|tx| tx.to.unwrap_or(Address::ZERO))
55+
.collect(),
5356
_value: batch.iter().map(|tx| tx.value).collect(),
5457
_calldata: batch.iter().map(|tx| tx.data.clone()).collect(),
5558
}

core/src/transaction.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
use crate::defs::{AddressDef, BytesDef, U256Def};
22
use alloy::primitives::{Address, Bytes, U256};
3-
use schemars::JsonSchema;
43
use serde::{Deserialize, Serialize};
54

65
/// # InnerTransaction
76
/// This is the actual encoded inner transaction data that will be sent to the blockchain.
8-
#[derive(Deserialize, Serialize, Debug, Clone, JsonSchema, utoipa::ToSchema)]
7+
#[derive(Deserialize, Serialize, Debug, Clone, utoipa::ToSchema)]
98
pub struct InnerTransaction {
10-
#[schemars(with = "AddressDef")]
11-
#[schema(value_type = AddressDef)]
12-
pub to: Address,
9+
#[schema(value_type = Option<AddressDef>)]
10+
pub to: Option<Address>,
1311

14-
#[schemars(with = "BytesDef")]
1512
#[schema(value_type = BytesDef)]
1613
#[serde(default)]
1714
pub data: Bytes,
1815

19-
#[schemars(with = "U256Def")]
2016
#[schema(value_type = U256Def)]
2117
#[serde(default)]
2218
pub value: U256,

server/src/http/dyn_contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl ContractCall {
312312
value: U256,
313313
) -> InnerTransaction {
314314
InnerTransaction {
315-
to: prepared.target,
315+
to: Some(prepared.target),
316316
data: prepared.call_data.clone(),
317317
value,
318318
}

0 commit comments

Comments
 (0)