From 0026966c9ea5b15fe99b83415b8c90334c87877f Mon Sep 17 00:00:00 2001 From: Alex Donesky Date: Wed, 14 Sep 2022 13:36:53 -0500 Subject: [PATCH] Skip searching 4byte directory if we don't have a full 4 bytes of data (#15473) * skip searching 4byte directory if we don't have a full 4bytes of data * address feedback * lint --- ui/store/actions.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/store/actions.js b/ui/store/actions.js index 1b71f7fbb..b297d28eb 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -3257,13 +3257,14 @@ export function getContractMethodData(data = '') { return (dispatch, getState) => { const prefixedData = addHexPrefix(data); const fourBytePrefix = prefixedData.slice(0, 10); + if (fourBytePrefix.length < 10) { + return Promise.resolve({}); + } const { knownMethodData } = getState().metamask; - if ( - (knownMethodData && - knownMethodData[fourBytePrefix] && - Object.keys(knownMethodData[fourBytePrefix]).length !== 0) || - fourBytePrefix === '0x' + knownMethodData && + knownMethodData[fourBytePrefix] && + Object.keys(knownMethodData[fourBytePrefix]).length !== 0 ) { return Promise.resolve(knownMethodData[fourBytePrefix]); }