Skip to content
Draft
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
# Two trailing spaces are a hard line break in Markdown
trim_trailing_whitespace = false
26 changes: 26 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check manifests

on:
pull_request:
push:
branches-ignore: ["main"] # main is covered by the deploy workflow's gate
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check JSON examples against the manifest schema
run: python3 scripts/check_manifests.py

- name: Build the book
env:
MDBOOK_VERSION: "0.4.52"
run: |
mkdir -p "$HOME/.local/bin"
curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
| tar -xz -C "$HOME/.local/bin"
"$HOME/.local/bin/mdbook" build
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# A book whose examples no longer match the format should not publish.
- name: Check JSON examples against the manifest schema
run: python3 scripts/check_manifests.py

- name: Install mdBook
run: |
mkdir -p "$HOME/.local/bin"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
book
.claude
meta
__pycache__/
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@ protocol.
> appendix are complete; several later recipes (05–10) and the lending walkthrough
> are still stubs being filled in.

**Format version: 0.2.0.** Every example is written against manifest format
`0.2.0`, and `manifest_version` is enforced at parse time — a `0.1.x` file is a
hard error in a current wallet, not a warning.

## Checking the examples

Every ```` ```json ```` block in `src/` is validated against
[`schema/txmanifest.schema.json`](schema/), copied verbatim from the reference
wallet (see [`schema/README.md`](schema/README.md) for the exact ref):

```sh
python3 scripts/check_manifests.py # check the book
python3 scripts/check_manifests.py --self-test path/to/wallet/examples
```

The checker needs no third-party packages. `--self-test` validates the checker
itself against the wallet's own example manifests, and against deliberately
corrupted copies of them, so a validator that accepted everything would fail.
CI runs the check on every push and blocks the deploy if it fails.

A block is anchored to what it is meant to be with an HTML comment above the
fence — `<!-- schema: Action -->`, `<!-- schema: manifest -->` for a slice of a
document, `<!-- schema: map:ParamDef -->` for a named map, or
`<!-- schema: none -->` for JSON that is not part of a manifest (a state file, a
params file). The book's `...` and `…` elisions are understood.

## Building the book

You need [mdBook](https://rust-lang.github.io/mdBook/guide/installation.html):
Expand Down
14 changes: 14 additions & 0 deletions schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Vendored schema

`txmanifest.schema.json` is copied verbatim from the reference wallet:

repo: git@github.com:stringhandler/txmanifest-wallet.git
path: schema/txmanifest.schema.json
ref: main @ 5624dfc77f742d66798d469de1bb79c8f09fcf0b
format: manifest_version 0.2.0

It is generated in that repo by `txmanifest_lib/examples/gen_schema.rs`, so it is
the machine-readable source of truth for what a manifest may contain. The book's
JSON examples are checked against it by `scripts/check_manifests.py`.

To refresh it, re-copy the file and update the ref above.
1,171 changes: 1,171 additions & 0 deletions schema/txmanifest.schema.json

Large diffs are not rendered by default.

Loading
Loading