UNPKG

@etherspot/remote-signer

Version:

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

1 lines 680 kB
{"version":3,"sources":["../../node_modules/viem/utils/chain/defineChain.ts","../../node_modules/viem/errors/transport.ts","../../node_modules/viem/utils/promise/withTimeout.ts","../../node_modules/viem/utils/rpc/id.ts","../../node_modules/viem/utils/rpc/http.ts","../../node_modules/viem/utils/promise/withDedupe.ts","../../node_modules/viem/utils/wait.ts","../../node_modules/viem/utils/promise/withRetry.ts","../../node_modules/viem/utils/buildRequest.ts","../../node_modules/viem/utils/uid.ts","../../node_modules/viem/clients/transports/createTransport.ts","../../node_modules/viem/clients/transports/http.ts","../../node_modules/viem/utils/chain/extractChain.ts","../../node_modules/viem/utils/regex.ts","../../node_modules/viem/utils/abi/encodePacked.ts","../../node_modules/viem/utils/data/isBytes.ts","../../node_modules/viem/utils/signature/serializeSignature.ts","../../node_modules/viem/clients/createClient.ts","../../node_modules/viem/utils/ens/errors.ts","../../node_modules/viem/utils/ens/encodedLabelToLabelhash.ts","../../node_modules/viem/utils/ens/namehash.ts","../../node_modules/viem/utils/ens/encodeLabelhash.ts","../../node_modules/viem/utils/ens/labelhash.ts","../../node_modules/viem/utils/ens/packetToBytes.ts","../../node_modules/viem/utils/getAction.ts","../../node_modules/viem/utils/errors/getContractError.ts","../../node_modules/viem/actions/public/readContract.ts","../../node_modules/viem/actions/ens/getEnsAddress.ts","../../node_modules/viem/errors/ens.ts","../../node_modules/viem/utils/ens/avatar/utils.ts","../../node_modules/viem/utils/ens/avatar/parseAvatarRecord.ts","../../node_modules/viem/actions/ens/getEnsText.ts","../../node_modules/viem/actions/ens/getEnsAvatar.ts","../../node_modules/viem/actions/ens/getEnsName.ts","../../node_modules/viem/actions/ens/getEnsResolver.ts","../../node_modules/viem/utils/filters/createFilterRequestScope.ts","../../node_modules/viem/actions/public/createBlockFilter.ts","../../node_modules/viem/errors/log.ts","../../node_modules/viem/utils/abi/encodeEventTopics.ts","../../node_modules/viem/actions/public/createContractEventFilter.ts","../../node_modules/viem/actions/public/createEventFilter.ts","../../node_modules/viem/actions/public/createPendingTransactionFilter.ts","../../node_modules/viem/errors/estimateGas.ts","../../node_modules/viem/utils/errors/getEstimateGasError.ts","../../node_modules/viem/errors/fee.ts","../../node_modules/viem/errors/block.ts","../../node_modules/viem/utils/formatters/transaction.ts","../../node_modules/viem/utils/formatters/block.ts","../../node_modules/viem/actions/public/getBlock.ts","../../node_modules/viem/actions/public/getGasPrice.ts","../../node_modules/viem/actions/public/estimateMaxPriorityFeePerGas.ts","../../node_modules/viem/actions/public/estimateFeesPerGas.ts","../../node_modules/viem/actions/public/getTransactionCount.ts","../../node_modules/viem/utils/blob/blobsToCommitments.ts","../../node_modules/viem/utils/blob/blobsToProofs.ts","../../node_modules/viem/utils/hash/sha256.ts","../../node_modules/viem/utils/blob/commitmentToVersionedHash.ts","../../node_modules/viem/utils/blob/commitmentsToVersionedHashes.ts","../../node_modules/viem/constants/blob.ts","../../node_modules/viem/constants/kzg.ts","../../node_modules/viem/errors/blob.ts","../../node_modules/viem/utils/blob/toBlobs.ts","../../node_modules/viem/utils/blob/toBlobSidecars.ts","../../node_modules/viem/utils/transaction/getTransactionType.ts","../../node_modules/viem/actions/public/getChainId.ts","../../node_modules/viem/actions/wallet/prepareTransactionRequest.ts","../../node_modules/viem/actions/public/estimateGas.ts","../../node_modules/viem/actions/public/estimateContractGas.ts","../../node_modules/viem/actions/public/getBalance.ts","../../node_modules/viem/actions/public/getBlobBaseFee.ts","../../node_modules/viem/utils/promise/withCache.ts","../../node_modules/viem/actions/public/getBlockNumber.ts","../../node_modules/viem/actions/public/getBlockTransactionCount.ts","../../node_modules/viem/actions/public/getCode.ts","../../node_modules/viem/utils/abi/decodeEventLog.ts","../../node_modules/viem/utils/abi/parseEventLogs.ts","../../node_modules/viem/utils/formatters/log.ts","../../node_modules/viem/actions/public/getLogs.ts","../../node_modules/viem/actions/public/getContractEvents.ts","../../node_modules/viem/errors/eip712.ts","../../node_modules/viem/actions/public/getEip712Domain.ts","../../node_modules/viem/utils/formatters/feeHistory.ts","../../node_modules/viem/actions/public/getFeeHistory.ts","../../node_modules/viem/actions/public/getFilterChanges.ts","../../node_modules/viem/actions/public/getFilterLogs.ts","../../node_modules/viem/utils/chain/assertCurrentChain.ts","../../node_modules/viem/utils/signature/hashTypedData.ts","../../node_modules/viem/utils/typedData.ts","../../node_modules/viem/accounts/utils/publicKeyToAddress.ts","../../node_modules/viem/utils/encoding/toRlp.ts","../../node_modules/viem/utils/formatters/transactionReceipt.ts","../../node_modules/viem/utils/errors/getTransactionError.ts","../../node_modules/viem/constants/strings.ts","../../node_modules/viem/utils/signature/toPrefixedMessage.ts","../../node_modules/viem/utils/signature/hashMessage.ts","../../node_modules/viem/constants/bytes.ts","../../node_modules/viem/utils/signature/isErc6492Signature.ts","../../node_modules/viem/utils/signature/serializeErc6492Signature.ts","../../node_modules/viem/utils/transaction/assertTransaction.ts","../../node_modules/viem/utils/transaction/serializeAccessList.ts","../../node_modules/viem/utils/transaction/serializeTransaction.ts","../../node_modules/viem/utils/formatters/proof.ts","../../node_modules/viem/actions/public/getProof.ts","../../node_modules/viem/actions/public/getStorageAt.ts","../../node_modules/viem/actions/public/getTransaction.ts","../../node_modules/viem/actions/public/getTransactionConfirmations.ts","../../node_modules/viem/actions/public/getTransactionReceipt.ts","../../node_modules/viem/actions/public/multicall.ts","../../node_modules/viem/actions/public/simulateContract.ts","../../node_modules/viem/actions/public/uninstallFilter.ts","../../node_modules/viem/utils/data/isBytesEqual.ts","../../node_modules/viem/actions/public/verifyHash.ts","../../node_modules/viem/actions/public/verifyMessage.ts","../../node_modules/viem/actions/public/verifyTypedData.ts","../../node_modules/viem/utils/observe.ts","../../node_modules/viem/utils/poll.ts","../../node_modules/viem/actions/public/watchBlockNumber.ts","../../node_modules/viem/actions/public/waitForTransactionReceipt.ts","../../node_modules/viem/actions/public/watchBlocks.ts","../../node_modules/viem/actions/public/watchContractEvent.ts","../../node_modules/viem/actions/public/watchEvent.ts","../../node_modules/viem/actions/public/watchPendingTransactions.ts","../../node_modules/viem/utils/siwe/parseSiweMessage.ts","../../node_modules/viem/utils/siwe/validateSiweMessage.ts","../../node_modules/viem/actions/siwe/verifySiweMessage.ts","../../node_modules/viem/actions/wallet/sendRawTransaction.ts","../../node_modules/viem/clients/decorators/public.ts","../../node_modules/viem/clients/createPublicClient.ts","../../node_modules/viem/actions/wallet/addChain.ts","../../node_modules/viem/errors/account.ts","../../node_modules/viem/actions/wallet/sendTransaction.ts","../../node_modules/viem/actions/wallet/deployContract.ts","../../node_modules/viem/actions/wallet/getAddresses.ts","../../node_modules/viem/actions/wallet/getPermissions.ts","../../node_modules/viem/actions/wallet/requestAddresses.ts","../../node_modules/viem/actions/wallet/requestPermissions.ts","../../node_modules/viem/actions/wallet/signMessage.ts","../../node_modules/viem/actions/wallet/signTransaction.ts","../../node_modules/viem/actions/wallet/signTypedData.ts","../../node_modules/viem/actions/wallet/switchChain.ts","../../node_modules/viem/actions/wallet/watchAsset.ts","../../node_modules/viem/actions/wallet/writeContract.ts","../../node_modules/viem/clients/decorators/wallet.ts","../../node_modules/viem/clients/createWalletClient.ts","../../node_modules/viem/utils/signature/parseSignature.ts","../../node_modules/viem/constants/number.ts"],"sourcesContent":["import type { Chain, ChainFormatters } from '../../types/chain.js'\nimport type { Assign, Prettify } from '../../types/utils.js'\n\nexport function defineChain<\n formatters extends ChainFormatters,\n const chain extends Chain<formatters>,\n>(chain: chain): Prettify<Assign<Chain<undefined>, chain>> {\n return {\n formatters: undefined,\n fees: undefined,\n serializers: undefined,\n ...chain,\n } as Assign<Chain<undefined>, chain>\n}\n","import { BaseError } from './base.js'\n\nexport type UrlRequiredErrorType = UrlRequiredError & {\n name: 'UrlRequiredError'\n}\nexport class UrlRequiredError extends BaseError {\n constructor() {\n super(\n 'No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.',\n {\n docsPath: '/docs/clients/intro',\n },\n )\n }\n}\n","import type { ErrorType } from '../../errors/utils.js'\n\nexport type WithTimeoutErrorType = ErrorType\n\nexport function withTimeout<TData>(\n fn: ({\n signal,\n }: { signal: AbortController['signal'] | null }) => Promise<TData>,\n {\n errorInstance = new Error('timed out'),\n timeout,\n signal,\n }: {\n // The error instance to throw when the timeout is reached.\n errorInstance?: Error | undefined\n // The timeout (in ms).\n timeout: number\n // Whether or not the timeout should use an abort signal.\n signal?: boolean | undefined\n },\n): Promise<TData> {\n return new Promise((resolve, reject) => {\n ;(async () => {\n let timeoutId!: NodeJS.Timeout\n try {\n const controller = new AbortController()\n if (timeout > 0) {\n timeoutId = setTimeout(() => {\n if (signal) {\n controller.abort()\n } else {\n reject(errorInstance)\n }\n }, timeout) as NodeJS.Timeout // need to cast because bun globals.d.ts overrides @types/node\n }\n resolve(await fn({ signal: controller?.signal || null }))\n } catch (err) {\n if ((err as Error)?.name === 'AbortError') reject(errorInstance)\n reject(err)\n } finally {\n clearTimeout(timeoutId)\n }\n })()\n })\n}\n","function createIdStore() {\n return {\n current: 0,\n take() {\n return this.current++\n },\n reset() {\n this.current = 0\n },\n }\n}\n\nexport const idCache = /*#__PURE__*/ createIdStore()\n","import {\n HttpRequestError,\n type HttpRequestErrorType as HttpRequestErrorType_,\n TimeoutError,\n type TimeoutErrorType,\n} from '../../errors/request.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcRequest, RpcResponse } from '../../types/rpc.js'\nimport {\n type WithTimeoutErrorType,\n withTimeout,\n} from '../promise/withTimeout.js'\nimport { stringify } from '../stringify.js'\nimport { idCache } from './id.js'\n\nexport type HttpRpcClientOptions = {\n /** Request configuration to pass to `fetch`. */\n fetchOptions?: Omit<RequestInit, 'body'> | undefined\n /** A callback to handle the request. */\n onRequest?: ((request: Request) => Promise<void> | void) | undefined\n /** A callback to handle the response. */\n onResponse?: ((response: Response) => Promise<void> | void) | undefined\n /** The timeout (in ms) for the request. */\n timeout?: number | undefined\n}\n\nexport type HttpRequestParameters<\n TBody extends RpcRequest | RpcRequest[] = RpcRequest,\n> = {\n /** The RPC request body. */\n body: TBody\n /** Request configuration to pass to `fetch`. */\n fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined\n /** A callback to handle the response. */\n onRequest?: ((request: Request) => Promise<void> | void) | undefined\n /** A callback to handle the response. */\n onResponse?: ((response: Response) => Promise<void> | void) | undefined\n /** The timeout (in ms) for the request. */\n timeout?: HttpRpcClientOptions['timeout'] | undefined\n}\n\nexport type HttpRequestReturnType<\n TBody extends RpcRequest | RpcRequest[] = RpcRequest,\n> = TBody extends RpcRequest[] ? RpcResponse[] : RpcResponse\n\nexport type HttpRequestErrorType =\n | HttpRequestErrorType_\n | TimeoutErrorType\n | WithTimeoutErrorType\n | ErrorType\n\nexport type HttpRpcClient = {\n request<TBody extends RpcRequest | RpcRequest[]>(\n params: HttpRequestParameters<TBody>,\n ): Promise<HttpRequestReturnType<TBody>>\n}\n\nexport function getHttpRpcClient(\n url: string,\n options: HttpRpcClientOptions = {},\n): HttpRpcClient {\n return {\n async request(params) {\n const {\n body,\n onRequest = options.onRequest,\n onResponse = options.onResponse,\n timeout = options.timeout ?? 10_000,\n } = params\n\n const fetchOptions = {\n ...(options.fetchOptions ?? {}),\n ...(params.fetchOptions ?? {}),\n }\n\n const { headers, method, signal: signal_ } = fetchOptions\n\n try {\n const response = await withTimeout(\n async ({ signal }) => {\n const init: RequestInit = {\n ...fetchOptions,\n body: Array.isArray(body)\n ? stringify(\n body.map((body) => ({\n jsonrpc: '2.0',\n id: body.id ?? idCache.take(),\n ...body,\n })),\n )\n : stringify({\n jsonrpc: '2.0',\n id: body.id ?? idCache.take(),\n ...body,\n }),\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n method: method || 'POST',\n signal: signal_ || (timeout > 0 ? signal : null),\n }\n const request = new Request(url, init)\n if (onRequest) await onRequest(request)\n const response = await fetch(url, init)\n return response\n },\n {\n errorInstance: new TimeoutError({ body, url }),\n timeout,\n signal: true,\n },\n )\n\n if (onResponse) await onResponse(response)\n\n let data: any\n if (\n response.headers.get('Content-Type')?.startsWith('application/json')\n )\n data = await response.json()\n else {\n data = await response.text()\n data = JSON.parse(data || '{}')\n }\n\n if (!response.ok) {\n throw new HttpRequestError({\n body,\n details: stringify(data.error) || response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n })\n }\n\n return data\n } catch (err) {\n if (err instanceof HttpRequestError) throw err\n if (err instanceof TimeoutError) throw err\n throw new HttpRequestError({\n body,\n details: (err as Error).message,\n url,\n })\n }\n },\n }\n}\n","import { LruMap } from '../lru.js'\n\n/** @internal */\nexport const promiseCache = /*#__PURE__*/ new LruMap<Promise<any>>(8192)\n\ntype WithDedupeOptions = {\n enabled?: boolean | undefined\n id?: string | undefined\n}\n\n/** Deduplicates in-flight promises. */\nexport function withDedupe<data>(\n fn: () => Promise<data>,\n { enabled = true, id }: WithDedupeOptions,\n): Promise<data> {\n if (!enabled || !id) return fn()\n if (promiseCache.get(id)) return promiseCache.get(id)!\n const promise = fn().finally(() => promiseCache.delete(id))\n promiseCache.set(id, promise)\n return promise\n}\n","export async function wait(time: number) {\n return new Promise((res) => setTimeout(res, time))\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport { wait } from '../wait.js'\n\nexport type WithRetryParameters = {\n // The delay (in ms) between retries.\n delay?:\n | ((config: { count: number; error: Error }) => number)\n | number\n | undefined\n // The max number of times to retry.\n retryCount?: number | undefined\n // Whether or not to retry when an error is thrown.\n shouldRetry?:\n | (({\n count,\n error,\n }: {\n count: number\n error: Error\n }) => Promise<boolean> | boolean)\n | undefined\n}\n\nexport type WithRetryErrorType = ErrorType\n\nexport function withRetry<TData>(\n fn: () => Promise<TData>,\n {\n delay: delay_ = 100,\n retryCount = 2,\n shouldRetry = () => true,\n }: WithRetryParameters = {},\n) {\n return new Promise<TData>((resolve, reject) => {\n const attemptRetry = async ({ count = 0 } = {}) => {\n const retry = async ({ error }: { error: Error }) => {\n const delay =\n typeof delay_ === 'function' ? delay_({ count, error }) : delay_\n if (delay) await wait(delay)\n attemptRetry({ count: count + 1 })\n }\n\n try {\n const data = await fn()\n resolve(data)\n } catch (err) {\n if (\n count < retryCount &&\n (await shouldRetry({ count, error: err as Error }))\n )\n return retry({ error: err as Error })\n reject(err)\n }\n }\n attemptRetry()\n })\n}\n","import { BaseError } from '../errors/base.js'\nimport {\n HttpRequestError,\n type HttpRequestErrorType,\n type RpcRequestErrorType,\n type TimeoutErrorType,\n type WebSocketRequestErrorType,\n} from '../errors/request.js'\nimport {\n ChainDisconnectedError,\n type ChainDisconnectedErrorType,\n InternalRpcError,\n type InternalRpcErrorType,\n InvalidInputRpcError,\n type InvalidInputRpcErrorType,\n InvalidParamsRpcError,\n type InvalidParamsRpcErrorType,\n InvalidRequestRpcError,\n type InvalidRequestRpcErrorType,\n JsonRpcVersionUnsupportedError,\n type JsonRpcVersionUnsupportedErrorType,\n LimitExceededRpcError,\n type LimitExceededRpcErrorType,\n MethodNotFoundRpcError,\n type MethodNotFoundRpcErrorType,\n MethodNotSupportedRpcError,\n type MethodNotSupportedRpcErrorType,\n ParseRpcError,\n type ParseRpcErrorType,\n ProviderDisconnectedError,\n type ProviderDisconnectedErrorType,\n type ProviderRpcErrorCode,\n ResourceNotFoundRpcError,\n type ResourceNotFoundRpcErrorType,\n ResourceUnavailableRpcError,\n type ResourceUnavailableRpcErrorType,\n type RpcError,\n type RpcErrorCode,\n type RpcErrorType,\n SwitchChainError,\n type SwitchChainErrorType,\n TransactionRejectedRpcError,\n type TransactionRejectedRpcErrorType,\n UnauthorizedProviderError,\n type UnauthorizedProviderErrorType,\n UnknownRpcError,\n type UnknownRpcErrorType,\n UnsupportedProviderMethodError,\n type UnsupportedProviderMethodErrorType,\n UserRejectedRequestError,\n type UserRejectedRequestErrorType,\n} from '../errors/rpc.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type {\n EIP1193RequestFn,\n EIP1193RequestOptions,\n} from '../types/eip1193.js'\nimport { stringToHex } from './encoding/toHex.js'\nimport { keccak256 } from './hash/keccak256.js'\nimport type { CreateBatchSchedulerErrorType } from './promise/createBatchScheduler.js'\nimport { withDedupe } from './promise/withDedupe.js'\nimport { type WithRetryErrorType, withRetry } from './promise/withRetry.js'\nimport type { GetSocketRpcClientErrorType } from './rpc/socket.js'\nimport { stringify } from './stringify.js'\n\nexport type RequestErrorType =\n | ChainDisconnectedErrorType\n | CreateBatchSchedulerErrorType\n | HttpRequestErrorType\n | InternalRpcErrorType\n | InvalidInputRpcErrorType\n | InvalidParamsRpcErrorType\n | InvalidRequestRpcErrorType\n | GetSocketRpcClientErrorType\n | JsonRpcVersionUnsupportedErrorType\n | LimitExceededRpcErrorType\n | MethodNotFoundRpcErrorType\n | MethodNotSupportedRpcErrorType\n | ParseRpcErrorType\n | ProviderDisconnectedErrorType\n | ResourceNotFoundRpcErrorType\n | ResourceUnavailableRpcErrorType\n | RpcErrorType\n | RpcRequestErrorType\n | SwitchChainErrorType\n | TimeoutErrorType\n | TransactionRejectedRpcErrorType\n | UnauthorizedProviderErrorType\n | UnknownRpcErrorType\n | UnsupportedProviderMethodErrorType\n | UserRejectedRequestErrorType\n | WebSocketRequestErrorType\n | WithRetryErrorType\n | ErrorType\n\nexport function buildRequest<request extends (args: any) => Promise<any>>(\n request: request,\n options: EIP1193RequestOptions = {},\n): EIP1193RequestFn {\n return async (args, overrideOptions = {}) => {\n const {\n dedupe = false,\n retryDelay = 150,\n retryCount = 3,\n uid,\n } = {\n ...options,\n ...overrideOptions,\n }\n const requestId = dedupe\n ? keccak256(stringToHex(`${uid}.${stringify(args)}`))\n : undefined\n return withDedupe(\n () =>\n withRetry(\n async () => {\n try {\n return await request(args)\n } catch (err_) {\n const err = err_ as unknown as RpcError<\n RpcErrorCode | ProviderRpcErrorCode\n >\n switch (err.code) {\n // -32700\n case ParseRpcError.code:\n throw new ParseRpcError(err)\n // -32600\n case InvalidRequestRpcError.code:\n throw new InvalidRequestRpcError(err)\n // -32601\n case MethodNotFoundRpcError.code:\n throw new MethodNotFoundRpcError(err)\n // -32602\n case InvalidParamsRpcError.code:\n throw new InvalidParamsRpcError(err)\n // -32603\n case InternalRpcError.code:\n throw new InternalRpcError(err)\n // -32000\n case InvalidInputRpcError.code:\n throw new InvalidInputRpcError(err)\n // -32001\n case ResourceNotFoundRpcError.code:\n throw new ResourceNotFoundRpcError(err)\n // -32002\n case ResourceUnavailableRpcError.code:\n throw new ResourceUnavailableRpcError(err)\n // -32003\n case TransactionRejectedRpcError.code:\n throw new TransactionRejectedRpcError(err)\n // -32004\n case MethodNotSupportedRpcError.code:\n throw new MethodNotSupportedRpcError(err)\n // -32005\n case LimitExceededRpcError.code:\n throw new LimitExceededRpcError(err)\n // -32006\n case JsonRpcVersionUnsupportedError.code:\n throw new JsonRpcVersionUnsupportedError(err)\n // 4001\n case UserRejectedRequestError.code:\n throw new UserRejectedRequestError(err)\n // 4100\n case UnauthorizedProviderError.code:\n throw new UnauthorizedProviderError(err)\n // 4200\n case UnsupportedProviderMethodError.code:\n throw new UnsupportedProviderMethodError(err)\n // 4900\n case ProviderDisconnectedError.code:\n throw new ProviderDisconnectedError(err)\n // 4901\n case ChainDisconnectedError.code:\n throw new ChainDisconnectedError(err)\n // 4902\n case SwitchChainError.code:\n throw new SwitchChainError(err)\n // CAIP-25: User Rejected Error\n // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25\n case 5000:\n throw new UserRejectedRequestError(err)\n default:\n if (err_ instanceof BaseError) throw err_\n throw new UnknownRpcError(err as Error)\n }\n }\n },\n {\n delay: ({ count, error }) => {\n // If we find a Retry-After header, let's retry after the given time.\n if (error && error instanceof HttpRequestError) {\n const retryAfter = error?.headers?.get('Retry-After')\n if (retryAfter?.match(/\\d/))\n return Number.parseInt(retryAfter) * 1000\n }\n\n // Otherwise, let's retry with an exponential backoff.\n return ~~(1 << count) * retryDelay\n },\n retryCount,\n shouldRetry: ({ error }) => shouldRetry(error),\n },\n ),\n { enabled: dedupe, id: requestId },\n )\n }\n}\n\n/** @internal */\nexport function shouldRetry(error: Error) {\n if ('code' in error && typeof error.code === 'number') {\n if (error.code === -1) return true // Unknown error\n if (error.code === LimitExceededRpcError.code) return true\n if (error.code === InternalRpcError.code) return true\n return false\n }\n if (error instanceof HttpRequestError && error.status) {\n // Forbidden\n if (error.status === 403) return true\n // Request Timeout\n if (error.status === 408) return true\n // Request Entity Too Large\n if (error.status === 413) return true\n // Too Many Requests\n if (error.status === 429) return true\n // Internal Server Error\n if (error.status === 500) return true\n // Bad Gateway\n if (error.status === 502) return true\n // Service Unavailable\n if (error.status === 503) return true\n // Gateway Timeout\n if (error.status === 504) return true\n return false\n }\n return true\n}\n","const size = 256\nlet index = size\nlet buffer: string\n\nexport function uid(length = 11) {\n if (!buffer || index + length > size * 2) {\n buffer = ''\n index = 0\n for (let i = 0; i < size; i++) {\n buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)\n }\n }\n return buffer.substring(index, index++ + length)\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { EIP1193RequestFn } from '../../types/eip1193.js'\nimport { buildRequest } from '../../utils/buildRequest.js'\nimport { uid as uid_ } from '../../utils/uid.js'\nimport type { ClientConfig } from '../createClient.js'\n\nexport type TransportConfig<\n TType extends string = string,\n TEIP1193RequestFn extends EIP1193RequestFn = EIP1193RequestFn,\n> = {\n /** The name of the transport. */\n name: string\n /** The key of the transport. */\n key: string\n /** The JSON-RPC request function that matches the EIP-1193 request spec. */\n request: TEIP1193RequestFn\n /** The base delay (in ms) between retries. */\n retryDelay?: number | undefined\n /** The max number of times to retry. */\n retryCount?: number | undefined\n /** The timeout (in ms) for requests. */\n timeout?: number | undefined\n /** The type of the transport. */\n type: TType\n}\n\nexport type Transport<\n TType extends string = string,\n TRpcAttributes = Record<string, any>,\n TEIP1193RequestFn extends EIP1193RequestFn = EIP1193RequestFn,\n> = <TChain extends Chain | undefined = Chain>({\n chain,\n}: {\n chain?: TChain | undefined\n pollingInterval?: ClientConfig['pollingInterval'] | undefined\n retryCount?: TransportConfig['retryCount'] | undefined\n timeout?: TransportConfig['timeout'] | undefined\n}) => {\n config: TransportConfig<TType>\n request: TEIP1193RequestFn\n value?: TRpcAttributes | undefined\n}\n\nexport type CreateTransportErrorType = ErrorType\n\n/**\n * @description Creates an transport intended to be used with a client.\n */\nexport function createTransport<\n TType extends string,\n TRpcAttributes extends Record<string, any>,\n>(\n {\n key,\n name,\n request,\n retryCount = 3,\n retryDelay = 150,\n timeout,\n type,\n }: TransportConfig<TType>,\n value?: TRpcAttributes | undefined,\n): ReturnType<Transport<TType, TRpcAttributes>> {\n const uid = uid_()\n return {\n config: {\n key,\n name,\n request,\n retryCount,\n retryDelay,\n timeout,\n type,\n },\n request: buildRequest(request, { retryCount, retryDelay, uid }),\n value,\n }\n}\n","import { RpcRequestError } from '../../errors/request.js'\nimport {\n UrlRequiredError,\n type UrlRequiredErrorType,\n} from '../../errors/transport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcRequest } from '../../types/rpc.js'\nimport { createBatchScheduler } from '../../utils/promise/createBatchScheduler.js'\nimport {\n type HttpRpcClientOptions,\n getHttpRpcClient,\n} from '../../utils/rpc/http.js'\n\nimport {\n type CreateTransportErrorType,\n type Transport,\n type TransportConfig,\n createTransport,\n} from './createTransport.js'\n\nexport type HttpTransportConfig = {\n /**\n * Whether to enable Batch JSON-RPC.\n * @link https://www.jsonrpc.org/specification#batch\n */\n batch?:\n | boolean\n | {\n /** The maximum number of JSON-RPC requests to send in a batch. @default 1_000 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n }\n | undefined\n /**\n * Request configuration to pass to `fetch`.\n * @link https://developer.mozilla.org/en-US/docs/Web/API/fetch\n */\n fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined\n /** A callback to handle the response from `fetch`. */\n onFetchRequest?: HttpRpcClientOptions['onRequest'] | undefined\n /** A callback to handle the response from `fetch`. */\n onFetchResponse?: HttpRpcClientOptions['onResponse'] | undefined\n /** The key of the HTTP transport. */\n key?: TransportConfig['key'] | undefined\n /** The name of the HTTP transport. */\n name?: TransportConfig['name'] | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n /** The timeout (in ms) for the HTTP request. Default: 10_000 */\n timeout?: TransportConfig['timeout'] | undefined\n}\n\nexport type HttpTransport = Transport<\n 'http',\n {\n fetchOptions?: HttpTransportConfig['fetchOptions'] | undefined\n url?: string | undefined\n }\n>\n\nexport type HttpTransportErrorType =\n | CreateTransportErrorType\n | UrlRequiredErrorType\n | ErrorType\n\n/**\n * @description Creates a HTTP transport that connects to a JSON-RPC API.\n */\nexport function http(\n /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */\n url?: string | undefined,\n config: HttpTransportConfig = {},\n): HttpTransport {\n const {\n batch,\n fetchOptions,\n key = 'http',\n name = 'HTTP JSON-RPC',\n onFetchRequest,\n onFetchResponse,\n retryDelay,\n } = config\n return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {\n const { batchSize = 1000, wait = 0 } =\n typeof batch === 'object' ? batch : {}\n const retryCount = config.retryCount ?? retryCount_\n const timeout = timeout_ ?? config.timeout ?? 10_000\n const url_ = url || chain?.rpcUrls.default.http[0]\n if (!url_) throw new UrlRequiredError()\n\n const rpcClient = getHttpRpcClient(url_, {\n fetchOptions,\n onRequest: onFetchRequest,\n onResponse: onFetchResponse,\n timeout,\n })\n\n return createTransport(\n {\n key,\n name,\n async request({ method, params }) {\n const body = { method, params }\n\n const { schedule } = createBatchScheduler({\n id: url_,\n wait,\n shouldSplitBatch(requests) {\n return requests.length > batchSize\n },\n fn: (body: RpcRequest[]) =>\n rpcClient.request({\n body,\n }),\n sort: (a, b) => a.id - b.id,\n })\n\n const fn = async (body: RpcRequest) =>\n batch\n ? schedule(body)\n : [\n await rpcClient.request({\n body,\n }),\n ]\n\n const [{ error, result }] = await fn(body)\n if (error)\n throw new RpcRequestError({\n body,\n error,\n url: url_,\n })\n return result\n },\n retryCount,\n retryDelay,\n timeout,\n type: 'http',\n },\n {\n fetchOptions,\n url: url_,\n },\n )\n }\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\n\nexport type ExtractChainParameters<\n chains extends readonly Chain[],\n chainId extends chains[number]['id'],\n> = {\n chains: chains\n id: chainId | chains[number]['id']\n}\n\nexport type ExtractChainReturnType<\n chains extends readonly Chain[],\n chainId extends chains[number]['id'],\n> = Extract<chains[number], { id: chainId }>\n\nexport type ExtractChainErrorType = ErrorType\n\nexport function extractChain<\n const chains extends readonly Chain[],\n chainId extends chains[number]['id'],\n>({\n chains,\n id,\n}: ExtractChainParameters<chains, chainId>): ExtractChainReturnType<\n chains,\n chainId\n> {\n return chains.find((chain) => chain.id === id) as ExtractChainReturnType<\n chains,\n chainId\n >\n}\n","export const arrayRegex = /^(.*)\\[([0-9]*)\\]$/\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","import type {\n AbiParameterToPrimitiveType,\n AbiType,\n Address,\n SolidityAddress,\n SolidityArrayWithoutTuple,\n SolidityBool,\n SolidityBytes,\n SolidityInt,\n SolidityString,\n} from 'abitype'\n\nimport {\n AbiEncodingLengthMismatchError,\n type AbiEncodingLengthMismatchErrorType,\n BytesSizeMismatchError,\n type BytesSizeMismatchErrorType,\n UnsupportedPackedAbiType,\n} from '../../errors/abi.js'\nimport {\n InvalidAddressError,\n type InvalidAddressErrorType,\n} from '../../errors/address.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport { type IsAddressErrorType, isAddress } from '../address/isAddress.js'\nimport { type ConcatHexErrorType, concatHex } from '../data/concat.js'\nimport { type PadErrorType, pad } from '../data/pad.js'\nimport {\n type BoolToHexErrorType,\n type NumberToHexErrorType,\n type StringToHexErrorType,\n boolToHex,\n numberToHex,\n stringToHex,\n} from '../encoding/toHex.js'\nimport { arrayRegex, bytesRegex, integerRegex } from '../regex.js'\n\ntype PackedAbiType =\n | SolidityAddress\n | SolidityBool\n | SolidityBytes\n | SolidityInt\n | SolidityString\n | SolidityArrayWithoutTuple\n\ntype EncodePackedValues<\n TPackedAbiTypes extends readonly PackedAbiType[] | readonly unknown[],\n> = {\n [K in keyof TPackedAbiTypes]: TPackedAbiTypes[K] extends AbiType\n ? AbiParameterToPrimitiveType<{ type: TPackedAbiTypes[K] }>\n : unknown\n}\n\nexport type EncodePackedErrorType =\n | AbiEncodingLengthMismatchErrorType\n | ConcatHexErrorType\n | EncodeErrorType\n | ErrorType\n\nexport function encodePacked<\n const TPackedAbiTypes extends readonly PackedAbiType[] | readonly unknown[],\n>(types: TPackedAbiTypes, values: EncodePackedValues<TPackedAbiTypes>): Hex {\n if (types.length !== values.length)\n throw new AbiEncodingLengthMismatchError({\n expectedLength: types.length as number,\n givenLength: values.length as number,\n })\n\n const data: Hex[] = []\n for (let i = 0; i < (types as unknown[]).length; i++) {\n const type = types[i]\n const value = values[i]\n data.push(encode(type, value))\n }\n return concatHex(data)\n}\n\ntype EncodeErrorType =\n | BoolToHexErrorType\n | BytesSizeMismatchErrorType\n | InvalidAddressErrorType\n | IsAddressErrorType\n | NumberToHexErrorType\n | PadErrorType\n | StringToHexErrorType\n | UnsupportedPackedAbiType\n | ErrorType\n\nfunction encode<const TPackedAbiType extends PackedAbiType | unknown>(\n type: TPackedAbiType,\n value: EncodePackedValues<[TPackedAbiType]>[0],\n isArray = false,\n): Hex {\n if (type === 'address') {\n const address = value as Address\n if (!isAddress(address)) throw new InvalidAddressError({ address })\n return pad(address.toLowerCase() as Hex, {\n size: isArray ? 32 : null,\n }) as Address\n }\n if (type === 'string') return stringToHex(value as string)\n if (type === 'bytes') return value as Hex\n if (type === 'bool')\n return pad(boolToHex(value as boolean), { size: isArray ? 32 : 1 })\n\n const intMatch = (type as string).match(integerRegex)\n if (intMatch) {\n const [_type, baseType, bits = '256'] = intMatch\n const size = Number.parseInt(bits) / 8\n return numberToHex(value as number, {\n size: isArray ? 32 : size,\n signed: baseType === 'int',\n })\n }\n\n const bytesMatch = (type as string).match(bytesRegex)\n if (bytesMatch) {\n const [_type, size] = bytesMatch\n if (Number.parseInt(size) !== ((value as Hex).length - 2) / 2)\n throw new BytesSizeMismatchError({\n expectedSize: Number.parseInt(size),\n givenSize: ((value as Hex).length - 2) / 2,\n })\n return pad(value as Hex, { dir: 'right', size: isArray ? 32 : null }) as Hex\n }\n\n const arrayMatch = (type as string).match(arrayRegex)\n if (arrayMatch && Array.isArray(value)) {\n const [_type, childType] = arrayMatch\n const data: Hex[] = []\n for (let i = 0; i < value.length; i++) {\n data.push(encode(childType, value[i], true))\n }\n if (data.length === 0) return '0x'\n return concatHex(data)\n }\n\n throw new UnsupportedPackedAbiType(type)\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray } from '../../types/misc.js'\n\nexport type IsBytesErrorType = ErrorType\n\nexport function isBytes(value: unknown): value is ByteArray {\n if (!value) return false\n if (typeof value !== 'object') return false\n if (!('BYTES_PER_ELEMENT' in value)) return false\n return (\n value.BYTES_PER_ELEMENT === 1 && value.constructor.name === 'Uint8Array'\n )\n}\n","import { secp256k1 } from '@noble/curves/secp256k1'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex, Signature } from '../../types/misc.js'\nimport { type HexToBigIntErrorType, hexToBigInt } from '../encoding/fromHex.js'\nimport type { ToHexErrorType } from '../encoding/toHex.js'\n\nexport type SerializeSignatureErrorType =\n | HexToBigIntErrorType\n | ToHexErrorType\n | ErrorType\n\n/**\n * @description Converts a signature into hex format.\n *\n * @param signature The signature to convert.\n * @returns The signature in hex format.\n *\n * @example\n * serializeSignature({\n * r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',\n * s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',\n * yParity: 1\n * })\n * // \"0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c\"\n */\nexport function serializeSignature({ r, s, v, yParity }: Signature): Hex {\n const yParity_ = (() => {\n if (yParity === 0 || yParity === 1) return yParity\n if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0\n throw new Error('Invalid `v` or `yParity` value')\n })()\n return `0x${new secp256k1.Signature(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${yParity_ === 0 ? '1b' : '1c'}`\n}\n","import type { Address } from 'abitype'\n\nimport type { JsonRpcAccount } from '../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../accounts/utils/parseAccount.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Chain } from '../types/chain.js'\nimport type {\n EIP1193RequestFn,\n EIP1474Methods,\n RpcSchema,\n} from '../types/eip1193.js'\nimport type { ExactPartial, Prettify } from '../types/utils.js'\nimport type {\n CcipRequestParameters,\n CcipRequestReturnType,\n} from '../utils/ccip.js'\nimport { uid } from '../utils/uid.js'\nimport type { PublicActions } from './decorators/public.js'\nimport type { WalletActions } from './decorators/wallet.js'\nimport type { Transport } from './transports/createTransport.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /**\n * [CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration.\n * If `false`, the client will not support offchain CCIP lookups.\n */\n ccipRead?:\n | {\n /**\n * A function that will be called to make the offchain CCIP lookup request.\n * @see https://eips.ethereum.org/EIPS/eip-3668#client-lookup-protocol\n */\n request?: (\n parameters: CcipRequestParameters,\n ) => Promise<CcipRequestReturnType>\n }\n | false\n | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// Actions that are used internally by other Actions (ie. `call` is used by `readContract`).\n// They are allowed to be extended, but must conform to their parameter & return type interfaces.\n// Example: an extended `call` action must accept `CallParameters` as parameters,\n// and conform to the `CallReturnType` return type.\ntype ExtendableProtectedActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = Pick<\n PublicActions<transport, chain, account>,\n | 'call'\n | 'createContractEventFilter'\n | 'createEventFilter'\n | 'estimateContractGas'\n | 'estimateGas'\n | 'getBlock'\n | 'getBlockNumber'\n | 'getChainId'\n | 'getContractEvents'\n | 'getEnsText'\n | 'getFilterChanges'\n | 'getGasPrice'\n | 'getLogs'\n | 'getTransaction'\n | 'getTransactionCount'\n | 'getTransactionReceipt'\n | 'prepareTransactionRequest'\n | 'readContract'\n | 'sendRawTransaction'\n | 'simulateContract'\n | 'uninstallFilter'\n | 'watchBlockNumber'\n | 'watchContractEvent'\n> &\n Pick<WalletActions<chain, account>, 'sendTransaction' | 'writeContract'>\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <\n const client extends Extended &\n ExactPartial<ExtendableProtectedActions<transport, chain, account>>,\n >(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>,\n ) => client,\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Flags for batch settings. */\n batch?: ClientConfig['batch'] | undefined\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** [CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration. */\n ccipRead?: ClientConfig['ccipRead'] | undefined\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: EIP1193RequestFn<\n rpcSchema extends undefined ? EIP1474Methods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }\n>\n\nexport type MulticallBatchOptions = {\n /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n}\n\nexport type CreateClientErrorType = ParseAccountErrorType | ErrorType\n\nexport function createClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n>(\n parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): Prettify<\n Client<\n transport,\n chain,\n accountOrAddress extends Address\n ? Prettify<JsonRpcAccount<accountOrAddress>>\n : accountOrAddress,\n rpcSchema\n >\n>\n\nexport function createClient(parameters: ClientConfig): Client {\n const {\n batch,\n cacheTime = parameters.pollingInterval ?? 4_000,\n ccipRead,\n key = 'base',\n name = 'Base Client',\n pollingInterval = 4_000,\n type = 'base',\n } = parameters\n\n const chain = parameters.chain\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n const { config, request, value } = parameters.transport({\n chain,\n pollingInterval,\n })\n const transport = { ...config, ...value }\n\n const client = {\n account,\n batch,\n cacheTime,\n ccipRead,\n chain,\n key,\n name,\n pollingInterval,\n request,\n transport,\n type,\n uid: uid(),\n }\n\n function extend(base: typeof client) {\n type ExtendFn = (base: typeof client) => unknown\n return (extendFn: ExtendFn) => {\n const extended = extendFn(base) as Extended\n for (const key in client) delete extended[key]\n const combined = { ...base, ...extended }\n return Object.assign(combined, { extend: extend(combined as any) })\n }\n }\n\n return Object.assign(client, { extend: extend(client) as any })\n}\n\n/**\n * Defines a typed JSON-RPC schema for the client.\n * Note: This is a runtime noop function.\n */\nexport function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {\n return null as any\n}\n","import { panicReasons } from '../../constants/solidity.js'\nimport { BaseError } from '../../errors/base.js'\nimport { ContractFunctionRevertedError } from '../../errors/contract.js'\nimport type { ErrorType } from '../../errors/utils.js'\n\n/** @internal */\nexport type IsNullUniversalResolverErrorErrorType = ErrorType\n\n/*\n * @description Checks if error is a valid null result UniversalResolver error\n */\nexport function isNullUniversalResolverError(\n err: unknown,\n callType: 'resolve' | 'reverse',\n): boolean {\n if (!(err instanceof BaseError)) return false\n const cause = err.walk((e) => e instanceof ContractFunctionRevertedError)\n if (!(cause instanceof ContractFunctionRevertedError)) return false\n if (cause.data?.errorName === 'ResolverNotFound') return true\n if (cause.data?.errorName === 'ResolverWildcardNotSupported') return true\n if (cause.data?.errorName === 'ResolverNotContract') return true\n if (cause.data?.errorName === 'ResolverError') return true\n if