Browse Source

runtime: working-group: Change RewardPaid event.

- add worker ID
Shamil Gadelshin 3 years ago
parent
commit
fdc08ab913

+ 6 - 1
runtime-modules/working-group/src/lib.rs

@@ -263,10 +263,11 @@ decl_event!(
 
         /// Emits on paying the reward.
         /// Params:
+        /// - Id of the worker.
         /// - Receiver Account Id.
         /// - Reward
         /// - Payment type (missed reward or regular one)
-        RewardPaid(AccountId, Balance, RewardPaymentType),
+        RewardPaid(WorkerId, AccountId, Balance, RewardPaymentType),
 
         /// Emits on reaching new missed reward.
         /// Params:
@@ -1317,6 +1318,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
             // Check whether the budget is not zero.
             if actual_reward > Zero::zero() {
                 Self::pay_reward(
+                    worker_id,
                     &worker.reward_account_id,
                     actual_reward,
                     RewardPaymentType::RegularReward,
@@ -1345,12 +1347,14 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Helper-function joining the reward payment with the event.
     fn pay_reward(
+        worker_id: &WorkerId<T>,
         account_id: &T::AccountId,
         amount: BalanceOf<T>,
         reward_payment_type: RewardPaymentType,
     ) {
         Self::pay_from_budget(account_id, amount);
         Self::deposit_event(RawEvent::RewardPaid(
+            *worker_id,
             account_id.clone(),
             amount,
             reward_payment_type,
@@ -1366,6 +1370,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
             // Checks if the budget allows any payment.
             if could_be_paid_reward > Zero::zero() {
                 Self::pay_reward(
+                    worker_id,
                     &worker.reward_account_id,
                     could_be_paid_reward,
                     RewardPaymentType::MissedReward,

+ 2 - 0
runtime-modules/working-group/src/tests/mod.rs

@@ -635,6 +635,7 @@ fn leave_worker_role_succeeds_with_paying_missed_reward() {
             Some(missed_reward),
         ));
         EventFixture::contains_crate_event(RawEvent::RewardPaid(
+            worker_id,
             account_id,
             missed_reward,
             RewardPaymentType::MissedReward,
@@ -1929,6 +1930,7 @@ fn rewards_payments_are_successful() {
 
         let reward_period: u64 = <Test as Trait>::RewardPeriod::get().into();
         EventFixture::assert_last_crate_event(RawEvent::RewardPaid(
+            worker_id,
             account_id,
             reward_per_block * reward_period,
             RewardPaymentType::RegularReward,