55
66#![ cfg_attr( not( feature = "std" ) , no_std) ]
77
8- pub use pallet:: * ;
98use frame_support:: pallet_prelude:: Weight ;
9+ pub use pallet:: * ;
1010
1111#[ frame_support:: pallet]
1212pub mod pallet {
13+ use crate :: WeightInfo ;
1314 use frame_support:: pallet_prelude:: * ;
14- use frame_system:: pallet_prelude:: * ;
15- use sp_staking:: OnStakingUpdate ;
1615 use frame_support:: traits:: Currency ;
17- use frame_support:: traits:: LockableCurrency ;
1816 use frame_support:: traits:: EnsureOrigin ;
19- use crate :: WeightInfo ;
17+ use frame_support:: traits:: LockableCurrency ;
18+ use frame_system:: pallet_prelude:: * ;
19+ use sp_staking:: OnStakingUpdate ;
2020
2121 pub type BalanceOf < T > =
22- <<T as Config >:: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance ;
22+ <<T as Config >:: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance ;
2323
2424 #[ pallet:: pallet]
2525 pub struct Pallet < T > ( _ ) ;
@@ -38,19 +38,15 @@ pub mod pallet {
3838 type WeightInfo : WeightInfo ;
3939 }
4040
41-
4241 /// Pallets use events to inform users when important changes are made.
4342 /// https://docs.substrate.io/main-docs/build/events-errors/
4443 #[ pallet:: event]
4544 #[ pallet:: generate_deposit( pub ( super ) fn deposit_event) ]
4645 pub enum Event < T : Config > {
4746 /// Withdrawal was called for a stash account. [stash_account, amount]
48- WithdrawCalled {
49- stash_account : T :: AccountId ,
50- amount : BalanceOf < T > ,
51- } ,
47+ WithdrawCalled { stash_account : T :: AccountId , amount : BalanceOf < T > } ,
5248 }
53-
49+
5450 #[ pallet:: error]
5551 pub enum Error < T > {
5652 /// Withdrawal failed due to insufficient balance or other staking constraints.
@@ -66,18 +62,19 @@ pub mod pallet {
6662 /// This function can be called by root or governance.
6763 #[ pallet:: call_index( 0 ) ]
6864 #[ pallet:: weight( T :: WeightInfo :: call_withdraw( ) ) ]
69- pub fn call_withdraw ( origin : OriginFor < T > , stash_account : T :: AccountId , amount : BalanceOf < T > ) -> DispatchResult {
65+ pub fn call_withdraw (
66+ origin : OriginFor < T > ,
67+ stash_account : T :: AccountId ,
68+ amount : BalanceOf < T > ,
69+ ) -> DispatchResult {
7070 T :: GovernanceOrigin :: ensure_origin ( origin) ?;
71-
71+
7272 // Call the delegation pallet connector to handle withdrawal
7373 T :: DelegationPalletConnector :: on_withdraw ( & stash_account, amount) ;
74-
74+
7575 // Emit an event.
76- Self :: deposit_event ( Event :: WithdrawCalled {
77- stash_account,
78- amount,
79- } ) ;
80-
76+ Self :: deposit_event ( Event :: WithdrawCalled { stash_account, amount } ) ;
77+
8178 Ok ( ( ) )
8279 }
8380 }
0 commit comments