From 315028ec53654c4ad7817741330627eae742e59d Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Wed, 24 Oct 2018 23:27:16 +0800 Subject: [PATCH] Fix UnknownFunction showing as Confirm (#5590) --- ui/app/helpers/transactions.util.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index e50196196..64ec82225 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -27,10 +27,21 @@ export function getTokenData (data = '') { const registry = new MethodRegistry({ provider: global.ethereumProvider }) +/** + * Attempts to return the method data from the MethodRegistry library, if the method exists in the + * registry. Otherwise, returns an empty object. + * @param {string} data - The hex data (@code txParams.data) of a transaction + * @returns {Object} + */ export async function getMethodData (data = '') { const prefixedData = ethUtil.addHexPrefix(data) const fourBytePrefix = prefixedData.slice(0, 10) const sig = await registry.lookup(fourBytePrefix) + + if (!sig) { + return {} + } + const parsedResult = registry.parse(sig) return {