Repository: paritytech/substrate
File: frame/examples/dev-mode/src/lib.rs (Rust)

Code before:
	// method.
	#[pallet::pallet]
	pub struct Pallet<T>(_);

	#[pallet::call]
	impl<T: Config> Pallet<T> {
		/// No need to define a `call_index` attribute here because of `dev_mode`.
		/// No need to define a `weight` attribute here because of `dev_mode`.
		pub fn add_dummy(origin: OriginFor<T>, id: T::AccountId) -> DispatchResult {
			ensure_root(origin)?;

			if let Some(mut dummies) = Dummy::<T>::get() {
				dummies.push(id.clone());
				Dummy::<T>::set(Some(dummies));
			} else {
				Dummy::<T>::set(Some(vec![id.clone()]));
			}

			// Let's deposit an event to let the outside world know this happened.
			Self::deposit_event(Event::AddDummy { account: id });

			Ok(())
		}

		/// No need to define a `call_index` attribute here because of `dev_mode`.
		/// No need to define a `weight` attribute here because of `dev_mode`.
		pub fn set_bar(
			origin: OriginFor<T>,
			#[pallet::compact] new_value: T::Balance,
		) -> DispatchResult {
			let sender = ensure_signed(origin)?;

			// Put the new value into storage.
			<Bar<T>>::insert(&sender, new_value);

			Self::deposit_event(Event::SetBar { account: sender, balance: new_value });

			Ok(())
		}
	}

	#[pallet::event]
	#[pallet::generate_deposit(pub(super) fn deposit_event)]
	pub enum Event<T: Config> {
		AddDummy { account: T::AccountId },
		SetBar { account: T::AccountId, balance: BalanceOf<T> },
	}

	/// The MEL requirement for bounded pallets is skipped by `dev_mode`.
	/// This means that all storages are marked as unbounded.
	/// This is equivalent to specifying `#[pallet::unbounded]` on this type definitions.

Review comment (suggestion):
```suggestion
		// No need to define a `call_index` attribute here because of `dev_mode`.
		// No need to define a `weight` attribute here because of `dev_mode`.
```

Code after:
	// method.
	#[pallet::pallet]
	pub struct Pallet<T>(_);

	#[pallet::call]
	impl<T: Config> Pallet<T> {
		// No need to define a `call_index` attribute here because of `dev_mode`.
		// No need to define a `weight` attribute here because of `dev_mode`.
		pub fn add_dummy(origin: OriginFor<T>, id: T::AccountId) -> DispatchResult {
			ensure_root(origin)?;

			if let Some(mut dummies) = Dummy::<T>::get() {
				dummies.push(id.clone());
				Dummy::<T>::set(Some(dummies));
			} else {
				Dummy::<T>::set(Some(vec![id.clone()]));
			}

			// Let's deposit an event to let the outside world know this happened.
			Self::deposit_event(Event::AddDummy { account: id });

			Ok(())
		}

		// No need to define a `call_index` attribute here because of `dev_mode`.
		// No need to define a `weight` attribute here because of `dev_mode`.
		pub fn set_bar(
			origin: OriginFor<T>,
			#[pallet::compact] new_value: T::Balance,
		) -> DispatchResult {
			let sender = ensure_signed(origin)?;

			// Put the new value into storage.
			<Bar<T>>::insert(&sender, new_value);

			Self::deposit_event(Event::SetBar { account: sender, balance: new_value });

			Ok(())
		}
	}

	#[pallet::event]
	#[pallet::generate_deposit(pub(super) fn deposit_event)]
	pub enum Event<T: Config> {
		AddDummy { account: T::AccountId },
		SetBar { account: T::AccountId, balance: BalanceOf<T> },
	}

	/// The MEL requirement for bounded pallets is skipped by `dev_mode`.
	/// This means that all storages are marked as unbounded.
	/// This is equivalent to specifying `#[pallet::unbounded]` on this type definitions.