Skip to content

Add simplex new and simplex example commands, improve generated t…#40

Open
stringhandler wants to merge 1 commit intoBlockstreamResearch:masterfrom
stringhandler:feat/generator
Open

Add simplex new and simplex example commands, improve generated t…#40
stringhandler wants to merge 1 commit intoBlockstreamResearch:masterfrom
stringhandler:feat/generator

Conversation

@stringhandler
Copy link
Copy Markdown

@stringhandler stringhandler commented Mar 27, 2026

…est template, and expand README docs

New commands

simplex new <name>

Creates a complete Simplex project scaffold in a new / directory. Equivalent to running simplex init --lib in a freshly created directory, but with a better UX — errors immediately if the target directory already exists rather than clobbering existing files.

simplex example <name>

Scaffolds a full example project into a new directory. Currently supports simplex example basic, which writes all files from the examples/basic/ template (including the options, option_offer, array_tr_storage, bytes32_tr_storage, and dual_currency_deposit contracts) using include_str! so the content is embedded in the binary at compile time. The Cargo.toml is generated dynamically to pin to the latest published smplx-std version from crates.io, consistent with how simplex new works.

Improved generated test template

The default test file produced by simplex new and simplex init --lib was previously a non-compiling todo!() stub. It is now a working end-to-end p2pk integration test that demonstrates:

  • Instantiating a program with typed arguments (P2pkArguments)
  • Deriving a script pubkey from the program
  • Funding the script via FinalTransaction + PartialOutput
  • Spending the script by supplying a P2pkWitness with DUMMY_SIGNATURE and RequiredSignature::Witness so the signer fills in the real signature

The crate name (simplex_<project_name>) is substituted at generation time so the artifact imports resolve correctly for any project name. anyhow is now also added to the generated Cargo.toml to support the -> anyhow::Result<()> return type.

README

  • Replaced the cargo add smplx-std getting-started flow with simplex new as the primary entry point
  • Added simplex new and simplex example to the CLI command reference
  • Added a "Typical workflow" section showing the new -> build -> test flow
  • Added a "Using smplx-std as a library" section covering: dependency setup, how generated artifacts are structured, instantiating a program with arguments, funding and spending scripts with FinalTransaction, a key types reference table, and the #[simplex::test] macro
  • Updated the future work checklist to mark simplex new and simplex example as complete

@stringhandler stringhandler requested a review from Arvolear as a code owner March 27, 2026 10:55
…est template, and expand README docs

New commands
------------

simplex new <name>
Creates a complete Simplex project scaffold in a new <name>/ directory.
Equivalent to running `simplex init --lib` in a freshly created directory,
but with a better UX — errors immediately if the target directory already
exists rather than clobbering existing files.

simplex example <name>
Scaffolds a full example project into a new directory. Currently supports
`simplex example basic`, which writes all files from the examples/basic/
template (including the options, option_offer, array_tr_storage,
bytes32_tr_storage, and dual_currency_deposit contracts) using include_str!
so the content is embedded in the binary at compile time. The Cargo.toml is
generated dynamically to pin to the latest published smplx-std version from
crates.io, consistent with how `simplex new` works.

Improved generated test template
---------------------------------

The default test file produced by `simplex new` and `simplex init --lib` was
previously a non-compiling todo!() stub. It is now a working end-to-end p2pk
integration test that demonstrates:

- Instantiating a program with typed arguments (P2pkArguments)
- Deriving a script pubkey from the program
- Funding the script via FinalTransaction + PartialOutput
- Spending the script by supplying a P2pkWitness with DUMMY_SIGNATURE and
  RequiredSignature::Witness so the signer fills in the real signature

The crate name (simplex_<project_name>) is substituted at generation time so
the artifact imports resolve correctly for any project name. anyhow is now
also added to the generated Cargo.toml to support the -> anyhow::Result<()>
return type.

README
------

- Replaced the `cargo add smplx-std` getting-started flow with `simplex new`
  as the primary entry point
- Added `simplex new` and `simplex example` to the CLI command reference
- Added a "Typical workflow" section showing the new -> build -> test flow
- Added a "Using smplx-std as a library" section covering: dependency setup,
  how generated artifacts are structured, instantiating a program with
  arguments, funding and spending scripts with FinalTransaction, a key types
  reference table, and the #[simplex::test] macro
- Updated the future work checklist to mark `simplex new` and `simplex example`
  as complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant