Skip to content

Commit

Permalink
Remove shallow constructor function.
Browse files Browse the repository at this point in the history
`CasperPrivateKey` can be created directly, as every
field is public.
  • Loading branch information
koxu1996 committed Feb 7, 2024
1 parent ade64d1 commit 0744fd5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions kairos-cli/bin/crypto/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ use crate::crypto::error::CryptoError;
pub struct CasperPrivateKey(pub casper_types::SecretKey);

impl CasperPrivateKey {
pub fn from_key(public_key: casper_types::SecretKey) -> Self {
Self(public_key)
}

pub fn from_file(file_path: &str) -> Result<Self, CryptoError> {
let secret_key = casper_types::SecretKey::from_file(file_path)
.map_err(|_e| CryptoError::FailedToParseKey {})?;
Expand Down
2 changes: 1 addition & 1 deletion kairos-cli/bin/crypto/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl CasperSigner {
let secret_key =
SecretKey::from_file(secret_key_path).map_err(|_| CryptoError::FailedToParseKey {})?;

Ok(Self::from_key(CasperPrivateKey::from_key(secret_key)))
Ok(Self::from_key(CasperPrivateKey(secret_key)))
}

fn get_public_key(&self) -> CasperPublicKey {
Expand Down

0 comments on commit 0744fd5

Please sign in to comment.