diff --git a/e2e/src/DeepLinkDappkit.spec.js b/e2e/src/DeepLinkDappkit.spec.js deleted file mode 100644 index ae66d0bb534..00000000000 --- a/e2e/src/DeepLinkDappkit.spec.js +++ /dev/null @@ -1,9 +0,0 @@ -import HandleDeepLinkDappkit from './usecases/HandleDeepLinkDappkit' -import { quickOnboarding } from './utils/utils' - -describe('Deep Link with account dappkit', () => { - beforeAll(async () => { - await quickOnboarding() - }) - describe('HandleDeepLinkDappkit', HandleDeepLinkDappkit) -}) diff --git a/e2e/src/usecases/HandleDeepLinkDappkit.js b/e2e/src/usecases/HandleDeepLinkDappkit.js deleted file mode 100644 index c8a5724470e..00000000000 --- a/e2e/src/usecases/HandleDeepLinkDappkit.js +++ /dev/null @@ -1,26 +0,0 @@ -import { launchApp } from '../utils/retries' -import { enterPinUiIfNecessary, quote, sleep } from '../utils/utils' - -export default HandleDeepLinkDappkit = () => { - const DAPPKIT_URL = - 'celo://wallet/dappkit?type=sign_tx&requestId=beneficiaryclaim&callback=impactmarket%3A%2F%2F&dappName=impactmarket&txs=W3sidHhEYXRhIjoiMHg0ZTcxZDkyZCIsImVzdGltYXRlZEdhcyI6MTIxMTI3LCJmcm9tIjoiMHhhY2FGQjRGMWQ5RERGMTQwNWViZEJGZWM5NTlBNzI4MTk0QjAyMzhhIiwidG8iOiIweDc0ZTVDNDA1RURFNEUzN2U3ODBEQjk2NTI1NDE1MzhkZDhBNzlBN2QiLCJub25jZSI6MjYsImZlZUN1cnJlbmN5QWRkcmVzcyI6IjB4NzY1REU4MTY4NDU4NjFlNzVBMjVmQ0ExMjJiYjY4OThCOEIxMjgyYSIsInZhbHVlIjoiMCJ9XQ%3D%3D' - - it('Launch app with dappkit deep link', async () => { - await device.terminateApp() - // I think at least on android we need this sleep because the - // OS has a timeout period in between closing and reopening an app - await sleep(5000) - await launchApp({ url: DAPPKIT_URL, newInstance: true }) - // this second sleep is to allow for navigation to reach the desired deep link handler - await sleep(5000) - - await device.takeScreenshot('dappkit screen') - await enterPinUiIfNecessary() - - // press Allow button on DappKitSignTxScreen - await element(by.id('DappKitSignRequest/Allow')).tap() - - // Arrived at pin code enter screen - await expect(element(by.id('digit1'))).toBeVisible() - }) -} diff --git a/scripts/adb-dappkit.sh b/scripts/adb-dappkit.sh deleted file mode 100755 index 9b307461fd4..00000000000 --- a/scripts/adb-dappkit.sh +++ /dev/null @@ -1 +0,0 @@ -adb shell am start -a android.intent.action.VIEW -d "celo://wallet/dappkit?type=sign_tx\&requestId=beneficiaryclaim\&callback=impactmarket%3A%2F%2F\&dappName=impactmarket\&txs=W3sidHhEYXRhIjoiMHg0ZTcxZDkyZCIsImVzdGltYXRlZEdhcyI6MTIxMTI3LCJmcm9tIjoiMHhhY2FGQjRGMWQ5RERGMTQwNWViZEJGZWM5NTlBNzI4MTk0QjAyMzhhIiwidG8iOiIweDc0ZTVDNDA1RURFNEUzN2U3ODBEQjk2NTI1NDE1MzhkZDhBNzlBN2QiLCJub25jZSI6MjYsImZlZUN1cnJlbmN5QWRkcmVzcyI6IjB4NzY1REU4MTY4NDU4NjFlNzVBMjVmQ0ExMjJiYjY4OThCOEIxMjgyYSIsInZhbHVlIjoiMCJ9XQ%3D%3D" diff --git a/src/analytics/Events.tsx b/src/analytics/Events.tsx index 6d73410ebb5..3101b9d0913 100644 --- a/src/analytics/Events.tsx +++ b/src/analytics/Events.tsx @@ -516,16 +516,6 @@ export enum WalletConnectEvents { wc_copy_request_payload = 'wc_copy_request_payload', } -export enum DappKitEvents { - dappkit_parse_deeplink_error = 'dappkit_parse_deeplink_error', - dappkit_request_propose = 'dappkit_request_propose', - dappkit_request_cancel = 'dappkit_request_cancel', - dappkit_copy_request_details = 'dappkit_copy_request_details', - dappkit_request_accept_start = 'dappkit_request_accept_start', - dappkit_request_accept_success = 'dappkit_request_accept_success', - dappkit_request_accept_error = 'dappkit_request_accept_error', -} - export enum CICOEvents { persona_kyc_start = 'persona_kyc_start', persona_kyc_success = 'persona_kyc_success', diff --git a/src/analytics/Properties.tsx b/src/analytics/Properties.tsx index 0304b685256..31264047fe8 100644 --- a/src/analytics/Properties.tsx +++ b/src/analytics/Properties.tsx @@ -1,4 +1,3 @@ -import { DappKitRequestTypes } from '@celo/utils' import { FiatAccountSchema, FiatConnectError, @@ -17,7 +16,6 @@ import { CoinbasePayEvents, ContractKitEvents, DappExplorerEvents, - DappKitEvents, DappShortcutsEvents, EarnEvents, EscrowEvents, @@ -1082,31 +1080,6 @@ interface WalletConnectProperties { [WalletConnectEvents.wc_copy_request_payload]: WalletConnectRequestDefaultProperties } -interface DappKitRequestDefaultProperties { - dappRequestOrigin: DappRequestOrigin - dappName: string - dappUrl: string - requestType: DappKitRequestTypes - requestCallback: string - requestId: string -} - -interface DappKitProperties { - [DappKitEvents.dappkit_parse_deeplink_error]: { - dappRequestOrigin: DappRequestOrigin - deeplink: string - error: string - } - [DappKitEvents.dappkit_request_propose]: DappKitRequestDefaultProperties - [DappKitEvents.dappkit_request_cancel]: DappKitRequestDefaultProperties - [DappKitEvents.dappkit_copy_request_details]: DappKitRequestDefaultProperties - [DappKitEvents.dappkit_request_accept_start]: DappKitRequestDefaultProperties - [DappKitEvents.dappkit_request_accept_success]: DappKitRequestDefaultProperties - [DappKitEvents.dappkit_request_accept_error]: DappKitRequestDefaultProperties & { - error: string - } -} - interface CICOEventsProperties { [CICOEvents.persona_kyc_start]: undefined [CICOEvents.persona_kyc_success]: undefined @@ -1688,7 +1661,6 @@ export type AnalyticsPropertiesList = AppEventsProperties & NavigationProperties & RewardsProperties & WalletConnectProperties & - DappKitProperties & CICOEventsProperties & DappExplorerEventsProperties & WebViewEventsProperties & diff --git a/src/analytics/docs.ts b/src/analytics/docs.ts index bac93e2dbd2..ba007ada11a 100644 --- a/src/analytics/docs.ts +++ b/src/analytics/docs.ts @@ -11,7 +11,6 @@ import { CoinbasePayEvents, ContractKitEvents, DappExplorerEvents, - DappKitEvents, DappShortcutsEvents, EarnEvents, EscrowEvents, @@ -515,13 +514,6 @@ export const eventDocs: Record = { [WalletConnectEvents.wc_request_deny_success]: `when the dapp request denial succeeds`, [WalletConnectEvents.wc_request_deny_error]: `when the dapp request denial fails`, [WalletConnectEvents.wc_copy_request_payload]: `when a user taps to copy the request payload from the bottom sheet`, - [DappKitEvents.dappkit_parse_deeplink_error]: `when dappkit fails to parse the deeplink`, - [DappKitEvents.dappkit_request_propose]: `when the dappkit request screen is displayed to accept/deny a dapp request`, - [DappKitEvents.dappkit_request_cancel]: `when user presses the button to cancel the dapp request`, - [DappKitEvents.dappkit_copy_request_details]: `when user presses the button to copy details of a dapp request`, - [DappKitEvents.dappkit_request_accept_start]: `when user presses the button to accept a dapp request`, - [DappKitEvents.dappkit_request_accept_success]: `when the dapp request succeeds`, - [DappKitEvents.dappkit_request_accept_error]: `when the dapp request fails`, [CICOEvents.persona_kyc_start]: `when a user begins the Persona KYC process (clicks 'Set up ID Verification' button)`, [CICOEvents.persona_kyc_success]: `when the onComplete callback is called for a Persona inquiry with success status`, [CICOEvents.persona_kyc_failed]: `when the onComplete callback is called for a Persona inquiry with failed status`, @@ -654,4 +646,11 @@ export const eventDocs: Record = { // [RequestEvents.request_error]: `when there is an error requesting a transaction`, // [FiatExchangeEvents.cico_currency_chosen]: `User selects a currency and taps next`, // [FiatExchangeEvents.cico_currency_back]: `User presses the back button from the currency screen`, + // [DappKitEvents.dappkit_parse_deeplink_error]: `when dappkit fails to parse the deeplink`, + // [DappKitEvents.dappkit_request_propose]: `when the dappkit request screen is displayed to accept/deny a dapp request`, + // [DappKitEvents.dappkit_request_cancel]: `when user presses the button to cancel the dapp request`, + // [DappKitEvents.dappkit_copy_request_details]: `when user presses the button to copy details of a dapp request`, + // [DappKitEvents.dappkit_request_accept_start]: `when user presses the button to accept a dapp request`, + // [DappKitEvents.dappkit_request_accept_success]: `when the dapp request succeeds`, + // [DappKitEvents.dappkit_request_accept_error]: `when the dapp request fails`, } diff --git a/src/analytics/types.ts b/src/analytics/types.ts index 86b1104c430..ee8ea958134 100644 --- a/src/analytics/types.ts +++ b/src/analytics/types.ts @@ -20,7 +20,7 @@ export enum WalletConnectPairingOrigin { Deeplink = 'deeplink', } -// Origin of WalletConnect/DappKit request +// Origin of WalletConnect request export enum DappRequestOrigin { InAppWebView = 'in_app_web_view', External = 'external', diff --git a/src/app/saga.test.ts b/src/app/saga.test.ts index ab3e398a6b2..01b9b554d03 100644 --- a/src/app/saga.test.ts +++ b/src/app/saga.test.ts @@ -37,7 +37,6 @@ import { sentryNetworkErrorsSelector, shouldRunVerificationMigrationSelector, } from 'src/app/selectors' -import { handleDappkitDeepLink } from 'src/dappkit/dappkit' import { activeDappSelector } from 'src/dapps/selectors' import { FiatExchangeFlow } from 'src/fiatExchanges/utils' import { initI18n } from 'src/i18n' @@ -73,7 +72,6 @@ import { import { createMockStore } from 'test/utils' import { mockAccount, mockTokenBalances } from 'test/values' -jest.mock('src/dappkit/dappkit') jest.mock('src/analytics/ValoraAnalytics') jest.mock('src/sentry/Sentry') jest.mock('src/sentry/SentryTransactionHub') @@ -107,19 +105,6 @@ describe('handleDeepLink', () => { jest.clearAllMocks() }) - it('Handles Dappkit deep link', async () => { - const deepLink = 'celo://wallet/dappkit?abcdsa' - await expectSaga(handleDeepLink, openDeepLink(deepLink)) - .provide([[select(walletAddressSelector), mockAccount]]) - .run() - expect(handleDappkitDeepLink).toHaveBeenCalledWith(deepLink) - expect(ValoraAnalytics.track).toHaveBeenCalledWith(AppEvents.handle_deeplink, { - pathStartsWith: 'dappkit', - fullPath: '/dappkit', - query: 'abcdsa', - }) - }) - it('Handles payment deep link', async () => { const data = { address: '0xf7f551752A78Ce650385B58364225e5ec18D96cB', diff --git a/src/app/saga.ts b/src/app/saga.ts index feb1d43827b..189c5e6351a 100644 --- a/src/app/saga.ts +++ b/src/app/saga.ts @@ -42,7 +42,6 @@ import { CeloNewsConfig } from 'src/celoNews/types' import { DEFAULT_APP_LANGUAGE, FETCH_TIMEOUT_DURATION, isE2EEnv } from 'src/config' import { claimRewardsSuccess } from 'src/consumerIncentives/slice' import { SuperchargeTokenConfigByToken } from 'src/consumerIncentives/types' -import { handleDappkitDeepLink } from 'src/dappkit/dappkit' import { FiatExchangeFlow } from 'src/fiatExchanges/utils' import { FiatAccountSchemaCountryOverrides } from 'src/fiatconnect/types' import { appVersionDeprecationChannel, fetchRemoteConfigValues } from 'src/firebase/firebase' @@ -315,7 +314,6 @@ export function* handleDeepLink(action: OpenDeepLink) { // don't accidentally log sensitive information on new deeplinks. 'jumpstart' is specifically excluded const pathStartsWithAllowList = [ 'pay', - 'dappkit', 'cashIn', 'bidali', 'cash-in-success', @@ -331,8 +329,6 @@ export function* handleDeepLink(action: OpenDeepLink) { }) if (rawParams.path.startsWith('/pay')) { yield* call(handlePaymentDeeplink, deepLink) - } else if (rawParams.path.startsWith('/dappkit')) { - yield* call(handleDappkitDeepLink, deepLink) } else if (rawParams.path === '/cashIn') { navigate(Screens.FiatExchangeCurrencyBottomSheet, { flow: FiatExchangeFlow.CashIn }) } else if (rawParams.pathname === '/bidali') { diff --git a/src/app/utils.ts b/src/app/utils.ts index 74014ffa684..6f8e3bff2bb 100644 --- a/src/app/utils.ts +++ b/src/app/utils.ts @@ -1,7 +1,7 @@ import { DappRequestOrigin } from 'src/analytics/types' import { ActiveDapp } from 'src/dapps/types' -// Assume that if we have an active dapp, any WC or DappKit request comes from the in-app webview. +// Assume that if we have an active dapp, any WC request comes from the in-app webview. // Note that this may be incorrect if the user interacts with another dapp while the dapp webview is open. // I thought about comparing the request url to the active dapp url, but that could fail too if the dapp url we have is different. // For instance the dapp-list could contain a "example.com", while the request is "dapp.something.com". diff --git a/src/dappkit/DappKitAccountScreen.tsx b/src/dappkit/DappKitAccountScreen.tsx deleted file mode 100644 index 25fb417cbf3..00000000000 --- a/src/dappkit/DappKitAccountScreen.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { BottomSheetScreenProps } from '@th3rdwave/react-navigation-bottom-sheet' -import React from 'react' -import { useTranslation } from 'react-i18next' -import { e164NumberSelector } from 'src/account/selectors' -import { DappKitEvents } from 'src/analytics/Events' -import ValoraAnalytics from 'src/analytics/ValoraAnalytics' -import BottomSheetScrollView from 'src/components/BottomSheetScrollView' -import { approveAccountAuth, getDefaultRequestTrackedProperties } from 'src/dappkit/dappkit' -import { activeDappSelector } from 'src/dapps/selectors' -import { isBottomSheetVisible, navigateBack } from 'src/navigator/NavigationService' -import { Screens } from 'src/navigator/Screens' -import { StackParamList } from 'src/navigator/types' -import { useDispatch, useSelector } from 'src/redux/hooks' -import { SentryTransactionHub } from 'src/sentry/SentryTransactionHub' -import { SentryTransaction } from 'src/sentry/SentryTransactions' -import Logger from 'src/utils/Logger' -import RequestContent from 'src/walletConnect/screens/RequestContent' -import { currentAccountSelector } from 'src/web3/selectors' - -const TAG = 'dappkit/DappKitAccountScreen' - -type Props = BottomSheetScreenProps - -const DappKitAccountScreen = ({ route }: Props) => { - const { dappKitRequest } = route.params - - const account = useSelector(currentAccountSelector) - const phoneNumber = useSelector(e164NumberSelector) - const activeDapp = useSelector(activeDappSelector) - - const dispatch = useDispatch() - const { t } = useTranslation() - - const handleAllow = () => { - if (!dappKitRequest) { - Logger.error(TAG, 'No request found in navigation props') - return - } - if (!account) { - Logger.error(TAG, 'No account set up for this wallet') - return - } - SentryTransactionHub.startTransaction(SentryTransaction.dappkit_connection) - dispatch(approveAccountAuth(dappKitRequest)) - } - - const handleCancel = async () => { - ValoraAnalytics.track( - DappKitEvents.dappkit_request_cancel, - getDefaultRequestTrackedProperties(route.params.dappKitRequest, activeDapp) - ) - if (await isBottomSheetVisible(Screens.DappKitAccountScreen)) { - navigateBack() - } - } - - return ( - - - - ) -} - -export default DappKitAccountScreen diff --git a/src/dappkit/DappKitSignTxScreen.tsx b/src/dappkit/DappKitSignTxScreen.tsx deleted file mode 100644 index 2a825741bde..00000000000 --- a/src/dappkit/DappKitSignTxScreen.tsx +++ /dev/null @@ -1,125 +0,0 @@ -import Clipboard from '@react-native-clipboard/clipboard' -import { BottomSheetScreenProps } from '@th3rdwave/react-navigation-bottom-sheet' -import React from 'react' -import { useTranslation } from 'react-i18next' -import { StyleSheet, Text, View } from 'react-native' -import Toast from 'react-native-simple-toast' -import { DappKitEvents } from 'src/analytics/Events' -import ValoraAnalytics from 'src/analytics/ValoraAnalytics' -import BottomSheetScrollView from 'src/components/BottomSheetScrollView' -import Touchable from 'src/components/Touchable' -import { getDefaultRequestTrackedProperties, requestTxSignature } from 'src/dappkit/dappkit' -import { activeDappSelector } from 'src/dapps/selectors' -import CopyIcon from 'src/icons/CopyIcon' -import { isBottomSheetVisible, navigateBack } from 'src/navigator/NavigationService' -import { Screens } from 'src/navigator/Screens' -import { StackParamList } from 'src/navigator/types' -import { useDispatch, useSelector } from 'src/redux/hooks' -import colors from 'src/styles/colors' -import fontStyles from 'src/styles/fonts' -import { vibrateInformative } from 'src/styles/hapticFeedback' -import { Spacing } from 'src/styles/styles' -import variables from 'src/styles/variables' -import Logger from 'src/utils/Logger' -import DappsDisclaimer from 'src/walletConnect/screens/DappsDisclaimer' -import RequestContent from 'src/walletConnect/screens/RequestContent' -import { useIsDappListed } from 'src/walletConnect/screens/useIsDappListed' - -const TAG = 'dappkit/DappKitSignTxScreen' - -type Props = BottomSheetScreenProps - -const DappKitSignTxScreen = ({ route }: Props) => { - const { dappKitRequest } = route.params - const { dappName, txs, callback } = dappKitRequest - - const activeDapp = useSelector(activeDappSelector) - const dispatch = useDispatch() - const { t } = useTranslation() - const isDappListed = useIsDappListed(callback) - - if (!dappKitRequest) { - Logger.error(TAG, 'No request found in navigation props') - return null - } - - const handleAllow = () => { - dispatch(requestTxSignature(dappKitRequest)) - } - - const handleCopyRequestPayload = () => { - Clipboard.setString(txs[0].txData) - vibrateInformative() - ValoraAnalytics.track( - DappKitEvents.dappkit_copy_request_details, - getDefaultRequestTrackedProperties(dappKitRequest, activeDapp) - ) - Toast.showWithGravity( - t('walletConnectRequest.transactionDataCopied'), - Toast.SHORT, - Toast.BOTTOM - ) - } - - const handleCancel = async () => { - ValoraAnalytics.track( - DappKitEvents.dappkit_request_cancel, - getDefaultRequestTrackedProperties(dappKitRequest, activeDapp) - ) - if (await isBottomSheetVisible(Screens.DappKitSignTxScreen)) { - navigateBack() - } - } - - return ( - - - - - - {t('walletConnectRequest.transactionDataLabel')} - - - {txs[0].txData} - - - - - - - - - - - ) -} - -const styles = StyleSheet.create({ - transactionContainer: { - padding: Spacing.Regular16, - backgroundColor: colors.gray1, - flexDirection: 'row', - alignItems: 'center', - borderRadius: 12, - marginBottom: Spacing.Thick24, - }, - transactionDataContainer: { - flex: 1, - marginRight: Spacing.Regular16, - }, - transactionDataLabel: { - ...fontStyles.small600, - marginBottom: 4, - }, -}) - -export default DappKitSignTxScreen diff --git a/src/dappkit/dappkit.ts b/src/dappkit/dappkit.ts deleted file mode 100644 index a53df41aca8..00000000000 --- a/src/dappkit/dappkit.ts +++ /dev/null @@ -1,229 +0,0 @@ -import { - AccountAuthRequest, - AccountAuthResponseSuccess, - DappKitRequest, - DappKitRequestTypes, - parseDappKitRequestDeeplink, - produceResponseDeeplink, - SignTxRequest, - SignTxResponseSuccess, -} from '@celo/utils/lib/dappkit' -import { e164NumberSelector } from 'src/account/selectors' -import { showMessage } from 'src/alert/actions' -import { DappKitEvents } from 'src/analytics/Events' -import ValoraAnalytics from 'src/analytics/ValoraAnalytics' -import { getDappRequestOrigin } from 'src/app/utils' -import { activeDappSelector } from 'src/dapps/selectors' -import { ActiveDapp } from 'src/dapps/types' -import i18n from 'src/i18n' -import { e164NumberToSaltSelector } from 'src/identity/selectors' -import { navigate, navigateBack } from 'src/navigator/NavigationService' -import { Screens } from 'src/navigator/Screens' -import { SentryTransactionHub } from 'src/sentry/SentryTransactionHub' -import { SentryTransaction } from 'src/sentry/SentryTransactions' -import { ensureError } from 'src/utils/ensureError' -import { navigateToURI } from 'src/utils/linking' -import Logger from 'src/utils/Logger' -import { safely } from 'src/utils/safely' -import { getWeb3 } from 'src/web3/contracts' -import { getConnectedUnlockedAccount } from 'src/web3/saga' -import { currentAccountSelector } from 'src/web3/selectors' -import { call, put, select, takeLeading } from 'typed-redux-saga' - -const TAG = 'dappkit/dappkit' - -export enum actions { - APPROVE_ACCOUNT_AUTH = 'DAPPKIT/APPROVE_ACCOUNT_AUTH', - REQUEST_TX_SIGNATURE = 'DAPPKIT/REQUEST_TX_SIGNATURE', -} - -export interface ApproveAccountAuthAction { - type: actions.APPROVE_ACCOUNT_AUTH - request: AccountAuthRequest -} - -export const approveAccountAuth = (request: AccountAuthRequest): ApproveAccountAuthAction => ({ - type: actions.APPROVE_ACCOUNT_AUTH, - request, -}) - -export interface RequestTxSignatureAction { - type: actions.REQUEST_TX_SIGNATURE - request: SignTxRequest -} - -export const requestTxSignature = (request: SignTxRequest): RequestTxSignatureAction => ({ - type: actions.REQUEST_TX_SIGNATURE, - request, -}) - -export function getDefaultRequestTrackedProperties( - request: DappKitRequest, - activeDapp: ActiveDapp | null -) { - const { type: requestType, callback: requestCallback, requestId, dappName } = request - const dappUrl = new URL(requestCallback).origin - return { - dappRequestOrigin: getDappRequestOrigin(activeDapp), - dappName, - dappUrl, - requestType, - requestCallback, - requestId, - } -} - -function* handleNavigationWithDeeplink(dappkitDeeplink: string) { - const activeDapp = yield* select(activeDappSelector) - - if (activeDapp) { - yield* put(showMessage(i18n.t('inAppConnectionSuccess', { dappName: activeDapp.name }))) - navigate(Screens.WebViewScreen, { - uri: activeDapp.dappUrl, - dappkitDeeplink, - }) - } else { - navigateToURI(dappkitDeeplink) - // prevent staying on dappkit confirmation screen - navigateBack() - } -} - -function* respondToAccountAuth(action: ApproveAccountAuthAction) { - const activeDapp: ActiveDapp | null = yield* select(activeDappSelector) - const defaultTrackedProperties = getDefaultRequestTrackedProperties(action.request, activeDapp) - try { - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_start, defaultTrackedProperties) - Logger.debug(TAG, 'Approving auth account') - const account = yield* select(currentAccountSelector) - const phoneNumber = yield* select(e164NumberSelector) - const e164NumberToSalt = yield* select(e164NumberToSaltSelector) - if (!account) { - throw new Error('Account is not set') - } - if (!phoneNumber) { - throw new Error('Phone number is not set') - } - const pepper = e164NumberToSalt[phoneNumber] - if (!pepper) { - throw new Error('Pepper is not set') - } - const responseDeeplink = produceResponseDeeplink( - action.request, - AccountAuthResponseSuccess(account, phoneNumber, pepper) - ) - - yield* call(handleNavigationWithDeeplink, responseDeeplink) - - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_success, defaultTrackedProperties) - SentryTransactionHub.finishTransaction(SentryTransaction.dappkit_connection) - } catch (err) { - const error = ensureError(err) - Logger.error(TAG, 'Failed to respond to account auth', error) - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_error, { - ...defaultTrackedProperties, - error: error.message, - }) - } -} - -// TODO Error handling here -function* produceTxSignature(action: RequestTxSignatureAction) { - const activeDapp: ActiveDapp | null = yield* select(activeDappSelector) - const defaultTrackedProperties = getDefaultRequestTrackedProperties(action.request, activeDapp) - try { - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_start, defaultTrackedProperties) - Logger.debug(TAG, 'Producing tx signature') - - yield* call(getConnectedUnlockedAccount) - // Call Sentry performance monitoring after entering pin if required - SentryTransactionHub.startTransaction(SentryTransaction.dappkit_transaction) - const web3 = yield* call(getWeb3) - - const rawTxs = (yield* call( - Promise.all, - action.request.txs.map(async (tx) => { - // TODO offload this logic to walletkit or contractkit, otherwise they - // could diverge again and create another bug - // See https://github.com/celo-org/celo-monorepo/issues/3045 - - // In walletKit we use web3.eth.getCoinbase() to get gateway fee recipient - // but that's throwing errors here. Not sure why, but txs work without it. - const gatewayFeeRecipient = undefined - const gatewayFee = undefined - const gas = Math.round(tx.estimatedGas * 1.5) - - const params: any = { - from: tx.from, - gasPrice: '0', - gas, - data: tx.txData, - nonce: tx.nonce, - value: tx.value, - feeCurrency: tx.feeCurrencyAddress, - gatewayFeeRecipient, - gatewayFee, - } - if (tx.to) { - params.to = tx.to - } - Logger.debug(TAG, 'Signing tx with params', params) - const signedTx = await web3.eth.signTransaction(params) - return signedTx.raw - }) - )) as string[] - - Logger.debug(TAG, 'Txs signed, opening URL') - const responseDeeplink = produceResponseDeeplink(action.request, SignTxResponseSuccess(rawTxs)) - yield* call(handleNavigationWithDeeplink, responseDeeplink) - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_success, defaultTrackedProperties) - SentryTransactionHub.finishTransaction(SentryTransaction.dappkit_transaction) - } catch (err) { - const error = ensureError(err) - Logger.error(TAG, 'Failed to produce tx signature', error) - ValoraAnalytics.track(DappKitEvents.dappkit_request_accept_error, { - ...defaultTrackedProperties, - error: error.message, - }) - } -} - -export function* dappKitSaga() { - yield* takeLeading(actions.APPROVE_ACCOUNT_AUTH, safely(respondToAccountAuth)) - yield* takeLeading(actions.REQUEST_TX_SIGNATURE, safely(produceTxSignature)) -} - -export function* handleDappkitDeepLink(deeplink: string) { - const activeDapp: ActiveDapp | null = yield* select(activeDappSelector) - try { - const dappKitRequest = parseDappKitRequestDeeplink(deeplink) - switch (dappKitRequest.type) { - case DappKitRequestTypes.ACCOUNT_ADDRESS: - ValoraAnalytics.track( - DappKitEvents.dappkit_request_propose, - getDefaultRequestTrackedProperties(dappKitRequest, activeDapp) - ) - navigate(Screens.DappKitAccountScreen, { dappKitRequest }) - break - case DappKitRequestTypes.SIGN_TX: - ValoraAnalytics.track( - DappKitEvents.dappkit_request_propose, - getDefaultRequestTrackedProperties(dappKitRequest, activeDapp) - ) - navigate(Screens.DappKitSignTxScreen, { dappKitRequest }) - break - default: - navigate(Screens.ErrorScreen, { errorMessage: 'Unsupported dapp request type' }) - Logger.warn(TAG, 'Unsupported dapp request type') - } - } catch (err) { - const error = ensureError(err) - navigate(Screens.ErrorScreen, { errorMessage: `Deep link not valid for dappkit: ${error}` }) - Logger.debug(TAG, `Deep link not valid for dappkit: ${error}`) - ValoraAnalytics.track(DappKitEvents.dappkit_parse_deeplink_error, { - dappRequestOrigin: getDappRequestOrigin(activeDapp), - deeplink, - error: error.message, - }) - } -} diff --git a/src/navigator/Navigator.tsx b/src/navigator/Navigator.tsx index 98726d009cc..b070d0835b6 100644 --- a/src/navigator/Navigator.tsx +++ b/src/navigator/Navigator.tsx @@ -27,8 +27,6 @@ import BackupIntroduction from 'src/backup/BackupIntroduction' import BackupPhrase, { navOptionsForBackupPhrase } from 'src/backup/BackupPhrase' import BackupQuiz, { navOptionsForQuiz } from 'src/backup/BackupQuiz' import ConsumerIncentivesHomeScreen from 'src/consumerIncentives/ConsumerIncentivesHomeScreen' -import DappKitAccountScreen from 'src/dappkit/DappKitAccountScreen' -import DappKitSignTxScreen from 'src/dappkit/DappKitSignTxScreen' import DappShortcutTransactionRequest from 'src/dapps/DappShortcutTransactionRequest' import DappShortcutsRewards from 'src/dapps/DappShortcutsRewards' import DappsScreen from 'src/dapps/DappsScreen' @@ -711,8 +709,6 @@ function nativeBottomSheets(BottomSheet: typeof RootStack) { return ( <> - - = { - DAppKitConnection: { - name: 'DAppKit Connection', - op: 'dappkit_connection', - }, - DAppKitTransaction: { - name: 'DAppKit Transaction', - op: 'dappkit_transaction', - }, FetchBalances: { name: 'Fetch Balances', op: 'fetch_balances', diff --git a/src/utils/linking.ts b/src/utils/linking.ts index 65d126dbfe1..e4a4fc3845b 100644 --- a/src/utils/linking.ts +++ b/src/utils/linking.ts @@ -22,7 +22,7 @@ export function navigateToURI(uri: string, backupUri?: string) { // We're NOT using `Linking.canOpenURL` here because we would need // the scheme to be added to LSApplicationQueriesSchemes on iOS - // which is not possible for DappKit callbacks + // which is not possible for arbitrary callbacks from other apps (DAppKit used to do this) Linking.openURL(uri).catch((reason) => { Logger.debug(TAG, 'URI not supported', uri) if (backupUri) { diff --git a/src/webview/WebViewScreen.tsx b/src/webview/WebViewScreen.tsx index 921699e591b..9e7444366d4 100644 --- a/src/webview/WebViewScreen.tsx +++ b/src/webview/WebViewScreen.tsx @@ -45,7 +45,7 @@ type RouteProps = NativeStackScreenProps type Props = RouteProps function WebViewScreen({ route, navigation }: Props) { - const { uri, dappkitDeeplink } = route.params + const { uri } = route.params const dispatch = useDispatch() const { t } = useTranslation() @@ -130,14 +130,6 @@ function WebViewScreen({ route, navigation }: Props) { } }, []) - useEffect(() => { - if (activeDapp && dappkitDeeplink) { - webViewRef.current?.injectJavaScript( - `window.history.replaceState({}, "", "${dappkitDeeplink}"); true;` - ) - } - }, [dappkitDeeplink, activeDapp]) - useBackHandler(() => { // android hardware back button functions as either browser back button or // app back button diff --git a/test/RootStateSchema.json b/test/RootStateSchema.json index 3f6b875887f..653ed5e4ade 100644 --- a/test/RootStateSchema.json +++ b/test/RootStateSchema.json @@ -3138,8 +3138,6 @@ "ChooseYourAdventure", "CoinbasePayScreen", "ConsumerIncentivesHomeScreen", - "DappKitAccountScreen", - "DappKitSignTxScreen", "DappShortcutTransactionRequest", "DappShortcutsRewards", "DappsScreen",