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

abitype

Package Overview
Dependencies
Maintainers
2
Versions
181
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 1.0.6 to 1.0.7

4

dist/cjs/human-readable/formatAbiItem.js

@@ -9,3 +9,3 @@ "use strict";

? ` ${abiItem.stateMutability}`
: ''}${abiItem.outputs.length
: ''}${abiItem.outputs?.length
? ` returns (${(0, formatAbiParameters_js_1.formatAbiParameters)(abiItem.outputs)})`

@@ -20,5 +20,5 @@ : ''}`;

if (abiItem.type === 'fallback')
return 'fallback()';
return `fallback() external${abiItem.stateMutability === 'payable' ? ' payable' : ''}`;
return 'receive() external payable';
}
//# sourceMappingURL=formatAbiItem.js.map

@@ -5,5 +5,16 @@ "use strict";

exports.getParameterCacheKey = getParameterCacheKey;
function getParameterCacheKey(param, type) {
function getParameterCacheKey(param, type, structs) {
let structKey = '';
if (structs)
for (const struct of Object.entries(structs)) {
if (!struct)
continue;
let propertyKey = '';
for (const property of struct[1]) {
propertyKey += `[${property.type}${property.name ? `:${property.name}` : ''}]`;
}
structKey += `(${struct[0]}{${propertyKey}})`;
}
if (type)
return `${type}:${param}`;
return `${type}:${param}${structKey}`;
return param;

@@ -10,0 +21,0 @@ }

@@ -108,3 +108,3 @@ "use strict";

function parseAbiParameter(param, options) {
const parameterCacheKey = (0, cache_js_1.getParameterCacheKey)(param, options?.type);
const parameterCacheKey = (0, cache_js_1.getParameterCacheKey)(param, options?.type, options?.structs);
if (cache_js_1.parameterCache.has(parameterCacheKey))

@@ -111,0 +111,0 @@ return cache_js_1.parameterCache.get(parameterCacheKey);

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

@@ -190,3 +190,3 @@ "use strict";

exports.TypedDataDomain = zod_1.z.object({
chainId: zod_1.z.number().optional(),
chainId: zod_1.z.union([zod_1.z.number(), zod_1.z.bigint()]).optional(),
name: Identifier.optional(),

@@ -193,0 +193,0 @@ salt: zod_1.z.string().optional(),

@@ -12,3 +12,3 @@ import { formatAbiParameters, } from './formatAbiParameters.js';

? ` ${abiItem.stateMutability}`
: ''}${abiItem.outputs.length
: ''}${abiItem.outputs?.length
? ` returns (${formatAbiParameters(abiItem.outputs)})`

@@ -23,5 +23,5 @@ : ''}`;

if (abiItem.type === 'fallback')
return 'fallback()';
return `fallback() external${abiItem.stateMutability === 'payable' ? ' payable' : ''}`;
return 'receive() external payable';
}
//# sourceMappingURL=formatAbiItem.js.map

