This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Proposal: Flatten AllPallets and similar types
#11813
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5d07608
flratten AllPallets types
kianenigma f46e648
feature flag it
kianenigma 1bb98a2
fix
kianenigma 9bc95fd
fix
kianenigma dc211b9
fmt
kianenigma 9bef35c
Merge remote-tracking branch 'origin/master' into kiz-flatten-all-pal…
e1f8c25
Merge branch 'master' of github.com:paritytech/substrate into kiz-fla…
kianenigma 81cbf48
remove todo
kianenigma 3aea087
master
kianenigma d4a8139
Update frame/support/src/traits/metadata.rs
kianenigma cf4790a
Update frame/support/src/migrations.rs
kianenigma ed03bfc
fix
kianenigma fdd602e
mark as deprecated
kianenigma f94a859
Merge remote-tracking branch 'origin/master' into kiz-flatten-all-pal…
5898880
add docs
kianenigma f9b788b
fix ui test?
kianenigma 7737659
Merge branch 'kiz-flatten-all-pallets-type' of github.com:paritytech/…
kianenigma a2ab6ec
fmt
kianenigma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -308,47 +308,26 @@ fn decl_all_pallets<'a>( | |||||
| names.push(&pallet_declaration.name); | ||||||
| } | ||||||
|
|
||||||
| // Make nested tuple structure like: | ||||||
| // `((FirstPallet, (SecondPallet, ( ... , LastPallet) ... ))))` | ||||||
| // But ignore the system pallet. | ||||||
| let all_pallets_without_system = names | ||||||
| .iter() | ||||||
| .filter(|n| **n != SYSTEM_PALLET_NAME) | ||||||
| .rev() | ||||||
| .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); | ||||||
|
|
||||||
| // Make nested tuple structure like: | ||||||
| // `((FirstPallet, (SecondPallet, ( ... , LastPallet) ... ))))` | ||||||
| let all_pallets_with_system = names | ||||||
| .iter() | ||||||
| .rev() | ||||||
| .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); | ||||||
|
|
||||||
| // Make nested tuple structure like: | ||||||
| // `((LastPallet, (SecondLastPallet, ( ... , FirstPallet) ... ))))` | ||||||
| // But ignore the system pallet. | ||||||
| let all_pallets_without_system_reversed = names | ||||||
| .iter() | ||||||
| .filter(|n| **n != SYSTEM_PALLET_NAME) | ||||||
| .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); | ||||||
|
|
||||||
| // Make nested tuple structure like: | ||||||
| // `((LastPallet, (SecondLastPallet, ( ... , FirstPallet) ... ))))` | ||||||
| let all_pallets_with_system_reversed = names | ||||||
| .iter() | ||||||
| .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); | ||||||
|
|
||||||
| let system_pallet = match names.iter().find(|n| **n == SYSTEM_PALLET_NAME) { | ||||||
| Some(name) => name, | ||||||
| None => | ||||||
| return syn::Error::new( | ||||||
| proc_macro2::Span::call_site(), | ||||||
| "`System` pallet declaration is missing. \ | ||||||
| Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event<T>},`", | ||||||
| Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event<T>},`", | ||||||
| ) | ||||||
| .into_compile_error(), | ||||||
| }; | ||||||
|
|
||||||
| let names_without_system = | ||||||
| names.iter().filter(|n| **n != SYSTEM_PALLET_NAME).collect::<Vec<_>>(); | ||||||
| let names_reversed = names.clone().into_iter().rev().collect::<Vec<_>>(); | ||||||
| let names_without_system_reverse = | ||||||
| names_without_system.clone().into_iter().rev().collect::<Vec<_>>(); | ||||||
| let names_reversed_with_system_first = std::iter::once(system_pallet) | ||||||
| .chain(names_without_system_reverse.clone().into_iter()) | ||||||
| .collect::<Vec<_>>(); | ||||||
bkchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| quote!( | ||||||
| #types | ||||||
|
|
||||||
|
|
@@ -364,25 +343,28 @@ fn decl_all_pallets<'a>( | |||||
| pub type AllPallets = AllPalletsWithSystem; | ||||||
|
|
||||||
| /// All pallets included in the runtime as a nested tuple of types. | ||||||
| pub type AllPalletsWithSystem = ( #all_pallets_with_system ); | ||||||
| pub type AllPalletsWithSystem = ( #(#names),* ); | ||||||
|
|
||||||
| /// All pallets included in the runtime as a nested tuple of types. | ||||||
| /// Excludes the System pallet. | ||||||
| pub type AllPalletsWithoutSystem = ( #all_pallets_without_system ); | ||||||
| pub type AllPalletsWithoutSystem = ( #(#names_without_system),* ); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| /// All pallets included in the runtime as a nested tuple of types in reversed order. | ||||||
| /// Excludes the System pallet. | ||||||
| pub type AllPalletsWithoutSystemReversed = ( #all_pallets_without_system_reversed ); | ||||||
| #[deprecated(note = "Using reverse pallet orders is deprecated. use only \ | ||||||
| `AllPalletWithSystem or AllPalletsWithoutSystem`")] | ||||||
| pub type AllPalletsWithoutSystemReversed =( #(#names_without_system_reverse),* ); | ||||||
|
|
||||||
| /// All pallets included in the runtime as a nested tuple of types in reversed order. | ||||||
| pub type AllPalletsWithSystemReversed = ( #all_pallets_with_system_reversed ); | ||||||
| #[deprecated(note = "Using reverse pallet orders is deprecated. use only \ | ||||||
| `AllPalletWithSystem or AllPalletsWithoutSystem`")] | ||||||
| pub type AllPalletsWithSystemReversed = ( #(#names_reversed),* ); | ||||||
|
|
||||||
| /// All pallets included in the runtime as a nested tuple of types in reversed order. | ||||||
| /// With the system pallet first. | ||||||
| pub type AllPalletsReversedWithSystemFirst = ( | ||||||
| #system_pallet, | ||||||
| AllPalletsWithoutSystemReversed | ||||||
| ); | ||||||
| #[deprecated(note = "Using reverse pallet orders is deprecated. use only \ | ||||||
| `AllPalletWithSystem or AllPalletsWithoutSystem`")] | ||||||
| pub type AllPalletsReversedWithSystemFirst = ( #(#names_reversed_with_system_first),* ); | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.