@aptos-labs/ts-sdk - v7.1.0
    Preparing search index...

    Function u64ToNumberSafe

    • Narrows a u64 (bigint) into a JS number with an explicit safety check.

      The deserializeU64 reader returns bigint, but several keyless code paths historically narrowed the value with Number(value) to fit existing number-typed fields (expiry timestamps, expiry horizons). For values larger than Number.MAX_SAFE_INTEGER (~9 × 10^15), Number(bigint) silently loses precision — comparisons against Date.now() / 1000 then return wrong results.

      Real-world expiry values are far below the unsafe range (year ~285 million AD as a Unix timestamp), so this check is effectively a guard against corrupted or malicious BCS data rather than a precision concern in normal operation. Throwing is correct behavior at the BCS/JSON boundary.

      Parameters

      • value: bigint
      • fieldName: string

      Returns number