Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jun 27, 2023
1 parent 772338c commit cef4145
Show file tree
Hide file tree
Showing 30 changed files with 547 additions and 316 deletions.
29 changes: 23 additions & 6 deletions scripts/deploy-suite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const environments = require("../environments");
const hre = require("hardhat");
const ethers = hre.ethers;
const { ZeroAddress, getContractAt, getSigners } = hre.ethers;
const network = hre.network.name;
const confirmations = network == "hardhat" ? 1 : environments.confirmations;
const tipMultiplier = BigInt(environments.tipMultiplier);
Expand Down Expand Up @@ -83,8 +83,20 @@ async function main(env, facetConfig) {
maxPriorityFeePerGas
);
deploymentComplete("AccessController", await accessController.getAddress(), [], "", contracts);
deploymentComplete("DiamondLoupeFacet", await dlf.getAddress(), [], interfaceIdFromFacetName("DiamondLoupeFacet"), contracts);
deploymentComplete("DiamondCutFacet", await dcf.getAddress(), [], interfaceIdFromFacetName("DiamondCutFacet"), contracts);
deploymentComplete(
"DiamondLoupeFacet",
await dlf.getAddress(),
[],
interfaceIdFromFacetName("DiamondLoupeFacet"),
contracts
);
deploymentComplete(
"DiamondCutFacet",
await dcf.getAddress(),
[],
interfaceIdFromFacetName("DiamondCutFacet"),
contracts
);
deploymentComplete("ERC165Facet", await erc165f.getAddress(), [], interfaceIdFromFacetName("ERC165Facet"), contracts);
deploymentComplete("ProtocolDiamond", await protocolDiamond.getAddress(), diamondArgs, "", contracts);

Expand Down Expand Up @@ -113,12 +125,17 @@ async function main(env, facetConfig) {
}

const { version } = packageFile;
let { deployedFacets } = await deployAndCutFacets(await protocolDiamond.getAddress(), facetData, maxPriorityFeePerGas, version);
let { deployedFacets } = await deployAndCutFacets(
await protocolDiamond.getAddress(),
facetData,
maxPriorityFeePerGas,
version
);

