Skip to content

Commit

Permalink
Revert "pallet-core-fellowship: import an unimported member on approv…
Browse files Browse the repository at this point in the history
…e" (#2956)

Reverts #2883

Code, not docs, was intended.
  • Loading branch information
joepetrowski authored and EgorPopelyaev committed Jan 17, 2024
1 parent 481165d commit afadb83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
9 changes: 0 additions & 9 deletions prdoc/1.6.0/pr_2883.prdoc

This file was deleted.

29 changes: 9 additions & 20 deletions substrate/frame/core-fellowship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ pub mod pallet {
///
/// This resets `last_proof` to the current block, thereby delaying any automatic demotion.
///
/// If `who` is not already tracked by this pallet, then it will become tracked.
/// `last_promotion` will be set to zero.
/// `who` must already be tracked by this pallet for this to have an effect.
///
/// - `origin`: An origin which satisfies `ApproveOrigin` or root.
/// - `who`: A member (i.e. of non-zero rank).
Expand All @@ -382,11 +381,7 @@ pub mod pallet {
ensure!(at_rank > 0, Error::<T, I>::InvalidRank);
let rank = T::Members::rank_of(&who).ok_or(Error::<T, I>::Unranked)?;
ensure!(rank == at_rank, Error::<T, I>::UnexpectedRank);
let mut member = if let Some(m) = Member::<T, I>::get(&who) {
m
} else {
Self::import_member(who.clone(), rank)
};
let mut member = Member::<T, I>::get(&who).ok_or(Error::<T, I>::NotTracked)?;

member.last_proof = frame_system::Pallet::<T>::block_number();
Member::<T, I>::insert(&who, &member);
Expand Down Expand Up @@ -522,7 +517,13 @@ pub mod pallet {
let who = ensure_signed(origin)?;
ensure!(!Member::<T, I>::contains_key(&who), Error::<T, I>::AlreadyInducted);
let rank = T::Members::rank_of(&who).ok_or(Error::<T, I>::Unranked)?;
let _ = Self::import_member(who, rank);

let now = frame_system::Pallet::<T>::block_number();
Member::<T, I>::insert(
&who,
MemberStatus { is_active: true, last_promotion: 0u32.into(), last_proof: now },
);
Self::deposit_event(Event::<T, I>::Imported { who, rank });

Ok(Pays::No.into())
}
Expand All @@ -546,18 +547,6 @@ pub mod pallet {
Self::deposit_event(e);
}
}

fn import_member(who: T::AccountId, rank: RankOf<T, I>) -> MemberStatusOf<T> {
let now = frame_system::Pallet::<T>::block_number();
let status = MemberStatus {
is_active: true,
last_promotion: BlockNumberFor::<T>::zero(),
last_proof: now,
};
Member::<T, I>::insert(&who, status.clone());
Self::deposit_event(Event::<T, I>::Imported { who, rank });
status
}
}

impl<T: Config<I>, I: 'static> GetSalary<RankOf<T, I>, T::AccountId, T::Balance> for Pallet<T, I> {
Expand Down
8 changes: 0 additions & 8 deletions substrate/frame/core-fellowship/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,3 @@ fn active_changing_get_salary_works() {
}
});
}

#[test]
fn approve_imports_not_tracked_member() {
new_test_ext().execute_with(|| {
set_rank(10, 5);
assert_ok!(CoreFellowship::approve(signed(5), 10, 5));
});
}

0 comments on commit afadb83

Please sign in to comment.