import type * as abitype from 'abitype'; import type * as Abi from '../Abi.js'; import type * as AbiItem from '../AbiItem.js'; import type * as AbiParameters from '../AbiParameters.js'; import * as Errors from '../Errors.js'; import type { Compute, IsNever, IsUnion, TypeErrorMessage, UnionToTuple } from './types.js'; /** @internal */ export type ExtractArgs = AbiItem.Name> = abitype.AbiParametersToPrimitiveTypes['inputs'], 'inputs'> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[]; /** @internal */ export type ExtractForArgs, args extends ExtractArgs> = IsUnion extends true ? { [key in keyof abi]: abi[key] extends { name: name; } ? abi[key] : never; }[number] : AbiItem.FromAbi extends infer abiItem extends AbiItem.AbiItem & { inputs: readonly abitype.AbiParameter[]; } ? IsUnion extends true ? UnionToTuple extends infer abiItems extends readonly (AbiItem.AbiItem & { inputs: readonly abitype.AbiParameter[]; })[] ? IsNever> extends true ? Compute>; }> : TupleToUnion : never : abiItem : never; /** @internal */ export type TupleToUnion, args extends ExtractArgs> = { [k in keyof abiItems]: (readonly [] extends args ? readonly [] : args) extends abitype.AbiParametersToPrimitiveTypes ? abiItems[k] : never; }[number]; /** @internal */ export type ErrorSignature = `error ${name}(${parameters})`; /** @internal */ export type IsErrorSignature = signature extends ErrorSignature ? IsName : false; /** @internal */ export type EventSignature = `event ${name}(${parameters})`; /** @internal */ export type IsEventSignature = signature extends EventSignature ? IsName : false; /** @internal */ export type FunctionSignature = `function ${name}(${tail}`; export type IsFunctionSignature = signature extends FunctionSignature ? IsName extends true ? signature extends ValidFunctionSignatures ? true : signature extends `function ${string}(${infer parameters})` ? parameters extends InvalidFunctionParameters ? false : true : false : false : false; /** @internal */ export type Scope = 'public' | 'external'; /** @internal */ export type Returns = `returns (${string})` | `returns(${string})`; /** @internal */ export type ValidFunctionSignatures = `function ${string}()` | `function ${string}() ${Returns}` | `function ${string}() ${abitype.AbiStateMutability}` | `function ${string}() ${Scope}` | `function ${string}() ${abitype.AbiStateMutability} ${Returns}` | `function ${string}() ${Scope} ${Returns}` | `function ${string}() ${Scope} ${abitype.AbiStateMutability}` | `function ${string}() ${Scope} ${abitype.AbiStateMutability} ${Returns}` | `function ${string}(${string}) ${Returns}` | `function ${string}(${string}) ${abitype.AbiStateMutability}` | `function ${string}(${string}) ${Scope}` | `function ${string}(${string}) ${abitype.AbiStateMutability} ${Returns}` | `function ${string}(${string}) ${Scope} ${Returns}` | `function ${string}(${string}) ${Scope} ${abitype.AbiStateMutability}` | `function ${string}(${string}) ${Scope} ${abitype.AbiStateMutability} ${Returns}`; /** @internal */ export type StructSignature = `struct ${name} {${properties}}`; /** @internal */ export type IsStructSignature = signature extends StructSignature ? IsName : false; /** @internal */ export type ConstructorSignature = `constructor(${tail}`; /** @internal */ export type IsConstructorSignature = signature extends ConstructorSignature ? signature extends ValidConstructorSignatures ? true : false : false; /** @internal */ export type ValidConstructorSignatures = `constructor(${string})` | `constructor(${string}) payable`; /** @internal */ export type FallbackSignature = `fallback() external${abiStateMutability}`; /** @internal */ export type ReceiveSignature = 'receive() external payable'; /** @internal */ export type IsSignature = (IsErrorSignature extends true ? true : never) | (IsEventSignature extends true ? true : never) | (IsFunctionSignature extends true ? true : never) | (IsStructSignature extends true ? true : never) | (IsConstructorSignature extends true ? true : never) | (type extends FallbackSignature ? true : never) | (type extends ReceiveSignature ? true : never) extends infer condition ? [condition] extends [never] ? false : true : false; /** @internal */ export type Signature = IsSignature extends true ? string1 : string extends string1 ? string1 : TypeErrorMessage<`Signature "${string1}" is invalid${string2 extends string ? ` at position ${string2}` : ''}.`>; /** @internal */ export type Signatures = { [key in keyof signatures]: Signature; }; /** @internal */ export type IsName = name extends '' ? false : ValidateName extends name ? true : false; /** @internal */ export type ValidateName = name extends `${string}${' '}${string}` ? TypeErrorMessage<`Identifier "${name}" cannot contain whitespace.`> : IsSolidityKeyword extends true ? TypeErrorMessage<`"${name}" is a protected Solidity keyword.`> : name extends `${number}` ? TypeErrorMessage<`Identifier "${name}" cannot be a number string.`> : name extends `${number}${string}` ? TypeErrorMessage<`Identifier "${name}" cannot start with a number.`> : checkCharacters extends true ? IsValidCharacter extends true ? name : TypeErrorMessage<`"${name}" contains invalid character.`> : name; /** @internal */ export type IsSolidityKeyword = type extends SolidityKeywords ? true : false; /** @internal */ export type SolidityKeywords = 'after' | 'alias' | 'anonymous' | 'apply' | 'auto' | 'byte' | 'calldata' | 'case' | 'catch' | 'constant' | 'copyof' | 'default' | 'defined' | 'error' | 'event' | 'external' | 'false' | 'final' | 'function' | 'immutable' | 'implements' | 'in' | 'indexed' | 'inline' | 'internal' | 'let' | 'mapping' | 'match' | 'memory' | 'mutable' | 'null' | 'of' | 'override' | 'partial' | 'private' | 'promise' | 'public' | 'pure' | 'reference' | 'relocatable' | 'return' | 'returns' | 'sizeof' | 'static' | 'storage' | 'struct' | 'super' | 'supports' | 'switch' | 'this' | 'true' | 'try' | 'typedef' | 'typeof' | 'var' | 'view' | 'virtual' | `address${`[${string}]` | ''}` | `bool${`[${string}]` | ''}` | `string${`[${string}]` | ''}` | `tuple${`[${string}]` | ''}` | `bytes${number | ''}${`[${string}]` | ''}` | `${'u' | ''}int${number | ''}${`[${string}]` | ''}`; /** @internal */ export type IsValidCharacter = character extends `${ValidCharacters}${infer tail}` ? tail extends '' ? true : IsValidCharacter : false; /** @internal */ export type ValidCharacters = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '_' | '$'; /** @internal */ export type InvalidFunctionParameters = `${string}${MangledReturns} (${string}` | `${string}) ${MangledReturns}${string}` | `${string})${string}${MangledReturns}${string}(${string}`; /** @internal */ export type MangledReturns = `r${string}eturns` | `re${string}turns` | `ret${string}urns` | `retu${string}rns` | `retur${string}ns` | `return${string}s` | `r${string}e${string}turns` | `r${string}et${string}urns` | `r${string}etu${string}rns` | `r${string}etur${string}ns` | `r${string}eturn${string}s` | `re${string}t${string}urns` | `re${string}tu${string}rns` | `re${string}tur${string}ns` | `re${string}turn${string}s` | `ret${string}u${string}rns` | `ret${string}ur${string}ns` | `ret${string}urn${string}s` | `retu${string}r${string}ns` | `retu${string}rn${string}s` | `retur${string}n${string}s` | `r${string}e${string}t${string}urns` | `r${string}e${string}tu${string}rns` | `r${string}e${string}tur${string}ns` | `r${string}e${string}turn${string}s` | `re${string}t${string}u${string}rns` | `re${string}t${string}ur${string}ns` | `re${string}t${string}urn${string}s` | `ret${string}u${string}r${string}ns` | `ret${string}u${string}rn${string}s` | `retu${string}r${string}n${string}s` | `r${string}e${string}t${string}u${string}rns` | `r${string}e${string}t${string}ur${string}ns` | `r${string}e${string}t${string}urn${string}s` | `re${string}t${string}u${string}r${string}ns` | `re${string}t${string}u${string}rn${string}s` | `ret${string}u${string}r${string}n${string}s` | `r${string}e${string}t${string}u${string}r${string}ns` | `r${string}e${string}t${string}u${string}rn${string}s` | `re${string}t${string}u${string}r${string}n${string}s` | `r${string}e${string}t${string}u${string}r${string}n${string}s`; /** @internal */ export type Widen = ([unknown] extends [type] ? unknown : never) | (type extends Function ? type : never) | (type extends abitype.ResolvedRegister['bigIntType'] ? bigint : never) | (type extends boolean ? boolean : never) | (type extends abitype.ResolvedRegister['intType'] ? number : never) | (type extends string ? type extends abitype.ResolvedRegister['addressType'] ? abitype.ResolvedRegister['addressType'] : type extends abitype.ResolvedRegister['bytesType']['inputs'] ? abitype.ResolvedRegister['bytesType'] : string : never) | (type extends readonly [] ? readonly [] : never) | (type extends Record ? { [K in keyof type]: Widen; } : never) | (type extends { length: number; } ? { [K in keyof type]: Widen; } extends infer Val extends readonly unknown[] ? readonly [...Val] : never : never); /** @internal */ export declare function normalizeSignature(signature: string): string; /** @internal */ export declare namespace normalizeSignature { type ErrorType = Errors.BaseError | Errors.GlobalErrorType; } /** @internal */ export declare function isArgOfType(arg: unknown, abiParameter: AbiParameters.Parameter): boolean; /** @internal */ export declare function getAmbiguousTypes(sourceParameters: readonly AbiParameters.Parameter[], targetParameters: readonly AbiParameters.Parameter[], args: ExtractArgs): AbiParameters.Parameter['type'][] | undefined; //# sourceMappingURL=abiItem.d.ts.map