Updated on 2026-08-14
This commit is contained in:
parent
ccb8c774ed
commit
57d3a102ab
4 changed files with 28 additions and 10 deletions
|
|
@ -344,18 +344,27 @@ internal class DefaultWalletsRepository(
|
|||
upgradeWalletNotificationDisabled.update { it.plus(userWalletId) }
|
||||
}
|
||||
|
||||
override suspend fun setWalletName(walletId: String, walletName: String) = withContext(dispatchers.io) {
|
||||
val userWallet = userWalletsStore.getSyncOrNull(key = UserWalletId(walletId))
|
||||
override suspend fun setWalletName(walletId: UserWalletId, walletName: String) = withContext(dispatchers.io) {
|
||||
val userWallet = userWalletsStore.getSyncOrNull(key = walletId)
|
||||
|
||||
tangemTechApi.updateWallet(
|
||||
walletId = walletId,
|
||||
walletId = walletId.stringValue,
|
||||
body = WalletBody(name = walletName, type = WalletType.from(userWallet)),
|
||||
).getOrThrow()
|
||||
}
|
||||
|
||||
override suspend fun getWalletInfo(walletId: String): UserWalletRemoteInfo = withContext(dispatchers.io) {
|
||||
override suspend fun upgradeWallet(walletId: UserWalletId) = withContext(dispatchers.io) {
|
||||
val userWallet = userWalletsStore.getSyncStrict(key = walletId)
|
||||
|
||||
tangemTechApi.updateWallet(
|
||||
walletId = walletId.stringValue,
|
||||
body = WalletBody(name = userWallet.name, type = WalletType.from(userWallet)),
|
||||
).getOrThrow()
|
||||
}
|
||||
|
||||
override suspend fun getWalletInfo(walletId: UserWalletId): UserWalletRemoteInfo = withContext(dispatchers.io) {
|
||||
UserWalletRemoteInfoConverter.convert(
|
||||
value = tangemTechApi.getWalletById(walletId).getOrThrow(),
|
||||
value = tangemTechApi.getWalletById(walletId.stringValue).getOrThrow(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,13 @@ interface WalletsRepository {
|
|||
suspend fun dismissUpgradeWalletNotification(userWalletId: UserWalletId)
|
||||
|
||||
@Throws
|
||||
suspend fun setWalletName(walletId: String, walletName: String)
|
||||
suspend fun setWalletName(walletId: UserWalletId, walletName: String)
|
||||
|
||||
@Throws
|
||||
suspend fun getWalletInfo(walletId: String): UserWalletRemoteInfo
|
||||
suspend fun upgradeWallet(walletId: UserWalletId)
|
||||
|
||||
@Throws
|
||||
suspend fun getWalletInfo(walletId: UserWalletId): UserWalletRemoteInfo
|
||||
|
||||
@Throws
|
||||
suspend fun getWalletsInfo(applicationId: String, updateCache: Boolean = true): List<UserWalletRemoteInfo>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class RenameWalletUseCase(
|
|||
suspend operator fun invoke(userWalletId: UserWalletId, name: String): Either<UpdateWalletError, UserWallet> =
|
||||
either {
|
||||
runCatching {
|
||||
walletsRepository.setWalletName(userWalletId.stringValue, name)
|
||||
walletsRepository.setWalletName(userWalletId, name)
|
||||
}
|
||||
|
||||
userWalletsSyncDelegate.syncWallet(userWalletId, name).bind()
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import com.tangem.sdk.api.BackupServiceHolder
|
|||
import com.tangem.sdk.api.TangemSdkManager
|
||||
import com.tangem.utils.StringsSigns
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.runSuspendCatching
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -91,7 +92,8 @@ internal class MultiWalletFinalizeModel @Inject constructor(
|
|||
// sets proper artwork state for initial step
|
||||
// (if we start from backup cards, we need to show proper artwork) ([REDACTED_TASK_KEY])
|
||||
when (getInitialStep()) {
|
||||
MultiWalletFinalizeUM.Step.Primary -> { /* state is already set */ }
|
||||
MultiWalletFinalizeUM.Step.Primary -> { /* state is already set */
|
||||
}
|
||||
MultiWalletFinalizeUM.Step.BackupDevice1 -> {
|
||||
onEvent.emit(MultiWalletFinalizeComponent.Event.OneBackupCardAdded)
|
||||
}
|
||||
|
|
@ -299,7 +301,11 @@ internal class MultiWalletFinalizeModel @Inject constructor(
|
|||
.updateWithHotWallet(wallet),
|
||||
)
|
||||
},
|
||||
).getOrElse {
|
||||
).onRight {
|
||||
launch(NonCancellable) {
|
||||
runSuspendCatching { walletsRepository.upgradeWallet(userWalletCreated.walletId) }
|
||||
}
|
||||
}.getOrElse {
|
||||
error("Failed to upgrade to cold wallet. Error: $it")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue