-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: master
Are you sure you want to change the base?
feat: cast mktx raw signaturee #10377
Conversation
#[arg(long, value_name = "V")] | ||
v: Option<u64>, | ||
|
||
#[arg(long, value_name = "R")] | ||
r: Option<String>, | ||
|
||
#[arg(long, value_name = "S")] | ||
s: Option<String>, |
There was a problem hiding this comment.
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
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>( |
There was a problem hiding this comment.
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:
Hello @yash-atreya @zerosnacks @grandizzy
Please review this pr, it closes #10167