@cryptoalgebra/alm-sdk
Version:
Algebra ALM SDK
18 lines • 854 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_1 = require("@ethersproject/bignumber");
function parseBigInt(_value, decimals) {
var valueStr = _value.toString();
// Handle scientific notation by converting to a full decimal string
if (valueStr.includes('e') || valueStr.includes('E')) {
valueStr = Number(valueStr).toFixed(decimals);
}
var _a = valueStr.split('.'), wholePart = _a[0], _b = _a[1], fractionalPart = _b === void 0 ? '' : _b;
if (fractionalPart.length > decimals)
throw new Error("Number ".concat(valueStr, " is too long"));
var combined = wholePart + fractionalPart.padEnd(decimals, '0');
var bigNumberValue = bignumber_1.BigNumber.from(combined);
return bigNumberValue;
}
exports.default = parseBigInt;
//# sourceMappingURL=parseBigInt.js.map