clients/js: Add command to start evm validator (ganache)

commit-id:42791bce
This commit is contained in:
Csongor Kiss 2022-08-28 17:09:11 +02:00
parent c4f4652f35
commit b37efa4c1b
1 changed files with 15 additions and 5 deletions

View File

@ -11,7 +11,7 @@ exports.builder = function(y: typeof yargs) {
array: true, array: true,
default: [], default: [],
describe: "Additional args to validator", describe: "Additional args to validator",
}).command("aptos", "Start a local aptos validator", (yargs) => { }).command("aptos", "Start a local aptos validator", (_yargs) => {
}, (argv) => { }, (argv) => {
const dir = `${config.wormholeDir}/aptos`; const dir = `${config.wormholeDir}/aptos`;
// check if aptos is installed // check if aptos is installed
@ -21,9 +21,19 @@ exports.builder = function(y: typeof yargs) {
console.error(`See ${dir}/README.md for instructions.`); console.error(`See ${dir}/README.md for instructions.`);
process.exit(1); process.exit(1);
} }
const args = argv['validator-args'].map(a => `"${a}"`).join(" "); const cmd = `cd ${dir} && aptos node run-local-testnet --with-faucet --force-restart --assume-yes`;
const cmd = `cd ${dir} && aptos node run-local-testnet --with-faucet --force-restart --assume-yes ${args}`; runCommand(cmd, argv['validator-args']);
console.log("\x1b[33m%s\x1b[0m", cmd); }).command("evm", "Start a local EVM validator", (_yargs) => {
spawnSync(cmd, { shell: true, stdio: "inherit" }); }, (argv) => {
const dir = `${config.wormholeDir}/ethereum`;
const cmd = `cd ${dir} && npx ganache-cli -e 10000 --deterministic --time="1970-01-01T00:00:00+00:00"`;
runCommand(cmd, argv['validator-args']);
}).strict().demandCommand(); }).strict().demandCommand();
} }
function runCommand(baseCmd: string, args: string[]) {
const args_string = args.map(a => `"${a}"`).join(" ");
const cmd = `${baseCmd} ${args_string}`;
console.log("\x1b[33m%s\x1b[0m", cmd);
spawnSync(cmd, { shell: true, stdio: "inherit" });
}