From 02b22d442811198a923eb5c8a4131d379f95c151 Mon Sep 17 00:00:00 2001 From: Andrew Dmytrenko Date: Tue, 5 Dec 2023 12:44:14 +0200 Subject: [PATCH 1/2] move console.log to deployed function --- scripts/deploy.ts | 48 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/scripts/deploy.ts b/scripts/deploy.ts index f8fef30..bcd1848 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -2,46 +2,32 @@ import { LockDealNFT, DealProvider, LockDealProvider, - TimedDealProvider, CollateralProvider, RefundProvider, VaultManager, - SimpleBuilder, - SimpleRefundBuilder, } from "../typechain-types" import { ethers } from "hardhat" -export const deployed = async (contractName: string, ...args: string[]): Promise => { - const Contract = await ethers.getContractFactory(contractName) - const contract = await Contract.deploy(...args) - return contract.deployed() as Promise -} +deployAllContracts().catch((error) => { + console.error(error) + process.exitCode = 1 +}) async function deployAllContracts() { const vaultManager: VaultManager = await deployed("VaultManager") - console.log(`VaultManager contract deployed to ${vaultManager.address}`) - const baseURI = "https://nft.poolz.finance/test/metadata/" // Deploy LockDealNFT contract const lockDealNFT: LockDealNFT = await deployed("LockDealNFT", vaultManager.address, baseURI) - console.log(`LockDealNFT contract deployed to ${lockDealNFT.address} with vaultManager ${vaultManager.address}`) // Deploy DealProvider contract const dealProvider: DealProvider = await deployed("DealProvider", lockDealNFT.address) - console.log(`DealProvider contract deployed to ${dealProvider.address} with lockDealNFT ${lockDealNFT.address}`) // Deploy LockDealProvider contract const lockProvider: LockDealProvider = await deployed("LockDealProvider", lockDealNFT.address, dealProvider.address) - console.log(`LockDealProvider contract deployed to ${lockProvider.address}`) // Deploy TimedDealProvider contract - const timedDealProvider: TimedDealProvider = await deployed( - "TimedDealProvider", - lockDealNFT.address, - lockProvider.address - ) - console.log(`TimedDealProvider contract deployed to ${timedDealProvider.address}`) + await deployed("TimedDealProvider", lockDealNFT.address, lockProvider.address) // Deploy CollateralProvider contract const collateralProvider: CollateralProvider = await deployed( @@ -49,7 +35,6 @@ async function deployAllContracts() { lockDealNFT.address, dealProvider.address ) - console.log(`CollateralProvider contract deployed to ${collateralProvider.address}`) // Deploy RefundProvider contract const refundProvider: RefundProvider = await deployed( @@ -57,22 +42,15 @@ async function deployAllContracts() { lockDealNFT.address, collateralProvider.address ) - console.log(`RefundProvider contract deployed to ${refundProvider.address}`) // Deploy Buiders - const simpleBuilder: SimpleBuilder = await deployed("SimpleBuilder", lockDealNFT.address) - console.log("Simple Builder deployed to", simpleBuilder.address) - - const simpleRefundBuilder: SimpleRefundBuilder = await deployed( - "SimpleRefundBuilder", - lockDealNFT.address, - refundProvider.address, - collateralProvider.address - ) - console.log("Simple Refund Builder deployed to", simpleRefundBuilder.address) + await deployed("SimpleBuilder", lockDealNFT.address) + await deployed("SimpleRefundBuilder", lockDealNFT.address, refundProvider.address, collateralProvider.address) } -deployAllContracts().catch((error) => { - console.error(error) - process.exitCode = 1 -}) +export const deployed = async (contractName: string, ...args: string[]): Promise => { + const Contract = await ethers.getContractFactory(contractName) + const contract = await Contract.deploy(...args) + console.log(`${contractName} contract deployed to ${contract.address}`) + return contract.deployed() as Promise +} From f94e407a2f2acb63165eace8375d10719881940a Mon Sep 17 00:00:00 2001 From: Andrew Dmytrenko Date: Tue, 5 Dec 2023 12:51:59 +0200 Subject: [PATCH 2/2] fix deployed scope --- scripts/deploy.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/deploy.ts b/scripts/deploy.ts index bcd1848..aa7d792 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -8,10 +8,12 @@ import { } from "../typechain-types" import { ethers } from "hardhat" -deployAllContracts().catch((error) => { - console.error(error) - process.exitCode = 1 -}) +export const deployed = async (contractName: string, ...args: string[]): Promise => { + const Contract = await ethers.getContractFactory(contractName) + const contract = await Contract.deploy(...args) + console.log(`${contractName} contract deployed to ${contract.address}`) + return contract.deployed() as Promise +} async function deployAllContracts() { const vaultManager: VaultManager = await deployed("VaultManager") @@ -48,9 +50,7 @@ async function deployAllContracts() { await deployed("SimpleRefundBuilder", lockDealNFT.address, refundProvider.address, collateralProvider.address) } -export const deployed = async (contractName: string, ...args: string[]): Promise => { - const Contract = await ethers.getContractFactory(contractName) - const contract = await Contract.deploy(...args) - console.log(`${contractName} contract deployed to ${contract.address}`) - return contract.deployed() as Promise -} +deployAllContracts().catch((error) => { + console.error(error) + process.exitCode = 1 +})