Skip to content

Commit

Permalink
Merge pull request #6521 from MetaMask/revert-6435-4byte-registry-fal…
Browse files Browse the repository at this point in the history
…lback

Revert "Adds 4byte registry fallback to getMethodData()"
  • Loading branch information
danfinlay authored Apr 26, 2019
2 parents 13605c2 + 6087963 commit 63e5e68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
30 changes: 3 additions & 27 deletions ui/app/helpers/utils/transactions.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@ export function getTokenData (data = '') {
return abiDecoder.decodeMethod(data)
}

async function getMethodFrom4Byte (fourBytePrefix) {
const fourByteResponse = (await fetch(`https://www.4byte.directory/api/v1/signatures/?hex_signature=${fourBytePrefix}`, {
referrerPolicy: 'no-referrer-when-downgrade',
body: null,
method: 'GET',
mode: 'cors',
})).json()

if (fourByteResponse.count === 1) {
return fourByteResponse.results[0].text_signature
} else {
return null
}
}

const registry = new MethodRegistry({ provider: global.ethereumProvider })

/**
Expand All @@ -58,16 +43,7 @@ const registry = new MethodRegistry({ provider: global.ethereumProvider })
const fourBytePrefix = prefixedData.slice(0, 10)

try {
const fourByteSig = getMethodFrom4Byte(fourBytePrefix).catch((e) => {
log.error(e)
return null
})

let sig = await registry.lookup(fourBytePrefix)

if (!sig) {
sig = await fourByteSig
}
const sig = await registry.lookup(fourBytePrefix)

if (!sig) {
return {}
Expand All @@ -81,8 +57,8 @@ const registry = new MethodRegistry({ provider: global.ethereumProvider })
}
} catch (error) {
log.error(error)
const tokenData = getTokenData(data)
const { name } = tokenData || {}
const contractData = getTokenData(data)
const { name } = contractData || {}
return { name }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export default class ConfirmTransactionBase extends Component {
toName={toName}
toAddress={toAddress}
showEdit={onEdit && !isTxReprice}
action={actionKey && this.context.t(actionKey) || getMethodName(name) || this.context.t('contractInteraction')}
action={this.context.t(actionKey) || getMethodName(name) || this.context.t('contractInteraction')}
title={title}
titleComponent={this.renderTitleComponent()}
subtitle={subtitle}
Expand Down

0 comments on commit 63e5e68

Please sign in to comment.