Skip to content

Commit

Permalink
Merge branch 'develop' into chore/clippy-unnecesary-to-owned-unwrap-o…
Browse files Browse the repository at this point in the history
…r-default
  • Loading branch information
obycode authored Jan 27, 2025
2 parents ccbf1af + a5a6ce6 commit b2c34d9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
3 changes: 1 addition & 2 deletions clarity/src/libclarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ pub mod boot_util {
pub fn boot_code_id(name: &str, mainnet: bool) -> QualifiedContractIdentifier {
let addr = boot_code_addr(mainnet);
QualifiedContractIdentifier::new(
addr.try_into()
.expect("FATAL: boot contract addr is not a legal principal"),
addr.into(),
ContractName::try_from(name.to_string())
.expect("FATAL: boot contract name is not a legal ContractName"),
)
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,8 +2140,8 @@ mod test {
// not simply rollback the tx and squelch the error as includable.
let e = env
.stx_transfer(
&PrincipalData::try_from(u1).unwrap(),
&PrincipalData::try_from(u2).unwrap(),
&PrincipalData::from(u1),
&PrincipalData::from(u2),
1000,
&BuffData::empty(),
)
Expand Down
2 changes: 1 addition & 1 deletion clarity/src/vm/test_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl From<&StacksPrivateKey> for StandardPrincipalData {
&vec![StacksPublicKey::from_private(o)],
)
.unwrap();
StandardPrincipalData::try_from(stacks_addr).unwrap()
StandardPrincipalData::from(stacks_addr)
}
}

Expand Down
10 changes: 4 additions & 6 deletions clarity/src/vm/tests/simple_apply_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ fn test_secp256k1() {
)
.unwrap();
eprintln!("addr from privk {:?}", &addr);
let principal = addr.try_into().unwrap();
let principal = addr.into();
if let PrincipalData::Standard(data) = principal {
eprintln!("test_secp256k1 principal {:?}", data.to_address());
}
Expand All @@ -446,7 +446,7 @@ fn test_secp256k1() {
)
.unwrap();
eprintln!("addr from hex {:?}", addr);
let principal: PrincipalData = addr.try_into().unwrap();
let principal: PrincipalData = addr.into();
if let PrincipalData::Standard(data) = principal.clone() {
eprintln!("test_secp256k1 principal {:?}", data.to_address());
}
Expand Down Expand Up @@ -491,8 +491,7 @@ fn test_principal_of_fix() {
.unwrap()],
)
.unwrap()
.try_into()
.unwrap();
.into();
let testnet_principal: PrincipalData = StacksAddress::from_public_keys(
C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
&AddressHashMode::SerializeP2PKH,
Expand All @@ -503,8 +502,7 @@ fn test_principal_of_fix() {
.unwrap()],
)
.unwrap()
.try_into()
.unwrap();
.into();

// Clarity2, mainnet, should have a mainnet principal.
assert_eq!(
Expand Down
5 changes: 2 additions & 3 deletions clarity/src/vm/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,9 +1531,8 @@ impl From<StandardPrincipalData> for StacksAddress {
fn from(o: StandardPrincipalData) -> StacksAddress {
// should be infallible because it's impossible to construct a StandardPrincipalData with
// an unsupported version byte
StacksAddress::new(o.version(), hash::Hash160(o.1)).unwrap_or_else(|_| {
panic!("FATAL: could not convert a StandardPrincipalData to StacksAddress")
})
StacksAddress::new(o.version(), hash::Hash160(o.1))
.expect("FATAL: could not convert a StandardPrincipalData to StacksAddress")
}
}

Expand Down

0 comments on commit b2c34d9

Please sign in to comment.