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.9.4 to 0.9.5

2

dist/cjs/version.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '0.9.4';
exports.version = '0.9.5';
//# sourceMappingURL=version.js.map

@@ -1,2 +0,2 @@

export const version = '0.9.4';
export const version = '0.9.5';
//# sourceMappingURL=version.js.map
import type { Abi, AbiConstructor, AbiError, AbiEvent, AbiEventParameter, AbiFallback, AbiFunction, AbiParameter, AbiReceive, AbiStateMutability } from '../abi.js';
import { type FormatAbiParameters as FormatAbiParameters_ } from './formatAbiParameters.js';
import type { AssertName } from './types/signatures.js';
/**

@@ -9,3 +10,3 @@ * Formats ABI item (e.g. error, event, function) into human-readable ABI item

*/
export type FormatAbiItem<TAbiItem extends Abi[number]> = Abi[number] extends TAbiItem ? string : (TAbiItem extends AbiFunction ? AbiFunction extends TAbiItem ? string : `function ${TAbiItem['name']}(${FormatAbiParameters<TAbiItem['inputs']>})${TAbiItem['stateMutability'] extends Exclude<AbiStateMutability, 'nonpayable'> ? ` ${TAbiItem['stateMutability']}` : ''}${TAbiItem['outputs']['length'] extends 0 ? '' : ` returns (${FormatAbiParameters<TAbiItem['outputs']>})`}` : never) | (TAbiItem extends AbiEvent ? AbiEvent extends TAbiItem ? string : `event ${TAbiItem['name']}(${FormatAbiParameters<TAbiItem['inputs']>})` : never) | (TAbiItem extends AbiError ? AbiError extends TAbiItem ? string : `error ${TAbiItem['name']}(${FormatAbiParameters<TAbiItem['inputs']>})` : never) | (TAbiItem extends AbiConstructor ? AbiConstructor extends TAbiItem ? string : `constructor(${FormatAbiParameters<TAbiItem['inputs']>})${TAbiItem['stateMutability'] extends 'payable' ? ' payable' : ''}` : never) | (TAbiItem extends AbiFallback ? AbiFallback extends TAbiItem ? string : 'fallback()' : never) | (TAbiItem extends AbiReceive ? AbiReceive extends TAbiItem ? string : 'receive() external payable' : never);
export type FormatAbiItem<TAbiItem extends Abi[number]> = Abi[number] extends TAbiItem ? string : (TAbiItem extends AbiFunction ? AbiFunction extends TAbiItem ? string : `function ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<TAbiItem['inputs']>})${TAbiItem['stateMutability'] extends Exclude<AbiStateMutability, 'nonpayable'> ? ` ${TAbiItem['stateMutability']}` : ''}${TAbiItem['outputs']['length'] extends 0 ? '' : ` returns (${FormatAbiParameters<TAbiItem['outputs']>})`}` : never) | (TAbiItem extends AbiEvent ? AbiEvent extends TAbiItem ? string : `event ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<TAbiItem['inputs']>})` : never) | (TAbiItem extends AbiError ? AbiError extends TAbiItem ? string : `error ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<TAbiItem['inputs']>})` : never) | (TAbiItem extends AbiConstructor ? AbiConstructor extends TAbiItem ? string : `constructor(${FormatAbiParameters<TAbiItem['inputs']>})${TAbiItem['stateMutability'] extends 'payable' ? ' payable' : ''}` : never) | (TAbiItem extends AbiFallback ? AbiFallback extends TAbiItem ? string : 'fallback()' : never) | (TAbiItem extends AbiReceive ? AbiReceive extends TAbiItem ? string : 'receive() external payable' : never);
type FormatAbiParameters<TAbiParameters extends readonly (AbiParameter | AbiEventParameter)[]> = TAbiParameters['length'] extends 0 ? '' : FormatAbiParameters_<TAbiParameters extends readonly [

@@ -12,0 +13,0 @@ AbiParameter | AbiEventParameter,

import type { AbiEventParameter, AbiParameter } from '../abi.js';
import type { IsNarrowable, Join } from '../types.js';
import type { AssertName } from './types/signatures.js';
/**

@@ -36,3 +37,3 @@ * Formats {@link AbiParameter} to human-readable ABI parameter.

indexed: true;
} ? ' indexed' : ''}${TAbiParameter['name'] extends infer Name extends string ? Name extends '' ? '' : ` ${Name}` : ''}`;
} ? ' indexed' : ''}${TAbiParameter['name'] extends infer Name extends string ? Name extends '' ? '' : ` ${AssertName<Name>}` : ''}`;
/**

@@ -39,0 +40,0 @@ * Formats {@link AbiParameter} to human-readable ABI parameter.

@@ -28,5 +28,6 @@ import type { AbiStateMutability } from '../../abi.js';

export type IsName<TName extends string> = TName extends '' ? false : ValidateName<TName> extends TName ? true : false;
export type AssertName<TName extends string> = ValidateName<TName> extends infer InvalidName extends string[] ? `[${InvalidName[number]}]` : TName;
export type ValidateName<TName extends string, CheckCharacters extends boolean = false> = TName extends `${string}${' '}${string}` ? Error<`Identifier "${TName}" cannot contain whitespace.`> : IsSolidityKeyword<TName> extends true ? Error<`"${TName}" is a protected Solidity keyword.`> : TName extends `${number}` ? Error<`Identifier "${TName}" cannot be a number string.`> : TName extends `${number}${string}` ? Error<`Identifier "${TName}" cannot start with a number.`> : CheckCharacters extends true ? IsValidCharacter<TName> extends true ? TName : Error<`"${TName}" contains invalid character.`> : TName;
export type IsSolidityKeyword<T extends string> = T extends SolidityKeywords ? true : false;
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';
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}]` | ''}`;
export type IsValidCharacter<T extends string> = T extends `${ValidCharacters}${infer Tail}` ? Tail extends '' ? true : IsValidCharacter<Tail> : false;

@@ -33,0 +34,0 @@ 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' | '_' | '$';

@@ -38,3 +38,3 @@ /**

*/
export type IsNarrowable<T, U> = IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
export type IsNarrowable<T, U> = IsUnknown<T> extends true ? false : IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
/**

@@ -41,0 +41,0 @@ * Checks if {@link T} is `never`

@@ -1,2 +0,2 @@

export declare const version = "0.9.4";
export declare const version = "0.9.5";
//# sourceMappingURL=version.d.ts.map
{
"name": "abitype",
"description": "Strict TypeScript types for Ethereum ABIs",
"version": "0.9.4",
"version": "0.9.5",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "wagmi-dev/abitype",

@@ -17,2 +17,3 @@ import type {

} from './formatAbiParameters.js'
import type { AssertName } from './types/signatures.js'

@@ -32,3 +33,3 @@ /**

? string
: `function ${TAbiItem['name']}(${FormatAbiParameters<
: `function ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<
TAbiItem['inputs']

@@ -47,3 +48,3 @@ >})${TAbiItem['stateMutability'] extends Exclude<

? string
: `event ${TAbiItem['name']}(${FormatAbiParameters<
: `event ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<
TAbiItem['inputs']

@@ -55,3 +56,3 @@ >})`

? string
: `error ${TAbiItem['name']}(${FormatAbiParameters<
: `error ${AssertName<TAbiItem['name']>}(${FormatAbiParameters<
TAbiItem['inputs']

@@ -58,0 +59,0 @@ >})`

import type { AbiEventParameter, AbiParameter } from '../abi.js'
import { execTyped } from '../regex.js'
import type { IsNarrowable, Join } from '../types.js'
import type { AssertName } from './types/signatures.js'

@@ -50,3 +51,3 @@ /**

? ''
: ` ${Name}`
: ` ${AssertName<Name>}`
: ''}`

@@ -53,0 +54,0 @@

@@ -131,2 +131,8 @@ import type { AbiStateMutability } from '../../abi.js'

: false
export type AssertName<TName extends string> =
ValidateName<TName> extends infer InvalidName extends string[]
? `[${InvalidName[number]}]`
: TName
export type ValidateName<

@@ -211,2 +217,8 @@ TName extends string,

| 'virtual'
| `address${`[${string}]` | ''}`
| `bool${`[${string}]` | ''}`
| `string${`[${string}]` | ''}`
| `tuple${`[${string}]` | ''}`
| `bytes${number | ''}${`[${string}]` | ''}`
| `${'u' | ''}int${number | ''}${`[${string}]` | ''}`

@@ -213,0 +225,0 @@ export type IsValidCharacter<T extends string> =

@@ -53,6 +53,8 @@ /**

*/
export type IsNarrowable<T, U> = IsNever<
(T extends U ? true : false) & (U extends T ? false : true)
> extends true
export type IsNarrowable<T, U> = IsUnknown<T> extends true
? false
: IsNever<
(T extends U ? true : false) & (U extends T ? false : true)
> extends true
? false
: true

@@ -59,0 +61,0 @@

@@ -1,1 +0,1 @@

export const version = '0.9.4'
export const version = '0.9.5'

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

Sorry, the diff of this file is not supported yet

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