Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate scheduler traits v1 and v2 #3718

3 changes: 3 additions & 0 deletions substrate/frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ impl<T: Config> Pallet<T> {
}
}

#[allow(deprecated)]
impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
for Pallet<T>
{
Expand Down Expand Up @@ -1469,6 +1470,8 @@ impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall
}
}

// TODO: migrate `schedule::v2::Anon` to `v3`
#[allow(deprecated)]
impl<T: Config> schedule::v2::Named<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
for Pallet<T>
{
Expand Down
18 changes: 16 additions & 2 deletions substrate/frame/support/src/traits/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<T: Decode, H> MaybeHashed<T, H> {
}
}

// TODO: deprecate
#[deprecated(note = "Use `v3` instead. Will be removed after September 2024.")]
pub mod v1 {
use super::*;

Expand Down Expand Up @@ -218,10 +218,12 @@ pub mod v1 {
fn next_dispatch_time(id: Vec<u8>) -> Result<BlockNumber, ()>;
}

#[allow(deprecated)]
impl<T, BlockNumber, Call, RuntimeOrigin> Anon<BlockNumber, Call, RuntimeOrigin> for T
where
T: v2::Anon<BlockNumber, Call, RuntimeOrigin>,
{
#[allow(deprecated)]
type Address = T::Address;

fn schedule(
Expand All @@ -232,29 +234,36 @@ pub mod v1 {
call: Call,
) -> Result<Self::Address, DispatchError> {
let c = MaybeHashed::<Call, T::Hash>::Value(call);

#[allow(deprecated)]
T::schedule(when, maybe_periodic, priority, origin, c)
}

fn cancel(address: Self::Address) -> Result<(), ()> {
#[allow(deprecated)]
T::cancel(address)
}

fn reschedule(
address: Self::Address,
when: DispatchTime<BlockNumber>,
) -> Result<Self::Address, DispatchError> {
#[allow(deprecated)]
T::reschedule(address, when)
}

fn next_dispatch_time(address: Self::Address) -> Result<BlockNumber, ()> {
#[allow(deprecated)]
T::next_dispatch_time(address)
}
}

#[allow(deprecated)]
impl<T, BlockNumber, Call, RuntimeOrigin> Named<BlockNumber, Call, RuntimeOrigin> for T
where
T: v2::Named<BlockNumber, Call, RuntimeOrigin>,
{
#[allow(deprecated)]
type Address = T::Address;

fn schedule_named(
Expand All @@ -266,27 +275,31 @@ pub mod v1 {
call: Call,
) -> Result<Self::Address, ()> {
let c = MaybeHashed::<Call, T::Hash>::Value(call);
#[allow(deprecated)]
T::schedule_named(id, when, maybe_periodic, priority, origin, c)
}

fn cancel_named(id: Vec<u8>) -> Result<(), ()> {
#[allow(deprecated)]
T::cancel_named(id)
}

fn reschedule_named(
id: Vec<u8>,
when: DispatchTime<BlockNumber>,
) -> Result<Self::Address, DispatchError> {
#[allow(deprecated)]
T::reschedule_named(id, when)
}

fn next_dispatch_time(id: Vec<u8>) -> Result<BlockNumber, ()> {
#[allow(deprecated)]
T::next_dispatch_time(id)
}
}
}

// TODO: deprecate
#[deprecated(note = "Use `v3` instead. Will be removed after September 2024.")]
pub mod v2 {
use super::*;

Expand Down Expand Up @@ -478,4 +491,5 @@ pub mod v3 {
}
}

#[allow(deprecated)]
pub use v1::*;
Loading