|
1 | 1 | import "hardhat-deploy";
|
2 |
| -import { HardhatRuntimeEnvironment } from "hardhat/types/runtime"; |
3 |
| - |
| 2 | +import hre from "hardhat"; |
4 | 3 | import { L2_ADDRESS_MAP } from "./consts";
|
| 4 | +import { getContractFactory } from "../utils"; |
5 | 5 |
|
6 |
| -const func = async function (hre: HardhatRuntimeEnvironment) { |
7 |
| - const { deployments, getNamedAccounts, getChainId } = hre; |
8 |
| - const { deploy } = deployments; |
| 6 | +const func = async function () { |
| 7 | + const { upgrades, run, getChainId, getNamedAccounts } = hre; |
9 | 8 |
|
| 9 | + const chainId = parseInt(await getChainId()); |
| 10 | + const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool"); |
10 | 11 | const { deployer } = await getNamedAccounts();
|
11 | 12 |
|
12 |
| - const chainId = parseInt(await getChainId()); |
13 |
| - const l1HubPool = await hre.companionNetworks.l1.deployments.get("HubPool"); |
14 |
| - const polygonTokenBridger = await deployments.get("PolygonTokenBridger"); |
| 13 | + // Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's |
| 14 | + // with deprecated spoke pool. |
| 15 | + // Set hub pool as cross domain admin since it delegatecalls the Adapter logic. |
| 16 | + const constructorArgs = [ |
| 17 | + 1_000_000, |
| 18 | + // The same token bridger must be deployed on mainnet and polygon, so its easier |
| 19 | + // to reuse it. |
| 20 | + "0x0330E9b4D0325cCfF515E81DFbc7754F2a02ac57", |
| 21 | + hubPool.address, |
| 22 | + hubPool.address, |
| 23 | + L2_ADDRESS_MAP[chainId].wMatic, |
| 24 | + L2_ADDRESS_MAP[chainId].fxChild, |
| 25 | + ]; |
| 26 | + const spokePool = await upgrades.deployProxy( |
| 27 | + await getContractFactory("Polygon_SpokePool", deployer), |
| 28 | + constructorArgs, |
| 29 | + { |
| 30 | + kind: "uups", |
| 31 | + } |
| 32 | + ); |
| 33 | + const instance = await spokePool.deployed(); |
| 34 | + console.log(`SpokePool deployed @ ${instance.address}`); |
| 35 | + const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address); |
| 36 | + console.log(`Implementation deployed @ ${implementationAddress}`); |
15 | 37 |
|
16 |
| - await deploy("Polygon_SpokePool", { |
17 |
| - from: deployer, |
18 |
| - log: true, |
19 |
| - skipIfAlreadyDeployed: true, |
20 |
| - args: [ |
21 |
| - polygonTokenBridger.address, |
22 |
| - l1HubPool.address, |
23 |
| - l1HubPool.address, |
24 |
| - L2_ADDRESS_MAP[chainId].wMatic, |
25 |
| - L2_ADDRESS_MAP[chainId].fxChild, |
26 |
| - "0x0000000000000000000000000000000000000000", |
27 |
| - ], |
| 38 | + // hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed |
| 39 | + // is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy |
| 40 | + // to the implementation's ABI on etherscan. |
| 41 | + // https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify |
| 42 | + await run("verify:verify", { |
| 43 | + address: instance.address, |
28 | 44 | });
|
29 | 45 | };
|
30 | 46 |
|
31 | 47 | module.exports = func;
|
32 |
| -func.dependencies = ["PolygonTokenBridgerL2"]; |
33 | 48 | func.tags = ["PolygonSpokePool", "polygon"];
|
0 commit comments