From c9167068d2b619c3afc53b4488ca40a4a4f51efc Mon Sep 17 00:00:00 2001 From: ioanSL Date: Tue, 19 Dec 2023 12:00:11 +0200 Subject: [PATCH] fix: generic deploy script --- scripts/deploy.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/deploy.ts b/scripts/deploy.ts index b42d5a1..d12adc4 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -1,28 +1,30 @@ import { ethers } from "hardhat"; +import fs from "fs"; -async function deployDelegate() { - const delegate = await ethers.deployContract("Delegate"); +async function deployContract(contractName: string) { + const contract = await ethers.deployContract(contractName); - await delegate.waitForDeployment(); + await contract.waitForDeployment(); - console.log(`Delegate deployed to ${delegate.target}`); + console.log(`Delegate deployed to ${contract.target}`); + + // Save delegate.target to .env file + fs.writeFileSync( + ".env", + `\n${contractName.toUpperCase()}_TARGET=${contract.target}`, + { flag: "a" } + ); } -async function deployERC721() { - const erc721 = await ethers.deployContract("MockERC721"); - await erc721.waitForDeployment(); +async function main() { + await deployContract("Delegate"); + await deployContract("LicenseCheck"); - console.log(`Mock ERC721 deployed to ${erc721.target}`); + console.log("Done! Check .env file for deployed contract addresses."); } -async function main() { - await deployERC721(); - await deployDelegate(); -} -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. main().catch((error) => { console.error(error); process.exitCode = 1;