diff --git a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt index 8b6d838b..8127ec64 100644 --- a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt +++ b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/presentation/viewmodel/MainViewModel.kt @@ -1471,20 +1471,26 @@ class MainViewModel @Inject constructor( // 保存交易记录到本地数据库 val state = _transferState.value android.util.Log.d("MainViewModel", "[BROADCAST] Saving transaction record: shareId=${state.shareId}, tokenType=${state.tokenType}") - repository.saveTransactionRecord( - shareId = state.shareId, - fromAddress = tx.from, - toAddress = tx.to, - amount = state.amount, - tokenType = state.tokenType, - txHash = hash, - gasPrice = tx.gasPrice.toString() - ) + try { + repository.saveTransactionRecord( + shareId = state.shareId, + fromAddress = tx.from, + toAddress = tx.to, + amount = state.amount, + tokenType = state.tokenType, + txHash = hash, + gasPrice = tx.gasPrice.toString() + ) + android.util.Log.d("MainViewModel", "[BROADCAST] Transaction record saved successfully") - // 启动后台确认交易状态 - confirmTransactionInBackground(hash, rpcUrl) + // 启动后台确认交易状态 + confirmTransactionInBackground(hash, rpcUrl) - _uiState.update { it.copy(isLoading = false, successMessage = "交易已广播!") } + _uiState.update { it.copy(isLoading = false, successMessage = "交易已广播!") } + } catch (e: Exception) { + android.util.Log.e("MainViewModel", "[BROADCAST] Failed to save transaction record: ${e.message}", e) + _uiState.update { it.copy(isLoading = false, error = "交易已广播但保存记录失败: ${e.message}") } + } }, onFailure = { e -> android.util.Log.e("MainViewModel", "[BROADCAST] FAILED: ${e.message}", e)