Skip to content

Commit

Permalink
chore(signers): fix errors from primitives upgrade, avoid passing `…
Browse files Browse the repository at this point in the history
…B256` by val (#152)

* chore(signers): fix errors from primitives upgrade

* more fixes
  • Loading branch information
Evalir authored Jan 25, 2024
1 parent d68e110 commit 5fa63d7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/network/src/transaction/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ impl<T: Transaction> Signed<T, Signature> {
&self,
) -> Result<alloy_primitives::Address, alloy_primitives::SignatureError> {
let sighash = self.tx.signature_hash();
self.signature.recover_address_from_prehash(sighash)
self.signature.recover_address_from_prehash(&sighash)
}
}
2 changes: 1 addition & 1 deletion crates/signer-aws/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn sig_from_digest_bytes_trial_recovery(

/// Makes a trial recovery to check whether an RSig corresponds to a known `VerifyingKey`.
fn check_candidate(signature: &Signature, hash: B256, pubkey: &VerifyingKey) -> bool {
signature.recover_from_prehash(hash).map(|key| key == *pubkey).unwrap_or(false)
signature.recover_from_prehash(&hash).map(|key| key == *pubkey).unwrap_or(false)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/signer-gcp/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn sig_from_digest_bytes_trial_recovery(

/// Makes a trial recovery to check whether an RSig corresponds to a known `VerifyingKey`.
fn check_candidate(signature: &Signature, hash: &B256, pubkey: &VerifyingKey) -> bool {
signature.recover_from_prehash(*hash).map(|key| key == *pubkey).unwrap_or(false)
signature.recover_from_prehash(hash).map(|key| key == *pubkey).unwrap_or(false)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/signer-ledger/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ mod tests {
let sighash = tx.signature_hash();
let sig = ledger.sign_transaction(&mut tx).await.unwrap();
assert_eq!(tx.chain_id, None);
assert_eq!(sig.recover_address_from_prehash(sighash).unwrap(), my_address());
assert_eq!(sig.recover_address_from_prehash(&sighash).unwrap(), my_address());
}

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions crates/signer/src/wallet/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ mod tests {
assert_eq!(recovered, address);

// if provided with a hash, it will skip hashing
let recovered2 = signature.recover_address_from_prehash(hash).unwrap();
let recovered2 = signature.recover_address_from_prehash(&hash).unwrap();
assert_eq!(recovered2, address);
}

Expand All @@ -247,7 +247,7 @@ mod tests {

let sig = wallet.sign_transaction_sync(tx)?;
let sighash = tx.signature_hash();
assert_eq!(sig.recover_address_from_prehash(sighash).unwrap(), wallet.address);
assert_eq!(sig.recover_address_from_prehash(&sighash).unwrap(), wallet.address);

let sig_async = wallet.sign_transaction(tx).await.unwrap();
assert_eq!(sig_async, sig);
Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {
let wallet = Wallet::random();
let hash = foo_bar.eip712_signing_hash(&domain);
let sig = wallet.sign_typed_data_sync(&foo_bar, &domain).unwrap();
assert_eq!(sig.recover_address_from_prehash(hash).unwrap(), wallet.address());
assert_eq!(sig.recover_address_from_prehash(&hash).unwrap(), wallet.address());
assert_eq!(wallet.sign_hash_sync(hash).unwrap(), sig);
}

Expand Down

0 comments on commit 5fa63d7

Please sign in to comment.