Skip to content

Commit

Permalink
Fix knownMethodData retrieval and data fetching from fourbyte
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Jun 17, 2019
1 parent 919b784 commit 91be4a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ui/app/helpers/utils/transactions.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ async function getMethodFrom4Byte (fourBytePrefix) {
body: null,
method: 'GET',
mode: 'cors',
})).json()
}))

if (fourByteResponse.count === 1) {
return fourByteResponse.results[0].text_signature
const fourByteJSON = await fourByteResponse.json()

if (fourByteJSON.count === 1) {
return fourByteJSON.results[0].text_signature
} else {
return null
}
Expand All @@ -62,6 +64,7 @@ export async function getMethodDataAsync (fourBytePrefix) {
})

let sig = await registry.lookup(fourBytePrefix)

if (!sig) {
sig = await fourByteSig
}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2798,14 +2798,14 @@ function getContractMethodData (data = '') {
return (dispatch, getState) => {
const prefixedData = ethUtil.addHexPrefix(data)
const fourBytePrefix = prefixedData.slice(0, 10)
const { knownMethodData } = getState().metamask.knownMethodData

const { knownMethodData } = getState().metamask
if (knownMethodData && knownMethodData[fourBytePrefix]) {
return Promise.resolve(knownMethodData[fourBytePrefix])
}

dispatch(actions.loadingMethoDataStarted())
log.debug(`loadingMethodData`)

return getMethodDataAsync(fourBytePrefix)
.then(({ name, params }) => {
dispatch(actions.loadingMethoDataFinished())
Expand Down

0 comments on commit 91be4a9

Please sign in to comment.