Skip to content

feat(stellar-scaffold-cli): build clients without a Cargo workspace - #652

Open
sharmis-tp wants to merge 1 commit into
stellar-scaffold:mainfrom
sharmis-tp:issue-584-no-rust-clients
Open

sharmis-tp wants to merge 1 commit into
stellar-scaffold:mainfrom
sharmis-tp:issue-584-no-rust-clients

Conversation

@sharmis-tp

Copy link
Copy Markdown
Contributor

Closes #584

A project that only uses contracts deployed elsewhere, such as the Registry UI, can now run stellar scaffold build with no Cargo.toml, no contracts/ and no Rust toolchain. As discussed in the issue, build follows the contract's type. Only workspace contracts need cargo, so if the selected network lists none, nothing is compiled and build goes straight to generating clients from scaffold.yml. Non-local sources (from-network, registry) are left for the follow-up.

Changes

build without cargo (commands/build/mod.rs)

  • When cargo metadata fails (no Cargo.toml, or no cargo at all) and the project root has a version 2 scaffold.yml, build resolves the selected network's plan without crate checks.
    • If no contract on that network is type: workspace, it prints No Cargo workspace found; nothing to compile, starts the local container if the network uses one, and runs the client pipeline.
    • If some are type: workspace, it fails with an error that names them and includes cargo's error: contract `hello` is `type: workspace`, so building it needs a Cargo workspace and a Rust toolchain, but cargo failed: …
    • --list, --compile-only and environments.toml projects still return cargo's original error, since for them there's nothing to do without crates.
  • The project root without cargo is the --manifest-path directory or the current directory. This now uses one helper, config::root_without_cargo, shared with Workspace::discover (used by config check and doctor).
  • No compile step, so the pre-/post-compile hooks don't fire. Deploy and codegen hooks fire as usual. Their compile context falls back to the default.
  • Refactor, no behavior change: building the ClientsArgs and resolving the v2 plan are now helpers (clients_args, v2_plan, start_network_if_local), so both paths share them.

Client pipeline (commands/build/clients.rs)

  • A version 2 build now always runs handle_listed_contracts. It used to return early when no crates were compiled, so referenced contracts got no client. This also affects a Cargo workspace with no cdylib crates.
  • A version 2 network with no accounts no longer fails with "you need to provide at least one account" when nothing on it is type: workspace. Bindings for a deployed contract sign nothing. config check already requires accounts for any contract that deploys.
  • New Environment::workspace_contracts() in env_toml.rs, used for both checks.

Docs

  • configuration.md: new "Projects without Rust contracts" section with a minimal scaffold.yml.
  • cli.md: a note under build.

Testing

  • cargo fmt --all -- --check
  • just clippy and just clippy-test equivalents: cargo clippy --all [--tests --all-features] -- -Dclippy::pedantic … are clean
  • cargo test -p stellar-scaffold-cli: 243 unit tests and tests/unit.rs pass. New tests:
    • clients::tests::referenced_contracts_need_no_account and workspace_contracts_need_an_account
    • unit.rs::builds_without_cargo_when_no_contract_is_a_workspace_crate: a temp dir with only scaffold.yml
    • unit.rs::workspace_contracts_need_cargo
    • unit.rs::without_cargo_other_builds_report_cargos_error: no scaffold.yml, and --compile-only
  • Integration tests (--features integration-tests), against a local stellar/quickstart (protocol 29) and stellar-cli 28.1.0:
    • New build_clients::scaffold_v2::client_for_a_deployed_contract_builds_without_cargo deploys hello from the boilerplate. It then builds a sibling directory that has only a scaffold.yml pointing at that ID (type: contract) and checks the generated client and index.ts.
    • All of build_clients::scaffold_v2 and build_clients::accounts still pass (6/6).
    • The rest of the localnet suite (examples::, features::, the other build_clients:: modules) was not run locally.
  • Manual: a directory containing only a scaffold.yml that references the testnet XLM SAC (CDLZ…CYSC) builds and generates app-lib/clients/xlm and index.ts. This also works with cargo removed from PATH.
  • docs/site: prettier -c and lint:admonitions pass on the changed pages.

This branch has not been deployed

No deployments
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.

Remove Rust dependency when building clients

1 participant