{"version":3,"sources":["../src/chainable/chainable.ts","../src/common/handleTransaction.ts","../src/matchers/balance/getBalanceChange.ts","../src/matchers/balance/getTokenBalanceChange.ts","../src/matchers/balance/getDiffMethodsFromPrestateTrace.ts","../src/matchers/balance/toChangeBalance.ts","../src/matchers/balance/toChangeBalances.ts","../src/matchers/balance/toChangeTokenBalance.ts","../src/matchers/balance/toChangeTokenBalances.ts","../src/matchers/contract/getSelectorToCalldataMap.ts","../src/matchers/contract/toCallContractFunction.ts","../src/matchers/contract/withFunctionArgs.ts","../src/matchers/contract/withFunctionNamedArgs.ts","../src/matchers/contract/index.ts","../src/matchers/errors/handleTransaction.ts","../src/matchers/errors/toBeReverted.ts","../src/matchers/errors/toBeRevertedWithError.ts","../src/matchers/errors/toBeRevertedWithString.ts","../src/matchers/errors/withErrorArgs.ts","../src/matchers/errors/withErrorNamedArgs.ts","../src/matchers/errors/index.ts","../src/matchers/events/toEmit.ts","../src/matchers/events/withEventArgs.ts","../src/matchers/events/withEventNamedArgs.ts","../src/matchers/events/index.ts","../src/matchers/state/toBeInitializedAccount.ts","../src/matchers/state/toHaveState.ts","../src/matchers/state/toHaveStorageAt.ts","../src/matchers/utils/toBeAddress.ts","../src/matchers/utils/toBeHex.ts","../src/matchers/utils/toEqualAddress.ts","../src/matchers/utils/toEqualHex.ts","../src/index.ts"],"names":["assert","expect","chaiUtils","chai","node","createTevmNode","isHex","waitForTransactionReceipt","contractHandler","ERC20","isEqual","numberToHex","anvilSetStorageAtJsonRpcProcedure","hexToBigInt","debugTraceTransactionJsonRpcProcedure","isAddress","getBalanceChange","getTokenBalanceChange","getAddress","AbiItem","pass","AbiFunction","calldata","decodeAbiParameters","handleTransaction","getTransactionReceipt","BaseError","ViemBaseError","getTransaction","estimateGas","decodeErrorResult","matchedLogs","encodeEventTopics","decodeEventLog","getAccountHandler","isAddressEqual","trim","hexToBytes","equalsBytes"],"mappings":";;;;;;;;;;;;;;AAeA,IAAI,SAAA;AAIJ,IAAM,YAAA,GA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AQ,CAAA;AAClC,IAAA,IAAI;AACH,MAAA,MAAM,aAAA,GAAgBC,gBAAW,kBAAkB,CAAA;AACnD,MAAA,MAAM,aAAA,GAAgBA,gBAAW,kBAAkB,CAAA;AACnD,MAAA,IAAA,GAAOC,iBAAA,CAAY,eAAe,aAAa,CAAA;AAAA,IAChD,CAAA,CAAA,MAAQ;AACP,MAAA,IAAA,GAAO,KAAA;AAAA,IACR;AAAA,EACD;AAEA,EAAA,OAAO;AAAA,IACN,IAAA;AAAA,IACA,MAAA,EAAQ,kBAAA;AAAA,IACR,QAAA,EAAU,kBAAA;AAAA,IACV,SAAS,MAAM;AACd,MAAA,IAAI,MAAM,OAAO,sCAAA;AACjB,MAAA,OAAO,CAAA,gCAAA,EAAmC,IAAA,EAAM,KAAA,GAAQ,gBAAA,GAAmB,0BAA0B,CAAA,CAAA;AAAA,IACtG;AAAA,GACD;AACD;;;ACzBArC,aAAAA,CAAO,MAAA,CAAO;AAAA,EACb,WAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACD,CAAC,CAAA;AAED,yBAAA,CAA0B,sBAAsB,CAAA;AAChD,yBAAA,CAA0B,sBAAsB,CAAA;AAChD,yBAAA,CAA0B,yBAAyB,CAAA","file":"index.cjs","sourcesContent":["import { type Assertion, assert, chai, expect } from 'vitest'\nimport type {\n\tChaiContext,\n\tChainableAssertion,\n\tChainState,\n\tChaiStatic,\n\tChaiUtils,\n\tExtractVitestArgs,\n\tInferredVitestChainableResult,\n\tIsAsync,\n\tMatcherResult,\n\tVitestMatcherConfig,\n\tVitestMatcherFunction,\n} from './types.js'\n\nlet chaiUtils: ChaiUtils | undefined\nexport const getChaiUtils = () => chaiUtils\n\n// Promise setup helper (waffle-chai pattern)\nconst setupPromise = (assertion: Assertion, utils: ChaiUtils): void => {\n\tconst existingPromise = utils.flag(assertion, 'callPromise')\n\tif (existingPromise) return\n\n\tconst obj = utils.flag(assertion, 'object')\n\tif (obj && typeof obj.then === 'function') {\n\t\tutils.flag(assertion, 'callPromise', obj)\n\t} else {\n\t\tutils.flag(assertion, 'callPromise', Promise.resolve())\n\t}\n}\n\nconst isAsyncMatcher = <TReceived, TState>(\n\tmatcher: VitestMatcherFunction<TReceived, boolean, TState>,\n): matcher is VitestMatcherFunction<TReceived, true, TState> => {\n\treturn matcher.constructor.name === 'AsyncFunction'\n}\n\n// Build chain state from flags - automatically detect any previous matcher\nconst buildChainState = (assertion: Assertion, utils: ChaiUtils): ChainState => {\n\t// Get the chain history from a dedicated flag\n\tconst chainHistory: string[] = utils.flag(assertion, 'chainHistory') || []\n\n\tif (chainHistory.length === 0) {\n\t\treturn {\n\t\t\tchainedFrom: undefined,\n\t\t\tpreviousPassed: undefined,\n\t\t\tpreviousValue: undefined,\n\t\t\tpreviousState: undefined,\n\t\t\tpreviousArgs: undefined,\n\t\t}\n\t}\n\n\t// Use the most recent chained matcher\n\tconst matcherName = chainHistory[chainHistory.length - 1]\n\n\t// For async matchers, use the current object (which gets updated)\n\t// rather than the stored value (which might be a Promise)\n\tlet previousValue = utils.flag(assertion, `${matcherName}.value`)\n\tconst currentObj = utils.flag(assertion, 'object')\n\t// If the stored value is a Promise but current object is resolved, use current object\n\tif (previousValue && typeof previousValue.then === 'function' && currentObj !== previousValue)\n\t\tpreviousValue = currentObj\n\n\tconst state = {\n\t\tchainedFrom: matcherName,\n\t\tpreviousPassed: utils.flag(assertion, `${matcherName}.passed`),\n\t\tpreviousValue,\n\t\tpreviousState: utils.flag(assertion, `${matcherName}.state`),\n\t\tpreviousArgs: utils.flag(assertion, `${matcherName}.args`),\n\t}\n\n\treturn state\n}\n\n// Used to fail an assertion in chai with vitest highlighting and trace\nconst createInternalResultHandler = () => {\n\treturn {\n\t\t__expectResult: function (this: any, result: MatcherResult, isNegated: boolean) {\n\t\t\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\t\t\tconst shouldFail = isNegated ? result.pass : !result.pass\n\n\t\t\tif (shouldFail) {\n\t\t\t\treturn {\n\t\t\t\t\tpass: false,\n\t\t\t\t\tmessage: () => result.message(),\n\t\t\t\t\tactual: result.actual,\n\t\t\t\t\texpected: result.expected,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { pass: true, message: () => result.message() }\n\t\t},\n\t}\n}\n\nconst expectResult = (result: MatcherResult, isNegated: boolean) => {\n\t;(\n\t\texpect(result) as unknown as {\n\t\t\t__expectResult: (isNegated: boolean) => MatcherResult\n\t\t}\n\t).__expectResult(isNegated)\n}\n\n// Only extract truly common parts\nconst storeChainState = <TName extends string, TAsync extends boolean = false>(\n\tassertion: ChaiContext<TAsync>,\n\tutils: ChaiUtils,\n\tname: TName,\n\tobj: unknown,\n\targs: readonly unknown[],\n\tresult: MatcherResult,\n) => {\n\tutils.flag(assertion, `${name}.passed`, result.pass)\n\tutils.flag(assertion, `${name}.value`, obj)\n\tutils.flag(assertion, `${name}.state`, result.state)\n\tutils.flag(assertion, `${name}.args`, args)\n\n\t// Track chain history\n\tconst chainHistory: string[] = utils.flag(assertion, 'chainHistory') ?? []\n\tchainHistory.push(name)\n\tutils.flag(assertion, 'chainHistory', chainHistory)\n}\n\nexport const parseChainArgs = <TData = unknown, TState = unknown>(args: readonly unknown[]) => {\n\tconst argsWithoutChainState = args.slice(0, -1)\n\tconst chainState = args[args.length - 1]\n\tassert(\n\t\tchainState && typeof chainState === 'object' && 'chainedFrom' in chainState,\n\t\t'Internal error: no chain state found',\n\t)\n\treturn { args: argsWithoutChainState, chainState: chainState as ChainState<TData, TState> }\n}\n\n// Vitest matcher wrapper for sync matchers\nfunction makeVitestSyncChainable<\n\tTName extends string,\n\tTArgs extends readonly unknown[],\n\tTReceived,\n\tTAsync extends boolean,\n\tTState,\n>(\n\tthis: ChaiContext<false>,\n\tname: TName,\n\tvitestMatcher: VitestMatcherFunction<TReceived, TAsync, TState>,\n\targs: TArgs,\n): Assertion {\n\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\n\t// Check if we're in an async chain\n\tconst callPromise = chaiUtils.flag(this, 'callPromise')\n\tif (callPromise && typeof callPromise.then === 'function') {\n\t\t// We're chaining after an async matcher - join the promise chain\n\t\treturn makeVitestAsyncChainable.call(this, name, vitestMatcher as VitestMatcherFunction, args)\n\t}\n\n\tconst obj = chaiUtils.flag(this, 'object')\n\tconst chainState = buildChainState(this, chaiUtils)\n\n\t// Capture and reset negation flag (sync pattern)\n\tconst isNegated = chaiUtils.flag(this, 'negate') === true\n\tchaiUtils.flag(this, 'negate', false)\n\n\tconst result = vitestMatcher(obj as TReceived, ...args, chainState) as MatcherResult<TState>\n\texpectResult(result, isNegated)\n\n\tstoreChainState(this, chaiUtils, name, obj, args, result)\n\treturn this\n}\n\n// Helper function to execute a promise-based matcher\nconst executeMatcherLogic = async <TName extends string, TArgs extends readonly unknown[], TReceived, TState>(\n\tcontext: ChaiContext<true>,\n\tname: TName,\n\tvitestMatcher: VitestMatcherFunction<TReceived, true, TState>,\n\targs: TArgs,\n\tactualObj: TReceived,\n\tisNegated: boolean,\n\tchaiUtils: ChaiUtils,\n): Promise<TReceived> => {\n\t// Update object with the actual value for further chaining\n\tchaiUtils.flag(context, 'object', actualObj)\n\n\t// Build chain state AFTER we have the actual object\n\tconst chainState = buildChainState(context, chaiUtils)\n\n\t// Store and restore negation flag properly\n\tconst currentNegated = chaiUtils.flag(context, 'negate') === true\n\tchaiUtils.flag(context, 'negate', isNegated)\n\n\tconst result = await (vitestMatcher(actualObj, ...args, chainState) as Promise<MatcherResult<TState>>)\n\n\texpectResult(result, isNegated)\n\n\t// Restore negation flag\n\tchaiUtils.flag(context, 'negate', currentNegated)\n\n\t// Store the results for future chained matchers\n\tstoreChainState(context, chaiUtils, name, actualObj, args, result)\n\n\treturn actualObj\n}\n\n// Updated async chainable function without duplication\nfunction makeVitestAsyncChainable<\n\tTName extends string,\n\tTArgs extends readonly unknown[],\n\tTReceived,\n\tTAsync extends boolean,\n\tTState,\n>(\n\tthis: ChaiContext<true>,\n\tname: TName,\n\tvitestMatcher: VitestMatcherFunction<TReceived, TAsync, TState>,\n\targs: TArgs,\n): ChainableAssertion {\n\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\n\tsetupPromise(this, chaiUtils)\n\tconst isNegated = chaiUtils.flag(this, 'negate') === true\n\n\t// Get the current object (might be a Promise)\n\tconst obj = chaiUtils.flag(this, 'object')\n\n\tconst callPromiseValue = chaiUtils.flag(this, 'callPromise')\n\n\t// Handle both resolved and rejected promises\n\tconst derivedPromise = callPromiseValue.then(\n\t\t// Success handler - for normal resolved promises\n\t\tasync (resolvedValue: any) => {\n\t\t\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\t\t\tconst actualObj = resolvedValue !== undefined ? resolvedValue : await obj\n\t\t\treturn await executeMatcherLogic(\n\t\t\t\tthis,\n\t\t\t\tname,\n\t\t\t\tvitestMatcher as VitestMatcherFunction<TReceived, true, TState>,\n\t\t\t\targs,\n\t\t\t\tactualObj as TReceived,\n\t\t\t\tisNegated,\n\t\t\t\tchaiUtils,\n\t\t\t)\n\t\t},\n\t\t// Error handler - for rejected promises (like contract reverts)\n\t\tasync (error: any) => {\n\t\t\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\n\t\t\t// Wrap the error in a rejected promise so the matcher can catch and process it\n\t\t\tconst errorPromise = Promise.reject(error)\n\n\t\t\ttry {\n\t\t\t\t// Execute the matcher with the rejected promise\n\t\t\t\t// The matcher will catch the error, process it, and return the same rejected promise\n\t\t\t\tawait executeMatcherLogic(\n\t\t\t\t\tthis,\n\t\t\t\t\tname,\n\t\t\t\t\tvitestMatcher as VitestMatcherFunction<TReceived, true, TState>,\n\t\t\t\t\targs,\n\t\t\t\t\terrorPromise as TReceived,\n\t\t\t\t\tisNegated,\n\t\t\t\t\tchaiUtils,\n\t\t\t\t)\n\n\t\t\t\t// If matcher succeeds, convert the error from \"rejected\" to \"resolved\" for chaining\n\t\t\t\t// Next matcher will receive this through success handler but can access previous state\n\t\t\t\treturn error\n\t\t\t} catch (executeError) {\n\t\t\t\t// The returned rejected promise throws when awaited - this is expected\n\t\t\t\t// Convert from rejected to resolved so the chain can continue\n\t\t\t\tif (executeError === error) return error\n\t\t\t\t// If it's a different error, the matcher actually failed - re-throw it\n\t\t\t\tthrow executeError\n\t\t\t}\n\t\t},\n\t)\n\n\t// Make thenable (waffle-chai pattern)\n\t// biome-ignore lint/suspicious/noThenProperty: binding the promise to replicate chai waffle pattern\n\tthis.then = derivedPromise.then.bind(derivedPromise)\n\tthis.catch = derivedPromise.catch.bind(derivedPromise)\n\tchaiUtils.flag(this, 'callPromise', derivedPromise)\n\n\treturn this as unknown as ChainableAssertion\n}\n\n// Convert existing vitest matcher to chainable with perfect type inference\nexport const createChainableFromVitest = <\n\tTName extends string,\n\tTReceived = any,\n\tTState = unknown,\n\tTMatcher extends VitestMatcherFunction<TReceived, boolean, TState> = VitestMatcherFunction<\n\t\tTReceived,\n\t\tboolean,\n\t\tTState\n\t>,\n>(config: {\n\tname: TName\n\tvitestMatcher: TMatcher\n}) => {\n\tconst { name, vitestMatcher } = config\n\tconst isAsync = isAsyncMatcher(vitestMatcher)\n\n\treturn {\n\t\tname,\n\t\tisAsync,\n\t\tmethodFunction: function (this: ChaiContext, ...args: ExtractVitestArgs<typeof vitestMatcher>) {\n\t\t\tif (isAsync) {\n\t\t\t\treturn (makeVitestAsyncChainable<TName, ExtractVitestArgs<typeof vitestMatcher>, TReceived, true, TState>).call(\n\t\t\t\t\tthis,\n\t\t\t\t\tname,\n\t\t\t\t\tvitestMatcher as VitestMatcherFunction<TReceived, true, TState>,\n\t\t\t\t\targs,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn (makeVitestSyncChainable<TName, ExtractVitestArgs<typeof vitestMatcher>, TReceived, false, TState>).call(\n\t\t\t\tthis as ChaiContext<false>,\n\t\t\t\tname,\n\t\t\t\tvitestMatcher as VitestMatcherFunction<TReceived, false, TState>,\n\t\t\t\targs as ExtractVitestArgs<typeof vitestMatcher>,\n\t\t\t)\n\t\t},\n\t\tchainFunction: function (this: ChaiContext): Assertion {\n\t\t\tassert(chaiUtils !== undefined, 'ChaiUtils not initialized')\n\t\t\tchaiUtils.flag(this, `${name}.chained`, true)\n\t\t\treturn this\n\t\t},\n\t} as InferredVitestChainableResult<VitestMatcherConfig<TName, TReceived, IsAsync<TMatcher>, TState>>\n}\n\n// Plugin creator with context-aware registration\nexport const createChainablePlugin = (\n\tmatchers: Record<string, InferredVitestChainableResult<VitestMatcherConfig<string, any, boolean, any>>>,\n) => {\n\treturn (_chai: ChaiStatic, utils: ChaiUtils) => {\n\t\t// Store utils reference\n\t\tchaiUtils = utils\n\n\t\tObject.entries(matchers).forEach(([_, matcher]) => {\n\t\t\tutils.addChainableMethod(_chai.Assertion.prototype, matcher.name, matcher.methodFunction, matcher.chainFunction)\n\t\t})\n\t}\n}\n\n// Convenience function to register chainable matchers\nexport const registerChainableMatchers = (\n\tmatchers: Record<string, InferredVitestChainableResult<VitestMatcherConfig<string, any, boolean, any>>>,\n): void => {\n\texpect.extend(createInternalResultHandler())\n\tchai.use(createChainablePlugin(matchers))\n}\n","import { createTevmNode, type TevmNode } from '@tevm/node'\nimport { type Client, type Hex, isHex } from 'viem'\nimport { waitForTransactionReceipt } from 'viem/actions'\nimport type { ContainsTransactionAny } from './types.js'\n\n/**\n * Common result from handling a transaction\n */\nexport interface HandleTransactionResult {\n\tnode: TevmNode\n\ttxHash: Hex\n}\n\n/**\n * Handles a transaction to extract the node and transaction hash\n * @param client - The client or node to use for handling the transaction\n * @param tx - The transaction to handle\n * @returns Promise with node and transaction hash\n */\nexport const handleTransaction = async (\n\tclient: Client | TevmNode,\n\ttx: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n): Promise<HandleTransactionResult> => {\n\tconst res = tx instanceof Promise ? await tx : tx\n\n\tconst node = 'request' in client ? createTevmNode({ fork: { transport: client } }) : client\n\n\tconst txHash =\n\t\t// If it's a transaction receipt\n\t\ttypeof res === 'object' && 'transactionHash' in res\n\t\t\t? res.transactionHash\n\t\t\t: // If it's a call result\n\t\t\t\ttypeof res === 'object' && 'txHash' in res\n\t\t\t\t? res.txHash\n\t\t\t\t: // If it's already a transaction hash\n\t\t\t\t\ttypeof res === 'string' && isHex(res)\n\t\t\t\t\t? res\n\t\t\t\t\t: undefined\n\n\tif (txHash === undefined) {\n\t\tthrow new Error(\n\t\t\t'Transaction hash is undefined, you need to pass a transaction hash, receipt or call result, or a promise that resolves to one of those',\n\t\t)\n\t}\n\n\t// If a client was passed, we assume the tx will get mined consumer side, so we just need to wait for it\n\tif ('request' in client) {\n\t\tawait waitForTransactionReceipt(client, { hash: txHash })\n\t}\n\n\treturn { node, txHash }\n}\n","import type { PrestateTraceResult } from '@tevm/actions'\nimport type { Address } from 'viem'\n\nexport const getBalanceChange = (prestateTrace: PrestateTraceResult<true>, address: Address) => {\n\tconst pre = prestateTrace.pre[address]\n\tconst post = prestateTrace.post[address]\n\tif (!pre || !post) return 0n\n\n\treturn BigInt(post.balance ?? 0n) - BigInt(pre.balance ?? 0n)\n}\n","import { anvilSetStorageAtJsonRpcProcedure, contractHandler, type PrestateTraceResult } from '@tevm/actions'\nimport { ERC20 } from '@tevm/contract'\nimport type { TevmNode } from '@tevm/node'\nimport { isEqual } from 'ox/Hex'\nimport { type Address, type Hex, hexToBigInt, numberToHex } from 'viem'\n\n/**\n * Gets the token balance change for a specific token and address by analyzing storage changes\n * @param node - The TevmNode instance\n * @param tokenAddress - The token contract address\n * @param address - The address to check balance change for\n * @param prestateTrace - The prestate trace containing storage changes\n * @returns The balance change and slot information\n */\nexport const getTokenBalanceChange = async (\n\tnode: TevmNode,\n\ttokenAddress: Address,\n\taddress: Address,\n\tprestateTrace: PrestateTraceResult<true>,\n): Promise<bigint> => {\n\t// Get the current balance\n\tconst currentBalanceResponse = await contractHandler(node)({\n\t\t...ERC20.withAddress(tokenAddress).read.balanceOf(address),\n\t\tthrowOnFail: false,\n\t})\n\n\tif (currentBalanceResponse.errors || currentBalanceResponse.data === undefined) {\n\t\tthrow new Error(\n\t\t\t`Failed to get initial balance for token ${tokenAddress} and address ${address} when trying to find the balanceOf slot. Could not retrieve the balance change.\\n\\n${JSON.stringify(currentBalanceResponse, null, 2)}`,\n\t\t)\n\t}\n\n\tconst currentBalance = currentBalanceResponse.data\n\n\t// Iterate through all addresses that have storage changes\n\tfor (const [contractAddress, traceData] of Object.entries(prestateTrace.post)) {\n\t\t// Skip if no storage changes\n\t\tif (!traceData.storage) continue\n\n\t\t// For each storage slot that was accessed\n\t\tfor (const [slot, currentValue] of Object.entries(traceData.storage)) {\n\t\t\t// Skip early if the value is not the encoded current balance\n\t\t\tif (!isEqual(currentValue, numberToHex(currentBalance))) continue\n\n\t\t\ttry {\n\t\t\t\t// Set to a different value to see if it affects the balance\n\t\t\t\tconst nextValue = numberToHex(currentBalance + 1n, { size: 32 })\n\t\t\t\tawait anvilSetStorageAtJsonRpcProcedure(node)({\n\t\t\t\t\tmethod: 'anvil_setStorageAt',\n\t\t\t\t\tparams: [contractAddress as Address, slot as Hex, nextValue],\n\t\t\t\t\tid: 1,\n\t\t\t\t\tjsonrpc: '2.0',\n\t\t\t\t})\n\n\t\t\t\t// Check if the balance changed\n\t\t\t\tconst nextBalanceResponse = await contractHandler(node)(ERC20.withAddress(tokenAddress).read.balanceOf(address))\n\n\t\t\t\t// If balance didn't change, that's not the slot we're looking for\n\t\t\t\tif (nextBalanceResponse.data === undefined || nextBalanceResponse.data === currentBalance) continue\n\n\t\t\t\t// Get the previous balance from the prestate trace\n\t\t\t\tconst preSlotValue = prestateTrace.pre[contractAddress as Address]?.storage?.[slot as Hex]\n\t\t\t\tif (preSlotValue === undefined) throw new Error('preSlotValue is undefined') // this can't happen as it was in the post state\n\n\t\t\t\tconst previousBalance = hexToBigInt(preSlotValue)\n\t\t\t\treturn currentBalance - previousBalance\n\t\t\t} catch (_) {\n\t\t\t\t// If there's an error, we'll try the next slot\n\t\t\t} finally {\n\t\t\t\t// Always restore the original value\n\t\t\t\tawait anvilSetStorageAtJsonRpcProcedure(node)({\n\t\t\t\t\tmethod: 'anvil_setStorageAt',\n\t\t\t\t\tparams: [contractAddress as Address, slot as Hex, currentValue],\n\t\t\t\t\tid: 1,\n\t\t\t\t\tjsonrpc: '2.0',\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no storage slot affected the balance, that means this account was untouched so its balance didn't change\n\t// or it was touched but only accessed (balance is in pre state but not in post state)\n\treturn 0n\n}\n","import { debugTraceTransactionJsonRpcProcedure, type PrestateTraceResult } from '@tevm/actions'\nimport { type TevmNode } from '@tevm/node'\nimport { type Address, type Client } from 'viem'\nimport { handleTransaction } from '../../common/handleTransaction.js'\nimport type { ContainsTransactionAny } from '../../common/types.js'\nimport { getBalanceChange } from './getBalanceChange.js'\nimport { getTokenBalanceChange } from './getTokenBalanceChange.js'\nimport type { HandleTransactionResult } from './types.js'\n\n/**\n * Replay a transaction with a prestate tracer to figure out the balance changes\n * @param node - The TEVM node\n * @param txHash - The transaction hash\n * @returns Promise with balance change getter functions\n */\nexport const getDiffMethodsFromPrestateTrace = async (\n\tclient: Client | TevmNode,\n\ttx: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n): Promise<HandleTransactionResult> => {\n\tconst { node, txHash } = await handleTransaction(client, tx)\n\n\tconst res = await debugTraceTransactionJsonRpcProcedure(node)({\n\t\tjsonrpc: '2.0',\n\t\tmethod: 'debug_traceTransaction',\n\t\tparams: [{ transactionHash: txHash, tracer: 'prestateTracer', tracerConfig: { diffMode: true } }],\n\t\tid: 1,\n\t})\n\n\tconst prestateTrace = res.result as PrestateTraceResult<true>\n\n\treturn {\n\t\tgetBalanceChange: (address: Address) => getBalanceChange(prestateTrace, address.toLowerCase() as Address),\n\t\tgetTokenBalanceChange: (tokenAddress: Address, address: Address) =>\n\t\t\tgetTokenBalanceChange(\n\t\t\t\tnode,\n\t\t\t\ttokenAddress.toLowerCase() as Address,\n\t\t\t\taddress.toLowerCase() as Address,\n\t\t\t\tprestateTrace,\n\t\t\t),\n\t}\n}\n","import { type TevmNode } from '@tevm/node'\nimport { type Address, type Client, isAddress } from 'viem'\nimport type { ContainsAddress, ContainsTransactionAny } from '../../common/types.js'\nimport { getDiffMethodsFromPrestateTrace } from './getDiffMethodsFromPrestateTrace.js'\n\n/**\n * Checks if a transaction changes an account's balance by the expected amount\n * @param received - The transaction to check\n * @param client - The client or node to use for balance queries\n * @param account - The account address or object with address\n * @param expectedChange - The expected balance change (can be negative)\n * @returns Promise with matcher result\n */\nexport const toChangeBalance = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client | TevmNode,\n\taccount: Address | ContainsAddress,\n\texpectedChange: bigint | number | string,\n) => {\n\t// Normalize the address\n\tconst address = typeof account === 'string' ? account : account.address\n\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\t// Normalize the expected change\n\tconst expectedChangeBigInt = typeof expectedChange === 'bigint' ? expectedChange : BigInt(expectedChange)\n\n\t// Handle the transaction and get balance change\n\tconst { getBalanceChange } = await getDiffMethodsFromPrestateTrace(client, received)\n\tconst balanceChange = getBalanceChange(address)\n\n\tconst pass = balanceChange === expectedChangeBigInt\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected account ${address} not to change balance by ${expectedChangeBigInt.toString()}`\n\t\t\t\t: `Expected account ${address} to change balance by ${expectedChangeBigInt.toString()}`,\n\t\tactual: balanceChange,\n\t\texpected: expectedChangeBigInt,\n\t}\n}\n","import { type TevmNode } from '@tevm/node'\nimport { type Client, isAddress } from 'viem'\nimport type { ContainsTransactionAny } from '../../common/types.js'\nimport { getDiffMethodsFromPrestateTrace } from './getDiffMethodsFromPrestateTrace.js'\nimport type { BalanceChange } from './types.js'\n\n/**\n * Checks if a transaction changes multiple accounts' balances by the expected amounts\n * @param received - The transaction to check\n * @param client - The client or node to use for balance queries\n * @param balanceChanges - Array of expected balance changes\n * @returns Promise with matcher result\n */\nexport const toChangeBalances = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client | TevmNode,\n\tbalanceChanges: BalanceChange[],\n) => {\n\t// Handle the transaction and get balance changes\n\tconst { getBalanceChange } = await getDiffMethodsFromPrestateTrace(client, received)\n\n\t// Validate and normalize balance changes\n\tconst normalizedBalanceChanges = balanceChanges.map((change) => {\n\t\tconst address = typeof change.account === 'string' ? change.account : change.account.address\n\t\tconst amount = typeof change.amount === 'bigint' ? change.amount : BigInt(change.amount)\n\n\t\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\t\treturn {\n\t\t\taddress,\n\t\t\tamount,\n\t\t\tactualAmount: getBalanceChange(address),\n\t\t}\n\t})\n\n\t// Check which balance changes failed\n\tconst failedIndexes = normalizedBalanceChanges\n\t\t.filter((change) => change.actualAmount !== change.amount)\n\t\t.map((change) => normalizedBalanceChanges.indexOf(change))\n\n\tconst pass = failedIndexes.length === 0\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? 'Expected transaction not to change balances by the specified amounts, but all of them passed'\n\t\t\t\t: failedIndexes.length === normalizedBalanceChanges.length\n\t\t\t\t\t? 'Expected transaction to change balances by the specified amounts, but none of them passed'\n\t\t\t\t\t: `Expected transaction to change balances by the specified amounts, but some of them didn't pass (at indexes [${failedIndexes.join(', ')}])`,\n\t\tactual: balanceChanges.map((change, i) => ({\n\t\t\taccount: change.account,\n\t\t\tamount: normalizedBalanceChanges[i]?.actualAmount,\n\t\t})),\n\t\texpected: balanceChanges.map((change, i) => ({\n\t\t\taccount: change.account,\n\t\t\tamount: normalizedBalanceChanges[i]?.amount,\n\t\t})),\n\t}\n}\n","import { type TevmNode } from '@tevm/node'\nimport { type Address, type Client, isAddress } from 'viem'\nimport type { ContainsAddress, ContainsTransactionAny } from '../../common/types.js'\nimport { getDiffMethodsFromPrestateTrace } from './getDiffMethodsFromPrestateTrace.js'\n\n/**\n * Checks if a transaction changes an account's token balance by the expected amount\n * @param received - The transaction to check\n * @param client - The client or node to use for balance queries\n * @param tokenContract - The token contract address or object with address\n * @param account - The account address or object with address\n * @param expectedChange - The expected balance change (can be negative)\n * @returns Promise with matcher result\n */\nexport const toChangeTokenBalance = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client | TevmNode,\n\ttokenContract: Address | ContainsAddress,\n\taccount: Address | ContainsAddress,\n\texpectedChange: bigint | number | string,\n) => {\n\t// Normalize the token address\n\tconst tokenAddress = typeof tokenContract === 'string' ? tokenContract : tokenContract.address\n\tif (!isAddress(tokenAddress)) throw new Error(`Invalid token address: ${tokenAddress}`)\n\n\t// Normalize the account address\n\tconst address = typeof account === 'string' ? account : account.address\n\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\t// Normalize the expected change\n\tconst expectedChangeBigInt = typeof expectedChange === 'bigint' ? expectedChange : BigInt(expectedChange)\n\n\t// Handle the transaction and get token balance change\n\tconst { getTokenBalanceChange } = await getDiffMethodsFromPrestateTrace(client, received)\n\tconst tokenBalanceChange = await getTokenBalanceChange(tokenAddress, address)\n\n\tconst pass = tokenBalanceChange === expectedChangeBigInt\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected account ${address} not to change token balance by ${expectedChangeBigInt.toString()}`\n\t\t\t\t: `Expected account ${address} to change token balance by ${expectedChangeBigInt.toString()}`,\n\t\tactual: tokenBalanceChange,\n\t\texpected: expectedChangeBigInt,\n\t}\n}\n","import { type TevmNode } from '@tevm/node'\nimport { type Address, type Client, isAddress } from 'viem'\nimport type { ContainsAddress, ContainsTransactionAny } from '../../common/types.js'\nimport { getDiffMethodsFromPrestateTrace } from './getDiffMethodsFromPrestateTrace.js'\nimport type { BalanceChange } from './types.js'\n\n/**\n * Checks if a transaction changes multiple accounts' token balances by the expected amounts\n * @param received - The transaction to check\n * @param client - The client or node to use for balance queries\n * @param tokenContract - The token contract address or object with address\n * @param balanceChanges - Array of expected token balance changes\n * @returns Promise with matcher result\n */\nexport const toChangeTokenBalances = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client | TevmNode,\n\ttokenContract: Address | ContainsAddress,\n\tbalanceChanges: BalanceChange[],\n) => {\n\t// Normalize the token address\n\tconst tokenAddress = typeof tokenContract === 'string' ? tokenContract : tokenContract.address\n\tif (!isAddress(tokenAddress)) throw new Error(`Invalid token address: ${tokenAddress}`)\n\n\t// Handle the transaction and get token balance changes\n\tconst { getTokenBalanceChange } = await getDiffMethodsFromPrestateTrace(client, received)\n\n\t// Validate and normalize token balance changes\n\tconst normalizedBalanceChanges = await Promise.all(\n\t\tbalanceChanges.map(async (change) => {\n\t\t\tconst address = typeof change.account === 'string' ? change.account : change.account.address\n\t\t\tconst amount = typeof change.amount === 'bigint' ? change.amount : BigInt(change.amount)\n\n\t\t\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\t\t\tconst balanceChange = await getTokenBalanceChange(tokenAddress, address)\n\n\t\t\treturn {\n\t\t\t\taddress,\n\t\t\t\tamount,\n\t\t\t\tactualAmount: balanceChange,\n\t\t\t}\n\t\t}),\n\t)\n\n\t// Check which balance changes failed\n\tconst failedIndexes = normalizedBalanceChanges\n\t\t.filter((change) => change.actualAmount !== change.amount)\n\t\t.map((change) => normalizedBalanceChanges.indexOf(change))\n\n\tconst pass = failedIndexes.length === 0\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? 'Expected transaction not to change token balances by the specified amounts, but all of them passed'\n\t\t\t\t: failedIndexes.length === normalizedBalanceChanges.length\n\t\t\t\t\t? 'Expected transaction to change token balances by the specified amounts, but none of them passed'\n\t\t\t\t\t: `Expected transaction to change token balances by the specified amounts, but some of them didn't pass (at indexes [${failedIndexes.join(', ')}])`,\n\t\tactual: balanceChanges.map((change, i) => ({\n\t\t\taccount: change.account,\n\t\t\tamount: normalizedBalanceChanges[i]?.actualAmount,\n\t\t})),\n\t\texpected: balanceChanges.map((change, i) => ({\n\t\t\taccount: change.account,\n\t\t\tamount: normalizedBalanceChanges[i]?.amount,\n\t\t})),\n\t}\n}\n","import { debugTraceTransactionJsonRpcProcedure, type FourbyteTraceResult } from '@tevm/actions'\nimport { type TevmNode } from '@tevm/node'\nimport { type Address, type Client, getAddress, type Hex, isHex } from 'viem'\nimport { handleTransaction } from '../../common/handleTransaction.js'\nimport type { ContainsTransactionAny } from '../../common/types.js'\n\nexport const getSelectorToCalldataMap = async (\n\tclient: Client | TevmNode,\n\tcontractAddress: Address,\n\ttx: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n) => {\n\tconst { node, txHash } = await handleTransaction(client, tx)\n\n\tconst { result, error } = await debugTraceTransactionJsonRpcProcedure(node)({\n\t\tjsonrpc: '2.0',\n\t\tmethod: 'debug_traceTransaction',\n\t\tparams: [{ transactionHash: txHash, tracer: '4byteTracer' }],\n\t\tid: 1,\n\t})\n\n\tif (error) throw new Error('Error tracing transaction to retrieve function calls', { cause: error })\n\n\tconst trace = result as FourbyteTraceResult\n\tconst contractTrace = trace[getAddress(contractAddress)] ?? {}\n\tconst calldataMap = new Map(Object.entries(contractTrace).filter(([selector]) => isHex(selector))) as Map<Hex, Hex[]>\n\n\treturn calldataMap\n}\n","import type { TevmNode } from '@tevm/node'\nimport { AbiFunction, AbiItem } from 'ox'\nimport type { Abi, Client, ContractFunctionName, Hex } from 'viem'\nimport { isHex } from 'viem'\nimport type { MatcherResult } from '../../chainable/types.js'\nimport type { ContainsContractAddressAndOptionalAbi, ContainsTransactionAny } from '../../common/types.js'\nimport { getSelectorToCalldataMap } from './getSelectorToCalldataMap.js'\nimport type { ToCallContractFunctionState } from './types.js'\n\nexport const toCallContractFunction = async <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTFunctionName extends TAbi extends Abi ? ContractFunctionName<TAbi> : never = TAbi extends Abi\n\t\t? ContractFunctionName<TAbi>\n\t\t: never,\n\tTContract extends TAbi extends Abi ? ContainsContractAddressAndOptionalAbi<TAbi> : never = TAbi extends Abi\n\t\t? ContainsContractAddressAndOptionalAbi<TAbi>\n\t\t: never,\n>(\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client | TevmNode,\n\tcontract: TContract,\n\tfunctionIdentifier: TFunctionName | Hex | string,\n): Promise<MatcherResult<ToCallContractFunctionState>> => {\n\tif (!contract.address) throw new Error('You need to provide a contract address')\n\tconst calldataMap = await getSelectorToCalldataMap(client, contract.address, received)\n\n\t// If it's a selector or signature\n\tif (isHex(functionIdentifier) || functionIdentifier.includes('function') || functionIdentifier.includes('(')) {\n\t\tconst functionSelector = isHex(functionIdentifier) ? functionIdentifier : AbiItem.getSelector(functionIdentifier)\n\n\t\tconst pass = calldataMap.has(functionSelector)\n\n\t\treturn {\n\t\t\tpass,\n\t\t\tactual: Array.from(calldataMap.keys()),\n\t\t\texpected: `transaction calling function with selector ${functionSelector}`,\n\t\t\tmessage: () =>\n\t\t\t\tpass\n\t\t\t\t\t? `Expected transaction not to call function ${functionIdentifier}`\n\t\t\t\t\t: `Expected transaction to call function ${functionIdentifier}`,\n\t\t}\n\t}\n\n\tif (!contract.abi) throw new Error('You need to provide a contract ABI if you want to match a function name')\n\tconst abiFunction = AbiFunction.fromAbi(contract.abi, functionIdentifier)\n\tconst selector = AbiFunction.getSelector(abiFunction)\n\n\tconst pass = calldataMap.has(selector)\n\n\treturn {\n\t\tpass,\n\t\tactual: Array.from(calldataMap.keys()),\n\t\texpected: `transaction calling function with selector ${selector}`,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected transaction not to call function ${functionIdentifier}`\n\t\t\t\t: `Expected transaction to call function ${functionIdentifier}`,\n\t\tstate: {\n\t\t\tabiFunction,\n\t\t\tselector,\n\t\t\tcalldataMap,\n\t\t},\n\t}\n}\n","import type { AbiParameter, AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype'\nimport { type Abi, type ContractFunctionName, decodeAbiParameters } from 'viem'\nimport { parseChainArgs } from '../../chainable/chainable.js'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { ToCallContractFunctionState } from './types.js'\n\nexport const withFunctionArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTFunctionName extends TAbi extends Abi ? ContractFunctionName<TAbi> : never = TAbi extends Abi\n\t\t? ContractFunctionName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiParameter[] = TAbi extends Abi\n\t\t? ExtractAbiFunction<TAbi, TFunctionName> extends { inputs: infer U extends readonly AbiParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\t...argsAndChainState: readonly [\n\t\t...AbiParametersToPrimitiveTypes<TInputs>,\n\t\tChainState<unknown, ToCallContractFunctionState>,\n\t]\n): MatcherResult => {\n\tconst {\n\t\targs,\n\t\tchainState: { previousState },\n\t} = parseChainArgs<unknown, ToCallContractFunctionState>(argsAndChainState)\n\n\tif (!previousState || !('abiFunction' in previousState))\n\t\tthrow new Error('withFunctionArgs() requires a contract with abi and function name')\n\n\tconst { abiFunction, selector, calldataMap } = previousState\n\tconst calldata = calldataMap.get(selector)\n\n\tconst actualDecodedArgs = calldata\n\t\t? calldata.map((calldata) => decodeAbiParameters(abiFunction.inputs, calldata))\n\t\t: undefined\n\n\tconst argsMatched = actualDecodedArgs\n\t\t? actualDecodedArgs.some((decodedArgs) => {\n\t\t\t\treturn Array.isArray(decodedArgs) && args.every((arg, i) => decodedArgs[i] === arg)\n\t\t\t})\n\t\t: false\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: actualDecodedArgs ? Object.fromEntries(actualDecodedArgs.map((decodedArgs, i) => [i, decodedArgs])) : {},\n\t\texpected: args,\n\t\tmessage: () =>\n\t\t\targsMatched\n\t\t\t\t? 'Expected transaction not to call function with the specified arguments'\n\t\t\t\t: 'Expected transaction to call function with the specified arguments',\n\t}\n}\n","import type { AbiParameter, ExtractAbiFunction } from 'abitype'\nimport { type Abi, type ContractFunctionName, decodeAbiParameters } from 'viem'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs } from '../../common/types.js'\nimport type { ToCallContractFunctionState } from './types.js'\n\nexport const withFunctionNamedArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTFunctionName extends TAbi extends Abi ? ContractFunctionName<TAbi> : never = TAbi extends Abi\n\t\t? ContractFunctionName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiParameter[] = TAbi extends Abi\n\t\t? ExtractAbiFunction<TAbi, TFunctionName> extends { inputs: infer U extends readonly AbiParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\texpectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>,\n\tchainState?: ChainState<unknown, ToCallContractFunctionState>,\n): MatcherResult => {\n\tif (!chainState?.previousState || !('abiFunction' in chainState.previousState))\n\t\tthrow new Error('withFunctionNamedArgs() requires a contract with abi and function name')\n\n\tconst { abiFunction, selector, calldataMap } = chainState.previousState\n\tconst calldata = calldataMap.get(selector)\n\tconst actualDecodedArgs = calldata\n\t\t? calldata.map((calldata) => decodeAbiParameters(abiFunction.inputs, calldata))\n\t\t: undefined\n\tconst actualNamedArgs = actualDecodedArgs\n\t\t? actualDecodedArgs.map((decodedArgs) =>\n\t\t\t\tabiFunction.inputs.reduce(\n\t\t\t\t\t(acc, input, index) => {\n\t\t\t\t\t\tacc[input.name ?? ''] = decodedArgs[index]\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t},\n\t\t\t\t\t{} as Record<string, unknown>,\n\t\t\t\t),\n\t\t\t)\n\t\t: undefined\n\n\tconst argsMatched = actualNamedArgs\n\t\t? actualNamedArgs.some((namedArgs) => {\n\t\t\t\treturn Object.entries(expectedArgs).every(\n\t\t\t\t\t([key, value]) => key in namedArgs && namedArgs[key as keyof typeof namedArgs] === value,\n\t\t\t\t)\n\t\t\t})\n\t\t: false\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: actualNamedArgs ? Object.fromEntries(actualNamedArgs.map((namedArgs, i) => [i, namedArgs])) : {},\n\t\texpected: expectedArgs,\n\t\tmessage: () =>\n\t\t\targsMatched\n\t\t\t\t? 'Expected transaction not to call function with the specified arguments'\n\t\t\t\t: 'Expected transaction to call function with the specified arguments',\n\t}\n}\n","import type { TevmNode } from '@tevm/node'\nimport type { AbiParameter, AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype'\nimport type { Abi, Client, ContractFunctionName, Hex } from 'viem'\nimport { createChainableFromVitest } from '../../chainable/chainable.js'\nimport type { ChainableAssertion } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs, ContainsContractAddressAndOptionalAbi } from '../../common/types.js'\nimport { toCallContractFunction } from './toCallContractFunction.js'\nimport { withFunctionArgs } from './withFunctionArgs.js'\nimport { withFunctionNamedArgs } from './withFunctionNamedArgs.js'\n\n// Create chainable matchers\nexport const toCallContractFunctionChainable = createChainableFromVitest({\n\tname: 'toCallContractFunction' as const,\n\tvitestMatcher: toCallContractFunction,\n})\n\nexport const withFunctionArgsChainable = createChainableFromVitest({\n\tname: 'withFunctionArgs' as const,\n\tvitestMatcher: withFunctionArgs,\n})\n\nexport const withFunctionNamedArgsChainable = createChainableFromVitest({\n\tname: 'withFunctionNamedArgs' as const,\n\tvitestMatcher: withFunctionNamedArgs,\n})\n\n// Register the chainable matchers\nexport const chainableContractMatchers = {\n\ttoCallContractFunction: toCallContractFunctionChainable,\n\twithFunctionArgs: withFunctionArgsChainable,\n\twithFunctionNamedArgs: withFunctionNamedArgsChainable,\n}\n\nexport { toCallContractFunction, withFunctionArgs, withFunctionNamedArgs }\n\n// TypeScript declaration for vitest\nexport interface ContractMatchers {\n\t/**\n\t * Asserts that a transaction called a specific contract function.\n\t * Can be used with contract objects, function signatures, or selectors.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param contract - Contract object with ABI and address\n\t * @param functionName - Name of the function in the ABI\n\t *\n\t * @example\n\t * ```typescript\n\t * // Using contract object\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *\n\t * // Chain with argument assertions\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *   .withFunctionArgs(to, 100n)\n\t *\n\t * // Chain with argument assertions by name (partial matching)\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *   .withFunctionNamedArgs({ to, value: 100n })\n\t * ```\n\t *\n\t * @see {@link withFunctionArgs} to test function arguments positionally\n\t * @see {@link withFunctionNamedArgs} to test function arguments by name\n\t */\n\ttoCallContractFunction<TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi>>(\n\t\tclient: Client | TevmNode,\n\t\tcontract: ContainsContractAddressAndOptionalAbi<TAbi>,\n\t\tfunctionName: TFunctionName,\n\t): Promise<ContractAssertionWithContract<TAbi, TFunctionName>> & ContractAssertionWithContract<TAbi, TFunctionName>\n\n\t/**\n\t * Asserts that a transaction called a function matching the signature.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param functionSignature - Function signature string (e.g., \"transfer(address,uint256)\")\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(txHash).toCallContractFunction(client, contract, 'transfer(address,uint256)')\n\t * await expect(txHash).toCallContractFunction(client, { address: '0x123...' }, 'transfer(address,uint256)')\n\t * ```\n\t */\n\ttoCallContractFunction(\n\t\tclient: Client | TevmNode,\n\t\tcontract: ContainsContractAddressAndOptionalAbi,\n\t\tfunctionSignature: string,\n\t): ChainableAssertion\n\n\t/**\n\t * Asserts that a transaction called a function matching the selector.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param functionSelector - Function selector (4-byte hex)\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(txHash).toCallContractFunction(client, contract, '0xa9059cbb') // transfer function selector\n\t * await expect(txHash).toCallContractFunction(client, { address: '0x123...' }, '0xa9059cbb') // transfer function selector\n\t * ```\n\t */\n\ttoCallContractFunction(\n\t\tclient: Client | TevmNode,\n\t\tcontract: ContainsContractAddressAndOptionalAbi,\n\t\tfunctionSelector: Hex,\n\t): ChainableAssertion\n}\n\n// Only-after toCallContractFunction assertion type\ninterface ContractAssertionWithContract<TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi>> {\n\t/**\n\t * Chains with toCallContractFunction to assert function arguments in positional order.\n\t * Arguments must match exactly in the order they appear in the function.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Expected arguments in order\n\t *\n\t * @example\n\t * ```typescript\n\t * // transfer function: transfer(address to, uint256 value)\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *   .withFunctionArgs(\n\t *     '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', // to\n\t *     1000n // value\n\t *   )\n\t * ```\n\t *\n\t * @see {@link withFunctionNamedArgs} for partial matching by name\n\t */\n\twithFunctionArgs<\n\t\tTInputs extends readonly AbiParameter[] = ExtractAbiFunction<TAbi, TFunctionName> extends {\n\t\t\tinputs: infer U extends readonly AbiParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiParameter[],\n\t>(...expectedArgs: AbiParametersToPrimitiveTypes<TInputs>): ChainableAssertion\n\n\t/**\n\t * Chains with toCallContractFunction to assert function arguments by name.\n\t * Supports partial matching - only specified arguments are checked.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Object with expected named arguments (partial)\n\t *\n\t * @example\n\t * ```typescript\n\t * // Check only specific arguments\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *   .withFunctionNamedArgs({\n\t *     to: recipient,\n\t *     value: 1000n\n\t *   })\n\t *\n\t * // Empty object matches any call to this function\n\t * await expect(txHash)\n\t *   .toCallContractFunction(client, tokenContract, 'transfer')\n\t *   .withFunctionNamedArgs({})\n\t * ```\n\t *\n\t * @see {@link withFunctionArgs} for positional argument matching\n\t */\n\twithFunctionNamedArgs<\n\t\tTInputs extends readonly AbiParameter[] = ExtractAbiFunction<TAbi, TFunctionName> extends {\n\t\t\tinputs: infer U extends readonly AbiParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiParameter[],\n\t>(expectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>): ChainableAssertion\n}\n","import { BaseError, RevertError } from '@tevm/errors'\nimport type { AbiError } from 'abitype'\nimport {\n\ttype Client,\n\tContractFunctionRevertedError,\n\ttype DecodeErrorResultReturnType,\n\tdecodeAbiParameters,\n\ttype Hex,\n\tisHex,\n\ttype TransactionReceipt,\n\tBaseError as ViemBaseError,\n} from 'viem'\nimport { estimateGas, getTransaction, getTransactionReceipt } from 'viem/actions'\nimport type { ContainsTransactionAny } from '../../common/types.js'\n\nexport const handleTransaction = async (\n\ttx: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\topts: { client?: Client | undefined },\n) => {\n\tconst { client } = opts\n\ttry {\n\t\tconst res = tx instanceof Promise ? await tx : tx\n\n\t\t// We can throw directly if it's the result of a tevm call that didn't throw\n\t\tif (typeof res === 'object' && 'errors' in res) throw res.errors[0]\n\n\t\t// If it didn't, we'll need a client\n\t\tif (!client)\n\t\t\tthrow new Error(\n\t\t\t\t\"You need to pass a client if the result of the promise is a transaction hash, receipt or call result that didn't throw\",\n\t\t\t)\n\n\t\tconst txReceipt =\n\t\t\ttypeof res === 'object' && 'status' in res\n\t\t\t\t? (res as TransactionReceipt)\n\t\t\t\t: typeof res === 'string' && isHex(res)\n\t\t\t\t\t? await getTransactionReceipt(client, { hash: res })\n\t\t\t\t\t: undefined\n\t\tif (txReceipt) await maybeThrowErrorFromTxReceipt(client, txReceipt)\n\n\t\treturn {\n\t\t\tisRevert: false,\n\t\t\tisError: false,\n\t\t\trevertReason: undefined,\n\t\t\terror: undefined,\n\t\t}\n\t} catch (error) {\n\t\t// Bubble the error up to the test if it's missing a client\n\t\tif (error instanceof Error && error.message.includes('You need to pass a client')) throw error\n\t\treturn {\n\t\t\t...parseError(error),\n\t\t\terror,\n\t\t}\n\t}\n}\n\nconst parseError = (error: unknown) => {\n\tconst isRevert = (error instanceof BaseError || error instanceof ViemBaseError) && error.message.includes('revert')\n\n\t// Return early if it's not a revert\n\tif (!isRevert) {\n\t\treturn {\n\t\t\tisRevert: false,\n\t\t\tisError: true,\n\t\t\trevertReason: undefined,\n\t\t}\n\t}\n\n\tlet decodedRevertData: DecodeErrorResultReturnType | undefined\n\tlet rawRevertData: Hex | undefined\n\n\t// Get the decoded data directly if it's available\n\tconst revertData = extractRevertData(error)\n\tif (isHex(revertData)) {\n\t\trawRevertData = revertData\n\t} else {\n\t\tdecodedRevertData = revertData\n\t}\n\n\tconst { revertString, revertReason } = extractRevertStringAndReason(rawRevertData, decodedRevertData)\n\n\treturn {\n\t\tisRevert: true,\n\t\tisError: false,\n\t\trawRevertData,\n\t\tdecodedRevertData,\n\t\trevertString,\n\t\trevertReason,\n\t}\n}\n\nconst maybeThrowErrorFromTxReceipt = async (client: Client, txReceipt: TransactionReceipt) => {\n\tif (txReceipt.status === 'success') return\n\tconst tx = await getTransaction(client, { hash: txReceipt.transactionHash })\n\tawait estimateGas(client, { account: tx.from, to: tx.to, data: tx.input, value: tx.value })\n\n\t// TODO: we should use that for better accuracy (fork the block to reexecute the tx) but rn this errors with:\n\t// State root for 0x... does not exist\n\t// const forkClient = createClient({\n\t//   transport: createTevmTransport({\n\t//     fork: {\n\t//       transport: client\n\t//     }\n\t//   })\n\t// })\n\t// const callTraceResult = await forkClient.transport.tevm.request({\n\t//   method: \"debug_traceTransaction\",\n\t//   params: [{ transactionHash: txReceipt.transactionHash }],\n\t// });\n\n\t// // Then something like\n\t// if (callTraceResult.trace.failed) {\n\t//   throw callTraceResult.execResult.exceptionError // add callTraceResult.trace.returnValue so we can decode\n\t// }\n}\n\n// End goal here is to extract either:\n// - ContractFunctionRevertedError (.data): decoded data, e.g. from viem `writeContract` or tevm `contractHandler`\n// - RevertError (.raw): raw data from tevm after we failed to decode it in `contractHandler`\n// - Error (.data.data): raw data from tevm `callProcedure` that wasn't decoded (could be from viem `sendTransaction` or `estimateGas` as well)\nconst extractRevertData = (error: unknown): DecodeErrorResultReturnType | Hex | undefined => {\n\tif (!error) return undefined\n\n\tconst isRevertError = (err: unknown): boolean => {\n\t\treturn (\n\t\t\t(err instanceof ViemBaseError || err instanceof BaseError) &&\n\t\t\terr.message.includes('execution reverted') &&\n\t\t\t('data' in err || 'raw' in err)\n\t\t)\n\t}\n\n\tconst revertError = (\n\t\tisRevertError(error)\n\t\t\t? error\n\t\t\t: error instanceof ViemBaseError || error instanceof BaseError\n\t\t\t\t? error.walk?.(isRevertError) || error.walk?.()\n\t\t\t\t: {}\n\t) as ContractFunctionRevertedError | RevertError | { data: { data: Hex } } | undefined\n\n\tif (!revertError) return undefined\n\n\tconst revertData = ('data' in revertError && !!revertError.data ? revertError.data : revertError) as\n\t\t| DecodeErrorResultReturnType\n\t\t| { data: Hex }\n\treturn ('data' in revertData ? revertData.data : revertData) ?? ('raw' in revertError ? revertError.raw : undefined)\n}\n\nconst REVERT_STRING_SELECTOR = '0x08c379a0'\n\nconst extractRevertStringAndReason = (rawData?: Hex, decodedData?: DecodeErrorResultReturnType) => {\n\tconst revertString = decodeRevertString(rawData, decodedData)\n\tif (revertString) return { revertString, revertReason: `revert: ${revertString}` }\n\n\tconst revertReason = formatNonStringRevertReason(rawData, decodedData)\n\tif (revertReason) return { revertString: undefined, revertReason }\n\n\treturn { revertString: undefined, revertReason: undefined }\n}\n\nconst decodeRevertString = (rawData?: Hex, decodedData?: DecodeErrorResultReturnType) => {\n\tif (decodedData && decodedData.errorName === 'Error') return decodedData.args?.[0] as string\n\tif (rawData && rawData !== '0x' && rawData.startsWith(REVERT_STRING_SELECTOR)) {\n\t\tconst rawDataString = `0x${rawData.slice(REVERT_STRING_SELECTOR.length)}` as Hex\n\t\treturn decodeAbiParameters([{ type: 'string' }], rawDataString)[0]\n\t}\n\n\treturn undefined\n}\n\nconst formatNonStringRevertReason = (rawData?: Hex, decodedData?: DecodeErrorResultReturnType) => {\n\tif (decodedData) {\n\t\t// if (decodedData.errorName === 'Error') return `revert: ${decodedData.args?.[0]}`\n\t\tconst prefix = `custom error: ${decodedData.errorName}`\n\t\tconst argTypes = (decodedData.abiItem as AbiError).inputs.map((i) => i.type).join(', ')\n\t\tif (!decodedData.args) return `${prefix}(${argTypes})`\n\n\t\tconst argValues = Array.isArray(decodedData.args)\n\t\t\t? decodedData.args.map((v) => (typeof v === 'bigint' ? v.toString() : JSON.stringify(v))).join(', ')\n\t\t\t: String(decodedData.args)\n\t\treturn `${prefix}(${argTypes})\\n${Array.from({ length: prefix.length })\n\t\t\t.map(() => ' ')\n\t\t\t.join('')}(${argValues})`\n\t}\n\n\tif (!rawData || rawData === '0x') return undefined\n\treturn `custom error: ${rawData.slice(0, 10)}`\n}\n","import { type Client } from 'viem'\nimport type { ContainsTransactionAny } from '../../common/types.js'\nimport { handleTransaction } from './handleTransaction.js'\n\n// Vitest-style matcher function\n// TODO: when we do With... we want to be able to say for instance \"Expected tx to revert with error ... but instead it reverted with error ...\"\nexport const toBeReverted = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient?: Client,\n) => {\n\tconst { error, isRevert, isError, revertReason } = await handleTransaction(received, { client })\n\n\tif (isError) {\n\t\tthrow new Error('Expected transaction to be or not be reverted, but a different error was thrown', { cause: error })\n\t}\n\n\treturn {\n\t\tpass: isRevert,\n\t\tmessage: () =>\n\t\t\tisRevert\n\t\t\t\t? `Expected transaction not to be reverted, but it reverted${revertReason ? ` with:\\n\\n${revertReason}` : ' without reason'}`\n\t\t\t\t: `Expected transaction to be reverted, but it didn't`,\n\t}\n}\n","import type { AbiError } from 'abitype'\nimport { AbiItem } from 'ox'\nimport type { Abi, Client, ContractErrorName, Hex } from 'viem'\nimport { isHex } from 'viem'\nimport type { MatcherResult } from '../../chainable/types.js'\nimport type { ContainsContractAbi, ContainsTransactionAny } from '../../common/types.js'\nimport { handleTransaction } from './handleTransaction.js'\nimport type { ToBeRevertedWithState } from './types.js'\n\nexport const toBeRevertedWithError = async <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTErrorName extends TAbi extends Abi ? ContractErrorName<TAbi> : never = TAbi extends Abi\n\t\t? ContractErrorName<TAbi>\n\t\t: never,\n\tTContract extends TAbi extends Abi ? ContainsContractAbi<TAbi> : never = TAbi extends Abi\n\t\t? ContainsContractAbi<TAbi>\n\t\t: never,\n>(\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client,\n\tcontractOrErrorIdentifier: TContract | Hex | string,\n\terrorName?: TErrorName,\n): Promise<MatcherResult<ToBeRevertedWithState>> => {\n\tconst { error, isRevert, isError, revertReason, decodedRevertData, rawRevertData } = await handleTransaction(\n\t\treceived,\n\t\t{ client },\n\t)\n\n\tif (isError) {\n\t\tthrow new Error('Expected transaction to be or not be reverted, but a different error was thrown', { cause: error })\n\t}\n\n\tconst actualSelector = decodedRevertData\n\t\t? AbiItem.getSelector(decodedRevertData.abiItem)\n\t\t: rawRevertData?.slice(0, 10)\n\tif (actualSelector === undefined) throw new Error('Could not get selector from revert data')\n\n\t// Handle error signature or selector\n\tif (typeof contractOrErrorIdentifier === 'string') {\n\t\tconst errorSelector = isHex(contractOrErrorIdentifier)\n\t\t\t? contractOrErrorIdentifier\n\t\t\t: AbiItem.getSelector(\n\t\t\t\t\tcontractOrErrorIdentifier.startsWith('error')\n\t\t\t\t\t\t? contractOrErrorIdentifier\n\t\t\t\t\t\t: `error ${contractOrErrorIdentifier}`,\n\t\t\t\t)\n\n\t\tconst pass = isRevert && actualSelector === errorSelector\n\n\t\treturn {\n\t\t\tpass,\n\t\t\tactual: actualSelector,\n\t\t\texpected: errorSelector,\n\t\t\tmessage: () =>\n\t\t\t\tpass\n\t\t\t\t\t? `Expected transaction not to be reverted with ${contractOrErrorIdentifier.startsWith('0x') ? 'selector' : 'signature'} ${contractOrErrorIdentifier}, but it reverted ${revertReason ? `with:\\n\\n${revertReason}` : 'without reason'}`\n\t\t\t\t\t: `Expected transaction to be reverted with ${contractOrErrorIdentifier.startsWith('0x') ? 'selector' : 'signature'} ${contractOrErrorIdentifier}`,\n\t\t\tstate: {\n\t\t\t\tdecodedRevertData,\n\t\t\t\trawRevertData,\n\t\t\t},\n\t\t}\n\t}\n\n\t// Contract + error name case\n\tif (typeof errorName !== 'string') throw new Error('You need to provide an error name as a second argument')\n\tconst contract = contractOrErrorIdentifier\n\tconst errorAbi = contract.abi.find((item): item is AbiError => item.type === 'error' && item.name === errorName)\n\n\tif (!errorAbi)\n\t\tthrow new Error(\n\t\t\t`Error ${errorName} not found in contract ABI. Please make sure you've compiled the latest version before running the test.`,\n\t\t)\n\n\tconst pass = isRevert && actualSelector === AbiItem.getSelector(errorAbi)\n\n\treturn {\n\t\tpass,\n\t\tactual: `error ${decodedRevertData?.errorName ?? rawRevertData?.slice(0, 10)}`,\n\t\texpected: `error ${errorName}`,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected transaction not to be reverted with error ${errorName}, but it reverted ${revertReason ? `with:\\n\\n${revertReason}` : 'without reason'}`\n\t\t\t\t: `Expected transaction to be reverted with error ${errorName}`,\n\t\tstate: {\n\t\t\tdecodedRevertData,\n\t\t\trawRevertData,\n\t\t\tcontract,\n\t\t},\n\t}\n}\n","import type { Client } from 'viem'\nimport type { ContainsTransactionAny } from '../../common/types.js'\nimport { handleTransaction } from './handleTransaction.js'\n\nexport const toBeRevertedWithString = async (\n\treceived: ContainsTransactionAny | Promise<ContainsTransactionAny>,\n\tclient: Client,\n\texpectedRevertString: string,\n) => {\n\tconst { error, isRevert, isError, revertString, revertReason } = await handleTransaction(received, { client })\n\n\tif (isError) {\n\t\tthrow new Error('Expected transaction to be or not be reverted, but a different error was thrown', { cause: error })\n\t}\n\n\tconst pass = isRevert && revertString !== undefined && revertString === expectedRevertString\n\n\treturn {\n\t\tpass,\n\t\tactual: revertString,\n\t\texpected: expectedRevertString,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected transaction not to be reverted with revert string, but it reverted ${revertReason ? `with:\\n\\n${revertReason}` : 'without reason'}`\n\t\t\t\t: `Expected transaction to be reverted with revert string ${expectedRevertString}`,\n\t}\n}\n","import type { AbiParameter, AbiParametersToPrimitiveTypes, ExtractAbiError } from 'abitype'\nimport { type Abi, type ContractErrorName, decodeErrorResult } from 'viem'\nimport { parseChainArgs } from '../../chainable/chainable.js'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { ToBeRevertedWithState } from './types.js'\n\nexport const withErrorArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTErrorName extends TAbi extends Abi ? ContractErrorName<TAbi> : never = TAbi extends Abi\n\t\t? ContractErrorName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiParameter[] = TAbi extends Abi\n\t\t? ExtractAbiError<TAbi, TErrorName> extends { inputs: infer U extends readonly AbiParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\t...argsAndChainState: readonly [...AbiParametersToPrimitiveTypes<TInputs>, ChainState<unknown, ToBeRevertedWithState>]\n): MatcherResult => {\n\tconst {\n\t\targs,\n\t\tchainState: { previousState },\n\t} = parseChainArgs<unknown, ToBeRevertedWithState>(argsAndChainState)\n\n\tif (!previousState || !('contract' in previousState))\n\t\tthrow new Error('withErrorArgs() requires a contract with abi and error name')\n\n\tconst { contract, decodedRevertData, rawRevertData } = previousState\n\tconst decodedRevert =\n\t\tdecodedRevertData ?? (rawRevertData ? decodeErrorResult({ abi: contract?.abi, data: rawRevertData }) : undefined)\n\tconst decodedArgs = decodedRevert?.args\n\tif (!decodedArgs) throw new Error('Could not decode revert data')\n\n\tconst argsMatched = args.length <= decodedArgs.length && args.every((arg, i) => decodedArgs[i] === arg)\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: decodedArgs,\n\t\texpected: args,\n\t\tmessage: () =>\n\t\t\targsMatched\n\t\t\t\t? 'Expected transaction not to revert with the specified arguments'\n\t\t\t\t: 'Expected transaction to revert with the specified arguments',\n\t}\n}\n","import type { AbiError, AbiParameter, ExtractAbiError } from 'abitype'\nimport { type Abi, type ContractErrorName, decodeErrorResult } from 'viem'\nimport { assert } from 'vitest'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs } from '../../common/types.js'\nimport type { ToBeRevertedWithState } from './types.js'\n\nexport const withErrorNamedArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTErrorName extends TAbi extends Abi ? ContractErrorName<TAbi> : never = TAbi extends Abi\n\t\t? ContractErrorName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiParameter[] = TAbi extends Abi\n\t\t? ExtractAbiError<TAbi, TErrorName> extends { inputs: infer U extends readonly AbiParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\texpectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>,\n\tchainState?: ChainState<unknown, ToBeRevertedWithState>,\n): MatcherResult => {\n\tassert(chainState, 'Internal error: no chain state found')\n\tconst { previousState } = chainState\n\n\tif (!previousState || !('contract' in previousState))\n\t\tthrow new Error('withErrorNamedArgs() requires a contract with abi and error name')\n\n\tconst { contract, decodedRevertData, rawRevertData } = previousState\n\tconst decodedRevert =\n\t\tdecodedRevertData ?? (rawRevertData ? decodeErrorResult({ abi: contract?.abi, data: rawRevertData }) : undefined)\n\tconst decodedArgs = decodedRevert?.args\n\tif (!decodedArgs) throw new Error('Could not decode revert data')\n\tconst namedArgs = (decodedRevert.abiItem as AbiError).inputs.reduce(\n\t\t(acc, input, index) => {\n\t\t\tacc[input.name ?? ''] = decodedArgs[index]\n\t\t\treturn acc\n\t\t},\n\t\t{} as Record<string, unknown>,\n\t)\n\n\tconst argsMatched = Object.keys(expectedArgs).every(\n\t\t(key) => key in namedArgs && namedArgs[key] === expectedArgs[key as keyof typeof expectedArgs],\n\t)\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: namedArgs,\n\t\texpected: expectedArgs,\n\t\tmessage: () =>\n\t\t\targsMatched\n\t\t\t\t? 'Expected transaction not to revert with the specified arguments'\n\t\t\t\t: 'Expected transaction to revert with the specified arguments',\n\t}\n}\n","import type { AbiParametersToPrimitiveTypes, ExtractAbiError } from 'abitype'\nimport type { Abi, AbiParameter, Client, ContractErrorName, Hex } from 'viem'\nimport { createChainableFromVitest } from '../../chainable/chainable.js'\nimport type { ChainableAssertion } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs, ContainsContractAbi } from '../../common/types.js'\nimport { toBeReverted } from './toBeReverted.js'\nimport { toBeRevertedWithError } from './toBeRevertedWithError.js'\nimport { toBeRevertedWithString } from './toBeRevertedWithString.js'\nimport { withErrorArgs } from './withErrorArgs.js'\nimport { withErrorNamedArgs } from './withErrorNamedArgs.js'\n\n// Create chainable matchers\nexport const toBeRevertedWithErrorChainable = createChainableFromVitest({\n\tname: 'toBeRevertedWithError' as const,\n\tvitestMatcher: toBeRevertedWithError,\n})\n\nexport const withErrorArgsChainable = createChainableFromVitest({\n\tname: 'withErrorArgs' as const,\n\tvitestMatcher: withErrorArgs,\n})\n\nexport const withErrorNamedArgsChainable = createChainableFromVitest({\n\tname: 'withErrorNamedArgs' as const,\n\tvitestMatcher: withErrorNamedArgs,\n})\n\n// Register the chainable matchers\nexport const chainableErrorMatchers = {\n\ttoBeRevertedWithError: toBeRevertedWithErrorChainable,\n\twithErrorArgs: withErrorArgsChainable,\n\twithErrorNamedArgs: withErrorNamedArgsChainable,\n}\n\nexport { toBeReverted, toBeRevertedWithString, toBeRevertedWithError, withErrorArgs, withErrorNamedArgs }\n\n// TypeScript declaration for vitest\nexport interface ErrorMatchers {\n\t/**\n\t * Asserts that a transaction reverted for any reason.\n\t * This includes string reverts, custom errors, and panics.\n\t *\n\t * @param client - Optional client for transaction execution\n\t *\n\t * @example\n\t * ```typescript\n\t * // Test any revert\n\t * await expect(writeContract(client, contract.write.failingFunction()))\n\t *   .toBeReverted(client)\n\t *\n\t * // Works with .not for successful transactions\n\t * await expect(writeContract(client, contract.write.successfulFunction()))\n\t *   .not.toBeReverted(client)\n\t * ```\n\t *\n\t * @see {@link toBeRevertedWithString} for specific revert messages\n\t * @see {@link toBeRevertedWithError} for custom errors\n\t */\n\ttoBeReverted(client?: Client): Promise<void>\n\n\t/**\n\t * Asserts that a transaction reverted with a specific revert string.\n\t * Use this for `revert(\"message\")` style reverts.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param revertString - Expected exact revert message\n\t *\n\t * @example\n\t * ```typescript\n\t * // Contract: require(amount > 0, \"Amount must be positive\")\n\t * await expect(writeContract(client, contract.write.transfer(to, 0n)))\n\t *   .toBeRevertedWithString(client, 'Amount must be positive')\n\t *\n\t * // Note: Message must match exactly\n\t * await expect(transaction)\n\t *   .not.toBeRevertedWithString(client, 'Different message')\n\t * ```\n\t *\n\t * @see {@link toBeRevertedWithError} for custom errors\n\t */\n\ttoBeRevertedWithString(client: Client, revertString: string): Promise<void>\n\n\t/**\n\t * Asserts that a transaction reverted with a specific custom error.\n\t * Use this for custom error types, not `revert()` strings.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param contract - Contract object with ABI containing the error\n\t * @param errorName - Name of the custom error in the ABI\n\t *\n\t * @example\n\t * ```typescript\n\t * // error InsufficientBalance(uint256 available, uint256 required);\n\t * await expect(writeContract(client, contract.write.transfer(to, 1000n)))\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *\n\t * // Chain with argument assertions\n\t * await expect(writeContract(client, contract.write.transfer(to, 1000n)))\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *   .withErrorArgs(50n, 1000n)\n\t *\n\t * // Chain with argument assertions by name (partial matching)\n\t * await expect(writeContract(client, contract.write.transfer(to, 1000n)))\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *   .withErrorNamedArgs({ required: 1000n })\n\t * ```\n\t *\n\t * @see {@link withErrorArgs} to test error arguments\n\t * @see {@link withErrorNamedArgs} to test error arguments by name\n\t * @see {@link toBeRevertedWithString} for revert strings\n\t */\n\ttoBeRevertedWithError<TAbi extends Abi, TErrorName extends ContractErrorName<TAbi>>(\n\t\tclient: Client,\n\t\tcontract: ContainsContractAbi<TAbi>,\n\t\terrorName: TErrorName,\n\t): Promise<ErrorAssertionWithContract<TAbi, TErrorName>> & ErrorAssertionWithContract<TAbi, TErrorName>\n\n\t/**\n\t * Asserts that a transaction reverted with an error matching the signature.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param errorName - Error signature string (e.g., \"InsufficientBalance(uint256,uint256)\")\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(transaction)\n\t *   .toBeRevertedWithError(client, 'InsufficientBalance(uint256,uint256)')\n\t *   .withErrorArgs(50n, 1000n)\n\t * ```\n\t */\n\ttoBeRevertedWithError(client: Client, errorName: string): ChainableAssertion\n\n\t/**\n\t * Asserts that a transaction reverted with an error matching the selector.\n\t *\n\t * @param client - Client for transaction execution\n\t * @param errorSelector - Error selector (4-byte hex)\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(transaction)\n\t *   .toBeRevertedWithError(client, '0x356680b7') // InsufficientBalance selector\n\t * ```\n\t */\n\ttoBeRevertedWithError(client: Client, errorSelector: Hex): ChainableAssertion\n}\n\n// Only-after toBeRevertedWithError assertion type\ninterface ErrorAssertionWithContract<TAbi extends Abi, TErrorName extends ContractErrorName<TAbi>> {\n\t/**\n\t * Chains with toBeRevertedWithError to assert error arguments in positional order.\n\t * Arguments must match exactly in the order they appear in the error.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Expected arguments in order\n\t *\n\t * @example\n\t * ```typescript\n\t * // error InsufficientBalance(uint256 available, uint256 required);\n\t * await expect(transaction)\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *   .withErrorArgs(\n\t *     50n,   // available\n\t *     1000n  // required\n\t *   )\n\t * ```\n\t *\n\t * @see {@link withErrorNamedArgs} for partial matching by name\n\t */\n\twithErrorArgs<\n\t\tTInputs extends readonly AbiParameter[] = ExtractAbiError<TAbi, TErrorName> extends {\n\t\t\tinputs: infer U extends readonly AbiParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiParameter[],\n\t>(...expectedArgs: AbiParametersToPrimitiveTypes<TInputs>): ChainableAssertion\n\n\t/**\n\t * Chains with toBeRevertedWithError to assert error arguments by name.\n\t * Supports partial matching - only specified arguments are checked.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Object with expected named arguments (partial)\n\t *\n\t * @example\n\t * ```typescript\n\t * // Check only specific arguments\n\t * await expect(transaction)\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *   .withErrorNamedArgs({ required: 1000n })\n\t *\n\t * // Check all arguments\n\t * await expect(transaction)\n\t *   .toBeRevertedWithError(client, contract, 'InsufficientBalance')\n\t *   .withErrorNamedArgs({\n\t *     available: 50n,\n\t *     required: 1000n\n\t *   })\n\t * ```\n\t *\n\t * @see {@link withErrorArgs} for positional argument matching\n\t */\n\twithErrorNamedArgs<\n\t\tTInputs extends readonly AbiParameter[] = ExtractAbiError<TAbi, TErrorName> extends {\n\t\t\tinputs: infer U extends readonly AbiParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiParameter[],\n\t>(expectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>): ChainableAssertion\n}\n","import { AbiItem } from 'ox'\nimport type { Abi, AbiEvent, ContractEventName, Hex } from 'viem'\nimport { decodeEventLog, encodeEventTopics, getAddress, isHex } from 'viem'\nimport type { MatcherResult } from '../../chainable/types.js'\nimport type { ContainsContractAbi, ContainsTransactionLogs } from '../../common/types.js'\nimport type { ToEmitState } from './types.js'\n\n// Vitest-style matcher function\nexport const toEmit = async <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTEventName extends TAbi extends Abi ? ContractEventName<TAbi> : never = TAbi extends Abi\n\t\t? ContractEventName<TAbi>\n\t\t: never,\n\tTContract extends TAbi extends Abi ? ContainsContractAbi<TAbi> : never = TAbi extends Abi\n\t\t? ContainsContractAbi<TAbi>\n\t\t: never,\n>(\n\treceived: ContainsTransactionLogs | Promise<ContainsTransactionLogs>,\n\tcontractOrEventIdentifier: TContract | Hex | string,\n\teventName?: TEventName,\n): Promise<MatcherResult<ToEmitState>> => {\n\tconst logs = (await received).logs\n\n\t// Handle event signature or selector\n\tif (typeof contractOrEventIdentifier === 'string') {\n\t\tconst eventSelector = isHex(contractOrEventIdentifier)\n\t\t\t? contractOrEventIdentifier\n\t\t\t: AbiItem.getSelector(contractOrEventIdentifier)\n\n\t\tconst matchedLogs = logs.filter((log) => log.topics[0]?.startsWith(eventSelector))\n\t\tconst pass = matchedLogs.length > 0\n\n\t\treturn {\n\t\t\tpass,\n\t\t\tactual: logs.map((log) => log.topics[0]).filter(Boolean),\n\t\t\texpected: `logs containing event selector ${eventSelector}`,\n\t\t\tmessage: () =>\n\t\t\t\tpass\n\t\t\t\t\t? `Expected event ${contractOrEventIdentifier} not to be emitted`\n\t\t\t\t\t: `Expected event ${contractOrEventIdentifier} to be emitted`,\n\t\t\tstate: {\n\t\t\t\tmatchedLogs,\n\t\t\t\teventIdentifier: contractOrEventIdentifier,\n\t\t\t},\n\t\t}\n\t}\n\n\t// Contract + event name case\n\tif (!eventName) throw new Error('You need to provide an event name as a third argument')\n\tconst contract = contractOrEventIdentifier\n\tconst eventAbi = contract.abi.find((item): item is AbiEvent => item.type === 'event' && item.name === eventName)\n\n\tif (!eventAbi)\n\t\tthrow new Error(\n\t\t\t`Event ${eventName} not found in contract ABI. Please make sure you've compiled the latest version before running the test.`,\n\t\t)\n\n\tconst eventTopic = encodeEventTopics({\n\t\tabi: contract.abi,\n\t\teventName: eventName,\n\t})[0]\n\n\tconst matchedLogs = logs.filter((log) => {\n\t\tconst topicMatches = log.topics[0] === eventTopic\n\t\tconst addressMatches = contract?.address ? getAddress(log.address) === getAddress(contract.address) : true\n\t\treturn topicMatches && addressMatches\n\t})\n\n\tconst pass = matchedLogs.length > 0\n\n\t// Create meaningful actual/expected values for the diff\n\tconst actualEvents = logs\n\t\t.filter((log) => (contract?.address ? getAddress(log.address) === getAddress(contract.address) : true))\n\t\t.map((log) => {\n\t\t\ttry {\n\t\t\t\tconst decoded = decodeEventLog({\n\t\t\t\t\tabi: contract.abi,\n\t\t\t\t\tdata: log.data,\n\t\t\t\t\ttopics: log.topics,\n\t\t\t\t})\n\t\t\t\treturn `${decoded.eventName}(${decoded.args ? Object.values(decoded.args).join(', ') : ''})`\n\t\t\t} catch {\n\t\t\t\treturn `UnknownEvent(${log.topics[0]})`\n\t\t\t}\n\t\t})\n\n\treturn {\n\t\tpass,\n\t\tactual: actualEvents,\n\t\texpected: `event \"${eventName}\" to be emitted`,\n\t\tmessage: () =>\n\t\t\tpass ? `Expected event ${eventName} not to be emitted` : `Expected event ${eventName} to be emitted`,\n\t\tstate: {\n\t\t\tmatchedLogs,\n\t\t\tcontract,\n\t\t\teventName,\n\t\t\teventAbi,\n\t\t},\n\t}\n}\n","import type { AbiEventParameter, AbiParametersToPrimitiveTypes, ExtractAbiEvent } from 'abitype'\nimport { type Abi, type ContractEventName, decodeEventLog } from 'viem'\nimport { parseChainArgs } from '../../chainable/chainable.js'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { ToEmitState } from './types.js'\n\nexport const withEventArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTEventName extends TAbi extends Abi ? ContractEventName<TAbi> : never = TAbi extends Abi\n\t\t? ContractEventName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiEventParameter[] = TAbi extends Abi\n\t\t? ExtractAbiEvent<TAbi, TEventName> extends { inputs: infer U extends readonly AbiEventParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiEventParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\t...argsAndChainState: readonly [...AbiParametersToPrimitiveTypes<TInputs>, ChainState<unknown, ToEmitState>]\n): MatcherResult => {\n\tconst {\n\t\targs,\n\t\tchainState: { previousState },\n\t} = parseChainArgs<unknown, ToEmitState>(argsAndChainState)\n\n\tif (!previousState || !('contract' in previousState))\n\t\tthrow new Error('withEventArgs() requires a contract with abi and event name')\n\n\tconst { matchedLogs, contract, eventName } = previousState\n\n\t// Try to decode and match arguments for each matched log\n\tlet argsMatched = false\n\tconst actualArgsFromLogs: unknown[][] = []\n\n\t// At this point since we provided an abi & event name we know for sure that the matched logs correspond to the event we're looking for\n\tfor (const log of matchedLogs) {\n\t\tconst decodedLog = decodeEventLog({\n\t\t\tabi: contract.abi,\n\t\t\tdata: log.data,\n\t\t\ttopics: log.topics,\n\t\t\teventName: eventName,\n\t\t})\n\n\t\tconst decodedArgs = Object.values(decodedLog.args as unknown as Record<string, unknown>)\n\t\tif (!decodedArgs.length) continue\n\t\tactualArgsFromLogs.push(decodedArgs)\n\n\t\tif (decodedArgs.length === args.length) {\n\t\t\tconst allArgsMatch = decodedArgs.every((actual, i) => actual === args[i])\n\t\t\tif (allArgsMatch) {\n\t\t\t\targsMatched = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: actualArgsFromLogs.flat(),\n\t\texpected: args,\n\t\tmessage: () => {\n\t\t\tif (argsMatched) return `Expected event ${eventName} not to be emitted with the specified arguments`\n\t\t\treturn `Expected event ${eventName} to be emitted with the specified arguments, but it wasn't found in any of the ${matchedLogs?.length ?? 0} emitted events`\n\t\t},\n\t}\n}\n","import type { AbiEventParameter, ExtractAbiEvent } from 'abitype'\nimport { type Abi, type ContractEventName, decodeEventLog } from 'viem'\nimport { assert } from 'vitest'\nimport type { ChainState, MatcherResult } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs } from '../../common/types.js'\nimport type { ToEmitState } from './types.js'\n\nexport const withEventNamedArgs = <\n\tTAbi extends Abi | undefined = Abi | undefined,\n\tTEventName extends TAbi extends Abi ? ContractEventName<TAbi> : never = TAbi extends Abi\n\t\t? ContractEventName<TAbi>\n\t\t: never,\n\tTInputs extends readonly AbiEventParameter[] = TAbi extends Abi\n\t\t? ExtractAbiEvent<TAbi, TEventName> extends { inputs: infer U extends readonly AbiEventParameter[] }\n\t\t\t? U\n\t\t\t: readonly AbiEventParameter[]\n\t\t: never,\n>(\n\t_received: unknown,\n\texpectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>,\n\tchainState?: ChainState<unknown, ToEmitState<TAbi, TEventName>>,\n): MatcherResult => {\n\tassert(chainState, 'Internal error: no chain state found')\n\tconst { previousState } = chainState\n\n\tif (!previousState || !('contract' in previousState))\n\t\tthrow new Error('withEventNamedArgs() requires a contract with abi and event name')\n\n\tconst { matchedLogs, contract, eventName } = previousState\n\n\tlet argsMatched = false\n\tconst actualNamedArgsFromLogs: Record<string, unknown>[] = []\n\n\tfor (const log of matchedLogs) {\n\t\tconst decodedLog = decodeEventLog({\n\t\t\tabi: contract.abi,\n\t\t\tdata: log.data,\n\t\t\ttopics: log.topics,\n\t\t\teventName: eventName,\n\t\t})\n\n\t\tconst decodedArgs = decodedLog.args as unknown as Record<string, unknown>\n\t\tactualNamedArgsFromLogs.push(decodedArgs)\n\n\t\t// Check if all expected args match\n\t\tconst allArgsMatch = Object.entries(expectedArgs).every(\n\t\t\t([argName, expectedValue]) => decodedArgs[argName] === expectedValue,\n\t\t)\n\t\tif (allArgsMatch) {\n\t\t\targsMatched = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn {\n\t\tpass: argsMatched,\n\t\tactual: actualNamedArgsFromLogs,\n\t\texpected: expectedArgs,\n\t\tmessage: () => {\n\t\t\tif (argsMatched) return `Expected event ${eventName} not to be emitted with the specified named arguments`\n\t\t\treturn `Expected event ${eventName} to be emitted with the specified named arguments, but it wasn't found in any of the ${matchedLogs?.length ?? 0} emitted events`\n\t\t},\n\t}\n}\n","import type { AbiEventParameter, AbiParametersToPrimitiveTypes, ExtractAbiEvent } from 'abitype'\nimport type { Abi, ContractEventName, Hex } from 'viem'\nimport { createChainableFromVitest } from '../../chainable/chainable.js'\nimport type { ChainableAssertion } from '../../chainable/types.js'\nimport type { AbiInputsToNamedArgs, ContainsContractAbi } from '../../common/types.js'\nimport { toEmit } from './toEmit.js'\nimport { withEventArgs } from './withEventArgs.js'\nimport { withEventNamedArgs } from './withEventNamedArgs.js'\n\n// Create chainable matchers\nexport const toEmitChainable = createChainableFromVitest({\n\tname: 'toEmit' as const,\n\tvitestMatcher: toEmit,\n})\n\nexport const withEventArgsChainable = createChainableFromVitest({\n\tname: 'withEventArgs' as const,\n\tvitestMatcher: withEventArgs,\n})\n\nexport const withEventNamedArgsChainable = createChainableFromVitest({\n\tname: 'withEventNamedArgs' as const,\n\tvitestMatcher: withEventNamedArgs,\n})\n\n// Register the chainable matchers with the new structure\nexport const chainableEventMatchers = {\n\ttoEmit: toEmitChainable,\n\twithEventArgs: withEventArgsChainable,\n\twithEventNamedArgs: withEventNamedArgsChainable,\n}\n\nexport { toEmit, withEventArgs, withEventNamedArgs }\n\n// TypeScript declaration for vitest\nexport interface EmitMatchers {\n\t/**\n\t * Asserts that a transaction emitted a specific event.\n\t * Can be used with contract objects, event signatures, or selectors.\n\t *\n\t * @param contract - Contract object with ABI and address\n\t * @param eventName - Name of the event in the ABI\n\t *\n\t * @example\n\t * ```typescript\n\t * // Using contract object\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *\n\t * // Chain with argument assertions\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *   .withEventArgs(from, to, 100n)\n\t *\n\t * // Chain with argument assertions by name (partial matching)\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *   .withEventNamedArgs({ to })\n\t * ```\n\t *\n\t * @see {@link withEventArgs} to test event arguments positionally\n\t * @see {@link withEventNamedArgs} to test event arguments by name\n\t */\n\ttoEmit<TAbi extends Abi, TEventName extends ContractEventName<TAbi>>(\n\t\tcontract: ContainsContractAbi<TAbi>,\n\t\teventName: TEventName,\n\t): Promise<EmitAssertionWithContract<TAbi, TEventName>> & EmitAssertionWithContract<TAbi, TEventName>\n\n\t/**\n\t * Asserts that a transaction emitted an event matching the signature.\n\t *\n\t * @param eventSignature - Event signature string (e.g., \"Transfer(address,address,uint256)\")\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(txHash)\n\t *   .toEmit('Transfer(address,address,uint256)')\n\t *   .withEventArgs(from, to, amount)\n\t * ```\n\t */\n\ttoEmit(eventSignature: string): ChainableAssertion\n\n\t/**\n\t * Asserts that a transaction emitted an event matching the selector.\n\t *\n\t * @param eventSelector - Event selector (4-byte hex)\n\t *\n\t * @example\n\t * ```typescript\n\t * await expect(txHash)\n\t *   .toEmit('0xddf252ad...') // Transfer event selector\n\t * ```\n\t */\n\ttoEmit(eventSelector: Hex): ChainableAssertion\n}\n\n// Only-after toEmit assertion type\ninterface EmitAssertionWithContract<TAbi extends Abi, TEventName extends ContractEventName<TAbi>> {\n\t/**\n\t * Chains with toEmit to assert event arguments in positional order.\n\t * Arguments must match exactly in the order they appear in the event.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Expected arguments in order\n\t *\n\t * @example\n\t * ```typescript\n\t * // Transfer event: Transfer(address from, address to, uint256 value)\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *   .withEventArgs(\n\t *     '0x742d35Cc6274c36e1019e41D77d0A4aa7D7dE01e', // from\n\t *     '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', // to\n\t *     1000n // value\n\t *   )\n\t * ```\n\t *\n\t * @see {@link withEventNamedArgs} for partial matching by name\n\t */\n\twithEventArgs<\n\t\tTInputs extends readonly AbiEventParameter[] = ExtractAbiEvent<TAbi, TEventName> extends {\n\t\t\tinputs: infer U extends readonly AbiEventParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiEventParameter[],\n\t>(...expectedArgs: AbiParametersToPrimitiveTypes<TInputs>): ChainableAssertion\n\n\t/**\n\t * Chains with toEmit to assert event arguments by name.\n\t * Supports partial matching - only specified arguments are checked.\n\t *\n\t * **Limitation**: Cannot use .not before this method.\n\t *\n\t * @param expectedArgs - Object with expected named arguments (partial)\n\t *\n\t * @example\n\t * ```typescript\n\t * // Check only specific arguments\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *   .withEventNamedArgs({\n\t *     to: recipient,\n\t *     value: 1000n\n\t *   })\n\t *\n\t * // Empty object matches any event of this type\n\t * await expect(txHash)\n\t *   .toEmit(tokenContract, 'Transfer')\n\t *   .withEventNamedArgs({})\n\t * ```\n\t *\n\t * @see {@link withEventArgs} for positional argument matching\n\t */\n\twithEventNamedArgs<\n\t\tTInputs extends readonly AbiEventParameter[] = ExtractAbiEvent<TAbi, TEventName> extends {\n\t\t\tinputs: infer U extends readonly AbiEventParameter[]\n\t\t}\n\t\t\t? U\n\t\t\t: readonly AbiEventParameter[],\n\t>(expectedArgs: Partial<AbiInputsToNamedArgs<TInputs>>): ChainableAssertion\n}\n","import { getAccountHandler } from '@tevm/actions'\nimport { createTevmNode, type TevmNode } from '@tevm/node'\nimport { type Address, type Client, isAddress } from 'viem'\nimport type { ContainsAddress } from '../../common/types.js'\n\n/**\n * Checks if an account is initialized in the TEVM state.\n * An account is considered initialized if it has a nonce, balance, storage root, or code hash.\n *\n * @param {Address | ContainsAddress} received The address or an object containing the address to check.\n * @param {Client} client The TEVM client instance.\n * @returns {Promise<MatcherResult>} The matcher result.\n */\nexport const toBeInitializedAccount = async (received: Address | ContainsAddress, client: Client | TevmNode) => {\n\tconst address = typeof received === 'string' ? received : received.address\n\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\tconst node = 'request' in client ? createTevmNode({ fork: { transport: client } }) : client\n\tconst account = await getAccountHandler(node, { throwOnFail: false })({ address })\n\n\tconst pass = account.errors === undefined\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected account ${address} not to be initialized`\n\t\t\t\t: `Expected account ${address} to be initialized but received:\\n\\n${account.errors?.[0]?.message}`,\n\t\tactual: account,\n\t}\n}\n","import { getAccountHandler } from '@tevm/actions'\nimport { createTevmNode, type TevmNode } from '@tevm/node'\nimport { type Address, type Client, type Hex, isAddress } from 'viem'\nimport type { ContainsAddress } from '../../common/types.js'\nimport type { ExpectedState } from './types.js'\n\nexport const toHaveState = async (\n\treceived: Address | ContainsAddress,\n\tclient: Client | TevmNode,\n\texpectedState: ExpectedState,\n) => {\n\tconst address = typeof received === 'string' ? received : received.address\n\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\tconst node = 'request' in client ? createTevmNode({ fork: { transport: client } }) : client\n\tconst account = await getAccountHandler(node, { throwOnFail: false })({ address, returnStorage: true })\n\n\tif (account.errors) throw new Error(account.errors[0]?.message ?? 'Could not retrieve account')\n\n\tconst { storage = {}, ...state } = expectedState\n\tconst mismatchedKeys: (keyof ExpectedState)[] = []\n\n\t// Check provided state entries (except storage)\n\tObject.entries(state).forEach(([_key, expectedValue]) => {\n\t\tconst key = _key as keyof Omit<ExpectedState, 'storage'>\n\t\tconst actualValue = account[key]\n\t\tif (actualValue !== expectedValue) mismatchedKeys.push(key)\n\t})\n\n\t// Check provided storage entries\n\tfor (const [_slot, expectedValue] of Object.entries(storage)) {\n\t\tconst slot = _slot as Hex\n\t\tconst actualValue = account.storage?.[slot]\n\t\tif (actualValue !== expectedValue) {\n\t\t\tmismatchedKeys.push('storage')\n\t\t\tbreak\n\t\t}\n\t}\n\n\tconst pass = mismatchedKeys.length === 0\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected account ${address} not to have state.`\n\t\t\t\t: `Expected account ${address} to have state but received mismatched state at keys: ${mismatchedKeys.join(', ')}`,\n\t\t// Only show provided keys with their actual values so it's not confusing\n\t\tactual: pass\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\tObject.entries(expectedState)\n\t\t\t\t\t\t\t.filter(([key]) => key !== 'storage')\n\t\t\t\t\t\t\t.map(([key]) => [key, account[key as keyof typeof account] ?? undefined]),\n\t\t\t\t\t),\n\t\t\t\t\t...(Object.keys(expectedState).includes('storage') && expectedState.storage\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstorage: Object.fromEntries(\n\t\t\t\t\t\t\t\t\tObject.entries(expectedState.storage).map(([slot]) => [\n\t\t\t\t\t\t\t\t\t\tslot,\n\t\t\t\t\t\t\t\t\t\taccount.storage?.[slot as Hex] ?? undefined,\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\texpected: pass ? undefined : expectedState,\n\t}\n}\n","import { getAccountHandler } from '@tevm/actions'\nimport { createTevmNode, type TevmNode } from '@tevm/node'\nimport { type Address, type Client, type Hex, isAddress } from 'viem'\nimport type { ContainsAddress } from '../../common/types.js'\nimport type { ExpectedStorage } from './types.js'\n\nexport const toHaveStorageAt = async (\n\treceived: Address | ContainsAddress,\n\tclient: Client | TevmNode,\n\texpectedStorage: ExpectedStorage,\n) => {\n\tconst address = typeof received === 'string' ? received : received.address\n\tif (!isAddress(address)) throw new Error(`Invalid address: ${address}`)\n\n\tconst node = 'request' in client ? createTevmNode({ fork: { transport: client } }) : client\n\tconst account = await getAccountHandler(node, { throwOnFail: false })({ address, returnStorage: true })\n\n\tif (account.errors) throw new Error(account.errors[0]?.message ?? 'Could not retrieve account')\n\n\tconst storageEntries = Array.isArray(expectedStorage) ? expectedStorage : [expectedStorage]\n\tconst mismatchedSlots: Hex[] = []\n\n\t// Check each storage entry\n\tfor (const { slot, value: expectedValue } of storageEntries) {\n\t\tconst actualValue = account.storage?.[slot]\n\t\tif (actualValue !== expectedValue) mismatchedSlots.push(slot)\n\t}\n\n\tconst pass = mismatchedSlots.length === 0\n\n\treturn {\n\t\tpass,\n\t\tmessage: () =>\n\t\t\tpass\n\t\t\t\t? `Expected account ${address} not to have storage values at the specified slots.`\n\t\t\t\t: `Expected account ${address} to have storage values at slots: ${mismatchedSlots.join(', ')}`,\n\t\tactual: pass\n\t\t\t? undefined\n\t\t\t: storageEntries.map(({ slot }) => ({ slot, value: account.storage?.[slot] ?? undefined })),\n\t\texpected: pass ? undefined : storageEntries.map(({ slot, value }) => ({ slot, value })),\n\t}\n}\n","import { type IsAddressOptions, isAddress } from 'viem'\n\n/**\n * Custom Vitest matcher to assert that a value is a valid Ethereum address\n * @param received - The value to test\n * @param opts - Options for address validation (strict checksum by default)\n * @returns Object with pass boolean, message function, and actual/expected for diff\n */\nexport function toBeAddress(received: unknown, opts?: IsAddressOptions) {\n\tconst pass = typeof received === 'string' && isAddress(received, opts)\n\n\treturn {\n\t\tpass,\n\t\tactual: received,\n\t\tmessage: () => {\n\t\t\tif (pass)\n\t\t\t\treturn `Expected ${received} not to be ${opts?.strict !== false ? 'a valid Ethereum address (checksummed)' : 'a valid Ethereum address'}`\n\t\t\t// Default is strict: true, so mention checksum unless explicitly strict: false\n\t\t\treturn `Expected ${received} to be a ${opts?.strict !== false ? 'valid Ethereum address (checksummed)' : 'valid Ethereum address'}`\n\t\t},\n\t}\n}\n","import { isHex } from 'viem'\n\nexport type IsHexOptions = {\n\t/**\n\t * Whether to check for strict hex format or only for 0x prefix\n\t * @default true\n\t */\n\tstrict?: boolean\n\t/**\n\t * Optional expected size in bytes\n\t */\n\tsize?: number\n}\n\n/**\n * Custom Vitest matcher to assert that a value is valid hex\n * @param received - The value to test\n * @param opts - Optional options for hex validation\n * @returns Object with pass boolean, message function, and actual/expected for diff\n */\nexport function toBeHex(received: unknown, opts?: IsHexOptions) {\n\tconst isStringReceived = typeof received === 'string'\n\tconst isValidHex = isStringReceived && isHex(received, opts)\n\tconst receivedSize = isStringReceived ? (received.length - 2) / 2 : 0\n\tconst isValidSize = opts?.size === undefined || receivedSize === opts.size\n\tconst pass = isValidHex && isValidSize\n\n\tconst expectedDescription = pass\n\t\t? 'not a valid hex string'\n\t\t: `a valid hex string${opts?.size ? ` with size ${opts.size} bytes` : ''}`\n\treturn {\n\t\tpass,\n\t\tactual: received,\n\t\tmessage: () => {\n\t\t\tif (pass) return `Expected ${received} not to be ${expectedDescription}`\n\t\t\tif (!isStringReceived) return `Expected ${typeof received} to be a hex string`\n\t\t\tif (!received.startsWith('0x')) return `Expected ${received} to start with \"0x\"`\n\t\t\tif (!isValidHex) return `Expected ${received} to contain only hex characters (0-9, a-f, A-F) after \"0x\"`\n\t\t\tif (!isValidSize) return `Expected ${received} to have ${opts?.size} bytes, but got ${receivedSize} bytes`\n\t\t\treturn `Expected ${received} to be ${expectedDescription}`\n\t\t},\n\t}\n}\n","import { getAddress, isAddress, isAddressEqual } from 'viem'\n\n/**\n * Custom Vitest matcher to assert that two addresses are equal\n * @param received - The first address to compare\n * @param expected - The second address to compare\n * @returns Object with pass boolean, message function, and actual/expected for diff\n */\nexport function toEqualAddress(received: unknown, expected: unknown) {\n\tconst isStringReceived = typeof received === 'string'\n\tconst isStringExpected = typeof expected === 'string'\n\tconst isAddressReceived = isStringReceived && isAddress(received, { strict: false })\n\tconst isAddressExpected = isStringExpected && isAddress(expected, { strict: false })\n\n\tlet pass = false\n\tlet normalizedReceived: string | undefined\n\tlet normalizedExpected: string | undefined\n\n\tif (isAddressReceived && isAddressExpected) {\n\t\ttry {\n\t\t\tnormalizedReceived = getAddress(received)\n\t\t\tnormalizedExpected = getAddress(expected)\n\t\t\tpass = isAddressEqual(received, expected)\n\t\t} catch {\n\t\t\tpass = false\n\t\t}\n\t}\n\n\treturn {\n\t\tpass,\n\t\tactual: normalizedReceived ?? received,\n\t\texpected: normalizedExpected ?? expected,\n\t\tmessage: () => {\n\t\t\tif (pass) return 'Expected addresses not to be equal'\n\t\t\tif (!isStringReceived) return `Expected ${received} to be a string, but got ${typeof received}`\n\t\t\tif (!isStringExpected) return `Expected ${expected} to be a string, but got ${typeof expected}`\n\t\t\tif (!isAddressReceived) return `Expected ${received} to be a valid address`\n\t\t\tif (!isAddressExpected) return `Expected ${expected} to be a valid address`\n\t\t\treturn 'Expected addresses to be equal'\n\t\t},\n\t}\n}\n","import { equalsBytes } from '@tevm/utils'\nimport { type Hex, hexToBytes, isHex, trim } from 'viem'\n\nexport type EqualHexOptions = {\n\t/**\n\t * Whether to compare hex strings exactly as written or normalize them first.\n\t * When false (default), leading zeros are trimmed before byte comparison (e.g., \"0x00123\" equals \"0x123\").\n\t * When true, hex strings must match exactly including leading zeros.\n\t * @default false\n\t */\n\texact?: boolean\n}\n\n/**\n * Custom Vitest matcher to assert that two hex strings are equal (after converting to bytes)\n * @param received - The first hex string to compare\n * @param expected - The second hex string to compare\n * @param opts - Options for comparison behavior\n * @returns Object with pass boolean, message function, and actual/expected for diff\n */\nexport function toEqualHex(received: unknown, expected: unknown, opts?: EqualHexOptions) {\n\tconst isStringReceived = typeof received === 'string'\n\tconst isStringExpected = typeof expected === 'string'\n\n\t// First validate both are valid hex strings\n\tconst isHexReceived = isStringReceived && isHex(received, { strict: true })\n\tconst isHexExpected = isStringExpected && isHex(expected, { strict: true })\n\n\tif (!isHexReceived || !isHexExpected) {\n\t\treturn {\n\t\t\tpass: false,\n\t\t\tactual: received,\n\t\t\texpected: expected,\n\t\t\tmessage: () => {\n\t\t\t\tif (!isStringReceived) return `Expected ${received} to be a string, but got ${typeof received}`\n\t\t\t\tif (!isStringExpected) return `Expected ${expected} to be a string, but got ${typeof expected}`\n\t\t\t\tif (!isHexReceived) return `Expected ${received} to be a valid hex string`\n\t\t\t\tif (!isHexExpected) return `Expected ${expected} to be a valid hex string`\n\t\t\t\treturn 'Expected hex strings to be equal'\n\t\t\t},\n\t\t}\n\t}\n\n\tlet pass: boolean\n\tlet normalizedReceived: Hex\n\tlet normalizedExpected: Hex\n\n\tif (opts?.exact) {\n\t\t// For exact comparison, compare strings directly (case-insensitive)\n\t\tnormalizedReceived = received.toLowerCase() as Hex\n\t\tnormalizedExpected = expected.toLowerCase() as Hex\n\t\tpass = normalizedReceived === normalizedExpected\n\t} else {\n\t\t// For normalized comparison, trim leading zeros and compare bytes\n\t\tnormalizedReceived = trim(received)\n\t\tnormalizedExpected = trim(expected)\n\t\ttry {\n\t\t\tconst receivedBytes = hexToBytes(normalizedReceived)\n\t\t\tconst expectedBytes = hexToBytes(normalizedExpected)\n\t\t\tpass = equalsBytes(receivedBytes, expectedBytes)\n\t\t} catch {\n\t\t\tpass = false\n\t\t}\n\t}\n\n\treturn {\n\t\tpass,\n\t\tactual: normalizedReceived,\n\t\texpected: normalizedExpected,\n\t\tmessage: () => {\n\t\t\tif (pass) return 'Expected hex strings not to be equal'\n\t\t\treturn `Expected hex strings to be equal${opts?.exact ? ' (exact match)' : ' (normalized comparison)'}`\n\t\t},\n\t}\n}\n","import { expect } from 'vitest'\nimport { registerChainableMatchers } from './chainable/chainable.js'\nimport type {\n\tContainsAddress,\n\tContainsContractAbi,\n\tContainsContractAddressAndOptionalAbi,\n\tContainsTransactionAny,\n\tContainsTransactionLogs,\n} from './common/types.js'\nimport {\n\ttype BalanceChange,\n\ttype BalanceMatchers,\n\ttoChangeBalance,\n\ttoChangeBalances,\n\ttoChangeTokenBalance,\n\ttoChangeTokenBalances,\n} from './matchers/balance/index.js'\nimport { type ContractMatchers, chainableContractMatchers } from './matchers/contract/index.js'\nimport {\n\tchainableErrorMatchers,\n\ttype ErrorMatchers,\n\ttoBeReverted,\n\ttoBeRevertedWithString,\n} from './matchers/errors/index.js'\nimport { chainableEventMatchers, type EmitMatchers } from './matchers/events/index.js'\nimport { type StateMatchers, toBeInitializedAccount, toHaveState, toHaveStorageAt } from './matchers/state/index.js'\nimport {\n\ttype EqualHexOptions,\n\ttype IsAddressOptions,\n\ttype IsHexOptions,\n\ttoBeAddress,\n\ttoBeHex,\n\ttoEqualAddress,\n\ttoEqualHex,\n\ttype UtilsMatchers,\n} from './matchers/utils/index.js'\n\nexport type {\n\tBalanceChange,\n\tIsAddressOptions,\n\tIsHexOptions,\n\tEqualHexOptions,\n\tContainsContractAbi,\n\tContainsTransactionLogs,\n\tContainsAddress,\n\tContainsTransactionAny,\n\tContainsContractAddressAndOptionalAbi,\n}\n\nexpect.extend({\n\ttoBeAddress,\n\ttoBeHex,\n\ttoEqualAddress,\n\ttoEqualHex,\n\ttoBeReverted,\n\ttoBeRevertedWithString,\n\ttoBeInitializedAccount,\n\ttoHaveState,\n\ttoHaveStorageAt,\n\ttoChangeBalance,\n\ttoChangeBalances,\n\ttoChangeTokenBalance,\n\ttoChangeTokenBalances,\n})\n\nregisterChainableMatchers(chainableEventMatchers)\nregisterChainableMatchers(chainableErrorMatchers)\nregisterChainableMatchers(chainableContractMatchers)\n\ndeclare module 'vitest' {\n\t// biome-ignore lint/correctness/noUnusedVariables: we need to match exactly the base vitest Assertion type\n\tinterface Assertion<T = any>\n\t\textends UtilsMatchers,\n\t\t\tEmitMatchers,\n\t\t\tErrorMatchers,\n\t\t\tStateMatchers,\n\t\t\tBalanceMatchers,\n\t\t\tContractMatchers {}\n\tinterface AsymmetricMatchersContaining\n\t\textends UtilsMatchers,\n\t\t\tEmitMatchers,\n\t\t\tErrorMatchers,\n\t\t\tStateMatchers,\n\t\t\tBalanceMatchers,\n\t\t\tContractMatchers {}\n}\n"]}