From a7bf82f04e9fbbf1e670d895d22ca5e11db7bd52 Mon Sep 17 00:00:00 2001
From: bear <boundless.forest@outlook.com>
Date: Fri, 1 Jul 2022 18:21:09 +0800
Subject: [PATCH] Add default implementation (#155)

---
 modules/fee-market/src/s2s/payment.rs    |  4 ++--
 modules/messages/src/instant_payments.rs |  2 +-
 primitives/message-dispatch/src/lib.rs   | 17 ++++++++++++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/modules/fee-market/src/s2s/payment.rs b/modules/fee-market/src/s2s/payment.rs
index 80dea38f4..d52ccd97d 100644
--- a/modules/fee-market/src/s2s/payment.rs
+++ b/modules/fee-market/src/s2s/payment.rs
@@ -56,10 +56,10 @@ where
 		let root_account = RootAccount::get();
 		let account = match submitter {
 			Sender::Signed(submitter) => submitter,
-			Sender::Root  => root_account
+			Sender::Root => root_account
 				.as_ref()
 				.ok_or("Sending messages using Root origin is disallowed.")?,
-			Sender::None => Err("Sending messages using None origin is disallowed.")?
+			Sender::None => Err("Sending messages using None origin is disallowed.")?,
 		};
 
 		<T as Config<I>>::Currency::transfer(
diff --git a/modules/messages/src/instant_payments.rs b/modules/messages/src/instant_payments.rs
index 7670a98b4..c94612e4a 100644
--- a/modules/messages/src/instant_payments.rs
+++ b/modules/messages/src/instant_payments.rs
@@ -76,7 +76,7 @@ where
 			Sender::Root => root_account
 				.as_ref()
 				.ok_or("Sending messages using Root origin is disallowed.")?,
-			Sender::None => Err("Sending messages using None origin is disallowed.")?
+			Sender::None => Err("Sending messages using None origin is disallowed.")?,
 		};
 
 		Currency::transfer(
diff --git a/primitives/message-dispatch/src/lib.rs b/primitives/message-dispatch/src/lib.rs
index 2cde19ffb..ee1b758cc 100644
--- a/primitives/message-dispatch/src/lib.rs
+++ b/primitives/message-dispatch/src/lib.rs
@@ -167,7 +167,10 @@ pub trait CallValidate<AccountId, Origin, Call> {
 	///
 	/// This will be called before the call enter dispatch phase. If failed, the message(call) will
 	/// be not be processed by this relayer, latter relayers can still continue process it.
-	fn check_receiving_before_dispatch(relayer_account: &AccountId, call: &Call) -> Result<(), &'static str>;
+	fn check_receiving_before_dispatch(
+		relayer_account: &AccountId,
+		call: &Call,
+	) -> Result<(), &'static str>;
 	/// In-dispatch call validation
 	///
 	/// This will be called in the dispatch process, If failed, return message dispatch errors.
@@ -177,3 +180,15 @@ pub trait CallValidate<AccountId, Origin, Call> {
 		call: &Call,
 	) -> Result<(), TransactionValidityError>;
 }
+
+/// CallValidate's default implementation, no additional validation
+pub enum Everything {}
+impl<AccountId, Origin, Call> CallValidate<AccountId, Origin, Call> for Everything {
+	fn check_receiving_before_dispatch(_: &AccountId, _: &Call) -> Result<(), &'static str> {
+		Ok(())
+	}
+
+	fn call_validate(_: &AccountId, _: &Origin, _: &Call) -> Result<(), TransactionValidityError> {
+		Ok(())
+	}
+}