|
| 1 | +import assert from "assert"; |
| 2 | +import { HardhatRuntimeEnvironment } from "hardhat/types"; |
| 3 | +import { DeployFunction } from "hardhat-deploy/types"; |
| 4 | +import { |
| 5 | + L1_ADDRESS_MAP, |
| 6 | + WETH, |
| 7 | + ZK_L2_GAS_LIMIT, |
| 8 | + ZK_L1_GAS_TO_L2_GAS_PER_PUBDATA_LIMIT, |
| 9 | + ZK_MAX_GASPRICE, |
| 10 | +} from "./consts"; |
| 11 | + |
| 12 | +/** |
| 13 | + * Note: |
| 14 | + * This adapter supports ZkStack L2s. |
| 15 | + * |
| 16 | + * Usage: |
| 17 | + * $ SPOKE_CHAIN_ID=37111 yarn hardhat deploy --network sepolia --tags ZkStackCustomGasTokenAdapter |
| 18 | + */ |
| 19 | + |
| 20 | +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { |
| 21 | + // Excess bridge fees will go to this address on L2. |
| 22 | + const L2_REFUND_ADDRESS = "0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67"; |
| 23 | + |
| 24 | + const { SPOKE_CHAIN_ID } = process.env; |
| 25 | + assert(SPOKE_CHAIN_ID !== undefined, "SPOKE_CHAIN_ID not defined in environment"); |
| 26 | + assert( |
| 27 | + parseInt(SPOKE_CHAIN_ID).toString() === SPOKE_CHAIN_ID, |
| 28 | + "SPOKE_CHAIN_ID (${SPOKE_CHAIN_ID}) must be an integer" |
| 29 | + ); |
| 30 | + |
| 31 | + const { deployer } = await hre.getNamedAccounts(); |
| 32 | + const chainId = parseInt(await hre.getChainId()); |
| 33 | + |
| 34 | + const constructorArguments = [ |
| 35 | + SPOKE_CHAIN_ID, |
| 36 | + L1_ADDRESS_MAP[chainId][`zkBridgeHub_${SPOKE_CHAIN_ID}`], |
| 37 | + WETH[chainId], |
| 38 | + L2_REFUND_ADDRESS, |
| 39 | + ZK_L2_GAS_LIMIT, |
| 40 | + ZK_L1_GAS_TO_L2_GAS_PER_PUBDATA_LIMIT, |
| 41 | + ZK_MAX_GASPRICE, |
| 42 | + ]; |
| 43 | + |
| 44 | + const { address: deployment } = await hre.deployments.deploy("ZkStack_Adapter", { |
| 45 | + from: deployer, |
| 46 | + log: true, |
| 47 | + skipIfAlreadyDeployed: true, |
| 48 | + args: constructorArguments, |
| 49 | + }); |
| 50 | + |
| 51 | + await hre.run("verify:verify", { address: deployment, constructorArguments }); |
| 52 | +}; |
| 53 | + |
| 54 | +module.exports = func; |
| 55 | +func.tags = ["ZkStackAdapter", "mainnet"]; |
0 commit comments