Skip to content

Conversation

@fnando
Copy link
Member

@fnando fnando commented Jan 30, 2026

What

Auto-build contracts when WASM file is not provided in stellar contract deploy and stellar contract upload commands.

  • stellar contract deploy automatically builds the project when neither --wasm nor --wasm-hash is provided. Adds optional --package flag to specify which package to build in multi-package workspaces.
  • stellar contract upload automatically builds the project when --wasm is omitted. Adds optional --package flag to specify which package to build in multi-package workspaces.
# Deploy without specifying WASM (auto-builds)
stellar contract deploy

# Deploy with specific package in workspace
stellar contract deploy --package my-contract

# Upload without specifying WASM (auto-builds)
stellar contract upload

# Upload with specific package in workspace
stellar contract upload --package my-contract

When deploying multiple contracts, aliases matching the package name will be used and automatically defined.

Why

Closes #2047.

Known limitations

N/A

@fnando fnando requested a review from a team as a code owner January 30, 2026 01:27
Copilot AI review requested due to automatic review settings January 30, 2026 01:27
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Jan 30, 2026
@fnando fnando self-assigned this Jan 30, 2026
@fnando fnando moved this from Backlog (Not Ready) to In Progress in DevX Jan 30, 2026
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the new code would benefit from tests, if it's not awkward to add integration tests for that.

One suggestion inline, but it is easily done as an improvement separately and doesn't need to block.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds “auto-build” behavior to contract deployment flows, so users can run stellar contract deploy / stellar contract upload without manually providing a WASM path when working inside a Cargo contract project/workspace.

Changes:

  • contract deploy: makes --wasm/--wasm-hash optional and auto-builds contracts when omitted; adds --package to select a specific workspace package; supports deploying multiple built contracts with derived aliases.
  • contract upload (and deprecated install): makes --wasm optional and auto-builds when omitted; adds --package to select a specific workspace package; supports uploading multiple built artifacts.
  • contract build: refactored to return a list of built WASM artifacts (name + path) for reuse by deploy/upload, and docs regenerated accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
cmd/soroban-cli/src/commands/contract/upload.rs Makes --wasm optional, auto-builds when omitted, and uploads one or many built WASMs.
cmd/soroban-cli/src/commands/contract/mod.rs Adjusts dispatch to the updated contract build return type.
cmd/soroban-cli/src/commands/contract/deploy/wasm.rs Makes WASM inputs optional, auto-builds when omitted, supports multi-contract deploy and derived aliases.
cmd/soroban-cli/src/commands/contract/build.rs Returns built artifact metadata (BuiltContract) so other commands can auto-build and consume outputs.
FULL_HELP_DOCS.md Updates CLI help docs to reflect new optional WASM flags and --package build options.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

@fnando fnando enabled auto-merge (squash) January 30, 2026 18:44
@fnando fnando moved this from In Progress to Needs Review in DevX Jan 30, 2026
@fnando fnando merged commit cc816f5 into main Jan 30, 2026
29 checks passed
@fnando fnando deleted the deploy-all branch January 30, 2026 18:49
@github-project-automation github-project-automation bot moved this from Needs Review to Done in DevX Jan 30, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let res = self
.execute(&self.config, global_args.quiet, global_args.no_cache)
if self.build_only && self.wasm.is_none() && self.wasm_hash.is_none() {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--build-only is currently allowed when --wasm-hash is provided (the early check only rejects when both --wasm and --wasm-hash are missing), but execute() later requires a local WASM file for --build-only and will error. This results in confusing behavior/error messages for stellar contract deploy --wasm-hash ... --build-only. Consider either (a) rejecting --build-only unless --wasm is provided, or (b) implementing true build-only support for --wasm-hash (likely only when no constructor args, or by allowing fetching spec in build-only).

Suggested change
if self.build_only && self.wasm.is_none() && self.wasm_hash.is_none() {
if self.build_only && self.wasm.is_none() {

Copilot uses AI. Check for mistakes.
Comment on lines +286 to +289
let contracts = build_cmd.run(global_args).map_err(|e| match e {
build::Error::Metadata(_) => Error::NotInCargoProject,
other => other.into(),
})?;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build::Error::Metadata(_) is mapped to NotInCargoProject, but build::Error::Metadata wraps any cargo_metadata::Error (invalid Cargo.toml, cargo failures, etc.), not just “no Cargo.toml found”. This can surface a misleading error message. Consider detecting the “no manifest / no Cargo.toml” case explicitly (e.g., by checking for a Cargo.toml in the cwd/ancestors or inspecting the cargo_metadata error) and otherwise returning the original build/metadata error.

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +188
let contracts = build_cmd.run(global_args).map_err(|e| match e {
build::Error::Metadata(_) => Error::NotInCargoProject,
other => other.into(),
})?;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build::Error::Metadata(_) is mapped to NotInCargoProject, but build::Error::Metadata wraps any cargo_metadata::Error (invalid Cargo.toml, cargo failures, etc.), not only the “no Cargo.toml found” case. This can produce a misleading NotInCargoProject message when the workspace exists but cargo_metadata fails for another reason. Consider distinguishing “no Cargo.toml” from other metadata failures before converting the error.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

stellar contract install|deploy build the current project and install/deploy all built

4 participants