Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move deep link prefix to .env file #6008

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.alfajores
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
SENTRY_ENABLED=true
AUTH0_DOMAIN=auth.alfajores.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
Copy link
Member

@jeanregisser jeanregisser Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of naming it DEEP_LINK_URL_SCHEME?
It better represents what it is and more closely follows what iOS and Android use for this.

1 change: 1 addition & 0 deletions .env.alfajoresdev
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajoresdev.plist
SENTRY_ENABLED=false
AUTH0_DOMAIN=auth.alfajores.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.alfajoresnightly
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajoresnightly.plist
SENTRY_ENABLED=true
AUTH0_DOMAIN=auth.alfajores.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ ENABLED_QUICK_ACTIONS=Send,Receive,Add,Swap,Withdraw
# See all possible feature values in ToggleableOnboardingFeatures.
# This example enabled all features except PhoneVerification
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.mainnet.plist
SENTRY_ENABLED=true
AUTH0_DOMAIN=auth.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.mainnetdev
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.mainnetdev.plist
SENTRY_ENABLED=false
AUTH0_DOMAIN=auth.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.mainnetnightly
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.mainnetnightly.plist
SENTRY_ENABLED=true
AUTH0_DOMAIN=auth.valora.xyz
ONBOARDING_FEATURES_ENABLED=CloudBackupSetup,CloudBackupRestore,CloudBackupInOnboarding,EnableBiometry,ProtectWallet
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
SENTRY_ENABLED=false
AUTH0_DOMAIN=auth.alfajores.valora.xyz
ONBOARDING_FEATURES_ENABLED=EnableBiometry,ProtectWallet,PhoneVerification
DEEP_LINK_PREFIX=celo
1 change: 1 addition & 0 deletions __mocks__/react-native-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default {
SHOW_TESTNET_BANNER: 'true',
DEFAULT_TESTNET: 'alfajores',
AUTH0_DOMAIN: 'auth0.com',
DEEP_LINK_PREFIX: 'celo',
}
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "app_name", project.env.get("APP_DISPLAY_NAME")
resValue "string", "build_config_package", "org.celo.mobile"
resValue "string", "deep_link_prefix", project.env.get("DEEP_LINK_PREFIX")
missingDimensionStrategy 'react-native-camera', 'general'
vectorDrawables.useSupportLibrary = true
resValue "bool", "is_profiling_build", System.getenv("IS_PROFILING_BUILD") ?: "false"
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="celo" android:host="wallet" />
<data android:scheme="@string/deep_link_prefix" android:host="wallet" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down
3 changes: 2 additions & 1 deletion ios/celo/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[CleverTapReactManager sharedInstance] applicationDidLaunchWithOptions:launchOptions];

NSString *env = [RNCConfig envFor:@"FIREBASE_ENABLED"];
NSString *deepLinkPrefix = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"DEEP_LINK_PREFIX"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NSString *deepLinkPrefix = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"DEEP_LINK_PREFIX"];
NSString *deepLinkPrefix = [RNCConfig envFor:@"DEEP_LINK_PREFIX"];

if (env.boolValue) {
[FIROptions defaultOptions].deepLinkURLScheme = @"celo";
[FIROptions defaultOptions].deepLinkURLScheme = deepLinkPrefix;
[FIRApp configure];
}

Expand Down
2 changes: 1 addition & 1 deletion ios/celo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>celo</string>
<string>$(DEEP_LINK_PREFIX)</string>
</array>
</dict>
<dict>
Expand Down
4 changes: 2 additions & 2 deletions src/app/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Platform } from 'react-native'
import { BIOMETRY_TYPE } from 'react-native-keychain'
import { Actions, ActionTypes, AppState, MultichainBetaStatus } from 'src/app/actions'
import { CeloNewsConfig } from 'src/celoNews/types'
import { DEEPLINK_PREFIX } from 'src/config'
import { DEEP_LINK_PREFIX } from 'src/config'
import { REMOTE_CONFIG_VALUES_DEFAULTS } from 'src/firebase/remoteConfigValuesDefaults'
import { Screens } from 'src/navigator/Screens'
import { getRehydratePayload, REHYDRATE, RehydrateAction } from 'src/redux/persist-helper'

