UNPKG

@bitte-ai/agent-sdk

Version:

Agent SDK for Bitte Protocol

30 lines (29 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NULL_TRANSACTION = void 0; exports.scientificToDecimal = scientificToDecimal; exports.NULL_TRANSACTION = { to: "0x0000000000000000000000000000000000000000", value: "0x00", data: "0x", }; function scientificToDecimal(num) { // If not in scientific notation, return as is if (!/^\d+\.?\d*e[+-]*\d+$/i.test(num.toString())) { return num.toString(); } const parts = num.toString().toLowerCase().split("e"); const mantissa = parts[0]; const exponent = parseInt(parts[1], 10); // Remove decimal point from mantissa if exists const [whole = "", decimal = ""] = mantissa.split("."); const mantissaWithoutPoint = whole + decimal; if (exponent > 0) { const zerosToAdd = exponent - decimal.length; return mantissaWithoutPoint + "0".repeat(Math.max(0, zerosToAdd)); } else { const absExponent = Math.abs(exponent); return `0.${"0".repeat(absExponent - 1)}${mantissaWithoutPoint}`; } }