Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/validation.js
Show All 36 Lines | ) { | ||||
) { | ) { | ||||
error = `${currency.ticker} transactions do not support more than ${currency.cashDecimals} decimal places`; | error = `${currency.ticker} transactions do not support more than ${currency.cashDecimals} decimal places`; | ||||
} | } | ||||
} | } | ||||
// return false if no error, or string error msg if error | // return false if no error, or string error msg if error | ||||
return error; | return error; | ||||
}; | }; | ||||
export const fiatToCrypto = (fiatAmount, fiatPrice) => { | export const fiatToCrypto = ( | ||||
fiatAmount, | |||||
fiatPrice, | |||||
cashDecimals = currency.cashDecimals, | |||||
) => { | |||||
let cryptoAmount = new BigNumber(fiatAmount) | let cryptoAmount = new BigNumber(fiatAmount) | ||||
.div(new BigNumber(fiatPrice)) | .div(new BigNumber(fiatPrice)) | ||||
.toFixed(currency.cashDecimals); | .toFixed(cashDecimals); | ||||
return cryptoAmount; | return cryptoAmount; | ||||
}; | }; | ||||
export const isValidTokenName = tokenName => { | export const isValidTokenName = tokenName => { | ||||
return ( | return ( | ||||
typeof tokenName === 'string' && | typeof tokenName === 'string' && | ||||
tokenName.length > 0 && | tokenName.length > 0 && | ||||
tokenName.length < 68 | tokenName.length < 68 | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |