Skip to content

Commit

Permalink
fix: generic deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanSL committed Dec 19, 2023
1 parent 7526537 commit c916706
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit c916706

Please sign in to comment.