@@ -13,6 +13,9 @@ use pop_common::{
1313use std:: { fs, path:: Path } ;
1414use walkdir:: WalkDir ;
1515
16+ // The latest version where we should overwrite the ./network.toml file on.
17+ const LATEST_NETWORK_TOML_OVERWRITE_VERSION : & str = "polkadot-stable2506" ;
18+
1619/// Create a new chain.
1720///
1821/// # Arguments
@@ -48,7 +51,7 @@ pub fn instantiate_standard_template(
4851 let temp_dir = :: tempfile:: TempDir :: new_in ( std:: env:: temp_dir ( ) ) ?;
4952 let source = temp_dir. path ( ) ;
5053
51- let tag = Git :: clone_and_degit ( template. repository_url ( ) ?, source, tag_version) ?;
54+ let tag = Git :: clone_and_degit ( template. repository_url ( ) ?, source, tag_version. clone ( ) ) ?;
5255
5356 for entry in WalkDir :: new ( source) {
5457 let entry = entry?;
@@ -73,9 +76,16 @@ pub fn instantiate_standard_template(
7376 & target. join ( "node/src/chain_spec.rs" ) ,
7477 chainspec. render ( ) . expect ( "infallible" ) . as_ref ( ) ,
7578 ) ?;
76- // Add network configuration
77- let network = Network { node : "parachain-template-node" . into ( ) } ;
78- write_to_file ( & target. join ( "network.toml" ) , network. render ( ) . expect ( "infallible" ) . as_ref ( ) ) ?;
79+ if let Some ( version) = tag_version. as_deref ( ) &&
80+ version <= LATEST_NETWORK_TOML_OVERWRITE_VERSION
81+ {
82+ // Add network configuration
83+ let network = Network { node : "parachain-template-node" . into ( ) } ;
84+ write_to_file (
85+ & target. join ( "network.toml" ) ,
86+ network. render ( ) . expect ( "infallible" ) . as_ref ( ) ,
87+ ) ?;
88+ }
7989 Ok ( tag)
8090}
8191
@@ -106,7 +116,12 @@ mod tests {
106116 decimals : 18 ,
107117 initial_endowment : "1000000" . to_string ( ) ,
108118 } ;
109- instantiate_standard_template ( & ChainTemplate :: Standard , temp_dir. path ( ) , config, None ) ?;
119+ instantiate_standard_template (
120+ & ChainTemplate :: Standard ,
121+ temp_dir. path ( ) ,
122+ config,
123+ Some ( LATEST_NETWORK_TOML_OVERWRITE_VERSION . to_string ( ) ) ,
124+ ) ?;
110125 Ok ( temp_dir)
111126 }
112127
0 commit comments