diff --git a/packages/math/src/integers.ts b/packages/math/src/integers.ts index 923e11dd..e57d1468 100644 --- a/packages/math/src/integers.ts +++ b/packages/math/src/integers.ts @@ -25,6 +25,12 @@ export class Uint32 implements Integer, WithByteConverters { return Uint32.fromBytes(bytes); } + /** + * Creates a Uint32 from a fixed length byte array. + * + * @param bytes a list of exactly 4 bytes + * @param endianess defaults to big endian + */ public static fromBytes(bytes: ArrayLike, endianess: "be" | "le" = "be"): Uint32 { if (bytes.length !== 4) { throw new Error("Invalid input length. Expected 4 bytes."); @@ -168,6 +174,12 @@ export class Uint64 implements Integer, WithByteConverters { return Uint64.fromBytes(bytes); } + /** + * Creates a Uint64 from a fixed length byte array. + * + * @param bytes a list of exactly 8 bytes + * @param endianess defaults to big endian + */ public static fromBytes(bytes: ArrayLike, endianess: "be" | "le" = "be"): Uint64 { if (bytes.length !== 8) { throw new Error("Invalid input length. Expected 8 bytes."); diff --git a/packages/math/types/integers.d.ts b/packages/math/types/integers.d.ts index 9a4cf8a3..b1078dcf 100644 --- a/packages/math/types/integers.d.ts +++ b/packages/math/types/integers.d.ts @@ -10,6 +10,12 @@ interface WithByteConverters { export declare class Uint32 implements Integer, WithByteConverters { /** @deprecated use Uint32.fromBytes */ static fromBigEndianBytes(bytes: ArrayLike): Uint32; + /** + * Creates a Uint32 from a fixed length byte array. + * + * @param bytes a list of exactly 4 bytes + * @param endianess defaults to big endian + */ static fromBytes(bytes: ArrayLike, endianess?: "be" | "le"): Uint32; static fromString(str: string): Uint32; protected readonly data: number; @@ -36,6 +42,12 @@ export declare class Uint53 implements Integer { export declare class Uint64 implements Integer, WithByteConverters { /** @deprecated use Uint64.fromBytes */ static fromBytesBigEndian(bytes: ArrayLike): Uint64; + /** + * Creates a Uint64 from a fixed length byte array. + * + * @param bytes a list of exactly 8 bytes + * @param endianess defaults to big endian + */ static fromBytes(bytes: ArrayLike, endianess?: "be" | "le"): Uint64; static fromString(str: string): Uint64; static fromNumber(input: number): Uint64;