Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-05 21:00:06 +03:00
parent 946d60c1c6
commit 9c11182ca6
14 changed files with 127 additions and 40 deletions

View file

@ -13,4 +13,7 @@ dependencies {
/** SDK */
implementation(deps.tangem.blockchain)
/** Core */
implementation(projects.core.utils)
}

View file

@ -0,0 +1,29 @@
package com.tangem.lib.crypto
import com.tangem.blockchain.blockchains.xrp.XrpAddressService
import com.tangem.blockchain.common.Blockchain
import com.tangem.lib.crypto.converter.XrpTaggedAddressConverter
import com.tangem.lib.crypto.models.XrpTaggedAddress
/**
* !!!IMPORTANT!!!
* Methods for working with different blockchains
* All methods are depend on specific blockchain or check for specific blockchain
*
* Temporary solution for domain specific logic for Blockchain.
* Instead of creating repositories and unnecessary and overkill use cases
*/
object BlockchainUtils {
private const val XRP_X_ADDRESS = 'X'
/** Decodes XRP Blockchain address */
fun decodeRippleXAddress(xAddress: String, networkId: String): XrpTaggedAddress? {
return if (networkId == Blockchain.XRP.id && xAddress.firstOrNull() == XRP_X_ADDRESS) {
val decodedAddress = XrpAddressService.decodeXAddress(xAddress)
return decodedAddress?.let(XrpTaggedAddressConverter()::convert)
} else {
null
}
}
}

View file

@ -0,0 +1,15 @@
package com.tangem.lib.crypto.converter
import com.tangem.lib.crypto.models.XrpTaggedAddress
import com.tangem.utils.converter.Converter
import com.tangem.blockchain.blockchains.xrp.XrpTaggedAddress as BlockchainXrpTaggedAddress
internal class XrpTaggedAddressConverter : Converter<BlockchainXrpTaggedAddress, XrpTaggedAddress> {
override fun convert(value: BlockchainXrpTaggedAddress): XrpTaggedAddress {
return XrpTaggedAddress(
address = value.address,
destinationTag = value.destinationTag,
)
}
}

View file

@ -0,0 +1,6 @@
package com.tangem.lib.crypto.models
data class XrpTaggedAddress(
val address: String,
val destinationTag: Long?,
)