diff --git a/src/redux/requests.ts b/src/redux/requests.ts index 3149d0e47d9..d9ee7f05113 100644 --- a/src/redux/requests.ts +++ b/src/redux/requests.ts @@ -80,7 +80,7 @@ export interface RequestData { sessionRequestEvent: SignClientTypes.EventArguments['session_request']; address: string; chainId: number; - onComplete(): void; + onComplete(type: string): void; }; } diff --git a/src/redux/walletconnect.ts b/src/redux/walletconnect.ts index b0db05a194b..cf833bff8d9 100644 --- a/src/redux/walletconnect.ts +++ b/src/redux/walletconnect.ts @@ -28,7 +28,7 @@ import Routes from '@/navigation/routesNames'; import { ethereumUtils, watchingAlert } from '@/utils'; import { getFCMToken } from '@/notifications/tokens'; import { logger, RainbowError } from '@/logger'; -import { IS_DEV, IS_TEST } from '@/env'; +import { IS_DEV, IS_IOS, IS_TEST } from '@/env'; import { RainbowNetworks } from '@/networks'; // -- Variables --------------------------------------- // @@ -261,15 +261,19 @@ export const walletConnectRemovePendingRedirect = ( } else if (type !== 'timedOut') { if (type === 'sign' || type === 'transaction') { showRedirectSheetThreshold += BIOMETRICS_ANIMATION_DELAY; - setTimeout(() => { - Minimizer.goBack(); - }, BIOMETRICS_ANIMATION_DELAY); + if (!IS_IOS) { + setTimeout(() => { + Minimizer.goBack(); + }, BIOMETRICS_ANIMATION_DELAY); + } } else if (type === 'sign-canceled' || type === 'transaction-canceled') { - setTimeout(() => { - Minimizer.goBack(); - }, 300); + if (!IS_IOS) { + setTimeout(() => { + Minimizer.goBack(); + }, 300); + } } else { - !IS_TEST && Minimizer.goBack(); + !IS_TEST && !IS_IOS && Minimizer.goBack(); } // If it's still active after showRedirectSheetThreshold // We need to show the redirect sheet cause the redirect diff --git a/src/screens/TransactionConfirmationScreen.js b/src/screens/TransactionConfirmationScreen.js index b43cd760eb3..70710c7b2db 100644 --- a/src/screens/TransactionConfirmationScreen.js +++ b/src/screens/TransactionConfirmationScreen.js @@ -116,6 +116,7 @@ import { handleSessionRequestResponse } from '@/walletConnect'; import { isAddress } from '@ethersproject/address'; import { logger, RainbowError } from '@/logger'; import { getNetworkObj } from '@/networks'; +import { IS_IOS } from '@/env'; const springConfig = { damping: 500, @@ -419,20 +420,21 @@ export default function TransactionConfirmationScreen() { if (!isMessageRequest) { stopPollingGasFees(); } + + let type = method === SEND_TRANSACTION ? 'transaction' : 'sign'; + if (canceled) { + type = `${type}-canceled`; + } + if (pendingRedirect) { InteractionManager.runAfterInteractions(() => { - let type = method === SEND_TRANSACTION ? 'transaction' : 'sign'; - - if (canceled) { - type = `${type}-canceled`; - } dispatch(walletConnectRemovePendingRedirect(type, dappScheme)); }); } if (walletConnectV2RequestValues?.onComplete) { InteractionManager.runAfterInteractions(() => { - walletConnectV2RequestValues.onComplete(); + walletConnectV2RequestValues.onComplete(type); }); } }, @@ -819,6 +821,7 @@ export default function TransactionConfirmationScreen() { } dispatch(removeRequest(requestId)); } + closeScreen(false); // When the tx is sent from a different wallet, // we need to switch to that wallet before saving the tx diff --git a/src/screens/WalletConnectApprovalSheet.js b/src/screens/WalletConnectApprovalSheet.js index 5a0059b5a26..478e482d91b 100644 --- a/src/screens/WalletConnectApprovalSheet.js +++ b/src/screens/WalletConnectApprovalSheet.js @@ -50,6 +50,7 @@ import { AssetType } from '@/entities'; import { RainbowNetworks, getNetworkObj } from '@/networks'; import { handleReviewPromptAction } from '@/utils/reviewAlert'; import { ReviewPromptAction } from '@/storage/schema'; +import { IS_IOS } from '@/env'; const LoadingSpinner = styled(android ? Spinner : ActivityIndicator).attrs( ({ theme: { colors } }) => ({ @@ -355,12 +356,17 @@ export default function WalletConnectApprovalSheet() { const handleConnect = useCallback(() => { handled.current = true; goBack(); + if (IS_IOS) { + navigate(Routes.WALLET_CONNECT_REDIRECT_SHEET, { + type: 'connect', + }); + } handleSuccess(true); setTimeout(() => { handleReviewPromptAction(ReviewPromptAction.DappConnections); }, 500); - }, [handleSuccess, goBack]); + }, [handleSuccess, goBack, navigate]); const handleCancel = useCallback(() => { handled.current = true; diff --git a/src/walletConnect/index.tsx b/src/walletConnect/index.tsx index a1933e71afa..c81358602d2 100644 --- a/src/walletConnect/index.tsx +++ b/src/walletConnect/index.tsx @@ -38,7 +38,7 @@ import { import { saveLocalRequests } from '@/handlers/localstorage/walletconnectRequests'; import { events } from '@/handlers/appEvents'; import { getFCMToken } from '@/notifications/tokens'; -import { IS_DEV, IS_ANDROID } from '@/env'; +import { IS_DEV, IS_ANDROID, IS_IOS } from '@/env'; import { loadWallet } from '@/model/wallet'; import * as portal from '@/screens/Portal'; import * as explain from '@/screens/Explain'; @@ -93,7 +93,10 @@ export function maybeGoBackAndClearHasPendingRedirect({ InteractionManager.runAfterInteractions(() => { setTimeout(() => { setHasPendingDeeplinkPendingRedirect(false); - Minimizer.goBack(); + + if (!IS_IOS) { + Minimizer.goBack(); + } }, delay); }); } @@ -774,7 +777,13 @@ export async function onSessionRequest( // @ts-ignore we assign address above address, // required by screen chainId, // required by screen - onComplete() { + onComplete(type: string) { + if (IS_IOS) { + Navigation.handleAction(Routes.WALLET_CONNECT_REDIRECT_SHEET, { + type, + }); + } + maybeGoBackAndClearHasPendingRedirect({ delay: 300 }); }, },