-
Notifications
You must be signed in to change notification settings - Fork 803
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
wip/PoC: Enrich metadata custom types with essential types for chain communications #4358
Changes from 11 commits
f0ea720
fecdd47
1279594
ab4f6cc
e7bee31
d0986cf
c8061aa
e63dae6
c666a6f
fbd75b0
0fedb4d
17ade23
616e38d
482a5ed
785436c
a4d7ec7
c50d364
f40acd4
7659b19
ab0b1b1
b1d37e2
97396d0
3f5597e
a6532ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,10 @@ use syn::{spanned::Spanned, Ident, Result}; | |
|
||
/// The fixed name of the system pallet. | ||
const SYSTEM_PALLET_NAME: &str = "System"; | ||
/// The fixed name of the ForeignAssets pallet. | ||
const FOREIGN_ASSETS_PALLET_NAME: &str = "ForeignAssets"; | ||
/// The fixed name of the Assets pallet. | ||
const ASSETS_PALLET_NAME: &str = "Assets"; | ||
Comment on lines
+229
to
+232
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. This is nothing we want to integrate. Users will have no fucking idea that they should call the pallets this way. These pallets can also have multiple instances. This doesn't makes any sense and we should not start doing this. 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. Yep that makes sense! Its a bit of a hack to see how far I can get in subxt to remove those config types :D I think a better approach may be to collect the associated types from pallet's configs. However, I'll have to look how much that will increase the metadata size and if we run into limitations with it (maybe not all types impl TypeInfo for us to expose these), will think about it! Thanks for the review! 🙏 |
||
|
||
/// Implementation of `construct_runtime` macro. Either expand to some code which will call | ||
/// `construct_runtime` again, or expand to the final runtime definition. | ||
|
@@ -365,6 +369,12 @@ fn construct_runtime_final_expansion( | |
)) | ||
} | ||
|
||
// Find either the foreign assets pallet or the local assets pallet in this order. | ||
let assets_pallet = pallets | ||
.iter() | ||
.find(|decl| decl.name == FOREIGN_ASSETS_PALLET_NAME) | ||
.or_else(|| pallets.iter().find(|decl| decl.name == ASSETS_PALLET_NAME)); | ||
|
||
let features = pallets | ||
.iter() | ||
.filter_map(|decl| { | ||
|
@@ -388,6 +398,7 @@ fn construct_runtime_final_expansion( | |
let frame_system = generate_access_from_frame_or_crate("frame-system")?; | ||
let block = quote!(<#name as #frame_system::Config>::Block); | ||
let unchecked_extrinsic = quote!(<#block as #scrate::sp_runtime::traits::Block>::Extrinsic); | ||
let header = quote!(<#block as #scrate::sp_runtime::traits::Block>::Header); | ||
|
||
let outer_event = | ||
expand::expand_outer_enum(&name, &pallets, &scrate, expand::OuterEnumType::Event)?; | ||
|
@@ -406,6 +417,8 @@ fn construct_runtime_final_expansion( | |
&scrate, | ||
&unchecked_extrinsic, | ||
&system_pallet.path, | ||
assets_pallet, | ||
&header, | ||
); | ||
let outer_config = expand::expand_outer_config(&name, &pallets, &scrate); | ||
let inherent = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They already exist in the extrinsic metadata?