Skip to content

Conversation

@scarmuega
Copy link
Member

@scarmuega scarmuega commented Nov 19, 2025

Summary

  • add a wallet utxos CLI command that streams the configured wallet's UTxOs in JSON by default
  • expose a provider helper that returns the raw UTxoRPC structures and track whether the user overrode the output format
  • document the new command and changelog entry for visibility

Testing

  • cargo test

Codex Task

Summary by CodeRabbit

  • New Features

    • Added wallet utxos command to display the current wallet's UTxO set (JSON by default) with an optional --output-format table for tabular display.
  • Documentation

    • Updated README, docs, and CHANGELOG with usage examples and instructions for the new wallet UTxOs command.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new wallet utxos CLI command to fetch and display a wallet's live on-chain UTxOs, a Provider method to query UTxOs, a Context flag tracking explicit output-format overrides, and supporting docs and changelog updates.

Changes

Cohort / File(s) Summary
Documentation & Changelog
CHANGELOG.md, README.md, docs/wallet.mdx
Add an "Unreleased" changelog section and document the new wallet utxos command, its example usage, and --output-format option (JSON default, optional table).
Wallet CLI
src/wallet/mod.rs, src/wallet/utxos.rs
Add Utxos subcommand, Args and run implementation; resolve wallet/provider from context, fetch UTxOs, and format output via JSON or table formatter; include argument parsing tests.
Provider & Context
src/provider/types.rs, src/main.rs
Add Provider::get_wallet_utxos(&Address) -> Result<Vec<utxorpc::spec::query::AnyUtxoData>>; add pub output_format_overridden: bool to Context and set it during CLI-to-Context construction.

Sequence Diagram

sequenceDiagram
    autonumber
    participant User
    participant CLI as "wallet utxos\ncommand"
    participant Context
    participant Store as "Context Store\n(wallet/provider)"
    participant Provider as Provider.get_wallet_utxos()
    participant Formatter as OutputFormatter

    User->>CLI: run wallet utxos [--output-format table]
    CLI->>Context: build/obtain Context (captures output_format_overridden)
    CLI->>Store: resolve wallet & provider (with fallbacks)
    Store-->>CLI: wallet, provider
    CLI->>Provider: get_wallet_utxos(address)
    Provider->>Provider: build CardanoQueryClient\nquery UTxOs -> Vec<AnyUtxoData>
    Provider-->>CLI: Vec<AnyUtxoData>
    CLI->>Formatter: format (JSON or table)
    Formatter-->>CLI: formatted output
    CLI-->>User: display UTxOs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Check Context initialization and propagation of output_format_overridden in src/main.rs.
  • Review get_wallet_utxos for query construction, error contexts, and mapping to AnyUtxoData in src/provider/types.rs.
  • Validate formatting logic and CLI argument parsing/tests in src/wallet/utxos.rs.
  • Confirm src/wallet/mod.rs dispatch integration and docs consistency.

Poem

🐰
I hopped through docs and code today,
To fetch your UTxOs on display.
JSON by default, tables on cue,
A tiny feature—hoppy and new! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Add wallet utxos command' directly and clearly describes the main change: introducing a new wallet utxos CLI command, which is the primary objective of the changeset.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9629a02 and 8d7b5b6.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/provider/types.rs (1 hunks)

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/provider/types.rs (1)

165-204: Consider extracting the predicate construction to reduce duplication.

The predicate construction in lines 171-184 is duplicated across get_balance, get_detailed_balance, and now get_wallet_utxos. Consider extracting this into a helper method to improve maintainability.

Apply this refactor:

+    fn build_address_predicate(&self, address: &Address) -> utxorpc::spec::query::UtxoPredicate {
+        utxorpc::spec::query::UtxoPredicate {
+            r#match: Some(utxorpc::spec::query::AnyUtxoPattern {
+                utxo_pattern: Some(UtxoPattern::Cardano(
+                    utxorpc::spec::cardano::TxOutputPattern {
+                        address: Some(utxorpc::spec::cardano::AddressPattern {
+                            exact_address: address.to_vec().into(),
+                            ..Default::default()
+                        }),
+                        ..Default::default()
+                    },
+                )),
+            }),
+            ..Default::default()
+        }
+    }
+
     pub async fn get_wallet_utxos(
         &self,
         address: &Address,
     ) -> Result<Vec<utxorpc::spec::query::AnyUtxoData>> {
         let mut client: CardanoQueryClient = self.client().await?;
 
-        let predicate = utxorpc::spec::query::UtxoPredicate {
-            r#match: Some(utxorpc::spec::query::AnyUtxoPattern {
-                utxo_pattern: Some(UtxoPattern::Cardano(
-                    utxorpc::spec::cardano::TxOutputPattern {
-                        address: Some(utxorpc::spec::cardano::AddressPattern {
-                            exact_address: address.to_vec().into(),
-                            ..Default::default()
-                        }),
-                        ..Default::default()
-                    },
-                )),
-            }),
-            ..Default::default()
-        };
+        let predicate = self.build_address_predicate(address);

