Repository: paritytech/substrate
File: frame/support/src/traits/misc.rs (Rust)

Code before:
pub trait PreimageRecipient<Hash>: PreimageProvider<Hash> {
	/// Maximum size of a preimage.
	type MaxSize: Get<u32>;

	/// Store the bytes of a preimage on chain infallible due to the bounded type.
	fn note_preimage(bytes: crate::BoundedVec<u8, Self::MaxSize>);

	/// Clear a previously noted preimage. This is infallible and should be treated more like a
	/// hint - if it was not previously noted or if it is now requested, then this will not do
	/// anything.
	fn unnote_preimage(hash: &Hash);
}

impl<Hash> PreimageRecipient<Hash> for () {
	type MaxSize = ();
	fn note_preimage(_: crate::BoundedVec<u8, Self::MaxSize>) {}
	fn unnote_preimage(_: &Hash) {}
}

/// Trait for creating an asset account with a deposit taken from a specified by client depositor.
pub trait AccountTouch<AssetId, AccountId> {
	/// The type for currency units of the deposit.
	type Balance;

	/// The deposit amount of a native currency required for creating an asset account.
	fn deposit() -> Self::Balance;

	/// Create an account for `who` of the `asset` with a deposit taken from the `depositor`.
	fn touch(asset: AssetId, who: AccountId, depositor: AccountId) -> DispatchResult;
}

#[cfg(test)]
mod test {
	use super::*;
	use sp_core::bounded::{BoundedSlice, BoundedVec};
	use sp_std::marker::PhantomData;

	#[test]
	fn defensive_assert_works() {
		defensive_assert!(true);
		defensive_assert!(true,);
		defensive_assert!(true, "must work");
		defensive_assert!(true, "must work",);
	}

	#[test]
	#[cfg(debug_assertions)]
	#[should_panic(expected = "Defensive failure has been triggered!: \"1 == 0\": \"Must fail\"")]
	fn defensive_assert_panics() {
		defensive_assert!(1 == 0, "Must fail");
	}

Review comment (suggestion):
```suggestion
	fn deposit_required() -> Self::Balance;
```

Code after:
pub trait PreimageRecipient<Hash>: PreimageProvider<Hash> {
	/// Maximum size of a preimage.
	type MaxSize: Get<u32>;

	/// Store the bytes of a preimage on chain infallible due to the bounded type.
	fn note_preimage(bytes: crate::BoundedVec<u8, Self::MaxSize>);

	/// Clear a previously noted preimage. This is infallible and should be treated more like a
	/// hint - if it was not previously noted or if it is now requested, then this will not do
	/// anything.
	fn unnote_preimage(hash: &Hash);
}

impl<Hash> PreimageRecipient<Hash> for () {
	type MaxSize = ();
	fn note_preimage(_: crate::BoundedVec<u8, Self::MaxSize>) {}
	fn unnote_preimage(_: &Hash) {}
}

/// Trait for creating an asset account with a deposit taken from a designated depositor specified
/// by the client.
pub trait AccountTouch<AssetId, AccountId> {
	/// The type for currency units of the deposit.
	type Balance;

	/// The deposit amount of a native currency required for creating an asset account.
	fn deposit_required() -> Self::Balance;

	/// Create an account for `who` of the `asset` with a deposit taken from the `depositor`.
	fn touch(asset: AssetId, who: AccountId, depositor: AccountId) -> DispatchResult;
}

#[cfg(test)]
mod test {
	use super::*;
	use sp_core::bounded::{BoundedSlice, BoundedVec};
	use sp_std::marker::PhantomData;

	#[test]
	fn defensive_assert_works() {
		defensive_assert!(true);
		defensive_assert!(true,);
		defensive_assert!(true, "must work");
		defensive_assert!(true, "must work",);
	}

	#[test]
	#[cfg(debug_assertions)]
	#[should_panic(expected = "Defensive failure has been triggered!: \"1 == 0\": \"Must fail\"")]
	fn defensive_assert_panics() {
		defensive_assert!(1 == 0, "Must fail");