Skip to content

Commit

Permalink
Merge pull request #9 from HerodotusDev/signer
Browse files Browse the repository at this point in the history
recover_signer
  • Loading branch information
rkdud007 committed Apr 30, 2024
2 parents bb73166 + a52deef commit 22fcf5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3"
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3", features = [
"k256",
] }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" }
alloy-primitives = "0.6.4"
url = "2.5.0"
Expand Down
9 changes: 9 additions & 0 deletions src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ impl ConsensusTx {
}
}

pub fn sender(&self) -> Result<alloy_primitives::Address, alloy_primitives::SignatureError> {
match &self.0 {
TxEnvelope::Legacy(tx) => tx.recover_signer(),
TxEnvelope::Eip2930(tx) => tx.recover_signer(),
TxEnvelope::Eip1559(tx) => tx.recover_signer(),
TxEnvelope::Eip4844(tx) => tx.recover_signer(),
}
}

pub fn chain_id(&self) -> Option<ChainId> {
match &self.0 {
TxEnvelope::Legacy(tx) => tx.tx().chain_id(),
Expand Down

0 comments on commit 22fcf5a

Please sign in to comment.