From 8365344fb237b3c20caa0e2e9a71ca5c7170a932 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 14:15:56 +0530 Subject: [PATCH 1/6] Selector getKnownMethodData should return empty object if user has opted out for using 4Byte Resolution --- ui/selectors/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 35bee7771dff..1394cd74f347 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -1262,7 +1262,7 @@ export function getKnownMethodData(state, data) { const fourBytePrefix = prefixedData.slice(0, 10); const { knownMethodData, use4ByteResolution } = state.metamask; // If 4byte setting is off, we do not want to return the knownMethodData - return use4ByteResolution ? knownMethodData?.[fourBytePrefix] : undefined; + return use4ByteResolution ? knownMethodData?.[fourBytePrefix] : {}; } export function getFeatureFlags(state) { From b47f50b5eee516312b11a993b7fb7c104524104e Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 15:21:14 +0530 Subject: [PATCH 2/6] fix build --- .../components/confirm/info/hooks/useFourByte.test.ts | 4 ++-- .../info/hooks/useKnownMethodDataInTransaction.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts index 1c3d66570d8b..a865603095d1 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts @@ -34,7 +34,7 @@ describe('useFourByte', () => { expect(result.current.params).toEqual([]); }); - it('returns undefined if resolution is turned off', () => { + it('returns empty object if resolution is turned off', () => { const currentConfirmation = genUnapprovedContractInteractionConfirmation({ address: CONTRACT_INTERACTION_SENDER_ADDRESS, txData: depositHexData, @@ -54,7 +54,7 @@ describe('useFourByte', () => { }, ); - expect(result.current).toBeUndefined(); + expect(result.current).toEqual({}); }); it("returns undefined if it's not known even if resolution is enabled", () => { diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts index 1c3d66570d8b..ea4bae9baf8e 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts @@ -34,7 +34,7 @@ describe('useFourByte', () => { expect(result.current.params).toEqual([]); }); - it('returns undefined if resolution is turned off', () => { + it('returns rmpty object if resolution is turned off', () => { const currentConfirmation = genUnapprovedContractInteractionConfirmation({ address: CONTRACT_INTERACTION_SENDER_ADDRESS, txData: depositHexData, @@ -54,7 +54,7 @@ describe('useFourByte', () => { }, ); - expect(result.current).toBeUndefined(); + expect(result.current).toEqual({}); }); it("returns undefined if it's not known even if resolution is enabled", () => { From 30328f0c51c16a5872f6fb62877932a2d83b5920 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 16:35:04 +0530 Subject: [PATCH 3/6] fix build --- .../confirm/info/hooks/useKnownMethodDataInTransaction.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts index ea4bae9baf8e..a865603095d1 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts @@ -34,7 +34,7 @@ describe('useFourByte', () => { expect(result.current.params).toEqual([]); }); - it('returns rmpty object if resolution is turned off', () => { + it('returns empty object if resolution is turned off', () => { const currentConfirmation = genUnapprovedContractInteractionConfirmation({ address: CONTRACT_INTERACTION_SENDER_ADDRESS, txData: depositHexData, From 14044f2146ea0b901745554385ee8e8e8db8f7e9 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 16:37:34 +0530 Subject: [PATCH 4/6] update --- ui/selectors/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 1394cd74f347..7d278675efd9 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -1262,7 +1262,7 @@ export function getKnownMethodData(state, data) { const fourBytePrefix = prefixedData.slice(0, 10); const { knownMethodData, use4ByteResolution } = state.metamask; // If 4byte setting is off, we do not want to return the knownMethodData - return use4ByteResolution ? knownMethodData?.[fourBytePrefix] : {}; + return use4ByteResolution ? knownMethodData?.[fourBytePrefix] ?? {} : {}; } export function getFeatureFlags(state) { From e65d5e6843fb9753d129160f5800502770f89608 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 17:04:52 +0530 Subject: [PATCH 5/6] update --- .../components/confirm/info/hooks/useFourByte.test.ts | 2 +- .../confirm/info/hooks/useKnownMethodDataInTransaction.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts index a865603095d1..bdff31ac33e6 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useFourByte.test.ts @@ -75,6 +75,6 @@ describe('useFourByte', () => { }, ); - expect(result.current).toBeUndefined(); + expect(result.current).toEqual({}); }); }); diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts index a865603095d1..bdff31ac33e6 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useKnownMethodDataInTransaction.test.ts @@ -75,6 +75,6 @@ describe('useFourByte', () => { }, ); - expect(result.current).toBeUndefined(); + expect(result.current).toEqual({}); }); }); From 4450a716f48a847f59fab6ecdf8fd6d471b07e42 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 17 Sep 2024 17:15:54 +0530 Subject: [PATCH 6/6] update --- .../info/shared/transaction-details/transaction-details.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/confirmations/components/confirm/info/shared/transaction-details/transaction-details.tsx b/ui/pages/confirmations/components/confirm/info/shared/transaction-details/transaction-details.tsx index f911c78fd343..e53387af325a 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/transaction-details/transaction-details.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/transaction-details/transaction-details.tsx @@ -68,7 +68,7 @@ export const MethodDataRow = () => { const { currentConfirmation } = useConfirmContext(); const methodData = useFourByte(currentConfirmation); - if (!methodData) { + if (!methodData?.name) { return null; }