From d46576e5dcbb6e9992842950b3d2f5e1df90ca83 Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Fri, 26 May 2023 16:09:58 -0400 Subject: [PATCH] refactor(UBA): sideload HRE environment variable This change essentially side-loads the HRE variables to prevent the need to directly interface with the Hardhat Runtime Environment. Signed-off-by: james-a-morris --- deploy/003_deploy_optimism_spokepool.ts | 2 +- deploy/005_deploy_arbitrum_spokepool.ts | 2 +- deploy/007_deploy_ethereum_spokepool.ts | 2 +- deploy/011_deploy_polygon_spokepool.ts | 2 +- deploy/013_deploy_boba_spokepool.ts | 2 +- deploy/016_deploy_zksync_spokepool.ts | 2 +- test/HubPool.Admin.ts | 25 ++++++++++++++++--- test/MerkleLib.Proofs.ts | 12 +++++++-- test/MerkleLib.utils.ts | 2 +- test/SpokePool.Admin.ts | 3 ++- test/SpokePool.Upgrades.ts | 3 ++- test/chain-adapters/Arbitrum_Adapter.ts | 4 ++- test/chain-adapters/Ethereum_Adapter.ts | 12 +++++++-- test/chain-adapters/Optimism_Adapter.ts | 13 ++++++++-- test/chain-adapters/Polygon_Adapter.ts | 14 +++++++++-- .../Arbitrum_SpokePool.ts | 15 +++++++++-- .../Ethereum_SpokePool.ts | 4 +-- .../Optimism_SpokePool.ts | 15 +++++++++-- .../Polygon_SpokePool.ts | 16 ++++++++++-- .../Succinct_SpokePool.ts | 3 ++- test/fixtures/BondToken.Fixture.ts | 3 ++- test/fixtures/HubPool.Fixture.ts | 3 ++- test/fixtures/MerkleLib.Fixture.ts | 3 ++- test/fixtures/SpokePool.Fixture.ts | 12 +++------ test/fixtures/UmaEcosystem.Fixture.ts | 3 ++- test/merkle-distributor/MerkleDistributor.ts | 12 +-------- utils/utils.hre.ts | 22 ++++++++++++++++ utils/utils.ts | 23 ++--------------- 28 files changed, 158 insertions(+), 76 deletions(-) create mode 100644 utils/utils.hre.ts diff --git a/deploy/003_deploy_optimism_spokepool.ts b/deploy/003_deploy_optimism_spokepool.ts index c10d26ae3..98bf2e90b 100644 --- a/deploy/003_deploy_optimism_spokepool.ts +++ b/deploy/003_deploy_optimism_spokepool.ts @@ -1,4 +1,4 @@ -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { DeployFunction } from "hardhat-deploy/types"; import { HardhatRuntimeEnvironment } from "hardhat/types"; diff --git a/deploy/005_deploy_arbitrum_spokepool.ts b/deploy/005_deploy_arbitrum_spokepool.ts index 944606a7f..2c57160f1 100644 --- a/deploy/005_deploy_arbitrum_spokepool.ts +++ b/deploy/005_deploy_arbitrum_spokepool.ts @@ -1,6 +1,6 @@ import { DeployFunction } from "hardhat-deploy/types"; import { L2_ADDRESS_MAP } from "./consts"; -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { HardhatRuntimeEnvironment } from "hardhat/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/007_deploy_ethereum_spokepool.ts b/deploy/007_deploy_ethereum_spokepool.ts index 00e28e70b..35ce7fa5d 100644 --- a/deploy/007_deploy_ethereum_spokepool.ts +++ b/deploy/007_deploy_ethereum_spokepool.ts @@ -1,5 +1,5 @@ import { DeployFunction } from "hardhat-deploy/types"; -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { L1_ADDRESS_MAP } from "./consts"; import { HardhatRuntimeEnvironment } from "hardhat/types"; diff --git a/deploy/011_deploy_polygon_spokepool.ts b/deploy/011_deploy_polygon_spokepool.ts index d68e407b4..9efa271be 100644 --- a/deploy/011_deploy_polygon_spokepool.ts +++ b/deploy/011_deploy_polygon_spokepool.ts @@ -1,6 +1,6 @@ import { DeployFunction } from "hardhat-deploy/types"; import { L2_ADDRESS_MAP } from "./consts"; -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { HardhatRuntimeEnvironment } from "hardhat/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/013_deploy_boba_spokepool.ts b/deploy/013_deploy_boba_spokepool.ts index 8b7114506..d6d2bb824 100644 --- a/deploy/013_deploy_boba_spokepool.ts +++ b/deploy/013_deploy_boba_spokepool.ts @@ -1,5 +1,5 @@ import { DeployFunction } from "hardhat-deploy/types"; -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { HardhatRuntimeEnvironment } from "hardhat/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/deploy/016_deploy_zksync_spokepool.ts b/deploy/016_deploy_zksync_spokepool.ts index 4eb10a00f..c4aecb251 100644 --- a/deploy/016_deploy_zksync_spokepool.ts +++ b/deploy/016_deploy_zksync_spokepool.ts @@ -1,6 +1,6 @@ import { DeployFunction } from "hardhat-deploy/types"; import { L2_ADDRESS_MAP } from "./consts"; -import { deployNewProxy } from "../utils"; +import { deployNewProxy } from "../utils/utils.hre"; import { HardhatRuntimeEnvironment } from "hardhat/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { diff --git a/test/HubPool.Admin.ts b/test/HubPool.Admin.ts index 6f55123a8..9be350c42 100644 --- a/test/HubPool.Admin.ts +++ b/test/HubPool.Admin.ts @@ -1,7 +1,24 @@ -import { getContractFactory, SignerWithAddress, seedWallet, expect } from "../utils/utils"; -import { Contract, ethers, randomAddress, utf8ToHex } from "../utils/utils"; -import { originChainId, destinationChainId, bondAmount, zeroAddress, mockTreeRoot } from "./constants"; -import { mockSlowRelayRoot, finalFeeUsdc, finalFee, totalBond } from "./constants"; +import { + getContractFactory, + SignerWithAddress, + seedWallet, + expect, + Contract, + ethers, + randomAddress, + utf8ToHex, +} from "../utils/utils"; +import { + originChainId, + destinationChainId, + bondAmount, + zeroAddress, + mockTreeRoot, + mockSlowRelayRoot, + finalFeeUsdc, + finalFee, + totalBond, +} from "./constants"; import { hubPoolFixture } from "./fixtures/HubPool.Fixture"; let hubPool: Contract, weth: Contract, usdc: Contract; diff --git a/test/MerkleLib.Proofs.ts b/test/MerkleLib.Proofs.ts index 239e036fb..81038b9df 100644 --- a/test/MerkleLib.Proofs.ts +++ b/test/MerkleLib.Proofs.ts @@ -1,8 +1,16 @@ import { PoolRebalanceLeaf, RelayerRefundLeaf } from "./MerkleLib.utils"; import { merkleLibFixture } from "./fixtures/MerkleLib.Fixture"; import { MerkleTree, EMPTY_MERKLE_ROOT } from "../utils/MerkleTree"; -import { expect, randomBigNumber, randomAddress, getParamType, defaultAbiCoder } from "../utils/utils"; -import { keccak256, Contract, BigNumber } from "../utils/utils"; +import { + expect, + randomBigNumber, + randomAddress, + getParamType, + defaultAbiCoder, + keccak256, + Contract, + BigNumber, +} from "../utils/utils"; let merkleLibTest: Contract; diff --git a/test/MerkleLib.utils.ts b/test/MerkleLib.utils.ts index b74a7e503..9379cb187 100644 --- a/test/MerkleLib.utils.ts +++ b/test/MerkleLib.utils.ts @@ -1,7 +1,7 @@ import { getParamType, expect, BigNumber, Contract, defaultAbiCoder, keccak256, toBNWei } from "../utils/utils"; import { repaymentChainId, amountToReturn } from "./constants"; import { MerkleTree } from "../utils/MerkleTree"; -import { RelayData, SlowFill } from "./fixtures/SpokePool.Fixture"; +import { SlowFill } from "./fixtures/SpokePool.Fixture"; export interface PoolRebalanceLeaf { chainId: BigNumber; groupIndex: BigNumber; diff --git a/test/SpokePool.Admin.ts b/test/SpokePool.Admin.ts index d77ff4231..fc9e4b91d 100644 --- a/test/SpokePool.Admin.ts +++ b/test/SpokePool.Admin.ts @@ -1,4 +1,5 @@ -import { expect, ethers, Contract, SignerWithAddress, getContractFactory, hre } from "../utils/utils"; +import { expect, ethers, Contract, SignerWithAddress, getContractFactory } from "../utils/utils"; +import { hre } from "../utils/utils.hre"; import { spokePoolFixture } from "./fixtures/SpokePool.Fixture"; import { destinationChainId, mockRelayerRefundRoot, mockSlowRelayRoot } from "./constants"; diff --git a/test/SpokePool.Upgrades.ts b/test/SpokePool.Upgrades.ts index d55ca0a14..38b2b2079 100644 --- a/test/SpokePool.Upgrades.ts +++ b/test/SpokePool.Upgrades.ts @@ -1,4 +1,5 @@ -import { expect, ethers, Contract, SignerWithAddress, hre, randomAddress } from "../utils/utils"; +import { expect, ethers, Contract, SignerWithAddress, randomAddress } from "../utils/utils"; +import { hre } from "../utils/utils.hre"; import { spokePoolFixture } from "./fixtures/SpokePool.Fixture"; let spokePool: Contract; diff --git a/test/chain-adapters/Arbitrum_Adapter.ts b/test/chain-adapters/Arbitrum_Adapter.ts index f6d212e14..9405a5d46 100644 --- a/test/chain-adapters/Arbitrum_Adapter.ts +++ b/test/chain-adapters/Arbitrum_Adapter.ts @@ -9,8 +9,10 @@ import { toWei, defaultAbiCoder, toBN, + getContractFactory, + seedWallet, + randomAddress, } from "../../utils/utils"; -import { getContractFactory, seedWallet, randomAddress } from "../../utils/utils"; import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture"; import { constructSingleChainTree } from "../MerkleLib.utils"; diff --git a/test/chain-adapters/Ethereum_Adapter.ts b/test/chain-adapters/Ethereum_Adapter.ts index bbd9e7e47..c2103a1c0 100644 --- a/test/chain-adapters/Ethereum_Adapter.ts +++ b/test/chain-adapters/Ethereum_Adapter.ts @@ -1,6 +1,14 @@ import * as consts from "../constants"; -import { ethers, expect, Contract, SignerWithAddress, randomAddress, hre } from "../../utils/utils"; -import { getContractFactory, seedWallet } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + SignerWithAddress, + randomAddress, + getContractFactory, + seedWallet, +} from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture"; import { constructSingleChainTree } from "../MerkleLib.utils"; diff --git a/test/chain-adapters/Optimism_Adapter.ts b/test/chain-adapters/Optimism_Adapter.ts index f4bf6e99c..4e6b719e2 100644 --- a/test/chain-adapters/Optimism_Adapter.ts +++ b/test/chain-adapters/Optimism_Adapter.ts @@ -1,6 +1,15 @@ import { sampleL2Gas, amountToLp, mockTreeRoot, refundProposalLiveness, bondAmount } from "./../constants"; -import { ethers, expect, Contract, FakeContract, SignerWithAddress, createFake, hre } from "../../utils/utils"; -import { getContractFactory, seedWallet, randomAddress } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + FakeContract, + SignerWithAddress, + createFake, + getContractFactory, + seedWallet, + randomAddress, +} from "../../utils/utils"; import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture"; import { constructSingleChainTree } from "../MerkleLib.utils"; diff --git a/test/chain-adapters/Polygon_Adapter.ts b/test/chain-adapters/Polygon_Adapter.ts index b10de94ef..2ce46fe9f 100644 --- a/test/chain-adapters/Polygon_Adapter.ts +++ b/test/chain-adapters/Polygon_Adapter.ts @@ -1,6 +1,16 @@ import { amountToLp, mockTreeRoot, refundProposalLiveness, bondAmount, mockSlowRelayRoot } from "./../constants"; -import { ethers, expect, Contract, FakeContract, SignerWithAddress } from "../../utils/utils"; -import { createFake, getContractFactory, seedWallet, randomAddress, hre } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + FakeContract, + SignerWithAddress, + createFake, + getContractFactory, + seedWallet, + randomAddress, +} from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture"; import { constructSingleChainTree } from "../MerkleLib.utils"; import { TokenRolesEnum } from "@uma/common"; diff --git a/test/chain-specific-spokepools/Arbitrum_SpokePool.ts b/test/chain-specific-spokepools/Arbitrum_SpokePool.ts index 459acbaa9..087490d34 100644 --- a/test/chain-specific-spokepools/Arbitrum_SpokePool.ts +++ b/test/chain-specific-spokepools/Arbitrum_SpokePool.ts @@ -1,6 +1,17 @@ import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress } from "../constants"; -import { ethers, expect, Contract, FakeContract, SignerWithAddress, createFake, toWei } from "../../utils/utils"; -import { getContractFactory, seedContract, avmL1ToL2Alias, hre } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + FakeContract, + SignerWithAddress, + createFake, + toWei, + getContractFactory, + seedContract, + avmL1ToL2Alias, +} from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; diff --git a/test/chain-specific-spokepools/Ethereum_SpokePool.ts b/test/chain-specific-spokepools/Ethereum_SpokePool.ts index aa5df2a4d..46fed70e0 100644 --- a/test/chain-specific-spokepools/Ethereum_SpokePool.ts +++ b/test/chain-specific-spokepools/Ethereum_SpokePool.ts @@ -1,6 +1,6 @@ import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; -import { ethers, expect, Contract, SignerWithAddress, hre } from "../../utils/utils"; -import { getContractFactory, seedContract } from "../../utils/utils"; +import { ethers, expect, Contract, SignerWithAddress, getContractFactory, seedContract } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; diff --git a/test/chain-specific-spokepools/Optimism_SpokePool.ts b/test/chain-specific-spokepools/Optimism_SpokePool.ts index 066247f66..21a2dd9ff 100644 --- a/test/chain-specific-spokepools/Optimism_SpokePool.ts +++ b/test/chain-specific-spokepools/Optimism_SpokePool.ts @@ -1,6 +1,17 @@ import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; -import { ethers, expect, Contract, FakeContract, SignerWithAddress, createFake, toWei } from "../../utils/utils"; -import { getContractFactory, seedContract, hre } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + FakeContract, + SignerWithAddress, + createFake, + toWei, + getContractFactory, + seedContract, +} from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; + import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; diff --git a/test/chain-specific-spokepools/Polygon_SpokePool.ts b/test/chain-specific-spokepools/Polygon_SpokePool.ts index d8ff5114d..8ad4c3eac 100644 --- a/test/chain-specific-spokepools/Polygon_SpokePool.ts +++ b/test/chain-specific-spokepools/Polygon_SpokePool.ts @@ -1,6 +1,18 @@ import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress, TokenRolesEnum } from "../constants"; -import { ethers, expect, Contract, SignerWithAddress, getContractFactory, createFake } from "../../utils/utils"; -import { seedContract, toWei, randomBigNumber, seedWallet, FakeContract, hre } from "../../utils/utils"; +import { + ethers, + expect, + Contract, + SignerWithAddress, + getContractFactory, + createFake, + seedContract, + toWei, + randomBigNumber, + seedWallet, + FakeContract, +} from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; import { randomBytes } from "crypto"; diff --git a/test/chain-specific-spokepools/Succinct_SpokePool.ts b/test/chain-specific-spokepools/Succinct_SpokePool.ts index 222768478..28e94b166 100644 --- a/test/chain-specific-spokepools/Succinct_SpokePool.ts +++ b/test/chain-specific-spokepools/Succinct_SpokePool.ts @@ -1,4 +1,5 @@ -import { ethers, expect, Contract, SignerWithAddress, getContractFactory, hre } from "../../utils/utils"; +import { ethers, expect, Contract, SignerWithAddress, getContractFactory } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; let succinctSpokePool: Contract, timer: Contract, weth: Contract; diff --git a/test/fixtures/BondToken.Fixture.ts b/test/fixtures/BondToken.Fixture.ts index eb38c8b57..a736452ad 100644 --- a/test/fixtures/BondToken.Fixture.ts +++ b/test/fixtures/BondToken.Fixture.ts @@ -1,4 +1,5 @@ -import { Contract, getContractFactory, hre } from "../../utils/utils"; +import { Contract, getContractFactory } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { hubPoolFixture } from "./HubPool.Fixture"; export const bondTokenFixture = hre.deployments.createFixture(async ({ ethers }, hubPool?: Contract) => { diff --git a/test/fixtures/HubPool.Fixture.ts b/test/fixtures/HubPool.Fixture.ts index c554dac1b..065e47e4d 100644 --- a/test/fixtures/HubPool.Fixture.ts +++ b/test/fixtures/HubPool.Fixture.ts @@ -1,4 +1,5 @@ -import { getContractFactory, randomAddress, hre, Contract, Signer } from "../../utils/utils"; +import { getContractFactory, randomAddress, Contract, Signer } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { originChainId, bondAmount, refundProposalLiveness, finalFee } from "../constants"; import { repaymentChainId, finalFeeUsdc, TokenRolesEnum } from "../constants"; import { umaEcosystemFixture } from "./UmaEcosystem.Fixture"; diff --git a/test/fixtures/MerkleLib.Fixture.ts b/test/fixtures/MerkleLib.Fixture.ts index a975a2cc0..7d545911c 100644 --- a/test/fixtures/MerkleLib.Fixture.ts +++ b/test/fixtures/MerkleLib.Fixture.ts @@ -1,4 +1,5 @@ -import { Contract, getContractFactory, hre } from "../../utils/utils"; +import { Contract, getContractFactory } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; export const merkleLibFixture: () => Promise<{ merkleLibTest: Contract }> = hre.deployments.createFixture(async () => { const [signer] = await hre.ethers.getSigners(); diff --git a/test/fixtures/SpokePool.Fixture.ts b/test/fixtures/SpokePool.Fixture.ts index 40de2a877..35ca2e31e 100644 --- a/test/fixtures/SpokePool.Fixture.ts +++ b/test/fixtures/SpokePool.Fixture.ts @@ -1,12 +1,6 @@ -import { - getContractFactory, - SignerWithAddress, - Contract, - hre, - ethers, - BigNumber, - defaultAbiCoder, -} from "../../utils/utils"; +import { getContractFactory, SignerWithAddress, Contract, ethers, BigNumber, defaultAbiCoder } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; + import * as consts from "../constants"; export const spokePoolFixture = hre.deployments.createFixture(async ({ ethers }) => { diff --git a/test/fixtures/UmaEcosystem.Fixture.ts b/test/fixtures/UmaEcosystem.Fixture.ts index 8573eb83e..f51e5c06e 100644 --- a/test/fixtures/UmaEcosystem.Fixture.ts +++ b/test/fixtures/UmaEcosystem.Fixture.ts @@ -1,4 +1,5 @@ -import { getContractFactory, utf8ToHex, hre, Contract } from "../../utils/utils"; +import { getContractFactory, utf8ToHex, Contract } from "../../utils/utils"; +import { hre } from "../../utils/utils.hre"; import { refundProposalLiveness, zeroRawValue, identifier } from "../constants"; import { interfaceName } from "@uma/common"; diff --git a/test/merkle-distributor/MerkleDistributor.ts b/test/merkle-distributor/MerkleDistributor.ts index 184d27785..8f1653511 100644 --- a/test/merkle-distributor/MerkleDistributor.ts +++ b/test/merkle-distributor/MerkleDistributor.ts @@ -1,16 +1,6 @@ /* eslint-disable no-unused-expressions */ -import { - ethers, - getContractFactory, - SignerWithAddress, - Contract, - toWei, - toBN, - expect, - keccak256, - defaultAbiCoder, -} from "../../utils/utils"; +import { ethers, getContractFactory, SignerWithAddress, Contract, toWei, toBN, expect } from "../../utils/utils"; import { deployErc20 } from "../gas-analytics/utils"; import { MAX_UINT_VAL, MerkleTree } from "@uma/common"; diff --git a/utils/utils.hre.ts b/utils/utils.hre.ts new file mode 100644 index 000000000..b7c5a1ba6 --- /dev/null +++ b/utils/utils.hre.ts @@ -0,0 +1,22 @@ +import { getContractFactory } from "./utils"; +import hre from "hardhat"; + +export async function deployNewProxy(name: string, args: (number | string)[]): Promise { + const { run, upgrades } = hre; + + const proxy = await upgrades.deployProxy(await getContractFactory(name, {}), args, { kind: "uups" }); + const instance = await proxy.deployed(); + console.log(`New ${name} proxy deployed @ ${instance.address}`); + const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address); + console.log(`${name} implementation deployed @ ${implementationAddress}`); + + // hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed + // is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy + // to the implementation's ABI on etherscan. + // https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify + await run("verify:verify", { + address: instance.address, + }); +} + +export { hre }; diff --git a/utils/utils.ts b/utils/utils.ts index 3418323ca..b4c86aca7 100644 --- a/utils/utils.ts +++ b/utils/utils.ts @@ -6,7 +6,6 @@ import { getBytecode, getAbi } from "@uma/contracts-node"; import * as optimismContracts from "@eth-optimism/contracts"; import { smock, FakeContract } from "@defi-wonderland/smock"; import { FactoryOptions } from "hardhat/types"; -import hre from "hardhat"; import { ethers } from "hardhat"; import { BigNumber, Signer, Contract, ContractFactory } from "ethers"; export { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; @@ -54,24 +53,6 @@ export async function getContractFactory( } } -export async function deployNewProxy(name: string, args: (number | string)[]): Promise { - const { run, upgrades } = hre; - - const proxy = await upgrades.deployProxy(await getContractFactory(name, {}), args, { kind: "uups" }); - const instance = await proxy.deployed(); - console.log(`New ${name} proxy deployed @ ${instance.address}`); - const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address); - console.log(`${name} implementation deployed @ ${implementationAddress}`); - - // hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed - // is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy - // to the implementation's ABI on etherscan. - // https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify - await run("verify:verify", { - address: instance.address, - }); -} - // Arbitrum does not export any of their artifacts nicely, so we have to do this manually. The methods that follow can // be re-used if we end up requiring to import contract artifacts from other projects that dont export cleanly. function getArbitrumArtifact(contractName: string) { @@ -88,7 +69,7 @@ function getArbitrumArtifact(contractName: string) { // Fetch the artifact from the publish package's artifacts directory. function getLocalArtifact(contractName: string) { - const artifactsPath = `${__dirname}/../../artifacts/contracts`; + const artifactsPath = path.join(__dirname, "../../artifacts/contracts"); return findArtifactFromPath(contractName, artifactsPath); } @@ -201,4 +182,4 @@ function avmL1ToL2Alias(l1Address: string) { const { defaultAbiCoder, keccak256 } = ethers.utils; -export { avmL1ToL2Alias, expect, Contract, ethers, hre, BigNumber, defaultAbiCoder, keccak256, FakeContract, Signer }; +export { avmL1ToL2Alias, expect, Contract, ethers, BigNumber, defaultAbiCoder, keccak256, FakeContract, Signer };