Skip to content

feat(taker-bloc): Implement maker fallback with logging#2715

Merged
takenagain merged 3 commits intocodex/update-taker-form-bloc-logicfrom
9ymfqi-codex/update-taker-form-bloc-logic
May 30, 2025
Merged

feat(taker-bloc): Implement maker fallback with logging#2715
takenagain merged 3 commits intocodex/update-taker-form-bloc-logicfrom
9ymfqi-codex/update-taker-form-bloc-logic

Conversation

@takenagain
Copy link
Copy Markdown
Contributor

@takenagain takenagain commented May 30, 2025

Summary

  • parse setPrice response and return order UUID
  • use Logger in TakerBloc and implement helper wait function
  • handle maker fallback with try/catch and structured logging

Testing

  • dart format lib/bloc/dex_repository.dart lib/bloc/taker_form/taker_bloc.dart
  • flutter analyze lib/bloc/dex_repository.dart lib/bloc/taker_form/taker_bloc.dart

Summary by CodeRabbit

  • New Features
    • Added a configuration file to specify the Flutter SDK version for the project.
  • Improvements
    • Enhanced swap functionality to check for existing matching orders before placing a sell order, with improved error handling and logging for better reliability and transparency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 30, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new Flutter version configuration file was introduced. The DexRepository class gained a setPrice method for placing maker orders. The taker form bloc's swap initiation logic was refactored to check for existing orders before selling, with improved error handling, logging, and a renamed utility pause function.

Changes

File(s) Change Summary
.fvmrc Added Flutter version configuration file specifying version 3.32.0.
lib/bloc/dex_repository.dart Added setPrice async method for placing maker orders, with error handling and logging.
lib/bloc/taker_form/taker_bloc.dart Refactored _onStartSwap to check for matching orders before selling, improved error handling and logging, added imports, and renamed/refactored pause utility function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TakerBloc
    participant DexRepository
    participant MM2Api

    User->>TakerBloc: Start Swap
    TakerBloc->>DexRepository: getBestOrders(base, rel, limit)
    DexRepository-->>TakerBloc: List of orders
    TakerBloc->>TakerBloc: Check for matching order UUID
    alt No matching order
        TakerBloc->>DexRepository: setPrice(SetPriceRequest)
        DexRepository->>MM2Api: setprice API call
        MM2Api-->>DexRepository: Response with uuid
        DexRepository-->>TakerBloc: uuid
        TakerBloc-->>User: Emit state with new swap uuid
    else Matching order exists
        TakerBloc->>DexRepository: sell(...)
        DexRepository-->>TakerBloc: Sell response
        TakerBloc-->>User: Emit state with sell result
    end
Loading

Suggested labels

bug, chore, QA

Suggested reviewers

  • ShantanuSharma9873
  • AndrewDelaney
  • smk762
  • CharlVS

Poem

A hop, a skip, a version set anew,
With swaps and checks, the logic grew.
Maker orders now can rise,
If matching swaps don’t meet our eyes.
Errors logged, the code refined—
A rabbit’s joy, with peace of mind! 🐇✨


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.

@takenagain takenagain self-assigned this May 30, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented May 30, 2025

Visit the preview URL for this PR (updated for commit 5cb95d8):

https://walletrc--pull-2715-merge-c1c4cfgz.web.app

