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 all 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
139 changes: 139 additions & 0 deletions .github/scripts/generateSupportedNetworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
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 || deprecatedBlockExplorers.includes(c.blockExplorerUrl)
? c.address
: `[${c.address}](${c.blockExplorerUrl}/address/${c.address})`
}`
)
.join('\n')}
`
})
.join('\n')}

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

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

generateSupportedNetworks()

const deprecatedBlockExplorers = [
'https://ropsten.etherscan.io',
'https://rinkeby.etherscan.io',
'https://kovan-optimistic.etherscan.io',
'https://stardust-explorer.metis.io',
'https://blockexplorer.rinkeby.boba.network',
'https://blockexplorer.bobabeam.boba.network',
'https://rabbit.analogscan.com',
'https://explorer.eurus.network',
'https://testnetexplorer.eurus.network',
'https://explorer.tst.publicmint.io',
'https://evm-testnet.venidiumexplorer.com',
'https://evm.venidiumexplorer.com',
'https://evm.explorer.canto.io',
'https://explorer.autobahn.network'
]
216 changes: 156 additions & 60 deletions .github/styles/Vocab/default/accept.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,169 @@
Safe{Core} Protocol
Safe{Core} Account Abstraction SDK
Safe Smart Account
Safe Module
Safe Modules
Safe Guards
Safe Transaction Service
Safe Apps SDK
Safe App
Safe Apps
Blockchain
blockchain
blockchains
onchain
offchain
Offchain
multisig
dapp
dapps
Auth Kit
Protocol Kit
Relay Kit
Onramp Kit
API Kit
UI Kit
IPFS
Onramp
Safe Transaction Service
Transaction Service
Safe Config Service
Config Service
Safe Client Gateway
Client Gateway
Config
config
backend
Safe{DAO}
A1
AA
API
ABI
ABIs
SDK
sdk
npm
API
API Kit
Acala
Alfajores
Andromeda
Apothem
Arbitrum
Arianee
Astar
Aurora
Auth Kit
Autobahn
Avax
BNB
Blockchain
Blocknative
Blockscout
Boba
Bobabeam
C-Chain
C1
CORS
CRA
HTTP
HTTPS
Blocknative
ETH
Canto
Cascadia
Celo
Chiado
Client Gateway
CloudWalk
Config
Crab
Cronos
Crossbell
DAO
Darwinia
EIP
ERC
Gunicorn
WSGI
Sourcify
Etherscan
Blockscout
delist
wagmi
crypto
cryptocurrencies
ETH
EVM
EdgeEVM
Edgeware
EtherLite
Ethereum
blockchain
Etherscan
Eurus
Evmos
Fantom
Fuji
Fuse
GC
Gelato
Gnosis
Godwoken
Goerli
Gunicorn
HTTP
HTTPS
Haqq
Holesky
IPFS
IoTeX
KCC
Kanazawa
Karura
Kava
Klaytn
Kovan
LUKSO
Lightlink
Linea
MainNet
Mainnet
Mandala
Mantle
Meld
Metadium
Metamask
Metis
Milkomeda
Monerium
Gelato
Moonbase
Moonbeam
Moonriver
Mordor
Nova
OP
Offchain
Onramp
Onramp Kit
PGN
Polis
Polygon
Protocol Kit
PublicMint
REI
RPC
Mainnet
Goerli
DAO
Relay Kit
Rethereum
Rinkeby
Rollux
Rootstock
Ropsten
SDK
Safe App
Safe Apps
Safe Apps SDK
Safe Client Gateway
Safe Config Service
Safe Guards
Safe Module
Safe Modules
Safe Smart Account
Safe Transaction Service
Safe{Core} Account Abstraction SDK
Safe{Core} Protocol
Safe{DAO}
Sepolia
Shiden
ShimmerEVM
Shyft
Solaris
Sourcify
Sparknet
Stardust
Supernet
Syscoin
TC9
Tanenbaum
Telos
Tenet
Testnet
ThunderCore
Transaction Service
U2U
UI Kit
Ultron
Velas
Venidium
WEMIX3.0
WSGI
XDC
ZetaChain
Zora
backend
blockchain
blockchains
composable
endhint
config
crypto
cryptocurrencies
dapp
dapps
delist
endembed
endhint
multisig
npm
offchain
onchain
sdk
undefined
v1
wagmi
zkEVM
zkSync
Loading
Loading