Skip to content

Commit 709116e

Browse files
authored
fix(cast): batch-send handling by clearing to/value fields (foundry-rs#14250)
1 parent de5b160 commit 709116e

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

crates/cast/src/cmd/batch_send.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::{
99
cmd::send::cast_send,
1010
tx::{self, CastTxBuilder, CastTxSender, SendTxOpts},
1111
};
12-
use alloy_network::{EthereumWallet, TransactionBuilder};
13-
use alloy_primitives::{Bytes, U256};
12+
use alloy_network::EthereumWallet;
13+
use alloy_primitives::Bytes;
1414
use alloy_provider::{Provider, ProviderBuilder as AlloyProviderBuilder};
1515
use alloy_signer::Signer;
1616
use clap::Parser;
@@ -119,9 +119,7 @@ impl BatchSendArgs {
119119
let builder = builder.with_to(first_call_to.map(Into::into)).await?;
120120

121121
// Use empty sig/args since we're using calls directly
122-
let mut builder = builder.with_code_sig_and_args(None, None, vec![]).await?;
123-
builder.tx.clear_kind();
124-
builder.tx.set_value(U256::ZERO);
122+
let builder = builder.with_code_sig_and_args(None, None, vec![]).await?;
125123

126124
let timeout = send_tx.timeout.unwrap_or(config.transaction_timeout);
127125

crates/cast/src/tx.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ where
484484
let sender = sender.into();
485485
self.prepare(&sender);
486486

487+
// For batch transactions with calls, clear `to` and `value` so the node correctly
488+
// identifies this as an AA batch transaction. The `calls` field determines the actual
489+
// targets. If `to` is set, `build_aa()` would add a spurious extra call.
490+
self.tx.clear_batch_to();
491+
487492
// resolve
488493
let tx_nonce = self.resolve_nonce(sender.address(), fill).await?;
489494
self.resolve_auth(&sender, tx_nonce).await?;

crates/common/src/transactions/builder.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ pub trait FoundryTransactionBuilder<N: Network>: TransactionBuilder<N> {
249249
/// No-op for non-Tempo networks.
250250
fn convert_create_to_call(&mut self) {}
251251

252+
/// Clears the `to` and `value` fields for batch transactions that use `calls`.
253+
///
254+
/// In Tempo AA batch transactions, targets are specified in the `calls` field, not in `to`.
255+
/// If `to` is set, `build_aa()` would add a spurious extra call. Must be called after
256+
/// `prepare()` sets `kind`/`to` but before gas estimation.
257+
/// No-op for non-Tempo networks.
258+
fn clear_batch_to(&mut self) {}
259+
252260
/// Signs the transaction using an access key (keychain mode).
253261
///
254262
/// If `key_authorization` is provided and the key is not yet provisioned on-chain,
@@ -440,6 +448,13 @@ impl FoundryTransactionBuilder<TempoNetwork> for <TempoNetwork as Network>::Tran
440448
}
441449
}
442450

451+
fn clear_batch_to(&mut self) {
452+
if !self.calls.is_empty() {
453+
self.inner.to = None;
454+
self.inner.value = None;
455+
}
456+
}
457+
443458
fn sign_with_access_key(
444459
mut self,
445460
provider: &impl Provider<TempoNetwork>,

0 commit comments

Comments
 (0)