Skip to content

Commit

Permalink
refactor: move constant values to the utils module
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlee42 committed Apr 7, 2024
1 parent 8e3c93c commit d3eb0d8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
22 changes: 1 addition & 21 deletions ts-src/deploy/01_LockingInfo.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
import { DeployFunction } from "hardhat-deploy/types";
import { LockingInfoContractName } from "../utils/constant";

const l2ChainIdMap: { [key: string]: number } = {
mainnet: 1088,
sepolia: 59902,
holesky: 59903,
devnet: Number(process.env["DEVBNET_L2_CHAINID"]),
};

const l1BridgeMap: { [key: string]: string } = {
mainnet: "0x3980c9ed79d2c191A89E02Fa3529C60eD6e9c04b",
sepolia: "0x9848dE505e6Aa301cEecfCf23A0a150140fc996e",
holesky: "0x890D4Ef96551C9904e7D4E73d2C22D3F207F5CFb",
devnet: process.env["DEVBNET_METIST_L1_BRIDGE"] as string,
};

const l1MetisMap: { [key: string]: string } = {
mainnet: "0x9e32b13ce7f2e80a01932b42553652e053d6ed8e",
sepolia: "0x7f49160EB9BB068101d445fe77E17ecDb37D0B47",
holesky: "0xaf8e5B10c69c983204505cDCD56Ec2aC2280D08e",
devnet: process.env["DEVBNET_METIST_TOKEN"] as string,
};
import { l1BridgeMap, l1MetisMap, l2ChainIdMap } from "../utils/address";

const func: DeployFunction = async function (hre) {
const networkName = hre.network.name;
Expand Down
5 changes: 3 additions & 2 deletions ts-src/tasks/l1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
LockingInfoContractName,
LockingPoolContractName,
} from "../utils/constant";
import { l1MetisMap } from "../utils/address";

task("l1:whitelist", "Whitelist an sequencer address")
.addParam("addr", "the sequencer address", "", types.string)
Expand Down Expand Up @@ -76,7 +77,7 @@ task("l1:lock", "Lock Metis to LockingPool contract")
throw new Error(`${hre.network.name} is not an l1`);
}

const metisL1Addr = process.env.MEITS_L1_TOKEN as string;
const metisL1Addr = l1MetisMap[hre.network.name];
if (!hre.ethers.isAddress(metisL1Addr)) {
throw new Error(`MEITS_L1_TOKEN env is not set or it's not an address`);
}
Expand Down Expand Up @@ -409,7 +410,7 @@ task("l1:set-reward-payer", "Update reward payer")
return;
}

const metisL1Addr = process.env.MEITS_L1_TOKEN;
const metisL1Addr = l1MetisMap[hre.network.name];
if (!hre.ethers.isAddress(metisL1Addr)) {
throw new Error(`MEITS_L1_TOKEN env is not set or it's not an address`);
}
Expand Down
22 changes: 22 additions & 0 deletions ts-src/utils/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const l2ChainIdMap: { [key: string]: number } = {
mainnet: 1088,
sepolia: 59902,
holesky: 59903,
devnet: Number(process.env["DEVBNET_L2_CHAINID"]),
};

const l1BridgeMap: { [key: string]: string } = {
mainnet: "0x3980c9ed79d2c191A89E02Fa3529C60eD6e9c04b",
sepolia: "0x9848dE505e6Aa301cEecfCf23A0a150140fc996e",
holesky: "0x890D4Ef96551C9904e7D4E73d2C22D3F207F5CFb",
devnet: process.env["DEVBNET_METIST_L1_BRIDGE"] as string,
};

const l1MetisMap: { [key: string]: string } = {
mainnet: "0x9e32b13ce7f2e80a01932b42553652e053d6ed8e",
sepolia: "0x7f49160EB9BB068101d445fe77E17ecDb37D0B47",
holesky: "0xaf8e5B10c69c983204505cDCD56Ec2aC2280D08e",
devnet: process.env["DEVBNET_METIST_TOKEN"] as string,
};

export { l2ChainIdMap, l1BridgeMap, l1MetisMap };

0 comments on commit d3eb0d8

Please sign in to comment.