Updated on 2026-08-14
This commit is contained in:
parent
19f7fc1e27
commit
a50a6a5bbc
6 changed files with 17 additions and 11 deletions
|
|
@ -68,8 +68,8 @@ class CardanoAddressFactory {
|
|||
.end()
|
||||
.build())
|
||||
|
||||
val hexAddress = addressBaos.toByteArray()
|
||||
return hexAddress.encodeBase58()
|
||||
val addressBytes = addressBaos.toByteArray()
|
||||
return addressBytes.encodeBase58()
|
||||
}
|
||||
|
||||
fun extendPublicKey(publicKey: ByteArray): ByteArray {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.blockchain.common.extensions.SimpleResult
|
|||
import com.tangem.blockchain.common.extensions.encodeBase64NoWrap
|
||||
import com.tangem.blockchain.wallets.CurrencyWallet
|
||||
import com.tangem.common.CompletionResult
|
||||
import java.math.RoundingMode
|
||||
|
||||
class CardanoWalletManager(
|
||||
private val cardId: String,
|
||||
|
|
@ -61,7 +62,7 @@ class CardanoWalletManager(
|
|||
val size = transactionBuilder.getEstimateSize(
|
||||
TransactionData(amount, null, address, destination), walletPublicKey
|
||||
)
|
||||
val fee = (a + b * size).toBigDecimal()
|
||||
val fee = (a + b * size).toBigDecimal().setScale(blockchain.decimals.toInt(), RoundingMode.UP)
|
||||
return Result.Success(listOf(Amount(blockchain.currency, fee, address, blockchain.decimals)))
|
||||
}
|
||||
}
|
||||
|
|
@ -12,9 +12,9 @@ interface AdaliteApi {
|
|||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/api/bulk/addresses/utxo")
|
||||
suspend fun getUnspents(@Body address: String): AdaliteUnspents
|
||||
suspend fun getUnspents(@Body addresses: List<String>): AdaliteUnspents
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/api/v2/txs/signed")
|
||||
suspend fun sendTransaction(@Body adaliteBody: AdaliteSendBody): ResponseBody // List<Any>?
|
||||
suspend fun sendTransaction(@Body adaliteBody: AdaliteSendBody): String // List<Any>?
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
package com.tangem.blockchain.cardano.network.adalite
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.tangem.blockchain.cardano.network.CardanoAddressResponse
|
||||
import com.tangem.blockchain.cardano.UnspentOutput
|
||||
import com.tangem.blockchain.cardano.network.api.AdaliteApi
|
||||
import com.tangem.blockchain.common.extensions.Result
|
||||
import com.tangem.blockchain.common.extensions.SimpleResult
|
||||
import com.tangem.blockchain.common.extensions.retryIO
|
||||
import com.tangem.common.extensions.hexToBytes
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
|
|
@ -15,7 +17,7 @@ class AdaliteProvider(private val api: AdaliteApi) {
|
|||
return try {
|
||||
coroutineScope {
|
||||
val addressDeferred = retryIO { async { api.getAddress(address) } }
|
||||
val unspentsDeferred = retryIO { async { api.getUnspents(address) } }
|
||||
val unspentsDeferred = retryIO { async { api.getUnspents(listOf(address)) } }
|
||||
|
||||
val addressData = addressDeferred.await()
|
||||
val unspents = unspentsDeferred.await()
|
||||
|
|
@ -24,7 +26,7 @@ class AdaliteProvider(private val api: AdaliteApi) {
|
|||
UnspentOutput(
|
||||
it.amountData!!.amount!!,
|
||||
it.outputIndex!!.toLong(),
|
||||
it.hash!!.toByteArray()
|
||||
it.hash!!.hexToBytes()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ class AdaliteProvider(private val api: AdaliteApi) {
|
|||
|
||||
suspend fun sendTransaction(transaction: String): SimpleResult {
|
||||
return try {
|
||||
retryIO { api.sendTransaction(AdaliteSendBody(transaction)) }
|
||||
val response = retryIO { api.sendTransaction(AdaliteSendBody(transaction)) }
|
||||
SimpleResult.Success
|
||||
} catch (exception: Exception) {
|
||||
SimpleResult.Failure(exception)
|
||||
|
|
@ -50,4 +52,7 @@ class AdaliteProvider(private val api: AdaliteApi) {
|
|||
}
|
||||
}
|
||||
|
||||
data class AdaliteSendBody(val signedTransaction: String)
|
||||
data class AdaliteSendBody(
|
||||
@Json(name = "signedTx")
|
||||
val signedTransaction: String
|
||||
)
|
||||
|
|
@ -5,7 +5,7 @@ import com.squareup.moshi.JsonClass
|
|||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class AdaliteAddress(
|
||||
@Json(name = "final_balance")
|
||||
@Json(name = "Right")
|
||||
var data: AdaliteAddressData? = null
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ const val API_STELLAR = "https://horizon.stellar.org/"
|
|||
const val API_STELLAR_RESERVE = "https://horizon.sui.li/"
|
||||
const val API_STELLAR_TESTNET = "https://horizon-testnet.stellar.org/"
|
||||
const val API_BLOCKCHAIN_INFO = "https://blockchain.info/"
|
||||
const val API_ADALITE = "https://explorer2.adalite.io"
|
||||
const val API_ADALITE = "https://explorer3.adalite.io"
|
||||
const val API_ADALITE_RESERVE = "https://nodes.southeastasia.cloudapp.azure.com"
|
||||
const val API_RIPPLED = "https://s1.ripple.com:51234"
|
||||
const val API_RIPPLED_RESERVE = "https://s2.ripple.com:51234"
|
||||
Loading…
Add table
Add a link
Reference in a new issue