A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/app/components/transaction-action/transaction-action.componen...

53 lines
1.2 KiB

import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { getTransactionActionKey } from '../../helpers/transactions.util'
export default class TransactionAction extends PureComponent {
static contextTypes = {
t: PropTypes.func,
}
static propTypes = {
className: PropTypes.string,
transaction: PropTypes.object,
methodData: PropTypes.object,
}
state = {
transactionAction: '',
}
componentDidMount () {
this.getTransactionAction()
}
componentDidUpdate () {
this.getTransactionAction()
}
async getTransactionAction () {
const { transactionAction } = this.state
const { transaction, methodData } = this.props
6 years ago
const { data, done } = methodData
6 years ago
if (!done || transactionAction) {
return
}
const actionKey = await getTransactionActionKey(transaction, data)
const action = actionKey && this.context.t(actionKey)
this.setState({ transactionAction: action })
}
render () {
const { className, methodData: { done } } = this.props
const { transactionAction } = this.state
return (
<div className={className}>
{ (done && transactionAction) || '--' }
</div>
)
}
}