Skip to content

Commit

Permalink
Merge pull request #5060 from MetaMask/bignumber-string
Browse files Browse the repository at this point in the history
Cast arguments for new Bignumbers() to string.
  • Loading branch information
danfinlay authored Aug 14, 2018
2 parents 742aa8b + ebb2372 commit d7aa1bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ui/app/conversion-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const decToBigNumberViaString = n => R.pipe(String, toBigNumber['dec'])
// Setter Maps
const toBigNumber = {
hex: n => new BigNumber(stripHexPrefix(n), 16),
dec: n => new BigNumber(n, 10),
dec: n => new BigNumber(String(n), 10),
BN: n => new BigNumber(n.toString(16), 16),
}
const toNormalizedDenomination = {
Expand Down Expand Up @@ -154,7 +154,7 @@ const subtractCurrencies = (a, b, options = {}) => {
bBase,
...conversionOptions
} = options
const value = (new BigNumber(a, aBase)).minus(b, bBase)
const value = (new BigNumber(String(a), aBase)).minus(b, bBase)

return converter({
value,
Expand Down
2 changes: 1 addition & 1 deletion ui/app/helpers/confirm-transaction/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function hasUnconfirmedTransactions (state) {

export function roundExponential (value) {
const PRECISION = 4
const bigNumberValue = new BigNumber(value)
const bigNumberValue = new BigNumber(String(value))

// In JS, numbers with exponentials greater than 20 get displayed as an exponential.
return bigNumberValue.e > 20 ? Number(bigNumberValue.toPrecision(PRECISION)) : value
Expand Down
2 changes: 1 addition & 1 deletion ui/app/token-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function getSymbolAndDecimals (tokenAddress, existingTokens = []) {

function calcTokenAmount (value, decimals) {
const multiplier = Math.pow(10, Number(decimals || 0))
return new BigNumber(value).div(multiplier).toNumber()
return new BigNumber(String(value)).div(multiplier).toNumber()
}


Expand Down

0 comments on commit d7aa1bf

Please sign in to comment.