From 7702e540375aed0cc4807fb727d1c1ece23d7068 Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Thu, 14 Nov 2024 17:24:36 +0000 Subject: [PATCH] chore: improve signature redesign approval type readability --- shared/modules/confirmation.utils.test.ts | 10 +++++----- shared/modules/confirmation.utils.ts | 8 ++++---- ui/pages/confirmations/hooks/useCurrentConfirmation.ts | 2 +- ui/pages/confirmations/utils/confirm.ts | 4 ++-- ui/pages/routes/routes.component.js | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/shared/modules/confirmation.utils.test.ts b/shared/modules/confirmation.utils.test.ts index 2d977eaca53c..0f26685060cb 100644 --- a/shared/modules/confirmation.utils.test.ts +++ b/shared/modules/confirmation.utils.test.ts @@ -1,7 +1,7 @@ import { TransactionType } from '@metamask/transaction-controller'; import { ApprovalType } from '@metamask/controller-utils'; import { - REDESIGN_APPROVAL_TYPES, + REDESIGN_SIGNATURE_APPROVAL_TYPES, shouldUseRedesignForTransactions, shouldUseRedesignForSignatures, } from './confirmation.utils'; @@ -138,7 +138,7 @@ describe('confirmation.utils', () => { }); it('should return true for supported approval types when user setting is enabled', () => { - REDESIGN_APPROVAL_TYPES.forEach((approvalType) => { + REDESIGN_SIGNATURE_APPROVAL_TYPES.forEach((approvalType) => { expect( shouldUseRedesignForSignatures( approvalType, @@ -152,7 +152,7 @@ describe('confirmation.utils', () => { it('should return true for supported approval types when developer mode is enabled via env', () => { process.env.ENABLE_CONFIRMATION_REDESIGN = 'true'; - REDESIGN_APPROVAL_TYPES.forEach((approvalType) => { + REDESIGN_SIGNATURE_APPROVAL_TYPES.forEach((approvalType) => { expect( shouldUseRedesignForSignatures( approvalType, @@ -164,7 +164,7 @@ describe('confirmation.utils', () => { }); it('should return true for supported approval types when developer setting is enabled', () => { - REDESIGN_APPROVAL_TYPES.forEach((approvalType) => { + REDESIGN_SIGNATURE_APPROVAL_TYPES.forEach((approvalType) => { expect( shouldUseRedesignForSignatures( approvalType, @@ -190,7 +190,7 @@ describe('confirmation.utils', () => { it('should return false when both user setting and developer mode are disabled', () => { process.env.ENABLE_CONFIRMATION_REDESIGN = 'false'; - REDESIGN_APPROVAL_TYPES.forEach((approvalType) => { + REDESIGN_SIGNATURE_APPROVAL_TYPES.forEach((approvalType) => { expect( shouldUseRedesignForSignatures( approvalType, diff --git a/shared/modules/confirmation.utils.ts b/shared/modules/confirmation.utils.ts index 8df73419e8fa..c464ee65cf72 100644 --- a/shared/modules/confirmation.utils.ts +++ b/shared/modules/confirmation.utils.ts @@ -1,7 +1,7 @@ import { TransactionType } from '@metamask/transaction-controller'; import { ApprovalType } from '@metamask/controller-utils'; -export const REDESIGN_APPROVAL_TYPES = [ +export const REDESIGN_SIGNATURE_APPROVAL_TYPES = [ ApprovalType.EthSignTypedData, ApprovalType.PersonalSign, ]; @@ -30,8 +30,8 @@ const isCorrectUserTransactionType = ( transactionMetadataType: TransactionType, ): boolean => REDESIGN_USER_TRANSACTION_TYPES.includes(transactionMetadataType); -const isCorrectApprovalType = (approvalType: ApprovalType): boolean => - REDESIGN_APPROVAL_TYPES.includes(approvalType); +const isCorrectSignatureApprovalType = (approvalType: ApprovalType): boolean => + REDESIGN_SIGNATURE_APPROVAL_TYPES.includes(approvalType); const shouldUseRedesignForTransactionsDeveloperMode = ( isRedesignedConfirmationsDeveloperEnabled: boolean, @@ -71,7 +71,7 @@ export const shouldUseRedesignForSignatures = ( process.env.ENABLE_CONFIRMATION_REDESIGN === 'true' || isRedesignedConfirmationsDeveloperEnabled; - if (!isCorrectApprovalType(approvalType)) { + if (!isCorrectSignatureApprovalType(approvalType)) { return false; } diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index 61e668f096d2..88c288347dd1 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -74,7 +74,7 @@ const useCurrentConfirmation = () => { // If the developer toggle or the build time environment variable are enabled, // all the signatures and transactions in development are shown. If the user // facing feature toggles for signature or transactions are enabled, we show - // only confirmations that shipped (contained in `REDESIGN_APPROVAL_TYPES` and + // only confirmations that shipped (contained in `REDESIGN_SIGNATURE_APPROVAL_TYPES` and // `REDESIGN_USER_TRANSACTION_TYPES` or `REDESIGN_DEV_TRANSACTION_TYPES` // respectively). const shouldUseRedesign = diff --git a/ui/pages/confirmations/utils/confirm.ts b/ui/pages/confirmations/utils/confirm.ts index f505935a8dfc..82d1872d3ca3 100644 --- a/ui/pages/confirmations/utils/confirm.ts +++ b/ui/pages/confirmations/utils/confirm.ts @@ -10,11 +10,11 @@ import { parseTypedDataMessage } from '../../../../shared/modules/transaction.ut import { sanitizeMessage } from '../../../helpers/utils/util'; import { Confirmation, SignatureRequestType } from '../types/confirm'; import { TYPED_SIGNATURE_VERSIONS } from '../constants'; -import { REDESIGN_APPROVAL_TYPES } from '../../../../shared/modules/confirmation.utils'; +import { REDESIGN_SIGNATURE_APPROVAL_TYPES } from '../../../../shared/modules/confirmation.utils'; export const isSignatureApprovalRequest = ( request: ApprovalRequest>, -) => REDESIGN_APPROVAL_TYPES.includes(request.type as ApprovalType); +) => REDESIGN_SIGNATURE_APPROVAL_TYPES.includes(request.type as ApprovalType); export const SIGNATURE_TRANSACTION_TYPES = [ TransactionType.personalSign, diff --git a/ui/pages/routes/routes.component.js b/ui/pages/routes/routes.component.js index ffd9d279f1f8..f23bda387650 100644 --- a/ui/pages/routes/routes.component.js +++ b/ui/pages/routes/routes.component.js @@ -115,7 +115,7 @@ import NftFullImage from '../../components/app/assets/nfts/nft-details/nft-full- import CrossChainSwap from '../bridge'; import { ToastMaster } from '../../components/app/toast-master/toast-master'; import { - REDESIGN_APPROVAL_TYPES, + REDESIGN_SIGNATURE_APPROVAL_TYPES, REDESIGN_DEV_TRANSACTION_TYPES, } from '../../../shared/modules/confirmation.utils'; import { @@ -471,7 +471,7 @@ export default class Routes extends Component { const pendingApproval = pendingApprovals.find( (approval) => approval.id === confirmationId, ); - const isCorrectApprovalType = REDESIGN_APPROVAL_TYPES.includes( + const isCorrectApprovalType = REDESIGN_SIGNATURE_APPROVAL_TYPES.includes( pendingApproval?.type, ); const isCorrectDeveloperTransactionType =