From 31c21d0fb1c51aab3106aef60d24da2429d573ac Mon Sep 17 00:00:00 2001 From: jeremy lee Date: Thu, 30 May 2024 16:55:30 -0400 Subject: [PATCH] fix setting tokens chains and resources --- .../TradingStateMachine+TransferInput.kt | 33 +++---------------- .../state/model/TradingStateMachine.kt | 2 +- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt index 2cc152517..29a45e6d7 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt @@ -204,24 +204,11 @@ private fun TradingStateMachine.updateTransferToTokenType(transfer: MutableMap, chainType: String) { val tokenOptions = squidProcessor.tokenOptions(chainType) if (transfer["type"] != "TRANSFER_OUT") { - transfer.safeSet( - "depositOptions.assets", - tokenOptions, - ) - transfer.safeSet( - "withdrawalOptions.assets", - tokenOptions, - ) + internalState.transfer.tokens = tokenOptions transfer.safeSet("chain", chainType) transfer.safeSet("token", squidProcessor.defaultTokenAddress(chainType)) - transfer.safeSet( - "resources.chainResources", - squidProcessor.chainResources(chainType), - ) - transfer.safeSet( - "resources.tokenResources", - squidProcessor.tokenResources(chainType), - ) + internalState.transfer.chainResources = squidProcessor.chainResources(chainType) + internalState.transfer.tokenResources = squidProcessor.tokenResources(chainType) } transfer.safeSet("exchange", null) transfer.safeSet("size.size", null) @@ -233,19 +220,9 @@ private fun TradingStateMachine.updateTransferExchangeType(transfer: MutableMap< val exchangeDestinationChainId = squidProcessor.exchangeDestinationChainId val tokenOptions = squidProcessor.tokenOptions(exchangeDestinationChainId) if (transfer["type"] != "TRANSFER_OUT") { - transfer.safeSet( - "depositOptions.assets", - tokenOptions, - ) - transfer.safeSet( - "withdrawalOptions.assets", - tokenOptions, - ) + internalState.transfer.tokens = tokenOptions transfer.safeSet("token", squidProcessor.defaultTokenAddress(exchangeDestinationChainId)) - transfer.safeSet( - "resources.tokenResources", - squidProcessor.tokenResources(exchangeDestinationChainId), - ) + internalState.transfer.tokenResources = squidProcessor.tokenResources(exchangeDestinationChainId) } transfer.safeSet("exchange", exchange) transfer.safeSet("chain", null) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt index 0d824bed3..25c710599 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt @@ -82,7 +82,7 @@ open class TradingStateMachine( private val maxSubaccountNumber: Int, private val useParentSubaccount: Boolean, ) { - private val internalState: InternalState = InternalState() + internal val internalState: InternalState = InternalState() internal val parser: ParserProtocol = Parser() internal val marketsProcessor = MarketsSummaryProcessor(parser)