From 8df00aef7b8d25c91434c703736772efc7599cab Mon Sep 17 00:00:00 2001 From: Rui Date: Fri, 25 Oct 2024 09:56:28 -0700 Subject: [PATCH 1/2] Fix transfer asset loading issues on iOS with static typing --- build.gradle.kts | 2 +- .../processor/input/TransferInputProcessor.kt | 6 +++++- .../state/model/TradingStateMachine+TransferInput.kt | 5 ----- v4_abacus.podspec | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8be4d821a..9675f2b29 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.13" +version = "1.13.14" repositories { google() 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/v4_abacus.podspec b/v4_abacus.podspec index 531a89995..4ae24dd3b 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.13.13' + spec.version = '1.13.14' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' From 47ae4fe3e1f5c94127293c5264da727e2e8d211c Mon Sep 17 00:00:00 2001 From: Rui Date: Fri, 25 Oct 2024 10:05:41 -0700 Subject: [PATCH 2/2] Add UT --- .../validation/TransferRequiredInputTests.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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() {