Skip to content

feat: Add smart accounts reference generation script and docs pages #716

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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4cd7b96
Create script to generate contracts references automatically for smar…
louis-md Mar 7, 2025
8cac8b0
Add callouts & _meta.json for new reference docs
louis-md Mar 7, 2025
4d1484e
Clean up script
louis-md Mar 7, 2025
296ab94
Edit _meta.json files
louis-md Mar 7, 2025
d02781a
Switch from ts-node to tsx
louis-md Mar 10, 2025
c38340c
Separate smart account & modules generation
louis-md Mar 10, 2025
e06ae0a
Fix typo
louis-md Mar 10, 2025
88171bd
Merge branch 'main' of https://github.com/safe-global/safe-docs into …
louis-md Mar 10, 2025
439b476
Move deployment sections from reference to the advanced section
louis-md Mar 10, 2025
21fb2ea
Further refactor
louis-md Mar 10, 2025
0de082d
Fix typo
louis-md Mar 10, 2025
a9272c1
Move script solidity functions to `lib` folder
louis-md Mar 10, 2025
005b634
Move script solidity functions to `lib` folder
louis-md Mar 10, 2025
ebbf382
Fix modules logic
louis-md Mar 11, 2025
30630f9
Create modules references script
louis-md Mar 11, 2025
b20a87b
Add module reference routes
louis-md Mar 11, 2025
23d8597
Genereate modules references
louis-md Mar 11, 2025
fb7bc84
Fix build; remove legacy warning for modules
louis-md Mar 11, 2025
a3f77c1
Minor fixes
louis-md Mar 12, 2025
58a3ca6
Minor fixes
louis-md Mar 13, 2025
9973ed1
Disambiguate between sync and async script functions
louis-md Mar 13, 2025
64dabc0
Re-generate smart account and modules docs
louis-md Mar 13, 2025
bb86cdf
Merge branch 'main' into modules-reference
louis-md Mar 13, 2025
4e942c7
Fix preview deploy
louis-md Mar 13, 2025
b4aec7f
Merge branch 'modules-reference' of https://github.com/safe-global/sa…
louis-md Mar 13, 2025
e883c6d
Minor fix
louis-md Mar 13, 2025
04392b7
Minor fix
louis-md Mar 13, 2025
98aa2ae
Minor fix
louis-md Mar 13, 2025
69e48f1
Merge branch 'main' of https://github.com/safe-global/safe-docs into …
louis-md Mar 14, 2025
4ae961d
Fix vale errors
louis-md Mar 14, 2025
57500d6
Fix vale errors
louis-md Mar 14, 2025
3fe3708
Fix vale errors
louis-md Mar 14, 2025
76a8fa8
Test deploying all files to S3 in one go
louis-md Apr 2, 2025
2976fe1
Use different content types depending on the type of files served
louis-md Apr 2, 2025
55a568b
Add build cache
louis-md Apr 2, 2025
b55fdb0
Use nextjs trailing slash instead of duplicate uploads
louis-md Apr 2, 2025
ed80178
Add zengo.com to the linkchecker whitelist
louis-md Apr 2, 2025
328c5de
Add `sharp`
louis-md Apr 2, 2025
84b116c
Merge branch 'deduped-deployments' of https://github.com/safe-global/…
louis-md Apr 2, 2025
7473079
Fix missing parameter in `createProxyWithCallback`
louis-md Apr 2, 2025
1a850c7
Fix typo
louis-md Apr 2, 2025
b926c64
Merge branch 'main' of https://github.com/safe-global/safe-docs into …
louis-md Apr 7, 2025
ffb07b3
Restore deleted files after merge
louis-md Apr 9, 2025
6f8ec36
Implement requested changes
louis-md Apr 9, 2025
a6e3340
Re-generate references
louis-md Apr 9, 2025
6ae2a18
Implement requested changes
louis-md Apr 10, 2025
03e7c08
Re-generate references
louis-md Apr 10, 2025
7008d6a
Fix vale error
louis-md Apr 10, 2025
0fd906f
Allow to override natspec comments
louis-md Apr 10, 2025
bd51950
Fix vale errors
louis-md Apr 10, 2025
7334491
Edit natspec overrides
louis-md Apr 10, 2025
87c27f6
Import natspec overrides from current v1.4.1 reference docs
louis-md Apr 11, 2025
3ca62f1
Fix vale error
louis-md Apr 11, 2025
5051545
Re-generate references
louis-md Apr 11, 2025
2f93197
Fix build
louis-md Apr 11, 2025
7179e21
Fix vale errors
louis-md Apr 11, 2025
120510f
Fix vale errors
louis-md Apr 14, 2025
66c8ac8
Fix vale errors
louis-md Apr 14, 2025
17b2022
Fix vale errors
louis-md Apr 14, 2025
673171b
Remove generated modules reference
louis-md Apr 14, 2025
dad9cff
Fix solidity examples
louis-md Apr 14, 2025
031c2c0
Implement requested changes
louis-md Apr 14, 2025
8b8ca3d
Re-generate references
louis-md Apr 14, 2025
90e2873
Fix function definitions
louis-md Apr 14, 2025
32c528b
Implement requested changes
louis-md Apr 14, 2025
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
93 changes: 93 additions & 0 deletions .github/scripts/generateModulesReference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import shell from 'shelljs'

