feat(taker-bloc): Implement maker fallback with logging#2715
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA new Flutter version configuration file was introduced. The Changes
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
Suggested labels
Suggested reviewers
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/bloc/dex_repository.dart (1)
40-67: Enhance input validation and error handling.The
setPricemethod implementation is mostly correct, but could benefit from some improvements:
- Missing input validation: Consider validating the
SetPriceRequestparameters before making the API call.- 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
📒 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:
- 1: https://docs.flutter.dev/release/release-notes
- 2: https://liudonghua123.github.io/flutter_website/release/archive/
- 3: https://docs.flutter.dev/release/whats-new
- 4: https://docs.bugsee.com/sdk/flutter/release-notes/
- 5: https://www.aubergine.co/insights/upgrade-the-flutter-version
- 6: https://support.singular.net/hc/en-us/articles/23088556519707-Flutter-SDK-Change-Log
- 7: https://docs.flutter.dev/install/archive
- 8: https://situm.com/docs/flutter-sdk-changelog/
- 9: https://docs.urbi.ae/en/flutter/sdk/releases
- 10: https://documentation.atomic.io/sdks/flutter
.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 2lib/bloc/dex_repository.dart (1)
7-7: LGTM!The import for
setprice_request.dartis correctly added to support the new functionality.lib/bloc/taker_form/taker_bloc.dart (8)
20-20: LGTM!The import for
setprice_request.dartis 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
pauseWhileto_pauseWhilemaintains consistency with the private function definition.
531-531: LGTM!The logging update to use the class logger instance improves consistency.
590-601: LGTM!The
_pauseWhileutility function is well-implemented with:
- Proper timeout mechanism
- Reasonable polling interval (10ms)
- Clear function signature with default timeout
32c72af to
5cb95d8
Compare
5cb95d8 to
ef05e28
Compare
f87df4d
into
codex/update-taker-form-bloc-logic
* fix(dex): refactor maker fallback logging * refactor(dex-repository): using logging package and reduce best orders * fix: rebase duplication and formatting issues
* fix(dex): refactor maker fallback logging * refactor(dex-repository): using logging package and reduce best orders * fix: rebase duplication and formatting issues
Summary
setPriceresponse and return order UUIDLoggerinTakerBlocand implement helper wait functionTesting
dart format lib/bloc/dex_repository.dart lib/bloc/taker_form/taker_bloc.dartflutter analyze lib/bloc/dex_repository.dart lib/bloc/taker_form/taker_bloc.dartSummary by CodeRabbit