@@ -338,7 +338,8 @@ pub mod pallet {
338
338
/// - `curve`: The curve parameters for the pool.
339
339
/// - `collateral_id`: The ID of the collateral currency.
340
340
/// - `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.
342
343
/// - `denomination`: The denomination for the bonded currencies.
343
344
/// - `transferable`: A boolean indicating if the bonded currencies are
344
345
/// transferable.
@@ -347,8 +348,10 @@ pub mod pallet {
347
348
/// - `DispatchResult`: The result of the dispatch.
348
349
///
349
350
/// # 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
352
355
/// - `Error::<T>::Internal`: If the conversion to `BoundedVec` fails.
353
356
/// - Other errors depending on the types in the config.
354
357
#[ pallet:: call_index( 0 ) ]
@@ -408,6 +411,7 @@ pub mod pallet {
408
411
// currency to it. This should also verify that the currency actually exists.
409
412
T :: Collaterals :: touch ( collateral_id. clone ( ) , pool_account, & who) ?;
410
413
414
+ // Enforce unique names and symbols by recording seen values in a set
411
415
let mut names_seen = BTreeSet :: < StringInputOf < T > > :: new ( ) ;
412
416
let mut symbols_seen = BTreeSet :: < StringInputOf < T > > :: new ( ) ;
413
417
@@ -419,6 +423,7 @@ pub mod pallet {
419
423
symbol,
420
424
} = token_metadata;
421
425
426
+ // insert() returns true if the set did not contain the inserted value
422
427
let name_ok = name. is_empty ( ) || names_seen. insert ( name. clone ( ) ) ;
423
428
let symbol_ok = symbol. is_empty ( ) || symbols_seen. insert ( symbol. clone ( ) ) ;
424
429
0 commit comments