mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Replace toNumber calls on BigNumbers with toString (#9369)
This commit is contained in:
parent
253cd12bbb
commit
23683c1630
@ -19,7 +19,7 @@ export default class ConfirmTokenTransactionBase extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
tokenAddress: PropTypes.string,
|
tokenAddress: PropTypes.string,
|
||||||
toAddress: PropTypes.string,
|
toAddress: PropTypes.string,
|
||||||
tokenAmount: PropTypes.number,
|
tokenAmount: PropTypes.string,
|
||||||
tokenSymbol: PropTypes.string,
|
tokenSymbol: PropTypes.string,
|
||||||
fiatTransactionTotal: PropTypes.string,
|
fiatTransactionTotal: PropTypes.string,
|
||||||
ethTransactionTotal: PropTypes.string,
|
ethTransactionTotal: PropTypes.string,
|
||||||
@ -29,7 +29,7 @@ export default class ConfirmTokenTransactionBase extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
tokenAmount: 0,
|
tokenAmount: '0',
|
||||||
}
|
}
|
||||||
|
|
||||||
getFiatTransactionAmount () {
|
getFiatTransactionAmount () {
|
||||||
@ -46,7 +46,7 @@ export default class ConfirmTokenTransactionBase extends Component {
|
|||||||
renderSubtitleComponent () {
|
renderSubtitleComponent () {
|
||||||
const { contractExchangeRate, tokenAmount } = this.props
|
const { contractExchangeRate, tokenAmount } = this.props
|
||||||
|
|
||||||
const decimalEthValue = (tokenAmount * contractExchangeRate) || 0
|
const decimalEthValue = (tokenAmount * contractExchangeRate) || '0'
|
||||||
const hexWeiValue = getWeiHexFromDecimalValue({
|
const hexWeiValue = getWeiHexFromDecimalValue({
|
||||||
value: decimalEthValue,
|
value: decimalEthValue,
|
||||||
fromCurrency: ETH,
|
fromCurrency: ETH,
|
||||||
|
@ -44,7 +44,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const tokenData = getTokenData(data)
|
const tokenData = getTokenData(data)
|
||||||
const tokenValue = getTokenValueParam(tokenData)
|
const tokenValue = getTokenValueParam(tokenData)
|
||||||
const toAddress = getTokenAddressParam(tokenData)
|
const toAddress = getTokenAddressParam(tokenData)
|
||||||
const tokenAmount = tokenData && calcTokenAmount(tokenValue, decimals).toNumber()
|
const tokenAmount = tokenData && calcTokenAmount(tokenValue, decimals).toString()
|
||||||
const contractExchangeRate = contractExchangeRateSelector(state)
|
const contractExchangeRate = contractExchangeRateSelector(state)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -165,10 +165,10 @@ export const tokenAmountAndToAddressSelector = createSelector(
|
|||||||
const toParam = args[TOKEN_PARAM_TO]
|
const toParam = args[TOKEN_PARAM_TO]
|
||||||
const valueParam = args[TOKEN_PARAM_VALUE]
|
const valueParam = args[TOKEN_PARAM_VALUE]
|
||||||
toAddress = toParam || args[0]
|
toAddress = toParam || args[0]
|
||||||
const value = valueParam ? valueParam.toNumber() : args[1].toNumber()
|
const value = valueParam ? valueParam.toString() : args[1].toString()
|
||||||
|
|
||||||
if (tokenDecimals) {
|
if (tokenDecimals) {
|
||||||
tokenAmount = calcTokenAmount(value, tokenDecimals).toNumber()
|
tokenAmount = calcTokenAmount(value, tokenDecimals).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenAmount = roundExponential(tokenAmount)
|
tokenAmount = roundExponential(tokenAmount)
|
||||||
@ -190,10 +190,10 @@ export const approveTokenAmountAndToAddressSelector = createSelector(
|
|||||||
|
|
||||||
if (args && args.length) {
|
if (args && args.length) {
|
||||||
toAddress = args[TOKEN_PARAM_SPENDER]
|
toAddress = args[TOKEN_PARAM_SPENDER]
|
||||||
const value = args[TOKEN_PARAM_VALUE].toNumber()
|
const value = args[TOKEN_PARAM_VALUE].toString()
|
||||||
|
|
||||||
if (tokenDecimals) {
|
if (tokenDecimals) {
|
||||||
tokenAmount = calcTokenAmount(value, tokenDecimals).toNumber()
|
tokenAmount = calcTokenAmount(value, tokenDecimals).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenAmount = roundExponential(tokenAmount)
|
tokenAmount = roundExponential(tokenAmount)
|
||||||
@ -215,10 +215,10 @@ export const sendTokenTokenAmountAndToAddressSelector = createSelector(
|
|||||||
|
|
||||||
if (args && args.length) {
|
if (args && args.length) {
|
||||||
toAddress = args[TOKEN_PARAM_TO]
|
toAddress = args[TOKEN_PARAM_TO]
|
||||||
let value = args[TOKEN_PARAM_VALUE].toNumber()
|
let value = args[TOKEN_PARAM_VALUE].toString()
|
||||||
|
|
||||||
if (tokenDecimals) {
|
if (tokenDecimals) {
|
||||||
value = calcTokenAmount(value, tokenDecimals).toNumber()
|
value = calcTokenAmount(value, tokenDecimals).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenAmount = roundExponential(value)
|
tokenAmount = roundExponential(value)
|
||||||
|
@ -51,7 +51,7 @@ describe('Confirm Transaction Selector', function () {
|
|||||||
name: 'transfer',
|
name: 'transfer',
|
||||||
args: getEthersArrayLikeFromObj({
|
args: getEthersArrayLikeFromObj({
|
||||||
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
'_value': { toNumber: () => '1' },
|
'_value': { toString: () => '1' },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
tokenProps: {
|
tokenProps: {
|
||||||
@ -75,7 +75,7 @@ describe('Confirm Transaction Selector', function () {
|
|||||||
name: 'approve',
|
name: 'approve',
|
||||||
args: getEthersArrayLikeFromObj({
|
args: getEthersArrayLikeFromObj({
|
||||||
'_spender': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'_spender': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
'_value': { toNumber: () => '1' },
|
'_value': { toString: () => '1' },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
tokenProps: {
|
tokenProps: {
|
||||||
@ -99,7 +99,7 @@ describe('Confirm Transaction Selector', function () {
|
|||||||
name: 'transfer',
|
name: 'transfer',
|
||||||
args: getEthersArrayLikeFromObj({
|
args: getEthersArrayLikeFromObj({
|
||||||
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'_to': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
'_value': { toNumber: () => '1' },
|
'_value': { toString: () => '1' },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
tokenProps: {
|
tokenProps: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user