Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-25 12:41:13 +05:00
parent 4649abbb60
commit db55e6eb1d
8 changed files with 101 additions and 64 deletions

View file

@ -8,6 +8,7 @@ import com.tangem.core.error.UniversalError
import com.tangem.data.common.currency.CryptoCurrencyFactory
import com.tangem.data.common.network.NetworkFactory
import com.tangem.data.pay.util.TangemPayErrorConverter
import com.tangem.domain.card.common.visa.VisaUtilities
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.pay.TangemPayCryptoCurrencyFactory
@ -57,4 +58,25 @@ internal class DefaultTangemPayCryptoCurrencyFactory @Inject constructor(
errorConverter.convert(exception)
}
}
override fun create(userWallet: UserWallet): Either<UniversalError, CryptoCurrency.Token> {
return catch {
val network = networkFactory.create(
blockchain = VisaUtilities.visaBlockchain,
extraDerivationPath = null,
userWallet = userWallet,
)
cryptoCurrencyFactory.createToken(
network = requireNotNull(network),
rawId = CryptoCurrency.RawID(TOKEN_ID),
name = TOKEN_NAME,
symbol = TOKEN_NAME,
contractAddress = TOKEN_CONTRACT_ADDRESS,
decimals = TOKEN_DECIMALS,
)
}.mapLeft { exception ->
TangemLogger.withTag(TAG).e("Error", exception)
errorConverter.convert(exception)
}
}
}