From dcdbd851d62418a07250df2dbe8debc6955302c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20B=C3=A9ranger?= Date: Thu, 29 Feb 2024 12:35:32 +0100 Subject: [PATCH] Add reset option in scripts (#38) * add wait func * add reset --- deploy/deploy-basic.ts | 86 +++++++++++------------------------------- package.json | 8 ++-- 2 files changed, 26 insertions(+), 68 deletions(-) diff --git a/deploy/deploy-basic.ts b/deploy/deploy-basic.ts index 5884455..0bdcc81 100644 --- a/deploy/deploy-basic.ts +++ b/deploy/deploy-basic.ts @@ -8,6 +8,10 @@ const initialMint = ethers.parseEther("10000") export default async ({ getNamedAccounts, deployments }: any) => { const { deploy } = deployments + function wait(ms: number): Promise { + return new Promise(resolve => setTimeout(resolve, ms)) + } + const { deployer } = await getNamedAccounts() console.log("deployer:", deployer) @@ -18,62 +22,6 @@ export default async ({ getNamedAccounts, deployments }: any) => { }) switch (hre.network.name) { - case "arthera": - console.log( - "Basic ERC-20 token contract deployed:", - msg(basic.receipt.contractAddress) - ) - - try { - // Please use `pnpm sourcify:arthera` after the deployment instead. - - // console.log("\nEtherscan verification in progress...") - // console.log( - // "\nWaiting for 6 block confirmations (you can skip this part)" - // ) - // await basic.deploymentTransaction()?.wait(6) - // await hre.run("verify:verify", { - // network: network.name, - // address: basic.receipt.contractAddress, - // constructorArguments: [initialMint] - // }) - - console.log( - "Please use `pnpm sourcify:arthera` to verify your contract." - ) - } catch (error) { - console.error(error) - } - - break - case "arthera-testnet": - console.log( - "Basic ERC-20 token contract deployed:", - msg(basic.receipt.contractAddress) - ) - - try { - // Please use `pnpm sourcify:arthera` after the deployment instead. - - // console.log("\nEtherscan verification in progress...") - // console.log( - // "\nWaiting for 6 block confirmations (you can skip this part)" - // ) - // await basic.deploymentTransaction()?.wait(6) - // await hre.run("verify:verify", { - // network: network.name, - // address: basic.receipt.contractAddress, - // constructorArguments: [initialMint] - // }) - - console.log( - "Please use `pnpm sourcify:arthera-testnet` to verify your contract." - ) - } catch (error) { - console.error(error) - } - - break case "sepolia": try { console.log( @@ -81,10 +29,7 @@ export default async ({ getNamedAccounts, deployments }: any) => { msg(basic.receipt.contractAddress) ) console.log("\nEtherscan verification in progress...") - console.log( - "\nWaiting for 6 block confirmations (you can skip this part)" - ) - // await basic.deploymentTransaction()?.wait(6) + await wait(90 * 1000) await hre.run("verify:verify", { network: network.name, address: basic.receipt.contractAddress, @@ -103,10 +48,7 @@ export default async ({ getNamedAccounts, deployments }: any) => { msg(basic.receipt.contractAddress) ) console.log("\nEtherscan verification in progress...") - console.log( - "\nWaiting for 6 block confirmations (you can skip this part)" - ) - // await basic.deploymentTransaction()?.wait(6) + await wait(90 * 1000) await hre.run("verify:verify", { network: network.name, address: basic.receipt.contractAddress, @@ -117,6 +59,22 @@ export default async ({ getNamedAccounts, deployments }: any) => { console.error(error) } break + + case "arthera": + // the contract will be verified automatically + console.log( + "Basic ERC-20 token contract deployed:", + msg(basic.receipt.contractAddress) + ) + break + + case "arthera-testnet": + // the contract will be verified automatically + console.log( + "Basic ERC-20 token contract deployed:", + msg(basic.receipt.contractAddress) + ) + break } } export const tags = ["Basic"] diff --git a/package.json b/package.json index 4524fca..954d518 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "scripts": { "test": "hardhat test", "compile": "hardhat compile", - "deploy:arthera": "hardhat deploy --network arthera", - "deploy:sepolia": "hardhat deploy --network sepolia", - "deploy:arthera-testnet": "hardhat deploy --network arthera-testnet && hardhat sourcify --network arthera-testnet", - "deploy:op-sepolia": "hardhat deploy --network op-sepolia", + "deploy:arthera": "hardhat deploy --network arthera --reset", + "deploy:sepolia": "hardhat deploy --network sepolia --reset", + "deploy:arthera-testnet": "hardhat deploy --network arthera-testnet && hardhat sourcify --network arthera-testnet --reset", + "deploy:op-sepolia": "hardhat deploy --network op-sepolia --reset", "sourcify:arthera": "hardhat sourcify --network arthera", "sourcify:arthera-testnet": "hardhat sourcify --network arthera-testnet", "mint:arthera": "hardhat mint --network arthera --amount",