@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
161 lines (160 loc) • 6.87 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const inquirer_1 = __importDefault(require("inquirer"));
const child_process_1 = require("child_process");
const selectDeployConfigs = {
"Deploy All": {
name: "deploy-all",
description: "Deploy all contracts in the project",
},
"VeBetter Passport": {
name: "ve-better-passport",
description: "Deploy only this contract",
},
"X2Earn Creator": {
name: "x2-earn-creator",
description: "Deploy only this contract",
},
"Node Management": {
name: "node-management",
description: "Deploy only this contract",
},
"Multi Sig": {
name: "b3tr-multi-sig",
description: "Deploy only this contract",
},
Challenges: {
name: "b3tr-challenges",
description: "Deploy only this contract",
},
XAllocationVoting: {
name: "x-allocation-voting",
description: "Deploy only this contract",
},
RelayerRewardsPool: {
name: "relayer-rewards-pool",
description: "Deploy only this contract",
},
"Grants Manager": {
name: "grants-manager",
description: "Deploy only this contract",
},
"Dynamic Base Allocation Pool": {
name: "dba-pool",
description: "Deploy only this contract",
},
"Navigator Registry": {
name: "navigator-registry",
description: "Deploy only this contract",
},
};
async function deployContract() {
try {
const env = process.env.NEXT_PUBLIC_APP_ENV;
if (!env)
throw new Error("Environment variable NEXT_PUBLIC_APP_ENV is not set.");
console.log("Deploying contracts on", env);
// I want deployChoices to show the key of selectDeployConfigs and description, and I want it to return the name inside the object when selected
const deployChoices = Object.entries(selectDeployConfigs).map(([key, value]) => {
return {
name: `${key} - ${value.description}`,
value: value.name,
};
});
// Prompt the user to select contracts to deploy
const userChoice = await inquirer_1.default.prompt({
type: "list",
name: "deploy",
message: "Which contracts do you want to deploy?",
choices: deployChoices,
});
switch (userChoice.deploy) {
case "ve-better-passport":
console.log("Deploying VeBetter Passport");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "x2-earn-creator":
console.log("Deploying X2Earn Creator");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "node-management":
console.log("Deploying Node Management");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "b3tr-multi-sig":
console.log("Deploying Multi Sig");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "b3tr-challenges":
console.log("Deploying Challenges");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "x-allocation-voting":
console.log("Deploying XAllocationVoting");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "relayer-rewards-pool":
console.log("Deploying Relayer Rewards Pool");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "grants-manager":
console.log("Deploying Grants Manager");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "deploy-all":
console.log("Deploying all contracts");
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:${env}`, { stdio: "inherit" });
break;
case "dba-pool":
console.log("Deploying Dynamic Base Allocation Pool");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
case "navigator-registry":
console.log("Deploying Navigator Registry");
// Set environment variables
process.env.CONTRACT_TO_DEPLOY = userChoice.deploy;
// Run the upgrade script
(0, child_process_1.execSync)(`turbo run deploy:contract:${env}`, { stdio: "inherit" });
break;
default:
throw new Error("Invalid choice");
}
console.log("\nDeploy complete!");
}
catch (error) {
console.error("Deploy failed:", error);
process.exit(1);
}
}
deployContract();