Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to generate Supported Networks pages from safe-deployments repo as a github action #278

Merged
merged 24 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
93fdc91
Add script to genereate Supported Networks pages from safe-deployment…
louis-md Nov 22, 2023
219a0ed
Update summary
louis-md Nov 22, 2023
d66528c
Update summary
louis-md Nov 22, 2023
fbdffc5
Fix typo in supported networks script & re-generate .md files
louis-md Nov 22, 2023
804c785
Implement requested changes
louis-md Nov 22, 2023
b65a642
Implement requested changes
louis-md Nov 22, 2023
3ea1402
Remove unused console.log; fix supported networks index page & block …
louis-md Nov 22, 2023
13de5e6
Fix some vale errors ("networks's" & "Testnet")
louis-md Nov 22, 2023
bf2025a
Re-generate supported networks
louis-md Nov 22, 2023
8efde45
Implement requested changes (wording & correct section)
louis-md Nov 22, 2023
842986f
Update SUMMARY.md
germartinez Nov 22, 2023
5b926a4
Update SUMMARY.md
germartinez Nov 22, 2023
46f0fdc
Update SUMMARY.md
germartinez Nov 22, 2023
b7611e3
Update SUMMARY.md
germartinez Nov 22, 2023
4952f3a
Update SUMMARY.md
germartinez Nov 22, 2023
d6794cc
Move supported networks .md folder into safe-smart-accounts
louis-md Nov 22, 2023
c064b8d
Implement requested changes (create PR on workflow, minor fixes)
louis-md Nov 23, 2023
8d91e92
Update vale dictionnary
louis-md Nov 23, 2023
db31036
Update vale dictionnary
louis-md Nov 23, 2023
da182cc
Remove duplicates in vale dictionnary
louis-md Nov 23, 2023
a677f99
Remove unnecessary steps in github workflow for supported networks
louis-md Nov 23, 2023
3165f46
Remove duplicates in vale dictionnary
louis-md Nov 23, 2023
ef46997
Alphabetize & deduplicate vale dictionnary
louis-md Nov 23, 2023
e642001
Exclude deprecated block explorer from supported networks page genera…
louis-md Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/scripts/generateSupportedNetworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const shell = require('shelljs')
const fs = require('fs')
const path = require('path')

const walkPath = dir => {
let results = []
const list = fs.readdirSync(dir)
list.forEach(function (file) {
const filePath = path.join(dir, file)
const stat = fs.statSync(filePath)
if (stat?.isDirectory()) {
results = results.concat(walkPath(filePath))
} else {
results.push(filePath)
}
})

return results
}

const deduplicate = () => [
(acc, curr) => {
if (acc.includes(curr)) {
return acc
}

return [...acc, curr]
},
[]
]

const supportedNetworksPath = './safe-smart-account/supported-networks'

const generateSupportedNetworks = async () => {
const deploymentRepoUrl = 'https://github.com/safe-global/safe-deployments/'
shell.exec(`git clone ${deploymentRepoUrl} ./deployments`)
shell.rm('-rf', supportedNetworksPath)

const fetch = await import('node-fetch')
const paths = walkPath('deployments/src/assets').map(p =>
p.replace('deployments/src/assets/', '')
)

const allNetworks = await fetch
.default('https://chainid.network/chains.json')
.then(res => res.json())

const contracts = paths.map(p => {
const file = fs.readFileSync(`deployments/src/assets/${p}`, 'utf8')
const json = JSON.parse(file)

return Object.entries(json.networkAddresses).map(([chainId, address]) => ({
name: p.split('/')[1].split('.')[0],
version: p.split('/')[0],
address,
chainId,
chainName: allNetworks.find(n => n.chainId === parseInt(chainId))?.name,
blockExplorerUrl: allNetworks.find(n => n.chainId === parseInt(chainId))
?.explorers?.[0]?.url
}))
})

const versions = contracts
.flat()
.map(c => c.version)
.reduce(...deduplicate())
.reverse()

shell.mkdir(supportedNetworksPath)

versions.forEach(version => {
const _contracts = contracts.flat().filter(c => c.version === version)

const networks = Object.entries(
_contracts.reduce((acc, curr) => {
const { chainId, chainName } = curr
if (acc[chainId]) {
return acc
}

return {
...acc,
[chainId]: chainName
}
}, {})
)

const content = `# ${version}

This page lists the addresses of all the Safe contracts \`${version}\` grouped by chain.

## Networks
${networks
.map(([chainId, network]) => {
return `
### ${network}

This network's chain ID is ${chainId}.

${_contracts
.filter(c => c.chainId === chainId)
.map(
c =>
`- \`${c.name}.sol\`: ${
c.blockExplorerUrl == null
? c.address
: `[${c.address}](${c.blockExplorerUrl}/address/${c.address})`
}`
)
.join('\n')}
`
})
.join('\n')}

`
fs.writeFileSync(`${supportedNetworksPath}/${version}.md`, content)
})

shell.rm('-rf', './deployments')
}

