Skip to content

Commit

Permalink
Rename prefix wc2 to wc for WalletConnect classes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Feb 15, 2024
1 parent 3a48e84 commit b314ca8
Show file tree
Hide file tree
Showing 28 changed files with 117 additions and 121 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ import io.horizontalsystems.bankwallet.modules.settings.appearance.AppIconServic
import io.horizontalsystems.bankwallet.modules.settings.appearance.LaunchScreenService
import io.horizontalsystems.bankwallet.modules.theme.ThemeService
import io.horizontalsystems.bankwallet.modules.theme.ThemeType
import io.horizontalsystems.bankwallet.modules.walletconnect.storage.WC2SessionStorage
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.storage.WCSessionStorage
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCSessionManager
import io.horizontalsystems.bankwallet.widgets.MarketWidgetManager
import io.horizontalsystems.bankwallet.widgets.MarketWidgetRepository
Expand Down Expand Up @@ -163,8 +163,8 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory {
lateinit var accountCleaner: IAccountCleaner
lateinit var rateAppManager: IRateAppManager
lateinit var coinManager: ICoinManager
lateinit var wc2SessionManager: WCSessionManager
lateinit var wc2Manager: WC2Manager
lateinit var wcSessionManager: WCSessionManager
lateinit var wcManager: WCManager
lateinit var termsManager: ITermsManager
lateinit var marketFavoritesManager: MarketFavoritesManager
lateinit var marketKit: MarketKitWrapper
Expand Down Expand Up @@ -366,7 +366,7 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory {

rateAppManager = RateAppManager(walletManager, adapterManager, localStorage)

wc2Manager = WC2Manager(accountManager)
wcManager = WCManager(accountManager)

termsManager = TermsManager(localStorage)

Expand Down Expand Up @@ -394,7 +394,7 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory {

initializeWalletConnectV2(appConfig)

wc2SessionManager = WCSessionManager(accountManager, WC2SessionStorage(appDatabase))
wcSessionManager = WCSessionManager(accountManager, WCSessionStorage(appDatabase))

baseTokenManager = BaseTokenManager(coinManager, localStorage)
balanceViewTypeManager = BalanceViewTypeManager(localStorage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import io.horizontalsystems.bankwallet.modules.pin.core.PinDao
import io.horizontalsystems.bankwallet.modules.profeatures.storage.ProFeaturesDao
import io.horizontalsystems.bankwallet.modules.profeatures.storage.ProFeaturesSessionKey
import io.horizontalsystems.bankwallet.modules.walletconnect.storage.WalletConnectV2Session
import io.horizontalsystems.bankwallet.modules.walletconnect.storage.WC2SessionDao
import io.horizontalsystems.bankwallet.modules.walletconnect.storage.WCSessionDao

@Database(version = 58, exportSchema = false, entities = [
EnabledWallet::class,
Expand Down Expand Up @@ -59,7 +59,7 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun restoreSettingDao(): RestoreSettingDao
abstract fun logsDao(): LogsDao
abstract fun marketFavoritesDao(): MarketFavoritesDao
abstract fun wc2SessionDao(): WC2SessionDao
abstract fun wcSessionDao(): WCSessionDao
abstract fun nftDao(): NftDao
abstract fun proFeaturesDao(): ProFeaturesDao
abstract fun evmAddressLabelDao(): EvmAddressLabelDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object BalanceModule {
App.balanceViewTypeManager,
TotalBalance(totalService, App.balanceHiddenManager),
App.localStorage,
App.wc2Manager,
App.wcManager,
AddressHandlerFactory(App.appConfigProvider.udnApiKey),
) as T
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import io.horizontalsystems.bankwallet.entities.Wallet
import io.horizontalsystems.bankwallet.modules.address.AddressHandlerFactory
import io.horizontalsystems.bankwallet.modules.walletconnect.list.WalletConnectListModule
import io.horizontalsystems.bankwallet.modules.walletconnect.list.WalletConnectListViewModel
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.marketkit.models.BlockchainType
import io.horizontalsystems.marketkit.models.TokenType
import kotlinx.coroutines.Dispatchers
Expand All @@ -38,7 +38,7 @@ class BalanceViewModel(
private val balanceViewTypeManager: BalanceViewTypeManager,
private val totalBalance: TotalBalance,
private val localStorage: ILocalStorage,
private val wC2Manager: WC2Manager,
private val wCManager: WCManager,
private val addressHandlerFactory: AddressHandlerFactory,
) : ViewModel(), ITotalBalance by totalBalance {

Expand Down Expand Up @@ -212,8 +212,8 @@ class BalanceViewModel(
}
}

fun getWalletConnectSupportState(): WC2Manager.SupportState {
return wC2Manager.getWalletConnectSupportState()
fun getWalletConnectSupportState(): WCManager.SupportState {
return wCManager.getWalletConnectSupportState()
}

fun handleScannedData(scannedText: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import io.horizontalsystems.bankwallet.modules.qrscanner.QRScannerActivity
import io.horizontalsystems.bankwallet.modules.swap.settings.Caution
import io.horizontalsystems.bankwallet.modules.walletconnect.WCAccountTypeNotSupportedDialog
import io.horizontalsystems.bankwallet.modules.walletconnect.list.WalletConnectListViewModel
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.TranslatableString
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
Expand Down Expand Up @@ -139,23 +139,23 @@ fun BalanceForAccount(navController: NavController, accountViewItem: AccountView
icon = R.drawable.ic_qr_scan_20,
onClick = {
when (val state = viewModel.getWalletConnectSupportState()) {
WC2Manager.SupportState.Supported -> {
WCManager.SupportState.Supported -> {
qrScannerLauncher.launch(QRScannerActivity.getScanQrIntent(context, true))
}

WC2Manager.SupportState.NotSupportedDueToNoActiveAccount -> {
WCManager.SupportState.NotSupportedDueToNoActiveAccount -> {
navController.slideFromBottom(R.id.wcErrorNoAccountFragment)
}

is WC2Manager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
val text = Translator.getString(R.string.WalletConnect_Error_NeedBackup)
navController.slideFromBottom(
R.id.backupRequiredDialog,
BackupRequiredDialog.Input(state.account, text)
)
}

is WC2Manager.SupportState.NotSupported -> {
is WCManager.SupportState.NotSupported -> {
navController.slideFromBottom(
R.id.wcAccountTypeNotSupportedDialog,
WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.horizontalsystems.bankwallet.modules.main

import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.flowWithLifecycle
Expand Down Expand Up @@ -53,7 +52,7 @@ class MainActivity : BaseActivity() {
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
.onEach { event ->
when (event) {
is SignEvent.SessionProposal -> navController.slideFromBottom(R.id.wc2SessionFragment)
is SignEvent.SessionProposal -> navController.slideFromBottom(R.id.wcSessionFragment)
is SignEvent.SessionRequest -> {
navController.slideFromBottom(R.id.wcRequestFragment,)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import io.horizontalsystems.bankwallet.modules.transactions.TransactionsModule
import io.horizontalsystems.bankwallet.modules.transactions.TransactionsScreen
import io.horizontalsystems.bankwallet.modules.transactions.TransactionsViewModel
import io.horizontalsystems.bankwallet.modules.walletconnect.WCAccountTypeNotSupportedDialog
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager.SupportState
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager.SupportState
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.DisposableLifecycleCallbacks
import io.horizontalsystems.bankwallet.ui.compose.components.HsBottomNavigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.lifecycle.ViewModelProvider
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.bankwallet.entities.Account
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import kotlinx.parcelize.Parcelize

object MainModule {
Expand All @@ -26,8 +26,8 @@ object MainModule {
App.accountManager,
App.releaseNotesManager,
App.localStorage,
App.wc2SessionManager,
App.wc2Manager,
App.wcSessionManager,
App.wcManager,
wcDeepLink
) as T
}
Expand Down Expand Up @@ -82,7 +82,7 @@ object MainModule {
val showWhatsNew: Boolean,
val activeWallet: Account?,
val torEnabled: Boolean,
val wcSupportState: WC2Manager.SupportState?
val wcSupportState: WCManager.SupportState?
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.horizontalsystems.bankwallet.modules.main.MainModule.MainNavigation
import io.horizontalsystems.bankwallet.modules.market.topplatforms.Platform
import io.horizontalsystems.bankwallet.modules.nft.collection.NftCollectionFragment
import io.horizontalsystems.bankwallet.modules.walletconnect.list.WCListFragment
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCSessionManager
import io.horizontalsystems.core.IPinComponent
import io.reactivex.disposables.CompositeDisposable
Expand All @@ -39,13 +39,13 @@ class MainViewModel(
private val accountManager: IAccountManager,
private val releaseNotesManager: ReleaseNotesManager,
private val localStorage: ILocalStorage,
wc2SessionManager: WCSessionManager,
private val wc2Manager: WC2Manager,
wcSessionManager: WCSessionManager,
private val wcManager: WCManager,
deepLink: Uri?
) : ViewModel() {

private val disposables = CompositeDisposable()
private var wc2PendingRequestsCount = 0
private var wcPendingRequestsCount = 0
private var marketsTabEnabled = localStorage.marketsTabEnabledFlow.value
private var transactionsEnabled = isTransactionsTabEnabled()
private var settingsBadge: MainModule.BadgeType? = null
Expand Down Expand Up @@ -87,7 +87,7 @@ class MainViewModel(
private var contentHidden = pinComponent.isLocked
private var showWhatsNew = false
private var activeWallet = accountManager.activeAccount
private var wcSupportState: WC2Manager.SupportState? = null
private var wcSupportState: WCManager.SupportState? = null
private var torEnabled = localStorage.torEnabled

val wallets: List<Account>
Expand Down Expand Up @@ -121,8 +121,8 @@ class MainViewModel(
updateSettingsBadge()
}

wc2SessionManager.pendingRequestCountFlow.collectWith(viewModelScope) {
wc2PendingRequestsCount = it
wcSessionManager.pendingRequestCountFlow.collectWith(viewModelScope) {
wcPendingRequestsCount = it
updateSettingsBadge()
}

Expand Down Expand Up @@ -333,8 +333,8 @@ class MainViewModel(
}

deeplinkString.startsWith("wc:") -> {
wcSupportState = wc2Manager.getWalletConnectSupportState()
if (wcSupportState == WC2Manager.SupportState.Supported) {
wcSupportState = wcManager.getWalletConnectSupportState()
if (wcSupportState == WCManager.SupportState.Supported) {
deeplinkPage = DeeplinkPage(R.id.wcListFragment, WCListFragment.Input(deeplinkString))
tab = MainNavigation.Settings
}
Expand Down Expand Up @@ -367,8 +367,8 @@ class MainViewModel(
val showDotBadge =
!(backupManager.allBackedUp && termsManager.allTermsAccepted && pinComponent.isPinSet) || accountManager.hasNonStandardAccount

settingsBadge = if (wc2PendingRequestsCount > 0) {
MainModule.BadgeType.BadgeNumber(wc2PendingRequestsCount)
settingsBadge = if (wcPendingRequestsCount > 0) {
MainModule.BadgeType.BadgeNumber(wcPendingRequestsCount)
} else if (showDotBadge) {
MainModule.BadgeType.BadgeDot
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object MainSettingsModule {
App.currencyManager,
App.termsManager,
App.pinComponent,
App.wc2SessionManager,
App.wc2Manager,
App.wcSessionManager,
App.wcManager,
App.accountManager,
App.appConfigProvider,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import io.horizontalsystems.bankwallet.modules.manageaccount.dialogs.BackupRequi
import io.horizontalsystems.bankwallet.modules.manageaccounts.ManageAccountsModule
import io.horizontalsystems.bankwallet.modules.settings.main.MainSettingsModule.CounterType
import io.horizontalsystems.bankwallet.modules.walletconnect.WCAccountTypeNotSupportedDialog
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.BadgeCount
Expand Down Expand Up @@ -147,20 +147,20 @@ private fun SettingSections(
counterBadge = (wcCounter as? CounterType.PendingRequestCounter)?.number?.toString(),
onClick = {
when (val state = viewModel.getWalletConnectSupportState()) {
WC2Manager.SupportState.Supported -> {
WCManager.SupportState.Supported -> {
navController.slideFromRight(R.id.wcListFragment)
}
WC2Manager.SupportState.NotSupportedDueToNoActiveAccount -> {
WCManager.SupportState.NotSupportedDueToNoActiveAccount -> {
navController.slideFromBottom(R.id.wcErrorNoAccountFragment)
}
is WC2Manager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
val text = Translator.getString(R.string.WalletConnect_Error_NeedBackup)
navController.slideFromBottom(
R.id.backupRequiredDialog,
BackupRequiredDialog.Input(state.account, text)
)
}
is WC2Manager.SupportState.NotSupported -> {
is WCManager.SupportState.NotSupported -> {
navController.slideFromBottom(
R.id.wcAccountTypeNotSupportedDialog,
WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import io.horizontalsystems.bankwallet.core.managers.LanguageManager
import io.horizontalsystems.bankwallet.core.providers.AppConfigProvider
import io.horizontalsystems.bankwallet.core.providers.Translator
import io.horizontalsystems.bankwallet.entities.Currency
import io.horizontalsystems.bankwallet.modules.walletconnect.WC2Manager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager
import io.horizontalsystems.bankwallet.modules.walletconnect.WCSessionManager
import io.horizontalsystems.core.IPinComponent
import io.horizontalsystems.core.ISystemInfoManager
Expand All @@ -27,8 +27,8 @@ class MainSettingsService(
private val currencyManager: CurrencyManager,
private val termsManager: ITermsManager,
private val pinComponent: IPinComponent,
private val wc2SessionManager: WCSessionManager,
private val wc2Manager: WC2Manager,
private val wcSessionManager: WCSessionManager,
private val wcManager: WCManager,
private val accountManager: IAccountManager,
private val appConfigProvider: AppConfigProvider
) {
Expand Down Expand Up @@ -68,10 +68,10 @@ class MainSettingsService(
val allBackedUp: Boolean
get() = backupManager.allBackedUp

val pendingRequestCountFlow by wc2SessionManager::pendingRequestCountFlow
val pendingRequestCountFlow by wcSessionManager::pendingRequestCountFlow

val walletConnectSessionCount: Int
get() = wc2SessionManager.sessions.count()
get() = wcSessionManager.sessions.count()

val currentLanguageDisplayName: String
get() = languageManager.currentLanguageName
Expand All @@ -88,7 +88,7 @@ class MainSettingsService(
})

coroutineScope.launch {
wc2SessionManager.sessionsFlow.collect{
wcSessionManager.sessionsFlow.collect{
walletConnectSessionCountSubject.onNext(walletConnectSessionCount)
}
}
Expand All @@ -106,7 +106,7 @@ class MainSettingsService(
disposables.clear()
}

fun getWalletConnectSupportState(): WC2Manager.SupportState {
return wc2Manager.getWalletConnectSupportState()
fun getWalletConnectSupportState(): WCManager.SupportState {
return wcManager.getWalletConnectSupportState()
}
}
Loading

0 comments on commit b314ca8

Please sign in to comment.