for (const deployedFacet of deployedFacets) {
deploymentComplete(
deployedFacet.name,
deployedFacet.await contract.getAddress(),
deployedFacet.contract,
deployedFacet.constructorArgs,
interfaceIdFromFacetName(deployedFacet.name),
contracts
Expand Down Expand Up @@ -205,7 +222,7 @@ async function main(env, facetConfig) {
);
await transactionResponse.wait(confirmations);

if (adminAddress.toLowerCase() != await deployer.getAddress().toLowerCase()) {
if (adminAddress.toLowerCase() != (await deployer.getAddress().toLowerCase())) {
// Grant ADMIN role to the specified admin address
// Skip this step if adminAddress is the deployer
transactionResponse = await accessController.grantRole(
Expand Down
2 changes: 1 addition & 1 deletion scripts/domain/Role.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const hre = require("hardhat");
const { keccak256, toUtf8Bytes } = hre.ethers;
const { keccak256, toUtf8Bytes } = hre.ethers;

/**
* Boson Protocol Domain Enum: Role
Expand Down
2 changes: 1 addition & 1 deletion scripts/example/SnapshotGate/deploy-snapshot-gate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const hre = require("hardhat");
const ethers = hre.ethers;
const { getContractFactory } = hre.ethers;
const environments = require("../../../environments");
const confirmations = hre.network.name == "hardhat" ? 1 : environments.confirmations;
const { getFees } = require("../../util/utils");
Expand Down
4 changes: 2 additions & 2 deletions scripts/manage-roles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const hre = require("hardhat");
const ethers = hre.ethers;
const { getContractAt, provider } = hre.ethers;
const network = hre.network.name;
const { RoleAssignments } = require("./config/role-assignments");
const { readContracts } = require("./util/utils");
Expand Down Expand Up @@ -63,7 +63,7 @@ async function main(env) {

let contractInfo;
contractInfo = contractsFile.contracts.find((i) => i.name === name);
await config.getAddress() = name === "AdminAddress" ? environments[network].adminAddress : await contractInfo.getAddress();
config.address = name === "AdminAddress" ? environments[network].adminAddress : await contractInfo.getAddress();

console.log(` 👉 ${await config.getAddress()}`);

Expand Down
2 changes: 1 addition & 1 deletion scripts/migrations/migrate_2.2.1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const shell = require("shelljs");
const { readContracts } = require("../util/utils.js");
const hre = require("hardhat");
const ethers = hre.ethers;
const { provider, getContractAt } = hre.ethers;
const network = hre.network.name;
const { getStateModifyingFunctionsHashes } = require("../../scripts/util/diamond-utils.js");
const tag = "v2.2.1";
Expand Down
13 changes: 9 additions & 4 deletions scripts/upgrade-clients.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const hre = require("hardhat");
const ethers = hre.ethers;
const { provider, ZeroAddress, getSigners, getSigner, getContractAt } = hre.ethers;
const network = hre.network.name;
const environments = require("../environments");
const tipMultiplier = BigInt(environments.tipMultiplier);
Expand Down Expand Up @@ -37,8 +37,7 @@ async function main(env, clientConfig, version) {
console.log(`⛓ Network: ${network}\n📅 ${new Date()}`);

// If hardhat, get an address generated by the mnemonic
const adminAddress =
network === "hardhat" ? (await getSigners())[0].address : environments[network].adminAddress;
const adminAddress = network === "hardhat" ? (await getSigners())[0].address : environments[network].adminAddress;

// If admin address is unspecified, exit the process
if (adminAddress == ZeroAddress || !adminAddress) {
Expand Down Expand Up @@ -88,7 +87,13 @@ async function main(env, clientConfig, version) {

// Remove old entry from contracts
contracts = contracts.filter((i) => i.name !== "BosonVoucher Logic");
deploymentComplete("BosonVoucher Logic", await bosonVoucherImplementation.getAddress(), clientImplementationArgs, "", contracts);
deploymentComplete(
"BosonVoucher Logic",
await bosonVoucherImplementation.getAddress(),
clientImplementationArgs,
"",
contracts
);

const contractsPath = await writeContracts(contracts, env, version);
console.log(divider);
Expand Down
15 changes: 4 additions & 11 deletions scripts/upgrade-facets.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const hre = require("hardhat");
const ethers = hre.ethers;
const { ZeroAddress, getContractAt, provider, getSigners, getContractFactory } = hre.ethers;
const network = hre.network.name;
const { getFacets } = require("./config/facet-upgrade");
const environments = require("../environments");
Expand Down Expand Up @@ -81,8 +81,7 @@ async function main(env, facetConfig, version) {
}

// If hardhat, get an address generated by the mnemonic
const adminAddress =
network === "hardhat" ? (await getSigners())[0].address : environments[network].adminAddress;
const adminAddress = network === "hardhat" ? (await getSigners())[0].address : environments[network].adminAddress;

// If admin address is unspecified, exit the process
if (adminAddress == ZeroAddress || !adminAddress) {
Expand Down Expand Up @@ -201,13 +200,7 @@ async function main(env, facetConfig, version) {
contracts = contracts.filter((i) => i.name !== newFacet.name);

const newFacetInterfaceId = interfaceIdFromFacetName(newFacet.name);
deploymentComplete(
newFacet.name,
newFacet.await contract.getAddress(),
newFacet.constructorArgs,
newFacetInterfaceId,
contracts
);
deploymentComplete(newFacet.name, newFacet.contract, newFacet.constructorArgs, newFacetInterfaceId, contracts);

// Get new selectors from compiled contract
const selectors = getSelectors(newFacet.contract, true);
Expand Down Expand Up @@ -262,7 +255,7 @@ async function main(env, facetConfig, version) {
}
}

const newFacetAddress = newFacet.await contract.getAddress();
const newFacetAddress = newFacet.contract;
if (selectorsToAdd.length > 0) {
deployedFacets[index].cut.push([newFacetAddress, FacetCutAction.Add, selectorsToAdd]);
}
Expand Down
1 change: 1 addition & 0 deletions scripts/upgrade-hooks/2.2.0.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { ethers } = require("hardhat");
const { getContractAt } = ethers;
const environments = require("../../environments");
const tipMultiplier = BigInt(environments.tipMultiplier);
const tipSuggestion = "1500000000"; // js always returns this constant, it does not vary per block
Expand Down
Loading

0 comments on commit cef4145

Please sign in to comment.