Skip to content

Commit

Permalink
using merge_preserve_keys instead of merge
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk committed Nov 6, 2024
1 parent 16e877b commit 26405a9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cumulus/test/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn get_chain_spec_with_extra_endowed(

if let Some(id) = id {
// Merge parachain ID if given, otherwise use the one from the preset.
sc_chain_spec::json_merge(
sc_chain_spec::json_patch::merge_preserve_keys(
&mut patch_json,
json!({
"parachainInfo": {
Expand All @@ -85,7 +85,7 @@ pub fn get_chain_spec_with_extra_endowed(
);
};

sc_chain_spec::json_merge(&mut development_preset, patch_json.into());
sc_chain_spec::json_patch::merge_preserve_keys(&mut development_preset, patch_json.into());

ChainSpec::builder(
code,
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/utils/chain-spec-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ pub fn generate_chain_spec_for_runtime(cmd: &CreateCmd) -> Result<String, String
});
let mut chain_spec_json_blob = serde_json::from_str(chain_spec_json_string.as_str())
.map_err(|e| format!("deserialization a json failed {e}"))?;
json_patch::merge(&mut chain_spec_json_blob, parachain_properties);
json_patch::merge_preserve_keys(&mut chain_spec_json_blob, parachain_properties);
Ok(serde_json::to_string_pretty(&chain_spec_json_blob)
.map_err(|e| format!("to pretty failed: {e}"))?)
} else {
Expand Down
8 changes: 4 additions & 4 deletions substrate/client/chain-spec/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ pub fn update_code_in_json_chain_spec(chain_spec: &mut json::Value, code: &[u8])
code: &'a [u8],
}
let code_patch = json::json!({"genesis":{"runtimeGenesis": Container { code }}});
crate::json_patch::merge(chain_spec, code_patch);
crate::json_patch::merge_preserve_keys(chain_spec, code_patch);
true
} else if json_contains_path(&chain_spec, &mut raw_path) {
#[derive(Serialize)]
Expand All @@ -759,7 +759,7 @@ pub fn update_code_in_json_chain_spec(chain_spec: &mut json::Value, code: &[u8])
code: &'a [u8],
}
let code_patch = json::json!({"genesis":{"raw":{"top": Container { code }}}});
crate::json_patch::merge(chain_spec, code_patch);
crate::json_patch::merge_preserve_keys(chain_spec, code_patch);
true
} else {
false
Expand All @@ -773,7 +773,7 @@ pub fn set_code_substitute_in_json_chain_spec(
block_height: u64,
) {
let substitutes = json::json!({"codeSubstitutes":{ &block_height.to_string(): sp_core::bytes::to_hex(code, false) }});
crate::json_patch::merge(chain_spec, substitutes);
crate::json_patch::merge_preserve_keys(chain_spec, substitutes);
}

#[cfg(test)]
Expand Down Expand Up @@ -898,7 +898,7 @@ mod tests {
)
};
assert!(json_contains_path(&json, &mut path));
crate::json_patch::merge(&mut json, zeroing_patch);
crate::json_patch::merge_preserve_keys(&mut json, zeroing_patch);
json
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/test-utils/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ mod tests {
}
});

sc_chain_spec::json_merge(&mut default_config, patch);
sc_chain_spec::json_patch::merge_preserve_keys(&mut default_config, patch);

// Build genesis config using custom json:
let mut t = BasicExternalities::new_empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ fn patch_genesis(mut input_value: Value, para_id: Option<u32>) -> Value {
// This ensures compatibility with the inherents that we provide to successfully build a
// block.
if let Some(para_id) = para_id {
sc_chain_spec::json_patch::merge(
sc_chain_spec::json_patch::merge_preserve_keys(
&mut input_value,
json!({
"parachainInfo": {
Expand Down

0 comments on commit 26405a9

Please sign in to comment.