Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
".git/.scripts/commands/fmt/fmt.sh"
Browse files Browse the repository at this point in the history
  • Loading branch information
command-bot committed Jun 12, 2023
1 parent 180ac42 commit 7e66913
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 88 deletions.
4 changes: 2 additions & 2 deletions frame/asset-conversion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ pub mod pallet {
let reserve_out = T::HigherPrecisionBalance::from(*reserve_out);

if reserve_in.is_zero() || reserve_out.is_zero() {
return Err(Error::<T>::ZeroLiquidity.into());
return Err(Error::<T>::ZeroLiquidity.into())
}

let amount_in_with_fee = amount_in
Expand Down Expand Up @@ -1076,7 +1076,7 @@ pub mod pallet {
let pool_id = Self::get_pool_id(asset1.clone(), asset2.clone());
let new_element = pools.try_insert(pool_id).expect("can't get here");
if !new_element {
return Err(Error::<T>::NonUniquePath.into());
return Err(Error::<T>::NonUniquePath.into())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions frame/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ impl<T: Config> Pallet<T> {

fn initialize(authorities: &Vec<T::BeefyId>) -> Result<(), ()> {
if authorities.is_empty() {
return Ok(());
return Ok(())
}

if !<Authorities<T>>::get().is_empty() {
return Err(());
return Err(())
}

let bounded_authorities =
Expand Down
2 changes: 1 addition & 1 deletion frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod pallet_test {
}

pub fn always_error(_origin: OriginFor<T>) -> DispatchResult {
return Err("I always fail".into());
return Err("I always fail".into())
}
}
}
Expand Down
30 changes: 13 additions & 17 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub mod pallet {
let remaining_weight = remaining_weight.saturating_sub(weight);

if !matches!(result, Completed | NoMigrationInProgress) {
return weight;
return weight
}

ContractInfo::<T>::process_deletion_queue_batch(remaining_weight)
Expand Down Expand Up @@ -575,7 +575,7 @@ pub mod pallet {
let contract = if let Some(contract) = contract {
contract
} else {
return Err(<Error<T>>::ContractNotFound.into());
return Err(<Error<T>>::ContractNotFound.into())
};
<PrefabWasmModule<T>>::add_user(code_hash)?;
<PrefabWasmModule<T>>::remove_user(contract.code_hash);
Expand Down Expand Up @@ -759,15 +759,12 @@ pub mod pallet {
let (result, weight) = Migration::<T>::migrate(weight_limit);

match result {
Completed => {
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::No })
},
InProgress { steps_done, .. } if steps_done > 0 => {
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::No })
},
InProgress { .. } => {
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::Yes })
},
Completed =>
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::No }),
InProgress { steps_done, .. } if steps_done > 0 =>
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::No }),
InProgress { .. } =>
Ok(PostDispatchInfo { actual_weight: Some(weight), pays_fee: Pays::Yes }),
NoMigrationInProgress | NoMigrationPerformed => {
let err: DispatchError = <Error<T>>::NoMigrationPerformed.into();
Err(err.with_weight(T::WeightInfo::migrate()))
Expand Down Expand Up @@ -1114,7 +1111,7 @@ trait Invokable<T: Config> {
gas_meter: GasMeter::new(gas_limit),
storage_deposit: Default::default(),
result: Err(ExecError { error: e.into(), origin: ErrorOrigin::Caller }),
};
}
}

