Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transfer asset loading issues on iOS with static typing #733

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,6 +182,10 @@ internal class TransferInputProcessor(
updated = true
}
}

else -> {
updated = true
}
}

val type = transfer.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Comment on lines -47 to -50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we removing because because type can be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. iOS is passing null there


val processor = TransferInputProcessor(
parser = parser,
routerProcessor = routerProcessor,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() {
Expand Down