Skip to content

Commit

Permalink
Adds l2 standard bridge to contracts markdown file (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamesh authored Jun 23, 2021
1 parent 40b99a6 commit 0112650
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
1 change: 1 addition & 0 deletions packages/contracts/deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
|Contract|Address|
|--|--|
|OVM_ETH: | `0x4200000000000000000000000000000000000006`
|OVM_L2StandardBridge: | `0x4200000000000000000000000000000000000010`
|OVM_L2CrossDomainMessenger: | `0x4200000000000000000000000000000000000007`
|OVM_L2ToL1MessagePasser: | `0x4200000000000000000000000000000000000000`
|OVM_L1MessageSender: | `0x4200000000000000000000000000000000000001`
Expand Down
89 changes: 46 additions & 43 deletions packages/contracts/scripts/generate-markdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
const dirtree = require("directory-tree");
const fs = require("fs");
const dirtree = require('directory-tree')
const fs = require('fs')

/**
*
Expand All @@ -9,22 +9,22 @@ const fs = require("fs");
*/

const networks = {
1: "mainnet",
3: "ropsten",
4: "rinkeby",
5: "goerli",
42: "kovan",
};
1: 'mainnet',
3: 'ropsten',
4: 'rinkeby',
5: 'goerli',
42: 'kovan',
}

(async () => {
console.log(`Writing contract addresses`);
;(async () => {
console.log(`Writing contract addresses`)

const deployments = dirtree(`./deployments`)
.children.filter((child) => {
return child.type === "directory";
return child.type === 'directory'
})
.map((d) => d.name)
.reverse();
.reverse()

let md = `# Optimism Regenesis Deployments
## LAYER 2
Expand All @@ -39,6 +39,7 @@ const networks = {
|Contract|Address|
|--|--|
|OVM_ETH: | \`0x4200000000000000000000000000000000000006\`
|OVM_L2StandardBridge: | \`0x4200000000000000000000000000000000000010\`
|OVM_L2CrossDomainMessenger: | \`0x4200000000000000000000000000000000000007\`
|OVM_L2ToL1MessagePasser: | \`0x4200000000000000000000000000000000000000\`
|OVM_L1MessageSender: | \`0x4200000000000000000000000000000000000001\`
Expand All @@ -51,62 +52,64 @@ const networks = {
---
---
## LAYER 1\n\n`;
## LAYER 1\n\n`

for (let deployment of deployments) {
md += `## ${deployment.toUpperCase()}\n\n`;
for (const deployment of deployments) {
md += `## ${deployment.toUpperCase()}\n\n`

const chainId = Number(
fs.readFileSync(`./deployments/${deployment}/.chainId`)
);
const network = networks[chainId];
)
const network = networks[chainId]

md += `Network : __${network} (chain id: ${chainId})__\n\n`;
md += `Network : __${network} (chain id: ${chainId})__\n\n`

md += `|Contract|Address|\n`;
md += `|--|--|\n`;
md += `|Contract|Address|\n`
md += `|--|--|\n`

const contracts = dirtree(`./deployments/${deployment}`)
.children.filter((child) => {
return child.extension === ".json";
return child.extension === '.json'
})
.map((child) => {
return child.name.replace(".json", "");
});
return child.name.replace('.json', '')
})

proxiedContracts = [];
proxiedContracts = []
for (let i = 0; i < contracts.length; i++) {
if (contracts[i] == 'OVM_L1CrossDomainMessenger')
proxiedContracts.push(contracts.splice(i, 1)[0]);
if (contracts[i] == 'OVM_L1ETHGateway')
proxiedContracts.push(contracts.splice(i, 1)[0]);
if (contracts[i] == 'OVM_L1CrossDomainMessenger') {
proxiedContracts.push(contracts.splice(i, 1)[0])
}
if (contracts[i] == 'OVM_L1ETHGateway') {
proxiedContracts.push(contracts.splice(i, 1)[0])
}
}

for (const contract of contracts) {
const colonizedName = contract.split(':').join('-');
const colonizedName = contract.split(':').join('-')

const deploymentInfo = require(`../deployments/${deployment}/${contract}.json`);
const deploymentInfo = require(`../deployments/${deployment}/${contract}.json`)

const escPrefix = chainId !== 1 ? `${network}.` : "";
const etherscanUrl = `https://${escPrefix}etherscan.io/address/${deploymentInfo.address}`;
md += `|${colonizedName}|[${deploymentInfo.address}](${etherscanUrl})|\n`;
const escPrefix = chainId !== 1 ? `${network}.` : ''
const etherscanUrl = `https://${escPrefix}etherscan.io/address/${deploymentInfo.address}`
md += `|${colonizedName}|[${deploymentInfo.address}](${etherscanUrl})|\n`
}

md += `<!--\nImplementation addresses. DO NOT use these addresses directly.\nUse their proxied counterparts seen above.\n\n`;
md += `<!--\nImplementation addresses. DO NOT use these addresses directly.\nUse their proxied counterparts seen above.\n\n`

for (const proxy of proxiedContracts) {
const colonizedName = proxy.split(':').join('-');
const colonizedName = proxy.split(':').join('-')

const deploymentInfo = require(`../deployments/${deployment}/${proxy}.json`);
const deploymentInfo = require(`../deployments/${deployment}/${proxy}.json`)

const escPrefix = chainId !== 1 ? `${network}.` : "";
const etherscanUrl = `https://${escPrefix}etherscan.io/address/${deploymentInfo.address}`;
md += `${colonizedName}: \n - ${deploymentInfo.address}\n - ${etherscanUrl})\n`;
const escPrefix = chainId !== 1 ? `${network}.` : ''
const etherscanUrl = `https://${escPrefix}etherscan.io/address/${deploymentInfo.address}`
md += `${colonizedName}: \n - ${deploymentInfo.address}\n - ${etherscanUrl})\n`
}

md += `-->\n`;
md += `---\n`;
md += `-->\n`
md += `---\n`
}

fs.writeFileSync(`./deployments/README.md`, md);
})().catch(console.error);
fs.writeFileSync(`./deployments/README.md`, md)
})().catch(console.error)

0 comments on commit 0112650

Please sign in to comment.