mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Tasks: general system for recognizing and executing service work (#1343)
`polkadot-sdk` version of original tasks PR located here: https://github.com/paritytech/substrate/pull/14329 Fixes #206 ## Status - [x] Generic `Task` trait - [x] `RuntimeTask` aggregated enum, compatible with `construct_runtime!` - [x] Casting between `Task` and `RuntimeTask` without needing `dyn` or `Box` - [x] Tasks Example pallet - [x] Runtime tests for Tasks example pallet - [x] Parsing for task-related macros - [x] Retrofit parsing to make macros optional - [x] Expansion for task-related macros - [x] Adds support for args in tasks - [x] Retrofit tasks example pallet to use macros instead of manual syntax - [x] Weights - [x] Cleanup - [x] UI tests - [x] Docs ## Target Syntax Adapted from https://github.com/paritytech/polkadot-sdk/issues/206#issue-1865172283 ```rust // NOTE: this enum is optional and is auto-generated by the other macros if not present #[pallet::task] pub enum Task<T: Config> { AddNumberIntoTotal { i: u32, } } /// Some running total. #[pallet::storage] pub(super) type Total<T: Config<I>, I: 'static = ()> = StorageValue<_, (u32, u32), ValueQuery>; /// Numbers to be added into the total. #[pallet::storage] pub(super) type Numbers<T: Config<I>, I: 'static = ()> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>; #[pallet::tasks_experimental] impl<T: Config<I>, I: 'static> Pallet<T, I> { /// Add a pair of numbers into the totals and remove them. #[pallet::task_list(Numbers::<T, I>::iter_keys())] #[pallet::task_condition(|i| Numbers::<T, I>::contains_key(i))] #[pallet::task_index(0)] pub fn add_number_into_total(i: u32) -> DispatchResult { let v = Numbers::<T, I>::take(i).ok_or(Error::<T, I>::NotFound)?; Total::<T, I>::mutate(|(total_keys, total_values)| { *total_keys += i; *total_values += v; }); Ok(()) } } ``` --------- Co-authored-by: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Nikhil Gupta <> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: gupnik <nikhilgupta.iitk@gmail.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: `Call` is not allowed to have generics. Only the following pallets are allowed to have generics: `Event`, `Error`, `Origin`, `Config`.
|
||||
error: `Call` is not allowed to have generics. Only the following pallets are allowed to have generics: `Event`, `Error`, `Origin`, `Config`, `Task`.
|
||||
--> tests/construct_runtime_ui/generics_in_invalid_module.rs:24:36
|
||||
|
|
||||
24 | Balance: balances::<Instance1>::{Call<T>, Origin<T>},
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason`
|
||||
error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `Task`, `LockId`, `SlashReason`
|
||||
--> tests/construct_runtime_ui/invalid_module_details_keyword.rs:23:20
|
||||
|
|
||||
23 | system: System::{enum},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason`
|
||||
error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `Task`, `LockId`, `SlashReason`
|
||||
--> tests/construct_runtime_ui/invalid_module_entry.rs:24:23
|
||||
|
|
||||
24 | Balance: balances::{Unexpected},
|
||||
|
||||
+8
@@ -76,3 +76,11 @@ help: consider importing one of these items
|
||||
|
|
||||
18 + use frame_support::traits::PalletInfo;
|
||||
|
|
||||
|
||||
error[E0412]: cannot find type `RuntimeTask` in this scope
|
||||
--> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:39:1
|
||||
|
|
||||
39 | #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeTask`
|
||||
|
|
||||
= note: this error originates in the macro `frame_system::config_preludes::TestDefaultConfig` which comes from the expansion of the macro `frame_support::macro_magic::forward_tokens_verbatim` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: `#[inject_runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo`
|
||||
error: `#[inject_runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeTask`, `RuntimeOrigin` or `PalletInfo`
|
||||
--> tests/derive_impl_ui/inject_runtime_type_invalid.rs:32:5
|
||||
|
|
||||
32 | type RuntimeInfo = ();
|
||||
|
||||
@@ -90,6 +90,8 @@ fn module_error_outer_enum_expand_explicit() {
|
||||
frame_system::Error::NonDefaultComposite => (),
|
||||
frame_system::Error::NonZeroRefCount => (),
|
||||
frame_system::Error::CallFiltered => (),
|
||||
frame_system::Error::InvalidTask => (),
|
||||
frame_system::Error::FailedTask => (),
|
||||
frame_system::Error::__Ignore(_, _) => (),
|
||||
},
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ fn module_error_outer_enum_expand_implicit() {
|
||||
frame_system::Error::NonDefaultComposite => (),
|
||||
frame_system::Error::NonZeroRefCount => (),
|
||||
frame_system::Error::CallFiltered => (),
|
||||
frame_system::Error::InvalidTask => (),
|
||||
frame_system::Error::FailedTask => (),
|
||||
frame_system::Error::__Ignore(_, _) => (),
|
||||
},
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: expected one of: `FreezeReason`, `HoldReason`, `LockId`, `SlashReason`
|
||||
error: expected one of: `FreezeReason`, `HoldReason`, `LockId`, `SlashReason`, `Task`
|
||||
--> tests/pallet_ui/composite_enum_unsupported_identifier.rs:27:11
|
||||
|
|
||||
27 | pub enum HoldReasons {}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::{ensure, pallet_prelude::DispatchResult};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|i, j| i == 0u32 && j == 2u64)]
|
||||
#[pallet::task_list(vec![(0u32, 2u64), (2u32, 4u64)].iter())]
|
||||
#[pallet::task_weight(0.into())]
|
||||
fn foo(i: u32, j: u64) -> DispatchResult {
|
||||
ensure!(i == 0, "i must be 0");
|
||||
ensure!(j == 2, "j must be 2");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
pub struct Task;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected `impl`
|
||||
--> tests/pallet_ui/task_can_only_be_attached_to_impl.rs:30:5
|
||||
|
|
||||
30 | pub struct Task;
|
||||
| ^^^
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|flag: bool| flag)]
|
||||
#[pallet::task_list(vec![1, 2].iter())]
|
||||
#[pallet::task_weight(0.into())]
|
||||
fn foo(_i: u32) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
error: unused import: `frame_system::pallet_prelude::OriginFor`
|
||||
--> tests/pallet_ui/task_condition_invalid_arg.rs:21:6
|
||||
|
|
||||
21 | use frame_system::pallet_prelude::OriginFor;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D unused-imports` implied by `-D warnings`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/pallet_ui/task_condition_invalid_arg.rs:35:10
|
||||
|
|
||||
32 | #[pallet::task_condition(|flag: bool| flag)]
|
||||
| ----------------- arguments to this function are incorrect
|
||||
...
|
||||
35 | fn foo(_i: u32) -> DispatchResult {
|
||||
| ^^ expected `bool`, found `u32`
|
||||
|
|
||||
note: closure parameter defined here
|
||||
--> tests/pallet_ui/task_condition_invalid_arg.rs:32:29
|
||||
|
|
||||
32 | #[pallet::task_condition(|flag: bool| flag)]
|
||||
| ^^^^^^^^^^
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(0)]
|
||||
#[pallet::task_list(vec![1, 2].iter())]
|
||||
#[pallet::task_weight(0.into())]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
error: unused import: `frame_system::pallet_prelude::OriginFor`
|
||||
--> tests/pallet_ui/task_invalid_condition.rs:21:6
|
||||
|
|
||||
21 | use frame_system::pallet_prelude::OriginFor;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D unused-imports` implied by `-D warnings`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/pallet_ui/task_invalid_condition.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet(dev_mode)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected integer, found `()`
|
||||
| expected due to this
|
||||
|
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0618]: expected function, found `{integer}`
|
||||
--> tests/pallet_ui/task_invalid_condition.rs:32:28
|
||||
|
|
||||
18 | #[frame_support::pallet(dev_mode)]
|
||||
| ---------------------------------- call expression requires function
|
||||
...
|
||||
32 | #[pallet::task_condition(0)]
|
||||
| ^
|
||||
@@ -0,0 +1,39 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index("0")]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected integer literal
|
||||
--> tests/pallet_ui/task_invalid_index.rs:31:24
|
||||
|
|
||||
31 | #[pallet::task_index("0")]
|
||||
| ^^^
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|| true)]
|
||||
#[pallet::task_list(0)]
|
||||
#[pallet::task_weight(0.into())]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
error: unused import: `frame_system::pallet_prelude::OriginFor`
|
||||
--> tests/pallet_ui/task_invalid_list.rs:21:6
|
||||
|
|
||||
21 | use frame_system::pallet_prelude::OriginFor;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D unused-imports` implied by `-D warnings`
|
||||
|
||||
error[E0689]: can't call method `map` on ambiguous numeric type `{integer}`
|
||||
--> tests/pallet_ui/task_invalid_list.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet(dev_mode)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: you must specify a concrete type for this numeric value, like `i32`
|
||||
|
|
||||
33 | #[pallet::task_list(0_i32)]
|
||||
| ~~~~~
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|| true)]
|
||||
#[pallet::task_list(vec![1, 2].iter())]
|
||||
#[pallet::task_weight("0")]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
error: unused import: `frame_system::pallet_prelude::OriginFor`
|
||||
--> tests/pallet_ui/task_invalid_weight.rs:21:6
|
||||
|
|
||||
21 | use frame_system::pallet_prelude::OriginFor;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D unused-imports` implied by `-D warnings`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/pallet_ui/task_invalid_weight.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet(dev_mode)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected integer, found `()`
|
||||
| expected due to this
|
||||
|
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> tests/pallet_ui/task_invalid_weight.rs:34:25
|
||||
|
|
||||
18 | #[frame_support::pallet(dev_mode)]
|
||||
| ---------------------------------- expected `Weight` because of return type
|
||||
...
|
||||
34 | #[pallet::task_weight("0")]
|
||||
| ^^^ expected `Weight`, found `&str`
|
||||
@@ -0,0 +1,39 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: missing `#[pallet::task_condition(..)]` attribute
|
||||
--> tests/pallet_ui/task_missing_condition.rs:32:6
|
||||
|
|
||||
32 | fn foo() -> DispatchResult {
|
||||
| ^^^
|
||||
@@ -0,0 +1,38 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: missing `#[pallet::task_index(..)]` attribute
|
||||
--> tests/pallet_ui/task_missing_index.rs:31:6
|
||||
|
|
||||
31 | fn foo() -> DispatchResult {
|
||||
| ^^^
|
||||
@@ -0,0 +1,40 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|| true)]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: missing `#[pallet::task_list(..)]` attribute
|
||||
--> tests/pallet_ui/task_missing_list.rs:33:6
|
||||
|
|
||||
33 | fn foo() -> DispatchResult {
|
||||
| ^^^
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::DispatchResult;
|
||||
use frame_system::pallet_prelude::OriginFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::tasks_experimental]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::task_index(0)]
|
||||
#[pallet::task_condition(|| true)]
|
||||
#[pallet::task_list(vec![1, 2].iter())]
|
||||
fn foo() -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: missing `#[pallet::task_weight(..)]` attribute
|
||||
--> tests/pallet_ui/task_missing_weight.rs:34:6
|
||||
|
|
||||
34 | fn foo() -> DispatchResult {
|
||||
| ^^^
|
||||
Reference in New Issue
Block a user