generateSupportedNetworks()
118 changes: 118 additions & 0 deletions .github/styles/Vocab/default/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,121 @@ DAO
composable
endhint
endembed
Rinkeby
Testnet
Ethereum
Ropsten
Rinkeby
Goerli
OP
Metadium
ThunderCore
Cronos
Boba Rinkeby
Rootstock
U2U Solaris
Telos
EVM
LUKSO
Crab
Darwinia
XDC
Apothem
BNB
Syscoin
Mordor
Kovan
Gnosis
Velas
ThunderCore
EtherLite Chain
Fuse
Sparknet
Polygon
ShimmerEVM
Tenet
Fantom
Boba
GC
KCC
zkSync Era
Shiden
Cronos
PGN
Rollux
Metis
Stardust
Astar
Acala Mandala TC9
Karura
Acala
Klaytn Baobab
Eurus
Metis Andromeda
zkEVM
WEMIX3.0
WEMIX3.0
tanay1337 marked this conversation as resolved.
Show resolved Hide resolved
Ultron
Ultron
Moonbeam
Moonriver
Moonbase Alpha
Bobabeam
Tenet
Lightlink
Eurus
Milkomeda
C1
A1
CloudWalk
PublicMint
Edgeware
EdgeEVM
Kava
Kava
Crossbell
Fantom
IoTeX
Venidium
Mantle
Syscoin
Tanenbaum
Cascadia
ZetaChain
Shyft
Canto
Klaytn
Evmos
Boba
Chiado
Haqq
Shyft
Supernet
Arianee
undefined
Holesky
Arbitrum
Nova
Celo
Fuji
C-Chain
Avax
Celo
Alfajores
Autobahn
REI
Haqq
Rollux
Linea
Godwoken
v1
Milkomeda
C1
A1
Polis
Rethereum
Zora
Sepolia
Kanazawa
Meld
Aurora
45 changes: 45 additions & 0 deletions .github/workflows/generate-supported-networks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Weekly update for supported networks

on:
schedule:
- cron: "0 9 * * 1"
workflow_dispatch:

jobs:
generate-supported-networks:
runs-on: ubuntu-latest
steps:
- name: Use Node.js 20.x
uses: actions/setup-node@v2
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: ./yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Generate supported networks
run: node ./.github/scripts/generateSupportedNetworks.js
- uses: actions/checkout@v4
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git commit -m "Update supported networks"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
node_modules
7 changes: 7 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

* [Audits](safe-smart-account/security-audits.md)

* [Supported Networks](safe-smart-account/supported-networks.md)
* [v.1.4.1](safe-smart-account/supported-networks/v1.4.1.md)
* [v.1.3.0](safe-smart-account/supported-networks/v1.3.0.md)
* [v.1.2.0](safe-smart-account/supported-networks/v1.2.0.md)
* [v.1.1.1](safe-smart-account/supported-networks/v1.1.1.md)
* [v.1.0.0](safe-smart-account/supported-networks/v1.0.0.md)

## Safe{Core} AA SDK

* [Overview](safe-core-sdk/README.md)
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"node-fetch": "^3.3.2",
"shelljs": "^0.8.5"
}
}
3 changes: 3 additions & 0 deletions safe-smart-account/supported-networks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This section lists the addresses of all the Safe contracts deployed grouped by version and chain. The same list can be found on the [GitHub repository](https://github.com/safe-global/safe-deployments), from which these pages are automatically generated.

The most recent version of the Safe contracts is `v1.4.1`, which adds compatibility with the ERC-4337. However, it's not supported yet in the [Safe{Wallet}](app.safe.global) interface and the Safe Transaction Service. For that reason, depending on your use case, it might be recommended to continue using `v1.3.0` until there is better support.
47 changes: 47 additions & 0 deletions safe-smart-account/supported-networks/v1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# v1.0.0

This page lists the addresses of all the Safe contracts `v1.0.0` grouped by chain.

## Networks

### Ethereum Mainnet

This network's chain ID is 1.

- `gnosis_safe.sol`: [0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A](https://etherscan.io/address/0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A)
- `proxy_factory.sol`: [0x12302fE9c02ff50939BaAaaf415fc226C078613C](https://etherscan.io/address/0x12302fE9c02ff50939BaAaaf415fc226C078613C)


### Rinkeby

This network's chain ID is 4.

- `gnosis_safe.sol`: [0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A](https://rinkeby.etherscan.io/address/0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A)
- `proxy_factory.sol`: [0x12302fE9c02ff50939BaAaaf415fc226C078613C](https://rinkeby.etherscan.io/address/0x12302fE9c02ff50939BaAaaf415fc226C078613C)


### Goerli

This network's chain ID is 5.

- `gnosis_safe.sol`: [0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A](https://goerli.etherscan.io/address/0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A)
- `proxy_factory.sol`: [0x12302fE9c02ff50939BaAaaf415fc226C078613C](https://goerli.etherscan.io/address/0x12302fE9c02ff50939BaAaaf415fc226C078613C)


### LUKSO Mainnet

This network's chain ID is 42.

- `gnosis_safe.sol`: [0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A](https://explorer.execution.mainnet.lukso.network/address/0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A)
- `proxy_factory.sol`: [0x12302fE9c02ff50939BaAaaf415fc226C078613C](https://explorer.execution.mainnet.lukso.network/address/0x12302fE9c02ff50939BaAaaf415fc226C078613C)


### Gnosis

This network's chain ID is 100.

- `gnosis_safe.sol`: [0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A](https://gnosisscan.io/address/0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A)
- `proxy_factory.sol`: [0x12302fE9c02ff50939BaAaaf415fc226C078613C](https://gnosisscan.io/address/0x12302fE9c02ff50939BaAaaf415fc226C078613C)



Loading
Loading