executing_contract::using_once(&mut false, || {
Expand Down Expand Up @@ -1172,13 +1169,12 @@ impl<T: Config> Invokable<T> for CallInput<T> {
let mut storage_meter =
match StorageMeter::new(&origin, common.storage_deposit_limit, common.value) {
Ok(meter) => meter,
Err(err) => {
Err(err) =>
return InternalOutput {
result: Err(err.into()),
gas_meter,
storage_deposit: Default::default(),
}
},
},
};
let schedule = T::Schedule::get();
let result = ExecStack::<T, PrefabWasmModule<T>>::run_call(
Expand Down Expand Up @@ -1294,7 +1290,7 @@ macro_rules! ensure_no_migration_in_progress {
debug_message: Vec::new(),
result: Err(Error::<T>::MigrationInProgress.into()),
events: None,
};
}
}
};
}
Expand Down Expand Up @@ -1448,7 +1444,7 @@ impl<T: Config> Pallet<T> {
/// Query storage of a specified contract under a specified key.
pub fn get_storage(address: T::AccountId, key: Vec<u8>) -> GetStorageResult {
if Migration::<T>::in_progress() {
return Err(ContractAccessError::MigrationInProgress);
return Err(ContractAccessError::MigrationInProgress)
}
let contract_info =
ContractInfoOf::<T>::get(&address).ok_or(ContractAccessError::DoesntExist)?;
Expand Down
40 changes: 19 additions & 21 deletions frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ impl<T: Config> Pallet<T> {
.map_err(ElectionError::DataProvider)?;

if targets.len() > target_limit || voters.len() > voter_limit {
return Err(ElectionError::DataProvider("Snapshot too big for submission."));
return Err(ElectionError::DataProvider("Snapshot too big for submission."))
}

let mut desired_targets = <Pallet<T> as ElectionProviderBase>::desired_targets_checked()
Expand Down Expand Up @@ -1592,14 +1592,14 @@ impl<T: Config> Pallet<T> {
// - [`DesiredTargets`] exists if and only if [`Snapshot`] is present.
// - [`SnapshotMetadata`] exist if and only if [`Snapshot`] is present.
fn try_state_snapshot() -> Result<(), TryRuntimeError> {
if <Snapshot<T>>::exists()
&& <SnapshotMetadata<T>>::exists()
&& <DesiredTargets<T>>::exists()
if <Snapshot<T>>::exists() &&
<SnapshotMetadata<T>>::exists() &&
<DesiredTargets<T>>::exists()
{
Ok(())
} else if !<Snapshot<T>>::exists()
&& !<SnapshotMetadata<T>>::exists()
&& !<DesiredTargets<T>>::exists()
} else if !<Snapshot<T>>::exists() &&
!<SnapshotMetadata<T>>::exists() &&
!<DesiredTargets<T>>::exists()
{
Ok(())
} else {
Expand All @@ -1620,39 +1620,38 @@ impl<T: Config> Pallet<T> {
if submission.is_none() {
return Err(
"All signed submissions indices must be part of the submissions map".into()
);
)
}

if i == 0 {
last_score = indice.0
} else {
if last_score.strict_threshold_better(indice.0, Perbill::zero()) {
return Err(
"Signed submission indices vector must be ordered by election score".into(),
);
"Signed submission indices vector must be ordered by election score".into()
)
}
last_score = indice.0;
}
}

if <SignedSubmissionsMap<T>>::iter().nth(indices.len()).is_some() {
return Err(
"Signed submissions map length should be the same as the indices vec length".into(),
);
"Signed submissions map length should be the same as the indices vec length".into()
)
}

match <SignedSubmissionNextIndex<T>>::get() {
0 => Ok(()),
next => {
next =>
if <SignedSubmissionsMap<T>>::get(next).is_some() {
return Err(
"The next submissions index should not be in the submissions maps already"
.into(),
);
)
} else {
Ok(())
}
},
},
}
}