import { modulesVersions } from '../../lib/solidity/constants.ts'
import {
generateMarkdownFromNatspec,
setupSolarity
} from '../../lib/solidity/solarity.ts'
import {
generateOverviewPageModule,
runSolidityGenerationScript
} from '../../lib/solidity/templates.ts'
import {
generateMetaJson,
generateMetaJsonVersionsModule
} from '../../lib/solidity/metaJsons.ts'

const repoUrl = 'https://github.com/safe-global/safe-modules/'
const repoDestination = '.temp/safe-modules'
const mdDestination = 'pages/reference-modules'
const versions = Object.entries(modulesVersions).reduce(
(acc, [moduleName, versions]) => {
versions.forEach(version => {
acc.push(moduleName + '/' + version)
})
return acc
},
[] as string[]
)

// Clones the safe-modules GitHub repository and generates documentation for each public function and event
const generateModulesReference = (
version: string,
callback: () => void,
repoDestination: string,
mdDestination: string
) => {
// Prepare files
const moduleName = version.split('/')[0]
const _version = version.split('/')[1]
const _repoDestination = `${repoDestination}/modules/${moduleName === 'allowance' ? 'allowances' : moduleName}`
const _mdDestination = `${mdDestination}/${moduleName}/${_version}`
const _repoUrl = `${repoUrl}tree/${version}/`
shell.exec(
`cd ${repoDestination} && git checkout tags/${version} && npx pnpm@9 i`,
{ async: true },
async () => {
// Prepare repo & generate .md doc files using @solarity:
setupSolarity({
repoDestination: _repoDestination,
moduleName,
callback: () => {
shell.exec(
`cd ${_repoDestination} && npx pnpm@9 exec hardhat markup && mkdir -p ${_mdDestination}`,
{ async: true },
() => {
// Generate final .mdx files
generateMarkdownFromNatspec({
repoDestination: _repoDestination,
mdDestination: _mdDestination,
repoUrl,
version,
callback: () => {
generateOverviewPageModule(version, _mdDestination, _repoUrl)
generateMetaJsonVersionsModule(moduleName, _mdDestination)
generateMetaJson(
`${mdDestination}/${moduleName}`,
[_version],
() => {
// Remove all changes to the git index so we can git checkout different branches again
shell.exec(
`rm -rf ${_repoDestination}/build && rm -rf ${_repoDestination}/node_modules && rm -rf ${_repoDestination}/generated-markups && cd ${repoDestination} && rm -f pnpm-lock.yaml && git stash && git stash drop`,
{ async: true },
callback
)
}
)
}
})
}
)
}
})
}
)
}

void runSolidityGenerationScript(
mdDestination,
repoDestination,
repoUrl,
versions,
generateModulesReference
)
71 changes: 71 additions & 0 deletions .github/scripts/generateSmartAccountReference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import shell from 'shelljs'

import { smartAccountVersions } from '../../lib/solidity/constants.ts'
import {
setupSolarity,
generateMarkdownFromNatspec
} from '../../lib/solidity/solarity.ts'
import {
generateOverviewPage,
runSolidityGenerationScript
} from '../../lib/solidity/templates.ts'
import { generateMetaJsonVersions } from '../../lib/solidity/metaJsons.ts'

const repoUrl = 'https://github.com/safe-global/safe-smart-account/'
const repoDestination = '.temp/contracts'
const mdDestination = 'pages/reference-smart-account'

const generateSmartAccountReference = (
version: string,
callback: () => void,
repoDestination: string,
mdDestination: string
) => {
shell.exec(
`cd ${repoDestination} && git checkout tags/${version}`,
{ async: true },
() => {
// Prepare repo & generate .md doc files using @solarity:
setupSolarity({
repoDestination,
callback: () => {
shell.exec(
`cd ${repoDestination} && npx hardhat markup && mkdir -p ${mdDestination}`,
{
async: true
},
() => {
// Generate final .mdx files
generateMarkdownFromNatspec({
repoDestination,
mdDestination: `${mdDestination}/${version}`,
repoUrl,
version,
callback: () => {
generateOverviewPage(version, `${mdDestination}/${version}`)
generateMetaJsonVersions(
version,
`${mdDestination}/${version}`
)
shell.exec(
`rm -rf ${repoDestination}/build && rm -rf ${repoDestination}/node_modules && rm -rf ${repoDestination}/generated-markups && cd ${repoDestination} && git stash && git stash drop`,
{ async: true },
callback
)
}
})
}
)
}
})
}
)
}

