Skip to content

Commit 88c972b

Browse files
authored
PR #12 from classcool/tx-odering
tx ordering algorithm scaffold
2 parents 74cf49f + 81429f4 commit 88c972b

29 files changed

+2001
-2738
lines changed

.github/workflows/auto-assign.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy Forge Docs to Pages
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build-and-deploy-docs:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Install Foundry
29+
uses: foundry-rs/foundry-toolchain@v1
30+
31+
- name: Show Forge version
32+
run: |
33+
forge --version
34+
35+
- name: Run Forge build
36+
run: |
37+
forge build --sizes
38+
id: build
39+
40+
- name: Generate and patch docs
41+
run: |
42+
bash build-docs.sh
43+
44+
- name: Deploy to GitHub Pages
45+
env:
46+
BRANCH_NAME: ${{ github.ref_name }}
47+
uses: peaceiris/actions-gh-pages@v3
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
publish_dir: ./docs/_build/${{ env.BRANCH_NAME }}/book
51+
publish_branch: gh-pages

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ bun run dev
8787
8888
Go to [http://localhost:42069](http://localhost:42069) to query orders from hook events
8989
90+
## Docs
91+
92+
View documentation:
93+
94+
```sh
95+
forge doc --serve --port 4000 --watch
96+
97+
```
9098
## Acknowledgment
9199

92100
Thanks to [Atrium Academy](https://atrium.academy), over the past 2 months we build this project during Uniswap Hook incubator program.

build-docs.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "🔍 Starting docs build script..."
5+
6+
BOOK_TOML="docs/book.toml"
7+
BRANCH_NAME=${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}
8+
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '/' '-')
9+
REPO_NAME=${GITHUB_REPOSITORY#*/}
10+
if [[ -z "$REPO_NAME" ]]; then
11+
REPO_NAME=$(basename -s .git "$(git config --get remote.origin.url)")
12+
fi
13+
14+
SITE_URL_LINE="site-url = \"/${REPO_NAME}/${SAFE_BRANCH_NAME}/\""
15+
DOCS_OUT_DIR="docs/_build/${SAFE_BRANCH_NAME}"
16+
17+
echo "📄 Target TOML file: $BOOK_TOML"
18+
echo "🌿 Branch name: $BRANCH_NAME (safe: $SAFE_BRANCH_NAME)"
19+
echo "📦 Repo name: $REPO_NAME"
20+
echo "🔧 site-url line: $SITE_URL_LINE"
21+
echo "📂 Output docs directory: $DOCS_OUT_DIR"
22+
23+
# Step 1: Generate docs folder and book.toml if not exist
24+
if [[ ! -d docs ]] || [[ ! -f "$BOOK_TOML" ]]; then
25+
echo "🛠 Running 'forge doc' to generate docs folder and book.toml..."
26+
forge doc
27+
else
28+
echo "✅ docs folder and book.toml already exist."
29+
fi
30+
31+
# Step 2: Patch book.toml
32+
if grep -q "^\[output.html\]" "$BOOK_TOML"; then
33+
if grep -q "^site-url" "$BOOK_TOML"; then
34+
echo "🔁 Replacing existing site-url line..."
35+
sed -i.bak "s|^site-url = .*|$SITE_URL_LINE|" "$BOOK_TOML"
36+
else
37+
echo "➕ Inserting site-url line after [output.html]..."
38+
awk -v s="$SITE_URL_LINE" '
39+
/^\[output.html\]/ {
40+
print
41+
print s
42+
next
43+
}
44+
{ print }
45+
' "$BOOK_TOML" > "$BOOK_TOML.tmp" && mv "$BOOK_TOML.tmp" "$BOOK_TOML"
46+
fi
47+
else
48+
echo "➕ Adding [output.html] section and site-url..."
49+
echo "[output.html]" >> "$BOOK_TOML"
50+
echo "$SITE_URL_LINE" >> "$BOOK_TOML"
51+
fi
52+
53+
# Show patch preview
54+
echo "📋 Preview of patched book.toml:"
55+
head -n 20 "$BOOK_TOML"
56+
57+
# Step 3: Build docs into branch-specific folder
58+
echo "⚙️ Running 'forge doc --build --out $DOCS_OUT_DIR' ..."
59+
forge doc --build --out "$DOCS_OUT_DIR"
60+
61+
echo "✅ Docs successfully built at $DOCS_OUT_DIR"
62+
63+
# List output folder content
64+
echo "📂 Listing $DOCS_OUT_DIR contents:"
65+
ls -la "$DOCS_OUT_DIR"
66+
67+
echo "🔚 Script finished."

0 commit comments

Comments
 (0)