refactor(withdraw): use SDK executeWithdrawal() to avoid duplicate transaction signing#3325
Conversation
…ansaction signing - Replace manual sendRawTransaction() call with SDK executeWithdrawal() - Remove unused mm2Api dependency and import - Simplifies code by using proper SDK abstraction - Maintains existing behavior while following SDK best practices - Ensures transaction is only signed once during preview phase
Updates SDK to commit 6576c4c which includes: - New executeWithdrawal() method for preview-then-execute workflow - Deprecation of direct withdraw() method - Prevention of duplicate transaction signing
|
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 Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull Request Overview
This refactor updates the withdrawal execution flow to use the SDK's executeWithdrawal() method instead of manually calling sendRawTransaction(), improving code maintainability and following proper SDK abstraction patterns.
Key changes:
- Replaced direct RPC call with SDK's withdrawal execution method
- Removed unused
mm2Apidependency fromWithdrawFormBloc - Updated SDK submodule to version
6576c4cwhich includes the newexecuteWithdrawal()method
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk | Updated submodule pointer to commit 6576c4c containing the new SDK withdrawal execution method |
| lib/bloc/withdraw_form/withdraw_form_bloc.dart | Refactored withdrawal execution to use SDK method, removed mm2Api dependency and related imports |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
smk762
left a comment
There was a problem hiding this comment.
Confirm single sig only on trezor and zhtlc withdraws, thanks for the update!
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Overview
Updated the main application to use the new SDK
executeWithdrawal()method, replacing the manual workaround that was callingsendRawTransaction()directly.Problem
The app was implementing a workaround to avoid double signing by manually calling
sendRawTransaction()with the preview'stxHex. This bypassed the SDK abstraction and duplicated logic.Solution
Updated
WithdrawFormBlocto use the new SDKexecuteWithdrawal()method which:Changes Made
WithdrawFormBloc
sendRawTransaction()call with SDKexecuteWithdrawal()mm2Apidependency and importBefore
After
Benefits
Dependencies
6576c4cTesting
Files Modified
lib/bloc/withdraw_form/withdraw_form_bloc.dartsdk(submodule pointer update)Note
Replace manual
sendRawTransactionflow with_sdk.withdrawals.executeWithdrawal()and update SDK submodule._mm2Api.sendRawTransaction(...)with streaming_sdk.withdrawals.executeWithdrawal(preview, state.asset.id.id); handlecomplete/errorstatuses and null-result fallback._mm2Apifield andsend_raw_transaction_requestimport; keep constructor param but no longer used.WithdrawFormStep.success, clearpreview, and surface errors viatransactionErrorwhen execution fails or yields no result.sdksubmodule to6576c4c.Written by Cursor Bugbot for commit b67732d. This will update automatically on new commits. Configure here.