Skip to content

Commit

Permalink
Separate deployment of master sigs
Browse files Browse the repository at this point in the history
Move switch into method
  • Loading branch information
LikoIlya committed Jun 18, 2024
1 parent beb24de commit c6fad49
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 28 deletions.
35 changes: 35 additions & 0 deletions scripts/multisig/deploy_ecosysem_multisig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ethers, network } from "hardhat";
import { ContractNames } from "../../src";
import { Andrii, AndriiTest, DimaTest, Igor, Kevin, Lang, Rory, SharedDev } from "../addresses";
import { deploy } from "@airdao/deployments/deploying";
import { MasterMultisig__factory } from "../../typechain-types";

export async function main() {
const [deployer] = await ethers.getSigners();

console.log("Deploing MasterMultisig for ECOSYSTEM...");
if (network.name == "main") {
console.log("--- MAINNET DEPLOYMENT ---");
await deploy<MasterMultisig__factory>({
contractName: ContractNames.Ecosystem_MasterMultisig,
artifactName: "MasterMultisig",
deployArgs: [[Lang, Igor, Rory, Kevin, Andrii], [true, true, true, false, false], 51],
signer: deployer,
});
} else {
console.log("Deploing MasterMultisig for ECOSYSTEM...");
await deploy<MasterMultisig__factory>({
contractName: ContractNames.Ecosystem_MasterMultisig,
artifactName: "MasterMultisig",
deployArgs: [[SharedDev, DimaTest, AndriiTest], [true, true, true], 51],
signer: deployer,
});
}
}

if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
14 changes: 0 additions & 14 deletions scripts/multisig/deploy_multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,13 @@ export async function main() {
deployArgs: [[Lang, Igor, Rory, Kevin, Andrii], [true, true, true, false, false], 51],
signer: deployer,
});
console.log("Deploing MasterMultisig for ECOSYSTEM...");
await deploy<MasterMultisig__factory>({
contractName: ContractNames.Ecosystem_MasterMultisig,
artifactName: "MasterMultisig",
deployArgs: [[Lang, Igor, Rory, Kevin, Andrii], [true, true, true, false, false], 51],
signer: deployer,
});
} else {
await deploy<MasterMultisig__factory>({
contractName: ContractNames.MasterMultisig,
artifactName: "MasterMultisig",
deployArgs: [[SharedDev, DimaTest, AndriiTest], [true, true, true], 51],
signer: deployer,
});
console.log("Deploing MasterMultisig for ECOSYSTEM...");
await deploy<MasterMultisig__factory>({
contractName: ContractNames.Ecosystem_MasterMultisig,
artifactName: "MasterMultisig",
deployArgs: [[SharedDev, DimaTest, AndriiTest], [true, true, true], 51],
signer: deployer,
});
}
}

Expand Down
33 changes: 19 additions & 14 deletions src/contracts/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Contract, ethers, Signer } from "ethers";

import { ContractNames, getMultisigNames, MultisigVersions } from "./names";
import { ContractNames, MultisigVersions } from "./names";

type Deployment = {
address: string;
Expand All @@ -9,6 +9,22 @@ type Deployment = {
fullyQualifiedName: string;
};

function allowedMultisigNames(multisigVersion: MultisigVersions) {
let allowedNames: ContractNames[] = [];
switch (multisigVersion) {
case MultisigVersions.ecosystem:
allowedNames = Object.values(ContractNames).filter((name) => name.startsWith("Ecosystem_"));
break;
case MultisigVersions.common:
allowedNames = Object.values(ContractNames).filter((name) => !name.startsWith("Ecosystem_"));
break;
default:
allowedNames = Object.values(ContractNames).filter((name) => !name.startsWith("Ecosystem_"));
break;
}
return allowedNames;
}

export class Contracts {
private contracts: { [contractName: string]: Contract };
private nameByAddress: { [address: string]: ContractNames };
Expand Down Expand Up @@ -71,7 +87,7 @@ export class Contracts {
) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const deployments = require(`../../deployments/${chainId}.json`);
const versionNames = getMultisigNames(multisigVersion);
const versionNames = allowedMultisigNames(multisigVersion);
if (!versionNames.includes(contractName)) return undefined;
return { address: deployments[contractName].address, abi: deployments[contractName].abi };
}
Expand All @@ -85,18 +101,7 @@ export function loadAllDeploymentsFromFile(
// eslint-disable-next-line @typescript-eslint/no-var-requires
const deployments = require(`../../deployments/${chainId}.json`);
const result: any = {};
let allowedNames: ContractNames[] = [];
switch (multisigVersion) {
case MultisigVersions.ecosystem:
allowedNames = Object.values(ContractNames).filter((name) => name.startsWith("Ecosystem_"));
break;
case MultisigVersions.common:
allowedNames = Object.values(ContractNames).filter((name) => !name.startsWith("Ecosystem_"));
break;
default:
allowedNames = Object.values(ContractNames).filter((name) => !name.startsWith("Ecosystem_"));
break;
};
const allowedNames = allowedMultisigNames(multisigVersion);
const filteredNames = Object.keys(deployments).filter((name) => allowedNames.includes(name as ContractNames));
for (const name of filteredNames) {
const deployment = deployments[name] as Deployment;
Expand Down

0 comments on commit c6fad49

Please sign in to comment.