Comparing version 0.8.9 to 0.8.10
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '0.8.9'; | ||
exports.version = '0.8.10'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export const version = '0.8.9'; | ||
export const version = '0.8.10'; | ||
//# sourceMappingURL=version.js.map |
import type { Abi } from '../abi.js'; | ||
import type { Narrow } from '../narrow.js'; | ||
import type { Error, Filter } from '../types.js'; | ||
@@ -22,3 +21,3 @@ import type { Signatures } from './types/signatures.js'; | ||
*/ | ||
export type ParseAbi<TSignatures extends readonly string[] | readonly unknown[]> = string[] extends TSignatures ? Abi : TSignatures extends readonly string[] ? TSignatures extends Signatures<TSignatures> ? ParseStructs<TSignatures> extends infer Structs ? { | ||
export type ParseAbi<TSignatures extends readonly string[]> = string[] extends TSignatures ? Abi : TSignatures extends readonly string[] ? TSignatures extends Signatures<TSignatures> ? ParseStructs<TSignatures> extends infer Structs ? { | ||
[K in keyof TSignatures]: TSignatures[K] extends string ? ParseSignature<TSignatures[K], Structs> : never; | ||
@@ -39,3 +38,3 @@ } extends infer Mapped extends readonly unknown[] ? Filter<Mapped, never> extends infer Result ? Result extends readonly [] ? never : Result : never : never : never : never : never; | ||
*/ | ||
export declare function parseAbi<TSignatures extends readonly string[] | readonly unknown[]>(signatures: Narrow<TSignatures> & (TSignatures extends readonly string[] ? TSignatures extends readonly [] ? Error<'At least one signature required.'> : string[] extends TSignatures ? unknown : Signatures<TSignatures> : never)): ParseAbi<TSignatures>; | ||
export declare function parseAbi<const TSignatures extends readonly string[]>(signatures: TSignatures['length'] extends 0 ? Error<'At least one signature required'> : Signatures<TSignatures> extends TSignatures ? TSignatures : Signatures<TSignatures>): ParseAbi<TSignatures>; | ||
//# sourceMappingURL=parseAbi.d.ts.map |
@@ -20,3 +20,3 @@ import type { AbiStateMutability } from '../../abi.js'; | ||
export type IsSignature<T extends string> = (IsErrorSignature<T> extends true ? true : never) | (IsEventSignature<T> extends true ? true : never) | (IsFunctionSignature<T> extends true ? true : never) | (IsStructSignature<T> extends true ? true : never) | (IsConstructorSignature<T> extends true ? true : never) | (T extends FallbackSignature ? true : never) | (T extends ReceiveSignature ? true : never) extends infer Condition ? [Condition] extends [never] ? false : true : false; | ||
export type Signature<T extends string, K extends string | unknown = unknown> = IsSignature<T> extends true ? T : Error<`Signature "${T}" is invalid${K extends string ? ` at position ${K}` : ''}.`>; | ||
export type Signature<T extends string, K extends string | unknown = unknown> = IsSignature<T> extends true ? T : string extends T ? T : Error<`Signature "${T}" is invalid${K extends string ? ` at position ${K}` : ''}.`>; | ||
export type Signatures<T extends readonly string[]> = { | ||
@@ -23,0 +23,0 @@ [K in keyof T]: Signature<T[K], K>; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.8.9"; | ||
export declare const version = "0.8.10"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "0.8.9", | ||
"version": "0.8.10", | ||
"files": [ | ||
@@ -16,0 +16,0 @@ "dist", |
import type { Abi } from '../abi.js' | ||
import type { Narrow } from '../narrow.js' | ||
import type { Error, Filter } from '../types.js' | ||
@@ -26,18 +25,18 @@ import { isStructSignature } from './runtime/signatures.js' | ||
*/ | ||
export type ParseAbi< | ||
TSignatures extends readonly string[] | readonly unknown[], | ||
> = string[] extends TSignatures | ||
? Abi // If `T` was not able to be inferred (e.g. just `string[]`), return `Abi` | ||
: TSignatures extends readonly string[] | ||
? TSignatures extends Signatures<TSignatures> // Validate signatures | ||
? ParseStructs<TSignatures> extends infer Structs | ||
? { | ||
[K in keyof TSignatures]: TSignatures[K] extends string | ||
? ParseSignature<TSignatures[K], Structs> | ||
export type ParseAbi<TSignatures extends readonly string[]> = | ||
string[] extends TSignatures | ||
? Abi // If `T` was not able to be inferred (e.g. just `string[]`), return `Abi` | ||
: TSignatures extends readonly string[] | ||
? TSignatures extends Signatures<TSignatures> // Validate signatures | ||
? ParseStructs<TSignatures> extends infer Structs | ||
? { | ||
[K in keyof TSignatures]: TSignatures[K] extends string | ||
? ParseSignature<TSignatures[K], Structs> | ||
: never | ||
} extends infer Mapped extends readonly unknown[] | ||
? Filter<Mapped, never> extends infer Result | ||
? Result extends readonly [] | ||
? never | ||
: Result | ||
: never | ||
} extends infer Mapped extends readonly unknown[] | ||
? Filter<Mapped, never> extends infer Result | ||
? Result extends readonly [] | ||
? never | ||
: Result | ||
: never | ||
@@ -47,3 +46,2 @@ : never | ||
: never | ||
: never | ||
@@ -63,13 +61,8 @@ /** | ||
*/ | ||
export function parseAbi< | ||
TSignatures extends readonly string[] | readonly unknown[], | ||
>( | ||
signatures: Narrow<TSignatures> & | ||
(TSignatures extends readonly string[] | ||
? TSignatures extends readonly [] // empty array | ||
? Error<'At least one signature required.'> | ||
: string[] extends TSignatures | ||
? unknown | ||
: Signatures<TSignatures> | ||
: never), | ||
export function parseAbi<const TSignatures extends readonly string[]>( | ||
signatures: TSignatures['length'] extends 0 | ||
? Error<'At least one signature required'> | ||
: Signatures<TSignatures> extends TSignatures | ||
? TSignatures | ||
: Signatures<TSignatures>, | ||
): ParseAbi<TSignatures> { | ||
@@ -76,0 +69,0 @@ const structs = parseStructs(signatures as readonly string[]) |
@@ -109,2 +109,4 @@ import type { AbiStateMutability } from '../../abi.js' | ||
? T | ||
: string extends T // if exactly `string` (not narrowed), then pass through as valid | ||
? T | ||
: Error<`Signature "${T}" is invalid${K extends string | ||
@@ -111,0 +113,0 @@ ? ` at position ${K}` |
@@ -1,1 +0,1 @@ | ||
export const version = '0.8.9' | ||
export const version = '0.8.10' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1140575
23548