void runSolidityGenerationScript(
mdDestination,
repoDestination,
repoUrl,
smartAccountVersions,
generateSmartAccountReference
)
32 changes: 27 additions & 5 deletions .github/styles/config/vocabularies/default/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
(?i)zkevm
(?i)zksync
(?i)wagmi
[Aa][Pp][Ii]
ABI|abi
API|api
DelegateCall|delegatecall
DelegateCalls|delegatecalls
LLM|llm
[Aa]urora
[Aa]rbitrum
[Aa]ccessor
Expand All @@ -19,6 +23,7 @@
[Bb]oolean
[Bb]undler
[Bb]undlers
[Cc]alldata
[Cc]hainlist
[Cc]elo
[Cc]omposable
Expand All @@ -44,9 +49,7 @@
[Ll]inea
[Ll]inea
[Ll]ogics
[Ll][Ll][Mm]
[Mm]ainnet
[Mm]astercopy
[Mm]iddleware
[Mm]onerium
[Mm]ultichain
Expand All @@ -67,6 +70,7 @@
[Qq]uickstarts
[Rr]eact
[Rr]eauthenticate
[Rr]eentrancy
[Rr]elayer
[Rr]elayers
[Ss]epolia
Expand All @@ -79,9 +83,9 @@
[Xx]code
A1
AA
ABI
ABIs
API Kit
APIs
Acala
Alfajores
Andromeda
Expand Down Expand Up @@ -141,6 +145,7 @@ Etherscan
Eurus
Evmos
Fantom
Fas
Fireblocks
Foesenek
Fraxtal
Expand Down Expand Up @@ -171,9 +176,12 @@ keystore
LUKSO
Lightlink
Lisk
LLMs
Mandala
Mantle
Masa
MasterCopy
MasterCopies
Meld
Metadium
Metamask
Expand Down Expand Up @@ -226,6 +234,7 @@ Safe Transaction Service
Safenet
Safe{Core} Account Abstraction SDK
Safe{DAO}
SDKs
Sei
SEPA
Shibarium
Expand Down Expand Up @@ -277,18 +286,26 @@ Zilliqa
Zircuit
Zoltu
Zora
_data
_dataHash
_execute
authorizer
approvalCount
address_full_match
auditable
automations
auth_code
bool
bytestrings
calldata
checksummed
createTransaction
const
deployer
e.g.
eth_getLogs
eSpace
execTransaction
initializer
ledgerblue
ledgereth
maxWidth
Expand All @@ -308,10 +325,13 @@ preimage
refetch
refetches
refetching
returndata
rollups
saltNonce
sigAuthorizer
stablecoin
superset
targetContract
textWrap
timelock
timelocks
Expand All @@ -322,6 +342,8 @@ undefined
undeployed
unencrypted
v1
validUntil
validAfter
viem
zkLink
zKyoto
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
NEXT_PUBLIC_HOST_URL: 'https://docs.safe.global'
NODE_OPTIONS: '--max-old-space-size=8000'


- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion components/ApiReference/ApiReference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack'
import ExpandLess from '@mui/icons-material/ExpandLess'

import TOC, { type Heading } from './TOC'
import { MDXComponents, useCurrentTocIndex } from '../../lib/mdx'
import { MDXComponents, useCurrentTocIndex } from '../Mdx'
import { NetworkProvider } from './Network'
import css from './styles.module.css'

Expand Down
2 changes: 1 addition & 1 deletion components/ApiReference/Parameter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Property from './Property'
import { MdxHeading } from '../../lib/mdx'
import { MdxHeading } from '../Mdx'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const Parameters: React.FC<{ parameters: any[] }> = ({ parameters }) => {
Expand Down
2 changes: 1 addition & 1 deletion components/ApiReference/Response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ExpandMore from '@mui/icons-material/ExpandMore'

import Property from './Property'
import Hr from '../Hr'
import { MdxHeading } from '../../lib/mdx'
import { MdxHeading } from '../Mdx'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const Response: React.FC<{ response: any; index: number }> = ({
Expand Down
2 changes: 1 addition & 1 deletion components/ApiReference/SampleRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Button from '@mui/material/Button'
import Grid from '@mui/material/Grid'
import { useContext } from 'react'
import { NetworkContext } from './Network'
import { MdxHeading } from '../../lib/mdx'
import { MdxHeading } from '../Mdx'

const SampleRequestHeader: React.FC<{
method: string
Expand Down
2 changes: 1 addition & 1 deletion components/ApiReference/TOC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Grid from '@mui/material/Grid'
import Link from '@mui/material/Link'
import { useState } from 'react'

import { useCurrentTocIndex } from '../../lib/mdx'
import { useCurrentTocIndex } from '../Mdx'
import { theme } from '../../styles/theme'
import Method from './Method'

Expand Down
Loading