moonbeam_runtime_common/
impl_self_contained_call.rs1#[macro_export]
18macro_rules! impl_self_contained_call {
19 {} => {
20 impl fp_self_contained::SelfContainedCall for RuntimeCall {
21 type SignedInfo = H160;
22
23 fn is_self_contained(&self) -> bool {
24 match self {
25 RuntimeCall::Ethereum(call) => call.is_self_contained(),
26 _ => false,
27 }
28 }
29
30 fn check_self_contained(
31 &self
32 ) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {
33 match self {
34 RuntimeCall::Ethereum(call) => call.check_self_contained(),
35 _ => None,
36 }
37 }
38
39 fn validate_self_contained(
40 &self,
41 signed_info: &Self::SignedInfo,
42 dispatch_info: &DispatchInfoOf<RuntimeCall>,
43 len: usize,
44 ) -> Option<TransactionValidity> {
45 match self {
46 RuntimeCall::Ethereum(call) => call.validate_self_contained(signed_info, dispatch_info, len),
47 _ => None,
48 }
49 }
50
51 fn pre_dispatch_self_contained(
52 &self,
53 info: &Self::SignedInfo,
54 dispatch_info: &DispatchInfoOf<RuntimeCall>,
55 len: usize,
56 ) -> Option<Result<(), TransactionValidityError>> {
57 match self {
58 RuntimeCall::Ethereum(call) => call.pre_dispatch_self_contained(info, dispatch_info, len),
59 _ => None,
60 }
61 }
62
63 fn apply_self_contained(
64 self,
65 info: Self::SignedInfo,
66 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
67 match self {
68 call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(
69 call.dispatch(RuntimeOrigin::from(
70 pallet_ethereum::RawOrigin::EthereumTransaction(info)
71 ))
72 ),
73 _ => None,
74 }
75 }
76 }
77 }
78}