Skip to content

feat: cast mktx raw signaturee #10377

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Ayushdubey86
Copy link
Contributor

@Ayushdubey86 Ayushdubey86 commented Apr 26, 2025

Hello @yash-atreya @zerosnacks @grandizzy

Please review this pr, it closes #10167

Comment on lines +55 to +62
#[arg(long, value_name = "V")]
v: Option<u64>,

#[arg(long, value_name = "R")]
r: Option<String>,

#[arg(long, value_name = "S")]
s: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

this should be a single argument that tis the hex encoded signature

Comment on lines +130 to +161
let raw_unsigned_hex = tx_builder.build_unsigned_raw(from).await?;

if let (Some(v), Some(r_hex), Some(s_hex)) = (v, r.as_ref(), s.as_ref()) {
let raw_unsigned_bytes = hex::decode(raw_unsigned_hex.trim_start_matches("0x"))?;
let mut buf = raw_unsigned_bytes.as_slice();
let unsigned_tx: UnsignedTransaction = UnsignedTransaction::decode(&mut buf)?;

let r_bytes = hex::decode(r_hex.trim_start_matches("0x"))?;
let s_bytes = hex::decode(s_hex.trim_start_matches("0x"))?;

if r_bytes.len() != 32 || s_bytes.len() != 32 {
eyre::bail!("r and s must be 32 bytes each");
}

let r = U256::from_be_slice(&r_bytes);
let s = U256::from_be_slice(&s_bytes);
let v = U64::from(v);

let mut out = Vec::new();
let fields: &[&dyn alloy_rlp::Encodable] = &[
&unsigned_tx.nonce,
&unsigned_tx.gas_price,
&unsigned_tx.gas_limit,
&unsigned_tx.to,
&unsigned_tx.value,
&unsigned_tx.data,
&v,
&r,
&s,
];

alloy_rlp::encode_list::<&dyn alloy_rlp::Encodable, dyn alloy_rlp::Encodable>(
Copy link
Member

Choose a reason for hiding this comment

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

this can removed entirely

this should be much simpler, just checking if the signature is there , decode it and then encode with signature:

https://github.com/alloy-rs/alloy/blob/ea2dc62620b34ce320e2232b2dbe7c218a1139ce/crates/consensus/src/transaction/rlp.rs#L53-L53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat(cast mktx --raw-unsigned): add way to accept signatures to build a transaction
2 participants