Then update get_balance (line 89) and get_detailed_balance (line 209) to use the same helper.

src/wallet/utxos.rs (1)

105-124: Consider adding integration tests for the actual UTxO retrieval flow.

The current tests only verify argument parsing. Consider adding tests that verify the actual functionality, such as:

  • Fetching UTxOs for a known wallet/provider combination
  • Verifying output format selection based on context
  • Testing error cases (missing wallet, missing provider)

This would improve confidence in the end-to-end behavior, though the current tests are sufficient for the argument parsing layer.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5df16e6 and 9629a02.

📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • docs/wallet.mdx (1 hunks)
  • src/main.rs (1 hunks)
  • src/provider/types.rs (1 hunks)
  • src/wallet/mod.rs (3 hunks)
  • src/wallet/utxos.rs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/wallet/mod.rs (2)
src/provider/utxorpc.rs (1)
  • utxos (161-201)
src/wallet/utxos.rs (1)
  • run (18-49)
src/provider/types.rs (1)
src/provider/utxorpc.rs (3)
  • client (25-37)
  • utxos (161-201)
  • utxo (172-186)
src/wallet/utxos.rs (2)
src/output.rs (1)
  • output (13-18)
src/wallet/mod.rs (1)
  • run (45-57)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: integration
  • GitHub Check: unit
🔇 Additional comments (10)
README.md (1)

106-112: LGTM!

The documentation clearly describes the new command and its output options.

docs/wallet.mdx (1)

65-73: LGTM!

The documentation accurately describes the command and its output format behavior.

CHANGELOG.md (1)

5-10: LGTM!

The changelog entry accurately describes the new feature.

src/wallet/mod.rs (3)

13-13: LGTM!

The module declaration follows the existing pattern.


40-41: LGTM!

The command variant is properly documented and follows the existing pattern.


55-55: LGTM!

The command routing is correct and consistent with other commands.

src/main.rs (2)

99-99: LGTM!

The new field correctly tracks whether the user explicitly set the output format.


105-116: LGTM!

The logic correctly determines both the output format and whether it was explicitly overridden. This enables commands to have different default formats while still respecting user preferences.

src/wallet/utxos.rs (2)

18-49: LGTM!

The function correctly resolves wallet and provider defaults, fetches UTxOs, and handles all error cases appropriately. The special-case default to JSON format (lines 35-39) makes sense for UTxO data, which is often piped to other tools.


61-103: LGTM!

The table formatter provides a useful summary with key fields, and the JSON formatter outputs the complete UTxO data. The handling of missing fields with fallback strings is appropriate.

};

let response = client
.search_utxos(predicate, None, u32::MAX)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Unbounded UTxO query could cause performance issues.

Using u32::MAX as the limit allows fetching an unbounded number of UTxOs. Wallets with many UTxOs (e.g., exchange wallets, large DeFi contracts) could trigger slow queries, high memory usage, or timeouts.

Consider either:

  1. Adding a configurable limit with a reasonable default (e.g., 1000)
  2. Implementing pagination support
  3. Documenting this limitation if it's intentional
-        let response = client
-            .search_utxos(predicate, None, u32::MAX)
-            .await
-            .context("failed to query utxos")?;
+        // Consider adding a reasonable limit or pagination
+        const MAX_UTXOS: u32 = 10000;
+        let response = client
+            .search_utxos(predicate, None, MAX_UTXOS)
+            .await
+            .context("failed to query utxos")?;

Committable suggestion skipped: line range outside the PR's diff.

@scarmuega scarmuega merged commit c2778be into main Nov 22, 2025
8 of 10 checks passed
@scarmuega scarmuega deleted the codex/add-cshell-wallet-utxos-command branch November 22, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants