diff --git a/README.md b/README.md index 278426a..fc8ccaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,44 @@ -> [!NOTE] -> Interim repository. +# Deplyoment Log Generator -``` +The deployment log generator is a tool that generates a json file and a human readable markdown log file with the deployment information about contracts deployed using `forge script`. It can keep track of upgrades for transparent proxies and generates a history of deployments. An example for such a log can be found [here](https://github.com/0xPolygon/pol-token/blob/main/deployments/5.md). Logs are generated by extracting information from the `run-latest.json` file generated by `forge script` in the `broadcast` directory. + +## Requirements + +The script utilizes Node.js to run. We recommend the node version defined in the `.nvmrc` file. + +## Installation + +```bash forge install 0xPolygon/deployment-log-generator ``` + +## Usage Example + +The following command will create a log for the contracts deployed in the `Deploy.s.sol` script on Ethereum mainnet. + +```bash +node lib/deployment-log-generator Deploy.s.sol --chain-id 1 --rpc-url https://mainnet.infura.io/v3/{your-infura-key} +``` + +## Usage + +Deployment markdown & json log file will be placed within the `deployments` directory. The name of the file will be the chain id of the network where the script was executed (e.g., for Ethereum mainnet the files will be `deployments/1.md` and `deployments/json/1.json`). + +Supplying the RPC url _can_ be optional. When contracts are deployed, the RPC url is used to check whether the deployed contracts implement a `version()` function. If they do, the version is extracted and recorded within the log file. If no RPC url is supplied, the version check is skipped. + +Supplying the RPC url is _required_ when an upgrade is deployed for a transparent proxy. The script can recognize when an upgrade is deployed, however, most of the times, only an implementation is deployed and the actual upgrade is performed by a multisig or governance. When an upgrade is detected, the RPC url will be used to verify that the upgrade was performed on chain directly and only then, deployment log files will be generated. If the upgrade was not performed on chain yet, the script will abort. + +## Flags + +| --flag | -flag | Description | +| ----------- | ----- | -------------------------------------------------------------------------- | +| --rpc-url | -r | RPC url used for versioning and upgrade verification (default: $RPC_URL) | +| --chain-id | -c | Chain id of the network where the script was executed (default: 31337) | +| --skip-json | -s | Skip generation of json file and only generate markdown from existing json | +| Options | | | +| --help | -h | Print help | +| --version | -v | Print the version number | + +--- + +© 2023 PT Services DMCC diff --git a/index.js b/index.js index 0d4cce2..30557a9 100644 --- a/index.js +++ b/index.js @@ -85,7 +85,7 @@ function validateAndExtractInputs() { const printHelp = () => { console.log( - "\nUsage: node lib/deployment-log-generator [-c chain-id] [-r rpc-url] [-s skip-json]\n\nCommands:\n -c, --chain-id\tChain id of the network where the script was executed (default: 31337)\n -r, --rpc-url\t\tRPC url used to fetch the version of the contract (default: $RPC_URL). If no rpc url is provided, version fetching is skipped.\n -s, --skip-json\tSkips the json generation and creates the markdown file using an existing json file\n\nOptions:\n -h, --help\t\tPrint help\n -v, --version\t\tPrint version\n\nDocumentation can be found at https://github.com/0xPolygon/deployment-log-generator", + "\nUsage: node lib/deployment-log-generator [-c chain-id] [-r rpc-url] [-s skip-json]\n\nCommands:\n -c, --chain-id\tChain id of the network where the script was executed (default: 31337)\n -r, --rpc-url\t\tRPC url used to fetch the version of the contract or verify an upgrade (default: $RPC_URL). If no rpc url is provided, version fetching is skipped.\n -s, --skip-json\tSkips the json generation and creates the markdown file using an existing json file\n\nOptions:\n -h, --help\t\tPrint help\n -v, --version\t\tPrint version\n\nDocumentation can be found at https://github.com/0xPolygon/deployment-log-generator", ); };