Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions code/parachain/frame/crowdloan-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,6 @@ pub mod pallet {
ensure!(available_to_claim > T::Balance::zero(), Error::<T>::NothingToClaim);

reward.claimed = available_to_claim.saturating_add(reward.claimed);
if T::LockByDefault::get() && !RemoveRewardLocks::<T>::exists() {
T::RewardAsset::set_lock(
T::LockId::get(),
reward_account,
reward.claimed,
WithdrawReasons::all(),
);
}

let funds_account = Self::account_id();
// No need to keep the pallet account alive.
Expand All @@ -508,6 +500,17 @@ pub mod pallet {
false,
)?;

// IMPORTANT: Order of execution of this lock matters for proper locking of
// funds. Refer https://app.clickup.com/t/33e4tdu
if T::LockByDefault::get() && !RemoveRewardLocks::<T>::exists() {
T::RewardAsset::set_lock(
T::LockId::get(),
reward_account,
reward.claimed,
WithdrawReasons::TRANSFER,
);
}

ClaimedRewards::<T>::mutate(|x| *x = x.saturating_add(available_to_claim));

Ok(available_to_claim)
Expand Down