Skip to content

Commit 0f2176b

Browse files
committed
Enable WalletConnect on F-Droid and build it with the shared R8 rules
WalletConnect runs through the Core client on every channel, so the per-channel flag and everything that existed only for it go away: the channel matrix key, BuildConfig.WALLET_CONNECT, IsWalletConnectEnabled, the unsupported dialog and gates in the main screen, and the wallet_connect_available parameter of the Core settings sections. F-Droid now uses the same R8 rules as the other channels, which removes proguard-reproducible-rules.pro and shrinks its APK from about 39.4 MB to 27.8 MB. Two container builds of the change are identical outside the signing block.
1 parent a44a987 commit 0f2176b

16 files changed

Lines changed: 22 additions & 83 deletions

File tree

‎android/app/build.gradle.kts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ android {
9292
.replace("\\", "\\\\")
9393
.replace("\"", "\\\"")
9494
buildConfigField("String", "UPDATE_URL", "\"$resolvedUpdateUrl\"")
95-
buildConfigField("boolean", "WALLET_CONNECT", (channel.getValue("walletConnect") as Boolean).toString())
9695
}
9796
}
9897
}

‎android/app/proguard-reproducible-rules.pro‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎android/app/src/main/kotlin/com/gemwallet/android/MainActivity.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ class MainActivity :
190190
pendingNavigation = pendingNavigation,
191191
systemAuthEnrollmentMissing = systemAuthEnrollmentMissing,
192192
activeWalletConnectRequest = activeWalletConnectRequest,
193-
walletConnectEnabled = viewModel.isWalletConnectEnabled,
194193
toastEvents = viewModel.toastEvents,
195194
onSystemAuthRequired = systemAuthenticator::authenticate,
196195
onPendingNavigationConsumed = viewModel::consumePendingNavigation,

