Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const convertLSKToBeddows = (lskAmount?: string): string => {
if (typeof lskAmount !== 'string') {
throw new Error('Cannot convert non-string amount');
}
if (getDecimalPlaces(lskAmount) > LISK_MAX_DECIMAL_POINTS) {
throw new Error('LSK amount has too many decimal points');
}
const lskAmountBigNum = new BigNum(lskAmount);
const beddowsAmountBigNum = lskAmountBigNum.mul(FIXED_POINT);
if (isGreaterThanMaxTransactionAmount(beddowsAmountBigNum)) {
throw new Error('LSK amount out of range');
}
return beddowsAmountBigNum.toString();
};
export const convertBeddowsToLSK = (beddowsAmount?: string): string => {
if (typeof beddowsAmount !== 'string') {
throw new Error('Cannot convert non-string amount');
}
if (getDecimalPlaces(beddowsAmount)) {
throw new Error('Beddows amount should not have decimal points');
}
const beddowsAmountBigNum = new BigNum(beddowsAmount);
if (isGreaterThanMaxTransactionAmount(beddowsAmountBigNum)) {
throw new Error('Beddows amount out of range');
}
const lskAmountBigNum = beddowsAmountBigNum.div(FIXED_POINT);
return lskAmountBigNum.toString(BASE_10);
};