Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoscout committed Dec 4, 2024
1 parent 5541bcb commit 8d500e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/did/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,23 +535,21 @@ impl From<Transaction> for alloy::rpc::types::Transaction {
}

impl Transaction {

/// RLP encodes the transaction and recalculates the hash.
/// It does not modify the transaction itself.
/// It returns the calcualted hash and the RLP encoded bytes.
pub fn slow_hash(&self) -> (H256, Vec<u8>) {
let encoded = self.rlp_encoded_2718();
(keccak_hash(&encoded), encoded)
}

/// Encode the transaction according to [EIP-2718] rules. First a 1-byte
/// type flag in the range 0x0-0x7f, then the body of the transaction.
pub fn rlp_encoded_2718(&self) -> Vec<u8> {
use alloy::eips::eip2718::Encodable2718;
let alloy_transaction: alloy::rpc::types::Transaction = self.clone().into();
alloy_transaction.inner.encoded_2718()
}

}

impl Storable for Transaction {
Expand Down Expand Up @@ -1338,7 +1336,7 @@ mod test {

assert_eq!(
alloy::primitives::B256::from_str(&hash).unwrap(),
transaction.slow_hash().0.0
transaction.slow_hash().0 .0
);

let transaction_to_value = serde_json::to_value(transaction).unwrap();
Expand Down
4 changes: 1 addition & 3 deletions src/eth-signer/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use alloy::signers::k256::ecdsa::SigningKey;
use did::error::EvmError;
use did::hash::H160;
use did::integer::U256;
use did::transaction::{
Signature as DidSignature, Transaction as DidTransaction,
};
use did::transaction::{Signature as DidSignature, Transaction as DidTransaction};

use crate::LocalWallet;

Expand Down

0 comments on commit 8d500e7

Please sign in to comment.