Skip to content

Commit

Permalink
Update deployment scripts to check for deployments first
Browse files Browse the repository at this point in the history
  • Loading branch information
asgeir-s committed Aug 1, 2023
1 parent bfcfb89 commit e674a39
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
15 changes: 11 additions & 4 deletions packages/contracts/src/deploy/deploy_circulating_supply.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deployMastercopy } from "@gnosis.pm/zodiac";
import { deployMastercopy, computeTargetAddress } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -17,14 +17,21 @@ const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
"CirculatingSupplyERC20"
);

const address = await deployMastercopy(
const args = [FirstAddress, FirstAddress, []];

const { address, isDeployed } = await computeTargetAddress(
deployer,
CirculatingSupplyERC20,
[FirstAddress, FirstAddress, []],
args,
SaltZero
);

console.log("CirculatingSupplyERC20 deployed to:", address);
if (isDeployed) {
console.log("CirculatingSupplyERC20 already deployed to:", address);
} else {
await deployMastercopy(deployer, CirculatingSupplyERC20, args, SaltZero);
console.log("CirculatingSupplyERC20 was deployed to:", address);
}

hre.deployments.save("CirculatingSupplyERC20", {
abi: CONTRACT_ARTIFACT.abi,
Expand Down
20 changes: 16 additions & 4 deletions packages/contracts/src/deploy/deploy_erc20_exit_module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deployMastercopy } from "@gnosis.pm/zodiac";
import { computeTargetAddress, deployMastercopy } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -15,14 +15,26 @@ const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const ExitERC20 = await hre.ethers.getContractFactory("ExitERC20");

const address = await deployMastercopy(
const args = [
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
];
const { address, isDeployed } = await computeTargetAddress(
deployer,
ExitERC20,
[FirstAddress, FirstAddress, FirstAddress, FirstAddress, FirstAddress],
args,
SaltZero
);

console.log("ExitERC20 deployed to:", address);
if (isDeployed) {
console.log("ExitERC20 already deployed to:", address);
} else {
await deployMastercopy(deployer, ExitERC20, args, SaltZero);
console.log("ExitERC20 was deployed to:", address);
}

hre.deployments.save("ExitERC20", {
abi: CONTRACT_ARTIFACT.abi,
Expand Down
21 changes: 17 additions & 4 deletions packages/contracts/src/deploy/deploy_erc721_exit_module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deployMastercopy } from "@gnosis.pm/zodiac";
import { computeTargetAddress, deployMastercopy } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand All @@ -15,14 +15,27 @@ const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const ExitERC721 = await hre.ethers.getContractFactory("ExitERC721");

const address = await deployMastercopy(
const args = [
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
];

const { address, isDeployed } = await computeTargetAddress(
deployer,
ExitERC721,
[FirstAddress, FirstAddress, FirstAddress, FirstAddress, FirstAddress],
args,
SaltZero
);

console.log("ExitERC721 deployed to:", address);
if (isDeployed) {
console.log("ExitERC721 already deployed to:", address);
} else {
await deployMastercopy(deployer, ExitERC721, args, SaltZero);
console.log("ExitERC721 was deployed to:", address);
}

hre.deployments.save("ExitERC721", {
abi: CONTRACT_ARTIFACT.abi,
Expand Down

0 comments on commit e674a39

Please sign in to comment.