Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bfc3ff7
Adds ability to use defaults for verbatim types
gupnik Jul 30, 2023
18dc0ac
Adds RuntimeOrigin and PalletInfo in DefaultConfig
gupnik Jul 30, 2023
7fb9749
Adds RuntimeEvent in DefaultConfig
gupnik Jul 30, 2023
43fff80
Adds RuntimeEvent in DefaultConfig
gupnik Jul 30, 2023
8e45209
Minor fix
gupnik Jul 30, 2023
9af59d6
Minor fix
gupnik Jul 30, 2023
44f2845
Everything in frame_system can now have a default
gupnik Jul 30, 2023
eed9dc8
Adds docs
gupnik Aug 4, 2023
d2a3546
Adds UI Test for no_bounds
gupnik Aug 4, 2023
821424a
Updates docs
gupnik Aug 4, 2023
5e54173
Adds UI tests for verbatim
gupnik Aug 4, 2023
cd3e530
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 4, 2023
641cc9b
Minor update
gupnik Aug 4, 2023
90af58e
Minor updates
gupnik Aug 4, 2023
c3f5134
Minor updates
gupnik Aug 4, 2023
7f80e65
Addresses review comments
gupnik Aug 9, 2023
38c0601
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 9, 2023
846f296
Fixes test
gupnik Aug 9, 2023
6dfb929
Update frame/support/procedural/src/derive_impl.rs
gupnik Aug 13, 2023
0ddf452
Minor fix
gupnik Aug 13, 2023
3e90665
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 14, 2023
de6e5b6
Minor
gupnik Aug 14, 2023
ce1ad29
Optionally keep verbatim to be replaced later
gupnik Aug 14, 2023
821758b
Fixes build
gupnik Aug 14, 2023
d33f51f
Uses runtime_type
gupnik Aug 15, 2023
96fc62c
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 17, 2023
e051985
Fixes comment
gupnik Aug 17, 2023
16028ff
Fixes comment
gupnik Aug 17, 2023
34f66f6
Fixes test
gupnik Aug 17, 2023
97e470c
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 17, 2023
92ddd1e
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 17, 2023
3524c14
Uses no_aggregated_types as an option in derive_impl
gupnik Aug 21, 2023
1218faf
Uses specific imports
gupnik Aug 21, 2023
01071a9
Fmt
gupnik Aug 21, 2023
a3db9f4
Updates doc
gupnik Aug 21, 2023
28f7cec
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 22, 2023
9d31723
Update frame/support/procedural/src/derive_impl.rs
gupnik Aug 23, 2023
3f1fcc6
Update frame/support/procedural/src/derive_impl.rs
gupnik Aug 23, 2023
58762cf
Addresses review comment
gupnik Aug 23, 2023
cb2a8e0
Addresses review comment
gupnik Aug 23, 2023
32f33ae
fmt
gupnik Aug 23, 2023
88f6253
Renames test files
gupnik Aug 23, 2023
bb30704
Adds docs using docify
gupnik Aug 24, 2023
8f3191f
Fixes test
gupnik Aug 24, 2023
718c1ce
Fixes UI tests
gupnik Aug 24, 2023
969bf0e
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Aug 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addresses review comment
  • Loading branch information
