1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Replace toNumber calls on BigNumbers with toString (#9369)

This commit is contained in:
Erik Marks 2020-09-08 08:49:51 -07:00 committed by GitHub
parent 253cd12bbb
commit 23683c1630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

View File

@ -19,7 +19,7 @@ export default class ConfirmTokenTransactionBase extends Component {
static propTypes = {
tokenAddress: PropTypes.string,
toAddress: PropTypes.string,
tokenAmount: PropTypes.number,
tokenAmount: PropTypes.string,
tokenSymbol: PropTypes.string,
fiatTransactionTotal: PropTypes.string,
ethTransactionTotal: PropTypes.string,
@ -29,7 +29,7 @@ export default class ConfirmTokenTransactionBase extends Component {
}
static defaultProps = {
tokenAmount: 0,
tokenAmount: '0',
}
getFiatTransactionAmount () {
@ -46,7 +46,7 @@ export default class ConfirmTokenTransactionBase extends Component {
renderSubtitleComponent () {
const { contractExchangeRate, tokenAmount } = this.props
const decimalEthValue = (tokenAmount * contractExchangeRate) || 0
const decimalEthValue = (tokenAmount * contractExchangeRate) || '0'
const hexWeiValue = getWeiHexFromDecimalValue({
value: decimalEthValue,
fromCurrency: ETH,

View File

@ -44,7 +44,7 @@ const mapStateToProps = (state, ownProps) => {
const tokenData = getTokenData(data)
const tokenValue = getTokenValueParam(tokenData)
const toAddress = getTokenAddressParam(tokenData)
const tokenAmount = tokenData && calcTokenAmount(tokenValue, decimals).toNumber()
const tokenAmount = tokenData && calcTokenAmount(tokenValue, decimals).toString()
const contractExchangeRate = contractExchangeRateSelector(state)
return {

View File

@ -165,10 +165,10 @@ export const tokenAmountAndToAddressSelector = createSelector(
const toParam = args[TOKEN_PARAM_TO]
const valueParam = args[TOKEN_PARAM_VALUE]
toAddress = toParam || args[0]
const value = valueParam ? valueParam.toNumber() : args[1].toNumber()
const value = valueParam ? valueParam.toString() : args[1].toString()
if (tokenDecimals) {
tokenAmount = calcTokenAmount(value, tokenDecimals).toNumber()
tokenAmount = calcTokenAmount(value, tokenDecimals).toString()
}
tokenAmount = roundExponential(tokenAmount)
@ -190,10 +190,10 @@ export const approveTokenAmountAndToAddressSelector = createSelector(
if (args && args.length) {
toAddress = args[TOKEN_PARAM_SPENDER]
const value = args[TOKEN_PARAM_VALUE].toNumber()
const value = args[TOKEN_PARAM_VALUE].toString()
if (tokenDecimals) {
tokenAmount = calcTokenAmount(value, tokenDecimals).toNumber()
tokenAmount = calcTokenAmount(value, tokenDecimals).toString()
}
tokenAmount = roundExponential(tokenAmount)
@ -215,10 +215,10 @@ export const sendTokenTokenAmountAndToAddressSelector = createSelector(
if (args && args.length) {
toAddress = args[TOKEN_PARAM_TO]
let value = args[TOKEN_PARAM_VALUE].toNumber()
let value = args[TOKEN_PARAM_VALUE].toString()
if (tokenDecimals) {
value = calcTokenAmount(value, tokenDecimals).toNumber()
value = calcTokenAmount(value, tokenDecimals).toString()
}
tokenAmount = roundExponential(value)

View File

@ -51,7 +51,7 @@ describe('Confirm Transaction Selector', function () {
name: 'transfer',
args: getEthersArrayLikeFromObj({
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
'_value': { toNumber: () => '1' },
'_value': { toString: () => '1' },
}),
},
tokenProps: {
@ -75,7 +75,7 @@ describe('Confirm Transaction Selector', function () {
name: 'approve',
args: getEthersArrayLikeFromObj({
'_spender': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
'_value': { toNumber: () => '1' },
'_value': { toString: () => '1' },
}),
},
tokenProps: {
@ -99,7 +99,7 @@ describe('Confirm Transaction Selector', function () {
name: 'transfer',
args: getEthersArrayLikeFromObj({
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
'_value': { toNumber: () => '1' },
'_value': { toString: () => '1' },
}),
},
tokenProps: {