From fbefc59204727167b2fb4d8bf4ae47d457546e4d Mon Sep 17 00:00:00 2001 From: aforaleka Date: Fri, 30 Aug 2024 09:49:31 -0400 Subject: [PATCH] address comments! --- .../supervisor/SubaccountTransactionSupervisor.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountTransactionSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountTransactionSupervisor.kt index 5db6c53bb..a1aefd7eb 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountTransactionSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountTransactionSupervisor.kt @@ -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(