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

cherrypick: User should be re-directed to old designs when signing using QR wallet #13168

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import * as AddressUtils from '../../../../util/address';
import { renderHookWithProvider } from '../../../../util/test/renderWithProvider';
import { personalSignatureConfirmationState } from '../../../../util/test/confirm-data-helpers';

// eslint-disable-next-line import/no-namespace
import * as QRHardwareAwareness from './useQRHardwareAwareness';
import { useConfirmationRedesignEnabled } from './useConfirmationRedesignEnabled';

jest.mock('../../../../core/Engine', () => ({
Expand Down Expand Up @@ -34,33 +32,7 @@ describe('useConfirmationRedesignEnabled', () => {
});

it('return false for external accounts', async () => {
jest.spyOn(AddressUtils, 'isExternalHardwareAccount').mockReturnValue(true);
const { result } = renderHookWithProvider(
() => useConfirmationRedesignEnabled(),
{
state: personalSignatureConfirmationState,
},
);
expect(result?.current.isRedesignedEnabled).toBeFalsy();
});

it('return false if QR hardware is syncing', async () => {
jest
.spyOn(QRHardwareAwareness, 'default')
.mockReturnValue({ isSigningQRObject: true, isSyncingQRHardware: false });
const { result } = renderHookWithProvider(
() => useConfirmationRedesignEnabled(),
{
state: personalSignatureConfirmationState,
},
);
expect(result?.current.isRedesignedEnabled).toBeFalsy();
});

it('return false if QR hardware has synced successfully', async () => {
jest
.spyOn(QRHardwareAwareness, 'default')
.mockReturnValue({ isSigningQRObject: false, isSyncingQRHardware: true });
jest.spyOn(AddressUtils, 'isHardwareAccount').mockReturnValue(true);
const { result } = renderHookWithProvider(
() => useConfirmationRedesignEnabled(),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { useMemo } from 'react';
import { useSelector } from 'react-redux';

import { ApprovalTypes } from '../../../../core/RPCMethods/RPCMethodMiddleware';
import { isExternalHardwareAccount } from '../../../../util/address';
import { isHardwareAccount } from '../../../../util/address';
import { selectRemoteFeatureFlags } from '../../../../selectors/featureFlagController';
import useApprovalRequest from './useApprovalRequest';
import useQRHardwareAwareness from './useQRHardwareAwareness';

export const useConfirmationRedesignEnabled = () => {
const { approvalRequest } = useApprovalRequest();
const { isSigningQRObject, isSyncingQRHardware } = useQRHardwareAwareness();
const { confirmation_redesign } = useSelector(selectRemoteFeatureFlags);

const approvalRequestType = approvalRequest?.type;
Expand All @@ -18,22 +16,13 @@ export const useConfirmationRedesignEnabled = () => {
const isRedesignedEnabled = useMemo(
() =>
(confirmation_redesign as Record<string, string>)?.signatures &&
// following condition will ensure that user is redirected to old designs is using QR scan aware hardware
!isSyncingQRHardware &&
!isSigningQRObject &&
// following condition will ensure that user is redirected to old designs for hardware wallets
!isExternalHardwareAccount(fromAddress) &&
!isHardwareAccount(fromAddress) &&
approvalRequestType &&
[ApprovalTypes.PERSONAL_SIGN, ApprovalTypes.ETH_SIGN_TYPED_DATA].includes(
approvalRequestType as ApprovalTypes,
),
[
approvalRequestType,
confirmation_redesign,
fromAddress,
isSigningQRObject,
isSyncingQRHardware,
],
[approvalRequestType, confirmation_redesign, fromAddress],
);

return { isRedesignedEnabled };
Expand Down

This file was deleted.

Loading