mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 06:01:02 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -57,37 +57,40 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
mod benchmarking;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod benchmarking;
|
||||
pub mod weights;
|
||||
|
||||
use codec::{Encode, Decode, MaxEncodedLen};
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::{
|
||||
traits::{AccountIdConversion, Saturating, StaticLookup, Zero},
|
||||
Permill, RuntimeDebug,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use frame_support::{
|
||||
print,
|
||||
traits::{
|
||||
Zero, StaticLookup, AccountIdConversion, Saturating
|
||||
}
|
||||
Currency, ExistenceRequirement::KeepAlive, Get, Imbalance, OnUnbalanced,
|
||||
ReservableCurrency, WithdrawReasons,
|
||||
},
|
||||
weights::Weight,
|
||||
PalletId,
|
||||
};
|
||||
|
||||
use frame_support::{print, PalletId};
|
||||
use frame_support::traits::{
|
||||
Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::KeepAlive,
|
||||
ReservableCurrency, WithdrawReasons
|
||||
};
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
pub use weights::WeightInfo;
|
||||
pub use pallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
pub type BalanceOf<T, I = ()> =
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
pub type PositiveImbalanceOf<T, I = ()> =
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::PositiveImbalance;
|
||||
pub type NegativeImbalanceOf<T, I = ()> =
|
||||
<<T as Config<I>>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
|
||||
pub type PositiveImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::PositiveImbalance;
|
||||
pub type NegativeImbalanceOf<T, I = ()> = <<T as Config<I>>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::NegativeImbalance;
|
||||
|
||||
/// A trait to allow the Treasury Pallet to spend it's funds for other purposes.
|
||||
/// There is an expectation that the implementer of this trait will correctly manage
|
||||
@@ -130,9 +133,9 @@ pub struct Proposal<AccountId, Balance> {
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use super::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::generate_store(pub(super) trait Store)]
|
||||
@@ -204,17 +207,14 @@ pub mod pallet {
|
||||
Twox64Concat,
|
||||
ProposalIndex,
|
||||
Proposal<T::AccountId, BalanceOf<T, I>>,
|
||||
OptionQuery
|
||||
OptionQuery,
|
||||
>;
|
||||
|
||||
/// Proposal indices that have been approved but not yet awarded.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn approvals)]
|
||||
pub type Approvals<T: Config<I>, I: 'static = ()> = StorageValue<
|
||||
_,
|
||||
BoundedVec<ProposalIndex, T::MaxApprovals>,
|
||||
ValueQuery
|
||||
>;
|
||||
pub type Approvals<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, BoundedVec<ProposalIndex, T::MaxApprovals>, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig;
|
||||
@@ -229,10 +229,12 @@ pub mod pallet {
|
||||
#[cfg(feature = "std")]
|
||||
impl GenesisConfig {
|
||||
/// Direct implementation of `GenesisBuild::assimilate_storage`.
|
||||
#[deprecated(note = "use `<GensisConfig<T, I> as GenesisBuild<T, I>>::assimilate_storage` instead")]
|
||||
#[deprecated(
|
||||
note = "use `<GensisConfig<T, I> as GenesisBuild<T, I>>::assimilate_storage` instead"
|
||||
)]
|
||||
pub fn assimilate_storage<T: Config<I>, I: 'static>(
|
||||
&self,
|
||||
storage: &mut sp_runtime::Storage
|
||||
storage: &mut sp_runtime::Storage,
|
||||
) -> Result<(), String> {
|
||||
<Self as GenesisBuild<T, I>>::assimilate_storage(self, storage)
|
||||
}
|
||||
@@ -272,8 +274,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Old name generated by `decl_event`.
|
||||
#[deprecated(note = "use `Event` instead")]
|
||||
pub type RawEvent<T, I = ()> = Event<T, I>;
|
||||
#[deprecated(note = "use `Event` instead")]
|
||||
pub type RawEvent<T, I = ()> = Event<T, I>;
|
||||
|
||||
/// Error for the treasury pallet.
|
||||
#[pallet::error]
|
||||
@@ -320,7 +322,7 @@ pub mod pallet {
|
||||
pub fn propose_spend(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] value: BalanceOf<T, I>,
|
||||
beneficiary: <T::Lookup as StaticLookup>::Source
|
||||
beneficiary: <T::Lookup as StaticLookup>::Source,
|
||||
) -> DispatchResult {
|
||||
let proposer = ensure_signed(origin)?;
|
||||
let beneficiary = T::Lookup::lookup(beneficiary)?;
|
||||
@@ -349,11 +351,12 @@ pub mod pallet {
|
||||
#[pallet::weight((T::WeightInfo::reject_proposal(), DispatchClass::Operational))]
|
||||
pub fn reject_proposal(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] proposal_id: ProposalIndex
|
||||
#[pallet::compact] proposal_id: ProposalIndex,
|
||||
) -> DispatchResult {
|
||||
T::RejectOrigin::ensure_origin(origin)?;
|
||||
|
||||
let proposal = <Proposals<T, I>>::take(&proposal_id).ok_or(Error::<T, I>::InvalidIndex)?;
|
||||
let proposal =
|
||||
<Proposals<T, I>>::take(&proposal_id).ok_or(Error::<T, I>::InvalidIndex)?;
|
||||
let value = proposal.bond;
|
||||
let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0;
|
||||
T::OnSlash::on_unbalanced(imbalance);
|
||||
@@ -375,12 +378,13 @@ pub mod pallet {
|
||||
#[pallet::weight((T::WeightInfo::approve_proposal(T::MaxApprovals::get()), DispatchClass::Operational))]
|
||||
pub fn approve_proposal(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] proposal_id: ProposalIndex
|
||||
#[pallet::compact] proposal_id: ProposalIndex,
|
||||
) -> DispatchResult {
|
||||
T::ApproveOrigin::ensure_origin(origin)?;
|
||||
|
||||
ensure!(<Proposals<T, I>>::contains_key(proposal_id), Error::<T, I>::InvalidIndex);
|
||||
Approvals::<T, I>::try_append(proposal_id).map_err(|_| Error::<T, I>::TooManyApprovals)?;
|
||||
Approvals::<T, I>::try_append(proposal_id)
|
||||
.map_err(|_| Error::<T, I>::TooManyApprovals)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -444,7 +448,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
total_weight += T::WeightInfo::on_initialize_proposals(proposals_len);
|
||||
|
||||
// Call Runtime hooks to external pallet using treasury to compute spend funds.
|
||||
T::SpendFunds::spend_funds( &mut budget_remaining, &mut imbalance, &mut total_weight, &mut missed_any);
|
||||
T::SpendFunds::spend_funds(
|
||||
&mut budget_remaining,
|
||||
&mut imbalance,
|
||||
&mut total_weight,
|
||||
&mut missed_any,
|
||||
);
|
||||
|
||||
if !missed_any {
|
||||
// burn some proportion of the remaining budget if we run a surplus.
|
||||
@@ -461,12 +470,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
// proof: budget_remaining is account free balance minus ED;
|
||||
// Thus we can't spend more than account free balance minus ED;
|
||||
// Thus account is kept alive; qed;
|
||||
if let Err(problem) = T::Currency::settle(
|
||||
&account_id,
|
||||
imbalance,
|
||||
WithdrawReasons::TRANSFER,
|
||||
KeepAlive
|
||||
) {
|
||||
if let Err(problem) =
|
||||
T::Currency::settle(&account_id, imbalance, WithdrawReasons::TRANSFER, KeepAlive)
|
||||
{
|
||||
print("Inconsistent state - couldn't settle imbalance for funds spent by treasury");
|
||||
// Nothing else to do here.
|
||||
drop(problem);
|
||||
|
||||
Reference in New Issue
Block a user