Skip to content

Commit 442e716

Browse files
authored
feat(docs): RPC methods reference (#6630)
1 parent 3719b78 commit 442e716

File tree

21 files changed

+20303
-890
lines changed

21 files changed

+20303
-890
lines changed

.github/workflows/docs-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
- uses: jdx/mise-action@v3
3535
- run: mise run docs:format-spellcheck-dictionary-check
3636
- run: mise run docs:lint
37-
- run: pnpm build
37+
- run: mise run docs:build

.github/workflows/docs-deploy.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ jobs:
3131
working-directory: ./docs
3232
steps:
3333
- uses: actions/checkout@v6
34-
- uses: actions/setup-node@v6
35-
with:
36-
node-version: 20
37-
package-manager-cache: false
38-
- run: corepack enable
39-
- run: pnpm i --frozen-lockfile
40-
- run: pnpm build
34+
- uses: jdx/mise-action@v3
35+
- run: mise run docs:build
4136

4237
- name: Deploy
4338
uses: cloudflare/wrangler-action@v3
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow, run daily, updates the Forest RPC reference docs, and submits a PR with the changes.
2+
name: Update Forest RPC reference docs
3+
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: "0 0 * * *"
8+
9+
jobs:
10+
update-docs:
11+
runs-on: ubuntu-slim
12+
steps:
13+
- uses: actions/checkout@v6
14+
- name: Generate OpenRPC specifications
15+
run: |
16+
cd docs/scripts
17+
./generate-openrpc-specs.sh docker
18+
# This is needed in order to have the commits signed.
19+
- uses: actions/create-github-app-token@v2
20+
id: generate-token
21+
with:
22+
app-id: ${{ secrets.LESHY_APP_ID }}
23+
private-key: ${{ secrets.LESHY_APP_PRIVATE_KEY }}
24+
- name: Create Pull Request
25+
uses: peter-evans/create-pull-request@v8
26+
with:
27+
base: main
28+
branch: leshy/update-forest-rpc-docs
29+
token: ${{ steps.generate-token.outputs.token }}
30+
commit-message: Update Forest RPC reference docs
31+
sign-commits: true
32+
title: "[automated] Update Forest RPC reference docs"
33+
add-paths: |
34+
docs/openrpc-specs/
35+
body: |
36+
### Changes
37+
- Updates Forest RPC reference docs to the latest commit in the `main` branch.
38+
- Regenerates OpenRPC specifications (v0, v1, v2) from latest Forest code.

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# Docusaurus Build Directory
99
/build/
1010

11+
# Generated RPC reference data
12+
/src/data/rpc-methods.json
13+
1114
### Docusaurus.Node Stack ###
1215
# Logs
1316
logs

docs/.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# OpenRPC specification files (auto-generated from Forest)
2+
openrpc-specs/
3+
4+
# Lock files
5+
pnpm-lock.yaml
6+
package-lock.json
7+
yarn.lock
8+
9+
# Build output
10+
build/
11+
.docusaurus/
12+
13+
# Generated data
14+
src/data/rpc-methods.json

docs/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ Follows the [Diátaxis](https://diataxis.fr/) framework for structuring document
6060

6161
These docs are automatically generated from the Forest CLI. See [script](/docs/docs/users/reference/cli.sh).
6262

63-
#### JSON-RPC Docs
64-
65-
We use the OpenRPC document from Forest to populate the documentation for each method. For this we use `@metamask/docusaurus-openrpc`.
66-
6763
### Developer Docs
6864

6965
Available at `/developers`, source code is located in `docs/developers`. Comprised of a collection of documents aimed at contributors. May be relevant to power users.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "JSON-RPC",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Forest JSON-RPC API documentation including schema explorer and method reference."
7+
}
8+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Methods Reference
3+
sidebar_position: 2
4+
---
5+
6+
import RPCReference from "@site/src/components/RPCReference";
7+
8+
# JSON-RPC Methods Reference
9+
10+
This page provides a comprehensive reference for all RPC methods supported by Forest across multiple API versions. You can search, filter by namespace, switch between API versions, and expand individual methods to see detailed parameter and return type information.
11+
12+
:::info
13+
14+
This reference is automatically generated from the OpenRPC specifications in the repository. For the interactive schema explorer, see the [Schema Explorer](./schema.mdx) page.
15+
16+
:::
17+
18+
## API Versions
19+
20+
Forest supports multiple RPC API versions:
21+
22+
- **V0** - Deprecated API
23+
- **V1** - Stable API - Recommended for production use
24+
- **V2** - Experimental API
25+
26+
Use the version selector to switch between versions and see the methods available in each.
27+
28+
---
29+
30+
<RPCReference />

docs/docs/users/reference/json_rpc_overview.md renamed to docs/docs/users/reference/json-rpc/overview.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
---
2-
title: JSON-RPC Overview
3-
sidebar_position: 3
2+
title: Overview
3+
sidebar_position: 0
44
---
55

66
# JSON-RPC Overview
77

8-
:::warning
9-
10-
This API is still a WIP, with more methods being added continuously.
11-
12-
:::
13-
148
:::note
159

1610
Need a specific method? Let us know on
@@ -39,7 +33,7 @@ An FIP to establish a canonical RPC API specification for general use [has been
3933

4034
## Connecting To A Node
4135

42-
By default, Forest exposes the RPC API on `localhost:2345`. See [CLI docs](./cli.md) for configuration options.
36+
By default, Forest exposes the RPC API on `localhost:2345`. See [CLI docs](../cli.md) for configuration options.
4337

4438
### Authentication
4539

@@ -49,7 +43,6 @@ Access control is implemented for certain methods. Levels of access include:
4943
- Write
5044
- Admin
5145

52-
Authentication is performed via [JWT Tokens](../knowledge_base/jwt_handling.md). When starting Forest use `--save-token
53-
<FILE>` to store an `Admin` token,
46+
Authentication is performed via [JWT Tokens](../../knowledge_base/jwt_handling.md). When starting Forest use `--save-token <FILE>` to store an `Admin` token,
5447
otherwise the token will be printed in the logs during startup. With this token you can call the methods `AuthNew`
5548
to generate additional tokens as needed.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Schema Explorer
3+
sidebar_position: 1
4+
---
5+
6+
export const style = {
7+
fontSize: "1.3em",
8+
textDecoration: "underline",
9+
};
10+
11+
export const versionStyle = {
12+
display: "flex",
13+
flexDirection: "column",
14+
gap: "1rem",
15+
marginBottom: "2rem",
16+
};
17+
18+
export const versionCard = {
19+
padding: "1rem",
20+
border: "1px solid var(--ifm-color-emphasis-300)",
21+
borderRadius: "8px",
22+
backgroundColor: "var(--ifm-background-surface-color)",
23+
};
24+
25+
# JSON-RPC Schema Explorer
26+
27+
Forest implements multiple API versions, each with its own OpenRPC specification. Use the interactive schema explorer to browse available methods, parameters, and return types for each version.
28+
29+
## API Versions
30+
31+
<div style={versionStyle}>
32+
<div style={versionCard}>
33+
<h3>RPC v0 API</h3>
34+
<p>Deprecated API</p>
35+
<a
36+
href="https://playground.open-rpc.org/?uiSchema[appBar][ui:darkMode]=true&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:input]=false&uiSchema[appBar][ui:title]=Forest%20RPC%20v0&schemaUrl=https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v0.json"
37+
target="_blank"
38+
rel="noopener noreferrer"
39+
style={style}
40+
>
41+
👉 View v0 Spec in Schema Explorer
42+
</a>
43+
<br />
44+
<a
45+
href="https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v0.json"
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
>
49+
📄 Raw v0 Spec (JSON)
50+
</a>
51+
</div>
52+
53+
<div style={versionCard}>
54+
<h3>RPC v1 API</h3>
55+
<p>Stable API - Recommended for production use</p>
56+
<a
57+
href="https://playground.open-rpc.org/?uiSchema[appBar][ui:darkMode]=true&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:input]=false&uiSchema[appBar][ui:title]=Forest%20RPC%20v1&schemaUrl=https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v1.json"
58+
target="_blank"
59+
rel="noopener noreferrer"
60+
style={style}
61+
>
62+
👉 View v1 Spec in Schema Explorer
63+
</a>
64+
<br />
65+
<a
66+
href="https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v1.json"
67+
target="_blank"
68+
rel="noopener noreferrer"
69+
>
70+
📄 Raw v1 Spec (JSON)
71+
</a>
72+
</div>
73+
74+
<div style={versionCard}>
75+
<h3>RPC v2 API</h3>
76+
<p>Experimental API</p>
77+
<a
78+
href="https://playground.open-rpc.org/?uiSchema[appBar][ui:darkMode]=true&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:input]=false&uiSchema[appBar][ui:title]=Forest%20RPC%20v2&schemaUrl=https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v2.json"
79+
target="_blank"
80+
rel="noopener noreferrer"
81+
style={style}
82+
>
83+
👉 View v2 Spec in Schema Explorer
84+
</a>
85+
<br />
86+
<a
87+
href="https://raw.githubusercontent.com/ChainSafe/forest/main/docs/openrpc-specs/v2.json"
88+
target="_blank"
89+
rel="noopener noreferrer"
90+
>
91+
📄 Raw v2 Spec (JSON)
92+
</a>
93+
</div>
94+
</div>
95+
96+
:::tip
97+
For a searchable, filterable reference of all RPC methods, see the [Methods Reference](./methods.mdx) page.
98+
:::
99+
100+
#### References
101+
102+
- [OpenRPC Specification](https://spec.open-rpc.org/)
103+
- [JSON Schema](https://json-schema.org/)

0 commit comments

Comments
 (0)