Skip to content

Commit

Permalink
Selector getKnownMethodData should return empty object if user has op…
Browse files Browse the repository at this point in the history
…ted out for using 4Byte Resolution
  • Loading branch information
jpuri committed Sep 17, 2024
1 parent 4b48aa9 commit 44ed8bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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", () => {
Expand All @@ -75,6 +75,6 @@ describe('useFourByte', () => {
},
);

expect(result.current).toBeUndefined();
expect(result.current).toEqual({});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const MethodDataRow = () => {

const methodData = useFourByte(currentConfirmation);

if (!methodData) {
if (!methodData?.name) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,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) {
Expand Down

0 comments on commit 44ed8bd

Please sign in to comment.