Skip to content

fix: add filtering flag back#7208

Merged
SWvheerden merged 2 commits intotari-project:developmentfrom
mmrrnn:mp_add_filtering_flag_back
Jun 12, 2025
Merged

fix: add filtering flag back#7208
SWvheerden merged 2 commits intotari-project:developmentfrom
mmrrnn:mp_add_filtering_flag_back

Conversation

@mmrrnn
Copy link
Copy Markdown
Contributor

@mmrrnn mmrrnn commented Jun 12, 2025

Description

For some reason it was removed while merging.

Origin: #7161

Summary by CodeRabbit

  • New Features

    • Added the ability to filter completed transactions by status when viewing transaction history.
  • Enhancements

    • Improved transaction history pagination to work with filtered results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 12, 2025

Test Results (CI)

    3 files    126 suites   44m 12s ⏱️
1 333 tests 1 332 ✅ 0 💤 1 ❌
3 997 runs  3 994 ✅ 0 💤 3 ❌

For more details on these failures, see this check.

Results for commit a98c761.

♻️ This comment has been updated with latest results.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

The change updates the transaction retrieval logic in the get_all_completed_transactions method of the gRPC wallet server. It introduces a filtering step that selects transactions based on a status bitflag provided in the request, applying this filter before paginating the results with offset and limit.

Changes

File(s) Change Summary
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs Added transaction status bitflag filtering before offset/limit pagination in transaction retrieval; added #[allow(clippy::too_many_lines)] attribute to the method

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WalletGrpcServer
    participant TransactionStore

    Client->>WalletGrpcServer: get_all_completed_transactions(req)
    WalletGrpcServer->>TransactionStore: fetch all completed transactions
    WalletGrpcServer->>WalletGrpcServer: filter transactions by status bitflag
    WalletGrpcServer->>WalletGrpcServer: apply offset and limit
    WalletGrpcServer->>Client: return filtered and paginated transactions
Loading

Possibly related PRs

Suggested reviewers

  • SWvheerden

Poem

A bunny hops through code so neat,
Filtering transactions, a clever feat!
With bitflags waving in the air,
Only the right ones make it there.
Offset and limit, now in line—
The wallet’s gRPC works just fine!
🐇✨


📜 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 c7fda4d and a98c761.

📒 Files selected for processing (1)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: ci
  • GitHub Check: cargo check with stable
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66bec7f and c7fda4d.

📒 Files selected for processing (1)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs

[error] 1182-1296: Clippy error: this function has too many lines (105/100). Function 'get_all_completed_transactions' exceeds the maximum allowed lines. See https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines


[warning] 1230-1230: Clippy warning: using clone on type TransactionStatus which implements the Copy trait. Suggestion: try removing the clone call: tx.status. See https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI

Comment on lines +1228 to +1233
for txn in completed_transactions
.into_iter()
.filter(|tx| req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status.clone() as u32))) != 0)
.skip(offset)
.take(limit)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Bit-flag filter causes type‐mismatch & unnecessary clone() – will not compile with u64 flags

req.status_bitflag comes from the protobuf message as an unsigned integer (u64 in the generated code).
The right-hand operand created by

(1 << (tx.status.clone() as u32))

is an i32, so the & operation (u64 & i32) fails to type-check.
In addition, TransactionStatus is Copy; the clone() is redundant and flagged by Clippy.

Proposed fix:

-            .filter(|tx| req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status.clone() as u32))) != 0)
+            .filter(|tx| {
+                // When no filter is supplied, include every tx
+                if req.status_bitflag == 0 {
+                    return true;
+                }
+                // Convert both sides to the same integer type before the bitwise op
+                let status_bit = 1u64 << (tx.status as u32);
+                (req.status_bitflag & status_bit) != 0
+            })

Benefits
• Compiles for any 64-bit flag mask.
• Removes the clone() call, satisfying Clippy.
• Reads clearer with an early return for the zero-mask case.

🧰 Tools
🪛 GitHub Actions: CI

[warning] 1230-1230: Clippy warning: using clone on type TransactionStatus which implements the Copy trait. Suggestion: try removing the clone call: tx.status. See https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

🤖 Prompt for AI Agents
In applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs around
lines 1228 to 1233, the bit-flag filter uses a type-mismatched expression where
req.status_bitflag is u64 but the shifted value is i32, causing a compilation
error. Remove the unnecessary clone() on tx.status since it is Copy, and cast
tx.status to u64 before shifting 1 by that amount to ensure both operands in the
bitwise AND are u64. Also, consider adding an early return if req.status_bitflag
is zero to simplify the filter logic.

@github-actions
Copy link
Copy Markdown

Test Results (Integration tests)

 2 files  10 suites   2h 14m 21s ⏱️
26 tests 16 ✅ 2 💤  8 ❌
42 runs  16 ✅ 2 💤 24 ❌

For more details on these failures, see this check.

Results for commit c7fda4d.

@SWvheerden SWvheerden merged commit 5c1923f into tari-project:development Jun 12, 2025
12 of 16 checks passed
sdbondi added a commit to sdbondi/tari that referenced this pull request Jun 18, 2025
* development: (607 commits)
  Wallet GRPC port comment fix from 18142 to 18143 (tari-project#7221)
  feat: integrated address support for Ledger (tari-project#7198)
  chore: new release v4.1.1-pre.0 (tari-project#7211)
  fix: migration can now correctly resume after stopping (tari-project#7210)
  fix: only revalidated rejected transactions on startup (tari-project#7209)
  fix: add filtering flag back (tari-project#7208)
  feat: improve wallet balance checks from external clients (tari-project#7207)
  feat!: update grpc supply query (tari-project#7137)
  docs: Updated API GRPC and Exchange Guide (tari-project#7205)
  chore: new release v4.4.0-pre.0 (tari-project#7202)
  feat: update base node proto to search bytes (tari-project#7201)
  feat: full PayRef implementation (tari-project#7154)
  test: add ffi cucumber wallet balance test (tari-project#7189)
  chore: fix tests (tari-project#7196)
  fix(network-discovery): add back idle event handling (tari-project#7194)
  Update SECURITY.md (tari-project#7193)
  fix: transaction manager service unmined lookup (tari-project#7192)
  fix: wallet ffi database name mismatch for mobile wallet (tari-project#7191)
  fix: payment_id deserialize (tari-project#7187)
  fix: remove code for deleting stale peers (tari-project#7184)
  ...
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.

2 participants