Skip to content

Commit

Permalink
[rooch-networkgh-2381] fix lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Sep 6, 2024
1 parent e6d8acb commit 0ca3687
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions crates/rooch/src/commands/account/commands/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,20 @@ pub struct VerifyCommand {
#[async_trait]
impl CommandAction<Option<bool>> for VerifyCommand {
async fn execute(self) -> RoochResult<Option<bool>> {
let signature_bytes = hex::decode(self.signature_hash).map_err(|e| {
RoochError::CommandArgumentError(format!("Decode hex failed: {}", e.to_string()))
})?;
let signature_bytes = hex::decode(self.signature_hash)
.map_err(|e| RoochError::CommandArgumentError(format!("Decode hex failed: {}", e)))?;
let signatrue = Signature::from_bytes(&signature_bytes).map_err(|e| {
RoochError::CommandArgumentError(format!(
"Invalid signature argument: {}",
e.to_string()
))
})?;
let pk = Secp256k1PublicKey::from_bytes(signatrue.public_key_bytes()).map_err(|e| {
RoochError::CommandArgumentError(format!("Invalid public key: {}", e.to_string()))
RoochError::CommandArgumentError(format!("Invalid signature argument: {}", e))
})?;
let pk = Secp256k1PublicKey::from_bytes(signatrue.public_key_bytes())
.map_err(|e| RoochError::CommandArgumentError(format!("Invalid public key: {}", e)))?;
let sig = Secp256k1Signature::from_bytes(signatrue.signature_bytes()).map_err(|e| {
RoochError::CommandArgumentError(format!(
"Invalid signature argument: {}",
e.to_string()
))
})?;
let message_hash = hex::decode(self.message_hash).map_err(|e| {
RoochError::CommandArgumentError(format!("Decode hex failed: {}", e.to_string()))
RoochError::CommandArgumentError(format!("Invalid signature argument: {}", e))
})?;
let message_hash = hex::decode(self.message_hash)
.map_err(|e| RoochError::CommandArgumentError(format!("Decode hex failed: {}", e)))?;
pk.verify_with_hash::<Sha256>(&message_hash, &sig)
.map_err(|e| {
RoochError::CommandArgumentError(format!("Failed verification: {}", e.to_string()))
})?;
.map_err(|e| RoochError::CommandArgumentError(format!("Failed verification: {}", e)))?;

if self.json {
Ok(Some(true))
Expand Down

0 comments on commit 0ca3687

Please sign in to comment.