Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-16 11:27:36 +04:00
parent 0598dd8e16
commit bbf13f1ae8
32 changed files with 53 additions and 142 deletions

View file

@ -11,23 +11,6 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
*/
class UserTokensBackwardCompatibility {
fun applyCompatibilityAndGetUpdated(userTokensResponse: UserTokensResponse): UserTokensResponse {
return userTokensResponse.copy(
tokens = userTokensResponse.tokens.map { token ->
val oldSavedId = NETWORKS_TO_OLD_SAVED_IDS[token.networkId]
if (oldSavedId != null && token.id == oldSavedId) {
Blockchain.fromNetworkId(token.networkId)?.let { blockchain ->
token.copy(
id = blockchain.toCoinId(),
)
} ?: token
} else {
token
}
},
)
}
fun applyCompatibilityAndGetUpdated(tokens: List<UserTokensResponse.Token>): List<UserTokensResponse.Token> {
return tokens.map { token ->
val oldSavedId = NETWORKS_TO_OLD_SAVED_IDS[token.networkId]

View file

@ -362,7 +362,7 @@ internal class DefaultWalletsRepository(
override suspend fun associateWallets(applicationId: String, wallets: List<UserWallet>) =
withContext(dispatchers.io) {
val associateApplicationIdWithWallets: suspend () -> ApiResponse<Unit> = {
tangemTechApi.associateApplicationIdWithWalletsV2(
tangemTechApi.associateApplicationIdWithWallets(
applicationId = applicationId,
body = AssociateApplicationIdWithWalletsBody(
walletIds = wallets.map { it.walletId.stringValue }.distinct(),

View file

@ -186,7 +186,7 @@ class DefaultWalletsRepositoryTest {
inner class AssociateWallets {
@Test
fun `should convert and send to API V2`() = runTest {
fun `should convert and send to associateApplicationIdWithWallets`() = runTest {
// Arrange
val applicationId = "test_app_id"
val wallet1Id = "1234567890abcdef"
@ -202,7 +202,7 @@ class DefaultWalletsRepositoryTest {
)
coEvery {
tangemTechApi.associateApplicationIdWithWalletsV2(eq(applicationId), any())
tangemTechApi.associateApplicationIdWithWallets(eq(applicationId), any())
} returns ApiResponse.Success(Unit)
// Act
@ -210,7 +210,7 @@ class DefaultWalletsRepositoryTest {
// Assert
coVerify(exactly = 1) {
tangemTechApi.associateApplicationIdWithWalletsV2(
tangemTechApi.associateApplicationIdWithWallets(
applicationId = eq(applicationId),
body = match { body ->
body.walletIds.size == 2 &&