Skip to content

ZSA Swap Demo 2026#72

Open
vivek-arte wants to merge 3 commits into
zsa-swapfrom
zsa_swap_demo
Open

ZSA Swap Demo 2026#72
vivek-arte wants to merge 3 commits into
zsa-swapfrom
zsa_swap_demo

Conversation

@vivek-arte

Copy link
Copy Markdown
Contributor

These are the updates made for the demonstrations of the Swaps and other ZSA functionalities in April 2026

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Add interactive ZSA demo subcommand with asset lifecycle flows

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add new demo subcommand for ZSA operations showcase
• Implement end-to-end demonstration of asset lifecycle flows
• Update logging messages for generic asset unit terminology
• Include interactive prompts for step-by-step demo progression
Diagram
flowchart LR
  A["Demo Command"] --> B["Issue Assets"]
  B --> C["Transfer Assets"]
  C --> D["Finalize Assets"]
  D --> E["Swap Assets"]
  E --> F["Verify Balances"]
Loading

Grey Divider

File Changes

1. src/commands.rs ✨ Enhancement +3/-0

Register demo command in application

• Add demo module declaration to command modules
• Import DemoCmd from demo module
• Add Demo(DemoCmd) variant to AppCmd enum

src/commands.rs


2. src/commands/demo.rs ✨ Enhancement +228/-0

Implement interactive ZSA operations demonstration

• Create new 228-line demo module for end-to-end ZSA operations
• Implement DemoCmd struct with Runnable trait
• Demonstrate asset issuance, transfer, finalization, and swapping
• Include interactive wait_for_enter() prompts between demo steps
• Verify balance updates at each stage of asset lifecycle

src/commands/demo.rs


3. src/components/transactions.rs ✨ Enhancement +2/-2

Update asset logging to use generic terminology

• Change log message in create_transfer_transaction from "zatoshi" to "units"
• Change log message in create_burn_transaction from "zatoshi" to "units"
• Makes logging generic for any asset type, not just ZEC

src/components/transactions.rs


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Apr 30, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. Demo blocks on stdin 🐞 Bug ☼ Reliability
Description
DemoCmd::run unconditionally pauses for user input via wait_for_enter(), which blocks on
stdin.read_line() and can hang indefinitely in non-interactive environments. This makes the new
demo subcommand unreliable when invoked from automation or when stdin is not a TTY.
Code

src/commands/demo.rs[R31-36]

+fn wait_for_enter() {
+    use std::io::{self, Write};
+    print!("\n\n\n\nPress Enter to continue...");
+    io::stdout().flush().unwrap();
+    let _ = io::stdin().read_line(&mut String::new());
+}
Evidence
The new demo command defines wait_for_enter() that blocks on stdin, and DemoCmd::run calls it
repeatedly; the command is registered into the CLI, so it can be invoked in any environment.

src/commands/demo.rs[31-36]
src/commands/demo.rs[74-82]
src/commands/demo.rs[90-98]
src/commands/demo.rs[113-121]
src/commands/demo.rs[153-161]
src/commands.rs[33-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`demo` currently pauses multiple times using `stdin.read_line()`, which can hang indefinitely in CI/non-interactive environments.

### Issue Context
The `demo` subcommand is wired into the main CLI, so it may be invoked from scripts/automation.

### Fix Focus Areas
- src/commands/demo.rs[31-36]
- src/commands/demo.rs[74-82]
- src/commands/demo.rs[90-98]
- src/commands/demo.rs[113-121]
- src/commands/demo.rs[153-161]

### Suggested change
- Add a CLI flag like `--interactive/--pause` (default false in non-interactive runs).
- Only call `wait_for_enter()` when interactive is enabled and stdin is a TTY (or when explicitly requested).
- Avoid `unwrap()` on `flush()`; handle errors gracefully (log and continue).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

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