Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use shared CustomAmountInput, dont allow too many decimals #1413

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 0 additions & 293 deletions app/tray/Account/Requests/TransactionRequest/TokenSpend/index.js

This file was deleted.

24 changes: 10 additions & 14 deletions app/tray/Account/Requests/TransactionRequest/TxAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BigNumber from 'bignumber.js'
import svg from '../../../../../../resources/svg'
import link from '../../../../../../resources/link'
import { ClusterBox, Cluster, ClusterRow, ClusterValue } from '../../../../../../resources/Components/Cluster'
import { formatDisplayInteger, isUnlimited } from '../../../../../../resources/utils/numbers'
import { formatDisplayDecimal, isUnlimited } from '../../../../../../resources/utils/numbers'
import { DisplayValue, DisplayCoinBalance } from '../../../../../../resources/Components/DisplayValue'
import { getAddress } from '../../../../../../resources/utils'

Expand Down Expand Up @@ -36,21 +36,12 @@ class TxSending extends React.Component {
amount,
decimals,
name,
recipient: recipientAddress,
symbol,
recipientType,
recipientEns
recipient: { address: recipientAddress, type: recipientType, ens: recipientEns },
symbol
} = action.data || {}
const address = getAddress(recipientAddress)
const ensName = recipientEns

// const ensName = (recipientEns && recipientEns.length < 25) ? recipientEns : ''
const value = new BigNumber(amount)
const displayValue = value
.dividedBy('1e' + decimals)
.decimalPlaces(6)
.toFormat()

const isTestnet = this.store('main.networks', this.props.chain.type, this.props.chain.id, 'isTestnet')
const rate = this.store('main.rates', contract)

Expand Down Expand Up @@ -120,14 +111,19 @@ class TxSending extends React.Component {
</ClusterBox>
)
} else if (actionType === 'approve') {
const { amount, decimals, spender: recipientAddress, symbol, spenderEns } = action.data || {}
const {
amount,
decimals,
spender: { address: recipientAddress, ens: spenderEns },
symbol
} = action.data || {}
const address = recipientAddress
const ensName = spenderEns
const value = new BigNumber(amount)
const revoke = value.eq(0)
const displayAmount = isUnlimited(this.state.amount)
? 'unlimited'
: formatDisplayInteger(amount, decimals)
: formatDisplayDecimal(amount, decimals)
const isSubmitted = req.status !== undefined

return (
Expand Down
24 changes: 16 additions & 8 deletions app/tray/Account/Requests/TransactionRequest/TxMainNew/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isNonZeroHex } from '../../../../../../resources/utils'
import { Cluster, ClusterRow, ClusterValue } from '../../../../../../resources/Components/Cluster'
import { DisplayValue } from '../../../../../../resources/Components/DisplayValue'
import RequestHeader from '../../../../../../resources/Components/RequestHeader'
import BigNumber from 'bignumber.js'

const SimpleContractCallOverview = ({ method }) => {
const body = method ? `Calling Contract Method ${method}` : 'Calling Contract'
Expand All @@ -17,16 +18,23 @@ const SimpleContractCallOverview = ({ method }) => {
}

const ApproveOverview = ({ amount, decimals, symbol }) => {
const isRevoke = BigNumber(amount).isZero()
return (
<div>
<span>{'Approve Spending '}</span>
<DisplayValue
type='ether'
value={amount}
valueDataParams={{ decimals }}
currencySymbol={symbol}
currencySymbolPosition='last'
/>
{isRevoke ? (
<span>{`Revoke Approval for ${symbol} `}</span>
Jamchello marked this conversation as resolved.
Show resolved Hide resolved
) : (
<>
<span>{'Approve Spending'}</span>
<DisplayValue
type='ether'
value={amount}
valueDataParams={{ decimals }}
currencySymbol={symbol}
currencySymbolPosition='last'
/>
</>
)}
</div>
)
}
Expand Down
Loading