Skip to content

Commit

Permalink
fix(orchestrator): fix chain-spec cmd custom (paritytech#1476)
Browse files Browse the repository at this point in the history
* fix(orchestrator): fix chain-spec cmd custom

* fmt
  • Loading branch information
pepoviola committed Nov 3, 2023
1 parent e48c162 commit 878f81c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions javascript/packages/orchestrator/src/configGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ export async function generateNetworkSpec(
}
} else {
parachainSetup.chainSpecCommand = parachain.chain_spec_command
? config.relaychain.chain_spec_command
? parachain.chain_spec_command
: `${collatorBinary} build-spec ${
parachain.chain ? "--chain " + parachain.chain : ""
parachain.chain ? "--chain {{chainName}}" : ""
} --disable-default-bootnode`;
}

Expand Down
23 changes: 17 additions & 6 deletions javascript/packages/orchestrator/src/paras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function generateParachainFiles(
chainSpecCommand: parachain.chainSpecCommand!,
defaultImage: parachain.collators[0].image,
},
chainName,
parachain.chain,
chainSpecFullPathPlain,
);
}
Expand Down Expand Up @@ -157,11 +157,9 @@ export async function generateParachainFiles(
// Generate the raw chain-spec logic

// Make sure we include the plain chain-spec
const chainSpecRawCommand = parachain
.chainSpecCommand!.split(" ")
.includes("--chain")
? parachain.chainSpecCommand
: `${parachain.chainSpecCommand} --chain {{chainName}}`;
const chainSpecRawCommand = getChainSpecCmdRaw(
parachain.chainSpecCommand!,
);

await getChainSpecRaw(
namespace,
Expand Down Expand Up @@ -333,3 +331,16 @@ export async function generateParachainFiles(

return;
}

function getChainSpecCmdRaw(chainSpecCommand: string) {
// Default to the provided cmd, will work for custom generator.
let returnCmd = chainSpecCommand;
const parts = chainSpecCommand!
.split(" ")
.filter((part: string) => part.length);
if (parts.includes("build-spec") && !parts.includes("--chain")) {
returnCmd = `${chainSpecCommand} --chain {{chainName}}`;
}

return returnCmd;
}

0 comments on commit 878f81c

Please sign in to comment.