Skip to content

Commit

Permalink
[Wallet] Make invitation links use vlra.app domain (#4733)
Browse files Browse the repository at this point in the history
### Description

Add `vlra.app` to dynamic links, so invitation links can be opened on the devices.

### Tested

iOS

### Related issues

- Part of #4566

### Backwards compatibility

Yes
  • Loading branch information
i1skn authored and annakaz committed Aug 21, 2020
1 parent e019c92 commit a62cc1a
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 36 deletions.
5 changes: 3 additions & 2 deletions packages/mobile/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENVIRONMENT=local
DEFAULT_TESTNET=alfajores
DEFAULT_TESTNET=mainnet
SMS_RETRIEVER_APP_SIGNATURE=aBQdOa/7QJh
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
# If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info
Expand All @@ -13,6 +13,7 @@ DEV_SETTINGS_ACTIVE_INITIALLY=true
# Enable for true hot reloading while dev-ing UI
DEV_RESTORE_NAV_STATE_ON_RELOAD=false
APP_BUNDLE_ID=org.celo.mobile.dev
APP_STORE_ID=1520414263
APP_DISPLAY_NAME=Celo (dev)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.dev.plist

DYNAMIC_LINK_DOMAIN=https://vlra.app
2 changes: 2 additions & 0 deletions packages/mobile/.env.alfajores
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ SECRETS_KEY=production
SHOW_TESTNET_BANNER=true
SHOW_GET_INVITE_LINK=true
APP_BUNDLE_ID=org.celo.mobile.alfajores
APP_STORE_ID=1482389446
APP_DISPLAY_NAME=Celo
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
DYNAMIC_LINK_DOMAIN=http://l.celo.org
2 changes: 2 additions & 0 deletions packages/mobile/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ SECRETS_KEY=production
SHOW_TESTNET_BANNER=false
SHOW_GET_INVITE_LINK=false
APP_BUNDLE_ID=co.clabs.valora
APP_STORE_ID=1520414263
APP_DISPLAY_NAME=Valora
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.mainnet.plist
DYNAMIC_LINK_DOMAIN=https://vlra.app
1 change: 1 addition & 0 deletions packages/mobile/ios/celo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://l.celo.org</string>
<string>https://vlra.app</string>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/ios/celo/celo.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:l.celo.org</string>
<string>applinks:vlra.app</string>
</array>
</dict>
</plist>
3 changes: 3 additions & 0 deletions packages/mobile/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ export const MOONPAY_PUBLIC_KEY = keyOrUndefined(
'MOONPAY_PUBLIC_KEY'
)
export const MOONPAY_RATE_API = `https://api.moonpay.io/v3/currencies/celo/price?apiKey=${MOONPAY_PUBLIC_KEY}`

export const APP_STORE_ID = Config.APP_STORE_ID
export const DYNAMIC_LINK_DOMAIN = Config.DYNAMIC_LINK_DOMAIN
4 changes: 3 additions & 1 deletion packages/mobile/src/firebase/dynamicLinks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import dynamicLinks, { FirebaseDynamicLinksTypes } from '@react-native-firebase/dynamic-links'
import { DYNAMIC_LINK_DOMAIN } from 'src/config'

import Logger from 'src/utils/Logger'

const TAG = 'firebase/dynamicLink'
Expand All @@ -15,7 +17,7 @@ export async function generateShortInviteLink({
try {
const dynamicLinkParams: FirebaseDynamicLinksTypes.DynamicLinkParameters = {
link,
domainUriPrefix: 'https://l.celo.org',
domainUriPrefix: DYNAMIC_LINK_DOMAIN,
}

if (bundleId) {
Expand Down
1 change: 0 additions & 1 deletion packages/mobile/src/geth/networkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const signMoonpayUrlStaging =
'https://us-central1-celo-org-mobile.cloudfunctions.net/signMoonpayStaging'
const signMoonpayUrlProd =
'https://us-central1-celo-mobile-mainnet.cloudfunctions.net/signMoonpayProd'

const networkConfigs: { [testnet: string]: NetworkConfig } = {
[Testnets.integration]: {
nodeDir: `.${Testnets.integration}`,
Expand Down
13 changes: 8 additions & 5 deletions packages/mobile/src/invite/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ jest.mock('src/firebase/dynamicLinks', () => ({
generateShortInviteLink: jest.fn(async () => 'http://celo.page.link/PARAMS'),
}))

jest.mock('src/utils/appstore', () => ({
getAppStoreId: jest.fn(async () => '1482389446'),
}))

jest.mock('src/account/actions', () => ({
...jest.requireActual('src/account/actions'),
getPincode: async () => 'pin',
Expand All @@ -55,6 +51,13 @@ jest.mock('src/transactions/send', () => ({
sendTransaction: async () => true,
}))

jest.mock('src/config', () => {
return {
...jest.requireActual('src/config'),
APP_STORE_ID: '1482389446',
}
})

SendIntentAndroid.sendSms = jest.fn()
SendSMS.send = jest.fn()

Expand Down Expand Up @@ -258,7 +261,7 @@ describe(generateInviteLink, () => {
expect(result).toBe('http://celo.page.link/PARAMS')
expect(generateShortInviteLink).toBeCalledTimes(1)
expect(generateShortInviteLink).toHaveBeenCalledWith({
link: `https://celo.org/build/wallet?invite-code=${mockKey}`,
link: `https://valoraapp.com/?invite-code=${mockKey}`,
appStoreId: '1482389446',
bundleId: 'org.celo.mobile.alfajores',
})
Expand Down
14 changes: 3 additions & 11 deletions packages/mobile/src/invite/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { showError, showMessage } from 'src/alert/actions'
import { InviteEvents, OnboardingEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { ErrorMessages } from 'src/app/ErrorMessages'
import { ALERT_BANNER_DURATION } from 'src/config'
import { ALERT_BANNER_DURATION, APP_STORE_ID } from 'src/config'
import { transferEscrowedPayment } from 'src/escrow/actions'
import { calculateFee } from 'src/fees/saga'
import { generateShortInviteLink } from 'src/firebase/dynamicLinks'
Expand Down Expand Up @@ -46,7 +46,6 @@ import { createTokenTransferTransaction, fetchTokenBalanceInWeiWithRetry } from
import { waitForTransactionWithId } from 'src/transactions/saga'
import { sendTransaction } from 'src/transactions/send'
import { newTransactionContext } from 'src/transactions/types'
import { getAppStoreId } from 'src/utils/appstore'
import { divideByWei } from 'src/utils/formatting'
import Logger from 'src/utils/Logger'
import { getContractKitAsync, getWallet, getWeb3 } from 'src/web3/contracts'
Expand Down Expand Up @@ -103,16 +102,9 @@ export async function generateInviteLink(inviteCode: string) {
bundleId = bundleId.replace(/\.(debug|dev)$/g, '.alfajores')

// trying to fetch appStoreId needed to build a dynamic link
let appStoreId
try {
appStoreId = await getAppStoreId(bundleId)
} catch (error) {
Logger.error(TAG, 'Failed to load AppStore ID: ' + error.toString())
}

const shortUrl = await generateShortInviteLink({
link: `https://celo.org/build/wallet?invite-code=${inviteCode}`,
appStoreId,
link: `https://valoraapp.com/?invite-code=${inviteCode}`,
appStoreId: APP_STORE_ID,
bundleId,
})

Expand Down
16 changes: 0 additions & 16 deletions packages/mobile/src/utils/appstore.ts

This file was deleted.

0 comments on commit a62cc1a

Please sign in to comment.