dsa-connectors/scripts/deployment/deployConnectorsFromCmd.ts

89 lines
2.1 KiB
TypeScript
Raw Permalink Normal View History

import { execScript } from "../tests/command";
import inquirer from "inquirer";
import { connectors, connectMapping } from "./connectors";
import { join } from "path";
2022-01-11 09:47:35 +00:00
let start: number, end: number, runchain: string;
2021-12-26 07:47:07 +00:00
2022-01-12 11:17:50 +00:00
// async function connectorSelect(chain: string) {
// let { connector } = await inquirer.prompt([
// {
// name: "connector",
// message: "Which connector do you want to deploy?",
// type: "list",
// choices: connectors[chain],
// },
// ]);
// return connector;
// }
2022-01-11 08:19:13 +00:00
async function deployRunner() {
2022-01-11 08:19:13 +00:00
let { chain } = await inquirer.prompt([
{
name: "chain",
message: "What chain do you want to deploy on?",
type: "list",
2022-03-20 14:39:04 +00:00
choices: ["mainnet", "polygon", "avalanche", "arbitrum", "optimism", "fantom"]
2022-03-09 12:03:47 +00:00
}
]);
2022-01-12 11:17:50 +00:00
// let connector = await connectorSelect(chain);
2022-01-11 08:19:13 +00:00
2022-01-12 11:17:50 +00:00
// let { choice } = await inquirer.prompt([
// {
// name: "choice",
// message: "Do you wanna select again?",
// type: "list",
// choices: ["yes", "no"],
// },
// ]);
// if (choice === "yes") {
// connector = await connectorSelect(chain);
// }
// connector = connectMapping[chain][connector];
let { connector } = await inquirer.prompt([
{
2022-01-12 11:17:50 +00:00
name: "connector",
message: "Enter the connector contract name? (ex: ConnectV2Paraswap)",
2022-03-09 12:03:47 +00:00
type: "input"
}
]);
2022-01-12 11:17:50 +00:00
let { choice } = await inquirer.prompt([
2022-01-11 08:19:13 +00:00
{
2022-01-12 11:17:50 +00:00
name: "choice",
2022-01-11 08:19:13 +00:00
message: "Do you wanna try deploy on hardhat first?",
type: "list",
2022-03-09 12:03:47 +00:00
choices: ["yes", "no"]
}
2022-01-11 08:19:13 +00:00
]);
2022-01-12 11:17:50 +00:00
runchain = choice === "yes" ? "hardhat" : chain;
2022-01-11 08:19:13 +00:00
2022-03-09 12:03:47 +00:00
console.log(`Deploying ${connector} on ${runchain}, press (ctrl + c) to stop`);
2022-01-11 08:19:13 +00:00
2021-12-26 07:47:07 +00:00
start = Date.now();
await execScript({
cmd: "npx",
2022-03-09 12:03:47 +00:00
args: ["hardhat", "run", "scripts/deployment/deploy.ts", "--network", `${runchain}`],
env: {
connectorName: connector,
2022-03-09 12:03:47 +00:00
networkType: chain
}
});
2021-12-26 07:47:07 +00:00
end = Date.now();
2021-12-04 13:08:16 +00:00
}
deployRunner()
2021-12-04 13:08:16 +00:00
.then(() => {
2022-03-09 12:03:47 +00:00
console.log(`Done successfully, total time taken: ${(end - start) / 1000} sec`);
2021-12-04 13:08:16 +00:00
process.exit(0);
})
.catch((err) => {
console.log("error:", err);
process.exit(1);
});