diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 939f994..68a682b 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -190,6 +190,9 @@ pub trait TxTrace { /// Get `access_list`. fn access_list(&self) -> AccessList; + /// Get `v`. + fn v(&self) -> u64; + /// Get `signature`. fn signature(&self) -> Result; @@ -205,7 +208,7 @@ pub trait TxTrace { let tx = match self.ty() { 0x0 => { let tx = TxLegacy { - chain_id: if chain_id >= 35 { Some(chain_id) } else { None }, + chain_id: if self.v() >= 35 { Some(chain_id) } else { None }, nonce: self.nonce(), gas_price: self.gas_price(), gas_limit: self.gas_limit(), @@ -391,6 +394,10 @@ impl TxTrace for &T { (*self).access_list() } + fn v(&self) -> u64 { + (*self).v() + } + fn signature(&self) -> Result { (*self).signature() } diff --git a/crates/primitives/src/types/tx.rs b/crates/primitives/src/types/tx.rs index 3220eb8..5b8c372 100644 --- a/crates/primitives/src/types/tx.rs +++ b/crates/primitives/src/types/tx.rs @@ -184,6 +184,10 @@ impl TxTrace for TransactionTrace { self.access_list.clone() } + fn v(&self) -> u64 { + self.v.to() + } + fn signature(&self) -> Result { Signature::from_rs_and_parity(self.r, self.s, self.v) } @@ -262,6 +266,11 @@ impl TxTrace for ArchivedTransactionTrace { rkyv::deserialize::<_, rancor::Error>(&self.access_list).unwrap() } + fn v(&self) -> u64 { + let v: U64 = self.v.into(); + v.to() + } + fn signature(&self) -> Result { let v: U64 = self.v.into(); Signature::from_rs_and_parity(self.r.into(), self.s.into(), v)