-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* preparations for the menu * dashboard and menu integration * add options * update menu script * add baseURI for menu options * add menu option to deploy only simple providers * menu item option - add only collateral and refund provider * refactor * menu progression * add LightMigrator to menu * refactor * add builders to menu * add deploy all option * add delayVaultProvider and migrator * add ability to multiply selection
- Loading branch information
1 parent
4e375ac
commit a04f5e2
Showing
16 changed files
with
1,598 additions
and
857 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
start cmd /k truffle dashboard | ||
start cmd /k ts-node .\\scripts\\terminal.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { getMenu } from "./utility/deployment/input" | ||
import { | ||
deployVaultAndLockDealNFT, | ||
deploySimpleProviders, | ||
deployRefundProvider, | ||
deployRefundAndCollateral, | ||
deployBuilders, | ||
deployAllContracts, | ||
deployLightMigrator, | ||
deployDelayProviderAndMigrator, | ||
} from "./utility/deployment/execute" | ||
|
||
const scriptPaths = [ | ||
"VaultAndLockDealNFT.ts", | ||
"SimpleProviders.ts", | ||
"RefundProvider.ts", | ||
"RefundAndCollateral.ts", | ||
"Builders.ts", | ||
"LightMigrator.ts", | ||
"DelayVaultProvider.ts", | ||
] | ||
|
||
const menuItems = [ | ||
{ name: "Deploy All contracts" }, | ||
...scriptPaths.map((script) => ({ name: `Deploy ${script.replace(".ts", "")}` })), | ||
] | ||
|
||
async function displayMenu() { | ||
let keepMenuOpen = true | ||
|
||
while (keepMenuOpen) { | ||
try { | ||
const answer = await getMenu(menuItems) | ||
|
||
switch (answer) { | ||
case "Deploy All contracts": | ||
await deployAllContracts() | ||
break | ||
case menuItems[1].name: | ||
await deployVaultAndLockDealNFT() | ||
break | ||
case menuItems[2].name: | ||
await deploySimpleProviders() | ||
break | ||
case menuItems[3].name: | ||
await deployRefundProvider() | ||
break | ||
case menuItems[4].name: | ||
await deployRefundAndCollateral() | ||
break | ||
case menuItems[5].name: | ||
await deployBuilders() | ||
break | ||
case menuItems[6].name: | ||
await deployLightMigrator() | ||
break | ||
case menuItems[7].name: | ||
await deployDelayProviderAndMigrator() | ||
break | ||
default: | ||
// Exit the loop if an invalid option is selected | ||
keepMenuOpen = false | ||
break | ||
} | ||
} catch (error) { | ||
console.error(`Error executing command: ${error}`) | ||
} | ||
} | ||
} | ||
|
||
displayMenu() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { deploy } from "../deployment" | ||
|
||
export async function deployBuilders( | ||
lockDealNFT: string, | ||
refundProvider: string, | ||
collateralProvider: string | ||
) { | ||
await deploy("SimpleBuilder", lockDealNFT) | ||
await deploy("SimpleRefundBuilder", lockDealNFT, refundProvider, collateralProvider) | ||
} | ||
|
||
const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || "" | ||
const refundProvider = process.env.REFUND_PROVIDER_ADDRESS || "" | ||
const collateralProvider = process.env.COLLATERAL_PROVIDER_ADDRESS || "" | ||
|
||
deployBuilders(lockDealNFT, refundProvider, collateralProvider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { deploy, delayVaultSettings } from "../deployment" | ||
import { DelayVaultMigrator } from "../../../typechain-types" | ||
import { POOLX } from "../constants" | ||
|
||
async function deployDelayProviderAndMigrator(lockDealNFT: string, v1DelayVault: string, lockProvider: string){ | ||
const migrator: DelayVaultMigrator = await deploy("DelayVaultMigrator", lockDealNFT, v1DelayVault) | ||
await deploy("DelayVaultProvider", POOLX, migrator.address, delayVaultSettings(lockProvider)) | ||
} | ||
|
||
// Retrieve environment variable | ||
const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || "" | ||
const v1DelayVault = process.env.V1_DELAY_VAULT || "" | ||
const lockProvider = process.env.LOCK_PROVIDER || "" | ||
|
||
deployDelayProviderAndMigrator(lockDealNFT, v1DelayVault, lockProvider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { deploy } from "../deployment" | ||
|
||
export async function deployLightMigrator(lockDealNFT: string, oldDelay: string, newDelay: string) { | ||
await deploy("LightMigrator", lockDealNFT, oldDelay, newDelay) | ||
} | ||
|
||
// Retrieve environment variables | ||
const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || "" | ||
const oldDelay = process.env.OLD_DELAY || "" | ||
const newDelay = process.env.NEW_DELAY || "" | ||
|
||
deployLightMigrator(lockDealNFT, oldDelay, newDelay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CollateralProvider } from "../../../typechain-types" | ||
import { deploy } from "../deployment" | ||
import { deployRefundProvider } from "./RefundProvider" | ||
|
||
export async function deployRefundWithCollateral(lockDealNFT: string, provider: string) { | ||
const collateralProvider: CollateralProvider = await deploy("CollateralProvider", lockDealNFT, provider) | ||
await deployRefundProvider(lockDealNFT, collateralProvider.address) | ||
} | ||
|
||
// Retrieve environment variables | ||
const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || "" | ||
const provider = process.env.PROVIDER_ADDRESS || "" | ||
|
||
deployRefundWithCollateral(lockDealNFT, provider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { deploy } from "../deployment" | ||
|
||
export async function deployRefundProvider(lockDealNFT: string, collateralProvider: string) { | ||
await deploy("RefundProvider", lockDealNFT, collateralProvider) | ||
} | ||
|
||
// Retrieve environment variables | ||
const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || "" | ||
const provider = process.env.COLLATERAL || "" | ||
|
||
deployRefundProvider(lockDealNFT, provider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DealProvider, LockDealProvider } from "../../../typechain-types"; | ||
import { deploy } from "../deployment" | ||
|
||
export async function deploySimpleProviders(lockDealNFT: string) { | ||
const dealProvider: DealProvider = await deploy("DealProvider", lockDealNFT); | ||
const lockProvider: LockDealProvider = await deploy("LockDealProvider", lockDealNFT, dealProvider.address); | ||
await deploy("TimedDealProvider", lockDealNFT, lockProvider.address); | ||
|
||
console.log("SimpleProviders deployed successfully!"); | ||
} | ||
|
||
const lockDealNFTAddress = process.env.LOCK_DEAL_NFT_ADDRESS || ""; | ||
|
||
deploySimpleProviders(lockDealNFTAddress); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { deploy } from "../deployment" | ||
import { VaultManager } from "../../../typechain-types" | ||
|
||
async function deployNFTandVaultManager(baseURI: string = "") { | ||
const vaultManager: VaultManager = await deploy("VaultManager") | ||
await deploy("LockDealNFT", vaultManager.address, baseURI) | ||
} | ||
|
||
// Retrieve environment variable | ||
const baseURI = process.env.BASEURI || "" | ||
|
||
deployNFTandVaultManager(baseURI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// scriptDeployer.js | ||
import { exec } from "child_process"; | ||
import util from "util"; | ||
import { | ||
getBaseURI, | ||
getLockDealNFTAddress, | ||
getCollateralProviderAddress, | ||
getDealProviderAddress, | ||
getLockProviderAddress, | ||
getOldDelay, | ||
getNewDelay, | ||
getRefundProviderAddress, | ||
} from "./input"; | ||
|
||
const execAsync = util.promisify(exec); | ||
|
||
async function executeScript(scriptName: string, scriptPath: string) { | ||
const network = "truffleDashboard"; | ||
const command = `npx hardhat run ${scriptPath} --network ${network}`; | ||
|
||
await execAsync(command); | ||
console.log(`Command executed successfully: Deploy ${scriptName}`); | ||
} | ||
|
||
export async function deployVaultAndLockDealNFT() { | ||
process.env.BASEURI = await getBaseURI(); | ||
await executeScript("VaultAndLockDealNFT", "scripts/utility/deployment/VaultAndLockDealNFT.ts"); | ||
} | ||
|
||
export async function deploySimpleProviders() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
await executeScript("SimpleProviders", "scripts/utility/deployment/SimpleProviders.ts"); | ||
} | ||
|
||
export async function deployRefundProvider() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
process.env.COLLATERAL = await getCollateralProviderAddress(); | ||
await executeScript("RefundProvider", "scripts/utility/deployment/RefundProvider.ts"); | ||
} | ||
|
||
export async function deployRefundAndCollateral() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
process.env.PROVIDER_ADDRESS = await getDealProviderAddress(); | ||
await executeScript("RefundAndCollateral", "scripts/utility/deployment/RefundAndCollateral.ts"); | ||
} | ||
|
||
export async function deployLightMigrator() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
process.env.OLD_DELAY = await getOldDelay(); | ||
process.env.NEW_DELAY = await getNewDelay(); | ||
await executeScript("LightMigrator", "scripts/utility/deployment/LightMigrator.ts"); | ||
} | ||
|
||
export async function deployBuilders() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
process.env.REFUND_PROVIDER_ADDRESS = await getRefundProviderAddress(); | ||
process.env.COLLATERAL_PROVIDER_ADDRESS = await getCollateralProviderAddress(); | ||
await executeScript("Builders", "scripts/utility/deployment/Builders.ts"); | ||
} | ||
|
||
export async function deployDelayProviderAndMigrator() { | ||
process.env.LOCK_DEAL_NFT_ADDRESS = await getLockDealNFTAddress(); | ||
process.env.V1_DELAY_VAULT = await getOldDelay(); | ||
process.env.LOCK_PROVIDER = await getLockProviderAddress(); | ||
await executeScript("DelayProviderAndMigrator", "scripts/utility/deployment/DelayVaultProvider.ts"); | ||
} | ||
|
||
export async function deployAllContracts() { | ||
process.env.BASEURI = await getBaseURI(); | ||
await executeScript("AllContracts", "scripts/deploy.ts"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// inquirerPrompts.js | ||
const inquirer = require("inquirer") | ||
|
||
async function promptUser( | ||
message: string, | ||
name: string, | ||
type = "input", | ||
choices: { name: string }[] = [], | ||
defaultValue = "" | ||
) { | ||
const answer = await inquirer.prompt([ | ||
{ | ||
type, | ||
name, | ||
message, | ||
choices, | ||
default: defaultValue, | ||
}, | ||
]) | ||
return answer[name] | ||
} | ||
|
||
async function getBaseURI() { | ||
return await promptUser("Enter the baseURI for NFT deployment:", "baseURI") | ||
} | ||
|
||
async function getLockDealNFTAddress() { | ||
return await promptUser("Enter the LockDealNFT address for deployment:", "lockDealNFTAddress") | ||
} | ||
|
||
async function getDealProviderAddress() { | ||
return await promptUser("Enter the Deal Provider address for deployment:", "providerAddress") | ||
} | ||
|
||
async function getLockProviderAddress() { | ||
return await promptUser("Enter the Lock Provider address for deployment:", "providerAddress") | ||
} | ||
|
||
async function getCollateralProviderAddress() { | ||
return await promptUser("Enter the Collateral Provider address for deployment:", "collateralProviderAddress") | ||
} | ||
|
||
async function getMenu(menuItems: { name: string }[]) { | ||
return await promptUser("Choose a menu item:\n", "menuItem", "list", menuItems) | ||
} | ||
|
||
async function getOldDelay() { | ||
return await promptUser("Enter the old delay address for deployment:", "oldDelay") | ||
} | ||
|
||
async function getNewDelay() { | ||
return await promptUser("Enter the new delay address for deployment:", "newDelay") | ||
} | ||
|
||
async function getRefundProviderAddress() { | ||
return await promptUser("Enter the Refund Provider address for deployment:", "refundProviderAddress") | ||
} | ||
|
||
export { | ||
getBaseURI, | ||
getLockDealNFTAddress, | ||
getDealProviderAddress, | ||
getLockProviderAddress, | ||
getCollateralProviderAddress, | ||
getMenu, | ||
getOldDelay, | ||
getNewDelay, | ||
getRefundProviderAddress, | ||
} |
Oops, something went wrong.