tuple to struct event variants (#10257)

* AFNPEV recovery

* AFNPEV session

* cargo +nightly fmt && cargo fmt

* removed redundant comments

* update

* update & cargo +nightly fmt

* update & cargo +nightly fmt

* update recovery/src/lib.rs

* update session/src/lib.rs
This commit is contained in:
Doordashcon
2021-11-20 09:00:43 +01:00
committed by GitHub
parent 25239c8642
commit 09d351ddad
2 changed files with 38 additions and 22 deletions
+35 -19
View File
@@ -262,22 +262,22 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A recovery process has been set up for an \[account\].
RecoveryCreated(T::AccountId),
/// A recovery process has been set up for an account.
RecoveryCreated { account: T::AccountId },
/// A recovery process has been initiated for lost account by rescuer account.
/// \[lost, rescuer\]
RecoveryInitiated(T::AccountId, T::AccountId),
RecoveryInitiated { lost_account: T::AccountId, rescuer_account: T::AccountId },
/// A recovery process for lost account by rescuer account has been vouched for by sender.
/// \[lost, rescuer, sender\]
RecoveryVouched(T::AccountId, T::AccountId, T::AccountId),
RecoveryVouched {
lost_account: T::AccountId,
rescuer_account: T::AccountId,
sender: T::AccountId,
},
/// A recovery process for lost account by rescuer account has been closed.
/// \[lost, rescuer\]
RecoveryClosed(T::AccountId, T::AccountId),
RecoveryClosed { lost_account: T::AccountId, rescuer_account: T::AccountId },
/// Lost account has been successfully recovered by rescuer account.
/// \[lost, rescuer\]
AccountRecovered(T::AccountId, T::AccountId),
/// A recovery process has been removed for an \[account\].
RecoveryRemoved(T::AccountId),
AccountRecovered { lost_account: T::AccountId, rescuer_account: T::AccountId },
/// A recovery process has been removed for an account.
RecoveryRemoved { lost_account: T::AccountId },
}
#[pallet::error]
@@ -409,7 +409,10 @@ pub mod pallet {
ensure_root(origin)?;
// Create the recovery storage item.
<Proxy<T>>::insert(&rescuer, &lost);
Self::deposit_event(Event::<T>::AccountRecovered(lost, rescuer));
Self::deposit_event(Event::<T>::AccountRecovered {
lost_account: lost,
rescuer_account: rescuer,
});
Ok(())
}
@@ -472,7 +475,7 @@ pub mod pallet {
// Create the recovery configuration storage item
<Recoverable<T>>::insert(&who, recovery_config);
Self::deposit_event(Event::<T>::RecoveryCreated(who));
Self::deposit_event(Event::<T>::RecoveryCreated { account: who });
Ok(())
}
@@ -519,7 +522,10 @@ pub mod pallet {
};
// Create the active recovery storage item
<ActiveRecoveries<T>>::insert(&account, &who, recovery_status);
Self::deposit_event(Event::<T>::RecoveryInitiated(account, who));
Self::deposit_event(Event::<T>::RecoveryInitiated {
lost_account: account,
rescuer_account: who,
});
Ok(())
}
@@ -568,7 +574,11 @@ pub mod pallet {
}
// Update storage with the latest details
<ActiveRecoveries<T>>::insert(&lost, &rescuer, active_recovery);
Self::deposit_event(Event::<T>::RecoveryVouched(lost, rescuer, who));
Self::deposit_event(Event::<T>::RecoveryVouched {
lost_account: lost,
rescuer_account: rescuer,
sender: who,
});
Ok(())
}
@@ -617,7 +627,10 @@ pub mod pallet {
frame_system::Pallet::<T>::inc_consumers(&who).map_err(|_| Error::<T>::BadState)?;
// Create the recovery storage item
Proxy::<T>::insert(&who, &account);
Self::deposit_event(Event::<T>::AccountRecovered(account, who));
Self::deposit_event(Event::<T>::AccountRecovered {
lost_account: account,
rescuer_account: who,
});
Ok(())
}
@@ -656,7 +669,10 @@ pub mod pallet {
BalanceStatus::Free,
);
debug_assert!(res.is_ok());
Self::deposit_event(Event::<T>::RecoveryClosed(who, rescuer));
Self::deposit_event(Event::<T>::RecoveryClosed {
lost_account: who,
rescuer_account: rescuer,
});
Ok(())
}
@@ -692,7 +708,7 @@ pub mod pallet {
// Unreserve the initial deposit for the recovery configuration.
T::Currency::unreserve(&who, recovery_config.deposit);
Self::deposit_event(Event::<T>::RecoveryRemoved(who));
Self::deposit_event(Event::<T>::RecoveryRemoved { lost_account: who });
Ok(())
}
+3 -3
View File
@@ -532,9 +532,9 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event {
/// New session has happened. Note that the argument is the \[session_index\], not the
/// New session has happened. Note that the argument is the session index, not the
/// block number as the type might suggest.
NewSession(SessionIndex),
NewSession { session_index: SessionIndex },
}
/// Old name generated by `decl_event`.
@@ -703,7 +703,7 @@ impl<T: Config> Pallet<T> {
<QueuedChanged<T>>::put(next_changed);
// Record that this happened.
Self::deposit_event(Event::NewSession(session_index));
Self::deposit_event(Event::NewSession { session_index });
// Tell everyone about the new session keys.
T::SessionHandler::on_new_session::<T::Keys>(changed, &session_keys, &queued_amalgamated);