Skip to content

Commit 22fcf5a

Browse files
authored
Merge pull request #9 from HerodotusDev/signer
recover_signer
2 parents bb73166 + a52deef commit 22fcf5a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3"
2222
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
2323
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
2424
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
25-
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
25+
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3", features = [
26+
"k256",
27+
] }
2628
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
2729
alloy-primitives = "0.6.4"
2830
url = "2.5.0"

src/tx.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ impl ConsensusTx {
104104
}
105105
}
106106

107+
pub fn sender(&self) -> Result<alloy_primitives::Address, alloy_primitives::SignatureError> {
108+
match &self.0 {
109+
TxEnvelope::Legacy(tx) => tx.recover_signer(),
110+
TxEnvelope::Eip2930(tx) => tx.recover_signer(),
111+
TxEnvelope::Eip1559(tx) => tx.recover_signer(),
112+
TxEnvelope::Eip4844(tx) => tx.recover_signer(),
113+
}
114+
}
115+
107116
pub fn chain_id(&self) -> Option<ChainId> {
108117
match &self.0 {
109118
TxEnvelope::Legacy(tx) => tx.tx().chain_id(),

0 commit comments

Comments
 (0)