Skip to content

Commit e7d312e

Browse files
authored
feat: Remove direct "hardhat" imports, update types in deploy/ scripts (#284)
* improve: Load existing HRE rather than re-instantiate The HRE should only be constructed once, and for the deploy scripts we should try to load that existing object Unfortunately we can't use mark the `hre` type as a `HardhatRuntimeEnvironment` because the `hardhat-deploy` module adds some properties to it that we want to access like `deployments` and `companionNetworks` that we want to use. * Fix type * Update utils.ts
1 parent 625db8f commit e7d312e

25 files changed

+76
-89
lines changed

deploy/001_deploy_hubpool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { L1_ADDRESS_MAP } from "./consts";
22

3-
import "hardhat-deploy";
4-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
3+
import { DeployFunction } from "hardhat-deploy/types";
4+
import { HardhatRuntimeEnvironment } from "hardhat/types";
55

6-
const func = async function (hre: HardhatRuntimeEnvironment) {
6+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
77
const { deployments, getNamedAccounts, getChainId } = hre;
88
const { deploy } = deployments;
99

deploy/002_deploy_optimism_adapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { L1_ADDRESS_MAP } from "./consts";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
24

3-
import "hardhat-deploy";
4-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
5-
6-
const func = async function (hre: HardhatRuntimeEnvironment) {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const { deployments, getNamedAccounts, getChainId } = hre;
87
const { deploy } = deployments;
98

deploy/003_deploy_optimism_spokepool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import "hardhat-deploy";
2-
import hre from "hardhat";
31
import { deployNewProxy } from "../utils";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
44

5-
const func = async function () {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
66
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
77
const chainId = await hre.getChainId();
88
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);

deploy/004_deploy_arbitrum_adapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { L1_ADDRESS_MAP } from "./consts";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
24

3-
import "hardhat-deploy";
4-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
5-
6-
const func = async function (hre: HardhatRuntimeEnvironment) {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const { deployments, getNamedAccounts, getChainId } = hre;
87
const { deploy } = deployments;
98

deploy/005_deploy_arbitrum_spokepool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import "hardhat-deploy";
2-
import hre from "hardhat";
1+
import { DeployFunction } from "hardhat-deploy/types";
32
import { L2_ADDRESS_MAP } from "./consts";
43
import { deployNewProxy } from "../utils";
4+
import { HardhatRuntimeEnvironment } from "hardhat/types";
55

6-
const func = async function () {
6+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
77
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
88
const chainId = await hre.getChainId();
99
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);

deploy/006_deploy_ethereum_adapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import "hardhat-deploy";
2-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
1+
import { DeployFunction } from "hardhat-deploy/types";
2+
import { HardhatRuntimeEnvironment } from "hardhat/types";
33

4-
const func = async function (hre: HardhatRuntimeEnvironment) {
4+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
55
const { deployments, getNamedAccounts } = hre;
66
const { deploy } = deployments;
77

deploy/007_deploy_ethereum_spokepool.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import "hardhat-deploy";
2-
import hre from "hardhat";
1+
import { DeployFunction } from "hardhat-deploy/types";
32
import { deployNewProxy } from "../utils";
43
import { L1_ADDRESS_MAP } from "./consts";
4+
import { HardhatRuntimeEnvironment } from "hardhat/types";
55

6-
export async function printProxyVerificationInstructions() {}
7-
8-
const func = async function () {
6+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
97
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
108
const chainId = await hre.getChainId();
119
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);

deploy/008_deploy_polygon_token_bridger_mainnet.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import "hardhat-deploy";
2-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
3-
1+
import { DeployFunction } from "hardhat-deploy/types";
42
import { L1_ADDRESS_MAP, POLYGON_CHAIN_IDS } from "./consts";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
54

6-
const func = async function (hre: HardhatRuntimeEnvironment) {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const { deployments, getNamedAccounts, getChainId } = hre;
87
const { deploy } = deployments;
98

deploy/009_deploy_polygon_adapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import "hardhat-deploy";
2-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
3-
1+
import { DeployFunction } from "hardhat-deploy/types";
42
import { L1_ADDRESS_MAP } from "./consts";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
54

6-
const func = async function (hre: HardhatRuntimeEnvironment) {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const { deployments, getNamedAccounts, getChainId } = hre;
87
const { deploy } = deployments;
98

deploy/010_deploy_polygon_token_bridger_polygon.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import "hardhat-deploy";
2-
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
3-
1+
import { DeployFunction } from "hardhat-deploy/types";
42
import { L1_ADDRESS_MAP } from "./consts";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
54

6-
const func = async function (hre: HardhatRuntimeEnvironment) {
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const { deployments, getNamedAccounts, getChainId } = hre;
87
const { deploy } = deployments;
98

0 commit comments

Comments
 (0)