Updated on 2026-08-14
This commit is contained in:
commit
2f2d6755f9
4 changed files with 57 additions and 9 deletions
|
|
@ -9,7 +9,7 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
|||
* Helper to apply compatibility changes for [UserTokensResponse] to support old saved tokens
|
||||
* in new application with new IDs
|
||||
*/
|
||||
internal class UserTokensBackwardCompatibility {
|
||||
class UserTokensBackwardCompatibility {
|
||||
|
||||
fun applyCompatibilityAndGetUpdated(userTokensResponse: UserTokensResponse): UserTokensResponse {
|
||||
return userTokensResponse.copy(
|
||||
|
|
@ -28,6 +28,21 @@ internal class UserTokensBackwardCompatibility {
|
|||
)
|
||||
}
|
||||
|
||||
fun applyCompatibilityAndGetUpdated(tokens: List<UserTokensResponse.Token>): List<UserTokensResponse.Token> {
|
||||
return 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NETWORKS_TO_OLD_SAVED_IDS = mapOf(
|
||||
"optimistic-ethereum" to "ethereum",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue