Skip to content

Commit 60519ee

Browse files
chore(config): migrate some remote config to Statsig and remove legacy configs (#6473)
### Description This PR removes some unused remote config configs, and replaces the following with statsig: - wallet connect v2 enabled -> feature gate (note that feature gates always default to false, but we should default this value to true since then builders can access wallet connect without a statsig account, [context](https://valora-app.slack.com/archives/C025V1D6F3J/p1722383273562829)) - celo education url -> new item in app_config links Note that the expanded pincode blocklist remote config flag doesn't actually exist in the remote config console - so it is always defaulting to false, so i've just removed the functionality. Removed unused config: - logPhoneNumberTypeEnabled - pincodeUseExpandedBlocklist - coinbasePayEnabled - maxSwapSlippagePercentage - networkTimeoutSeconds ### Test plan n/a ### Related issues - Related to RET-1272 ### Backwards compatibility Y ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [ ] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
1 parent 4bcb306 commit 60519ee

23 files changed

+110
-273
lines changed

src/app/reducers.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,17 @@ interface State {
2121
locked: boolean
2222
lastTimeBackgrounded: number
2323
sessionId: string
24-
celoEducationUri: string | null
2524
activeScreen: Screens
26-
walletConnectV2Enabled: boolean
2725
// In 1.13 we had a critical error which requires a migration to fix. See |verificationMigration.ts|
2826
// for the migration code. We can remove all the code associated with this after some time has passed.
29-
logPhoneNumberTypeEnabled: boolean
3027
googleMobileServicesAvailable?: boolean
3128
huaweiMobileServicesAvailable?: boolean
32-
pincodeUseExpandedBlocklist: boolean
3329
sentryTracesSampleRate: number
3430
sentryNetworkErrors: string[]
3531
supportedBiometryType: BIOMETRY_TYPE | null
3632
fiatConnectCashInEnabled: boolean
3733
fiatConnectCashOutEnabled: boolean
38-
coinbasePayEnabled: boolean
39-
maxSwapSlippagePercentage: number
4034
inviterAddress: string | null
41-
networkTimeoutSeconds: number
4235
celoNews: CeloNewsConfig
4336
hapticFeedbackEnabled: boolean
4437
pushNotificationRequestedUnixTime: number | null
@@ -63,22 +56,15 @@ const initialState = {
6356
locked: false,
6457
lastTimeBackgrounded: 0,
6558
sessionId: '',
66-
celoEducationUri: null,
6759
activeScreen: Screens.Main,
68-
walletConnectV2Enabled: REMOTE_CONFIG_VALUES_DEFAULTS.walletConnectV2Enabled,
69-
logPhoneNumberTypeEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.logPhoneNumberTypeEnabled,
7060
googleMobileServicesAvailable: undefined,
7161
huaweiMobileServicesAvailable: undefined,
72-
pincodeUseExpandedBlocklist: REMOTE_CONFIG_VALUES_DEFAULTS.pincodeUseExpandedBlocklist,
7362
sentryTracesSampleRate: REMOTE_CONFIG_VALUES_DEFAULTS.sentryTracesSampleRate,
7463
sentryNetworkErrors: REMOTE_CONFIG_VALUES_DEFAULTS.sentryNetworkErrors.split(','),
7564
supportedBiometryType: null,
7665
fiatConnectCashInEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashInEnabled,
7766
fiatConnectCashOutEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashOutEnabled,
78-
coinbasePayEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.coinbasePayEnabled,
79-
maxSwapSlippagePercentage: REMOTE_CONFIG_VALUES_DEFAULTS.maxSwapSlippagePercentage,
8067
inviterAddress: null,
81-
networkTimeoutSeconds: REMOTE_CONFIG_VALUES_DEFAULTS.networkTimeoutSeconds,
8268
celoNews: JSON.parse(REMOTE_CONFIG_VALUES_DEFAULTS.celoNews),
8369
hapticFeedbackEnabled: true,
8470
pushNotificationRequestedUnixTime: null,
@@ -167,17 +153,10 @@ export const appReducer = (
167153
case Actions.UPDATE_REMOTE_CONFIG_VALUES:
168154
return {
169155
...state,
170-
celoEducationUri: action.configValues.celoEducationUri,
171-
walletConnectV2Enabled: action.configValues.walletConnectV2Enabled,
172-
logPhoneNumberTypeEnabled: action.configValues.logPhoneNumberTypeEnabled,
173-
pincodeUseExpandedBlocklist: action.configValues.pincodeUseExpandedBlocklist,
174156
sentryTracesSampleRate: action.configValues.sentryTracesSampleRate,
175157
sentryNetworkErrors: action.configValues.sentryNetworkErrors,
176158
fiatConnectCashInEnabled: action.configValues.fiatConnectCashInEnabled,
177159
fiatConnectCashOutEnabled: action.configValues.fiatConnectCashOutEnabled,
178-
coinbasePayEnabled: action.configValues.coinbasePayEnabled,
179-
maxSwapSlippagePercentage: action.configValues.maxSwapSlippagePercentage,
180-
networkTimeoutSeconds: action.configValues.networkTimeoutSeconds,
181160
celoNews: action.configValues.celoNews,
182161
}
183162
case Actions.ACTIVE_SCREEN_CHANGED:

src/app/saga.test.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ import { allowHooksPreviewSelector } from 'src/positions/selectors'
4646
import { handlePaymentDeeplink } from 'src/send/utils'
4747
import { initializeSentry } from 'src/sentry/Sentry'
4848
import { getDynamicConfigParams, getFeatureGate, patchUpdateStatsigUser } from 'src/statsig'
49+
import { StatsigFeatureGates } from 'src/statsig/types'
4950
import { NetworkId } from 'src/transactions/types'
5051
import { navigateToURI } from 'src/utils/linking'
5152
import Logger from 'src/utils/Logger'
5253
import { ONE_DAY_IN_MILLIS } from 'src/utils/time'
53-
import { initialiseWalletConnect } from 'src/walletConnect/saga'
54+
import { _setClientForTesting, initialiseWalletConnect } from 'src/walletConnect/saga'
5455
import { selectHasPendingState } from 'src/walletConnect/selectors'
5556
import { WalletConnectRequestType } from 'src/walletConnect/types'
5657
import { handleWalletConnectDeepLink } from 'src/walletConnect/walletConnect'
@@ -286,6 +287,7 @@ describe('handleDeepLink', () => {
286287
describe('WalletConnect deeplinks', () => {
287288
beforeEach(() => {
288289
jest.clearAllMocks()
290+
_setClientForTesting({} as any)
289291
})
290292

291293
const connectionString = encodeURIComponent(
@@ -619,7 +621,12 @@ describe(requestInAppReview, () => {
619621
`(
620622
`Should show when isAvailable: true, Last Interaction: $lastInteraction and Wallet Address: 0xTest`,
621623
async ({ lastInteractionTimestamp }) => {
622-
jest.mocked(getFeatureGate).mockReturnValue(true)
624+
jest.mocked(getFeatureGate).mockImplementation((featureGate) => {
625+
if (featureGate === StatsigFeatureGates.APP_REVIEW) {
626+
return true
627+
}
628+
return false
629+
})
623630
mockIsInAppReviewAvailable.mockReturnValue(true)
624631
mockRequestInAppReview.mockResolvedValue(true)
625632

@@ -648,7 +655,12 @@ describe(requestInAppReview, () => {
648655
`(
649656
`Should not show when Device Available: $isAvailable, Feature Gate: $featureGate, Last Interaction: $lastInteraction and Wallet Address: $walletAddress`,
650657
async ({ lastInteractionTimestamp, isAvailable, featureGate, walletAddress }) => {
651-
jest.mocked(getFeatureGate).mockReturnValue(featureGate)
658+
jest.mocked(getFeatureGate).mockImplementation((gate) => {
659+
if (gate === StatsigFeatureGates.APP_REVIEW) {
660+
return featureGate
661+
}
662+
return false
663+
})
652664
mockIsInAppReviewAvailable.mockReturnValue(isAvailable)
653665
mockRequestInAppReview.mockResolvedValue(true)
654666

@@ -668,7 +680,12 @@ describe(requestInAppReview, () => {
668680
)
669681

670682
it('Should handle error from react-native-in-app-review', async () => {
671-
jest.mocked(getFeatureGate).mockReturnValue(true)
683+
jest.mocked(getFeatureGate).mockImplementation((featureGate) => {
684+
if (featureGate === StatsigFeatureGates.APP_REVIEW) {
685+
return true
686+
}
687+
return false
688+
})
672689
mockIsInAppReviewAvailable.mockReturnValue(true)
673690
mockRequestInAppReview.mockRejectedValue(new Error('🤖💥'))
674691

src/app/saga.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,8 @@ export function* checkAndroidMobileServicesSaga() {
176176
}
177177

178178
export interface RemoteConfigValues {
179-
celoEducationUri: string | null
180179
dappListApiUrl: string | null
181180
inviteRewardsVersion: string
182-
walletConnectV2Enabled: boolean
183-
logPhoneNumberTypeEnabled: boolean
184-
pincodeUseExpandedBlocklist: boolean
185181
allowOtaTranslations: boolean
186182
sentryTracesSampleRate: number
187183
sentryNetworkErrors: string[]
@@ -190,9 +186,6 @@ export interface RemoteConfigValues {
190186
fiatConnectCashInEnabled: boolean
191187
fiatConnectCashOutEnabled: boolean
192188
fiatAccountSchemaCountryOverrides: FiatAccountSchemaCountryOverrides
193-
coinbasePayEnabled: boolean
194-
maxSwapSlippagePercentage: number
195-
networkTimeoutSeconds: number
196189
celoNews: CeloNewsConfig
197190
priceImpactWarningThreshold: number
198191
}

src/app/selectors.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ export const sessionIdSelector = (state: RootState) => {
2424
return state.app.sessionId
2525
}
2626

27-
// this can be called with undefined state in the tests
28-
export const walletConnectEnabledSelector = (state?: RootState) => ({
29-
v2: state?.app.walletConnectV2Enabled ?? false,
30-
})
31-
32-
export const logPhoneNumberTypeEnabledSelector = (state: RootState) =>
33-
state.app.logPhoneNumberTypeEnabled
34-
3527
export const googleMobileServicesAvailableSelector = (state: RootState) =>
3628
state.app.googleMobileServicesAvailable
3729

@@ -49,15 +41,10 @@ export const fiatConnectCashInEnabledSelector = (state: RootState) =>
4941
export const fiatConnectCashOutEnabledSelector = (state: RootState) =>
5042
state.app.fiatConnectCashOutEnabled
5143

52-
export const maxSwapSlippagePercentageSelector = (state: RootState) =>
53-
state.app.maxSwapSlippagePercentage
54-
5544
export const phoneNumberVerifiedSelector = (state: RootState) => state.app.phoneNumberVerified
5645

5746
export const inviterAddressSelector = (state: RootState) => state.app.inviterAddress
5847

59-
export const networkTimeoutSecondsSelector = (state: RootState) => state.app.networkTimeoutSeconds
60-
6148
export const celoNewsConfigSelector = (state: RootState) => state.app.celoNews
6249

6350
export const hapticFeedbackEnabledSelector = (state: RootState) => state.app.hapticFeedbackEnabled

src/firebase/firebase.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,8 @@ export async function fetchRemoteConfigValues(): Promise<RemoteConfigValues | nu
274274
const celoNewsString = flags.celoNews?.asString()
275275

276276
return {
277-
// these next 2 flags are a bit weird because their default is undefined or null
278-
// and the default map cannot have a value of undefined or null
279-
// that is why we still need to check for it before calling a method
280-
// in the future it would be great to avoid using these as default values
281-
celoEducationUri: flags.celoEducationUri?.asString() ?? null,
282277
dappListApiUrl: flags.dappListApiUrl?.asString() ?? null,
283278
inviteRewardsVersion: flags.inviteRewardsVersion.asString(),
284-
walletConnectV2Enabled: flags.walletConnectV2Enabled.asBoolean(),
285-
pincodeUseExpandedBlocklist: flags.pincodeUseExpandedBlocklist.asBoolean(),
286-
logPhoneNumberTypeEnabled: flags.logPhoneNumberTypeEnabled.asBoolean(),
287279
allowOtaTranslations: flags.allowOtaTranslations.asBoolean(),
288280
sentryTracesSampleRate: flags.sentryTracesSampleRate.asNumber(),
289281
sentryNetworkErrors: flags.sentryNetworkErrors.asString().split(','),
@@ -294,9 +286,6 @@ export async function fetchRemoteConfigValues(): Promise<RemoteConfigValues | nu
294286
fiatAccountSchemaCountryOverrides: fiatAccountSchemaCountryOverrides
295287
? JSON.parse(fiatAccountSchemaCountryOverrides)
296288
: {},
297-
coinbasePayEnabled: flags.coinbasePayEnabled.asBoolean(),
298-
maxSwapSlippagePercentage: flags.maxSwapSlippagePercentage.asNumber(),
299-
networkTimeoutSeconds: flags.networkTimeoutSeconds.asNumber(),
300289
celoNews: celoNewsString ? JSON.parse(celoNewsString) : {},
301290
// Convert to percentage, so we're consistent with the price impact value returned by our swap API
302291
priceImpactWarningThreshold: flags.priceImpactWarningThreshold.asNumber() * 100,

src/firebase/remoteConfigValuesDefaults.e2e.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import { RemoteConfigValues } from 'src/app/saga'
22

33
export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
44
RemoteConfigValues,
5-
'celoEducationUri' | 'sentryNetworkErrors' | 'fiatAccountSchemaCountryOverrides' | 'celoNews'
5+
'sentryNetworkErrors' | 'fiatAccountSchemaCountryOverrides' | 'celoNews'
66
> & {
77
sentryNetworkErrors: string
88
celoNews: string
99
} = {
1010
inviteRewardsVersion: 'none',
11-
walletConnectV2Enabled: true,
12-
pincodeUseExpandedBlocklist: true,
13-
logPhoneNumberTypeEnabled: false,
1411
allowOtaTranslations: false,
1512
sentryTracesSampleRate: 0.2,
1613
sentryNetworkErrors: '',
@@ -19,9 +16,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
1916
dappsWebViewEnabled: true,
2017
fiatConnectCashInEnabled: false,
2118
fiatConnectCashOutEnabled: true,
22-
coinbasePayEnabled: false,
23-
maxSwapSlippagePercentage: 2,
24-
networkTimeoutSeconds: 30,
2519
celoNews: JSON.stringify({} as RemoteConfigValues['celoNews']),
2620
priceImpactWarningThreshold: 0.04,
2721
}

src/firebase/remoteConfigValuesDefaults.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import { DEFAULT_SENTRY_NETWORK_ERRORS, DEFAULT_SENTRY_TRACES_SAMPLE_RATE } from
33

44
export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
55
RemoteConfigValues,
6-
'celoEducationUri' | 'sentryNetworkErrors' | 'fiatAccountSchemaCountryOverrides' | 'celoNews'
6+
'sentryNetworkErrors' | 'fiatAccountSchemaCountryOverrides' | 'celoNews'
77
> & {
88
sentryNetworkErrors: string
99
dappListApiUrl: string
1010
celoNews: string
1111
} = {
1212
inviteRewardsVersion: 'none',
13-
walletConnectV2Enabled: true,
14-
pincodeUseExpandedBlocklist: false,
15-
logPhoneNumberTypeEnabled: false,
1613
allowOtaTranslations: false,
1714
sentryTracesSampleRate: DEFAULT_SENTRY_TRACES_SAMPLE_RATE,
1815
sentryNetworkErrors: DEFAULT_SENTRY_NETWORK_ERRORS.join(','),
@@ -21,9 +18,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
2118
dappListApiUrl: '',
2219
fiatConnectCashInEnabled: false,
2320
fiatConnectCashOutEnabled: false,
24-
coinbasePayEnabled: false,
25-
maxSwapSlippagePercentage: 2,
26-
networkTimeoutSeconds: 30,
2721
celoNews: JSON.stringify({} as RemoteConfigValues['celoNews']),
2822
priceImpactWarningThreshold: 0.04,
2923
}

src/navigator/SettingsMenu.test.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ import { clearStoredAccount } from 'src/account/actions'
66
import { navigate } from 'src/navigator/NavigationService'
77
import { Screens } from 'src/navigator/Screens'
88
import SettingsMenu from 'src/navigator/SettingsMenu'
9+
import { getFeatureGate, getMultichainFeatures } from 'src/statsig'
10+
import { StatsigFeatureGates } from 'src/statsig/types'
11+
import { NetworkId } from 'src/transactions/types'
912
import MockedNavigator from 'test/MockedNavigator'
1013
import { createMockStore } from 'test/utils'
1114
import { mockE164Number } from 'test/values'
1215

13-
jest.mock('src/statsig', () => ({
14-
...jest.requireActual('src/statsig'),
15-
getFeatureGate: jest.fn().mockReturnValue(false),
16-
getMultichainFeatures: jest.fn(() => ({
17-
showBalances: ['celo-alfajores'],
18-
})),
19-
}))
16+
jest.mock('src/statsig')
17+
jest.mocked(getMultichainFeatures).mockReturnValue({
18+
showBalances: [NetworkId['celo-alfajores']],
19+
})
20+
jest.mocked(getFeatureGate).mockImplementation((gate) => {
21+
if (gate === StatsigFeatureGates.DISABLE_WALLET_CONNECT_V2) {
22+
return false
23+
}
24+
throw new Error('Unexpected gate')
25+
})
2026

2127
jest.mock('statsig-react-native', () => ({
2228
Statsig: {

src/navigator/SettingsMenu.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222
import AppAnalytics from 'src/analytics/AppAnalytics'
2323
import { SettingsEvents } from 'src/analytics/Events'
2424
import { setSessionId } from 'src/app/actions'
25-
import {
26-
phoneNumberVerifiedSelector,
27-
sessionIdSelector,
28-
walletConnectEnabledSelector,
29-
} from 'src/app/selectors'
25+
import { phoneNumberVerifiedSelector, sessionIdSelector } from 'src/app/selectors'
3026
import ContactCircleSelf from 'src/components/ContactCircleSelf'
3127
import GradientBlock from 'src/components/GradientBlock'
3228
import { SettingsItemTextValue } from 'src/components/SettingsItem'
@@ -44,6 +40,8 @@ import { navigate } from 'src/navigator/NavigationService'
4440
import { Screens } from 'src/navigator/Screens'
4541
import { StackParamList } from 'src/navigator/types'
4642
import { useDispatch, useSelector } from 'src/redux/hooks'
43+
import { getFeatureGate } from 'src/statsig'
44+
import { StatsigFeatureGates } from 'src/statsig/types'
4745
import Colors from 'src/styles/colors'
4846
import { typeScale } from 'src/styles/fonts'
4947
import { Spacing } from 'src/styles/styles'
@@ -125,9 +123,8 @@ export default function SettingsMenu({ route }: Props) {
125123
const appVersion = deviceInfoModule.getVersion()
126124
const buildNumber = deviceInfoModule.getBuildNumber()
127125

128-
const { v2 } = useSelector(walletConnectEnabledSelector)
129126
const { sessions } = useSelector(selectSessions)
130-
const walletConnectEnabled = v2
127+
const walletConnectV2Disabled = getFeatureGate(StatsigFeatureGates.DISABLE_WALLET_CONNECT_V2)
131128
const connectedDapps = sessions?.length
132129

133130
const sessionId = useSelector(sessionIdSelector)
@@ -231,7 +228,7 @@ export default function SettingsMenu({ route }: Props) {
231228
showChevron
232229
borderless
233230
/>
234-
{walletConnectEnabled && (
231+
{!walletConnectV2Disabled && (
235232
<SettingsItemTextValue
236233
icon={<Stack size={24} color={Colors.contentPrimary} />}
237234
title={t('connectedApplications')}

0 commit comments

Comments
 (0)