Comparing version 0.9.5 to 0.9.6
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '0.9.5'; | ||
exports.version = '0.9.6'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export const version = '0.9.5'; | ||
export const version = '0.9.6'; | ||
//# sourceMappingURL=version.js.map |
@@ -75,3 +75,5 @@ import type { Abi, AbiParameter, AbiParameterKind, AbiStateMutability, AbiType, MBits, SolidityAddress, SolidityArray, SolidityBool, SolidityBytes, SolidityFixedArrayRange, SolidityFixedArraySizeLookup, SolidityFunction, SolidityInt, SolidityString, SolidityTuple, TypedData, TypedDataParameter, TypedDataType } from './abi.js'; | ||
type: Head; | ||
}>, TAbiParameterKind>[] : never : ResolvedConfig['StrictAbiType'] extends true ? TAbiParameter['type'] extends infer TAbiType extends string ? Error<`Unknown type '${TAbiType}'.`> : never : unknown; | ||
}>, TAbiParameterKind>[] : never : ResolvedConfig['StrictAbiType'] extends true ? TAbiParameter['type'] extends infer TAbiType extends string ? Error<`Unknown type '${TAbiType}'.`> : never : TAbiParameter extends { | ||
components: Error<string>; | ||
} ? TAbiParameter['components'] : unknown; | ||
type _HasUnnamedAbiParameter<TAbiParameters extends readonly AbiParameter[]> = TAbiParameters extends readonly [ | ||
@@ -207,22 +209,33 @@ infer Head extends AbiParameter, | ||
[K2 in TTypedData[K][number] as K2['name']]: K2['type'] extends K ? Error<`Cannot convert self-referencing struct '${K2['type']}' to primitive type.`> : K2['type'] extends keyof TTypedData ? K2['type'] extends keyof TKeyReferences ? Error<`Circular reference detected. '${K2['type']}' is a circular reference.`> : TypedDataToPrimitiveTypes<Exclude<TTypedData, K>, TAbiParameterKind, TKeyReferences & { | ||
[_ in K2['type']]: true; | ||
}>[K2['type']] : K2['type'] extends `${infer TType extends keyof TTypedData & string}[${infer Tail}]` ? AbiParameterToPrimitiveType<Merge<K2, { | ||
[_ in K2['type'] | K]: true; | ||
}>[K2['type']] : K2['type'] extends `${infer TType extends keyof TTypedData & string}[${infer Tail}]` ? AbiParameterToPrimitiveType<{ | ||
name: K2['name']; | ||
type: `tuple[${Tail}]`; | ||
components: _TypedDataParametersToAbiParameters<TTypedData[TType], TTypedData>; | ||
}>, TAbiParameterKind> : K2['type'] extends TypedDataType ? AbiParameterToPrimitiveType<K2, TAbiParameterKind> : Error<`Cannot convert unknown type '${K2['type']}' to primitive type.`>; | ||
components: _TypedDataParametersToAbiParameters<TTypedData[TType], TTypedData, TKeyReferences & { | ||
[_ in TType | K]: true; | ||
}>; | ||
}, TAbiParameterKind> : K2['type'] extends TypedDataType ? AbiParameterToPrimitiveType<K2, TAbiParameterKind> : Error<`Cannot convert unknown type '${K2['type']}' to primitive type.`>; | ||
}; | ||
}; | ||
type _TypedDataParametersToAbiParameters<TTypedDataParameters extends readonly TypedDataParameter[], TTypedData extends TypedData> = { | ||
type _TypedDataParametersToAbiParameters<TTypedDataParameters extends readonly TypedDataParameter[], TTypedData extends TypedData, TKeyReferences extends { | ||
[_: string]: unknown; | ||
} | unknown = unknown> = { | ||
[K in keyof TTypedDataParameters]: TTypedDataParameters[K] extends infer TTypedDataParameter extends { | ||
name: string; | ||
type: unknown; | ||
} ? TTypedDataParameter['type'] extends keyof TTypedData ? Merge<TTypedDataParameter, { | ||
} ? TTypedDataParameter['type'] extends keyof TTypedData & string ? { | ||
name: TTypedDataParameter['name']; | ||
type: 'tuple'; | ||
components: _TypedDataParametersToAbiParameters<TTypedData[TTypedDataParameter['type']], TTypedData>; | ||
}> : TTypedDataParameter['type'] extends `${infer TType extends keyof TTypedData & string}[${infer Tail}]` ? Merge<TTypedDataParameter, { | ||
components: TTypedDataParameter['type'] extends keyof TKeyReferences ? Error<`Circular reference detected. '${TTypedDataParameter['type']}' is a circular reference.`> : _TypedDataParametersToAbiParameters<TTypedData[TTypedDataParameter['type']], TTypedData, TKeyReferences & { | ||
[_ in TTypedDataParameter['type']]: true; | ||
}>; | ||
} : TTypedDataParameter['type'] extends `${infer TType extends keyof TTypedData & string}[${infer Tail}]` ? { | ||
name: TTypedDataParameter['name']; | ||
type: `tuple[${Tail}]`; | ||
components: _TypedDataParametersToAbiParameters<TTypedData[TType], TTypedData>; | ||
}> : TTypedDataParameter : never; | ||
components: TType extends keyof TKeyReferences ? Error<`Circular reference detected. '${TTypedDataParameter['type']}' is a circular reference.`> : _TypedDataParametersToAbiParameters<TTypedData[TType], TTypedData, TKeyReferences & { | ||
[_ in TType]: true; | ||
}>; | ||
} : TTypedDataParameter : never; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.9.5"; | ||
export declare const version = "0.9.6"; | ||
//# sourceMappingURL=version.d.ts.map |
{ | ||
"name": "abitype", | ||
"description": "Strict TypeScript types for Ethereum ABIs", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "wagmi-dev/abitype", |
@@ -163,2 +163,6 @@ import type { | ||
: never | ||
: // 5. If we've gotten this far, let's check for errors in tuple components. | ||
// (Happens for recursive tuple typed data types.) | ||
TAbiParameter extends { components: Error<string> } | ||
? TAbiParameter['components'] | ||
: unknown | ||
@@ -376,3 +380,3 @@ | ||
TAbiParameterKind, | ||
TKeyReferences & { [_ in K2['type']]: true } | ||
TKeyReferences & { [_ in K2['type'] | K]: true } | ||
>[K2['type']] | ||
@@ -383,12 +387,11 @@ : // 3. Check if type is array of structs | ||
? AbiParameterToPrimitiveType< | ||
Merge< | ||
K2, | ||
{ | ||
type: `tuple[${Tail}]` | ||
components: _TypedDataParametersToAbiParameters< | ||
TTypedData[TType], | ||
TTypedData | ||
> | ||
} | ||
>, | ||
{ | ||
name: K2['name'] | ||
type: `tuple[${Tail}]` | ||
components: _TypedDataParametersToAbiParameters< | ||
TTypedData[TType], | ||
TTypedData, | ||
TKeyReferences & { [_ in TType | K]: true } | ||
> | ||
}, | ||
TAbiParameterKind | ||
@@ -405,2 +408,3 @@ > | ||
TTypedData extends TypedData, | ||
TKeyReferences extends { [_: string]: unknown } | unknown = unknown, | ||
> = { | ||
@@ -414,26 +418,28 @@ // Map over typed data parameters and convert into ABI parameters | ||
? // 1. Check if type is struct | ||
TTypedDataParameter['type'] extends keyof TTypedData | ||
? Merge< | ||
TTypedDataParameter, | ||
{ | ||
type: 'tuple' | ||
components: _TypedDataParametersToAbiParameters< | ||
TTypedData[TTypedDataParameter['type']], | ||
TTypedData | ||
> | ||
} | ||
> | ||
TTypedDataParameter['type'] extends keyof TTypedData & string | ||
? { | ||
name: TTypedDataParameter['name'] | ||
type: 'tuple' | ||
components: TTypedDataParameter['type'] extends keyof TKeyReferences | ||
? Error<`Circular reference detected. '${TTypedDataParameter['type']}' is a circular reference.`> | ||
: _TypedDataParametersToAbiParameters< | ||
TTypedData[TTypedDataParameter['type']], | ||
TTypedData, | ||
TKeyReferences & { [_ in TTypedDataParameter['type']]: true } | ||
> | ||
} | ||
: // 2. Check if type is array of structs | ||
TTypedDataParameter['type'] extends `${infer TType extends keyof TTypedData & | ||
string}[${infer Tail}]` | ||
? Merge< | ||
TTypedDataParameter, | ||
{ | ||
type: `tuple[${Tail}]` | ||
components: _TypedDataParametersToAbiParameters< | ||
TTypedData[TType], | ||
TTypedData | ||
> | ||
} | ||
> | ||
? { | ||
name: TTypedDataParameter['name'] | ||
type: `tuple[${Tail}]` | ||
components: TType extends keyof TKeyReferences | ||
? Error<`Circular reference detected. '${TTypedDataParameter['type']}' is a circular reference.`> | ||
: _TypedDataParametersToAbiParameters< | ||
TTypedData[TType], | ||
TTypedData, | ||
TKeyReferences & { [_ in TType]: true } | ||
> | ||
} | ||
: // 3. Type is already ABI parameter | ||
@@ -440,0 +446,0 @@ TTypedDataParameter |
@@ -1,1 +0,1 @@ | ||
export const version = '0.9.5' | ||
export const version = '0.9.6' |
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
1170845
24135