-
Notifications
You must be signed in to change notification settings - Fork 124
Auto-build contracts when WASM not provided in deploy/upload. #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
leighmcculloch
left a comment
There was a problem hiding this 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.
There was a problem hiding this 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-hashoptional and auto-builds contracts when omitted; adds--packageto select a specific workspace package; supports deploying multiple built contracts with derived aliases.contract upload(and deprecatedinstall): makes--wasmoptional and auto-builds when omitted; adds--packageto 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. |
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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() { |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
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).
| if self.build_only && self.wasm.is_none() && self.wasm_hash.is_none() { | |
| if self.build_only && self.wasm.is_none() { |
| let contracts = build_cmd.run(global_args).map_err(|e| match e { | ||
| build::Error::Metadata(_) => Error::NotInCargoProject, | ||
| other => other.into(), | ||
| })?; |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
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.
| let contracts = build_cmd.run(global_args).map_err(|e| match e { | ||
| build::Error::Metadata(_) => Error::NotInCargoProject, | ||
| other => other.into(), | ||
| })?; |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
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.
What
Auto-build contracts when WASM file is not provided in stellar contract deploy and stellar contract upload commands.
stellar contract deployautomatically builds the project when neither --wasm nor --wasm-hash is provided. Adds optional--packageflag to specify which package to build in multi-package workspaces.stellar contract uploadautomatically builds the project when--wasmis omitted. Adds optional--packageflag to specify which package to build in multi-package workspaces.When deploying multiple contracts, aliases matching the package name will be used and automatically defined.
Why
Closes #2047.
Known limitations
N/A