supra-ts-sdk - v2.0.0
    Preparing search index...

    Function stringifyWithBigInt

    • JSON.stringify that emits bigint values as exact JSON number literals.

      A u64 above Number.MAX_SAFE_INTEGER cannot survive a trip through a JavaScript number — Number(9007199254740993n) is 9007199254740992 — so a transaction body built that way no longer matches the transaction the caller signed. Keeping the value a bigint all the way to serialization avoids the lossy conversion, and writing it as a bare number literal keeps the wire format byte-identical to what the RPC already accepts (Rust's serde_json parses u64/u128 from number literals without going through a float).

      Every other value is serialized exactly as JSON.stringify would, so the output for a bigint-free input is unchanged.

      Parameters

      • value: unknown

        The value to serialize.

      Returns string

      The JSON text, with any bigint written as an exact number literal.

      If value is not JSON-serializable, or if a string inside value collides with the internal marker — the serializer fails closed rather than emitting a number the caller never supplied.