From db37958e6cdfc402b5b0a9edbc73f85fffd5d0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3v=C3=A3o=20Honorato?= Date: Wed, 17 Jul 2024 00:00:22 +0200 Subject: [PATCH] Use named accounts --- deploy/01_mastercopy_module.ts | 6 ++---- deploy/02_test_dependencies.ts | 9 ++++----- deploy/03_proxy_module.ts | 6 ++---- test/myModule.test.ts | 1 - 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/deploy/01_mastercopy_module.ts b/deploy/01_mastercopy_module.ts index 3d4ecb0..51316c3 100644 --- a/deploy/01_mastercopy_module.ts +++ b/deploy/01_mastercopy_module.ts @@ -9,11 +9,9 @@ const FirstAddress = "0x0000000000000000000000000000000000000001" const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { getNamedAccounts, ethers } = hre - const { deployer_address } = await getNamedAccounts() + const { deployer: deployerAddress } = await getNamedAccounts() + const deployer = await ethers.getSigner(deployerAddress) - // const deployer = await ethers.getSigner() - - const [deployer] = await hre.ethers.getSigners() await createFactory(deployer) const MyModule = await ethers.getContractFactory("MyModule") diff --git a/deploy/02_test_dependencies.ts b/deploy/02_test_dependencies.ts index f81c3e4..5cf535a 100644 --- a/deploy/02_test_dependencies.ts +++ b/deploy/02_test_dependencies.ts @@ -5,21 +5,20 @@ const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log("Deploying 'external' dependencies (Button and Avatar)") const { deployments, getNamedAccounts, ethers } = hre const { deploy } = deployments - // const { deployer_address } = await getNamedAccounts() - const [deployer] = await ethers.getSigners() + const { deployer: deployerAddress } = await getNamedAccounts() + const deployer = await ethers.getSigner(deployerAddress) const testAvatarDeployment = await deploy("TestAvatar", { - from: await deployer.getAddress(), + from: deployerAddress, }) console.log("TestAvatar deployed to:", testAvatarDeployment.address) const buttonDeployment = await deploy("Button", { - from: await deployer.getAddress(), + from: deployerAddress, }) console.log("Button deployed to:", buttonDeployment.address) // Make the TestAvatar the owner of the button - // const dependenciesDeployerSigner = await ethers.getSigner(deployer_address) const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address, deployer) const currentOwner = await buttonContract.owner() if (currentOwner !== testAvatarDeployment.address) { diff --git a/deploy/03_proxy_module.ts b/deploy/03_proxy_module.ts index 1c88e2f..3589931 100644 --- a/deploy/03_proxy_module.ts +++ b/deploy/03_proxy_module.ts @@ -13,9 +13,8 @@ const deploy: DeployFunction = async function ({ getChainId, }: HardhatRuntimeEnvironment) { console.log("Deploying MyModule Proxy") - // const { deployer } = await getNamedAccounts() - // const deployerSigner = await ethers.getSigner(deployer) - const [deployer] = await ethers.getSigners() + const { deployer: deployerAddress } = await getNamedAccounts() + const deployer = await ethers.getSigner(deployerAddress) const buttonDeployment = await deployments.get("Button") const testAvatarDeployment = await deployments.get("TestAvatar") @@ -24,7 +23,6 @@ const deploy: DeployFunction = async function ({ /// const chainId = await getChainId() // const network: SupportedNetworks = Number(chainId) - // if ((await ethers.provider.getCode(ContractAddresses[network][KnownContracts.FACTORY])) === "0x") { // // the Module Factory should already be deployed to all supported chains // // if you are deploying to a chain where its not deployed yet (most likely locale test chains), run deployModuleFactory from the zodiac package diff --git a/test/myModule.test.ts b/test/myModule.test.ts index 091efeb..d3e3231 100644 --- a/test/myModule.test.ts +++ b/test/myModule.test.ts @@ -4,7 +4,6 @@ import { ethers, deployments, getNamedAccounts } from "hardhat" const setup = async () => { await deployments.fixture(["moduleProxy"]) const { tester } = await getNamedAccounts() - const testSigner = await ethers.getSigner(tester) const buttonDeployment = await deployments.get("Button") const myModuleProxyDeployment = await deployments.get("MyModuleProxy") const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address)