Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/cashMethods.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | ) => { | ||||
if (!isValidSendAmount) { | if (!isValidSendAmount) { | ||||
return false; | return false; | ||||
} | } | ||||
const conversionFactor = new BigNumber(10 ** cashDecimals); | const conversionFactor = new BigNumber(10 ** cashDecimals); | ||||
const sendAmountSmallestDenomination = sendAmount.times(conversionFactor); | const sendAmountSmallestDenomination = sendAmount.times(conversionFactor); | ||||
return sendAmountSmallestDenomination; | return sendAmountSmallestDenomination; | ||||
}; | }; | ||||
export const formatBalance = x => { | export const formatBalance = (unformattedBalance, optionalLocale) => { | ||||
try { | try { | ||||
let balanceInParts = x.toString().split('.'); | if (unformattedBalance === undefined) { | ||||
balanceInParts[0] = balanceInParts[0].replace( | return 'N/A'; | ||||
/\B(?=(\d{3})+(?!\d))/g, | } else { | ||||
bytesofman: We don't need this `else` block; the `return` statement makes it obsolete. Please remove. | |||||
' ', | if (optionalLocale === undefined) { | ||||
return new Number(unformattedBalance).toLocaleString({ | |||||
maximumFractionDigits: currency.cashDecimals, | |||||
}); | |||||
} else { | |||||
bytesofmanUnsubmitted Not Done Inline ActionsSame for this else block, please remove bytesofman: Same for this `else` block, please remove | |||||
return new Number(unformattedBalance).toLocaleString( | |||||
optionalLocale, | |||||
{ | |||||
maximumFractionDigits: currency.cashDecimals, | |||||
}, | |||||
); | ); | ||||
return balanceInParts.join('.'); | } | ||||
} | |||||
} catch (err) { | } catch (err) { | ||||
console.log(`Error in formatBalance for ${x}`); | console.log(`Error in formatBalance for ${unformattedBalance}`); | ||||
console.log(err); | console.log(err); | ||||
return x; | return unformattedBalance; | ||||
} | } | ||||
}; | }; | ||||
export const batchArray = (inputArray, batchSize) => { | export const batchArray = (inputArray, batchSize) => { | ||||
// take an array of n elements, return an array of arrays each of length batchSize | // take an array of n elements, return an array of arrays each of length batchSize | ||||
const batchedArray = []; | const batchedArray = []; | ||||
for (let i = 0; i < inputArray.length; i += batchSize) { | for (let i = 0; i < inputArray.length; i += batchSize) { | ||||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |
We don't need this else block; the return statement makes it obsolete. Please remove.