Skip to content

Commit

Permalink
feat: enable testnet OTE flows (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Jun 19, 2024
1 parent 2c7f1eb commit 789e897
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,56 @@ internal open class AccountSupervisor(
}
}

private fun transferNobleBalanceSkip(amount: BigDecimal) {
val url = helper.configs.skipV2MsgsDirect()
val fromChain = helper.configs.nobleChainId()
val fromToken = helper.configs.nobleDenom
val nobleAddress = accountAddress.toNobleAddress() ?: return
val chainId = helper.environment.dydxChainId ?: return
val dydxTokenDemon = helper.environment.tokens["usdc"]?.denom ?: return
val body: Map<String, Any> = mapOf(
"amount_in" to amount.toPlainString(),
// from noble denom and chain
"source_asset_denom" to fromToken,
"source_asset_chain_id" to fromChain,
// to dydx denom and chain
"dest_asset_denom" to dydxTokenDemon,
"dest_asset_chain_id" to chainId,
"chain_ids_to_addresses" to mapOf(
fromChain to nobleAddress,
chainId to accountAddress,
),
"slippage_tolerance_percent" to SLIPPAGE_PERCENT,
)
val header =
iMapOf(
"Content-Type" to "application/json",
)
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, _ ->
if (response == null) {
val json = helper.parser.decodeJsonObject(response)
if (json != null) {
val skipRoutePayloadProcessor = SkipRoutePayloadProcessor(parser = helper.parser)
val processedPayload = skipRoutePayloadProcessor.received(existing = mapOf(), payload = json)
val ibcPayload =
helper.parser.asString(
processedPayload.get("data"),
)
if (ibcPayload != null) {
helper.transaction(TransactionType.SendNobleIBC, ibcPayload) {
val error = helper.parseTransactionResponse(it)
if (error != null) {
Logger.e { "transferNobleBalanceSkip error: $error" }
}
}
}
}
} else {
Logger.e { "transferNobleBalanceSkip error, code: $code" }
}
}
}

private fun handleComplianceResponse(response: String?, httpCode: Int): ComplianceStatus {
var complianceStatus = ComplianceStatus.UNKNOWN
var updatedAt: String? = null
Expand Down

0 comments on commit 789e897

Please sign in to comment.