Repository: paritytech/substrate
File: frame/system/src/lib.rs (Rust)

Code before:
		/// - Writes: Number of subkeys + 1
		/// # </weight>
		#[pallet::weight((
			T::SystemWeightInfo::kill_prefix(_subkeys.saturating_add(1)),
			DispatchClass::Operational,
		))]
		pub(crate) fn kill_prefix(
			origin: OriginFor<T>,
			prefix: Key,
			_subkeys: u32,
		) -> DispatchResultWithPostInfo {
			ensure_root(origin)?;
			storage::unhashed::kill_prefix(&prefix);
			Ok(().into())
		}

		/// Make some on-chain remark and emit event.
		///
		/// # <weight>
		/// - `O(1)`
		/// - 1 event.
		/// # </weight>
		#[pallet::weight(T::SystemWeightInfo::remark_with_event(remark.len() as u32))]
		pub(crate) fn remark_with_event(origin: OriginFor<T>, remark: Vec<u8>) -> DispatchResultWithPostInfo {
			ensure_signed(origin)?;
			Self::deposit_event(Event::Remarked(remark));
			Ok(().into())
		}
	}

	/// Event for the System pallet.
	#[pallet::event]
	#[pallet::metadata(T::AccountId = "AccountId")]
	pub enum Event<T: Config> {
		/// An extrinsic completed successfully. \[info\]
		ExtrinsicSuccess(DispatchInfo),
		/// An extrinsic failed. \[error, info\]
		ExtrinsicFailed(DispatchError, DispatchInfo),
		/// `:code` was updated.
		CodeUpdated,
		/// A new \[account\] was created.
		NewAccount(T::AccountId),
		/// An \[account\] was reaped.
		KilledAccount(T::AccountId),
		/// On on-chain \[remark\] happened.
		Remarked(Vec<u8>),
	}

	/// Old name generated by `decl_event`.
	#[deprecated(note = "use `Event` instead")]
	pub type RawEvent<T> = Event<T>;

Review comment (suggestion):
I still do not see what this ACTUALLY does.

Like events should be for presenting data which may not easily be accessible, for example that an extrinsic completed using fork path A versus fork path B.

In this case, all the information you need is already on chain and accessible as easily as an even it:

* Extrinsic with Remark data is in the block header
* Success event of the remark is in events already

So what am I missing? Is this just lazily trying to use the events API in JavaScript? if so, then we could probably program in the JS API side this functionality.

Code after:
		/// - Writes: Number of subkeys + 1
		/// # </weight>
		#[pallet::weight((
			T::SystemWeightInfo::kill_prefix(_subkeys.saturating_add(1)),
			DispatchClass::Operational,
		))]
		pub(crate) fn kill_prefix(
			origin: OriginFor<T>,
			prefix: Key,
			_subkeys: u32,
		) -> DispatchResultWithPostInfo {
			ensure_root(origin)?;
			storage::unhashed::kill_prefix(&prefix);
			Ok(().into())
		}

		/// Make some on-chain remark and emit event.
		///
		/// # <weight>
		/// - `O(b)` where b is the length of the remark.
		/// - 1 event.
		/// # </weight>
		#[pallet::weight(T::SystemWeightInfo::remark_with_event(remark.len() as u32))]
		pub(crate) fn remark_with_event(origin: OriginFor<T>, remark: Vec<u8>) -> DispatchResultWithPostInfo {
			let who = ensure_signed(origin)?;
			let hash = T::Hashing::hash(&remark[..]);
			Self::deposit_event(Event::Remarked(who, hash));
			Ok(().into())
		}
	}

	/// Event for the System pallet.
	#[pallet::event]
	#[pallet::metadata(T::AccountId = "AccountId", T::Hash = "Hash")]
	pub enum Event<T: Config> {
		/// An extrinsic completed successfully. \[info\]
		ExtrinsicSuccess(DispatchInfo),
		/// An extrinsic failed. \[error, info\]
		ExtrinsicFailed(DispatchError, DispatchInfo),
		/// `:code` was updated.
		CodeUpdated,
		/// A new \[account\] was created.
		NewAccount(T::AccountId),
		/// An \[account\] was reaped.
		KilledAccount(T::AccountId),
		/// On on-chain remark happened. \[origin, remark_hash\]
		Remarked(T::AccountId, T::Hash),
	}

	/// Old name generated by `decl_event`.
	#[deprecated(note = "use `Event` instead")]