Updated on 2026-08-14
This commit is contained in:
parent
f8268dbe6e
commit
cc78c7dde5
2 changed files with 8 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.data.account.converter
|
package com.tangem.data.account.converter
|
||||||
|
|
||||||
import arrow.core.getOrElse
|
import arrow.core.getOrElse
|
||||||
|
import arrow.core.right
|
||||||
import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO
|
import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO
|
||||||
import com.tangem.domain.models.account.AccountId
|
import com.tangem.domain.models.account.AccountId
|
||||||
import com.tangem.domain.models.account.CryptoPortfolioIcon
|
import com.tangem.domain.models.account.CryptoPortfolioIcon
|
||||||
|
|
@ -8,7 +9,10 @@ import com.tangem.domain.models.account.DerivationIndex
|
||||||
import com.tangem.domain.models.wallet.UserWalletId
|
import com.tangem.domain.models.wallet.UserWalletId
|
||||||
|
|
||||||
internal fun String.toAccountId(userWalletId: UserWalletId): AccountId {
|
internal fun String.toAccountId(userWalletId: UserWalletId): AccountId {
|
||||||
return AccountId.forCryptoPortfolio(value = this, userWalletId = userWalletId).getOrElse {
|
return when {
|
||||||
|
startsWith(AccountId.PaymentAccountIdPrefix) -> AccountId.forPaymentAccount(userWalletId).right()
|
||||||
|
else -> AccountId.forCryptoPortfolio(value = this, userWalletId = userWalletId)
|
||||||
|
}.getOrElse {
|
||||||
error("Unable to create AccountId from value: $this. Cause: $it")
|
error("Unable to create AccountId from value: $this. Cause: $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ data class AccountId private constructor(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
const val PaymentAccountIdPrefix = "payment_"
|
||||||
|
|
||||||
private val sha256Digest: MessageDigest by lazy { MessageDigest.getInstance("SHA-256") }
|
private val sha256Digest: MessageDigest by lazy { MessageDigest.getInstance("SHA-256") }
|
||||||
private val hexRegex = Regex("^[a-fA-F0-9]{64}$")
|
private val hexRegex = Regex("^[a-fA-F0-9]{64}$")
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ data class AccountId private constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun forPaymentAccount(userWalletId: UserWalletId): AccountId {
|
fun forPaymentAccount(userWalletId: UserWalletId): AccountId {
|
||||||
return AccountId(value = "payment_$userWalletId", userWalletId = userWalletId)
|
return AccountId(value = "$PaymentAccountIdPrefix$userWalletId", userWalletId = userWalletId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue