mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove unused with-method-data
HOC (#9050)
This higher-order-component has been unused since #6551
This commit is contained in:
parent
5899937165
commit
a0589d3290
@ -1 +0,0 @@
|
|||||||
export { default } from './with-method-data.component'
|
|
@ -1,65 +0,0 @@
|
|||||||
import React, { PureComponent } from 'react'
|
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
import { getMethodDataAsync, getFourBytePrefix } from '../../utils/transactions.util'
|
|
||||||
|
|
||||||
export default function withMethodData (WrappedComponent) {
|
|
||||||
return class MethodDataWrappedComponent extends PureComponent {
|
|
||||||
static propTypes = {
|
|
||||||
transaction: PropTypes.object,
|
|
||||||
knownMethodData: PropTypes.object,
|
|
||||||
addKnownMethodData: PropTypes.func,
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
transaction: {},
|
|
||||||
knownMethodData: {},
|
|
||||||
}
|
|
||||||
|
|
||||||
state = {
|
|
||||||
methodData: {},
|
|
||||||
done: false,
|
|
||||||
error: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
this.fetchMethodData()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchMethodData () {
|
|
||||||
const { transaction, knownMethodData, addKnownMethodData } = this.props
|
|
||||||
const { txParams: { data = '' } = {} } = transaction
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
try {
|
|
||||||
let methodData
|
|
||||||
const fourBytePrefix = getFourBytePrefix(data)
|
|
||||||
if (fourBytePrefix in knownMethodData) {
|
|
||||||
methodData = knownMethodData[fourBytePrefix]
|
|
||||||
} else {
|
|
||||||
methodData = await getMethodDataAsync(data)
|
|
||||||
if (!Object.entries(methodData).length === 0) {
|
|
||||||
addKnownMethodData(fourBytePrefix, methodData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ methodData, done: true })
|
|
||||||
} catch (error) {
|
|
||||||
this.setState({ done: true, error })
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.setState({ done: true })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { methodData, done, error } = this.state
|
|
||||||
|
|
||||||
return (
|
|
||||||
<WrappedComponent
|
|
||||||
{ ...this.props }
|
|
||||||
methodData={{ data: methodData, done, error }}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user