"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv = __importStar(require("dotenv"));
const common_1 = require("@uma/common");
const constants_1 = require("./utils/constants");
require("@nomicfoundation/hardhat-verify"); // Must be above hardhat-upgrades
require("@nomiclabs/hardhat-waffle");
require("@typechain/hardhat");
require("@matterlabs/hardhat-zksync-solc");
require("@matterlabs/hardhat-zksync-verify");
require("@matterlabs/hardhat-zksync-upgradable");
require("hardhat-gas-reporter");
require("solidity-coverage");
require("hardhat-deploy");
require("@openzeppelin/hardhat-upgrades");
// Custom tasks to add to HRE.
const tasks = [
    "enableL1TokenAcrossEcosystem",
    "finalizeScrollClaims",
    "rescueStuckScrollTxn",
    "verifySpokePool",
    "evmRelayMessageWithdrawal",
    "testChainAdapter",
    "upgradeSpokePool",
];
// eslint-disable-next-line node/no-missing-require
tasks.forEach((task) => require(`./tasks/${task}`));
dotenv.config();
const isTest = process.env.IS_TEST === "true" || process.env.CI === "true";
// To compile with zksolc, `hardhat` must be the default network and its `zksync` property must be true.
// So we allow the caller to set this environment variable to toggle compiling zk contracts or not.
// TODO: Figure out way to only compile specific contracts intended to be deployed on ZkSync (e.g. ZkSync_SpokePool) if
// the following config is true.
const compileZk = process.env.COMPILE_ZK === "true";
const solcVersion = "0.8.23";
const mnemonic = (0, common_1.getMnemonic)();
// Compilation settings are overridden for large contracts to allow them to compile without going over the bytecode
// limit.
const LARGE_CONTRACT_COMPILER_SETTINGS = {
    version: solcVersion,
    settings: {
        optimizer: { enabled: true, runs: 800 },
        viaIR: true,
        debug: { revertStrings: isTest ? "debug" : "strip" },
    },
};
const DEFAULT_CONTRACT_COMPILER_SETTINGS = {
    version: solcVersion,
    settings: {
        optimizer: { enabled: true, runs: 1000000 },
        viaIR: true,
        // Only strip revert strings if not testing or in ci.
        debug: { revertStrings: isTest ? "debug" : "strip" },
    },
};
const config = {
    solidity: {
        compilers: [DEFAULT_CONTRACT_COMPILER_SETTINGS],
        overrides: {
            "contracts/HubPool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Linea_SpokePool.sol": {
                ...LARGE_CONTRACT_COMPILER_SETTINGS,
                // NOTE: Linea only supports 0.8.19.
                // See https://docs.linea.build/build-on-linea/ethereum-differences#evm-opcodes
                version: "0.8.19",
            },
            "contracts/SpokePoolVerifier.sol": {
                ...DEFAULT_CONTRACT_COMPILER_SETTINGS,
                // NOTE: Linea only supports 0.8.19.
                // See https://docs.linea.build/build-on-linea/ethereum-differences#evm-opcodes
                version: "0.8.19",
            },
            "contracts/Arbitrum_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Scroll_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Blast_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Lisk_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Redstone_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Zora_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Mode_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Base_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Optimism_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/WorldChain_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Ink_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/Cher_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
            "contracts/DoctorWho_SpokePool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
        },
    },
    zksolc: {
        version: "latest",
        settings: {
            optimizer: {
                enabled: true,
            },
        },
    },
    networks: {
        hardhat: {
            accounts: { accountsBalance: "1000000000000000000000000" },
            zksync: compileZk,
            allowUnlimitedContractSize: true,
        },
        mainnet: {
            url: (0, common_1.getNodeUrl)("mainnet", true, 1),
            accounts: { mnemonic },
            saveDeployments: true,
            chainId: constants_1.CHAIN_IDs.MAINNET,
            companionNetworks: { l1: "mainnet" },
        },
        zksync: {
            chainId: constants_1.CHAIN_IDs.ZK_SYNC,
            url: "https://mainnet.era.zksync.io",
            saveDeployments: true,
            accounts: { mnemonic },
            ethNetwork: "mainnet",
            companionNetworks: { l1: "mainnet" },
            zksync: true,
            verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
        },
        optimism: {
            url: (0, common_1.getNodeUrl)("optimism-mainnet", true, constants_1.CHAIN_IDs.OPTIMISM),
            accounts: { mnemonic },
            saveDeployments: true,
            chainId: constants_1.CHAIN_IDs.OPTIMISM,
            companionNetworks: { l1: "mainnet" },
        },
        "optimism-sepolia": {
            url: (0, common_1.getNodeUrl)("optimism-sepolia", true, constants_1.CHAIN_IDs.OPTIMISM_SEPOLIA),
            accounts: { mnemonic },
            saveDeployments: true,
            chainId: constants_1.CHAIN_IDs.OPTIMISM_SEPOLIA,
            companionNetworks: { l1: "sepolia" },
        },
        arbitrum: {
            chainId: constants_1.CHAIN_IDs.ARBITRUM,
            url: (0, common_1.getNodeUrl)("arbitrum-mainnet", true, constants_1.CHAIN_IDs.ARBITRUM),
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "arbitrum-sepolia": {
            chainId: constants_1.CHAIN_IDs.ARBITRUM_SEPOLIA,
            url: (0, common_1.getNodeUrl)("arbitrum-sepolia", true, constants_1.CHAIN_IDs.ARBITRUM_SEPOLIA),
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        sepolia: {
            url: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
            accounts: { mnemonic },
            saveDeployments: true,
            chainId: constants_1.CHAIN_IDs.SEPOLIA,
            companionNetworks: { l1: "sepolia" },
        },
        polygon: {
            chainId: constants_1.CHAIN_IDs.POLYGON,
            url: (0, common_1.getNodeUrl)("polygon-mainnet", true, constants_1.CHAIN_IDs.POLYGON),
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        boba: {
            chainId: constants_1.CHAIN_IDs.BOBA,
            url: (0, common_1.getNodeUrl)("boba", true, constants_1.CHAIN_IDs.BOBA),
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "polygon-amoy": {
            chainId: constants_1.CHAIN_IDs.POLYGON_AMOY,
            url: "https://rpc-amoy.polygon.technology",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        base: {
            chainId: constants_1.CHAIN_IDs.BASE,
            url: "https://mainnet.base.org",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "base-sepolia": {
            chainId: constants_1.CHAIN_IDs.BASE_SEPOLIA,
            url: `https://base-sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        ink: {
            chainId: constants_1.CHAIN_IDs.INK,
            url: "https://rpc-gel.inkonchain.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        linea: {
            chainId: constants_1.CHAIN_IDs.LINEA,
            url: `https://linea-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        scroll: {
            chainId: constants_1.CHAIN_IDs.SCROLL,
            url: "https://rpc.scroll.io",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "scroll-sepolia": {
            chainId: constants_1.CHAIN_IDs.SCROLL_SEPOLIA,
            url: "https://sepolia-rpc.scroll.io",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        "polygon-zk-evm": {
            chainId: 1101,
            url: "https://zkevm-rpc.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "polygon-zk-evm-testnet": {
            chainId: 1442,
            url: "https://rpc.public.zkevm-test.net",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "goerli" },
        },
        mode: {
            chainId: constants_1.CHAIN_IDs.MODE,
            url: "https://mainnet.mode.network",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "mode-sepolia": {
            chainId: constants_1.CHAIN_IDs.MODE_SEPOLIA,
            url: "https://sepolia.mode.network",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        "lens-sepolia": {
            chainId: constants_1.CHAIN_IDs.LENS_SEPOLIA,
            url: "https://rpc.testnet.lens.dev",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
            ethNetwork: "sepolia",
            verifyURL: "https://block-explorer-verify.testnet.lens.dev/contract_verification",
            zksync: true,
        },
        lisk: {
            chainId: constants_1.CHAIN_IDs.LISK,
            url: "https://rpc.api.lisk.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "lisk-sepolia": {
            chainId: constants_1.CHAIN_IDs.LISK_SEPOLIA,
            url: "https://rpc.sepolia-api.lisk.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        redstone: {
            chainId: constants_1.CHAIN_IDs.REDSTONE,
            url: "https://rpc.redstonechain.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        blast: {
            chainId: constants_1.CHAIN_IDs.BLAST,
            url: "https://rpc.blast.io",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "blast-sepolia": {
            chainId: constants_1.CHAIN_IDs.BLAST_SEPOLIA,
            url: "https://sepolia.blast.io",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
        worldchain: {
            chainId: constants_1.CHAIN_IDs.WORLD_CHAIN,
            url: "https://worldchain-mainnet.g.alchemy.com/public",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        zora: {
            chainId: constants_1.CHAIN_IDs.ZORA,
            url: "https://rpc.zora.energy",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        alephzero: {
            chainId: constants_1.CHAIN_IDs.ALEPH_ZERO,
            url: "https://rpc.alephzero.raas.gelato.cloud",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        soneium: {
            chainId: constants_1.CHAIN_IDs.SONEIUM,
            url: "https://soneium.blockscout.com",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        unichain: {
            chainId: constants_1.CHAIN_IDs.UNICHAIN,
            url: "https://mainnet.unichain.org",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "mainnet" },
        },
        "unichain-sepolia": {
            chainId: constants_1.CHAIN_IDs.UNICHAIN_SEPOLIA,
            url: "https://sepolia.unichain.org",
            saveDeployments: true,
            accounts: { mnemonic },
            companionNetworks: { l1: "sepolia" },
        },
    },
    gasReporter: { enabled: process.env.REPORT_GAS !== undefined, currency: "USD" },
    etherscan: {
        apiKey: {
            mainnet: process.env.ETHERSCAN_API_KEY,
            sepolia: process.env.ETHERSCAN_API_KEY,
            optimisticEthereum: process.env.OPTIMISM_ETHERSCAN_API_KEY,
            optimisticSepolia: process.env.OPTIMISM_ETHERSCAN_API_KEY,
            arbitrumOne: process.env.ARBITRUM_ETHERSCAN_API_KEY,
            "arbitrum-sepolia": process.env.ARBITRUM_ETHERSCAN_API_KEY,
            polygon: process.env.POLYGON_ETHERSCAN_API_KEY,
            "polygon-amoy": process.env.POLYGON_ETHERSCAN_API_KEY,
            base: process.env.BASE_ETHERSCAN_API_KEY,
            "base-sepolia": process.env.BASE_ETHERSCAN_API_KEY,
            linea: process.env.LINEA_ETHERSCAN_API_KEY,
            scroll: process.env.SCROLL_ETHERSCAN_API_KEY,
            "scroll-sepolia": process.env.SCROLL_ETHERSCAN_API_KEY,
            "polygon-zk-evm": process.env.POLYGON_ZK_EVM_ETHERSCAN_API_KEY,
            "polygon-zk-evm-testnet": process.env.POLYGON_ZK_EVM_ETHERSCAN_API_KEY,
            mode: "blockscout",
            "mode-sepolia": "blockscout",
            lisk: "blockscout",
            "lisk-sepolia": "blockscout",
            redstone: "blockscout",
            blast: process.env.BLAST_ETHERSCAN_API_KEY,
            "blast-sepolia": process.env.BLAST_ETHERSCAN_API_KEY,
            zora: "routescan",
            worldchain: "blockscout",
            alephzero: "blockscout",
            ink: "blockscout",
            soneium: "blockscout",
            unichain: process.env.UNICHAIN_ETHERSCAN_API_KEY,
            "unichain-sepolia": process.env.UNICHAIN_ETHERSCAN_API_KEY,
        },
        customChains: [
            {
                network: "alephzero",
                chainId: constants_1.CHAIN_IDs.ALEPH_ZERO,
                urls: {
                    apiURL: "https://evm-explorer.alephzero.org/api",
                    browserURL: "https://evm-explorer.alephzero.org",
                },
            },
            {
                network: "base",
                chainId: constants_1.CHAIN_IDs.BASE,
                urls: {
                    apiURL: "https://api.basescan.org/api",
                    browserURL: "https://basescan.org",
                },
            },
            {
                network: "base-sepolia",
                chainId: constants_1.CHAIN_IDs.BASE_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.basescan.org/api",
                    browserURL: "https://sepolia.basescan.org",
                },
            },
            {
                network: "ink",
                chainId: constants_1.CHAIN_IDs.INK,
                urls: {
                    apiURL: "https://explorer.inkonchain.com/api",
                    browserURL: "https://explorer.inkonchain.com",
                },
            },
            {
                network: "soneium",
                chainId: constants_1.CHAIN_IDs.SONEIUM,
                urls: {
                    apiURL: "https://soneium.blockscout.com/api",
                    browserURL: "https://soneium.blockscout.com",
                },
            },
            {
                network: "linea",
                chainId: constants_1.CHAIN_IDs.LINEA,
                urls: {
                    apiURL: "https://api.lineascan.build/api",
                    browserURL: "https://lineascan.build",
                },
            },
            {
                network: "sepolia",
                chainId: constants_1.CHAIN_IDs.SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.etherscan.io/api",
                    browserURL: "https://sepolia.etherscan.io",
                },
            },
            {
                network: "scroll",
                chainId: constants_1.CHAIN_IDs.SCROLL,
                urls: {
                    apiURL: "https://api.scrollscan.com/api",
                    browserURL: "https://scrollscan.com",
                },
            },
            {
                network: "scroll-sepolia",
                chainId: constants_1.CHAIN_IDs.SCROLL_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.scrollscan.com/api",
                    browserURL: "https://api-sepolia.scrollscan.com",
                },
            },
            {
                network: "optimisticSepolia",
                chainId: constants_1.CHAIN_IDs.OPTIMISM_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia-optimistic.etherscan.io/api",
                    browserURL: "https://sepolia-optimism.etherscan.io",
                },
            },
            {
                network: "polygon-zk-evm",
                chainId: 1101,
                urls: {
                    apiURL: "https://api-zkevm.polygonscan.com/api",
                    browserURL: "https://zkevm.polygonscan.com",
                },
            },
            {
                network: "polygon-zk-evm-testnet",
                chainId: 1442,
                urls: {
                    apiURL: "https://api-testnet-zkevm.polygonscan.com/api",
                    browserURL: "https://testnet-zkevm.polygonscan.com/",
                },
            },
            {
                network: "polygon-amoy",
                chainId: constants_1.CHAIN_IDs.POLYGON_AMOY,
                urls: {
                    apiURL: "https://api-amoy.polygonscan.com/api",
                    browserURL: "https://amoy.polygonscan.com",
                },
            },
            {
                network: "arbitrum-sepolia",
                chainId: constants_1.CHAIN_IDs.ARBITRUM_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.arbiscan.io/api",
                    browserURL: "https://sepolia.arbiscan.io",
                },
            },
            {
                network: "mode-sepolia",
                chainId: constants_1.CHAIN_IDs.MODE_SEPOLIA,
                urls: {
                    apiURL: "https://api.routescan.io/v2/network/testnet/evm/919/etherscan",
                    browserURL: "https://testnet.modescan.io",
                },
            },
            {
                network: "mode",
                chainId: constants_1.CHAIN_IDs.MODE,
                urls: {
                    apiURL: "https://explorer.mode.network/api",
                    browserURL: "https://explorer.mode.network/",
                },
            },
            {
                network: "lisk",
                chainId: constants_1.CHAIN_IDs.LISK,
                urls: {
                    apiURL: "https://blockscout.lisk.com/api",
                    browserURL: "https://blockscout.lisk.com",
                },
            },
            {
                network: "lisk-sepolia",
                chainId: constants_1.CHAIN_IDs.LISK_SEPOLIA,
                urls: {
                    apiURL: "https://sepolia-blockscout.lisk.com/api",
                    browserURL: "https://sepolia-blockscout.lisk.com",
                },
            },
            {
                network: "redstone",
                chainId: constants_1.CHAIN_IDs.REDSTONE,
                urls: {
                    apiURL: "https://explorer.redstone.xyz/api",
                    browserURL: "https://explorer.redstone.xyz",
                },
            },
            {
                network: "blast",
                chainId: constants_1.CHAIN_IDs.BLAST,
                urls: {
                    apiURL: "https://api.blastscan.io/api",
                    browserURL: "https://blastscan.io",
                },
            },
            {
                network: "blast-sepolia",
                chainId: constants_1.CHAIN_IDs.BLAST_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.blastscan.io/api",
                    browserURL: "https://sepolia.blastscan.io",
                },
            },
            {
                network: "worldchain",
                chainId: constants_1.CHAIN_IDs.WORLD_CHAIN,
                urls: {
                    apiURL: "https://worldchain-mainnet.explorer.alchemy.com/api",
                    browserURL: "https://worldchain-mainnet.explorer.alchemy.com",
                },
            },
            {
                network: "zora",
                chainId: constants_1.CHAIN_IDs.ZORA,
                urls: {
                    apiURL: "https://api.routescan.io/v2/network/mainnet/evm/7777777/etherscan",
                    browserURL: "https://zorascan.xyz",
                },
            },
            {
                network: "unichain",
                chainId: constants_1.CHAIN_IDs.UNICHAIN,
                urls: {
                    apiURL: "https://api.uniscan.xyz/api",
                    browserURL: "https://uniscan.xyz",
                },
            },
            {
                network: "unichain-sepolia",
                chainId: constants_1.CHAIN_IDs.UNICHAIN_SEPOLIA,
                urls: {
                    apiURL: "https://api-sepolia.uniscan.xyz/api",
                    browserURL: "https://sepolia.uniscan.xyz",
                },
            },
        ],
    },
    namedAccounts: { deployer: 0 },
    typechain: {
        outDir: "./typechain",
        target: "ethers-v5",
    },
    paths: {
        tests: "./test/evm/hardhat",
    },
};
exports.default = config;
