Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<WithdrawalProgress>] that emits progress updates.
@override
Stream<WithdrawalProgress> 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<bool> cancelWithdrawal(int taskId) async => false;
Expand Down
Loading