Updated on 2026-08-14

This commit is contained in:
Tangem 2022-07-12 11:08:13 +04:00
parent db4ffb192e
commit 699f261589
2 changed files with 3 additions and 15 deletions

View file

@ -6,9 +6,7 @@ import com.tangem.common.extensions.calculateSha512
import com.tangem.common.extensions.toHexString
import com.tangem.common.services.Result
import com.tangem.common.services.performRequest
import com.tangem.domain.common.extensions.removePrefixFromAddress
import com.tangem.network.common.createRetrofitInstance
import com.tangem.tap.common.extensions.urlEncode
import com.tangem.tap.common.redux.global.CryptoCurrencyName
import com.tangem.tap.features.wallet.redux.Currency
import com.tangem.tap.network.exchangeServices.CurrencyExchangeManager
@ -101,18 +99,17 @@ class MercuryoService(
cryptoCurrencyName: CryptoCurrencyName,
fiatCurrencyName: String,
walletAddress: String
): String? {
): String {
if (action == CurrencyExchangeManager.Action.Sell) throw UnsupportedOperationException()
val walletAddressCorrected = blockchain.removePrefixFromAddress(walletAddress)
val builder = Uri.Builder()
.scheme(ExchangeUrlBuilder.SCHEME)
.authority("exchange.mercuryo.io")
.appendQueryParameter("widget_id", mercuryoWidgetId)
.appendQueryParameter("type", action.name.lowercase())
.appendQueryParameter("currency", cryptoCurrencyName)
.appendQueryParameter("address", walletAddressCorrected.urlEncode())
.appendQueryParameter("signature", signature(walletAddressCorrected).urlEncode())
.appendQueryParameter("address", walletAddress)
.appendQueryParameter("signature", signature(walletAddress))
.appendQueryParameter("fix_currency", "true")
.appendQueryParameter("return_url", ExchangeUrlBuilder.SUCCESS_URL)

View file

@ -1,6 +1,5 @@
package com.tangem.domain.common.extensions
import com.tangem.blockchain.blockchains.bitcoincash.cashaddr.CashAddr
import com.tangem.blockchain.common.Blockchain
fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? {
@ -105,12 +104,4 @@ fun Blockchain.toCoinId(): String {
Blockchain.Tron, Blockchain.TronTestnet -> "tron"
else -> "unknown"
}
}
fun Blockchain.removePrefixFromAddress(address: String): String {
return when (this) {
Blockchain.BitcoinCash -> address
.removePrefix(CashAddr.MAIN_NET_PREFIX).removePrefix(":")
else -> address
}
}