Expand All @@ -1661,13 +1660,12 @@ impl<T: Config> Pallet<T> {
fn try_state_phase_off() -> Result<(), TryRuntimeError> {
match Self::current_phase().is_off() {
false => Ok(()),
true => {
true =>
if <Snapshot<T>>::get().is_some() {
Err("Snapshot must be none when in Phase::Off".into())
} else {
Ok(())
}
},
},
}
}
}
Expand Down Expand Up @@ -2658,8 +2656,8 @@ mod tests {

let mut active = 1;
while weight_with(active)
.all_lte(<Runtime as frame_system::Config>::BlockWeights::get().max_block)
|| active == all_voters
.all_lte(<Runtime as frame_system::Config>::BlockWeights::get().max_block) ||
active == all_voters
{
active += 1;
}
Expand Down
21 changes: 10 additions & 11 deletions frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ pub mod pallet {
);

let to_seconds = |w: &Weight| {
w.ref_time() as f32
/ frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND as f32
w.ref_time() as f32 /
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND as f32
};

frame_support::log::debug!(
Expand Down Expand Up @@ -953,7 +953,7 @@ impl<T: Config> Pallet<T> {

if candidates_and_deposit.len().is_zero() {
Self::deposit_event(Event::EmptyTerm);
return T::DbWeight::get().reads(3);
return T::DbWeight::get().reads(3)
}

// All of the new winners that come out of phragmen will thus have a deposit recorded.
Expand Down Expand Up @@ -985,7 +985,7 @@ impl<T: Config> Pallet<T> {
"Failed to run election. Number of voters exceeded",
);
Self::deposit_event(Event::ElectionError);
return T::DbWeight::get().reads(3 + max_voters as u64);
return T::DbWeight::get().reads(3 + max_voters as u64)
},
}

Expand Down Expand Up @@ -1092,8 +1092,8 @@ impl<T: Config> Pallet<T> {
// All candidates/members/runners-up who are no longer retaining a position as a
// seat holder will lose their bond.
candidates_and_deposit.iter().for_each(|(c, d)| {
if new_members_ids_sorted.binary_search(c).is_err()
&& new_runners_up_ids_sorted.binary_search(c).is_err()
if new_members_ids_sorted.binary_search(c).is_err() &&
new_runners_up_ids_sorted.binary_search(c).is_err()
{
let (imbalance, _) = T::Currency::slash_reserved(c, *d);
T::LoserCandidate::on_unbalanced(imbalance);
Expand Down Expand Up @@ -1261,12 +1261,11 @@ impl<T: Config> Pallet<T> {
// - Members and candidates sets are disjoint;
// - Members and runners-ups sets are disjoint.
fn try_state_members_disjoint() -> Result<(), TryRuntimeError> {
match Self::intersects(&Pallet::<T>::members_ids(), &Self::candidates_ids())
&& Self::intersects(&Pallet::<T>::members_ids(), &Self::runners_up_ids())
match Self::intersects(&Pallet::<T>::members_ids(), &Self::candidates_ids()) &&
Self::intersects(&Pallet::<T>::members_ids(), &Self::runners_up_ids())
{
true => {
Err("Members set should be disjoint from candidates and runners-up sets".into())
},
true =>
Err("Members set should be disjoint from candidates and runners-up sets".into()),
false => Ok(()),
}
}
Expand Down
17 changes: 7 additions & 10 deletions frame/preimage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<T: Config> Pallet<T> {
origin: T::RuntimeOrigin,
) -> Result<Option<T::AccountId>, BadOrigin> {
if T::ManagerOrigin::ensure_origin(origin.clone()).is_ok() {
return Ok(None);
return Ok(None)
}
let who = ensure_signed(origin)?;
Ok(Some(who))
Expand All @@ -233,15 +233,12 @@ impl<T: Config> Pallet<T> {
// We take a deposit only if there is a provided depositor and the preimage was not
// previously requested. This also allows the tx to pay no fee.
let status = match (StatusFor::<T>::get(hash), maybe_depositor) {
(Some(RequestStatus::Requested { count, deposit, .. }), _) => {
RequestStatus::Requested { count, deposit, len: Some(len) }
},
(Some(RequestStatus::Unrequested { .. }), Some(_)) => {
return Err(Error::<T>::AlreadyNoted.into())
},
(Some(RequestStatus::Unrequested { len, deposit }), None) => {
RequestStatus::Requested { deposit: Some(deposit), count: 1, len: Some(len) }
},
(Some(RequestStatus::Requested { count, deposit, .. }), _) =>
RequestStatus::Requested { count, deposit, len: Some(len) },
(Some(RequestStatus::Unrequested { .. }), Some(_)) =>
return Err(Error::<T>::AlreadyNoted.into()),
(Some(RequestStatus::Unrequested { len, deposit }), None) =>
RequestStatus::Requested { deposit: Some(deposit), count: 1, len: Some(len) },
(None, None) => RequestStatus::Requested { count: 1, len: Some(len), deposit: None },
(None, Some(depositor)) => {
let length = preimage.len() as u32;
Expand Down
Loading

0 comments on commit 7e66913

Please sign in to comment.