Skip to content

Commit

Permalink
feat: reset team on start_refund
Browse files Browse the repository at this point in the history
  • Loading branch information
rflechtner committed Nov 5, 2024
1 parent 969a25b commit c59b04b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pallets/pallet-bonded-coins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ pub mod pallet {

let pool_details = Pools::<T>::get(&pool_id).ok_or(Error::<T>::PoolUnknown)?;

ensure!(pool_details.state.is_live(), Error::<T>::PoolNotLive);
ensure!(pool_details.is_manager(&who), Error::<T>::NoPermission);

let asset_id = pool_details
Expand Down Expand Up @@ -866,8 +867,10 @@ pub mod pallet {
Error::<T>::NothingToRefund
);

let has_holders = pool_details
.bonded_currencies
// cloning here lets us avoid cloning the pool details later
let bonded_currencies = pool_details.bonded_currencies.clone();

let has_holders = bonded_currencies
.iter()
.any(|asset_id| T::Fungibles::total_issuance(asset_id.clone()) > FungiblesBalanceOf::<T>::zero());
// no token holders to refund
Expand All @@ -878,6 +881,18 @@ pub mod pallet {
new_pool_details.state.start_refund();
Pools::<T>::set(&pool_id, Some(new_pool_details));

// reset team on currencies to avoid unexpected burns etc.
let pool_account = pool_id.clone().into();
for asset_id in bonded_currencies {
T::Fungibles::reset_team(
asset_id,
pool_account.clone(),
pool_account.clone(),
pool_account.clone(),
pool_account.clone(),
)?;
}

Self::deposit_event(Event::RefundingStarted { id: pool_id });

Ok(n_currencies)
Expand Down

0 comments on commit c59b04b

Please sign in to comment.