mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Revert "Adds 4byte registry fallback to getMethodData() (#6435)"
This reverts commit 09f2a2a547
.
This commit is contained in:
parent
13605c2b5e
commit
608796398e
@ -30,21 +30,6 @@ export function getTokenData (data = '') {
|
|||||||
return abiDecoder.decodeMethod(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 })
|
const registry = new MethodRegistry({ provider: global.ethereumProvider })
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,16 +43,7 @@ const registry = new MethodRegistry({ provider: global.ethereumProvider })
|
|||||||
const fourBytePrefix = prefixedData.slice(0, 10)
|
const fourBytePrefix = prefixedData.slice(0, 10)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fourByteSig = getMethodFrom4Byte(fourBytePrefix).catch((e) => {
|
const sig = await registry.lookup(fourBytePrefix)
|
||||||
log.error(e)
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
|
|
||||||
let sig = await registry.lookup(fourBytePrefix)
|
|
||||||
|
|
||||||
if (!sig) {
|
|
||||||
sig = await fourByteSig
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sig) {
|
if (!sig) {
|
||||||
return {}
|
return {}
|
||||||
@ -81,8 +57,8 @@ const registry = new MethodRegistry({ provider: global.ethereumProvider })
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error)
|
log.error(error)
|
||||||
const tokenData = getTokenData(data)
|
const contractData = getTokenData(data)
|
||||||
const { name } = tokenData || {}
|
const { name } = contractData || {}
|
||||||
return { name }
|
return { name }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
toName={toName}
|
toName={toName}
|
||||||
toAddress={toAddress}
|
toAddress={toAddress}
|
||||||
showEdit={onEdit && !isTxReprice}
|
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}
|
title={title}
|
||||||
titleComponent={this.renderTitleComponent()}
|
titleComponent={this.renderTitleComponent()}
|
||||||
subtitle={subtitle}
|
subtitle={subtitle}
|
||||||
|
Loading…
Reference in New Issue
Block a user