mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
7921196536
After updating the custom spend limit on the approve screen, the data for the transaction was not being updated. Instead it showed the original transaction data. The transaction data was being updated correctly in the final transaction though. The approve screen has been updated to ensure changes to the custom spend limit are reflected correctly in the data shown.
115 lines
3.2 KiB
JavaScript
115 lines
3.2 KiB
JavaScript
import React, { Component } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import ConfirmTransactionBase from '../confirm-transaction-base'
|
|
import ConfirmApproveContent from './confirm-approve-content'
|
|
import { getCustomTxParamsData } from './confirm-approve.util'
|
|
import {
|
|
calcTokenAmount,
|
|
} from '../../helpers/utils/token-util'
|
|
|
|
export default class ConfirmApprove extends Component {
|
|
static contextTypes = {
|
|
t: PropTypes.func,
|
|
}
|
|
|
|
static propTypes = {
|
|
tokenAddress: PropTypes.string,
|
|
toAddress: PropTypes.string,
|
|
tokenAmount: PropTypes.number,
|
|
tokenSymbol: PropTypes.string,
|
|
fiatTransactionTotal: PropTypes.string,
|
|
ethTransactionTotal: PropTypes.string,
|
|
contractExchangeRate: PropTypes.number,
|
|
conversionRate: PropTypes.number,
|
|
currentCurrency: PropTypes.string,
|
|
showCustomizeGasModal: PropTypes.func,
|
|
showEditApprovalPermissionModal: PropTypes.func,
|
|
origin: PropTypes.string,
|
|
siteImage: PropTypes.string,
|
|
tokenTrackerBalance: PropTypes.string,
|
|
data: PropTypes.string,
|
|
decimals: PropTypes.number,
|
|
txData: PropTypes.object,
|
|
}
|
|
|
|
static defaultProps = {
|
|
tokenAmount: 0,
|
|
}
|
|
|
|
state = {
|
|
customPermissionAmount: '',
|
|
}
|
|
|
|
componentDidUpdate (prevProps) {
|
|
const { tokenAmount } = this.props
|
|
|
|
if (tokenAmount !== prevProps.tokenAmount) {
|
|
this.setState({ customPermissionAmount: tokenAmount })
|
|
}
|
|
}
|
|
|
|
render () {
|
|
const {
|
|
toAddress,
|
|
tokenAddress,
|
|
tokenSymbol,
|
|
tokenAmount,
|
|
showCustomizeGasModal,
|
|
showEditApprovalPermissionModal,
|
|
origin,
|
|
siteImage,
|
|
tokenTrackerBalance,
|
|
data,
|
|
decimals,
|
|
txData,
|
|
currentCurrency,
|
|
ethTransactionTotal,
|
|
fiatTransactionTotal,
|
|
...restProps
|
|
} = this.props
|
|
const { customPermissionAmount } = this.state
|
|
|
|
const tokensText = `${tokenAmount} ${tokenSymbol}`
|
|
|
|
const tokenBalance = tokenTrackerBalance
|
|
? Number(calcTokenAmount(tokenTrackerBalance, decimals)).toPrecision(9)
|
|
: ''
|
|
|
|
const customData = customPermissionAmount
|
|
? getCustomTxParamsData(data, { customPermissionAmount, tokenAmount, decimals })
|
|
: null
|
|
|
|
return (
|
|
<ConfirmTransactionBase
|
|
toAddress={toAddress}
|
|
identiconAddress={tokenAddress}
|
|
showAccountInHeader
|
|
title={tokensText}
|
|
contentComponent={(
|
|
<ConfirmApproveContent
|
|
siteImage={siteImage}
|
|
setCustomAmount={(newAmount) => {
|
|
this.setState({ customPermissionAmount: newAmount })
|
|
}}
|
|
customTokenAmount={String(customPermissionAmount)}
|
|
tokenAmount={String(tokenAmount)}
|
|
origin={origin}
|
|
tokenSymbol={tokenSymbol}
|
|
tokenBalance={tokenBalance}
|
|
showCustomizeGasModal={() => showCustomizeGasModal(txData)}
|
|
showEditApprovalPermissionModal={showEditApprovalPermissionModal}
|
|
data={customData || data}
|
|
toAddress={toAddress}
|
|
currentCurrency={currentCurrency}
|
|
ethTransactionTotal={ethTransactionTotal}
|
|
fiatTransactionTotal={fiatTransactionTotal}
|
|
/>
|
|
)}
|
|
hideSenderToRecipient
|
|
customTxParamsData={customData}
|
|
{...restProps}
|
|
/>
|
|
)
|
|
}
|
|
}
|