feat(cli): add chain scaffold kit for supported-chain contributions#162
feat(cli): add chain scaffold kit for supported-chain contributions#162okwn wants to merge 2 commits intoopen-wallet-standard:mainfrom
Conversation
|
@okwn is attempting to deploy a commit to the MoonPay Team on Vercel. A member of the Team first needs to authorize it. |
njdawn
left a comment
There was a problem hiding this comment.
I found three issues that should be fixed before merging:
-
--output+--forcecan recursively delete any existing directory inside the repo, including the repo root.
ScaffoldChainaccepts any repository-relative output path, andwrite_plan()unconditionally callsremove_dir_all()/remove_file()on that target when--forceis passed. In an isolated worktree,cargo run -p ows-cli -- dev scaffold-chain --slug root-test --family evm --output . --forcedry-ran successfully and reported that the repository root would be replaced, so a real--writewould attempt to wipe the checkout. -
The repository-boundary check is bypassable via symlinks.
resolve_output_dir()only normalizes path components lexically; it does not resolve symlink components. I reproduced this by creating.ows-dev/outside-link -> /tmp/ows-pr162-escape-targetand running--output .ows-dev/outside-link/escape-test. The scaffold wrote all generated files outside the repository into/tmp/ows-pr162-escape-target/escape-test. With--force, the same path can also delete external content. -
User-provided text is injected into TOML and Rust templates without escaping.
validate_display_name()/validate_optional_text()reject control characters, but they still allow quotes and backslashes, andrender_template()does raw string replacement. I verified this with--display-name 'Foo "Bar"': the generatedchain-profile.tomlcontaineddisplay_name = "Foo "Bar"", and the Rust stubs contained broken string literals too.
I validated these in an isolated worktree with cargo run -p ows-cli -- dev scaffold-chain ....
|
Addressed the reported safety issues:
Also added regression tests for:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| "Ed25519" | ||
| } else { | ||
| "Secp256k1" | ||
| }; |
There was a problem hiding this comment.
Template variables computed but never used in templates
Low Severity
The curve_variant and family_variant fields in ScaffoldContext are computed (via chain_type_variant() and a string comparison) and processed in render_template with .replace("{{curve_variant}}", ...) and .replace("{{family_variant}}", ...), but no template file actually contains {{curve_variant}} or {{family_variant}}. A grep across templates/chain-plugin-kit/ confirms zero matches. This is dead code — computation and replacement that produces no visible effect.
Additional Locations (2)
|
this is a useful feature -> that being said, would like the architecture of this PR to be as isolated as possible from all source code, since this is for dev-ex and not a feature. Alternatively, can think about a refactor that makes a chain registry, so that there are less places where chain prs need to change. |


Summary
Adds a contributor-focused Chain Plugin Kit scaffold command to make adding a new supported chain easier and more consistent.
What this PR adds
Why
OWS is explicitly multi-chain and already documents supported chains, canonical identifiers, and derivation rules. This PR improves contributor ergonomics by standardizing the first step of new-chain work.
Scope
This PR focuses on scaffolding only.
It does not implement dynamic runtime plugin loading.
Validation
cargo run -p ows-cli -- dev scaffold-chain --slug release-check --family evm --display-name "Release Check" --write --force --output ".ows-dev/release-check-c"cd ows && cargo fmt --all --checkcd ows && cargo clippy --workspace -- -D warningscd ows && cargo test --workspaceNotes
Two minimal portability fixes were included so the documented workspace verification passes cleanly:
process_hardening.rspolicy_engine.rsNote
Medium Risk
Adds a new CLI command that validates user input and can create/overwrite files on disk (with
--force), so path-safety and deletion logic need careful review; no runtime chain support or signing behavior is changed.Overview
Adds a new
ows dev scaffold-chainCLI subcommand that dry-runs by default and can--writea self-contained “Chain Plugin Kit” under.ows-dev/chain-plugin-kit/<slug>/, generating templated TOML profiles, CAIP placeholders, signing/serialization stubs, docs skeletons, and JSON test-vector fixtures.Implements slug/token validation plus safe output-path/
--forceoverwrite restrictions to keep writes and deletions confined to the.ows-devscaffold area, with unit tests including an Aptos “golden path”. Updates contributor docs to describe the workflow, ignores.ows-dev/, and includes small Unix/Windows portability fixes for policy-engine tests and Unix-gating of cleanup hooks.Written by Cursor Bugbot for commit d39fc0c. This will update automatically on new commits. Configure here.