Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(UBA): sideload HRE environment variable #289

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/003_deploy_optimism_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion deploy/005_deploy_arbitrum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion deploy/007_deploy_ethereum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion deploy/011_deploy_polygon_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion deploy/013_deploy_boba_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion deploy/016_deploy_zksync_spokepool.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/mintERC1155.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getContractFactory, ethers, hre } from "../utils/utils";
import { getContractFactory, ethers } from "../utils/utils";
import { readFileSync } from "fs";
import path from "path";
import { getNodeUrl } from "@uma/common";
import { hre } from "../utils/utils.hre";

const RECIPIENTS_CHUNK_SIZE = 100; // TODO: Still need to figure out which size is optimal

Expand Down
3 changes: 2 additions & 1 deletion scripts/setERC1155Metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getContractFactory, ethers, hre } from "../utils/utils";
import { getContractFactory, ethers } from "../utils/utils";
import { hre } from "../utils/utils.hre";
import { readFileSync } from "fs";
import path from "path";
import { CID } from "multiformats/cid";
Expand Down
25 changes: 21 additions & 4 deletions test/HubPool.Admin.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 10 additions & 2 deletions test/MerkleLib.Proofs.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/MerkleLib.utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/SpokePool.Admin.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
3 changes: 2 additions & 1 deletion test/SpokePool.Upgrades.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 3 additions & 1 deletion test/chain-adapters/Arbitrum_Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
12 changes: 10 additions & 2 deletions test/chain-adapters/Ethereum_Adapter.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
13 changes: 11 additions & 2 deletions test/chain-adapters/Optimism_Adapter.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
14 changes: 12 additions & 2 deletions test/chain-adapters/Polygon_Adapter.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
15 changes: 13 additions & 2 deletions test/chain-specific-spokepools/Arbitrum_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
4 changes: 2 additions & 2 deletions test/chain-specific-spokepools/Ethereum_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
15 changes: 13 additions & 2 deletions test/chain-specific-spokepools/Optimism_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
16 changes: 14 additions & 2 deletions test/chain-specific-spokepools/Polygon_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion test/chain-specific-spokepools/Succinct_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/BondToken.Fixture.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/HubPool.Fixture.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/MerkleLib.Fixture.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
12 changes: 3 additions & 9 deletions test/fixtures/SpokePool.Fixture.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/UmaEcosystem.Fixture.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
16 changes: 14 additions & 2 deletions test/gas-analytics/HubPool.RootExecution.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { toBNWei, toBN, SignerWithAddress, seedWallet, Contract, ethers, hre, expect } from "../../utils/utils";
import { getContractFactory, BigNumber, randomAddress, createRandomBytes32 } from "../../utils/utils";
import {
toBNWei,
toBN,
SignerWithAddress,
seedWallet,
Contract,
ethers,
expect,
getContractFactory,
BigNumber,
randomAddress,
createRandomBytes32,
} from "../../utils/utils";
import { deployErc20 } from "./utils";
import * as consts from "../constants";
import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture";
import { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, PoolRebalanceLeaf } from "../MerkleLib.utils";
import { MerkleTree } from "../../utils/MerkleTree";
import { hre } from "../../utils/utils.hre";

require("dotenv").config();

Expand Down
12 changes: 1 addition & 11 deletions test/merkle-distributor/MerkleDistributor.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
22 changes: 22 additions & 0 deletions utils/utils.hre.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getContractFactory } from "./utils";
import hre from "hardhat";

export async function deployNewProxy(name: string, args: (number | string)[]): Promise<void> {
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 };
Loading