Skip to content

Commit

Permalink
refactor: generate recoverd from auth
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed Sep 10, 2024
1 parent 9e1e305 commit c793c19
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions bins/revme/src/cmd/statetest/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use deserializer::*;
pub use spec::SpecName;

use revm::primitives::{
AccessList, Address, Authorization, Bytes, HashMap, RecoveredAuthorization, Signature,
SignedAuthorization, B256, U256,
AccessList, Address, Authorization, Bytes, HashMap, RecoveredAuthorization, Signature, B256,
U256,
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -121,7 +121,7 @@ pub struct TransactionParts {
pub struct TestAuthorization {
chain_id: U256,
address: Address,
nonce: u64,
nonce: U256,
v: U256,
r: U256,
s: U256,
Expand All @@ -135,19 +135,19 @@ impl TestAuthorization {
}

pub fn into_recovered(self) -> RecoveredAuthorization {
let signed: SignedAuthorization = self.into();
signed.into()
}
}

impl Into<SignedAuthorization> for TestAuthorization {
fn into(self) -> SignedAuthorization {
let auth = Authorization {
let authorization = Authorization {
chain_id: self.chain_id,
address: self.address,
nonce: self.nonce,
nonce: u64::try_from(self.nonce).unwrap(),
};
auth.into_signed(self.signature())
let authority = self
.signature()
.recover_address_from_prehash(&authorization.signature_hash())
.unwrap();
RecoveredAuthorization::new_unchecked(
authorization.into_signed(self.signature()),
Some(authority),
)
}
}

Expand Down

0 comments on commit c793c19

Please sign in to comment.