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.8.0-canary.20230414T231212 to 0.8.0-canary.20230420T183122

dist/abi-3a9c20c7.d.ts

104

dist/index.d.ts

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

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-7aa1f183.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-7aa1f183.js';
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, p as AbiItemType } from './abi-3a9c20c7.js';
export { l as Abi, q as AbiConstructor, r as AbiError, s as AbiEvent, t as AbiFallback, u as AbiFunction, v as AbiInternalType, p 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-3a9c20c7.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';

@@ -270,2 +270,15 @@ export { C as Config, D as DefaultConfig, R as ResolvedConfig } from './config-edd78478.js';

declare class InvalidAbiItemError extends BaseError {
name: string;
constructor({ signature }: {
signature: string | object;
});
}
declare class UnknownTypeError extends BaseError {
name: string;
constructor({ type }: {
type: string;
});
}
type ErrorSignature<TName extends string = string, TParameters extends string = string> = `error ${TName}(${TParameters})`;

@@ -496,2 +509,87 @@ type IsErrorSignature<T extends string> = T extends ErrorSignature<infer Name> ? IsName<Name> : false;

declare class InvalidAbiParameterError extends BaseError {
name: string;
constructor({ param }: {
param: string | object;
});
}
declare class InvalidAbiParametersError extends BaseError {
name: string;
constructor({ params }: {
params: string | object;
});
}
declare class InvalidParameterError extends BaseError {
name: string;
constructor({ param }: {
param: string;
});
}
declare class SolidityProtectedKeywordError extends BaseError {
name: string;
constructor({ param, name }: {
param: string;
name: string;
});
}
declare class InvalidModifierError extends BaseError {
name: string;
constructor({ param, type, modifier, }: {
param: string;
type?: AbiItemType | 'struct';
modifier: Modifier;
});
}
declare class InvalidFunctionModifierError extends BaseError {
name: string;
constructor({ param, type, modifier, }: {
param: string;
type?: AbiItemType | 'struct';
modifier: Modifier;
});
}
declare class InvalidAbiTypeParameterError extends BaseError {
name: string;
constructor({ abiParameter, }: {
abiParameter: AbiParameter & {
indexed?: boolean;
};
});
}
declare class InvalidSignatureError extends BaseError {
name: string;
constructor({ signature, type, }: {
signature: string;
type: AbiItemType | 'struct';
});
}
declare class UnknownSignatureError extends BaseError {
name: string;
constructor({ signature }: {
signature: string;
});
}
declare class InvalidStructSignatureError extends BaseError {
name: string;
constructor({ signature }: {
signature: string;
});
}
declare class InvalidParenthesisError extends BaseError {
name: string;
constructor({ current, depth }: {
current: string;
depth: number;
});
}
declare class CircularReferenceError extends BaseError {
name: string;
constructor({ type }: {
type: string;
});
}
/**

@@ -654,2 +752,2 @@ * Parses human-readable ABI into JSON {@link Abi}

export { AbiParameterToPrimitiveType, AbiParametersToPrimitiveTypes, AbiTypeToPrimitiveType, BaseError, ExtractAbiError, ExtractAbiErrorNames, ExtractAbiErrors, ExtractAbiEvent, ExtractAbiEventNames, ExtractAbiEvents, ExtractAbiFunction, ExtractAbiFunctionNames, ExtractAbiFunctions, IsAbi, IsTypedData, Narrow, ParseAbi, ParseAbiItem, ParseAbiParameter, ParseAbiParameters, TypedDataToPrimitiveTypes, narrow, parseAbi, parseAbiItem, parseAbiParameter, parseAbiParameters };
export { AbiParameterToPrimitiveType, AbiParametersToPrimitiveTypes, AbiTypeToPrimitiveType, BaseError, CircularReferenceError, ExtractAbiError, ExtractAbiErrorNames, ExtractAbiErrors, ExtractAbiEvent, ExtractAbiEventNames, ExtractAbiEvents, ExtractAbiFunction, ExtractAbiFunctionNames, ExtractAbiFunctions, InvalidAbiItemError, InvalidAbiParameterError, InvalidAbiParametersError, InvalidAbiTypeParameterError, InvalidFunctionModifierError, InvalidModifierError, InvalidParameterError, InvalidParenthesisError, InvalidSignatureError, InvalidStructSignatureError, IsAbi, IsTypedData, Narrow, ParseAbi, ParseAbiItem, ParseAbiParameter, ParseAbiParameters, SolidityProtectedKeywordError, TypedDataToPrimitiveTypes, UnknownSignatureError, UnknownTypeError, narrow, parseAbi, parseAbiItem, parseAbiParameter, parseAbiParameters };

282

dist/index.js

@@ -48,2 +48,165 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// src/human-readable/errors/abiItem.ts
var InvalidAbiItemError = class extends BaseError {
constructor({ signature }) {
super("Failed to parse ABI item.", {
details: `parseAbiItem(${JSON.stringify(signature, null, 2)})`,
docsPath: "/api/human.html#parseabiitem-1"
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidAbiItemError");
}
};
var UnknownTypeError = class extends BaseError {
constructor({ type }) {
super("Unknown type.", {
metaMessages: [
`Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "UnknownTypeError");
}
};
var UnknownSolidityTypeError = class extends BaseError {
constructor({ type }) {
super("Unknown type.", {
metaMessages: [`Type "${type}" is not a valid ABI type.`]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "UnknownSolidityTypeError");
}
};
// src/human-readable/errors/abiParameter.ts
var InvalidAbiParameterError = class extends BaseError {
constructor({ param }) {
super("Failed to parse ABI parameter.", {
details: `parseAbiParameter(${JSON.stringify(param, null, 2)})`,
docsPath: "/api/human.html#parseabiparameter-1"
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidAbiParameterError");
}
};
var InvalidAbiParametersError = class extends BaseError {
constructor({ params }) {
super("Failed to parse ABI parameters.", {
details: `parseAbiParameters(${JSON.stringify(params, null, 2)})`,
docsPath: "/api/human.html#parseabiparameters-1"
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidAbiParametersError");
}
};
var InvalidParameterError = class extends BaseError {
constructor({ param }) {
super("Invalid ABI parameter.", {
details: param
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidParameterError");
}
};
var SolidityProtectedKeywordError = class extends BaseError {
constructor({ param, name: name2 }) {
super("Invalid ABI parameter.", {
details: param,
metaMessages: [
`"${name2}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "SolidityProtectedKeywordError");
}
};
var InvalidModifierError = class extends BaseError {
constructor({
param,
type,
modifier
}) {
super("Invalid ABI parameter.", {
details: param,
metaMessages: [
`Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`
]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidModifierError");
}
};
var InvalidFunctionModifierError = class extends BaseError {
constructor({
param,
type,
modifier
}) {
super("Invalid ABI parameter.", {
details: param,
metaMessages: [
`Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`,
`Data location can only be specified for array, struct, or mapping types, but "${modifier}" was given.`
]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidFunctionModifierError");
}
};
var InvalidAbiTypeParameterError = class extends BaseError {
constructor({
abiParameter
}) {
super("Invalid ABI parameter.", {
details: JSON.stringify(abiParameter, null, 2),
metaMessages: ["ABI parameter type is invalid."]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidAbiTypeParameterError");
}
};
// src/human-readable/errors/signature.ts
var InvalidSignatureError = class extends BaseError {
constructor({
signature,
type
}) {
super(`Invalid ${type} signature.`, {
details: signature
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidSignatureError");
}
};
var UnknownSignatureError = class extends BaseError {
constructor({ signature }) {
super(`Unknown signature.`, {
details: signature
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "UnknownSignatureError");
}
};
var InvalidStructSignatureError = class extends BaseError {
constructor({ signature }) {
super(`Invalid struct signature.`, {
details: signature,
metaMessages: ["No properties exist."]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidStructSignatureError");
}
};
// src/human-readable/errors/splitParameters.ts
var InvalidParenthesisError = class extends BaseError {
constructor({ current, depth }) {
super("Unbalanced parentheses.", {
metaMessages: [
`"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.`
],
details: `Depth "${depth}"`
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "InvalidParenthesisError");
}
};
// src/human-readable/errors/struct.ts
var CircularReferenceError = class extends BaseError {
constructor({ type }) {
super("Circular reference detected.", {
metaMessages: [`Struct "${type}" is a circular reference.`]
});
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "name", "CircularReferenceError");
}
};
// src/human-readable/runtime/signatures.ts

@@ -181,5 +344,3 @@ var errorSignatureRegex = /^error (?<name>[a-zA-Z0-9_]+)\((?<parameters>.*?)\)$/;

if (!match)
throw new BaseError("Invalid function signature.", {
details: signature
});
throw new InvalidSignatureError({ signature, type: "function" });
const inputParams = splitParameters(match.parameters);

@@ -222,5 +383,3 @@ const inputs = [];

if (!match)
throw new BaseError("Invalid event signature.", {
details: signature
});
throw new InvalidSignatureError({ signature, type: "event" });
const params = splitParameters(match.parameters);

@@ -243,5 +402,3 @@ const abiParameters = [];

if (!match)
throw new BaseError("Invalid error signature.", {
details: signature
});
throw new InvalidSignatureError({ signature, type: "error" });
const params = splitParameters(match.parameters);

@@ -260,5 +417,3 @@ const abiParameters = [];

if (!match)
throw new BaseError("Invalid constructor signature.", {
details: signature
});
throw new InvalidSignatureError({ signature, type: "constructor" });
const params = splitParameters(match.parameters);

@@ -285,5 +440,3 @@ const abiParameters = [];

};
throw new BaseError("Unknown signature.", {
details: signature
});
throw new UnknownSignatureError({ signature });
}

@@ -303,12 +456,5 @@ var abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z0-9_]+?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z0-9_]+))?$/;

if (!match)
throw new BaseError("Invalid ABI parameter.", {
details: param
});
throw new InvalidParameterError({ param });
if (match.name && isSolidityKeyword(match.name))
throw new BaseError("Invalid ABI parameter.", {
details: param,
metaMessages: [
`"${match.name}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
]
});
throw new SolidityProtectedKeywordError({ param, name: match.name });
const name2 = match.name ? { name: match.name } : {};

@@ -336,21 +482,16 @@ const indexed = match.modifier === "indexed" ? { indexed: true } : {};

if (!(_optionalChain([options, 'optionalAccess', _5 => _5.type]) === "struct") && !isSolidityType(type))
throw new BaseError("Unknown type.", {
metaMessages: [`Type "${type}" is not a valid ABI type.`]
});
throw new UnknownSolidityTypeError({ type });
}
if (match.modifier) {
if (!_optionalChain([options, 'optionalAccess', _6 => _6.modifiers, 'optionalAccess', _7 => _7.has, 'optionalCall', _8 => _8(match.modifier)]))
throw new BaseError("Invalid ABI parameter.", {
details: param,
metaMessages: [
`Modifier "${match.modifier}" not allowed${_optionalChain([options, 'optionalAccess', _9 => _9.type]) ? ` in "${options.type}" type` : ""}.`
]
throw new InvalidModifierError({
param,
type: _optionalChain([options, 'optionalAccess', _9 => _9.type]),
modifier: match.modifier
});
if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array))
throw new BaseError("Invalid ABI parameter.", {
details: param,
metaMessages: [
`Modifier "${match.modifier}" not allowed${_optionalChain([options, 'optionalAccess', _10 => _10.type]) ? ` in "${options.type}" type` : ""}.`,
`Data location can only be specified for array, struct, or mapping types, but "${match.modifier}" was given.`
]
throw new InvalidFunctionModifierError({
param,
type: _optionalChain([options, 'optionalAccess', _10 => _10.type]),
modifier: match.modifier
});

@@ -372,9 +513,5 @@ }

if (depth !== 0)
throw new BaseError("Unbalanced parentheses.", {
metaMessages: [
`"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.`
],
details: `Depth "${depth}"`
});
return [...result, current.trim()];
throw new InvalidParenthesisError({ current, depth });
result.push(current.trim());
return result;
}

@@ -419,5 +556,3 @@ const length = params.length;

if (!match)
throw new BaseError("Invalid struct signature.", {
details: signature
});
throw new InvalidSignatureError({ signature, type: "struct" });
const properties = match.properties.split(";");

@@ -437,6 +572,3 @@ const components = [];

if (!components.length)
throw new BaseError("Invalid struct signature.", {
details: signature,
metaMessages: ["No properties exist."]
});
throw new InvalidStructSignatureError({ signature });
shallowStructs[match.name] = components;

@@ -468,12 +600,7 @@ }

if (!_optionalChain([match, 'optionalAccess', _11 => _11.type]))
throw new BaseError("Invalid ABI parameter.", {
details: JSON.stringify(abiParameter, null, 2),
metaMessages: ["ABI parameter type is invalid."]
});
throw new InvalidAbiTypeParameterError({ abiParameter });
const { array, type } = match;
if (type in structs) {
if (ancestors.has(type))
throw new BaseError("Circular reference detected.", {
metaMessages: [`Struct "${type}" is a circular reference.`]
});
throw new CircularReferenceError({ type });
components.push({

@@ -492,7 +619,3 @@ ...abiParameter,

else
throw new BaseError("Unknown type.", {
metaMessages: [
`Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
]
});
throw new UnknownTypeError({ type });
}

@@ -535,6 +658,3 @@ }

if (!abiItem)
throw new BaseError("Failed to parse ABI item.", {
details: `parseAbiItem(${JSON.stringify(signature, null, 2)})`,
docsPath: "/api/human.html#parseabiitem-1"
});
throw new InvalidAbiItemError({ signature });
return abiItem;

@@ -562,6 +682,3 @@ }

if (!abiParameter)
throw new BaseError("Failed to parse ABI parameter.", {
details: `parseAbiParameter(${JSON.stringify(param, null, 2)})`,
docsPath: "/api/human.html#parseabiparameter-1"
});
throw new InvalidAbiParameterError({ param });
return abiParameter;

@@ -596,6 +713,3 @@ }

if (abiParameters.length === 0)
throw new BaseError("Failed to parse ABI parameters.", {
details: `parseAbiParameters(${JSON.stringify(params, null, 2)})`,
docsPath: "/api/human.html#parseabiparameters-1"
});
throw new InvalidAbiParametersError({ params });
return abiParameters;

@@ -610,2 +724,16 @@ }

exports.BaseError = BaseError; exports.narrow = narrow; exports.parseAbi = parseAbi; exports.parseAbiItem = parseAbiItem; exports.parseAbiParameter = parseAbiParameter2; exports.parseAbiParameters = parseAbiParameters;
exports.BaseError = BaseError; exports.CircularReferenceError = CircularReferenceError; exports.InvalidAbiItemError = InvalidAbiItemError; exports.InvalidAbiParameterError = InvalidAbiParameterError; exports.InvalidAbiParametersError = InvalidAbiParametersError; exports.InvalidAbiTypeParameterError = InvalidAbiTypeParameterError; exports.InvalidFunctionModifierError = InvalidFunctionModifierError; exports.InvalidModifierError = InvalidModifierError; exports.InvalidParameterError = InvalidParameterError; exports.InvalidParenthesisError = InvalidParenthesisError; exports.InvalidSignatureError = InvalidSignatureError; exports.InvalidStructSignatureError = InvalidStructSignatureError; exports.SolidityProtectedKeywordError = SolidityProtectedKeywordError; exports.UnknownSignatureError = UnknownSignatureError; exports.UnknownTypeError = UnknownTypeError; exports.narrow = narrow; exports.parseAbi = parseAbi; exports.parseAbiItem = parseAbiItem; exports.parseAbiParameter = parseAbiParameter2; exports.parseAbiParameters = parseAbiParameters;
import { z } from 'zod';
import { i as AbiParameter$1 } from '../abi-7aa1f183.js';
import { i as AbiParameter$1 } from '../abi-3a9c20c7.js';
import '../config-edd78478.js';

@@ -4,0 +4,0 @@

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

"license": "MIT",
"version": "0.8.0-canary.20230414T231212",
"version": "0.8.0-canary.20230420T183122",
"repository": {

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

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