blob: aa38afd8a3cbec6b6c00cda9c2a9c26018759563 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { getMethodData } from '../../helpers/confirm-transaction/util'
export default function withMethodData (WrappedComponent) {
return class MethodDataWrappedComponent extends PureComponent {
static propTypes = {
transaction: PropTypes.object,
}
static defaultProps = {
transaction: {},
}
state = {
methodData: {},
}
componentDidMount () {
this.fetchMethodData()
}
async fetchMethodData () {
const { transaction } = this.props
const { txParams: { data = '' } = {} } = transaction
if (data) {
const methodData = await getMethodData(data)
this.setState({ methodData })
}
}
render () {
const { methodData } = this.state
return (
<WrappedComponent
{ ...this.props }
methodData={methodData}
/>
)
}
}
}
|