Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Add default implementation (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest authored Jul 1, 2022
1 parent 1dc1d91 commit a7bf82f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/fee-market/src/s2s/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion modules/messages/src/instant_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 16 additions & 1 deletion primitives/message-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(())
}
}

0 comments on commit a7bf82f

Please sign in to comment.