New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.10.0-canary.20230710T162259 to 0.10.0-canary.20230712T160300

8

dist/cjs/human-readable/runtime/signatures.js

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

const regex_js_1 = require("../../regex.js");
const errorSignatureRegex = /^error (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/;
const errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
function isErrorSignature(signature) {

@@ -15,3 +15,3 @@ return errorSignatureRegex.test(signature);

exports.execErrorSignature = execErrorSignature;
const eventSignatureRegex = /^event (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/;
const eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
function isEventSignature(signature) {

@@ -25,3 +25,3 @@ return eventSignatureRegex.test(signature);

exports.execEventSignature = execEventSignature;
const functionSignatureRegex = /^function (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
const functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
function isFunctionSignature(signature) {

@@ -35,3 +35,3 @@ return functionSignatureRegex.test(signature);

exports.execFunctionSignature = execFunctionSignature;
const structSignatureRegex = /^struct (?<name>[a-zA-Z0-9_]+) \{(?<properties>.*?)\}$/;
const structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
function isStructSignature(signature) {

@@ -38,0 +38,0 @@ return structSignatureRegex.test(signature);

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

exports.parseStructs = parseStructs;
const typeWithoutTupleRegex = /^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?$/;
const typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
function resolveStructs(abiParameters, structs, ancestors = new Set()) {

@@ -51,0 +51,0 @@ const components = [];

@@ -100,4 +100,4 @@ "use strict";

exports.parseSignature = parseSignature;
const abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/;
const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/;
const abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
const dynamicIntegerRegex = /^u?int$/;

@@ -104,0 +104,0 @@ function parseAbiParameter(param, options) {

@@ -114,2 +114,4 @@ "use strict";

(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
});

@@ -121,2 +123,5 @@ (0, vitest_1.test)('ValidateName', () => {

(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
});

@@ -141,3 +146,4 @@ (0, vitest_1.test)('IsSolidityKeyword', () => {

(0, vitest_1.expectTypeOf)().toEqualTypeOf();
(0, vitest_1.expectTypeOf)().toEqualTypeOf();
});
//# sourceMappingURL=signatures-test-d.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '0.10.0-canary.20230710T162259';
exports.version = '0.10.0-canary.20230712T160300';
//# sourceMappingURL=version.js.map
import { execTyped } from '../../regex.js';
const errorSignatureRegex = /^error (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/;
const errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
export function isErrorSignature(signature) {

@@ -9,3 +9,3 @@ return errorSignatureRegex.test(signature);

}
const eventSignatureRegex = /^event (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/;
const eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
export function isEventSignature(signature) {

@@ -17,3 +17,3 @@ return eventSignatureRegex.test(signature);

}
const functionSignatureRegex = /^function (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
const functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
export function isFunctionSignature(signature) {

@@ -25,3 +25,3 @@ return functionSignatureRegex.test(signature);

}
const structSignatureRegex = /^struct (?<name>[a-zA-Z0-9_]+) \{(?<properties>.*?)\}$/;
const structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
export function isStructSignature(signature) {

@@ -28,0 +28,0 @@ return structSignatureRegex.test(signature);

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

}
const typeWithoutTupleRegex = /^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?$/;
const typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
function resolveStructs(abiParameters, structs, ancestors = new Set()) {

@@ -47,0 +47,0 @@ const components = [];

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

}
const abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/;
const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/;
const abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
const dynamicIntegerRegex = /^u?int$/;

@@ -100,0 +100,0 @@ export function parseAbiParameter(param, options) {

@@ -112,2 +112,4 @@ import { assertType, expectTypeOf, test } from 'vitest';

expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
});

@@ -119,2 +121,5 @@ test('ValidateName', () => {

expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
});

@@ -139,3 +144,4 @@ test('IsSolidityKeyword', () => {

expectTypeOf().toEqualTypeOf();
expectTypeOf().toEqualTypeOf();
});
//# sourceMappingURL=signatures-test-d.js.map

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

export const version = '0.10.0-canary.20230710T162259';
export const version = '0.10.0-canary.20230712T160300';
//# sourceMappingURL=version.js.map

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

export type IsName<TName extends string> = TName extends '' ? false : ValidateName<TName> extends TName ? true : false;
export type ValidateName<TName extends string, CheckCharacters extends boolean = false> = TName extends `${string}${' '}${string}` ? Error<`Name "${TName}" cannot contain whitespace.`> : IsSolidityKeyword<TName> extends true ? Error<`"${TName}" is a protected Solidity keyword.`> : CheckCharacters extends true ? IsValidCharacter<TName> extends true ? TName : Error<`"${TName}" contains invalid character.`> : 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 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 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}`;

@@ -35,0 +35,0 @@ 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`;

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

export declare const version = "0.10.0-canary.20230710T162259";
export declare const version = "0.10.0-canary.20230712T160300";
//# sourceMappingURL=version.d.ts.map
{
"name": "abitype",
"description": "Strict TypeScript types for Ethereum ABIs",
"version": "0.10.0-canary.20230710T162259",
"version": "0.10.0-canary.20230712T160300",
"license": "MIT",

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

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

// https://regexr.com/78tsr
// https://regexr.com/7gmok
const errorSignatureRegex =
/^error (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/
/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/
export function isErrorSignature(signature: string) {

@@ -23,5 +23,5 @@ return errorSignatureRegex.test(signature)

// https://regexr.com/78tv3
// https://regexr.com/7gmoq
const eventSignatureRegex =
/^event (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/
/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/
export function isEventSignature(signature: string) {

@@ -37,5 +37,5 @@ return eventSignatureRegex.test(signature)

// https://regexr.com/78u1b
// https://regexr.com/7gmot
const functionSignatureRegex =
/^function (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/
/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/
export function isFunctionSignature(signature: string) {

@@ -53,5 +53,5 @@ return functionSignatureRegex.test(signature)

// https://regexr.com/78tsu
// https://regexr.com/7gmp3
const structSignatureRegex =
/^struct (?<name>[a-zA-Z0-9_]+) \{(?<properties>.*?)\}$/
/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/
export function isStructSignature(signature: string) {

@@ -58,0 +58,0 @@ return structSignatureRegex.test(signature)

@@ -56,3 +56,3 @@ import type { AbiParameter } from '../../abi.js'

const typeWithoutTupleRegex =
/^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?$/
/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/

@@ -59,0 +59,0 @@ function resolveStructs(

@@ -152,5 +152,5 @@ import type {

const abiParameterWithoutTupleRegex =
/^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/
/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/
const abiParameterWithTupleRegex =
/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/
/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/
const dynamicIntegerRegex = /^u?int$/

@@ -157,0 +157,0 @@

@@ -196,2 +196,5 @@ import { assertType, expectTypeOf, test } from 'vitest'

expectTypeOf<IsName<'virtual'>>().toEqualTypeOf<false>()
// no number strings
expectTypeOf<IsName<'123'>>().toEqualTypeOf<false>()
expectTypeOf<IsName<'12foo'>>().toEqualTypeOf<false>()
// no invalid characters

@@ -204,4 +207,5 @@ // expectTypeOf<IsName<'foo?'>>().toEqualTypeOf<false>()

expectTypeOf<ValidateName<'foo'>>().toEqualTypeOf<'foo'>()
expectTypeOf<ValidateName<'foo$', true>>().toEqualTypeOf<'foo$'>()
expectTypeOf<ValidateName<'foo bar'>>().toEqualTypeOf<
['Error: Name "foo bar" cannot contain whitespace.']
['Error: Identifier "foo bar" cannot contain whitespace.']
>()

@@ -211,5 +215,11 @@ expectTypeOf<ValidateName<'alias'>>().toEqualTypeOf<

>()
expectTypeOf<ValidateName<'foo$', true>>().toEqualTypeOf<
['Error: "foo$" contains invalid character.']
expectTypeOf<ValidateName<'123'>>().toEqualTypeOf<
['Error: Identifier "123" cannot be a number string.']
>()
expectTypeOf<ValidateName<'12foo'>>().toEqualTypeOf<
['Error: Identifier "12foo" cannot start with a number.']
>()
expectTypeOf<ValidateName<'foo?', true>>().toEqualTypeOf<
['Error: "foo?" contains invalid character.']
>()
})

@@ -232,2 +242,3 @@

expectTypeOf<IsValidCharacter<'___'>>().toEqualTypeOf<true>()
expectTypeOf<IsValidCharacter<'$$$'>>().toEqualTypeOf<true>()
expectTypeOf<IsValidCharacter<'foo_123'>>().toEqualTypeOf<true>()

@@ -234,0 +245,0 @@ expectTypeOf<IsValidCharacter<'foo_123?'>>().toEqualTypeOf<false>()

@@ -135,5 +135,9 @@ import type { AbiStateMutability } from '../../abi.js'

> = TName extends `${string}${' '}${string}`
? Error<`Name "${TName}" cannot contain whitespace.`>
? 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

@@ -224,3 +228,3 @@ ? IsValidCharacter<TName> extends true

// special characters
| '_'
| '_' | '$'

@@ -227,0 +231,0 @@ // Template string inference can absorb `returns`:

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

export const version = '0.10.0-canary.20230710T162259'
export const version = '0.10.0-canary.20230712T160300'

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