difftreelog
Apply extrinsic custom trait
in: master
2 files changed
pallets/scheduler/src/lib.rsdiffbeforeafterboth59use codec::{Encode, Decode, Codec};59use codec::{Encode, Decode, Codec};60use sp_runtime::{60use sp_runtime::{61 RuntimeDebug,61 RuntimeDebug,62 traits::{Zero, One, BadOrigin, Saturating, SignedExtension},62 traits::{One, BadOrigin, Saturating},63};63};64use frame_support::{64use frame_support::{65 decl_module, decl_storage, decl_event, decl_error,65 decl_module, decl_storage, decl_event, decl_error,73};73};74use frame_system::{self as system, ensure_signed};74use frame_system::{self as system, ensure_signed};75pub use weights::WeightInfo;75pub use weights::WeightInfo;76use up_sponsorship::SponsorshipHandler;76use scale_info::TypeInfo;77use scale_info::TypeInfo;77use sp_runtime::ApplyExtrinsicResult;78use sp_runtime::traits::{IdentifyAccount, Verify};79use sp_runtime::{MultiSignature};8081pub trait ApplyExtrinsic<C: Dispatchable> {82 fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult;83}8485/// The address format for describing accounts.86pub type Signature = MultiSignature;87pub type Address = sp_runtime::MultiAddress<AccountId, ()>;88pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;788979/// Our pallet's configuration trait. All our types and constants go in here. If the90/// Our pallet's configuration trait. All our types and constants go in here. If the80/// pallet is dependent on specific other pallets, then their configuration traits91/// pallet is dependent on specific other pallets, then their configuration traits111 /// Not strictly enforced, but used for weight estimation.122 /// Not strictly enforced, but used for weight estimation.112 type MaxScheduledPerBlock: Get<u32>;123 type MaxScheduledPerBlock: Get<u32>;113124114 /// Sponsoring function125 /// Weight information for extrinsics in this pallet.126 type WeightInfo: WeightInfo;127115 type SponsorshipHandler: SponsorshipHandler<Self::AccountId, <Self as Config>::Call>;128 type Executor: ApplyExtrinsic<<Self as Config>::Call>;116117 /// Weight information for extrinsics in this pallet.118 type WeightInfo: WeightInfo;119120 /// Unchecked extrinsic type as expected by the runtime that uses this pallet.121 type PaymentHandler: SignedExtension;122}129}123130124pub const MAX_TASK_ID_LENGTH_IN_BYTES: u8 = 16;131pub const MAX_TASK_ID_LENGTH_IN_BYTES: u8 = 16;495 <<T as Config>::Origin as From<T::PalletsOrigin>>::from(origin.clone()).into()502 <<T as Config>::Origin as From<T::PalletsOrigin>>::from(origin.clone()).into(),496 ).unwrap_or_default();503 )504 .unwrap_or_default();497 let who_will_pay = T::SponsorshipHandler::get_sponsor(&sender, &call).unwrap_or(sender);505 let who_will_pay = sender; // T::SponsorshipHandler::get_sponsor(&sender, &call).unwrap_or(sender);498 let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));506 let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));499 let r = call.clone().dispatch(sponsor.into());507 let r = call.clone().dispatch(sponsor.into());500508501 //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch call509 //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch call502510503 // sanitize maybe_periodic511 // sanitize maybe_periodic504 let maybe_periodic = maybe_periodic512 let maybe_periodic = None;505 .filter(|p| p.1 > 1 && !p.0.is_zero())513 // let maybe_periodic = maybe_periodic506 // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now.514 // .filter(|p| p.1 > 1 && !p.0.is_zero())507 .map(|(p, c)| (p, std::cmp::min(c, PERIODIC_CALLS_LIMIT) - 1));515 // // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now.508 516 // .map(|(p, c)| (p, std::cmp::min(c, PERIODIC_CALLS_LIMIT) - 1));517509 let s = Some(Scheduled {518 let s = Some(Scheduled {510 maybe_id,519 maybe_id,runtime/src/lib.rsdiffbeforeafterboth54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55 },55 },56};56};57use pallet_unq_scheduler::ApplyExtrinsic;57use up_data_structs::*;58use up_data_structs::*;58// use pallet_contracts::weights::WeightInfo;59// use pallet_contracts::weights::WeightInfo;59// #[cfg(any(feature = "std", test))]60// #[cfg(any(feature = "std", test))]822 type MaximumWeight = MaximumSchedulerWeight;823 type MaximumWeight = MaximumSchedulerWeight;823 type ScheduleOrigin = EnsureSigned<AccountId>;824 type ScheduleOrigin = EnsureSigned<AccountId>;824 type MaxScheduledPerBlock = MaxScheduledPerBlock;825 type MaxScheduledPerBlock = MaxScheduledPerBlock;825 type SponsorshipHandler = SponsorshipHandler;826 type WeightInfo = ();826 type WeightInfo = ();827 type PaymentHandler = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;827 type Executor = Ex;828}828}829830// pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {831// node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)832// }833834struct Ex;835impl<C: Dispatchable> ApplyExtrinsic<C> for Ex {836 fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult {837 let extrinsic = sign(fp_self_contained::CheckedExtrinsic {838 signed: fp_self_contained::CheckedSignature::SelfContained(None),839 function: function,840 });841842 Executive::apply_extrinsic(extrinsic)843 }844}829845830impl pallet_evm_transaction_payment::Config for Runtime {846impl pallet_evm_transaction_payment::Config for Runtime {831 type EvmSponsorshipHandler = EvmSponsorshipHandler;847 type EvmSponsorshipHandler = EvmSponsorshipHandler;