From e747b1e863fe647ca45489ba59c867a47c937fdc Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Mon, 11 Nov 2024 10:52:04 +0100 Subject: [PATCH] feat(consensus): `TxEnvelope::signature` (#1634) * feat(consensus): `TxEnvelope::signature` * const --- crates/consensus/src/transaction/envelope.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index 9af4c1a5d27..6ac86b18d38 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -9,7 +9,7 @@ use alloy_eips::{ eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718}, eip2930::AccessList, }; -use alloy_primitives::{Bytes, TxKind, B256}; +use alloy_primitives::{Bytes, PrimitiveSignature as Signature, TxKind, B256}; use alloy_rlp::{Decodable, Encodable}; use core::fmt; @@ -272,6 +272,17 @@ impl TxEnvelope { } } + /// Return the reference to signature. + pub const fn signature(&self) -> &Signature { + match self { + Self::Legacy(tx) => tx.signature(), + Self::Eip2930(tx) => tx.signature(), + Self::Eip1559(tx) => tx.signature(), + Self::Eip4844(tx) => tx.signature(), + Self::Eip7702(tx) => tx.signature(), + } + } + /// Return the hash of the inner Signed. #[doc(alias = "transaction_hash")] pub const fn tx_hash(&self) -> &B256 {