Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Jun 4, 2024
1 parent 9fc61cb commit 97ba0c2
Showing 1 changed file with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,24 @@ internal class OnboardingSupervisor(
dydxTokenDemon != null &&
url != null
) {
val params: IMap<String, String> = iMapOf(
"fromChain" to fromChain,
"fromToken" to fromToken,
"fromAmount" to fromAmountString,
"toChain" to chainId,
"toToken" to dydxTokenDemon,
"toAddress" to accountAddress,
"slippage" to "1",
"enableForecall" to "false",
"fromAddress" to sourceAddress,
val body: Map<String, Any> = mapOf(
"amount_in" to fromAmountString,
"source_asset_denom" to fromToken,
"source_asset_chain_id" to fromChain,
"dest_asset_denom" to dydxTokenDemon,
"dest_asset_chain_id" to chainId,
"chain_ids_to_addresses" to mapOf(
"fromChain" to sourceAddress,
"toChain" to accountAddress,
),
"slippage_tolerance_percent" to SLIPPAGE_PERCENT,
)

val oldState = stateMachine.state
val header = iMapOf(
"Content-Type" to "application/json",
)
helper.get(url, params, header) { _, response, code, headers ->
helper.get(url, body, header) { _, response, code, headers ->
if (response != null) {
val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size
val oldFromAmount = oldState?.input?.transfer?.size?.size
Expand All @@ -265,21 +266,21 @@ internal class OnboardingSupervisor(
// TODO: Consider creating generateArgs fun to reduce code duplication
val fromChain = state?.input?.transfer?.chain
val fromToken = state?.input?.transfer?.token
val fromAmount = parser.asDecimal(state?.input?.transfer?.size?.size)?.let {
val decimals = parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain))
val fromAmount = helper.parser.asDecimal(state?.input?.transfer?.size?.size)?.let {
val decimals = helper.parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain))
if (decimals != null) {
(it * Numeric.decimal.TEN.pow(decimals)).toBigInteger()
} else {
null
}
}
val chainId = environment.dydxChainId
val dydxTokenDemon = environment.tokens["usdc"]?.denom
val fromAmountString = parser.asString(fromAmount)
val chainId = helper.environment.dydxChainId
val dydxTokenDemon = helper.environment.tokens["usdc"]?.denom
val fromAmountString = helper.parser.asString(fromAmount)
val nobleAddress = accountAddress?.toNobleAddress()
val url = configs.skipV2MsgsDirect()
val toChain = configs.nobleChainId()
val toToken = configs.nobleDenom()
val url = helper.configs.skipV2MsgsDirect()
val toChain = helper.configs.nobleChainId()
val toToken = helper.configs.nobleDenom()
if (fromChain != null &&
fromToken != null &&
fromAmount != null && fromAmount > 0 &&
Expand All @@ -306,7 +307,7 @@ internal class OnboardingSupervisor(
val header = iMapOf(
"Content-Type" to "application/json",
)
post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers ->
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers ->
if (response != null) {
val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size
val oldFromAmount = oldState?.input?.transfer?.size?.size
Expand Down

0 comments on commit 97ba0c2

Please sign in to comment.