From 5186a9c3602eabbb2aa683c7f94eee8bc772cf98 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Mon, 28 Aug 2023 13:33:14 +0200 Subject: [PATCH] fix deploy scripts --- deploy/00_deploy_ERC6551Registry.ts | 31 +++++++++++++++++++ ... 01_deploy_mastercopy_ERC721Tokenbound.ts} | 16 ++++++++-- ...02_deploy_mastercopy_ERC1155Tokenbound.ts} | 14 +++++++-- ...diac.ts => 03_deploy_mastercopy_Zodiac.ts} | 14 +++++++-- test/utils.ts | 2 +- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 deploy/00_deploy_ERC6551Registry.ts rename deploy/{00_deploy_mastercopy_ERC721Tokenbound.ts => 01_deploy_mastercopy_ERC721Tokenbound.ts} (69%) rename deploy/{01_deploy_mastercopy_ERC1155Tokenbound.ts => 02_deploy_mastercopy_ERC1155Tokenbound.ts} (71%) rename deploy/{02_deploy_mastercopy_Zodiac.ts => 03_deploy_mastercopy_Zodiac.ts} (73%) diff --git a/deploy/00_deploy_ERC6551Registry.ts b/deploy/00_deploy_ERC6551Registry.ts new file mode 100644 index 0000000..b7b0cb3 --- /dev/null +++ b/deploy/00_deploy_ERC6551Registry.ts @@ -0,0 +1,31 @@ +import { DeployFunction } from "hardhat-deploy/types" + +const deployERC6551Registry: DeployFunction = async (hre) => { + // const [signer] = await hre.ethers.getSigners() + + const ERC6551Registry = await hre.ethers.getContractFactory("ERC6551Registry") + const erc6551Registry = await ERC6551Registry.deploy() + + try { + await hre.run("verify:verify", { + address: await erc6551Registry.getAddress(), + constructorArguments: [], + }) + } catch (e) { + if ( + e instanceof Error && + e.stack && + (e.stack.indexOf("Reason: Already Verified") > -1 || + e.stack.indexOf("Contract source code already verified") > -1) + ) { + console.log(" ✔ Contract is already verified") + } else { + console.log( + " ✘ Verifying the contract failed. This is probably because Etherscan is still indexing the contract. Try running this same command again in a few seconds." + ) + throw e + } + } +} + +export default deployERC6551Registry diff --git a/deploy/00_deploy_mastercopy_ERC721Tokenbound.ts b/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts similarity index 69% rename from deploy/00_deploy_mastercopy_ERC721Tokenbound.ts rename to deploy/01_deploy_mastercopy_ERC721Tokenbound.ts index ef4e79b..8b5c2f4 100644 --- a/deploy/00_deploy_mastercopy_ERC721Tokenbound.ts +++ b/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts @@ -1,15 +1,25 @@ import { DeployFunction } from "hardhat-deploy/types" +import { createWalletClient, custom as customTransport } from "viem" import { calculateERC721TokenboundMechMastercopyAddress, deployERC721TokenboundMechMastercopy, -} from "../sdk/build/cjs/sdk/src" +} from "../sdk" const deployMastercopyERC721Tokenbound: DeployFunction = async (hre) => { const [signer] = await hre.ethers.getSigners() - const deployer = hre.ethers.provider.getSigner(signer.address) + const deployer = await hre.ethers.provider.getSigner(signer.address) - await deployERC721TokenboundMechMastercopy(deployer) + const deployerClient = createWalletClient({ + account: deployer.address as `0x${string}`, + transport: customTransport({ + async request({ method, params }) { + return deployer.provider.send(method, params) + }, + }), + }) + + await deployERC721TokenboundMechMastercopy(deployerClient) const address = calculateERC721TokenboundMechMastercopyAddress() try { diff --git a/deploy/01_deploy_mastercopy_ERC1155Tokenbound.ts b/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts similarity index 71% rename from deploy/01_deploy_mastercopy_ERC1155Tokenbound.ts rename to deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts index c4a9747..1609843 100644 --- a/deploy/01_deploy_mastercopy_ERC1155Tokenbound.ts +++ b/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts @@ -1,4 +1,5 @@ import { DeployFunction } from "hardhat-deploy/types" +import { createWalletClient, custom as customTransport } from "viem" import { calculateERC1155TokenboundMechMastercopyAddress, @@ -7,9 +8,18 @@ import { const deployMastercopyERC1155Tokenbound: DeployFunction = async (hre) => { const [signer] = await hre.ethers.getSigners() - const deployer = hre.ethers.provider.getSigner(signer.address) + const deployer = await hre.ethers.provider.getSigner(signer.address) - await deployERC1155TokenboundMechMastercopy(deployer) + const deployerClient = createWalletClient({ + account: deployer.address as `0x${string}`, + transport: customTransport({ + async request({ method, params }) { + return deployer.provider.send(method, params) + }, + }), + }) + + await deployERC1155TokenboundMechMastercopy(deployerClient) const address = calculateERC1155TokenboundMechMastercopyAddress() try { diff --git a/deploy/02_deploy_mastercopy_Zodiac.ts b/deploy/03_deploy_mastercopy_Zodiac.ts similarity index 73% rename from deploy/02_deploy_mastercopy_Zodiac.ts rename to deploy/03_deploy_mastercopy_Zodiac.ts index e366312..e1b2d33 100644 --- a/deploy/02_deploy_mastercopy_Zodiac.ts +++ b/deploy/03_deploy_mastercopy_Zodiac.ts @@ -1,9 +1,10 @@ import { DeployFunction } from "hardhat-deploy/types" +import { createWalletClient, custom as customTransport } from "viem" import { calculateZodiacMechMastercopyAddress, deployZodiacMechMastercopy, -} from "../sdk" +} from "../sdk/build/cjs/sdk/src" const deployMastercopyZodiac: DeployFunction = async (hre) => { // TODO disabled for now @@ -12,7 +13,16 @@ const deployMastercopyZodiac: DeployFunction = async (hre) => { const [signer] = await hre.ethers.getSigners() const deployer = await hre.ethers.provider.getSigner(signer.address) - await deployZodiacMechMastercopy(deployer) + const deployerClient = createWalletClient({ + account: deployer.address as `0x${string}`, + transport: customTransport({ + async request({ method, params }) { + return deployer.provider.send(method, params) + }, + }), + }) + + await deployZodiacMechMastercopy(deployerClient) const address = calculateZodiacMechMastercopyAddress() try { diff --git a/test/utils.ts b/test/utils.ts index fddf8a6..4640665 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -17,7 +17,7 @@ export async function deployFactories() { const ERC6551Registry = await ethers.getContractFactory("ERC6551Registry") const erc6551Registry = await ERC6551Registry.deploy() - deployer.populateTransaction + const deployerClient = createTestClient({ account: deployer.address as `0x${string}`, chain: hardhat,