-
Notifications
You must be signed in to change notification settings - Fork 710
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
RuntimeGenesiConfig
: json macro added
#5813
Conversation
RuntimeGenesiConfig
: json macro added
Co-authored-by: Sebastian Kunert <[email protected]>
I'll do one more renaming round. |
One thing I noticed while playing that is not supported is initilializing with full path, e.g. this fails: use frame_support::build_struct_json_patch;
mod sub_module {
#[derive(Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct B {
pub i_field: u32,
pub j_field: u32,
}
}
#[derive(Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct RuntimeGenesisConfig {
b_field: sub_module::B,
}
build_struct_json_patch!(RuntimeGenesisConfig { b_field: sub_module::B { i_field: 10 } }); The macro parses |
S**t I forgot about tests for paths, should be fixed with d6c8854 |
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.
Machine! :D
Nice!
I left some comments around macro hygiene, for the macro itself you have enough tests.
This PR adds `build_struct_json_patch` which helps to generate a JSON used for preset. Here is doc and example: https://github.com/paritytech/polkadot-sdk/blob/d868b858758d3886d16c8ba8feb3c93c188044f3/substrate/frame/support/src/generate_genesis_config.rs#L168-L266 And real-world usage: https://github.com/paritytech/polkadot-sdk/blob/d868b858758d3886d16c8ba8feb3c93c188044f3/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs#L37-L61 Closes paritytech#5700 --------- Co-authored-by: Sebastian Kunert <[email protected]>
This PR adds `build_struct_json_patch` which helps to generate a JSON used for preset. Here is doc and example: https://github.com/paritytech/polkadot-sdk/blob/d868b858758d3886d16c8ba8feb3c93c188044f3/substrate/frame/support/src/generate_genesis_config.rs#L168-L266 And real-world usage: https://github.com/paritytech/polkadot-sdk/blob/d868b858758d3886d16c8ba8feb3c93c188044f3/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs#L37-L61 Closes paritytech#5700 --------- Co-authored-by: Sebastian Kunert <[email protected]>
This PR adds
build_struct_json_patch
which helps to generate a JSON used for preset.Here is doc and example:
polkadot-sdk/substrate/frame/support/src/generate_genesis_config.rs
Lines 168 to 266 in d868b85
And real-world usage:
polkadot-sdk/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs
Lines 37 to 59 in c92afa3
Closes #5700