UNPKG

@etherspot/remote-signer

Version:

Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler

1 lines 407 kB
{"version":3,"sources":["../../node_modules/abitype/src/version.ts","../../node_modules/abitype/src/errors.ts","../../node_modules/abitype/src/regex.ts","../../node_modules/abitype/src/human-readable/formatAbiParameter.ts","../../node_modules/abitype/src/human-readable/formatAbiParameters.ts","../../node_modules/abitype/src/human-readable/formatAbiItem.ts","../../node_modules/abitype/src/human-readable/runtime/signatures.ts","../../node_modules/abitype/src/human-readable/errors/abiItem.ts","../../node_modules/abitype/src/human-readable/errors/abiParameter.ts","../../node_modules/abitype/src/human-readable/errors/signature.ts","../../node_modules/abitype/src/human-readable/errors/struct.ts","../../node_modules/abitype/src/human-readable/errors/splitParameters.ts","../../node_modules/abitype/src/human-readable/runtime/cache.ts","../../node_modules/abitype/src/human-readable/runtime/utils.ts","../../node_modules/abitype/src/human-readable/runtime/structs.ts","../../node_modules/abitype/src/human-readable/parseAbi.ts","../../node_modules/abitype/src/human-readable/parseAbiItem.ts","../../node_modules/abitype/src/human-readable/parseAbiParameters.ts","../../node_modules/viem/accounts/utils/parseAccount.ts","../../node_modules/viem/constants/abis.ts","../../node_modules/viem/constants/contract.ts","../../node_modules/viem/constants/contracts.ts","../../node_modules/viem/errors/version.ts","../../node_modules/viem/errors/utils.ts","../../node_modules/viem/errors/base.ts","../../node_modules/viem/errors/chain.ts","../../node_modules/viem/constants/solidity.ts","../../node_modules/viem/utils/abi/formatAbiItem.ts","../../node_modules/viem/utils/data/isHex.ts","../../node_modules/viem/utils/data/size.ts","../../node_modules/viem/errors/abi.ts","../../node_modules/viem/errors/data.ts","../../node_modules/viem/utils/data/slice.ts","../../node_modules/viem/utils/data/pad.ts","../../node_modules/viem/errors/encoding.ts","../../node_modules/viem/utils/data/trim.ts","../../node_modules/viem/utils/encoding/fromHex.ts","../../node_modules/viem/utils/encoding/toHex.ts","../../node_modules/viem/utils/encoding/toBytes.ts","../../node_modules/@noble/hashes/src/_u64.ts","../../node_modules/@noble/hashes/src/sha3.ts","../../node_modules/viem/utils/hash/keccak256.ts","../../node_modules/viem/utils/hash/hashSignature.ts","../../node_modules/viem/utils/hash/normalizeSignature.ts","../../node_modules/viem/utils/hash/toSignature.ts","../../node_modules/viem/utils/hash/toSignatureHash.ts","../../node_modules/viem/utils/hash/toFunctionSelector.ts","../../node_modules/viem/errors/address.ts","../../node_modules/viem/utils/lru.ts","../../node_modules/viem/utils/address/isAddress.ts","../../node_modules/viem/utils/address/getAddress.ts","../../node_modules/viem/errors/cursor.ts","../../node_modules/viem/utils/cursor.ts","../../node_modules/viem/utils/encoding/fromBytes.ts","../../node_modules/viem/utils/data/concat.ts","../../node_modules/viem/utils/abi/encodeAbiParameters.ts","../../node_modules/viem/utils/abi/decodeAbiParameters.ts","../../node_modules/viem/utils/abi/decodeErrorResult.ts","../../node_modules/viem/utils/stringify.ts","../../node_modules/viem/utils/abi/formatAbiItemWithArgs.ts","../../node_modules/viem/utils/hash/toEventSelector.ts","../../node_modules/viem/utils/abi/getAbiItem.ts","../../node_modules/viem/constants/unit.ts","../../node_modules/viem/utils/unit/formatUnits.ts","../../node_modules/viem/utils/unit/formatEther.ts","../../node_modules/viem/utils/unit/formatGwei.ts","../../node_modules/viem/errors/stateOverride.ts","../../node_modules/viem/errors/transaction.ts","../../node_modules/viem/errors/contract.ts","../../node_modules/viem/utils/abi/decodeFunctionResult.ts","../../node_modules/viem/utils/abi/encodeDeployData.ts","../../node_modules/viem/utils/abi/prepareEncodeFunctionData.ts","../../node_modules/viem/utils/abi/encodeFunctionData.ts","../../node_modules/viem/utils/chain/getChainContractAddress.ts","../../node_modules/viem/errors/node.ts","../../node_modules/viem/errors/request.ts","../../node_modules/viem/errors/rpc.ts","../../node_modules/viem/utils/errors/getNodeError.ts","../../node_modules/viem/utils/errors/getCallError.ts","../../node_modules/viem/utils/formatters/extract.ts","../../node_modules/viem/utils/formatters/formatter.ts","../../node_modules/viem/utils/formatters/transactionRequest.ts","../../node_modules/viem/utils/promise/createBatchScheduler.ts","../../node_modules/viem/utils/stateOverride.ts","../../node_modules/viem/utils/transaction/assertRequest.ts","../../node_modules/viem/actions/public/call.ts","../../node_modules/viem/errors/ccip.ts","../../node_modules/viem/utils/address/isAddressEqual.ts","../../node_modules/viem/utils/ccip.ts"],"sourcesContent":["export const version = '1.0.4'\n","import type { OneOf, Pretty } from './types.js'\nimport { version } from './version.js'\n\ntype BaseErrorArgs = Pretty<\n {\n docsPath?: string | undefined\n metaMessages?: string[] | undefined\n } & OneOf<{ details?: string | undefined } | { cause?: BaseError | Error }>\n>\n\nexport class BaseError extends Error {\n details: string\n docsPath?: string | undefined\n metaMessages?: string[] | undefined\n shortMessage: string\n\n override name = 'AbiTypeError'\n\n constructor(shortMessage: string, args: BaseErrorArgs = {}) {\n const details =\n args.cause instanceof BaseError\n ? args.cause.details\n : args.cause?.message\n ? args.cause.message\n : args.details!\n const docsPath =\n args.cause instanceof BaseError\n ? args.cause.docsPath || args.docsPath\n : args.docsPath\n const message = [\n shortMessage || 'An error occurred.',\n '',\n ...(args.metaMessages ? [...args.metaMessages, ''] : []),\n ...(docsPath ? [`Docs: https://abitype.dev${docsPath}`] : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: abitype@${version}`,\n ].join('\\n')\n\n super(message)\n\n if (args.cause) this.cause = args.cause\n this.details = details\n this.docsPath = docsPath\n this.metaMessages = args.metaMessages\n this.shortMessage = shortMessage\n }\n}\n","// TODO: This looks cool. Need to check the performance of `new RegExp` versus defined inline though.\n// https://twitter.com/GabrielVergnaud/status/1622906834343366657\nexport function execTyped<type>(regex: RegExp, string: string) {\n const match = regex.exec(string)\n return match?.groups as type | undefined\n}\n\n// `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`\n// https://regexr.com/6va55\nexport const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/\n\n// `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`\n// https://regexr.com/6v8hp\nexport const integerRegex =\n /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/\n\nexport const isTupleRegex = /^\\(.+?\\).*?$/\n","import type { AbiEventParameter, AbiParameter } from '../abi.js'\nimport { execTyped } from '../regex.js'\nimport type { IsNarrowable, Join } from '../types.js'\nimport type { AssertName } from './types/signatures.js'\n\n/**\n * Formats {@link AbiParameter} to human-readable ABI parameter.\n *\n * @param abiParameter - ABI parameter\n * @returns Human-readable ABI parameter\n *\n * @example\n * type Result = FormatAbiParameter<{ type: 'address'; name: 'from'; }>\n * // ^? type Result = 'address from'\n */\nexport type FormatAbiParameter<\n abiParameter extends AbiParameter | AbiEventParameter,\n> = abiParameter extends {\n name?: infer name extends string\n type: `tuple${infer array}`\n components: infer components extends readonly AbiParameter[]\n indexed?: infer indexed extends boolean\n}\n ? FormatAbiParameter<\n {\n type: `(${Join<\n {\n [key in keyof components]: FormatAbiParameter<\n {\n type: components[key]['type']\n } & (IsNarrowable<components[key]['name'], string> extends true\n ? { name: components[key]['name'] }\n : unknown) &\n (components[key] extends { components: readonly AbiParameter[] }\n ? { components: components[key]['components'] }\n : unknown)\n >\n },\n ', '\n >})${array}`\n } & (IsNarrowable<name, string> extends true ? { name: name } : unknown) &\n (IsNarrowable<indexed, boolean> extends true\n ? { indexed: indexed }\n : unknown)\n >\n : `${abiParameter['type']}${abiParameter extends { indexed: true }\n ? ' indexed'\n : ''}${abiParameter['name'] extends infer name extends string\n ? name extends ''\n ? ''\n : ` ${AssertName<name>}`\n : ''}`\n\n// https://regexr.com/7f7rv\nconst tupleRegex = /^tuple(?<array>(\\[(\\d*)\\])*)$/\n\n/**\n * Formats {@link AbiParameter} to human-readable ABI parameter.\n *\n * @param abiParameter - ABI parameter\n * @returns Human-readable ABI parameter\n *\n * @example\n * const result = formatAbiParameter({ type: 'address', name: 'from' })\n * // ^? const result: 'address from'\n */\nexport function formatAbiParameter<\n const abiParameter extends AbiParameter | AbiEventParameter,\n>(abiParameter: abiParameter): FormatAbiParameter<abiParameter> {\n type Result = FormatAbiParameter<abiParameter>\n\n let type = abiParameter.type\n if (tupleRegex.test(abiParameter.type) && 'components' in abiParameter) {\n type = '('\n const length = abiParameter.components.length as number\n for (let i = 0; i < length; i++) {\n const component = abiParameter.components[i]!\n type += formatAbiParameter(component)\n if (i < length - 1) type += ', '\n }\n const result = execTyped<{ array?: string }>(tupleRegex, abiParameter.type)\n type += `)${result?.array ?? ''}`\n return formatAbiParameter({\n ...abiParameter,\n type,\n }) as Result\n }\n // Add `indexed` to type if in `abiParameter`\n if ('indexed' in abiParameter && abiParameter.indexed)\n type = `${type} indexed`\n // Return human-readable ABI parameter\n if (abiParameter.name) return `${type} ${abiParameter.name}` as Result\n return type as Result\n}\n","import type { AbiEventParameter, AbiParameter } from '../abi.js'\nimport type { Join } from '../types.js'\nimport {\n type FormatAbiParameter,\n formatAbiParameter,\n} from './formatAbiParameter.js'\n\n/**\n * Formats {@link AbiParameter}s to human-readable ABI parameter.\n *\n * @param abiParameters - ABI parameters\n * @returns Human-readable ABI parameters\n *\n * @example\n * type Result = FormatAbiParameters<[\n * // ^? type Result = 'address from, uint256 tokenId'\n * { type: 'address'; name: 'from'; },\n * { type: 'uint256'; name: 'tokenId'; },\n * ]>\n */\nexport type FormatAbiParameters<\n abiParameters extends readonly [\n AbiParameter | AbiEventParameter,\n ...(readonly (AbiParameter | AbiEventParameter)[]),\n ],\n> = Join<\n {\n [key in keyof abiParameters]: FormatAbiParameter<abiParameters[key]>\n },\n ', '\n>\n\n/**\n * Formats {@link AbiParameter}s to human-readable ABI parameters.\n *\n * @param abiParameters - ABI parameters\n * @returns Human-readable ABI parameters\n *\n * @example\n * const result = formatAbiParameters([\n * // ^? const result: 'address from, uint256 tokenId'\n * { type: 'address', name: 'from' },\n * { type: 'uint256', name: 'tokenId' },\n * ])\n */\nexport function formatAbiParameters<\n const abiParameters extends readonly [\n AbiParameter | AbiEventParameter,\n ...(readonly (AbiParameter | AbiEventParameter)[]),\n ],\n>(abiParameters: abiParameters): FormatAbiParameters<abiParameters> {\n let params = ''\n const length = abiParameters.length\n for (let i = 0; i < length; i++) {\n const abiParameter = abiParameters[i]!\n params += formatAbiParameter(abiParameter)\n if (i !== length - 1) params += ', '\n }\n return params as FormatAbiParameters<abiParameters>\n}\n","import type {\n Abi,\n AbiConstructor,\n AbiError,\n AbiEvent,\n AbiEventParameter,\n AbiFallback,\n AbiFunction,\n AbiParameter,\n AbiReceive,\n AbiStateMutability,\n} from '../abi.js'\nimport {\n type FormatAbiParameters as FormatAbiParameters_,\n formatAbiParameters,\n} from './formatAbiParameters.js'\nimport type { AssertName } from './types/signatures.js'\n\n/**\n * Formats ABI item (e.g. error, event, function) into human-readable ABI item\n *\n * @param abiItem - ABI item\n * @returns Human-readable ABI item\n */\nexport type FormatAbiItem<abiItem extends Abi[number]> =\n Abi[number] extends abiItem\n ? string\n :\n | (abiItem extends AbiFunction\n ? AbiFunction extends abiItem\n ? string\n : `function ${AssertName<abiItem['name']>}(${FormatAbiParameters<\n abiItem['inputs']\n >})${abiItem['stateMutability'] extends Exclude<\n AbiStateMutability,\n 'nonpayable'\n >\n ? ` ${abiItem['stateMutability']}`\n : ''}${abiItem['outputs']['length'] extends 0\n ? ''\n : ` returns (${FormatAbiParameters<abiItem['outputs']>})`}`\n : never)\n | (abiItem extends AbiEvent\n ? AbiEvent extends abiItem\n ? string\n : `event ${AssertName<abiItem['name']>}(${FormatAbiParameters<\n abiItem['inputs']\n >})`\n : never)\n | (abiItem extends AbiError\n ? AbiError extends abiItem\n ? string\n : `error ${AssertName<abiItem['name']>}(${FormatAbiParameters<\n abiItem['inputs']\n >})`\n : never)\n | (abiItem extends AbiConstructor\n ? AbiConstructor extends abiItem\n ? string\n : `constructor(${FormatAbiParameters<\n abiItem['inputs']\n >})${abiItem['stateMutability'] extends 'payable'\n ? ' payable'\n : ''}`\n : never)\n | (abiItem extends AbiFallback\n ? AbiFallback extends abiItem\n ? string\n : 'fallback()'\n : never)\n | (abiItem extends AbiReceive\n ? AbiReceive extends abiItem\n ? string\n : 'receive() external payable'\n : never)\n\ntype FormatAbiParameters<\n abiParameters extends readonly (AbiParameter | AbiEventParameter)[],\n> = abiParameters['length'] extends 0\n ? ''\n : FormatAbiParameters_<\n abiParameters extends readonly [\n AbiParameter | AbiEventParameter,\n ...(readonly (AbiParameter | AbiEventParameter)[]),\n ]\n ? abiParameters\n : never\n >\n\n/**\n * Formats ABI item (e.g. error, event, function) into human-readable ABI item\n *\n * @param abiItem - ABI item\n * @returns Human-readable ABI item\n */\nexport function formatAbiItem<const abiItem extends Abi[number]>(\n abiItem: abiItem,\n): FormatAbiItem<abiItem> {\n type Result = FormatAbiItem<abiItem>\n type Params = readonly [\n AbiParameter | AbiEventParameter,\n ...(readonly (AbiParameter | AbiEventParameter)[]),\n ]\n\n if (abiItem.type === 'function')\n return `function ${abiItem.name}(${formatAbiParameters(\n abiItem.inputs as Params,\n )})${\n abiItem.stateMutability && abiItem.stateMutability !== 'nonpayable'\n ? ` ${abiItem.stateMutability}`\n : ''\n }${\n abiItem.outputs.length\n ? ` returns (${formatAbiParameters(abiItem.outputs as Params)})`\n : ''\n }`\n if (abiItem.type === 'event')\n return `event ${abiItem.name}(${formatAbiParameters(\n abiItem.inputs as Params,\n )})`\n if (abiItem.type === 'error')\n return `error ${abiItem.name}(${formatAbiParameters(\n abiItem.inputs as Params,\n )})`\n if (abiItem.type === 'constructor')\n return `constructor(${formatAbiParameters(abiItem.inputs as Params)})${\n abiItem.stateMutability === 'payable' ? ' payable' : ''\n }`\n if (abiItem.type === 'fallback') return 'fallback()' as Result\n return 'receive() external payable' as Result\n}\n","import type { AbiStateMutability } from '../../abi.js'\nimport { execTyped } from '../../regex.js'\nimport type {\n EventModifier,\n FunctionModifier,\n Modifier,\n} from '../types/signatures.js'\n\n// https://regexr.com/7gmok\nconst errorSignatureRegex =\n /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)$/\nexport function isErrorSignature(signature: string) {\n return errorSignatureRegex.test(signature)\n}\nexport function execErrorSignature(signature: string) {\n return execTyped<{ name: string; parameters: string }>(\n errorSignatureRegex,\n signature,\n )\n}\n\n// https://regexr.com/7gmoq\nconst eventSignatureRegex =\n /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)$/\nexport function isEventSignature(signature: string) {\n return eventSignatureRegex.test(signature)\n}\nexport function execEventSignature(signature: string) {\n return execTyped<{ name: string; parameters: string }>(\n eventSignatureRegex,\n signature,\n )\n}\n\n// https://regexr.com/7gmot\nconst functionSignatureRegex =\n /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\\s?\\((?<returns>.*?)\\))?$/\nexport function isFunctionSignature(signature: string) {\n return functionSignatureRegex.test(signature)\n}\nexport function execFunctionSignature(signature: string) {\n return execTyped<{\n name: string\n parameters: string\n stateMutability?: AbiStateMutability\n returns?: string\n }>(functionSignatureRegex, signature)\n}\n\n// https://regexr.com/7gmp3\nconst structSignatureRegex =\n /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \\{(?<properties>.*?)\\}$/\nexport function isStructSignature(signature: string) {\n return structSignatureRegex.test(signature)\n}\nexport function execStructSignature(signature: string) {\n return execTyped<{ name: string; properties: string }>(\n structSignatureRegex,\n signature,\n )\n}\n\n// https://regexr.com/78u01\nconst constructorSignatureRegex =\n /^constructor\\((?<parameters>.*?)\\)(?:\\s(?<stateMutability>payable{1}))?$/\nexport function isConstructorSignature(signature: string) {\n return constructorSignatureRegex.test(signature)\n}\nexport function execConstructorSignature(signature: string) {\n return execTyped<{\n parameters: string\n stateMutability?: Extract<AbiStateMutability, 'payable'>\n }>(constructorSignatureRegex, signature)\n}\n\n// https://regexr.com/7srtn\nconst fallbackSignatureRegex =\n /^fallback\\(\\) external(?:\\s(?<stateMutability>payable{1}))?$/\nexport function isFallbackSignature(signature: string) {\n return fallbackSignatureRegex.test(signature)\n}\n\n// https://regexr.com/78u1k\nconst receiveSignatureRegex = /^receive\\(\\) external payable$/\nexport function isReceiveSignature(signature: string) {\n return receiveSignatureRegex.test(signature)\n}\n\nexport const modifiers = new Set<Modifier>([\n 'memory',\n 'indexed',\n 'storage',\n 'calldata',\n])\nexport const eventModifiers = new Set<EventModifier>(['indexed'])\nexport const functionModifiers = new Set<FunctionModifier>([\n 'calldata',\n 'memory',\n 'storage',\n])\n","import { BaseError } from '../../errors.js'\n\nexport class InvalidAbiItemError extends BaseError {\n override name = 'InvalidAbiItemError'\n\n constructor({ signature }: { signature: string | object }) {\n super('Failed to parse ABI item.', {\n details: `parseAbiItem(${JSON.stringify(signature, null, 2)})`,\n docsPath: '/api/human#parseabiitem-1',\n })\n }\n}\n\nexport class UnknownTypeError extends BaseError {\n override name = 'UnknownTypeError'\n\n constructor({ type }: { type: string }) {\n super('Unknown type.', {\n metaMessages: [\n `Type \"${type}\" is not a valid ABI type. Perhaps you forgot to include a struct signature?`,\n ],\n })\n }\n}\n\nexport class UnknownSolidityTypeError extends BaseError {\n override name = 'UnknownSolidityTypeError'\n\n constructor({ type }: { type: string }) {\n super('Unknown type.', {\n metaMessages: [`Type \"${type}\" is not a valid ABI type.`],\n })\n }\n}\n","import type { AbiItemType, AbiParameter } from '../../abi.js'\nimport { BaseError } from '../../errors.js'\nimport type { Modifier } from '../types/signatures.js'\n\nexport class InvalidAbiParameterError extends BaseError {\n override name = 'InvalidAbiParameterError'\n\n constructor({ param }: { param: string | object }) {\n super('Failed to parse ABI parameter.', {\n details: `parseAbiParameter(${JSON.stringify(param, null, 2)})`,\n docsPath: '/api/human#parseabiparameter-1',\n })\n }\n}\n\nexport class InvalidAbiParametersError extends BaseError {\n override name = 'InvalidAbiParametersError'\n\n constructor({ params }: { params: string | object }) {\n super('Failed to parse ABI parameters.', {\n details: `parseAbiParameters(${JSON.stringify(params, null, 2)})`,\n docsPath: '/api/human#parseabiparameters-1',\n })\n }\n}\n\nexport class InvalidParameterError extends BaseError {\n override name = 'InvalidParameterError'\n\n constructor({ param }: { param: string }) {\n super('Invalid ABI parameter.', {\n details: param,\n })\n }\n}\n\nexport class SolidityProtectedKeywordError extends BaseError {\n override name = 'SolidityProtectedKeywordError'\n\n constructor({ param, name }: { param: string; name: string }) {\n super('Invalid ABI parameter.', {\n details: param,\n metaMessages: [\n `\"${name}\" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`,\n ],\n })\n }\n}\n\nexport class InvalidModifierError extends BaseError {\n override name = 'InvalidModifierError'\n\n constructor({\n param,\n type,\n modifier,\n }: {\n param: string\n type?: AbiItemType | 'struct' | undefined\n modifier: Modifier\n }) {\n super('Invalid ABI parameter.', {\n details: param,\n metaMessages: [\n `Modifier \"${modifier}\" not allowed${\n type ? ` in \"${type}\" type` : ''\n }.`,\n ],\n })\n }\n}\n\nexport class InvalidFunctionModifierError extends BaseError {\n override name = 'InvalidFunctionModifierError'\n\n constructor({\n param,\n type,\n modifier,\n }: {\n param: string\n type?: AbiItemType | 'struct' | undefined\n modifier: Modifier\n }) {\n super('Invalid ABI parameter.', {\n details: param,\n metaMessages: [\n `Modifier \"${modifier}\" not allowed${\n type ? ` in \"${type}\" type` : ''\n }.`,\n `Data location can only be specified for array, struct, or mapping types, but \"${modifier}\" was given.`,\n ],\n })\n }\n}\n\nexport class InvalidAbiTypeParameterError extends BaseError {\n override name = 'InvalidAbiTypeParameterError'\n\n constructor({\n abiParameter,\n }: {\n abiParameter: AbiParameter & { indexed?: boolean | undefined }\n }) {\n super('Invalid ABI parameter.', {\n details: JSON.stringify(abiParameter, null, 2),\n metaMessages: ['ABI parameter type is invalid.'],\n })\n }\n}\n","import type { AbiItemType } from '../../abi.js'\nimport { BaseError } from '../../errors.js'\n\nexport class InvalidSignatureError extends BaseError {\n override name = 'InvalidSignatureError'\n\n constructor({\n signature,\n type,\n }: {\n signature: string\n type: AbiItemType | 'struct'\n }) {\n super(`Invalid ${type} signature.`, {\n details: signature,\n })\n }\n}\n\nexport class UnknownSignatureError extends BaseError {\n override name = 'UnknownSignatureError'\n\n constructor({ signature }: { signature: string }) {\n super('Unknown signature.', {\n details: signature,\n })\n }\n}\n\nexport class InvalidStructSignatureError extends BaseError {\n override name = 'InvalidStructSignatureError'\n\n constructor({ signature }: { signature: string }) {\n super('Invalid struct signature.', {\n details: signature,\n metaMessages: ['No properties exist.'],\n })\n }\n}\n","import { BaseError } from '../../errors.js'\n\nexport class CircularReferenceError extends BaseError {\n override name = 'CircularReferenceError'\n\n constructor({ type }: { type: string }) {\n super('Circular reference detected.', {\n metaMessages: [`Struct \"${type}\" is a circular reference.`],\n })\n }\n}\n","import { BaseError } from '../../errors.js'\n\nexport class InvalidParenthesisError extends BaseError {\n override name = 'InvalidParenthesisError'\n\n constructor({ current, depth }: { current: string; depth: number }) {\n super('Unbalanced parentheses.', {\n metaMessages: [\n `\"${current.trim()}\" has too many ${\n depth > 0 ? 'opening' : 'closing'\n } parentheses.`,\n ],\n details: `Depth \"${depth}\"`,\n })\n }\n}\n","import type { AbiItemType, AbiParameter } from '../../abi.js'\n\n/**\n * 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'`).\n * @param param ABI parameter string\n * @param type ABI parameter type\n * @returns Cache key for {@link parameterCache}\n */\nexport function getParameterCacheKey(\n param: string,\n type?: AbiItemType | 'struct',\n) {\n if (type) return `${type}:${param}`\n return param\n}\n\n/**\n * Basic cache seeded with common ABI parameter strings.\n *\n * **Note: When seeding more parameters, make sure you benchmark performance. The current number is the ideal balance between performance and having an already existing cache.**\n */\nexport const parameterCache = new Map<\n string,\n AbiParameter & { indexed?: boolean }\n>([\n // Unnamed\n ['address', { type: 'address' }],\n ['bool', { type: 'bool' }],\n ['bytes', { type: 'bytes' }],\n ['bytes32', { type: 'bytes32' }],\n ['int', { type: 'int256' }],\n ['int256', { type: 'int256' }],\n ['string', { type: 'string' }],\n ['uint', { type: 'uint256' }],\n ['uint8', { type: 'uint8' }],\n ['uint16', { type: 'uint16' }],\n ['uint24', { type: 'uint24' }],\n ['uint32', { type: 'uint32' }],\n ['uint64', { type: 'uint64' }],\n ['uint96', { type: 'uint96' }],\n ['uint112', { type: 'uint112' }],\n ['uint160', { type: 'uint160' }],\n ['uint192', { type: 'uint192' }],\n ['uint256', { type: 'uint256' }],\n\n // Named\n ['address owner', { type: 'address', name: 'owner' }],\n ['address to', { type: 'address', name: 'to' }],\n ['bool approved', { type: 'bool', name: 'approved' }],\n ['bytes _data', { type: 'bytes', name: '_data' }],\n ['bytes data', { type: 'bytes', name: 'data' }],\n ['bytes signature', { type: 'bytes', name: 'signature' }],\n ['bytes32 hash', { type: 'bytes32', name: 'hash' }],\n ['bytes32 r', { type: 'bytes32', name: 'r' }],\n ['bytes32 root', { type: 'bytes32', name: 'root' }],\n ['bytes32 s', { type: 'bytes32', name: 's' }],\n ['string name', { type: 'string', name: 'name' }],\n ['string symbol', { type: 'string', name: 'symbol' }],\n ['string tokenURI', { type: 'string', name: 'tokenURI' }],\n ['uint tokenId', { type: 'uint256', name: 'tokenId' }],\n ['uint8 v', { type: 'uint8', name: 'v' }],\n ['uint256 balance', { type: 'uint256', name: 'balance' }],\n ['uint256 tokenId', { type: 'uint256', name: 'tokenId' }],\n ['uint256 value', { type: 'uint256', name: 'value' }],\n\n // Indexed\n [\n 'event:address indexed from',\n { type: 'address', name: 'from', indexed: true },\n ],\n ['event:address indexed to', { type: 'address', name: 'to', indexed: true }],\n [\n 'event:uint indexed tokenId',\n { type: 'uint256', name: 'tokenId', indexed: true },\n ],\n [\n 'event:uint256 indexed tokenId',\n { type: 'uint256', name: 'tokenId', indexed: true },\n ],\n])\n","import type {\n AbiItemType,\n AbiType,\n SolidityArray,\n SolidityBytes,\n SolidityString,\n SolidityTuple,\n} from '../../abi.js'\nimport {\n bytesRegex,\n execTyped,\n integerRegex,\n isTupleRegex,\n} from '../../regex.js'\nimport { UnknownSolidityTypeError } from '../errors/abiItem.js'\nimport {\n InvalidFunctionModifierError,\n InvalidModifierError,\n InvalidParameterError,\n SolidityProtectedKeywordError,\n} from '../errors/abiParameter.js'\nimport {\n InvalidSignatureError,\n UnknownSignatureError,\n} from '../errors/signature.js'\nimport { InvalidParenthesisError } from '../errors/splitParameters.js'\nimport type { FunctionModifier, Modifier } from '../types/signatures.js'\nimport type { StructLookup } from '../types/structs.js'\nimport { getParameterCacheKey, parameterCache } from './cache.js'\nimport {\n eventModifiers,\n execConstructorSignature,\n execErrorSignature,\n execEventSignature,\n execFunctionSignature,\n functionModifiers,\n isConstructorSignature,\n isErrorSignature,\n isEventSignature,\n isFallbackSignature,\n isFunctionSignature,\n isReceiveSignature,\n} from './signatures.js'\n\nexport function parseSignature(signature: string, structs: StructLookup = {}) {\n if (isFunctionSignature(signature)) {\n const match = execFunctionSignature(signature)\n if (!match) throw new InvalidSignatureError({ signature, type: 'function' })\n\n const inputParams = splitParameters(match.parameters)\n const inputs = []\n const inputLength = inputParams.length\n for (let i = 0; i < inputLength; i++) {\n inputs.push(\n parseAbiParameter(inputParams[i]!, {\n modifiers: functionModifiers,\n structs,\n type: 'function',\n }),\n )\n }\n\n const outputs = []\n if (match.returns) {\n const outputParams = splitParameters(match.returns)\n const outputLength = outputParams.length\n for (let i = 0; i < outputLength; i++) {\n outputs.push(\n parseAbiParameter(outputParams[i]!, {\n modifiers: functionModifiers,\n structs,\n type: 'function',\n }),\n )\n }\n }\n\n return {\n name: match.name,\n type: 'function',\n stateMutability: match.stateMutability ?? 'nonpayable',\n inputs,\n outputs,\n }\n }\n\n if (isEventSignature(signature)) {\n const match = execEventSignature(signature)\n if (!match) throw new InvalidSignatureError({ signature, type: 'event' })\n\n const params = splitParameters(match.parameters)\n const abiParameters = []\n const length = params.length\n for (let i = 0; i < length; i++) {\n abiParameters.push(\n parseAbiParameter(params[i]!, {\n modifiers: eventModifiers,\n structs,\n type: 'event',\n }),\n )\n }\n return { name: match.name, type: 'event', inputs: abiParameters }\n }\n\n if (isErrorSignature(signature)) {\n const match = execErrorSignature(signature)\n if (!match) throw new InvalidSignatureError({ signature, type: 'error' })\n\n const params = splitParameters(match.parameters)\n const abiParameters = []\n const length = params.length\n for (let i = 0; i < length; i++) {\n abiParameters.push(\n parseAbiParameter(params[i]!, { structs, type: 'error' }),\n )\n }\n return { name: match.name, type: 'error', inputs: abiParameters }\n }\n\n if (isConstructorSignature(signature)) {\n const match = execConstructorSignature(signature)\n if (!match)\n throw new InvalidSignatureError({ signature, type: 'constructor' })\n\n const params = splitParameters(match.parameters)\n const abiParameters = []\n const length = params.length\n for (let i = 0; i < length; i++) {\n abiParameters.push(\n parseAbiParameter(params[i]!, { structs, type: 'constructor' }),\n )\n }\n return {\n type: 'constructor',\n stateMutability: match.stateMutability ?? 'nonpayable',\n inputs: abiParameters,\n }\n }\n\n if (isFallbackSignature(signature)) return { type: 'fallback' }\n if (isReceiveSignature(signature))\n return {\n type: 'receive',\n stateMutability: 'payable',\n }\n\n throw new UnknownSignatureError({ signature })\n}\n\nconst abiParameterWithoutTupleRegex =\n /^(?<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$_]*))?$/\nconst abiParameterWithTupleRegex =\n /^\\((?<type>.+?)\\)(?<array>(?:\\[\\d*?\\])+?)?(?:\\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/\nconst dynamicIntegerRegex = /^u?int$/\n\ntype ParseOptions = {\n modifiers?: Set<Modifier>\n structs?: StructLookup\n type?: AbiItemType | 'struct'\n}\n\nexport function parseAbiParameter(param: string, options?: ParseOptions) {\n // optional namespace cache by `type`\n const parameterCacheKey = getParameterCacheKey(param, options?.type)\n if (parameterCache.has(parameterCacheKey))\n return parameterCache.get(parameterCacheKey)!\n\n const isTuple = isTupleRegex.test(param)\n const match = execTyped<{\n array?: string\n modifier?: Modifier\n name?: string\n type: string\n }>(\n isTuple ? abiParameterWithTupleRegex : abiParameterWithoutTupleRegex,\n param,\n )\n if (!match) throw new InvalidParameterError({ param })\n\n if (match.name && isSolidityKeyword(match.name))\n throw new SolidityProtectedKeywordError({ param, name: match.name })\n\n const name = match.name ? { name: match.name } : {}\n const indexed = match.modifier === 'indexed' ? { indexed: true } : {}\n const structs = options?.structs ?? {}\n let type: string\n let components = {}\n if (isTuple) {\n type = 'tuple'\n const params = splitParameters(match.type)\n const components_ = []\n const length = params.length\n for (let i = 0; i < length; i++) {\n // remove `modifiers` from `options` to prevent from being added to tuple components\n components_.push(parseAbiParameter(params[i]!, { structs }))\n }\n components = { components: components_ }\n } else if (match.type in structs) {\n type = 'tuple'\n components = { components: structs[match.type] }\n } else if (dynamicIntegerRegex.test(match.type)) {\n type = `${match.type}256`\n } else {\n type = match.type\n if (!(options?.type === 'struct') && !isSolidityType(type))\n throw new UnknownSolidityTypeError({ type })\n }\n\n if (match.modifier) {\n // Check if modifier exists, but is not allowed (e.g. `indexed` in `functionModifiers`)\n if (!options?.modifiers?.has?.(match.modifier))\n throw new InvalidModifierError({\n param,\n type: options?.type,\n modifier: match.modifier,\n })\n\n // Check if resolved `type` is valid if there is a function modifier\n if (\n functionModifiers.has(match.modifier as FunctionModifier) &&\n !isValidDataLocation(type, !!match.array)\n )\n throw new InvalidFunctionModifierError({\n param,\n type: options?.type,\n modifier: match.modifier,\n })\n }\n\n const abiParameter = {\n type: `${type}${match.array ?? ''}`,\n ...name,\n ...indexed,\n ...components,\n }\n parameterCache.set(parameterCacheKey, abiParameter)\n return abiParameter\n}\n\n// s/o latika for this\nexport function splitParameters(\n params: string,\n result: string[] = [],\n current = '',\n depth = 0,\n): readonly string[] {\n const length = params.trim().length\n // biome-ignore lint/correctness/noUnreachable: recursive\n for (let i = 0; i < length; i++) {\n const char = params[i]\n const tail = params.slice(i + 1)\n switch (char) {\n case ',':\n return depth === 0\n ? splitParameters(tail, [...result, current.trim()])\n : splitParameters(tail, result, `${current}${char}`, depth)\n case '(':\n return splitParameters(tail, result, `${current}${char}`, depth + 1)\n case ')':\n return splitParameters(tail, result, `${current}${char}`, depth - 1)\n default:\n return splitParameters(tail, result, `${current}${char}`, depth)\n }\n }\n\n if (current === '') return result\n if (depth !== 0) throw new InvalidParenthesisError({ current, depth })\n\n result.push(current.trim())\n return result\n}\n\nexport function isSolidityType(\n type: string,\n): type is Exclude<AbiType, SolidityTuple | SolidityArray> {\n return (\n type === 'address' ||\n type === 'bool' ||\n type === 'function' ||\n type === 'string' ||\n bytesRegex.test(type) ||\n integerRegex.test(type)\n )\n}\n\nconst protectedKeywordsRegex =\n /^(?: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)$/\n\n/** @internal */\nexport function isSolidityKeyword(name: string) {\n return (\n name === 'address' ||\n name === 'bool' ||\n name === 'function' ||\n name === 'string' ||\n name === 'tuple' ||\n bytesRegex.test(name) ||\n integerRegex.test(name) ||\n protectedKeywordsRegex.test(name)\n )\n}\n\n/** @internal */\nexport function isValidDataLocation(\n type: string,\n isArray: boolean,\n): type is Exclude<\n AbiType,\n SolidityString | Extract<SolidityBytes, 'bytes'> | SolidityArray\n> {\n return isArray || type === 'bytes' || type === 'string' || type === 'tuple'\n}\n","import type { AbiParameter } from '../../abi.js'\nimport { execTyped, isTupleRegex } from '../../regex.js'\nimport { UnknownTypeError } from '../errors/abiItem.js'\nimport { InvalidAbiTypeParameterError } from '../errors/abiParameter.js'\nimport {\n InvalidSignatureError,\n InvalidStructSignatureError,\n} from '../errors/signature.js'\nimport { CircularReferenceError } from '../errors/struct.js'\nimport type { StructLookup } from '../types/structs.js'\nimport { execStructSignature, isStructSignature } from './signatures.js'\nimport { isSolidityType, parseAbiParameter } from './utils.js'\n\nexport function parseStructs(signatures: readonly string[]) {\n // Create \"shallow\" version of each struct (and filter out non-structs or invalid structs)\n const shallowStructs: StructLookup = {}\n const signaturesLength = signatures.length\n for (let i = 0; i < signaturesLength; i++) {\n const signature = signatures[i]!\n if (!isStructSignature(signature)) continue\n\n const match = execStructSignature(signature)\n if (!match) throw new InvalidSignatureError({ signature, type: 'struct' })\n\n const properties = match.properties.split(';')\n\n const components: AbiParameter[] = []\n const propertiesLength = properties.length\n for (let k = 0; k < propertiesLength; k++) {\n const property = properties[k]!\n const trimmed = property.trim()\n if (!trimmed) continue\n const abiParameter = parseAbiParameter(trimmed, {\n type: 'struct',\n })\n components.push(abiParameter)\n }\n\n if (!components.length) throw new InvalidStructSignatureError({ signature })\n shallowStructs[match.name] = components\n }\n\n // Resolve nested structs inside each parameter\n const resolvedStructs: StructLookup = {}\n const entries = Object.entries(shallowStructs)\n const entriesLength = entries.length\n for (let i = 0; i < entriesLength; i++) {\n const [name, parameters] = entries[i]!\n resolvedStructs[name] = resolveStructs(parameters, shallowStructs)\n }\n\n return resolvedStructs\n}\n\nconst typeWithoutTupleRegex =\n /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\\[\\d*?\\])+?)?$/\n\nfunction resolveStructs(\n abiParameters: readonly (AbiParameter & { indexed?: true })[],\n structs: StructLookup,\n ancestors = new Set<string>(),\n) {\n const components: AbiParameter[] = []\n const length = abiParameters.length\n for (let i = 0; i < length; i++) {\n const abiParameter = abiParameters[i]!\n const isTuple = isTupleRegex.test(abiParameter.type)\n if (isTuple) components.push(abiParameter)\n else {\n const match = execTyped<{ array?: string; type: string }>(\n typeWithoutTupleRegex,\n abiParameter.type,\n )\n if (!match?.type) throw new InvalidAbiTypeParameterError({ abiParameter })\n\n const { array, type } = match\n if (type in structs) {\n if (ancestors.has(type)) throw new CircularReferenceError({ type })\n\n components.push({\n ...abiParameter,\n type: `tuple${array ?? ''}`,\n components: resolveStructs(\n structs[type] ?? [],\n structs,\n new Set([...ancestors, type]),\n ),\n })\n } else {\n if (isSolidityType(type)) components.push(abiParameter)\n else throw new UnknownTypeError({ type })\n }\n }\n }\n\n return components\n}\n","import type { Abi } from '../abi.js'\nimport type { Error, Filter } from '../types.js'\nimport { isStructSignature } from './runtime/signatures.js'\nimport { parseStructs } from './runtime/structs.js'\nimport { parseSignature } from './runtime/utils.js'\nimport type { Signatures } from './types/signatures.js'\nimport type { ParseStructs } from './types/structs.js'\nimport type { ParseSignature } from './types/utils.js'\n\n/**\n * Parses human-readable ABI into JSON {@link Abi}\n *\n * @param signatures - Human-readable ABI\n * @returns Parsed {@link Abi}\n *\n * @example\n * type Result = ParseAbi<\n * // ^? type Result = readonly [{ name: \"balanceOf\"; type: \"function\"; stateMutability:...\n * [\n * 'function balanceOf(address owner) view returns (uint256)',\n * 'event Transfer(address indexed from, address indexed to, uint256 amount)',\n * ]\n * >\n */\nexport type ParseAbi<signatures extends readonly string[]> =\n string[] extends signatures\n ? Abi // If `T` was not able to be inferred (e.g. just `string[]`), return `Abi`\n : signatures extends readonly string[]\n ? signatures extends Signatures<signatures> // Validate signatures\n ? ParseStructs<signatures> extends infer sructs\n ? {\n [key in keyof signatures]: signatures[key] extends string\n ? ParseSignature<signatures[key], sructs>\n : never\n } extends infer mapped extends readonly unknown[]\n ? Filter<mapped, never> extends infer result\n ? result extends readonly []\n ? never\n : result\n : never\n : never\n : never\n : never\n : never\n\n/**\n * Parses human-readable ABI into JSON {@link Abi}\n *\n * @param signatures - Human-Readable ABI\n * @returns Parsed {@link Abi}\n *\n * @example\n * const abi = parseAbi([\n * // ^? const abi: readonly [{ name: \"balanceOf\"; type: \"function\"; stateMutability:...\n * 'function balanceOf(address owner) view returns (uint256)',\n * 'event Transfer(address indexed from, address indexed to, uint256 amount)',\n * ])\n */\nexport function parseAbi<const signatures extends readonly string[]>(\n signatures: signatures['length'] extends 0\n ? Error<'At least one signature required'>\n : Signatures<signatures> extends signatures\n ? signatures\n : Signatures<signatures>,\n): ParseAbi<signatures> {\n const structs = parseStructs(signatures as readonly string[])\n const abi = []\n const length = signatures.length as number\n for (let i = 0; i < length; i++) {\n const signature = (signatures as readonly string[])[i]!\n if (isStructSignature(signature)) continue\n abi.push(parseSignature(signature, structs))\n }\n return abi as unknown as ParseAbi<signatures>\n}\n","import type { Abi } from '../abi.js'\nimport type { Narrow } from '../narrow.js'\nimport type { Error, Filter } from '../types.js'\nimport { InvalidAbiItemError } from './errors/abiItem.js'\nimport { isStructSignature } from './runtime/signatures.js'\nimport { parseStructs } from './runtime/structs.js'\nimport { parseSignature } from './runtime/utils.js'\nimport type { Signature, Signatures } from './types/signatures.js'\nimport type { ParseStructs } from './types/structs.js'\nimport type { ParseSignature } from './types/utils.js'\n\n/**\n * Parses human-readable ABI item (e.g. error, event, function) into {@link Abi} item\n *\n * @param signature - Human-readable ABI item\n * @returns Parsed {@link Abi} item\n *\n * @example\n * type Result = ParseAbiItem<'function balanceOf(address owner) view returns (uint256)'>\n * // ^? type Result = { name: \"balanceOf\"; type: \"function\"; stateMutability: \"view\";...\n *\n * @example\n * type Result = ParseAbiItem<\n * // ^? type Result = { name: \"foo\"; type: \"function\"; stateMutability: \"view\"; inputs:...\n * ['function foo(Baz bar) view returns (string)', 'struct Baz { string name; }']\n * >\n */\nexport type ParseAbiItem<\n signature extends string | readonly string[] | readonly unknown[],\n> =\n | (signature extends string\n ? string extends signature\n ? Abi[number]\n : signature extends Signature<signature> // Validate signature\n ? ParseSignature<signature>\n : never\n : never)\n | (signature extends readonly string[]\n ? string[] extends signature\n ? Abi[number] // Return generic Abi item since type was no inferrable\n : signature extends Signatures<signature> // Validate signature\n ? ParseStructs<signature> extends infer structs\n ? {\n [key in keyof signature]: ParseSignature<\n signature[key] extends string ? signature[key] : never,\n structs\n >\n } extends infer mapped extends readonly unknown[]\n ? // Filter out `never` since those are structs\n Filter<mapped, never>[0] extends infer result\n ? result extends undefined // convert `undefined` to `never` (e.g. `ParseAbiItem<['struct Foo { string name; }']>`)\n ? never\n : result\n : never\n : never\n : never\n : never\n : never)\n\n/**\n * Parses human-readable ABI item (e.g. error, event, function) into {@link Abi} item\n *\n * @param signature - Human-readable ABI item\n * @returns Parsed {@link Abi} item\n *\n * @example\n * const abiItem = parseAbiItem('function balanceOf(address owner) view returns (uint256)')\n * // ^? const abiItem: { name: \"balanceOf\"; type: \"function\"; stateMutability: \"view\";...\n *\n * @example\n * const abiItem = parseAbiItem([\n * // ^? const abiItem: { name: \"foo\"; type: \"function\"; stateMutability: \"view\"; inputs:...\n * 'function foo(Baz bar) view returns (string)',\n * 'struct Baz { string name; }',\n * ])\n */\nexport function parseAbiItem<\n signature extends string | readonly string[] | readonly unknown[],\n>(\n signature: Narrow<signature> &\n (\n | (signature extends string\n ? string extends signature\n ? unknown\n : Signature<signature>\n : never)\n | (signature extends readonly string[]\n ? signature extends readonly [] // empty array\n ? Error<'At least one signature required.'>\n : string[] extends signature\n ? unknown\n : Signatures<signature>\n : never)\n ),\n): ParseAbiItem<signature> {\n let abiItem: ParseAbiItem<signature> | undefined\n if (typeof signature === 'string')\n abiItem = parseSignature(signature) as ParseAbiItem<signature>\n else {\n const structs = parseStructs(signature as readonly string[])\n const length = signature.length as number\n for (let i = 0; i < length; i++) {\n const signature_ = (signature as readonly string[])[i]!\n if (isStructSignature(signature_)) continue\n abiItem = parseSignature(signature_, structs) as ParseAbiItem<signature>\n break\n }\n }\n\n if (!abiItem) throw new InvalidAbiItemError({ signature })\n return abiItem as ParseAbiItem<signature>\n}\n","import type { AbiParameter } from '../abi.js'\nimport type { Narrow } from '../narrow.js'\nimport type { Error, Filter } from '../types.js'\nimport { InvalidAbiParametersError } from './errors/abiParameter.js'\nimport { isStructSignature, modifiers } from './runtime/signatures.js'\nimport { parseStructs } from './runtime/structs.js'\nimport { splitParameters } from './runtime/utils.js'\nimport { parseAbiParameter as parseAbiParameter_ } from './runtime/utils.js'\nimport type { IsStructSignature, Modifier } from './types/signatures.js'\nimport type { ParseStructs } from './types/structs.js'\nimport type { SplitParameters } from './types/utils.js'\nimport type { ParseAbiParameters as ParseAbiParameters_ } from './types/utils.js'\n\n/**\n * Parses human-readable ABI parameters into {@link AbiParameter}s\n *\n * @param params - Human-readable ABI parameters\n * @returns Parsed {@link AbiParameter}s\n *\n * @example\n * type Result = ParseAbiParameters('address from, address to, uint256 amount')\n * // ^? type Result: [{ type: \"address\"; name: \"from\"; }, { type: \"address\";...\n *\n * @example\n * type Result = ParseAbiParameters<\n * //