import fs from 'fs' import path from 'path' import dirtree from 'directory-tree' import { predeploys } from '../src' interface DeploymentInfo { folder: string name: string chainid: number rpc?: string l1Explorer?: string l2Explorer?: string notice?: string } const PUBLIC_DEPLOYMENTS: DeploymentInfo[] = [ { folder: 'mainnet', name: 'Optimism (mainnet)', chainid: 10, rpc: 'https://mainnet.optimism.io', l1Explorer: 'https://etherscan.io', l2Explorer: 'https://optimistic.etherscan.io', }, { folder: 'kovan', name: 'Optimism Kovan (public testnet)', chainid: 69, rpc: 'https://kovan.optimism.io', l1Explorer: 'https://kovan.etherscan.io', l2Explorer: 'https://kovan-optimistic.etherscan.io', }, { folder: 'goerli', name: 'Optimism Goerli (internal devnet)', chainid: 420, notice: `Optimism Goerli is an internal Optimism development network. You're probably looking for [Optimism Kovan](../kovan#readme), the public Optimism testnet.`, l1Explorer: 'https://goerli.etherscan.io', }, ] // List of contracts that are part of a deployment but aren't meant to be used by the general // public. E.g., implementation addresses for proxy contracts or helpers used during the // deployment process. Although these addresses are public and users can technically try to use // them, there's no point in doing so. As a result, we hide these addresses to avoid confusion. const HIDDEN_CONTRACTS = [ // Used for being able to verify the ChugSplashProxy contract. 'L1StandardBridge_for_verification_only', // Implementation address for the Proxy__OVM_L1CrossDomainMessenger. 'OVM_L1CrossDomainMessenger', // Utility for modifying many records in the AddressManager at the same time. 'AddressDictator', // Utility for modifying a ChugSplashProxy during an upgrade. 'ChugSplashDictator', ] interface ContractInfo { name: string address: string } /** * Gets the full deployment folder path for a given deployment. * * @param name Deployment folder name. * @returns Full path to the deployment folder. */ const getDeploymentFolderPath = (name: string): string => { return path.resolve(__dirname, `../deployments/${name}`) } /** * Helper function for adding a line to a string. Avoids having to add the ugly \n to each new line * that you want to add a string. * * @param str String to add a line to. * @param line Line to add to the string. * @returns String with the added line and a newline at the end. */ const addline = (str: string, line: string): string => { return str + line + '\n' } /** * Generates a nicely formatted table presenting a list of contracts. * * @param contracts List of contracts to display. * @param explorer URL for etherscan for the network that the contracts are deployed to. * @returns Nicely formatted markdown-compatible table as a string. */ const buildContractsTable = ( contracts: ContractInfo[], explorer?: string ): string => { // Being very verbose within this function to make it clear what's going on. // We use HTML instead of markdown so we can get a table that displays well on GitHub. // GitHub READMEs are 1012px wide. Adding a 506px image to each table header is a hack that // allows us to create a table where each column is 1/2 the full README width. let table = `` table = addline(table, '
')
table = addline(table, ' Contract ') table = addline(table, ' | ')
table = addline(table, '')
table = addline(table, ' Address ') table = addline(table, ' | ')
table = addline(table, '
---|---|
') table = addline(table, contract.name) table = addline(table, ' | ') table = addline(table, '')
if (explorer) {
table = addline(
table,
``
)
table = addline(table, `${contract.address} `)
table = addline(table, '')
} else {
table = addline(table, `${contract.address} `)
}
table = addline(table, ' | ')
table = addline(table, '