From 5ddc5356535b30f5e42c0fd40d3b4515b10e766d Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:56:01 -0700 Subject: [PATCH] Fix transfer asset loading issues on iOS with static typing (#733) --- .../processor/input/TransferInputProcessor.kt | 6 +++++- .../model/TradingStateMachine+TransferInput.kt | 5 ----- .../validation/TransferRequiredInputTests.kt | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt index a65871503..a89f8be63 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt @@ -38,7 +38,7 @@ internal class TransferInputProcessor( inputState: InternalInputState, walletState: InternalWalletState, data: String?, - inputField: TransferInputField, + inputField: TransferInputField?, subaccountNumber: Int = 0 ): InputProcessorResult { val error: ParsingError? = null @@ -182,6 +182,10 @@ internal class TransferInputProcessor( updated = true } } + + else -> { + updated = true + } } val type = transfer.type 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 c16ebe625..f4b8798c4 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 @@ -44,11 +44,6 @@ fun TradingStateMachine.transfer( environment: V4Environment, ): StateResponse { if (staticTyping) { - if (type == null) { - val error = ParsingError.cannotModify("type") - return StateResponse(state, null, iListOf(error)) - } - val processor = TransferInputProcessor( parser = parser, routerProcessor = routerProcessor, diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/validation/TransferRequiredInputTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/validation/TransferRequiredInputTests.kt index e3a30f892..5055a9a67 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/validation/TransferRequiredInputTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/validation/TransferRequiredInputTests.kt @@ -1,6 +1,7 @@ package exchange.dydx.abacus.validation import exchange.dydx.abacus.output.input.ErrorType +import exchange.dydx.abacus.output.input.InputType import exchange.dydx.abacus.output.input.TransferType import exchange.dydx.abacus.payload.v4.V4BaseTests import exchange.dydx.abacus.state.model.TransferInputField @@ -38,9 +39,19 @@ class TransferRequiredInputTests : V4BaseTests() { override fun reset() { super.reset() - test({ + + if (perp.staticTyping) { perp.transfer(null, null, environment = mock.v4Environment) - }, null) + + assertEquals(InputType.TRANSFER, perp.internalState.input.currentType) + + val transfer = perp.internalState.input.transfer + assertEquals(TransferType.deposit, transfer.type) + } else { + test({ + perp.transfer(null, null, environment = mock.v4Environment) + }, null) + } } private fun testTransferInputDeposit() {