Skip to content

Commit

Permalink
liquidity-pools: Ensure only pool admins can allow investment currencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Jan 8, 2024
1 parent 17e00b5 commit 1ea61bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pallets/liquidity-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,15 @@ pub mod pallet {
// See spec: https://centrifuge.hackmd.io/SERpps-URlG4hkOyyS94-w?view#fn-add_pool_currency
let who = ensure_signed(origin)?;

ensure!(
T::Permission::has(
PermissionScope::Pool(pool_id),
who.clone(),
Role::PoolRole(PoolRole::PoolAdmin)
),
Error::<T>::NotPoolAdmin
);

// Ensure currency is allowed as payment and payout currency for pool
let invest_id = Self::derive_invest_id(pool_id, tranche_id)?;
// Required for increasing and collecting investments
Expand Down
12 changes: 11 additions & 1 deletion runtime/integration-tests/src/generic/cases/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,16 @@ mod development {
currency_id,
)
);

assert_noop!(
pallet_liquidity_pools::Pallet::<T>::allow_investment_currency(
RawOrigin::Signed(Keyring::Charlie.into()).into(),
pool_id,
default_tranche_id::<T>(pool_id),
currency_id,
),
pallet_liquidity_pools::Error::<T>::NotPoolAdmin
);
});
}

Expand Down Expand Up @@ -1452,7 +1462,7 @@ mod development {
[0u8; 16],
currency_id,
),
pallet_liquidity_pools::Error::<T>::PoolNotFound
pallet_liquidity_pools::Error::<T>::NotPoolAdmin
);

// Register currency_id with pool_currency set to true
Expand Down

0 comments on commit 1ea61bb

Please sign in to comment.