import { CustomError } from "../error.js"; declare const ABI_ENCODING_ERROR_KINDS: readonly ["parameters-length-mismatch", "invalid-value", "value-out-of-bounds", "unsupported-type", "duplicate-parameter-name", "encoding-failed"]; /** * Discriminates the errors that ABI encoding can throw. */ export type AbiEncodingErrorKind = (typeof ABI_ENCODING_ERROR_KINDS)[number]; /** * Base class of every error thrown while ABI-encoding values. * * Consumers should discriminate with `isAbiEncodingError` rather than * `instanceof`, so that the checks keep working if more than one copy of this * package ends up installed. */ export declare abstract class AbiEncodingError extends CustomError { abstract readonly kind: AbiEncodingErrorKind; } /** * Thrown when the number of values to encode doesn't match the number of * parameters. */ export declare class AbiParametersLengthMismatchError extends AbiEncodingError { readonly expectedLength: number; readonly providedLength: number; readonly kind: "parameters-length-mismatch"; constructor(expectedLength: number, providedLength: number); } /** * Thrown when a value can't be encoded as its parameter's Solidity type. */ export declare class InvalidAbiValueError extends AbiEncodingError { readonly path: string; readonly solidityType: string; readonly value: unknown; readonly reason: string; readonly kind: "invalid-value"; constructor(path: string, solidityType: string, value: unknown, reason: string); } /** * Thrown when a numeric value is outside the range of its Solidity type. */ export declare class AbiValueOutOfBoundsError extends AbiEncodingError { readonly path: string; readonly solidityType: string; readonly value: unknown; readonly min: bigint; readonly max: bigint; readonly kind: "value-out-of-bounds"; constructor(path: string, solidityType: string, value: unknown, min: bigint, max: bigint); } /** * Thrown when a parameter's Solidity type can't be encoded at all. */ export declare class UnsupportedAbiTypeError extends AbiEncodingError { readonly path: string; readonly solidityType: string; readonly kind: "unsupported-type"; constructor(path: string, solidityType: string); } /** * Thrown when two parameters, or two components of the same tuple, share a * name. * * Only a hand-written ABI can carry duplicate names; solc never emits one. The * encoder's own guard covers named parameters only, and names are stripped * before it runs, so it never sees them. */ export declare class DuplicateAbiParameterNameError extends AbiEncodingError { readonly path: string | undefined; readonly duplicatedName: string; readonly kind: "duplicate-parameter-name"; constructor(path: string | undefined, duplicatedName: string); } /** * Thrown when the encoder refuses values that already passed validation. */ export declare class AbiEncodingFailedError extends AbiEncodingError { readonly kind: "encoding-failed"; constructor(cause: Error); } /** * The union of every error that ABI encoding can throw. */ export type AnyAbiEncodingError = AbiParametersLengthMismatchError | InvalidAbiValueError | AbiValueOutOfBoundsError | UnsupportedAbiTypeError | DuplicateAbiParameterNameError | AbiEncodingFailedError; /** * Checks whether a value is an ABI encoding error, optionally of a given kind. * * @param error The value to check. * @param kind The kind of error to check for. If omitted, any kind matches. * @returns True if the value is an ABI encoding error of that kind. */ export declare function isAbiEncodingError(error: unknown): error is AnyAbiEncodingError; export declare function isAbiEncodingError(error: unknown, kind: KindT): error is Extract; /** * Thrown when a human-readable ABI signature can't be parsed. * * Consumers should discriminate with `isInvalidAbiSignatureError` rather than * `instanceof`, for the same reason as `isAbiEncodingError`. */ export declare class InvalidAbiSignatureError extends CustomError { readonly input: string; readonly reason: string; readonly kind: "invalid-signature"; constructor(input: string, reason: string); } /** * Whether an error is an `InvalidAbiSignatureError`, even if thrown by another * copy of this package. * * @param error The value to check. * @returns Whether it's an `InvalidAbiSignatureError`. */ export declare function isInvalidAbiSignatureError(error: unknown): error is InvalidAbiSignatureError; export {}; //# sourceMappingURL=abi.d.ts.map