1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Cast arguments for new Bignumbers() to string.

This commit is contained in:
Dan Miller 2018-08-14 00:42:22 -02:30
parent e2be22a4b7
commit ebb23721ed
3 changed files with 4 additions and 4 deletions

View File

@ -46,7 +46,7 @@ const decToBigNumberViaString = n => R.pipe(String, toBigNumber['dec'])
// Setter Maps // Setter Maps
const toBigNumber = { const toBigNumber = {
hex: n => new BigNumber(stripHexPrefix(n), 16), 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), BN: n => new BigNumber(n.toString(16), 16),
} }
const toNormalizedDenomination = { const toNormalizedDenomination = {
@ -154,7 +154,7 @@ const subtractCurrencies = (a, b, options = {}) => {
bBase, bBase,
...conversionOptions ...conversionOptions
} = options } = options
const value = (new BigNumber(a, aBase)).minus(b, bBase) const value = (new BigNumber(String(a), aBase)).minus(b, bBase)
return converter({ return converter({
value, value,

View File

@ -141,7 +141,7 @@ export function hasUnconfirmedTransactions (state) {
export function roundExponential (value) { export function roundExponential (value) {
const PRECISION = 4 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. // In JS, numbers with exponentials greater than 20 get displayed as an exponential.
return bigNumberValue.e > 20 ? Number(bigNumberValue.toPrecision(PRECISION)) : value return bigNumberValue.e > 20 ? Number(bigNumberValue.toPrecision(PRECISION)) : value

View File

@ -44,7 +44,7 @@ async function getSymbolAndDecimals (tokenAddress, existingTokens = []) {
function calcTokenAmount (value, decimals) { function calcTokenAmount (value, decimals) {
const multiplier = Math.pow(10, Number(decimals || 0)) const multiplier = Math.pow(10, Number(decimals || 0))
return new BigNumber(value).div(multiplier).toNumber() return new BigNumber(String(value)).div(multiplier).toNumber()
} }