Skip to content

Commit

Permalink
address comments!
Browse files Browse the repository at this point in the history
  • Loading branch information
aforaleka committed Aug 30, 2024
1 parent 1e6445e commit fbefc59
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,23 @@ internal class SubaccountTransactionSupervisor(

internal fun cancelAllOrders(marketId: String?, callback: TransactionCallback): HumanReadableCancelAllOrdersPayload {
val payload = payloadProvider.cancelAllOrdersPayload(marketId)
val subaccount = stateMachine.state?.subaccount(subaccountNumber) ?: throw ParsingException(
ParsingErrorType.MissingRequiredData,
"no subaccount found",
)

payload.payloads.forEach { cancelPayload ->
val subaccount = stateMachine.state?.subaccount(subaccountNumber)
val existingOrder = subaccount?.orders?.firstOrNull { it.id == cancelPayload.orderId }
val existingOrder = subaccount.orders?.firstOrNull { it.id == cancelPayload.orderId }
?: throw ParsingException(
ParsingErrorType.MissingRequiredData,
"no existing order to be cancelled for $cancelPayload.orderId",
"no existing order to be cancelled for ${cancelPayload.orderId}",
)
val analyticsPayload = analyticsUtils.cancelOrderAnalyticsPayload(
cancelPayload,
existingOrder,
false,
false,
true,
fromSlTpDialog = false,
isOrphanedTriggerOrder = false,
isCancelAll = true,
)
val uiClickTimeMs = transactionTracker.trackOrderClick(analyticsPayload, AnalyticsEvent.TradeCancelAllOrdersClick)
submitCancelOrder(
Expand Down

0 comments on commit fbefc59

Please sign in to comment.