Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cast): setting transaction opts in call --trace #9642

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/cast/bin/cmd/call.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::tx::{CastTxBuilder, SenderKind};
use alloy_network::TransactionBuilder;
use alloy_primitives::{TxKind, U256};
use alloy_rpc_types::{BlockId, BlockNumberOrTag};
use cast::{traces::TraceKind, Cast};
Expand Down Expand Up @@ -187,6 +188,14 @@ impl CallArgs {
env.cfg.disable_block_gas_limit = true;
env.block.gas_limit = U256::MAX;

// setting transaction opt
if let Some(gas_price) = tx.gas_price() {
env.tx.gas_price = U256::from(gas_price);
}
if let Some(gas_limit) = tx.gas_limit() {
env.tx.gas_limit = gas_limit;
}
Comment on lines +191 to +197
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be incomplete, all options in

Transaction options:
      --gas-limit <GAS_LIMIT>
          Gas limit for the transaction
          
          [env: ETH_GAS_LIMIT=]

      --gas-price <PRICE>
          Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either specified in wei, or as a string with a unit type.
          
          Examples: 1ether, 10gwei, 0.01ether
          
          [env: ETH_GAS_PRICE=]

      --priority-gas-price <PRICE>
          Max priority fee per gas for EIP1559 transactions
          
          [env: ETH_PRIORITY_GAS_PRICE=]

      --value <VALUE>
          Ether to send in the transaction, either specified in wei, or as a string with a unit type.
          
          Examples: 1ether, 10gwei, 0.01ether

      --nonce <NONCE>
          Nonce for the transaction

      --legacy
          Send a legacy transaction instead of an EIP1559 transaction.
          
          This is automatically enabled for common networks without EIP1559.

      --blob
          Send a EIP-4844 blob transaction

      --blob-gas-price <BLOB_PRICE>
          Gas price for EIP-4844 blob transaction
          
          [env: ETH_BLOB_GAS_PRICE=]

      --auth <AUTH>
          EIP-7702 authorization list.
          
          Can be either a hex-encoded signed authorization or an address.

      --access-list [<ACCESS_LIST>]
          EIP-2930 access list.
          
          Accepts either a JSON-encoded access list or an empty value to create the access list via an RPC call to `eth_createAccessList`. To retrieve
          only the access list portion, use the `cast access-list` command.

should be handled

#[derive(Clone, Debug, Parser)]
#[command(next_help_heading = "Transaction options")]
pub struct TransactionOpts {
/// Gas limit for the transaction.
#[arg(long, env = "ETH_GAS_LIMIT")]
pub gas_limit: Option<U256>,
/// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either
/// specified in wei, or as a string with a unit type.
///
/// Examples: 1ether, 10gwei, 0.01ether
#[arg(
long,
env = "ETH_GAS_PRICE",
value_parser = parse_ether_value,
value_name = "PRICE"
)]
pub gas_price: Option<U256>,
/// Max priority fee per gas for EIP1559 transactions.
#[arg(
long,
env = "ETH_PRIORITY_GAS_PRICE",
value_parser = parse_ether_value,
value_name = "PRICE"
)]
pub priority_gas_price: Option<U256>,
/// Ether to send in the transaction, either specified in wei, or as a string with a unit type.
///
///
///
/// Examples: 1ether, 10gwei, 0.01ether
#[arg(long, value_parser = parse_ether_value)]
pub value: Option<U256>,
/// Nonce for the transaction.
#[arg(long)]
pub nonce: Option<U64>,
/// Send a legacy transaction instead of an EIP1559 transaction.
///
/// This is automatically enabled for common networks without EIP1559.
#[arg(long)]
pub legacy: bool,
/// Send a EIP-4844 blob transaction.
#[arg(long, conflicts_with = "legacy")]
pub blob: bool,
/// Gas price for EIP-4844 blob transaction.
#[arg(long, conflicts_with = "legacy", value_parser = parse_ether_value, env = "ETH_BLOB_GAS_PRICE", value_name = "BLOB_PRICE")]
pub blob_gas_price: Option<U256>,
/// EIP-7702 authorization list.
///
/// Can be either a hex-encoded signed authorization or an address.
#[arg(long, conflicts_with_all = &["legacy", "blob"])]
pub auth: Option<CliAuthorizationList>,
/// EIP-2930 access list.
///
/// Accepts either a JSON-encoded access list or an empty value to create the access list
/// via an RPC call to `eth_createAccessList`. To retrieve only the access list portion, use
/// the `cast access-list` command.
#[arg(long, value_parser = parse_json::<AccessList>)]
pub access_list: Option<Option<AccessList>>,
}


let trace_mode = TraceMode::Call
.with_debug(debug)
.with_decode_internal(if decode_internal {
Expand Down