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.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -54,6 +54,7 @@
WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
},
};
+use pallet_unq_scheduler::ApplyExtrinsic;
use up_data_structs::*;
// use pallet_contracts::weights::WeightInfo;
// #[cfg(any(feature = "std", test))]
@@ -822,9 +823,24 @@
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureSigned<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
- type SponsorshipHandler = SponsorshipHandler;
type WeightInfo = ();
- type PaymentHandler = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
+ type Executor = Ex;
+}
+
+// pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
+// node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
+// }
+
+struct Ex;
+impl<C: Dispatchable> ApplyExtrinsic<C> for Ex {
+ fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult {
+ let extrinsic = sign(fp_self_contained::CheckedExtrinsic {
+ signed: fp_self_contained::CheckedSignature::SelfContained(None),
+ function: function,
+ });
+
+ Executive::apply_extrinsic(extrinsic)
+ }
}
impl pallet_evm_transaction_payment::Config for Runtime {