Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Polkaverse committed Jul 28, 2023
1 parent 056a802 commit bc71863
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pallets/user/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub mod pallet {
/// Add/Update the user details by any JUR user.
///
/// Parameters:
/// - `username`: Username of the Account.
/// - `name`: Username of the Account.
/// - `avatar`: This is an image file address(also a GIF is valid) that is uploaded on IPFS.
///
/// Emits `UserDetailsUpdated` event when successful.
Expand All @@ -83,17 +83,17 @@ pub mod pallet {
#[pallet::weight(10000)]
pub fn update_user(
origin: OriginFor<T>,
username: Option<BoundedVec<u8, T::NameLimit>>,
name: Option<BoundedVec<u8, T::NameLimit>>,
avatar: Option<BoundedVec<u8, T::AddressLimit>>,
) -> DispatchResult {
let user = ensure_signed(origin.clone())?;

for (_, userdata) in Users::<T>::iter() {
ensure!(userdata.username != username, Error::<T>::UsernameNotAvailable);
ensure!(userdata.name != name, Error::<T>::UsernameNotAvailable);
}

// creating the user data structure as per given inputs
let new_user = User { username, avatar };
let new_user = User { name, avatar };

// Inserting the data into the storage.
Users::<T>::insert(user.clone(), new_user);
Expand Down
2 changes: 1 addition & 1 deletion pallets/user/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ use sp_std::prelude::*;
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)]
#[scale_info(skip_type_params(NameLimit, AddressLimit))]
pub struct User<NameLimit: Get<u32>, AddressLimit: Get<u32>> {
pub username: Option<BoundedVec<u8, NameLimit>>,
pub name: Option<BoundedVec<u8, NameLimit>>,
pub avatar: Option<BoundedVec<u8, AddressLimit>>,
}

0 comments on commit bc71863

Please sign in to comment.