(expires Fri, 06 Jun 2025 11:17:52 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

@takenagain takenagain marked this pull request as draft May 30, 2025 10:10
@takenagain takenagain requested a review from Copilot May 30, 2025 10:42
@takenagain
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 30, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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 implements a maker fallback mechanism with logging for failed order operations and introduces helper functions to control execution flow.

  • Parse setPrice response to return order UUID
  • Add structured logging and error handling in TakerBloc and DexRepository
  • Replace pauseWhile with a new _pauseWhile helper function and update error logging

Reviewed Changes

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

File Description
lib/bloc/taker_form/taker_bloc.dart Adds maker fallback logic with logging, refactors order handling, and introduces _pauseWhile.
lib/bloc/dex_repository.dart Implements the setPrice API call with error checking and logging.
.fvmrc Updates Flutter version configuration.

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

🧹 Nitpick comments (1)
lib/bloc/dex_repository.dart (1)

40-67: Enhance input validation and error handling.

The setPrice method implementation is mostly correct, but could benefit from some improvements:

  1. Missing input validation: Consider validating the SetPriceRequest parameters before making the API call.
  2. Response structure assumptions: The code assumes specific response structure (result.uuid) which could be brittle.

Consider adding input validation:

 Future<String> setPrice(SetPriceRequest request) async {
+  // Validate input parameters
+  if (request.base.isEmpty || request.rel.isEmpty) {
+    throw Exception('Invalid base or rel coin');
+  }
+  if (request.volume == null || request.volume! <= Rational.zero) {
+    throw Exception('Invalid volume');
+  }
+  if (request.price == null || request.price! <= Rational.zero) {
+    throw Exception('Invalid price');
+  }
+
   try {
     final Map<String, dynamic>? response = await _mm2Api.setprice(request);

Also consider more specific error handling for the response structure:

-      final String? uuid = response['result']?['uuid'] as String?;
+      final Map<String, dynamic>? result = response['result'] as Map<String, dynamic>?;
+      if (result == null) {
+        throw Exception('Missing result in setprice response');
+      }
+      final String? uuid = result['uuid'] as String?;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 902b7e1 and 1212dd9.

📒 Files selected for processing (3)
  • .fvmrc (1 hunks)
  • lib/bloc/dex_repository.dart (2 hunks)
  • lib/bloc/taker_form/taker_bloc.dart (6 hunks)
🔇 Additional comments (10)
.fvmrc (1)

2-2:

Details

✅ Verification successful

Verify the Flutter SDK version exists and is stable.

The specified Flutter version "3.32.0" appears to be unusually high. Please verify that this version exists and is a stable release.


🌐 Web query:

What is the latest stable version of Flutter SDK as of 2025?

💡 Result:

The latest stable version of the Flutter SDK as of May 30, 2025, is 3.32.0. This version was released on May 20, 2025, following previous stable releases such as 3.29.0 and 3.27.0[1][3]. The official Flutter documentation and release notes confirm that 3.32.0 is currently reflected as the latest stable release[1][3].

Citations:


.fvmrc Flutter version validated

Confirmed that Flutter SDK 3.32.0 is the latest stable release as of May 30, 2025, according to the official Flutter release notes. No changes are needed.

  • File: .fvmrc, Line 2
lib/bloc/dex_repository.dart (1)

7-7: LGTM!

The import for setprice_request.dart is correctly added to support the new functionality.

lib/bloc/taker_form/taker_bloc.dart (8)

20-20: LGTM!

The import for setprice_request.dart is correctly added to support the new maker fallback functionality.


27-27: LGTM!

The logging import is correctly added to support the enhanced error handling.


83-83: LGTM!

The logger instance is properly initialized for the TakerBloc class.


131-150: LGTM!

The existing sell order logic is preserved and correctly integrated with the new maker fallback flow.


151-156: LGTM!

The error handling with logging and state management is well-implemented.


177-177: LGTM!

The function name update from pauseWhile to _pauseWhile maintains consistency with the private function definition.


531-531: LGTM!

The logging update to use the class logger instance improves consistency.


590-601: LGTM!

The _pauseWhile utility function is well-implemented with:

  • Proper timeout mechanism
  • Reasonable polling interval (10ms)
  • Clear function signature with default timeout

@takenagain takenagain marked this pull request as ready for review May 30, 2025 11:12
@takenagain takenagain force-pushed the 9ymfqi-codex/update-taker-form-bloc-logic branch from 32c72af to 5cb95d8 Compare May 30, 2025 11:14
@takenagain takenagain changed the base branch from dev to codex/update-taker-form-bloc-logic May 30, 2025 11:18
@takenagain takenagain force-pushed the 9ymfqi-codex/update-taker-form-bloc-logic branch from 5cb95d8 to ef05e28 Compare May 30, 2025 11:26
@takenagain takenagain changed the title Implement maker fallback with logging feat(taker-bloc): Implement maker fallback with logging May 30, 2025
@takenagain takenagain merged commit f87df4d into codex/update-taker-form-bloc-logic May 30, 2025
3 of 5 checks passed
@takenagain takenagain deleted the 9ymfqi-codex/update-taker-form-bloc-logic branch May 30, 2025 11:31
takenagain added a commit that referenced this pull request Jun 16, 2025
* fix(dex): refactor maker fallback logging

* refactor(dex-repository): using logging package and reduce best orders

* fix: rebase duplication and formatting issues
takenagain added a commit that referenced this pull request Jun 17, 2025
* fix(dex): refactor maker fallback logging

* refactor(dex-repository): using logging package and reduce best orders

* fix: rebase duplication and formatting issues
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