gupnik committed Aug 23, 2023
commit cb2a8e08e0a50ca3aec123ad8832eded5f3f35ab
2 changes: 1 addition & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub mod pallet {

#[frame_support::register_default_impl(TestDefaultConfig)]
impl DefaultConfig for TestDefaultConfig {
#[runtime_type]
#[inject_runtime_type]
type RuntimeEvent = ();

type Balance = u64;
Expand Down
2 changes: 1 addition & 1 deletion frame/examples/default-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub mod tests {
// type BlockHashCount = frame_support::traits::ConstU64<10>;
// type OnSetCode = ();

// These are marked as `#[runtime_type]`. Hence, they are being injected as
// These are marked as `#[inject_runtime_type]`. Hence, they are being injected as
// types generated by `construct_runtime`.

// type RuntimeOrigin = RuntimeOrigin;
Expand Down
6 changes: 3 additions & 3 deletions frame/support/procedural/src/derive_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ use syn::{
};

mod keyword {
syn::custom_keyword!(runtime_type);
syn::custom_keyword!(inject_runtime_type);
syn::custom_keyword!(no_aggregated_types);
}

#[derive(derive_syn_parse::Parse, PartialEq, Eq)]
pub enum PalletAttrType {
#[peek(keyword::runtime_type, name = "runtime_type")]
RuntimeType(keyword::runtime_type),
#[peek(keyword::inject_runtime_type, name = "inject_runtime_type")]
RuntimeType(keyword::inject_runtime_type),
}

#[derive(derive_syn_parse::Parse)]
Expand Down
10 changes: 5 additions & 5 deletions frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// ```
///
/// If specified, this indicates that the aggregated types (as denoted by impl items
/// attached with [`#[runtime_type]`]) should not be injected with the respective concrete types. By
/// attached with [`#[inject_runtime_type]`]) should not be injected with the respective concrete types. By
/// default, all such types are injected.
///
/// You can also make use of `#[pallet::no_default]` on specific items in your default impl that you
Expand Down Expand Up @@ -870,18 +870,18 @@ pub fn register_default_impl(attrs: TokenStream, tokens: TokenStream) -> TokenSt
}
}

/// The optional attribute `#[runtime_type]` can be attached to `RuntimeCall`, `RuntimeEvent`,
/// The optional attribute `#[inject_runtime_type]` can be attached to `RuntimeCall`, `RuntimeEvent`,
/// `RuntimeOrigin` or `PalletInfo` in an impl statement that has `#[register_default_impl]`
/// attached to indicate that this item is generated by `construct_runtime`.
///
/// Attaching this attribute to such an item ensures that the combined impl generated via
/// [`#[derive_impl(..)]`](`macro@derive_impl`) will use the correct type auto-generated by
/// [`construct_runtime!`].
///
/// As an example, if you have an impl item `#[runtime_type] type RuntimeEvent = ();` in
/// As an example, if you have an impl item `#[inject_runtime_type] type RuntimeEvent = ();` in
/// your impl statement, the combined impl will have `type RuntimeEvent = RuntimeEvent;` instead.
#[proc_macro_attribute]
pub fn runtime_type(_: TokenStream, tokens: TokenStream) -> TokenStream {
pub fn inject_runtime_type(_: TokenStream, tokens: TokenStream) -> TokenStream {
let item = tokens.clone();
let item = syn::parse_macro_input!(item as TraitItemType);
if item.ident != "RuntimeCall" &&
Expand All @@ -891,7 +891,7 @@ pub fn runtime_type(_: TokenStream, tokens: TokenStream) -> TokenStream {
{
return syn::Error::new_spanned(
item,
"`#[runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo`",
"`#[inject_runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo`",
)
.to_compile_error()
.into();
Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ pub mod pallet_macros {
call_index, compact, composite_enum, config, constant,
disable_frame_system_supertrait_check, error, event, extra_constants, generate_deposit,
generate_store, genesis_build, genesis_config, getter, hooks, import_section, inherent,
no_default, no_default_bounds, origin, pallet_section, runtime_type, storage,
no_default, no_default_bounds, origin, pallet_section, inject_runtime_type, storage,
storage_prefix, storage_version, type_value, unbounded, validate_unsigned, weight,
whitelist_storage,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use frame_support::{*, pallet_macros::runtime_type};
use frame_support::{*, pallet_macros::inject_runtime_type};
use static_assertions::assert_type_eq_all;

pub trait Config {
Expand All @@ -11,7 +11,7 @@ struct Pallet;

#[register_default_impl(Pallet)]
impl Config for Pallet {
#[runtime_type]
#[inject_runtime_type]
type RuntimeCall = ();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use frame_support::{*, pallet_macros::runtime_type};
use frame_support::{*, pallet_macros::inject_runtime_type};
use static_assertions::assert_type_eq_all;

pub trait Config {
Expand All @@ -9,7 +9,7 @@ struct Pallet;

#[register_default_impl(Pallet)]
impl Config for Pallet {
#[runtime_type]
#[inject_runtime_type]
type RuntimeCall = ();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `RuntimeCall` in this scope
--> tests/derive_impl_ui/runtime_type_fails_when_type_not_in_scope.rs:13:10
--> 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`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use frame_support::{*, pallet_macros::runtime_type};
use frame_support::{*, pallet_macros::inject_runtime_type};
use static_assertions::assert_type_eq_all;

pub trait Config {
Expand All @@ -11,7 +11,7 @@ struct Pallet;

#[register_default_impl(Pallet)]
impl Config for Pallet {
#[runtime_type]
#[inject_runtime_type]
type RuntimeInfo = ();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: `#[runtime_type]` can only be attached to `RuntimeCall`, `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo`
--> tests/derive_impl_ui/runtime_type_invalid.rs:15:5
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/runtime_type_invalid.rs:13:1
--> tests/derive_impl_ui/inject_runtime_type_invalid.rs:13:1
|
5 | type RuntimeInfo;
| ---------------- `RuntimeInfo` from trait
Expand Down
10 changes: 5 additions & 5 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub mod pallet {

/// Default implementations of [`DefaultConfig`], which can be used to implement [`Config`].
pub mod config_preludes {
use super::{runtime_type, DefaultConfig};
use super::{inject_runtime_type, DefaultConfig};

/// Provides a viable default config that can be used with
/// [`derive_impl`](`frame_support::derive_impl`) to derive a testing pallet config
Expand All @@ -232,13 +232,13 @@ pub mod pallet {
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
#[runtime_type]
#[inject_runtime_type]
type RuntimeEvent = ();
#[runtime_type]
#[inject_runtime_type]
type RuntimeOrigin = ();
#[runtime_type]
#[inject_runtime_type]
type RuntimeCall = ();
#[runtime_type]
#[inject_runtime_type]
type PalletInfo = ();
type BaseCallFilter = frame_support::traits::Everything;
type BlockHashCount = frame_support::traits::ConstU64<10>;
Expand Down