difftreelog
fix remove unused items
in: master
1 file changed
runtime/common/scheduler.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18 dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},19};20use sp_runtime::{21 traits::{Dispatchable, Applyable, Member},22 generic::Era,23 transaction_validity::TransactionValidityError,24 DispatchErrorWithPostInfo,25};26use codec::Encode;27use crate::{Runtime, RuntimeCall, RuntimeOrigin, maintenance};28use up_common::types::AccountId;29use fp_self_contained::SelfContainedCall;30use pallet_unique_scheduler_v2::DispatchCall;31use pallet_transaction_payment::ChargeTransactionPayment;3233/// The SignedExtension to the basic transaction logic.34pub type SignedExtraScheduler = (35 frame_system::CheckWeight<Runtime>,36 maintenance::CheckMaintenance,37 ChargeTransactionPayment<Runtime>,38);3940fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {41 (42 frame_system::CheckWeight::<Runtime>::new(),43 maintenance::CheckMaintenance,44 ChargeTransactionPayment::<Runtime>::from(0),45 )46}4748pub struct SchedulerPaymentExecutor;4950impl<T: frame_system::Config + pallet_unique_scheduler_v2::Config, SelfContainedSignedInfo>51 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor52where53 <T as frame_system::Config>::RuntimeCall: Member54 + Dispatchable<RuntimeOrigin = RuntimeOrigin, Info = DispatchInfo>55 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>56 + GetDispatchInfo57 + From<frame_system::Call<Runtime>>,58 SelfContainedSignedInfo: Send + Sync + 'static,59 RuntimeCall: From<<T as frame_system::Config>::RuntimeCall>60 + From<<T as pallet_unique_scheduler_v2::Config>::RuntimeCall>61 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,62 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,63{64 fn dispatch_call(65 signer: Option<<T as frame_system::Config>::AccountId>,66 call: <T as pallet_unique_scheduler_v2::Config>::RuntimeCall,67 ) -> Result<68 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,69 TransactionValidityError,70 > {71 let dispatch_info = call.get_dispatch_info();72 let len = call.encoded_size();7374 let signed = match signer {75 Some(signer) => fp_self_contained::CheckedSignature::Signed(76 signer.clone().into(),77 get_signed_extras(signer.into()),78 ),79 None => fp_self_contained::CheckedSignature::Unsigned,80 };8182 let extrinsic = fp_self_contained::CheckedExtrinsic::<83 AccountId,84 RuntimeCall,85 SignedExtraScheduler,86 SelfContainedSignedInfo,87 > {88 signed,89 function: call.into(),90 };9192 extrinsic.apply::<Runtime>(&dispatch_info, len)93 }94}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18 dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},19};20use sp_runtime::{21 traits::{Dispatchable, Applyable, Member},22 transaction_validity::TransactionValidityError,23 DispatchErrorWithPostInfo,24};25use codec::Encode;26use crate::{Runtime, RuntimeCall, RuntimeOrigin, maintenance};27use up_common::types::AccountId;28use fp_self_contained::SelfContainedCall;29use pallet_unique_scheduler_v2::DispatchCall;30use pallet_transaction_payment::ChargeTransactionPayment;3132/// The SignedExtension to the basic transaction logic.33pub type SignedExtraScheduler = (34 frame_system::CheckWeight<Runtime>,35 maintenance::CheckMaintenance,36 ChargeTransactionPayment<Runtime>,37);3839fn get_signed_extras() -> SignedExtraScheduler {40 (41 frame_system::CheckWeight::<Runtime>::new(),42 maintenance::CheckMaintenance,43 ChargeTransactionPayment::<Runtime>::from(0),44 )45}4647pub struct SchedulerPaymentExecutor;4849impl<T: frame_system::Config + pallet_unique_scheduler_v2::Config, SelfContainedSignedInfo>50 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor51where52 <T as frame_system::Config>::RuntimeCall: Member53 + Dispatchable<RuntimeOrigin = RuntimeOrigin, Info = DispatchInfo>54 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>55 + GetDispatchInfo56 + From<frame_system::Call<Runtime>>,57 SelfContainedSignedInfo: Send + Sync + 'static,58 RuntimeCall: From<<T as frame_system::Config>::RuntimeCall>59 + From<<T as pallet_unique_scheduler_v2::Config>::RuntimeCall>60 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,61 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,62{63 fn dispatch_call(64 signer: Option<<T as frame_system::Config>::AccountId>,65 call: <T as pallet_unique_scheduler_v2::Config>::RuntimeCall,66 ) -> Result<67 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,68 TransactionValidityError,69 > {70 let dispatch_info = call.get_dispatch_info();71 let len = call.encoded_size();7273 let signed = match signer {74 Some(signer) => fp_self_contained::CheckedSignature::Signed(75 signer.clone().into(),76 get_signed_extras(),77 ),78 None => fp_self_contained::CheckedSignature::Unsigned,79 };8081 let extrinsic = fp_self_contained::CheckedExtrinsic::<82 AccountId,83 RuntimeCall,84 SignedExtraScheduler,85 SelfContainedSignedInfo,86 > {87 signed,88 function: call.into(),89 };9091 extrinsic.apply::<Runtime>(&dispatch_info, len)92 }93}