mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: impl SignedTransaction for OpPooledTransaction (#13406)
This commit is contained in:
@ -105,6 +105,18 @@ impl InMemorySize for op_alloy_consensus::OpTypedTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "op")]
|
||||
impl InMemorySize for op_alloy_consensus::OpPooledTransaction {
|
||||
fn size(&self) -> usize {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.size(),
|
||||
Self::Eip2930(tx) => tx.size(),
|
||||
Self::Eip1559(tx) => tx.size(),
|
||||
Self::Eip7702(tx) => tx.size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@ -119,3 +119,40 @@ impl SignedTransaction for PooledTransaction {
|
||||
recover_signer_unchecked(self.signature(), signature_hash)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "op")]
|
||||
impl SignedTransaction for op_alloy_consensus::OpPooledTransaction {
|
||||
fn tx_hash(&self) -> &TxHash {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.hash(),
|
||||
Self::Eip2930(tx) => tx.hash(),
|
||||
Self::Eip1559(tx) => tx.hash(),
|
||||
Self::Eip7702(tx) => tx.hash(),
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> &Signature {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.signature(),
|
||||
Self::Eip2930(tx) => tx.signature(),
|
||||
Self::Eip1559(tx) => tx.signature(),
|
||||
Self::Eip7702(tx) => tx.signature(),
|
||||
}
|
||||
}
|
||||
|
||||
fn recover_signer(&self) -> Option<Address> {
|
||||
let signature_hash = self.signature_hash();
|
||||
recover_signer(self.signature(), signature_hash)
|
||||
}
|
||||
|
||||
fn recover_signer_unchecked_with_buf(&self, buf: &mut Vec<u8>) -> Option<Address> {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.tx().encode_for_signing(buf),
|
||||
Self::Eip2930(tx) => tx.tx().encode_for_signing(buf),
|
||||
Self::Eip1559(tx) => tx.tx().encode_for_signing(buf),
|
||||
Self::Eip7702(tx) => tx.tx().encode_for_signing(buf),
|
||||
}
|
||||
let signature_hash = keccak256(buf);
|
||||
recover_signer_unchecked(self.signature(), signature_hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user