ox
Version:
Ethereum Standard Library
61 lines • 2.25 kB
TypeScript
import * as Hex from '../Hex.js';
/** @internal */
export declare class MissingFieldError extends Error {
readonly name = "Quantity.MissingFieldError";
constructor(args: {
field: string;
container?: string | undefined;
});
}
/**
* Converts an optional RPC quantity (`Hex.Hex | undefined | null`) to `bigint | undefined`.
*
* Returns `undefined` for both `undefined` and `null` (RPC encoders may use either to mean "absent").
*
* @internal
*/
export declare function toBigInt(value: Hex.Hex | undefined | null): bigint | undefined;
/**
* Converts a required RPC quantity to `bigint`. Throws `MissingFieldError` if the
* value is `undefined` or `null`.
*
* @internal
*/
export declare function toBigIntRequired(value: Hex.Hex | undefined | null, field: string, container?: string): bigint;
/**
* Converts an optional RPC quantity to `number | undefined` via `BigInt` to avoid
* silent precision loss on values that overflow Number.MAX_SAFE_INTEGER.
*
* Returns `undefined` for both `undefined` and `null`.
*
* @internal
*/
export declare function toNumber(value: Hex.Hex | undefined | null): number | undefined;
/**
* Converts a "numberish" value (`Hex.Hex | bigint | number`) to an RPC quantity
* (`Hex.Hex`). Hex values are passed through unchanged; numbers and bigints are
* encoded via {@link ox#Hex.(fromNumber:function)}.
*
* @internal
*/
export declare function fromNumberish(value: Hex.Hex | bigint | number, options?: Hex.fromNumber.Options): Hex.Hex;
/**
* Converts an optional "numberish" value to an RPC quantity (`Hex.Hex | undefined`).
* Returns `undefined` for both `undefined` and `null`.
*
* @internal
*/
export declare function fromNumberishOptional(value: Hex.Hex | bigint | number | undefined | null, options?: Hex.fromNumber.Options): Hex.Hex | undefined;
/**
* Converts an optional `bigint` to an RPC quantity (`Hex.Hex | undefined`).
*
* @internal
*/
export declare function fromBigInt(value: bigint | undefined | null): Hex.Hex | undefined;
/**
* Converts an optional `number` to an RPC quantity (`Hex.Hex | undefined`).
*
* @internal
*/
export declare function fromNumber(value: number | undefined | null): Hex.Hex | undefined;
//# sourceMappingURL=quantity.d.ts.map