‎android/app/src/main/kotlin/com/gemwallet/android/MainContent.kt‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ import androidx.compose.runtime.remember
1717
import androidx.compose.runtime.setValue
1818
import androidx.compose.ui.Alignment
1919
import androidx.compose.ui.Modifier
20-
import androidx.compose.ui.res.stringResource
2120
import com.gemwallet.android.application.wallet_connect.ActiveWalletConnectRequest
2221
import com.gemwallet.android.features.settings.presents.lock.LockScene
2322
import com.gemwallet.android.features.settings.presents.lock.LockScreen
2423
import com.gemwallet.android.features.settings.presents.lock.UnlockedContent
2524
import com.gemwallet.android.features.settings.viewmodels.lock.models.AuthState
2625
import com.gemwallet.android.features.settings.viewmodels.lock.models.LockUIState
27-
import com.gemwallet.android.ui.R
2826
import com.gemwallet.android.ui.WalletApp
2927
import com.gemwallet.android.ui.components.dialog.ErrorDialog
3028
import com.gemwallet.android.ui.components.screen.SnackbarHost
@@ -44,7 +42,6 @@ internal fun MainContent(
4442
pendingNavigation: PendingNavigation?,
4543
systemAuthEnrollmentMissing: Boolean,
4644
activeWalletConnectRequest: ActiveWalletConnectRequest,
47-
walletConnectEnabled: Boolean,
4845
toastEvents: Flow<ToastMessage>,
4946
onSystemAuthRequired: () -> Unit,
5047
onPendingNavigationConsumed: () -> Unit,
@@ -59,11 +56,6 @@ internal fun MainContent(
5956
val requiresAuthPrompt = lockState.initialAuth == AuthState.Required || lockState.authState == AuthState.Required
6057
val isWalletUnlocked = lockState.isUnlocked
6158
val unlockedPendingRoutes = if (isWalletUnlocked) pendingRoutes else emptyList()
62-
val unsupportedWalletConnectError = if (state.isWalletConnectUnsupportedVisible) {
63-
"${stringResource(R.string.wallet_connect_title)}: ${stringResource(R.string.errors_not_supported)} (${BuildConfig.FLAVOR})"
64-
} else {
65-
null
66-
}
6759
var isWalletContentReady by remember { mutableStateOf(isWalletUnlocked) }
6860
val onWalletContentReady: () -> Unit = remember { { isWalletContentReady = true } }
6961

@@ -81,7 +73,7 @@ internal fun MainContent(
8173
pendingTab = pendingDestination?.tab,
8274
onPendingNavigationConsumed = onPendingNavigationConsumed,
8375
onContentReady = onWalletContentReady,
84-
activeWalletConnectRequest = activeWalletConnectRequest.takeIf { walletConnectEnabled },
76+
activeWalletConnectRequest = activeWalletConnectRequest,
8577
onWalletConnectError = onWalletConnectError,
8678
)
8779
AppToastHost(toastEvents)
@@ -103,7 +95,7 @@ internal fun MainContent(
10395
}
10496

10597
ErrorDialog(
106-
message = (state.walletConnectError ?: unsupportedWalletConnectError ?: state.startupError)?.takeIf { it.isNotEmpty() },
98+
message = (state.walletConnectError ?: state.startupError)?.takeIf { it.isNotEmpty() },
10799
onDismiss = onErrorDismiss,
108100
)
109101
}

‎android/app/src/main/kotlin/com/gemwallet/android/MainViewModel.kt‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.lifecycle.viewModelScope
88
import com.gemwallet.android.application.IoDispatcher
99
import com.gemwallet.android.application.WalletPasswordProtection
1010
import com.gemwallet.android.application.security.cases.SecurityPreferences
11-
import com.gemwallet.android.application.wallet_connect.cases.IsWalletConnectEnabled
1211
import com.gemwallet.android.application.wallet_connect.cases.PairWalletConnect
1312
import com.gemwallet.android.data.services.gemstone.config.UserConfig
1413
import com.gemwallet.android.ext.errorText
@@ -45,7 +44,6 @@ class MainViewModel @Inject constructor(
4544
private val userConfig: UserConfig,
4645
private val securityPreferences: SecurityPreferences,
4746
private val passwordProtection: WalletPasswordProtection,
48-
private val isWalletConnectEnabledCase: IsWalletConnectEnabled,
4947
private val pairWalletConnect: PairWalletConnect,
5048
private val appStartService: GemAppStartServiceInterface,
5149
private val migrateV3KeystoreService: MigrateV3KeystoreService,
@@ -64,25 +62,13 @@ class MainViewModel @Inject constructor(
6462

6563
val toastEvents: Flow<ToastMessage> = toastPresenter.toastEvents
6664

67-
val isWalletConnectEnabled: Boolean = isWalletConnectEnabledCase.isWalletConnectEnabled()
68-
6965
val appearance = userConfig.appearance()
7066
.stateIn(viewModelScope, SharingStarted.Eagerly, Appearance.System)
7167

7268
private val walletConnectHandler = object : PendingNavigationCoordinator.WalletConnectHandler {
73-
override fun onLinkOpened(link: WalletConnectLink) {
74-
if (isWalletConnectEnabled) {
75-
pairWalletConnect.linkOpened(link)
76-
}
77-
}
69+
override fun onLinkOpened(link: WalletConnectLink) = pairWalletConnect.linkOpened(link)
7870
override fun onPairing(uri: String) = addPairing(uri)
79-
override fun onRequest() {
80-
if (isWalletConnectEnabled) {
81-
showWalletConnectPairingToast()
82-
} else {
83-
showWalletConnectUnsupported()
84-
}
85-
}
71+
override fun onRequest() = showWalletConnectPairingToast()
8672
}
8773

8874
private var isMaintained = false
@@ -161,7 +147,6 @@ class MainViewModel @Inject constructor(
161147
it.copy(
162148
walletConnectError = null,
163149
startupError = null,
164-
isWalletConnectUnsupportedVisible = false,
165150
)
166151
}
167152
}
@@ -171,10 +156,6 @@ class MainViewModel @Inject constructor(
171156
}
172157

173158
private fun addPairing(uri: String) {
174-
if (!isWalletConnectEnabled) {
175-
showWalletConnectUnsupported()
176-
return
177-
}
178159
showWalletConnectPairingToast()
179160
viewModelScope.launch(ioDispatcher) {
180161
pairWalletConnect.pair(
@@ -193,9 +174,5 @@ class MainViewModel @Inject constructor(
193174
toastPresenter.emitToast(ToastMessage(text, R.drawable.ic_error))
194175
}
195176

196-
private fun showWalletConnectUnsupported() {
197-
_uiState.update { it.copy(isWalletConnectUnsupportedVisible = true) }
198-
}
199-
200-
data class MainUIState(val walletConnectError: String? = null, val startupError: String? = null, val isWalletConnectUnsupportedVisible: Boolean = false)
177+
data class MainUIState(val walletConnectError: String? = null, val startupError: String? = null)
201178
}

‎android/app/src/main/kotlin/com/gemwallet/android/di/BuildInfoModule.kt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.gemwallet.android.di
33
import android.content.Context
44
import com.gemwallet.android.application.device.cases.RequestPushToken
55
import com.gemwallet.android.application.notifications.cases.ShowSystemNotification
6-
import com.gemwallet.android.application.wallet_connect.cases.IsWalletConnectEnabled
76
import com.gemwallet.android.flavors.StoreRequestPushToken
87
import com.gemwallet.android.flavors.isNotificationsAvailable
98
import com.gemwallet.android.model.BuildInfo
@@ -41,10 +40,6 @@ object BuildInfoModule {
4140
@Singleton
4241
fun provideNotificationEnabled(): NotificationsAvailable = isNotificationsAvailable()
4342

44-
@Provides
45-
@Singleton
46-
fun provideIsWalletConnectEnabled(): IsWalletConnectEnabled = IsWalletConnectEnabled { com.gemwallet.android.BuildConfig.WALLET_CONNECT }
47-
4843
@Provides
4944
@Singleton
5045
fun providePlatformStore(): PlatformStore {

‎android/app/src/test/kotlin/com/gemwallet/android/MainViewModelStartupErrorTest.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class MainViewModelStartupErrorTest {
134134
userConfig = userConfig,
135135
securityPreferences = mockk<SecurityPreferences> { every { authRequired() } returns authRequired },
136136
passwordProtection = protection,
137-
isWalletConnectEnabledCase = mockk(relaxed = true),
138137
pairWalletConnect = mockk(relaxed = true),
139138
appStartService = mockk(relaxed = true),
140139
migrateV3KeystoreService = mockk(relaxed = true),

‎android/features/settings/viewmodels/src/main/kotlin/com/gemwallet/android/features/settings/viewmodels/SettingsViewModel.kt‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.gemwallet.android.application.device.cases.GetPushEnabled
88
import com.gemwallet.android.application.device.cases.RefreshPushEnabled
99
import com.gemwallet.android.application.device.cases.SwitchPushEnabled
1010
import com.gemwallet.android.application.preferences.cases.ObservablePreferences
11-
import com.gemwallet.android.application.wallet_connect.cases.IsWalletConnectEnabled
1211
import com.gemwallet.android.data.services.store.queries.WalletListItemsQuery
1312
import com.gemwallet.android.ext.toGem
1413
import com.gemwallet.android.model.NotificationsAvailable
@@ -42,7 +41,6 @@ class SettingsViewModel @Inject constructor(
4241
private val refreshPushEnabled: RefreshPushEnabled,
4342
val notificationsAvailable: NotificationsAvailable,
4443
private val settingsService: GemSettingsServiceInterface,
45-
private val isWalletConnectEnabled: IsWalletConnectEnabled,
4644
@param:IoDispatcher private val ioDispatcher: CoroutineDispatcher,
4745
@param:ApplicationContext private val context: Context,
4846
) : ViewModel() {
@@ -54,7 +52,6 @@ class SettingsViewModel @Inject constructor(
5452
settingsService.sections(
5553
wallets = wallets.map { it.toGem() },
5654
notificationsAvailable = notificationsAvailable,
57-
walletConnectAvailable = isWalletConnectEnabled.isWalletConnectEnabled(),
5855
)
5956
}
6057
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())

‎android/features/settings/viewmodels/src/test/kotlin/com/gemwallet/android/features/settings/viewmodels/SettingsViewModelTest.kt‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ class SettingsViewModelTest {
126126

127127
@Test
128128
fun `the rows follow core's answer for the loaded wallets`() = runTest(testDispatcher) {
129-
every { settingsService.sections(any(), any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets))
129+
every { settingsService.sections(any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets))
130130
wallets.value = listOf(mockWalletListItem(id = WalletId("single_ethereum_0x1")))
131131
viewModel = createViewModel()
132132
advanceUntilIdle()
133133

134134
assertEquals(listOf(SettingsAction.Wallets), viewModel.actions().first { it.isNotEmpty() })
135135

136-
every { settingsService.sections(any(), any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets, GemListRowTitle.REWARDS to GemRowAction.Rewards))
136+
every { settingsService.sections(any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets, GemListRowTitle.REWARDS to GemRowAction.Rewards))
137137
wallets.value = listOf(mockWalletListItem())
138138
advanceUntilIdle()
139139

@@ -150,7 +150,7 @@ class SettingsViewModelTest {
150150
)
151151

152152
private val settingsService = mockk<GemSettingsServiceInterface>(relaxed = true).also {
153-
every { it.sections(any(), any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets))
153+
every { it.sections(any(), any()) } returns listOf(section(GemListRowTitle.WALLETS to GemRowAction.Wallets))
154154
}
155155

156156
private fun createViewModel() = SettingsViewModel(
@@ -161,7 +161,6 @@ class SettingsViewModelTest {
161161
refreshPushEnabled = refreshPushEnabled,
162162
notificationsAvailable = true,
163163
settingsService = settingsService,
164-
isWalletConnectEnabled = mockk { every { isWalletConnectEnabled() } returns true },
165164
ioDispatcher = testDispatcher,
166165
context = mockk<Context> { every { getString(any()) } answers { "string:${firstArg<Int>()}" } },
167166
)

‎android/gemcore/src/main/kotlin/com/gemwallet/android/application/wallet_connect/cases/IsWalletConnectEnabled.kt‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)