From f973f1cd8019b997e253e354350724da22d4b669 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 31 Jan 2025 23:10:25 +0100 Subject: [PATCH] Add `with_code_substitutes` to chain spec builder (DDay Poc: https://github.com/paritytech/polkadot-sdk/issues/5588) (https://github.com/paritytech/polkadot-sdk/issues/78) (https://github.com/paritytech/polkadot-sdk/issues/971) --- substrate/client/chain-spec/src/chain_spec.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/substrate/client/chain-spec/src/chain_spec.rs b/substrate/client/chain-spec/src/chain_spec.rs index fa161f1202ab1..293bee612b262 100644 --- a/substrate/client/chain-spec/src/chain_spec.rs +++ b/substrate/client/chain-spec/src/chain_spec.rs @@ -314,6 +314,7 @@ pub struct ChainSpecBuilder { protocol_id: Option, fork_id: Option, properties: Option, + code_substitutes: Option>, } impl ChainSpecBuilder { @@ -331,6 +332,7 @@ impl ChainSpecBuilder { protocol_id: None, fork_id: None, properties: None, + code_substitutes: None, } } @@ -413,6 +415,12 @@ impl ChainSpecBuilder { self } + /// Sets the `code_substitutes`. + pub fn with_code_substitutes(mut self, code_substitutes: BTreeMap) -> Self { + self.code_substitutes = Some(code_substitutes); + self + } + /// Builds a [`ChainSpec`] instance using the provided settings. pub fn build(self) -> ChainSpec { let client_spec = ClientSpec { @@ -427,7 +435,7 @@ impl ChainSpecBuilder { extensions: self.extensions, consensus_engine: (), genesis: Default::default(), - code_substitutes: BTreeMap::new(), + code_substitutes: self.code_substitutes.unwrap_or_default(), }; ChainSpec {