Skip to content

Commit

Permalink
Use named accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Jul 16, 2024
1 parent 22906ec commit db37958
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 2 additions & 4 deletions deploy/01_mastercopy_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 4 additions & 5 deletions deploy/02_test_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions deploy/03_proxy_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/myModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit db37958

Please sign in to comment.