Skip to content

Commit

Permalink
nits (#310)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Alejandro Gutierrez Sandoval <[email protected]>
  • Loading branch information
friedger and CAGS295 authored Oct 20, 2023
1 parent 462562e commit 25f1447
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions stacks-core/src/crypto/wif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl WIF {
{
Ok(())
} else {
Err(StacksError::InvalidData("WIF is invalid"))
Err(StacksError::InvalidData("WIF is invalid".into()))
}
}

Expand All @@ -62,7 +62,7 @@ impl WIF {
match WIFPrefix::from_repr(self.0[0]) {
Some(WIFPrefix::Mainnet) => Ok(Network::Mainnet),
Some(WIFPrefix::Testnet) => Ok(Network::Testnet),
_ => Err(StacksError::InvalidData("Unknown network byte")),
_ => Err(StacksError::InvalidData("Unknown network byte".into())),
}
}

Expand Down
2 changes: 1 addition & 1 deletion stacks-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub enum StacksError {
CodecError(#[from] CodecError),
#[error("Invalid data: {0}")]
/// Invalid data
InvalidData(&'static str),
InvalidData(String),
/// BIP32 Error
#[error("BIP32 error: {0}")]
BIP32(#[from] bdk::bitcoin::util::bip32::Error),
Expand Down
12 changes: 7 additions & 5 deletions stacks-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,20 @@ impl TryFrom<String> for PrincipalData {
2 => {
let address = StacksAddress::try_from(parts[0])?;
let contract_name =
ContractName::new(parts[1]).map_err(|_err| {
StacksError::InvalidData("Invalid contract name")
ContractName::new(parts[1]).map_err(|err| {
StacksError::InvalidData(format!(
"Invalid contract name from {value}: {err}"
))
})?;

Ok(Self::Contract(
StandardPrincipalData::from(address),
contract_name,
))
}
_ => Err(StacksError::InvalidData(
"Principal data may contain at most 1 dot character",
)),
_ => Err(StacksError::InvalidData(format!(
"Principal data from {value} may contain at most 1 dot character"
))),
}
}
}
Expand Down

0 comments on commit 25f1447

Please sign in to comment.