Skip to content

Commit d11587f

Browse files
committed
fix build
1 parent 8f7a22d commit d11587f

File tree

108 files changed

+258
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+258
-349
lines changed

src/audit/src/lib/tally.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bech32::{self, Error as Bech32Error, FromBase32};
1+
use bech32::{self, FromBase32};
22
use bech32::{ToBase32, Variant};
33

44
use chain_crypto::{Ed25519, SecretKey};
@@ -11,8 +11,8 @@ use chain_vote::TallyDecryptShare;
1111
use base64::{engine::general_purpose, Engine as _};
1212

1313
use color_eyre::Result;
14-
use rand_core::SeedableRng;
1514
use rand::rngs::StdRng;
15+
use rand_core::SeedableRng;
1616

1717
/// A Bech32_encoded address consists of 3 parts: A Human-Readable Part (HRP) + Separator + Data:
1818
const HRP_PK: &str = "ristretto255_memberpk";
@@ -24,9 +24,9 @@ const HRP_SK: &str = "ristretto255_membersk";
2424
pub fn get_members_secret_share(
2525
key: String,
2626
) -> Result<MemberSecretKey, Box<dyn std::error::Error>> {
27-
let (_hrp, data, _variant) = bech32::decode(&key).map_err(Bech32Error::from)?;
27+
let (_hrp, data, _variant) = bech32::decode(&key)?;
2828

29-
let bytes = Vec::<u8>::from_base32(&data).map_err(Bech32Error::from)?;
29+
let bytes = Vec::<u8>::from_base32(&data)?;
3030

3131
Ok(MemberSecretKey::from_bytes(&bytes).ok_or("member secret key from bytes")?)
3232
}
@@ -36,9 +36,9 @@ pub fn get_members_secret_share(
3636
pub fn get_members_public_share(
3737
key: String,
3838
) -> Result<MemberPublicKey, Box<dyn std::error::Error>> {
39-
let (_hrp, data, _variant) = bech32::decode(&key).map_err(Bech32Error::from)?;
39+
let (_hrp, data, _variant) = bech32::decode(&key)?;
4040

41-
let bytes = Vec::<u8>::from_base32(&data).map_err(Bech32Error::from)?;
41+
let bytes = Vec::<u8>::from_base32(&data)?;
4242

4343
Ok(MemberPublicKey::from_bytes(&bytes).ok_or("member public key from bytes")?)
4444
}

src/catalyst-toolbox/catalyst-toolbox/src/ideascale/models/de/clean_string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ pub fn clean_str(s: &str) -> String {
7474
#[allow(dead_code)]
7575
mod tests {
7676
use proptest::arbitrary::any;
77-
#[allow(unused_imports)]
78-
use serde_json::json;
7977
use proptest::prelude::*;
8078
use proptest::{
8179
arbitrary::{Arbitrary, StrategyFor},
8280
strategy::Map,
8381
};
82+
#[allow(unused_imports)]
83+
use serde_json::json;
8484
use test_strategy::proptest;
8585

8686
use super::*;

src/catalyst-toolbox/snapshot-lib/src/registration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub mod serde_impl {
253253

254254
let addr_type = match addr_type {
255255
// Shelley
256-
0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 => AddrType::Shelley,
256+
0x0..=0x7 => AddrType::Shelley,
257257
// Stake
258258
0xf | 0xe => AddrType::Stake,
259259
_ => {

src/chain-libs/chain-crypto/src/ec/ristretto255.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl From<bool> for Scalar {
254254
// FE + FE
255255
//////////
256256

257-
impl<'a, 'b> Add<&'b Scalar> for &'a Scalar {
257+
impl<'b> Add<&'b Scalar> for &Scalar {
258258
type Output = Scalar;
259259

260260
fn add(self, other: &'b Scalar) -> Scalar {
@@ -268,7 +268,7 @@ std_ops_gen!(Scalar, Add, Scalar, Scalar, add);
268268
// FE - FE
269269
//////////
270270

271-
impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar {
271+
impl<'b> Sub<&'b Scalar> for &Scalar {
272272
type Output = Scalar;
273273

274274
fn sub(self, other: &'b Scalar) -> Scalar {
@@ -282,7 +282,7 @@ std_ops_gen!(Scalar, Sub, Scalar, Scalar, sub);
282282
// FE * FE
283283
//////////
284284

285-
impl<'a, 'b> Mul<&'b Scalar> for &'a Scalar {
285+
impl<'b> Mul<&'b Scalar> for &Scalar {
286286
type Output = Scalar;
287287

288288
fn mul(self, other: &'b Scalar) -> Scalar {
@@ -296,15 +296,15 @@ std_ops_gen!(Scalar, Mul, Scalar, Scalar, mul);
296296
// FE * GE
297297
//////////
298298

299-
impl<'a, 'b> Mul<&'b GroupElement> for &'a Scalar {
299+
impl<'b> Mul<&'b GroupElement> for &Scalar {
300300
type Output = GroupElement;
301301

302302
fn mul(self, other: &'b GroupElement) -> GroupElement {
303303
other * self
304304
}
305305
}
306306

307-
impl<'a, 'b> Mul<&'b Scalar> for &'a GroupElement {
307+
impl<'b> Mul<&'b Scalar> for &GroupElement {
308308
type Output = GroupElement;
309309

310310
fn mul(self, other: &'b Scalar) -> GroupElement {
@@ -332,7 +332,7 @@ impl<'a> Mul<&'a GroupElement> for u64 {
332332
}
333333
}
334334

335-
impl<'a> Mul<u64> for &'a GroupElement {
335+
impl Mul<u64> for &GroupElement {
336336
type Output = GroupElement;
337337

338338
fn mul(self, mut other: u64) -> GroupElement {
@@ -354,7 +354,7 @@ impl<'a> Mul<u64> for &'a GroupElement {
354354
// GE + GE
355355
//////////
356356

357-
impl<'a, 'b> Add<&'b GroupElement> for &'a GroupElement {
357+
impl<'b> Add<&'b GroupElement> for &GroupElement {
358358
type Output = GroupElement;
359359

360360
fn add(self, other: &'b GroupElement) -> GroupElement {
@@ -368,7 +368,7 @@ std_ops_gen!(GroupElement, Add, GroupElement, GroupElement, add);
368368
// GE - GE
369369
//////////
370370

371-
impl<'a, 'b> Sub<&'b GroupElement> for &'a GroupElement {
371+
impl<'b> Sub<&'b GroupElement> for &GroupElement {
372372
type Output = GroupElement;
373373

374374
fn sub(self, other: &'b GroupElement) -> GroupElement {

src/chain-libs/chain-impl-mockchain/src/header/version.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ impl BlockVersion {
7777

7878
pub const fn get_size(self) -> NonZeroUsize {
7979
const SIZE: [NonZeroUsize; 3] = [
80-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_COMMON_SIZE) },
81-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_BFT_SIZE) },
82-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_GP_SIZE) },
80+
NonZeroUsize::new(cstruct::HEADER_COMMON_SIZE).unwrap(),
81+
NonZeroUsize::new(cstruct::HEADER_BFT_SIZE).unwrap(),
82+
NonZeroUsize::new(cstruct::HEADER_GP_SIZE).unwrap(),
8383
];
8484
SIZE[self as usize]
8585
}
8686

8787
pub const fn get_auth_size(self) -> NonZeroUsize {
8888
const SIZE: [NonZeroUsize; 3] = [
89-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_COMMON_SIZE) },
90-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_BFT_AUTHED_SIZE) },
91-
unsafe { NonZeroUsize::new_unchecked(cstruct::HEADER_GP_AUTHED_SIZE) },
89+
NonZeroUsize::new(cstruct::HEADER_COMMON_SIZE).unwrap(),
90+
NonZeroUsize::new(cstruct::HEADER_BFT_AUTHED_SIZE).unwrap(),
91+
NonZeroUsize::new(cstruct::HEADER_GP_AUTHED_SIZE).unwrap(),
9292
];
9393
SIZE[self as usize]
9494
}

src/chain-libs/chain-impl-mockchain/src/leadership/bft.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct LeadershipData {
1717
impl LeadershipData {
1818
/// Create a new BFT leadership
1919
pub fn new(leaders: Arc<[BftLeaderId]>) -> Option<Self> {
20-
if leaders.len() == 0 {
20+
if leaders.is_empty() {
2121
return None;
2222
}
2323

src/chain-libs/chain-impl-mockchain/src/ledger/governance/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct GovernanceAcceptanceCriteria {
3434

3535
impl Default for GovernanceAcceptanceCriteria {
3636
fn default() -> Self {
37-
const CENT: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(100) };
37+
const CENT: NonZeroU64 = NonZeroU64::new(100).unwrap();
3838

3939
Self {
4040
minimum_stake_participation: Some(Ratio {

src/chain-libs/chain-impl-mockchain/src/multiverse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<State> Multiverse<State> {
110110
pub fn insert(&mut self, chain_length: ChainLength, k: HeaderId, st: State) -> Ref<State> {
111111
self.states_by_chain_length
112112
.entry(chain_length)
113-
.or_insert_with(HashSet::new)
113+
.or_default()
114114
.insert(k);
115115
let state = Arc::new(st);
116116
self.states_by_hash

src/chain-libs/chain-impl-mockchain/src/setting.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,8 @@ impl Settings {
266266
self.transaction_max_expiry_epochs,
267267
));
268268

269-
match &self.reward_params {
270-
Some(p) => params.push(ConfigParam::RewardParams(p.clone())),
271-
None => (),
272-
};
273-
match &self.treasury_params {
274-
Some(p) => params.push(ConfigParam::TreasuryParams(*p)),
275-
None => (),
276-
};
269+
if let Some(p) = &self.reward_params { params.push(ConfigParam::RewardParams(p.clone())) };
270+
if let Some(p) = &self.treasury_params { params.push(ConfigParam::TreasuryParams(*p)) };
277271

278272
debug_assert_eq!(self, &Settings::new().try_apply(&params).unwrap());
279273

src/chain-libs/chain-impl-mockchain/src/testing/arbitrary/address.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,18 @@ impl Arbitrary for AddressDataValue {
105105
impl ArbitraryAddressDataValueVec {
106106
pub fn utxos(&self) -> Vec<AddressDataValue> {
107107
self.0
108-
.iter()
109-
.cloned()
110-
.filter(|x| matches!(x.address_data.kind(), Kind::Single { .. }))
108+
.iter().filter(|&x| matches!(x.address_data.kind(), Kind::Single { .. })).cloned()
111109
.collect()
112110
}
113111
pub fn accounts(&self) -> Vec<AddressDataValue> {
114112
self.0
115-
.iter()
116-
.cloned()
117-
.filter(|x| matches!(x.address_data.kind(), Kind::Account { .. }))
113+
.iter().filter(|&x| matches!(x.address_data.kind(), Kind::Account { .. })).cloned()
118114
.collect()
119115
}
120116

121117
pub fn delegations(&self) -> Vec<AddressDataValue> {
122118
self.0
123-
.iter()
124-
.cloned()
125-
.filter(|x| matches!(x.address_data.kind(), Kind::Group { .. }))
119+
.iter().filter(|&x| matches!(x.address_data.kind(), Kind::Group { .. })).cloned()
126120
.collect()
127121
}
128122
}

0 commit comments

Comments
 (0)