Skip to content

Commit

Permalink
fix setting tokens chains and resources
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed May 30, 2024
1 parent f62aca4 commit 31c21d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,11 @@ private fun TradingStateMachine.updateTransferToTokenType(transfer: MutableMap<S
private fun TradingStateMachine.updateTransferToChainType(transfer: MutableMap<String, Any>, 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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 31c21d0

Please sign in to comment.