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

Cast arguments for new Bignumbers() to string. #5060

Merged
merged 1 commit into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
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