Skip to content

Commit

Permalink
Add with_code_substitutes to chain spec builder
Browse files Browse the repository at this point in the history
(DDay Poc: #5588)
(#78)
(#971)
  • Loading branch information
bkontur committed Jan 31, 2025
1 parent 0d35be7 commit f973f1c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion substrate/client/chain-spec/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ pub struct ChainSpecBuilder<E = NoExtension, EHF = ()> {
protocol_id: Option<String>,
fork_id: Option<String>,
properties: Option<Properties>,
code_substitutes: Option<BTreeMap<String, Bytes>>,
}

impl<E, EHF> ChainSpecBuilder<E, EHF> {
Expand All @@ -331,6 +332,7 @@ impl<E, EHF> ChainSpecBuilder<E, EHF> {
protocol_id: None,
fork_id: None,
properties: None,
code_substitutes: None,
}
}

Expand Down Expand Up @@ -413,6 +415,12 @@ impl<E, EHF> ChainSpecBuilder<E, EHF> {
self
}

/// Sets the `code_substitutes`.
pub fn with_code_substitutes(mut self, code_substitutes: BTreeMap<String, Bytes>) -> Self {
self.code_substitutes = Some(code_substitutes);
self
}

/// Builds a [`ChainSpec`] instance using the provided settings.
pub fn build(self) -> ChainSpec<E, EHF> {
let client_spec = ClientSpec {
Expand All @@ -427,7 +435,7 @@ impl<E, EHF> ChainSpecBuilder<E, EHF> {
extensions: self.extensions,
consensus_engine: (),
genesis: Default::default(),
code_substitutes: BTreeMap::new(),
code_substitutes: self.code_substitutes.unwrap_or_default(),
};

ChainSpec {
Expand Down

0 comments on commit f973f1c

Please sign in to comment.