From 2481a7df1f26c36314bc15d75735a9634f6635f1 Mon Sep 17 00:00:00 2001 From: CharlVS <77973576+CharlVS@users.noreply.github.com> Date: Wed, 18 Mar 2026 21:54:18 +0100 Subject: [PATCH] fix(withdrawals): remove duplicate executeWithdrawal method The squash merge of the SIA branch into dev left a duplicate executeWithdrawal method in LegacyWithdrawalManager. Remove the second copy which also inconsistently used WithdrawalException directly instead of the _mapError helper. --- .../legacy_withdrawal_manager.dart | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/packages/komodo_defi_sdk/lib/src/withdrawals/legacy_withdrawal_manager.dart b/packages/komodo_defi_sdk/lib/src/withdrawals/legacy_withdrawal_manager.dart index 0341216a..e10c00a6 100644 --- a/packages/komodo_defi_sdk/lib/src/withdrawals/legacy_withdrawal_manager.dart +++ b/packages/komodo_defi_sdk/lib/src/withdrawals/legacy_withdrawal_manager.dart @@ -195,71 +195,6 @@ class LegacyWithdrawalManager implements WithdrawalManager { } } - /// Execute a withdrawal from a previously generated preview. - /// - /// This method broadcasts the pre-signed transaction from the preview, - /// avoiding the need to sign the transaction again. This is the ONLY - /// recommended way to execute withdrawals for Tendermint assets. - /// - /// Parameters: - /// - [preview] - The preview result from [previewWithdrawal] - /// - [assetId] - The asset identifier (coin symbol) - /// - /// Returns a [Stream] that emits progress updates. - @override - Stream executeWithdrawal( - WithdrawalPreview preview, - String assetId, - ) async* { - try { - // Initial progress update - yield WithdrawalProgress( - status: WithdrawalStatus.inProgress, - message: 'Broadcasting signed transaction...', - withdrawalResult: WithdrawalResult( - txHash: preview.txHash, - balanceChanges: preview.balanceChanges, - coin: assetId, - toAddress: preview.to.first, - fee: preview.fee, - kmdRewardsEligible: - preview.kmdRewards != null && - Decimal.parse(preview.kmdRewards!.amount) > Decimal.zero, - ), - ); - - // Broadcast the pre-signed transaction - final broadcastResponse = await _client.rpc.withdraw.sendRawTransaction( - coin: assetId, - txHex: preview.txHex, - txJson: preview.txJson, - ); - - // Final success update with actual broadcast transaction hash - yield WithdrawalProgress( - status: WithdrawalStatus.complete, - message: 'Withdrawal completed successfully', - withdrawalResult: WithdrawalResult( - txHash: broadcastResponse.txHash, - balanceChanges: preview.balanceChanges, - coin: assetId, - toAddress: preview.to.first, - fee: preview.fee, - kmdRewardsEligible: - preview.kmdRewards != null && - Decimal.parse(preview.kmdRewards!.amount) > Decimal.zero, - ), - ); - } catch (e) { - yield* Stream.error( - WithdrawalException( - 'Failed to broadcast transaction: $e', - WithdrawalErrorCode.networkError, - ), - ); - } - } - /// No-op for legacy implementation since there's no task to cancel @override Future cancelWithdrawal(int taskId) async => false;