Commit 3c92bdb4 authored by Matt Masurka's avatar Matt Masurka Committed by GitHub

contracts: script for making markdown file with all our contract addresses (#456)

* contracts: adds generate-markdown script for making markdown file with all our contract addresses

* Moves generate-markdown to deploy script

* Adds Goerli chain Id

* Removes etherscan Open column
Co-authored-by: default avatarPacien Boisson <pakokrew@gmail.com>
parent fae4e29b
This diff is collapsed.
......@@ -31,12 +31,13 @@
"lint:fix": "yarn run lint:fix:typescript",
"lint:fix:typescript": "prettier --config prettier-config.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"",
"clean": "rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm ./tsconfig.build.tsbuildinfo",
"deploy": "./bin/deploy.ts",
"deploy": "./bin/deploy.ts && yarn generate-markdown",
"serve": "./bin/serve_dump.sh",
"prepublishOnly": "yarn copyfiles -u 2 \"contracts/optimistic-ethereum/**/*\" ./",
"postpublish": "rimraf OVM iOVM libraries mockOVM",
"prepack": "yarn prepublishOnly",
"postpack": "yarn postpublish"
"postpack": "yarn postpublish",
"generate-markdown": "node scripts/generate-markdown.js"
},
"dependencies": {
"@eth-optimism/core-utils": "^0.2.1",
......
#!/usr/bin/env node
const dirtree = require("directory-tree");
const fs = require("fs");
/**
*
* takes a directory of hardhat artifacts and builds a markdown table that shows the name of the contract in one column and its address in another column with a hyperlink to etherscan
*
*/
const networks = {
1: "mainnet",
3: "ropsten",
4: "rinkeby",
5: "goerli",
42: "kovan",
};
(async () => {
console.log(`Writing contract addresses`);
const deployments = dirtree(`./deployments`)
.children.filter((child) => {
return child.type === "directory";
})
.map((d) => d.name)
.reverse();
let md = `# Optimism Regenesis Deployments
## LAYER 2
### Chain IDs:
- Mainnet: 10
- Kovan: 69
- Goerli: 420
*The contracts relevant for the majority of developers are \`OVM_ETH\` and the cross-domain messengers. The L2 addresses don't change.*
### Predeploy contracts:
|Contract|Address|
|--|--|
|OVM_ETH: | \`0x4200000000000000000000000000000000000006\`
|OVM_L2CrossDomainMessenger: | \`0x4200000000000000000000000000000000000007\`
|OVM_L2ToL1MessagePasser: | \`0x4200000000000000000000000000000000000000\`
|OVM_L1MessageSender: | \`0x4200000000000000000000000000000000000001\`
|OVM_DeployerWhitelist: | \`0x4200000000000000000000000000000000000002\`
|OVM_ECDSAContractAccount: | \`0x4200000000000000000000000000000000000003\`
|OVM_ProxySequencerEntrypoint: | \`0x4200000000000000000000000000000000000004\`
|OVM_SequencerEntrypoint: | \`0x4200000000000000000000000000000000000005\`
|Lib_AddressManager: | \`0x4200000000000000000000000000000000000008\`
|ERC1820Registry: | \`0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24\`
---
---
## LAYER 1\n\n`;
for (let deployment of deployments) {
md += `## ${deployment.toUpperCase()}\n\n`;
const chainId = Number(
fs.readFileSync(`./deployments/${deployment}/.chainId`)
);
const network = networks[chainId];
md += `Network : __${network} (chain id: ${chainId})__\n\n`;
md += `|Contract|Address|\n`;
md += `|--|--|\n`;
const contracts = dirtree(`./deployments/${deployment}`)
.children.filter((child) => {
return child.extension === ".json";
})
.map((child) => {
return child.name.replace(".json", "");
});
for (const contract of contracts) {
const deploymentInfo = require(`../deployments/${deployment}/${contract}.json`);
const escPrefix = chainId !== 1 ? `${network}.` : "";
const etherscanUrl = `https://${escPrefix}etherscan.io/address/${deploymentInfo.address}`;
md += `|${contract}|[${deploymentInfo.address}](${etherscanUrl})|\n`;
}
md += `---\n`;
}
fs.writeFileSync(`./addresses.md`, md);
})().catch(console.error);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment