mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 16:07:57 +00:00
cargo +nightly fmt (#3540)
* cargo +nightly fmt * add cargo-fmt check to ci * update ci * fmt * fmt * skip macro * ignore bridges
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Auxiliary `struct`/`enum`s for polkadot runtime.
|
||||
|
||||
use frame_support::traits::{OnUnbalanced, Imbalance, Currency};
|
||||
use crate::NegativeImbalance;
|
||||
use frame_support::traits::{Currency, Imbalance, OnUnbalanced};
|
||||
|
||||
/// Logic for the author to get a portion of fees.
|
||||
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
|
||||
@@ -31,8 +31,14 @@ where
|
||||
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
|
||||
let numeric_amount = amount.peek();
|
||||
let author = <pallet_authorship::Pallet<R>>::author();
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(&<pallet_authorship::Pallet<R>>::author(), amount);
|
||||
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(author, numeric_amount));
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(
|
||||
&<pallet_authorship::Pallet<R>>::author(),
|
||||
amount,
|
||||
);
|
||||
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(
|
||||
author,
|
||||
numeric_amount,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +51,7 @@ where
|
||||
<R as frame_system::Config>::AccountId: Into<primitives::v1::AccountId>,
|
||||
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
|
||||
{
|
||||
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance<R>>) {
|
||||
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
|
||||
if let Some(fees) = fees_then_tips.next() {
|
||||
// for fees, 80% to treasury, 20% to author
|
||||
let mut split = fees.ration(80, 20);
|
||||
@@ -60,20 +66,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_support::{parameter_types, traits::FindAuthor, weights::DispatchClass, PalletId};
|
||||
use frame_system::limits;
|
||||
use frame_support::{parameter_types, PalletId, weights::DispatchClass};
|
||||
use frame_support::traits::FindAuthor;
|
||||
use primitives::v1::AccountId;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
Perbill,
|
||||
};
|
||||
use primitives::v1::AccountId;
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
@@ -169,7 +173,8 @@ mod tests {
|
||||
pub struct OneAuthor;
|
||||
impl FindAuthor<AccountId> for OneAuthor {
|
||||
fn find_author<'a, I>(_: I) -> Option<AccountId>
|
||||
where I: 'a,
|
||||
where
|
||||
I: 'a,
|
||||
{
|
||||
Some(Default::default())
|
||||
}
|
||||
@@ -184,7 +189,9 @@ mod tests {
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
pallet_balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
||||
pallet_balances::GenesisConfig::<Test>::default()
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user