Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Nov 8, 2024
1 parent 4faa5ad commit 3340b66
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 38 deletions.
28 changes: 4 additions & 24 deletions app-libs/sgx-runtime/pallets/notes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};
use frame_support::{
dispatch::DispatchResult,
pallet_prelude::Get,
traits::{Currency, ExistenceRequirement, OnTimestampSet},
PalletId,
};
use itp_randomness::Randomness;
use log::*;
use frame_support::{pallet_prelude::Get, traits::Currency};
pub use pallet::*;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{CheckedDiv, Hash, Saturating, Zero},
SaturatedConversion,
};
use sp_std::{cmp::min, ops::Rem, vec, vec::Vec};

pub use pallet::*;
use sp_std::{vec, vec::Vec};

pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
Expand Down Expand Up @@ -45,7 +34,6 @@ pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_runtime::traits::Zero;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
Expand All @@ -56,8 +44,6 @@ pub mod pallet {
/// Configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config + pallet_timestamp::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

#[pallet::constant]
type MomentsPerDay: Get<Self::Moment>;

Expand All @@ -68,12 +54,6 @@ pub mod pallet {
type MaxNoteSize: Get<u32>;
}

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
BuckedPurged { index: BucketIndex },
}

#[pallet::error]
pub enum Error<T> {
BucketPurged,
Expand Down Expand Up @@ -128,7 +108,7 @@ pub mod pallet {
link_to: Vec<T::AccountId>,
payload: Vec<u8>,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
ensure_signed(origin)?;
ensure!(link_to.len() < 3, Error::<T>::TooManyLinkedAccounts);
ensure!(payload.len() <= T::MaxNoteSize::get() as usize, Error::<T>::NoteTooLong);
let bucket_index = 0; // todo
Expand Down
3 changes: 1 addition & 2 deletions app-libs/sgx-runtime/pallets/notes/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ frame_support::construct_runtime!(
System: frame_system::{Pallet, Call, Config, Event<T>},
Balances: pallet_balances::{Pallet, Call, Config<T>, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Notes: dut::{Pallet, Call, Event<T>},
Notes: dut::{Pallet, Call},
}
);

Expand All @@ -76,7 +76,6 @@ parameter_types! {
pub const MomentsPerDay: u64 = 86_400_000; // [ms/d]
}
impl dut::Config for Test {
type RuntimeEvent = RuntimeEvent;
type MomentsPerDay = MomentsPerDay;
type Currency = Balances;
type MaxNoteSize = ConstU32<512>;
Expand Down
2 changes: 1 addition & 1 deletion app-libs/sgx-runtime/pallets/notes/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/
use crate::{mock::*, BalanceOf, Error, Event, TrustedNote};
use crate::{mock::*, BalanceOf, Error, TrustedNote};
use codec::Encode;
use frame_support::{
assert_err, assert_ok,
Expand Down
5 changes: 2 additions & 3 deletions app-libs/sgx-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ impl pallet_guess_the_number::Config for Runtime {
}

impl pallet_notes::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MomentsPerDay = MomentsPerDay;
type Currency = Balances;
type MaxNoteSize = ConstU32<512>;
Expand All @@ -338,7 +337,7 @@ construct_runtime!(

GuessTheNumber: pallet_guess_the_number::{Pallet, Call, Storage, Event<T>} = 30,

Notes: pallet_notes::{Pallet, Call, Storage, Event<T>} = 40,
Notes: pallet_notes::{Pallet, Call, Storage} = 40,
}
);

Expand Down Expand Up @@ -367,7 +366,7 @@ construct_runtime!(

GuessTheNumber: pallet_guess_the_number::{Pallet, Call, Storage, Event<T>} = 30,

Notes: pallet_notes::{Pallet, Call, Storage, Event<T>} = 40,
Notes: pallet_notes::{Pallet, Call, Storage} = 40,
}
);

Expand Down
4 changes: 3 additions & 1 deletion app-libs/stf/src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ impl ExecuteGetter for TrustedGetterSigned {
// todo: do we need pagination here?
let mut notes = Vec::new();
for note_index in note_indices {
Notes::notes(bucket_index, note_index).map(|note| notes.push(note));
if let Some(note) = Notes::notes(bucket_index, note_index) {
notes.push(note)
};
}
std::println!("⣿STF⣿ 🔍 TrustedGetter query: notes for ⣿⣿⣿",);
Some(notes.encode())
Expand Down
2 changes: 1 addition & 1 deletion app-libs/stf/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub fn store_note(
link_to: Vec<AccountId>,
) -> Result<(), StfError> {
// i.e. unshielding can go to self or to other. make sure we don't duplicate links
let mut unique_links = link_to.clone();
let mut unique_links = link_to;
unique_links.sort_unstable();
unique_links.dedup();

Expand Down
2 changes: 1 addition & 1 deletion app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ where
.map_err(|e| {
Self::Error::Dispatch(format!("Balance Transfer error: {:?}", e.error))
})?;
store_note(&from, self.call, vec![from.clone(), to.clone()])?;
store_note(&from, self.call, vec![from.clone(), to])?;
Ok(())
},
TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/trusted_base_cli/commands/get_note_buckets_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
trusted_cli::TrustedCli, trusted_operation::perform_trusted_operation, Cli, CliResult,
CliResultOk,
};
use ita_stf::{Getter, ParentchainsInfo, PublicGetter, TrustedCallSigned};
use ita_stf::{Getter, PublicGetter, TrustedCallSigned};
use itp_stf_primitives::types::TrustedOperation;
use pallet_notes::BucketInfo;

Expand Down
6 changes: 2 additions & 4 deletions cli/src/trusted_base_cli/commands/get_notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*/
use crate::{
trusted_cli::TrustedCli,
trusted_command_utils::{get_balance, get_pair_from_str},
trusted_operation::perform_trusted_operation,
Cli, CliResult, CliResultOk,
trusted_cli::TrustedCli, trusted_command_utils::get_pair_from_str,
trusted_operation::perform_trusted_operation, Cli, CliResult, CliResultOk,
};
use codec::Decode;
use ita_stf::{
Expand Down

0 comments on commit 3340b66

Please sign in to comment.