Skip to content

Commit 1415732

Browse files
committed
fix: cargo clippy-stacks errors
1 parent a46254d commit 1415732

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

clarity/src/libclarity.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ pub mod boot_util {
6060
pub fn boot_code_id(name: &str, mainnet: bool) -> QualifiedContractIdentifier {
6161
let addr = boot_code_addr(mainnet);
6262
QualifiedContractIdentifier::new(
63-
addr.try_into()
64-
.expect("FATAL: boot contract addr is not a legal principal"),
63+
addr.into(),
6564
ContractName::try_from(name.to_string())
6665
.expect("FATAL: boot contract name is not a legal ContractName"),
6766
)

clarity/src/vm/contexts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,8 +2140,8 @@ mod test {
21402140
// not simply rollback the tx and squelch the error as includable.
21412141
let e = env
21422142
.stx_transfer(
2143-
&PrincipalData::try_from(u1).unwrap(),
2144-
&PrincipalData::try_from(u2).unwrap(),
2143+
&PrincipalData::from(u1),
2144+
&PrincipalData::from(u2),
21452145
1000,
21462146
&BuffData::empty(),
21472147
)

clarity/src/vm/test_util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl From<&StacksPrivateKey> for StandardPrincipalData {
108108
&vec![StacksPublicKey::from_private(o)],
109109
)
110110
.unwrap();
111-
StandardPrincipalData::try_from(stacks_addr).unwrap()
111+
StandardPrincipalData::from(stacks_addr)
112112
}
113113
}
114114

clarity/src/vm/tests/simple_apply_eval.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ fn test_secp256k1() {
430430
)
431431
.unwrap();
432432
eprintln!("addr from privk {:?}", &addr);
433-
let principal = addr.try_into().unwrap();
433+
let principal = addr.into();
434434
if let PrincipalData::Standard(data) = principal {
435435
eprintln!("test_secp256k1 principal {:?}", data.to_address());
436436
}
@@ -446,7 +446,7 @@ fn test_secp256k1() {
446446
)
447447
.unwrap();
448448
eprintln!("addr from hex {:?}", addr);
449-
let principal: PrincipalData = addr.try_into().unwrap();
449+
let principal: PrincipalData = addr.into();
450450
if let PrincipalData::Standard(data) = principal.clone() {
451451
eprintln!("test_secp256k1 principal {:?}", data.to_address());
452452
}
@@ -491,8 +491,7 @@ fn test_principal_of_fix() {
491491
.unwrap()],
492492
)
493493
.unwrap()
494-
.try_into()
495-
.unwrap();
494+
.into();
496495
let testnet_principal: PrincipalData = StacksAddress::from_public_keys(
497496
C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
498497
&AddressHashMode::SerializeP2PKH,
@@ -503,8 +502,7 @@ fn test_principal_of_fix() {
503502
.unwrap()],
504503
)
505504
.unwrap()
506-
.try_into()
507-
.unwrap();
505+
.into();
508506

509507
// Clarity2, mainnet, should have a mainnet principal.
510508
assert_eq!(

clarity/src/vm/types/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,9 +1531,8 @@ impl From<StandardPrincipalData> for StacksAddress {
15311531
fn from(o: StandardPrincipalData) -> StacksAddress {
15321532
// should be infallible because it's impossible to construct a StandardPrincipalData with
15331533
// an unsupported version byte
1534-
StacksAddress::new(o.version(), hash::Hash160(o.1)).unwrap_or_else(|_| {
1535-
panic!("FATAL: could not convert a StandardPrincipalData to StacksAddress")
1536-
})
1534+
StacksAddress::new(o.version(), hash::Hash160(o.1))
1535+
.expect("FATAL: could not convert a StandardPrincipalData to StacksAddress")
15371536
}
15381537
}
15391538

0 commit comments

Comments
 (0)