const PERSISTED_DEEP_LINKS = [
'https://valoraapp.com/share',
`${DEEPLINK_PREFIX}://wallet/jumpstart`,
`${DEEP_LINK_PREFIX}://wallet/jumpstart`,
]

interface State {
Expand Down
26 changes: 13 additions & 13 deletions src/app/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
inAppReviewLastInteractionTimestampSelector,
sentryNetworkErrorsSelector,
} from 'src/app/selectors'
import { DEEPLINK_PREFIX } from 'src/config'
import { DEEP_LINK_PREFIX } from 'src/config'
import { activeDappSelector } from 'src/dapps/selectors'
import { FiatExchangeFlow } from 'src/fiatExchanges/utils'
import { initI18n } from 'src/i18n'
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('handleDeepLink', () => {
}

const params = new URLSearchParams(data)
const deepLink = `${DEEPLINK_PREFIX}://wallet/pay?${params.toString()}`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/pay?${params.toString()}`

await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([
Expand All @@ -113,7 +113,7 @@ describe('handleDeepLink', () => {
})

it('Handles cash in deep link', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/cashIn`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/cashIn`
await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand All @@ -128,7 +128,7 @@ describe('handleDeepLink', () => {
})

it('Handles Bidali deep link', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/bidali`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/bidali`
await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand All @@ -141,7 +141,7 @@ describe('handleDeepLink', () => {
})

it('Handles cash-in-success deep link', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/cash-in-success/simplex`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/cash-in-success/simplex`
await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand All @@ -154,7 +154,7 @@ describe('handleDeepLink', () => {
})

it('Handles cash-in-success deep link with query params', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/cash-in-success/simplex?isApproved=true`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/cash-in-success/simplex?isApproved=true`
await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand All @@ -167,7 +167,7 @@ describe('handleDeepLink', () => {
})

it('Handles openScreen deep link with safe origin', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/openScreen?screen=${Screens.FiatExchangeCurrency}&flow=CashIn`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/openScreen?screen=${Screens.FiatExchangeCurrency}&flow=CashIn`
await expectSaga(handleDeepLink, openDeepLink(deepLink, true))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand All @@ -183,7 +183,7 @@ describe('handleDeepLink', () => {
})

it('Handles openScreen deep link without safe origin', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/openScreen?screen=${Screens.FiatExchangeCurrency}&flow=CashIn`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/openScreen?screen=${Screens.FiatExchangeCurrency}&flow=CashIn`
await expectSaga(handleDeepLink, openDeepLink(deepLink, false))
.provide([[select(walletAddressSelector), mockAccount]])
.run()
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('handleDeepLink', () => {
})

it('Handles jumpstart links', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/jumpstart/0xPrivateKey/celo-alfajores`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/jumpstart/0xPrivateKey/celo-alfajores`
jest.mocked(getDynamicConfigParams).mockReturnValue({
jumpstartContracts: {
[NetworkId['celo-alfajores']]: { contractAddress: '0xTEST' },
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('handleDeepLink', () => {
})

it('Handles hooks enable preview links', async () => {
const deepLink = `${DEEPLINK_PREFIX}://wallet/hooks/enablePreview?hooksApiUrl=https://192.168.0.42:18000`
const deepLink = `${DEEP_LINK_PREFIX}://wallet/hooks/enablePreview?hooksApiUrl=https://192.168.0.42:18000`
await expectSaga(handleDeepLink, openDeepLink(deepLink))
.provide([
[select(allowHooksPreviewSelector), true],
Expand Down Expand Up @@ -298,7 +298,7 @@ describe('WalletConnect deeplinks', () => {
},
{
name: 'iOS deeplink',
link: `${DEEPLINK_PREFIX}://wallet/wc?uri=${connectionString}`,
link: `${DEEP_LINK_PREFIX}://wallet/wc?uri=${connectionString}`,
},
{
name: 'iOS universal link',
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('WalletConnect deeplinks', () => {
const actionString = 'wc:1234'
const actionLinks = [
{ name: 'Android', link: actionString },
{ name: 'iOS deeplink', link: `${DEEPLINK_PREFIX}://wallet/wc?uri=${actionString}` },
{ name: 'iOS deeplink', link: `${DEEP_LINK_PREFIX}://wallet/wc?uri=${actionString}` },
{ name: 'iOS universal link', link: `https://valoraapp.com/wc?uri=${actionString}` },
]
for (const { name, link } of actionLinks) {
Expand Down Expand Up @@ -419,7 +419,7 @@ describe('handleOpenUrl', () => {

const httpLink = 'http://example.com'
const httpsLink = 'https://example.com'
const appLink = `${DEEPLINK_PREFIX}://something`
const appLink = `${DEEP_LINK_PREFIX}://something`
const otherDeepLink = 'other://deeplink'

describe('when openExternal is `false` or not specified', () => {
Expand Down
7 changes: 1 addition & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const DEFAULT_FORNO_URL =
: 'https://alfajores-forno.celo-testnet.org/'

export const APP_BUNDLE_ID = configOrThrow('APP_BUNDLE_ID')
export const DEEP_LINK_PREFIX = configOrThrow('DEEP_LINK_PREFIX')

// The network that FiatConnect providers operate on
export const FIATCONNECT_NETWORK =
Expand Down Expand Up @@ -161,12 +162,6 @@ export const SUPERCHARGE_LOGO_URL =
export const SIMPLEX_FEES_URL =
'https://support.simplex.com/hc/en-gb/articles/360014078420-What-fees-am-I-paying-'

// N.B.: Make sure to update the following files to match this value:
// * app.json
// * android/**/AndroidManifest.xml
// * ios/**/AppDelegate.mm
export const DEEPLINK_PREFIX = 'celo'

export const APP_STORE_ID = Config.APP_STORE_ID
export const DYNAMIC_LINK_DOMAIN_URI_PREFIX = 'https://vlra.app'
export const CROWDIN_DISTRIBUTION_HASH = 'e-f9f6869461793b9d1a353b2v7c'
Expand Down
4 changes: 2 additions & 2 deletions src/dapps/saga.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FetchMock } from 'jest-fetch-mock/types'
import { expectSaga } from 'redux-saga-test-plan'
import { select } from 'redux-saga/effects'
import { DEEP_LINK_PREFIX } from 'src/config'
import { handleFetchDappsList, handleOpenDapp } from 'src/dapps/saga'
import { dappsListApiUrlSelector, dappsWebViewEnabledSelector } from 'src/dapps/selectors'
import { dappSelected, fetchDappsListCompleted, fetchDappsListFailed } from 'src/dapps/slice'
Expand All @@ -11,7 +12,6 @@ import { Screens } from 'src/navigator/Screens'
import { getExperimentParams } from 'src/statsig'
import { walletAddressSelector } from 'src/web3/selectors'
import { mockAccount } from 'test/values'
import { DEEPLINK_PREFIX } from 'src/config'

jest.mock('src/statsig')

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Dapps saga', () => {
dappSelected({
dapp: {
...baseDapp,
dappUrl: `${DEEPLINK_PREFIX}://wallet/bidali`,
dappUrl: `${DEEP_LINK_PREFIX}://wallet/bidali`,
openedFrom: DappSection.All,
},
})
Expand Down
4 changes: 2 additions & 2 deletions src/dapps/selectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DEEP_LINK_PREFIX } from 'src/config'
import {
dappCategoriesSelector,
dappListWithCategoryNamesSelector,
favoriteDappsWithCategoryNamesSelector,
} from 'src/dapps/selectors'
import { getMockStoreData } from 'test/utils'
import { DEEPLINK_PREFIX } from 'src/config'

const dapp1V2 = {
name: 'Ubeswap',
Expand All @@ -21,7 +21,7 @@ const dapp2V2 = {
categories: ['2'],
description: 'Lend and borrow tokens!',
iconUrl: 'https://raw.githubusercontent.com/app-list/main/assets/moola.png',
dappUrl: `${DEEPLINK_PREFIX}://wallet/moolaScreen`,
dappUrl: `${DEEP_LINK_PREFIX}://wallet/moolaScreen`,
}

const dappsCategories = [
Expand Down
7 changes: 3 additions & 4 deletions src/fiatExchanges/SimplexScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { useTranslation } from 'react-i18next'
import { ActivityIndicator, StyleSheet, View } from 'react-native'
import { e164NumberSelector } from 'src/account/selectors'
import { showError } from 'src/alert/actions'
import { FiatExchangeEvents } from 'src/analytics/Events'
import AppAnalytics from 'src/analytics/AppAnalytics'
import { FiatExchangeEvents } from 'src/analytics/Events'
import { ErrorMessages } from 'src/app/ErrorMessages'
import { phoneNumberVerifiedSelector } from 'src/app/selectors'
import BackButton from 'src/components/BackButton'
import Button, { BtnSizes } from 'src/components/Button'
import WebView from 'src/components/WebView'
import { SIMPLEX_FEES_URL } from 'src/config'
import { DEEP_LINK_PREFIX, SIMPLEX_FEES_URL } from 'src/config'
import ReviewFees from 'src/fiatExchanges/ReviewFees'
import { fetchSimplexPaymentData } from 'src/fiatExchanges/utils'
import i18n from 'src/i18n'
Expand All @@ -27,7 +27,6 @@ import { useTokenInfo } from 'src/tokens/hooks'
import { resolveCurrency } from 'src/utils/currencies'
import { navigateToURI } from 'src/utils/linking'
import { currentAccountSelector } from 'src/web3/selectors'
import { DEEPLINK_PREFIX } from 'src/config'

type RouteProps = NativeStackScreenProps<StackParamList, Screens.Simplex>
type Props = RouteProps
Expand Down Expand Up @@ -59,7 +58,7 @@ function SimplexScreen({ route, navigation }: Props) {
const onNavigationStateChange = ({ url }: any) => {
if (url?.includes('/payments/new')) {
setRedirected(true)
} else if (url?.startsWith(`${DEEPLINK_PREFIX}://wallet`)) {
} else if (url?.startsWith(`${DEEP_LINK_PREFIX}://wallet`)) {
navigateToURI(url)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/firebase/notifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { expectSaga } from 'redux-saga-test-plan'
import { select } from 'redux-saga/effects'
import { showMessage } from 'src/alert/actions'
import { openUrl } from 'src/app/actions'
import { DEEP_LINK_PREFIX } from 'src/config'
import { handleNotification } from 'src/firebase/notifications'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { NotificationReceiveState, NotificationTypes } from 'src/notifications/types'
import { recipientInfoSelector } from 'src/recipients/reducer'
import { NetworkId, TransactionStatus } from 'src/transactions/types'
import { mockRecipientInfo } from 'test/values'
import { DEEPLINK_PREFIX } from 'src/config'

describe(handleNotification, () => {
beforeEach(() => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe(handleNotification, () => {
})

describe("with a notification with an 'open url' semantic and a deep link", () => {
const expectedUrl = `${DEEPLINK_PREFIX}://wallet/openScreen?screen=${Screens.TabNavigator}`
const expectedUrl = `${DEEP_LINK_PREFIX}://wallet/openScreen?screen=${Screens.TabNavigator}`
const message: FirebaseMessagingTypes.RemoteMessage = {
notification: { title: 'My title', body: 'My Body' },
data: { ou: expectedUrl },
Expand Down
4 changes: 2 additions & 2 deletions src/home/reducers.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DEEP_LINK_PREFIX } from 'src/config'
import {
Actions,
celebratedNftFound,
Expand All @@ -16,7 +17,6 @@ import {
} from 'src/home/reducers'
import { NetworkId } from 'src/transactions/types'
import { mockCleverTapInboxMessage, mockContractAddress } from 'test/values'
import { DEEPLINK_PREFIX } from 'src/config'

const createTestNotification = (body: string) => ({
ctaUri: 'https://celo.org',
Expand All @@ -31,7 +31,7 @@ const createTestNotification = (body: string) => ({
})

const mockRewardProperties = {
deepLink: `${DEEPLINK_PREFIX}://test`,
deepLink: `${DEEP_LINK_PREFIX}://test`,
rewardExpirationDate: '3000-12-01T00:00:00.000Z',
rewardReminderDate: '3000-01-01T00:00:00.000Z',
}
Expand Down
Loading
Loading