mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Adds ability to provide defaults for types provided by construct_runtime (#14682)
* Adds ability to use defaults for verbatim types * Adds RuntimeOrigin and PalletInfo in DefaultConfig * Adds RuntimeEvent in DefaultConfig * Adds RuntimeEvent in DefaultConfig * Minor fix * Minor fix * Everything in frame_system can now have a default * Adds docs * Adds UI Test for no_bounds * Updates docs * Adds UI tests for verbatim * Minor update * Minor updates * Minor updates * Addresses review comments * Fixes test * Update frame/support/procedural/src/derive_impl.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Minor fix * Minor * Fixes build * Uses runtime_type * Fixes comment * Fixes comment * Fixes test * Uses no_aggregated_types as an option in derive_impl * Uses specific imports * Fmt * Updates doc * Update frame/support/procedural/src/derive_impl.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update frame/support/procedural/src/derive_impl.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Addresses review comment * Addresses review comment * fmt * Renames test files * Adds docs using docify * Fixes test * Fixes UI tests --------- Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
use frame_support::{*, pallet_prelude::inject_runtime_type};
|
||||
use static_assertions::assert_type_eq_all;
|
||||
|
||||
pub trait Config {
|
||||
type RuntimeCall;
|
||||
}
|
||||
|
||||
struct Pallet;
|
||||
|
||||
#[register_default_impl(Pallet)]
|
||||
impl Config for Pallet {
|
||||
#[inject_runtime_type]
|
||||
type RuntimeCall = ();
|
||||
}
|
||||
|
||||
struct SomePallet;
|
||||
|
||||
#[derive_impl(Pallet)] // Injects type RuntimeCall = RuntimeCall;
|
||||
impl Config for SomePallet {}
|
||||
|
||||
assert_type_eq_all!(<SomePallet as Config>::RuntimeCall, u32);
|
||||
|
||||
fn main() {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
error[E0412]: cannot find type `RuntimeCall` in this scope
|
||||
--> tests/derive_impl_ui/inject_runtime_type_fails_when_type_not_in_scope.rs:13:10
|
||||
|
|
||||
13 | type RuntimeCall = ();
|
||||
| ^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeCall`
|
||||
...
|
||||
18 | #[derive_impl(Pallet)] // Injects type RuntimeCall = RuntimeCall;
|
||||
| ---------------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `__export_tokens_tt_pallet` which comes from the expansion of the macro `frame_support::macro_magic::forward_tokens` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,25 @@
|
||||
use frame_support::{*, pallet_prelude::inject_runtime_type};
|
||||
use static_assertions::assert_type_eq_all;
|
||||
|
||||
pub trait Config {
|
||||
type RuntimeInfo;
|
||||
}
|
||||
|
||||
type RuntimeInfo = u32;
|
||||
|
||||
struct Pallet;
|
||||
|
||||
#[register_default_impl(Pallet)]
|
||||
impl Config for Pallet {
|
||||
#[inject_runtime_type]
|
||||
type RuntimeInfo = ();
|
||||
}
|
||||
|
||||
struct SomePallet;
|
||||
|
||||
#[derive_impl(Pallet)] // Injects type RuntimeInfo = RuntimeInfo;
|
||||
impl Config for SomePallet {}
|
||||
|
||||
assert_type_eq_all!(<SomePallet as Config>::RuntimeInfo, u32);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,14 @@
|
||||
error: `#[inject_runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo`
|
||||
--> tests/derive_impl_ui/inject_runtime_type_invalid.rs:15:5
|
||||
|
|
||||
15 | type RuntimeInfo = ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `RuntimeInfo`
|
||||
--> tests/derive_impl_ui/inject_runtime_type_invalid.rs:13:1
|
||||
|
|
||||
5 | type RuntimeInfo;
|
||||
| ---------------- `RuntimeInfo` from trait
|
||||
...
|
||||
13 | impl Config for Pallet {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ missing `RuntimeInfo` in implementation
|
||||
@@ -0,0 +1,25 @@
|
||||
use frame_support::{*, pallet_prelude::inject_runtime_type};
|
||||
use static_assertions::assert_type_eq_all;
|
||||
|
||||
pub trait Config {
|
||||
type RuntimeCall;
|
||||
}
|
||||
|
||||
type RuntimeCall = u32;
|
||||
|
||||
struct Pallet;
|
||||
|
||||
#[register_default_impl(Pallet)]
|
||||
impl Config for Pallet {
|
||||
#[inject_runtime_type]
|
||||
type RuntimeCall = ();
|
||||
}
|
||||
|
||||
struct SomePallet;
|
||||
|
||||
#[derive_impl(Pallet)] // Injects type RuntimeCall = RuntimeCall;
|
||||
impl Config for SomePallet {}
|
||||
|
||||
assert_type_eq_all!(<SomePallet as Config>::RuntimeCall, u32);
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user