Repository: paritytech/substrate
File: frame/nfts/src/features/attributes.rs (Rust)

Code before:
		let mut result = false;
		match namespace {
			AttributeNamespace::CollectionOwner =>
				result = Self::has_role(&collection, &origin, CollectionRole::Admin),
			AttributeNamespace::ItemOwner =>
				if let Some(item) = maybe_item {
					let item_details =
						Item::<T, I>::get(&collection, &item).ok_or(Error::<T, I>::UnknownItem)?;
					result = origin == &item_details.owner
				},
			AttributeNamespace::Account(account_id) =>
				if let Some(item) = maybe_item {
					let approvals = ItemAttributesApprovalsOf::<T, I>::get(&collection, &item);
					result = account_id == origin && approvals.contains(&origin)
				},
			_ => (),
		};
		Ok(result)
	}

	/// A helper method to construct an attribute's key.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided attribute `key` is incorrectly formatted.
	pub fn construct_attribute_key(
		key: Vec<u8>,
	) -> Result<BoundedVec<u8, T::KeyLimit>, DispatchError> {
		Ok(BoundedVec::try_from(key).map_err(|_| Error::<T, I>::IncorrectData)?)
	}

	/// A helper method to construct an attribute's value.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided `value` is incorrectly formatted.
	pub fn construct_attribute_value(
		value: Vec<u8>,
	) -> Result<BoundedVec<u8, T::ValueLimit>, DispatchError> {
		Ok(BoundedVec::try_from(value).map_err(|_| Error::<T, I>::IncorrectData)?)
	}

	/// A helper method to check whether a system attribute is set for a given item.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided pallet attribute is incorrectly formatted.
	pub fn has_system_attribute(

Review comment (refactor):
```suggestion
	/// provided attribute `key` is too long.
```

Code after:
		let mut result = false;
		match namespace {
			AttributeNamespace::CollectionOwner =>
				result = Self::has_role(&collection, &origin, CollectionRole::Admin),
			AttributeNamespace::ItemOwner =>
				if let Some(item) = maybe_item {
					let item_details =
						Item::<T, I>::get(&collection, &item).ok_or(Error::<T, I>::UnknownItem)?;
					result = origin == &item_details.owner
				},
			AttributeNamespace::Account(account_id) =>
				if let Some(item) = maybe_item {
					let approvals = ItemAttributesApprovalsOf::<T, I>::get(&collection, &item);
					result = account_id == origin && approvals.contains(&origin)
				},
			_ => (),
		};
		Ok(result)
	}

	/// A helper method to construct an attribute's key.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided attribute `key` is too long.
	pub fn construct_attribute_key(
		key: Vec<u8>,
	) -> Result<BoundedVec<u8, T::KeyLimit>, DispatchError> {
		Ok(BoundedVec::try_from(key).map_err(|_| Error::<T, I>::IncorrectData)?)
	}

	/// A helper method to construct an attribute's value.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided `value` is too long.
	pub fn construct_attribute_value(
		value: Vec<u8>,
	) -> Result<BoundedVec<u8, T::ValueLimit>, DispatchError> {
		Ok(BoundedVec::try_from(value).map_err(|_| Error::<T, I>::IncorrectData)?)
	}

	/// A helper method to check whether a system attribute is set for a given item.
	///
	/// # Errors
	///
	/// This function returns an [`IncorrectData`](crate::Error::IncorrectData) error if the
	/// provided pallet attribute is too long.
	pub fn has_system_attribute(