@@ -7,5 +7,16 @@ /**

*/
export function getParameterCacheKey(param, type) {
export function getParameterCacheKey(param, type, structs) {
let structKey = '';
if (structs)
for (const struct of Object.entries(structs)) {
if (!struct)
continue;
let propertyKey = '';
for (const property of struct[1]) {
propertyKey += `[${property.type}${property.name ? `:${property.name}` : ''}]`;
}
structKey += `(${struct[0]}{${propertyKey}})`;
}
if (type)
return `${type}:${param}`;
return `${type}:${param}${structKey}`;
return param;

@@ -12,0 +23,0 @@ }

@@ -101,3 +101,3 @@ import { bytesRegex, execTyped, integerRegex, isTupleRegex, } from '../../regex.js';

// optional namespace cache by `type`
const parameterCacheKey = getParameterCacheKey(param, options?.type);
const parameterCacheKey = getParameterCacheKey(param, options?.type, options?.structs);
if (parameterCache.has(parameterCacheKey))

@@ -104,0 +104,0 @@ return parameterCache.get(parameterCacheKey);

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

export const version = '1.0.6';
export const version = '1.0.7';
//# sourceMappingURL=version.js.map

@@ -240,3 +240,3 @@ import { z } from 'zod';

export const TypedDataDomain = z.object({
chainId: z.number().optional(),
chainId: z.union([z.number(), z.bigint()]).optional(),
name: Identifier.optional(),

@@ -243,0 +243,0 @@ salt: z.string().optional(),

@@ -122,3 +122,3 @@ import type { ResolvedRegister } from './register.js';

export type TypedDataDomain = {
chainId?: number | undefined;
chainId?: number | bigint | undefined;
name?: string | undefined;

@@ -125,0 +125,0 @@ salt?: ResolvedRegister['bytesType']['outputs'] | undefined;

@@ -10,3 +10,3 @@ import type { Abi, AbiConstructor, AbiError, AbiEvent, AbiEventParameter, AbiFallback, AbiFunction, AbiParameter, AbiReceive, AbiStateMutability } from '../abi.js';

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

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

import type { AbiItemType, AbiParameter } from '../../abi.js';
import type { StructLookup } from '../types/structs.js';
/**

@@ -8,3 +9,3 @@ * Gets {@link parameterCache} cache key namespaced by {@link type}. This prevents parameters from being accessible to types that don't allow them (e.g. `string indexed foo` not allowed outside of `type: 'event'`).

*/
export declare function getParameterCacheKey(param: string, type?: AbiItemType | 'struct'): string;
export declare function getParameterCacheKey(param: string, type?: AbiItemType | 'struct', structs?: StructLookup): string;
/**

@@ -11,0 +12,0 @@ * Basic cache seeded with common ABI parameter strings.

@@ -10,4 +10,4 @@ import type { AbiItemType, AbiType, SolidityArray, SolidityBytes, SolidityString, SolidityTuple } from '../../abi.js';

type: string;
name?: string | undefined;
internalType?: import("../../abi.js").AbiInternalType | undefined;
name?: string | undefined | undefined;
internalType?: string | undefined;
} & {

@@ -34,4 +34,4 @@ indexed?: boolean;

type: string;
name?: string | undefined;
internalType?: import("../../abi.js").AbiInternalType | undefined;
name?: string | undefined | undefined;
internalType?: string | undefined;
} & {

@@ -61,4 +61,4 @@ indexed?: boolean;

type: string;
name?: string | undefined;
internalType?: import("../../abi.js").AbiInternalType | undefined;
name?: string | undefined | undefined;
internalType?: string | undefined;
} & {

@@ -90,4 +90,4 @@ indexed?: boolean;

type: string;
name?: string | undefined;
internalType?: import("../../abi.js").AbiInternalType | undefined;
name?: string | undefined | undefined;
internalType?: string | undefined;
} & {

@@ -134,4 +134,4 @@ indexed?: boolean;

type: string;
name?: string | undefined;
internalType?: import("../../abi.js").AbiInternalType | undefined;
name?: string | undefined | undefined;
internalType?: string | undefined;
} & {

@@ -138,0 +138,0 @@ indexed?: boolean;

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

export declare const version = "1.0.6";
export declare const version = "1.0.7";
//# sourceMappingURL=version.d.ts.map

@@ -287,3 +287,3 @@ import { z } from 'zod';

export declare const TypedDataDomain: z.ZodObject<{
chainId: z.ZodOptional<z.ZodNumber>;
chainId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
name: z.ZodOptional<z.ZodString>;

@@ -295,3 +295,3 @@ salt: z.ZodOptional<z.ZodString>;

name?: string | undefined;
chainId?: number | undefined;
chainId?: number | bigint | undefined;
salt?: string | undefined;

@@ -302,3 +302,3 @@ verifyingContract?: `0x${string}` | undefined;

name?: string | undefined;
chainId?: number | undefined;
chainId?: number | bigint | undefined;
salt?: string | undefined;

@@ -305,0 +305,0 @@ verifyingContract?: string | undefined;

{
"name": "abitype",
"description": "Strict TypeScript types for Ethereum ABIs",
"version": "1.0.6",
"version": "1.0.7",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "wevm/abitype",

@@ -221,3 +221,3 @@ import type { ResolvedRegister } from './register.js'

export type TypedDataDomain = {
chainId?: number | undefined
chainId?: number | bigint | undefined
name?: string | undefined

@@ -224,0 +224,0 @@ salt?: ResolvedRegister['bytesType']['outputs'] | undefined

@@ -69,3 +69,5 @@ import type {

? string
: 'fallback()'
: `fallback() external${abiItem['stateMutability'] extends 'payable'
? ' payable'
: ''}`
: never)

@@ -114,3 +116,3 @@ | (abiItem extends AbiReceive

}${
abiItem.outputs.length
abiItem.outputs?.length
? ` returns (${formatAbiParameters(abiItem.outputs as Params)})`

@@ -131,4 +133,7 @@ : ''

}`
if (abiItem.type === 'fallback') return 'fallback()' as Result
if (abiItem.type === 'fallback')
return `fallback() external${
abiItem.stateMutability === 'payable' ? ' payable' : ''
}` as Result
return 'receive() external payable' as Result
}
import type { AbiItemType, AbiParameter } from '../../abi.js'
import type { StructLookup } from '../types/structs.js'

@@ -12,4 +13,15 @@ /**

type?: AbiItemType | 'struct',
structs?: StructLookup,
) {
if (type) return `${type}:${param}`
let structKey = ''
if (structs)
for (const struct of Object.entries(structs)) {
if (!struct) continue
let propertyKey = ''
for (const property of struct[1]) {
propertyKey += `[${property.type}${property.name ? `:${property.name}` : ''}]`
}
structKey += `(${struct[0]}{${propertyKey}})`
}
if (type) return `${type}:${param}${structKey}`
return param

@@ -16,0 +28,0 @@ }

@@ -165,3 +165,7 @@ import type {

// optional namespace cache by `type`
const parameterCacheKey = getParameterCacheKey(param, options?.type)
const parameterCacheKey = getParameterCacheKey(
param,
options?.type,
options?.structs,
)
if (parameterCache.has(parameterCacheKey))

@@ -168,0 +172,0 @@ return parameterCache.get(parameterCacheKey)!

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

export const version = '1.0.6'
export const version = '1.0.7'

@@ -302,3 +302,3 @@ import { z } from 'zod'

export const TypedDataDomain = z.object({
chainId: z.number().optional(),
chainId: z.union([z.number(), z.bigint()]).optional(),
name: Identifier.optional(),

@@ -305,0 +305,0 @@ salt: z.string().optional(),

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

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