--- a/Cargo.lock +++ b/Cargo.lock @@ -6272,6 +6272,7 @@ "parity-scale-codec", "scale-info", "serde", + "sp-api", "sp-core", "sp-io", "sp-runtime", --- a/pallets/scheduler/src/lib.rs +++ b/pallets/scheduler/src/lib.rs @@ -55,11 +55,11 @@ mod benchmarking; pub mod weights; -use sp_std::{prelude::*, marker::PhantomData, borrow::Borrow}; +use sp_std::{prelude::*, marker::PhantomData, borrow::Borrow, cmp}; use codec::{Encode, Decode, Codec}; use sp_runtime::{ RuntimeDebug, - traits::{One, BadOrigin, Saturating}, + traits::{Zero, One, BadOrigin, Saturating}, }; use frame_support::{ decl_module, decl_storage, decl_event, decl_error, @@ -242,7 +242,6 @@ type Error = Error; fn deposit_event() = default; - /// Anonymously schedule a task. /// /// # @@ -506,14 +505,14 @@ let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay)); let r = call.clone().dispatch(sponsor.into()); - //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch call + //T::PaymentHandler::apply(); + //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch extrinsic here // sanitize maybe_periodic - let maybe_periodic = None; - // let maybe_periodic = maybe_periodic - // .filter(|p| p.1 > 1 && !p.0.is_zero()) - // // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now. - // .map(|(p, c)| (p, std::cmp::min(c, PERIODIC_CALLS_LIMIT) - 1)); + let maybe_periodic = maybe_periodic + .filter(|p| p.1 > 1 && !p.0.is_zero()) + // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now. + .map(|(p, c)| (p, cmp::min(c, PERIODIC_CALLS_LIMIT) - 1)); let s = Some(Scheduled { maybe_id, @@ -571,6 +570,7 @@ if let Some(s) = scheduled { if let Some(id) = s.maybe_id { Lookup::::remove(id); + // todo add back money / displace to another function for consistency } Self::deposit_event(RawEvent::Canceled(when, index)); Ok(()) @@ -648,6 +648,7 @@ } Ok(()) })?; + // todo add money back / displace to another function Self::deposit_event(RawEvent::Canceled(when, index)); Ok(()) } else { @@ -795,7 +796,7 @@ pub struct Module for enum Call where origin: ::Origin, - ::Origin: OriginTrait + ::Origin: OriginTrait { fn deposit_event() = default; @@ -841,6 +842,13 @@ } } + pub struct DummyExecutor; // todo do something with naming and function body + impl ApplyExtrinsic for DummyExecutor { + fn apply_extrinsic(_signer: Address, _function: C) -> ApplyExtrinsicResult { + todo!() + } + } + parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = @@ -891,7 +899,6 @@ type ScheduleOrigin = EnsureOneOf, EnsureSignedBy>; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = (); - type SponsorshipHandler = (); - type PaymentHandler = (); + type Executor = DummyExecutor; } } --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -815,34 +815,35 @@ pallet_evm_transaction_payment::BridgeSponsorshipHandler, ); -impl pallet_unq_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureSigned; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = (); - type Executor = Ex; -} - // pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic { // node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH) // } -struct Ex; -impl ApplyExtrinsic for Ex { +pub struct SchedulerPaymentExecutor; +impl ApplyExtrinsic for SchedulerPaymentExecutor { fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult { - let extrinsic = sign(fp_self_contained::CheckedExtrinsic { + /*let extrinsic = sign(fp_self_contained::CheckedExtrinsic { signed: fp_self_contained::CheckedSignature::SelfContained(None), - function: function, + function, }); - Executive::apply_extrinsic(extrinsic) + Executive::apply_extrinsic(extrinsic)*/ + todo!() } } +impl pallet_unq_scheduler::Config for Runtime { + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureSigned; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = (); + type Executor = SchedulerPaymentExecutor; +} + impl pallet_evm_transaction_payment::Config for Runtime { type EvmSponsorshipHandler = EvmSponsorshipHandler; type Currency = Balances;