Updated on 2026-08-14
This commit is contained in:
parent
946d60c1c6
commit
9c11182ca6
14 changed files with 127 additions and 40 deletions
|
|
@ -13,4 +13,7 @@ dependencies {
|
|||
|
||||
/** SDK */
|
||||
implementation(deps.tangem.blockchain)
|
||||
|
||||
/** Core */
|
||||
implementation(projects.core.utils)
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.tangem.lib.crypto.models
|
||||
|
||||
data class XrpTaggedAddress(
|
||||
val address: String,
|
||||
val destinationTag: Long?,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue