Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

abitype

Package Overview
Dependencies
Maintainers
2
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abitype - npm Package Compare versions

Comparing version 0.7.0-canary.20230307T235025 to 0.7.0-canary.20230309T205532

92

dist/index.d.ts
import { A as AbiType, a as AbiParameterKind, S as SolidityAddress, b as SolidityBool, c as SolidityBytes, d as SolidityFunction, e as SolidityInt, f as SolidityString, g as SolidityTuple, h as SolidityArray, i as AbiParameter, j as SolidityFixedArrayRange, k as SolidityFixedArraySizeLookup, l as Abi, m as AbiStateMutability, T as TypedData, n as TypedDataType, o as TypedDataParameter, M as MBits } from './abi-4dfce13f.js';
export { l as Abi, p as AbiConstructor, q as AbiError, r as AbiEvent, s as AbiFallback, t as AbiFunction, u as AbiInternalType, v as AbiItemType, i as AbiParameter, a as AbiParameterKind, w as AbiReceive, m as AbiStateMutability, A as AbiType, x as Address, S as SolidityAddress, h as SolidityArray, z as SolidityArrayWithTuple, y as SolidityArrayWithoutTuple, b as SolidityBool, c as SolidityBytes, j as SolidityFixedArrayRange, k as SolidityFixedArraySizeLookup, d as SolidityFunction, e as SolidityInt, f as SolidityString, g as SolidityTuple, T as TypedData, B as TypedDataDomain, o as TypedDataParameter, n as TypedDataType } from './abi-4dfce13f.js';
import { R as ResolvedConfig, E as Error$1, T as Tuple, M as Merge, a as Trim, P as Prettify, I as IsUnknown, F as Filter } from './config-edd78478.js';
import { R as ResolvedConfig, E as Error$1, T as Tuple, M as Merge, a as Trim, I as IsUnknown, P as Prettify, F as Filter } from './config-edd78478.js';
export { C as Config, D as DefaultConfig, R as ResolvedConfig } from './config-edd78478.js';

@@ -270,3 +270,2 @@

type IsName<T extends string> = T extends '' | `${string}${' '}${string}` ? false : true;
type ErrorSignature<TName extends string = string, TParameters extends string = string> = `error ${TName}(${TParameters})`;

@@ -283,6 +282,8 @@ type IsErrorSignature<T extends string> = T extends ErrorSignature<infer Name> ? IsName<Name> : false;

type IsStructSignature<T extends string> = T extends StructSignature<infer Name> ? IsName<Name> : false;
type ConstructorSignature<TParameters extends string = string> = `constructor(${TParameters})`;
type FallbackSignature = 'fallback()';
type ConstructorSignature<TTail extends string = string> = `constructor(${TTail}`;
type IsConstructorSignature<T> = T extends ConstructorSignature ? T extends ValidConstructorSignatures ? true : false : false;
type ValidConstructorSignatures = `constructor(${string})` | `constructor(${string}) payable`;
type FallbackSignature<TAbiStateMutability extends '' | ' payable' = ''> = `fallback() external${TAbiStateMutability}`;
type ReceiveSignature = 'receive() external payable';
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) | (T extends ConstructorSignature ? true : never) | (T extends FallbackSignature ? true : never) | (T extends ReceiveSignature ? true : never) extends infer Condition ? [Condition] extends [never] ? false : true : false;
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;
type Signature<T extends string, K extends string | unknown = unknown> = IsSignature<T> extends true ? T : Error$1<`Signature "${T}" is invalid${K extends string ? ` at position ${K}` : ''}.`>;

@@ -295,2 +296,8 @@ type Signatures<T extends readonly string[]> = {

type EventModifier = Extract<Modifier, 'indexed'>;
type IsName<TName extends string> = TName extends '' ? false : ValidateName<TName> extends TName ? true : false;
type ValidateName<TName extends string, CheckCharacters extends boolean = false> = TName extends `${string}${' '}${string}` ? Error$1<`Name "${TName}" cannot contain whitespace.`> : IsSolidityKeyword<TName> extends true ? Error$1<`"${TName}" is a protected Solidity keyword.`> : CheckCharacters extends true ? IsValidCharacter<TName> extends true ? TName : Error$1<`"${TName}" contains invalid character.`> : TName;
type IsSolidityKeyword<T extends string> = T extends SolidityKeywords ? true : false;
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';
type IsValidCharacter<T extends string> = T extends `${ValidCharacters}${infer Tail}` ? Tail extends '' ? true : IsValidCharacter<Tail> : false;
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' | '_';
type InvalidFunctionParameters = `${string}${MangledReturns} (${string}` | `${string}) ${MangledReturns}${string}` | `${string})${string}${MangledReturns}${string}(${string}`;

@@ -324,10 +331,11 @@ 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`;

}> : readonly [];
} : never : never) | (TSignature extends ConstructorSignature<infer Parameters> ? {
} : never : never) | (IsConstructorSignature<TSignature> extends true ? {
readonly type: 'constructor';
readonly stateMutability: 'nonpayable';
readonly inputs: ParseAbiParameters$1<SplitParameters<Parameters>, {
readonly stateMutability: _ParseConstructorParametersAndStateMutability<TSignature>['StateMutability'];
readonly inputs: ParseAbiParameters$1<SplitParameters<_ParseConstructorParametersAndStateMutability<TSignature>['Inputs']>, {
Structs: TStructs;
}>;
} : never) | (TSignature extends FallbackSignature ? {
} : never) | (TSignature extends FallbackSignature<infer StateMutability> ? {
readonly type: 'fallback';
readonly stateMutability: StateMutability extends `${string}payable` ? 'payable' : 'nonpayable';
} : never) | (TSignature extends ReceiveSignature ? {

@@ -347,26 +355,45 @@ readonly type: 'receive';

];
type ParseAbiParameter$1<T extends string, Options extends ParseOptions = DefaultParseOptions> = T extends `(${string})${string}` ? _ParseTuple<T, Options> : (T extends `${infer Type} ${infer Tail}` ? Trim<Tail> extends infer Trimmed extends string ? Prettify<{
type ParseAbiParameter$1<T extends string, Options extends ParseOptions = DefaultParseOptions> = (T extends `(${string})${string}` ? _ParseTuple<T, Options> : T extends `${infer Type} ${infer Tail}` ? Trim<Tail> extends infer Trimmed extends string ? // TODO: data location modifiers only allowed for struct/array types
{
readonly type: Trim<Type>;
} & _SplitNameOrModifier<Trimmed, Options>> : never : {
} & _SplitNameOrModifier<Trimmed, Options> : never : {
readonly type: T;
}) extends infer Parameter extends AbiParameter & {
}) extends infer ShallowParameter extends AbiParameter & {
type: string;
indexed?: boolean;
} ? Parameter['type'] extends keyof Options['Structs'] ? Prettify<{
} ? (ShallowParameter['type'] extends keyof Options['Structs'] ? {
readonly type: 'tuple';
readonly components: Options['Structs'][Parameter['type']];
} & (IsUnknown<Parameter['name']> extends false ? {
readonly name: Parameter['name'];
} : object) & (Parameter['indexed'] extends true ? {
readonly components: Options['Structs'][ShallowParameter['type']];
} & (IsUnknown<ShallowParameter['name']> extends false ? {
readonly name: ShallowParameter['name'];
} : object) & (ShallowParameter['indexed'] extends true ? {
readonly indexed: true;
} : object)> : Parameter['type'] extends `${infer Type extends string & keyof Options['Structs']}[${infer Tail}]` ? Prettify<{
} : object) : ShallowParameter['type'] extends `${infer Type extends string & keyof Options['Structs']}[${infer Tail}]` ? {
readonly type: `tuple[${Tail}]`;
readonly components: Options['Structs'][Type];
} & (IsUnknown<Parameter['name']> extends false ? {
readonly name: Parameter['name'];
} : object) & (Parameter['indexed'] extends true ? {
} & (IsUnknown<ShallowParameter['name']> extends false ? {
readonly name: ShallowParameter['name'];
} : object) & (ShallowParameter['indexed'] extends true ? {
readonly indexed: true;
} : object)> : Parameter : never;
type SplitParameters<T extends string, Result extends unknown[] = [], Current extends string = '', Depth extends ReadonlyArray<number> = []> = T extends '' ? Current extends '' ? [...Result] : [...Result, Trim<Current>] : T extends `${infer Char}${infer Tail}` ? Char extends ',' ? Depth['length'] extends 0 ? SplitParameters<Tail, [...Result, Trim<Current>], ''> : SplitParameters<Tail, Result, `${Current}${Char}`, Depth> : Char extends '(' ? SplitParameters<Tail, Result, `${Current}${Char}`, [...Depth, 1]> : Char extends ')' ? SplitParameters<Tail, Result, `${Current}${Char}`, Pop<Depth>> : SplitParameters<Tail, Result, `${Current}${Char}`, Depth> : [];
} : object) : ShallowParameter) extends infer Parameter extends AbiParameter & {
type: string;
indexed?: boolean;
} ? Prettify<_ValidateAbiParameter<Parameter>> : never : never;
type SplitParameters<T extends string, Result extends unknown[] = [], Current extends string = '', Depth extends ReadonlyArray<number> = []> = T extends '' ? Current extends '' ? [...Result] : Depth['length'] extends 0 ? [...Result, Trim<Current>] : Error$1<`Unbalanced parentheses. "${Current}" has too many opening parentheses.`> : T extends `${infer Char}${infer Tail}` ? Char extends ',' ? Depth['length'] extends 0 ? SplitParameters<Tail, [...Result, Trim<Current>], ''> : SplitParameters<Tail, Result, `${Current}${Char}`, Depth> : Char extends '(' ? SplitParameters<Tail, Result, `${Current}${Char}`, [...Depth, 1]> : Char extends ')' ? Depth['length'] extends 0 ? Error$1<`Unbalanced parentheses. "${Current}" has too many closing parentheses.`> : SplitParameters<Tail, Result, `${Current}${Char}`, Pop<Depth>> : SplitParameters<Tail, Result, `${Current}${Char}`, Depth> : [];
type Pop<T extends ReadonlyArray<number>> = T extends [...infer R, any] ? R : [];
type _ValidateAbiParameter<TAbiParameter extends AbiParameter> = (TAbiParameter extends {
name: string;
} ? ValidateName<TAbiParameter['name']> extends infer Name ? Name extends TAbiParameter['name'] ? TAbiParameter : Merge<TAbiParameter, {
readonly name: Name;
}> : never : TAbiParameter) extends infer Parameter ? (ResolvedConfig['StrictAbiType'] extends true ? Parameter extends {
type: AbiType;
} ? Parameter : Merge<Parameter, {
readonly type: Error$1<`Type "${Parameter extends {
type: string;
} ? Parameter['type'] : string}" is not a valid ABI type.`>;
}> : Parameter) extends infer Parameter2 extends {
type: unknown;
} ? Parameter2['type'] extends `${infer Prefix extends 'u' | ''}int${infer Suffix extends `[${string}]` | ''}` ? Merge<Parameter2, {
readonly type: `${Prefix}int256${Suffix}`;
}> : Parameter2 : never : never;
type _ParseFunctionParametersAndStateMutability<TSignature extends string> = TSignature extends `${infer Head}returns (${string})` ? _ParseFunctionParametersAndStateMutability<Trim<Head>> : TSignature extends `function ${string}(${infer Parameters})` ? {

@@ -379,2 +406,9 @@ Inputs: Parameters;

} : never;
type _ParseConstructorParametersAndStateMutability<TSignature extends string> = TSignature extends `constructor(${infer Parameters}) payable` ? {
Inputs: Parameters;
StateMutability: 'payable';
} : TSignature extends `constructor(${infer Parameters})` ? {
Inputs: Parameters;
StateMutability: 'nonpayable';
} : never;
type _ParseTuple<T extends `(${string})${string}`, Options extends ParseOptions = DefaultParseOptions> = T extends `(${infer Parameters})` ? {

@@ -389,18 +423,18 @@ readonly type: 'tuple';

End: string;
} ? Prettify<{
} ? {
readonly type: 'tuple';
readonly components: ParseAbiParameters$1<SplitParameters<`${Parameters})[${Size}] ${Parts['End']}`>, Omit<Options, 'Modifier'>>;
} & _SplitNameOrModifier<Parts['NameOrModifier'], Options>> : never : Prettify<{
} & _SplitNameOrModifier<Parts['NameOrModifier'], Options> : never : {
readonly type: `tuple[${Size}]`;
readonly components: ParseAbiParameters$1<SplitParameters<Parameters>, Omit<Options, 'Modifier'>>;
} & _SplitNameOrModifier<NameOrModifier, Options>> : never : T extends `(${infer Parameters}) ${infer NameOrModifier}` ? NameOrModifier extends `${string}) ${string}` ? _UnwrapNameOrModifier<NameOrModifier> extends infer Parts extends {
} & _SplitNameOrModifier<NameOrModifier, Options> : never : T extends `(${infer Parameters}) ${infer NameOrModifier}` ? NameOrModifier extends `${string}) ${string}` ? _UnwrapNameOrModifier<NameOrModifier> extends infer Parts extends {
NameOrModifier: string;
End: string;
} ? Prettify<{
} ? {
readonly type: 'tuple';
readonly components: ParseAbiParameters$1<SplitParameters<`${Parameters}) ${Parts['End']}`>, Omit<Options, 'Modifier'>>;
} & _SplitNameOrModifier<Parts['NameOrModifier'], Options>> : never : Prettify<{
} & _SplitNameOrModifier<Parts['NameOrModifier'], Options> : never : {
readonly type: 'tuple';
readonly components: ParseAbiParameters$1<SplitParameters<Parameters>, Omit<Options, 'Modifier'>>;
} & _SplitNameOrModifier<NameOrModifier, Options>> : never;
} & _SplitNameOrModifier<NameOrModifier, Options> : never;
type _SplitNameOrModifier<T extends string, Options extends ParseOptions = DefaultParseOptions> = Trim<T> extends infer Trimmed ? Options extends {

@@ -407,0 +441,0 @@ Modifier: Modifier;

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.7.0-canary.20230307T235025",
"version": "0.7.0-canary.20230309T205532",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

<br/>
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wagmi-dev/abitype/main/.github/logo-dark.svg">
<img alt="ABIType logo" src="https://raw.githubusercontent.com/wagmi-dev/abitype/main/.github/logo-light.svg" width="auto" height="45">
</picture>
<a href="https://abitype.dev">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wagmi-dev/abitype/main/.github/logo-dark.svg">
<img alt="ABIType logo" src="https://raw.githubusercontent.com/wagmi-dev/abitype/main/.github/logo-light.svg" width="auto" height="45">
</picture>
</a>
</p>

@@ -29,2 +31,8 @@

</a>
<a href="https://bestofjs.org/projects/abitype">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/endpoint?colorA=21262d&colorB=21262d&style=flat&url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=wagmi-dev%2Fabitype%26since=daily">
<img src="https://img.shields.io/endpoint?colorA=f6f8fa&colorB=f6f8fa&style=flat&url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=wagmi-dev%2Fabitype%26since=daily" alt="Best of JS">
</picture>
</a>
</div>

@@ -56,3 +64,3 @@

- You want to [typecheck](https://abitype.dev/api/types) your ABIs or EIP-712 Typed Data.
- You want to add type inference and autocomplete to your library based on user-provided ABIs or EIP-712 Typed Data, like [wagmi](https://wagmi.sh) does.
- You want to add type inference and autocomplete to your library based on user-provided ABIs or EIP-712 Typed Data, like [wagmi](https://wagmi.sh) and [viem](https://viem.sh).
- You need to [convert ABI types](https://abitype.dev/api/utilities#abiparameterstoprimitivetypes) (e.g. `'string'`) to TypeScript types (e.g. `string`) or other type transformations.

@@ -59,0 +67,0 @@ - You need to validate ABIs at [runtime](https://abitype.dev/api/zod) (e.g. after fetching from external resource).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc