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

v4.0.0 #321

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NEXT_PUBLIC_HOST_URL='http://localhost:3000'
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID=
NEXT_PUBLIC_GOOGLE_ANALYTICS_DOMAIN=
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:security/recommended-legacy',
'standard-with-typescript',
'next/core-web-vitals'
],
parserOptions: {
project: './tsconfig.json'
},
ignorePatterns: ['.eslintrc.js', 'next.config.js', 'next-env.d.ts', 'out'],
rules: {
'@typescript-eslint/key-spacing': 0,
'multiline-ternary': 0,
'no-console': ['error', { allow: ['info', 'warn', 'error'] }],
'max-len': [
2,
{
code: 100,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreUrls: true
}
]
}
}
11 changes: 0 additions & 11 deletions .gitbook.yaml

This file was deleted.

Binary file removed .gitbook/assets/diagram-safe-ecosystem.png
Binary file not shown.
Binary file removed .gitbook/assets/diagram-safe-tools.png
Binary file not shown.
Binary file removed .gitbook/assets/diagram-third-party-custody.png
Binary file not shown.
Binary file removed .gitbook/assets/eoas-vs-smart-accounts.png
Binary file not shown.
Binary file removed .gitbook/assets/safe-iceberg.png
Binary file not shown.
Binary file removed .gitbook/assets/table-compare-storage-solutions.png
Binary file not shown.
156 changes: 156 additions & 0 deletions .github/scripts/generateSupportedNetworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// This script generates the supported networks page from the safe-deployments repo.
// It clones the repo, reads the JSON files, and generates the markdown files as well as a _meta.json file for nextra.

const shell = require('shelljs')
const fs = require('fs')
const path = require('path')

// Explore a given directory recursively and return all the file paths
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
}

// Reduce function to deduplicate an array
const deduplicate = (acc, curr) => {
if (acc.includes(curr)) {
return acc
}

return [...acc, curr]
}

const supportedNetworksPath = './pages/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)
})

// Generate _meta.json file to order versions in descending order
fs.writeFileSync(
`${supportedNetworksPath}/_meta.json`,
JSON.stringify(
versions.reduce((acc, curr) => ({ ...acc, [curr]: curr }), {}),
null,
2
)
)

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

generateSupportedNetworks()

const deprecatedBlockExplorers = [
'https://blockexplorer.avax.boba.network',
'https://blockexplorer.bobabeam.boba.network',
'https://blockexplorer.rinkeby.boba.network',
'https://evm.explorer.canto.io',
'https://evm-testnet.venidiumexplorer.com',
'https://evm.venidiumexplorer.com',
'https://explorer.autobahn.network',
'https://explorer.eurus.network',
'https://explorer.tst.publicmint.io',
'https://goerli.arbiscan.io',
'https://kovan-optimistic.etherscan.io',
'https://rabbit.analogscan.com',
'https://rinkeby.etherscan.io',
'https://ropsten.etherscan.io',
'https://stardust-explorer.metis.io',
'https://testnet.arbiscan.io',
'https://testnet.torusscan.com',
'https://testnetexplorer.eurus.network'
]
17 changes: 17 additions & 0 deletions .github/scripts/prepar_production_deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -ev

# Only:
# - Tagged commits
# - Security env variables are available.
if [ -n "$VERSION_TAG" ] && [ -n "$PROD_DEPLOYMENT_HOOK_TOKEN" ] && [ -n "$PROD_DEPLOYMENT_HOOK_URL" ]
then
curl --silent --output /dev/null --write-out "%{http_code}" -X POST \
-F token="$PROD_DEPLOYMENT_HOOK_TOKEN" \
-F ref=master \
-F "variables[TRIGGER_RELEASE_COMMIT_TAG]=$VERSION_TAG" \
$PROD_DEPLOYMENT_HOOK_URL
else
echo "[ERROR] Production deployment could not be prepared"
fi
13 changes: 13 additions & 0 deletions .github/scripts/s3_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -ev

aws s3 sync ./out $BUCKET --delete

# Upload all HTML files again but w/o an extention so that URLs like /welcome open the right page

cd out

for file in $(find . -name '*.html' | sed 's|^\./||'); do
aws s3 cp ${file%} $BUCKET/${file%.*} --content-type 'text/html'
done
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extends: existence
message: "Always spell out the name of the month."
link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates
ignorecase: true
level: error
level: warning
nonword: true
tokens:
- '\b\d{1,2}/\d{1,2}/(?:\d{4}|\d{2})\b'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading