Skip to content

Commit 5f97114

Browse files
committed
docs: update documentation and add inline comments
1 parent 245e68b commit 5f97114

File tree

1 file changed

+8
-3
lines changed
  • pallets/pallet-bonded-coins/src

1 file changed

+8
-3
lines changed

pallets/pallet-bonded-coins/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ pub mod pallet {
338338
/// - `curve`: The curve parameters for the pool.
339339
/// - `collateral_id`: The ID of the collateral currency.
340340
/// - `currencies`: A bounded vector of token metadata for the bonded
341-
/// currencies.
341+
/// currencies. Note that no two currencies may use the same name or
342+
/// symbol.
342343
/// - `denomination`: The denomination for the bonded currencies.
343344
/// - `transferable`: A boolean indicating if the bonded currencies are
344345
/// transferable.
@@ -347,8 +348,10 @@ pub mod pallet {
347348
/// - `DispatchResult`: The result of the dispatch.
348349
///
349350
/// # Errors
350-
/// - `Error::<T>::InvalidInput`: If the denomination is greater than
351-
/// the maximum allowed or if the curve input is invalid.
351+
/// - `Error::<T>::InvalidInput`: If either
352+
/// - the denomination is greater than the maximum allowed
353+
/// - the curve input is invalid
354+
/// - two currencies use the same name or symbol
352355
/// - `Error::<T>::Internal`: If the conversion to `BoundedVec` fails.
353356
/// - Other errors depending on the types in the config.
354357
#[pallet::call_index(0)]
@@ -408,6 +411,7 @@ pub mod pallet {
408411
// currency to it. This should also verify that the currency actually exists.
409412
T::Collaterals::touch(collateral_id.clone(), pool_account, &who)?;
410413

414+
// Enforce unique names and symbols by recording seen values in a set
411415
let mut names_seen = BTreeSet::<StringInputOf<T>>::new();
412416
let mut symbols_seen = BTreeSet::<StringInputOf<T>>::new();
413417

@@ -419,6 +423,7 @@ pub mod pallet {
419423
symbol,
420424
} = token_metadata;
421425

426+
// insert() returns true if the set did not contain the inserted value
422427
let name_ok = name.is_empty() || names_seen.insert(name.clone());
423428
let symbol_ok = symbol.is_empty() || symbols_seen.insert(symbol.clone());
424429

0 commit comments

Comments
 (0)