forked from scroll-tech/scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitialize_l1_custom_erc20_gateway.ts
43 lines (35 loc) · 1.33 KB
/
initialize_l1_custom_erc20_gateway.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable node/no-missing-import */
import * as dotenv from "dotenv";
import { constants } from "ethers";
import * as hre from "hardhat";
import { ethers } from "hardhat";
import { selectAddressFile } from "./utils";
dotenv.config();
async function main() {
const addressFile = selectAddressFile(hre.network.name);
const [deployer] = await ethers.getSigners();
const L1CustomERC20Gateway = await ethers.getContractAt(
"L1CustomERC20Gateway",
addressFile.get("L1CustomERC20Gateway.proxy"),
deployer
);
const L1GatewayRouterAddress = addressFile.get("L1GatewayRouter.proxy");
const L1ScrollMessengerAddress = addressFile.get("L1ScrollMessenger.proxy");
const L2CustomERC20GatewayAddress = process.env.L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR!;
if ((await L1CustomERC20Gateway.counterpart()) === constants.AddressZero) {
const tx = await L1CustomERC20Gateway.initialize(
L2CustomERC20GatewayAddress,
L1GatewayRouterAddress,
L1ScrollMessengerAddress
);
console.log("initialize L1CustomERC20Gateway, hash:", tx.hash);
const receipt = await tx.wait();
console.log(`✅ Done, gas used: ${receipt.gasUsed}`);
}
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});