import { Address, Abi } from 'abitype'; import { Hex, Address as Address$1, ContractFunctionName, EncodeFunctionDataParameters, BlockTag, CallParameters, EstimateGasParameters, GetBalanceParameters, GetTransactionParameters, SendRawTransactionParameters, SendTransactionParameters, SignMessageParameters, Chain, DecodeFunctionResultReturnType, Transaction } from 'viem'; /** * Tevm params to put an account into the vm state * @example * // all fields are optional except address * const accountParams: import('@tevm/api').AccountParams = { * account: '0x...', * nonce: 5n, * balance: 9000000000000n, * storageRoot: '0x....', * deployedBytecode: '0x....' * } */ type AccountParams = { /** * Address of account */ address: Address; /** * Nonce to set account to */ nonce?: bigint; /** * Balance to set account to */ balance?: bigint; /** * Contract bytecode to set account to */ deployedBytecode?: Hex; /** * Storage root to set account to */ storageRoot?: Hex; }; /** * Header information of an ethereum block */ type Block = { /** * The block number (height) in the blockchain. */ readonly number: bigint; /** * The address of the miner or validator who mined or validated the block. */ readonly coinbase: Address; /** * The timestamp at which the block was mined or validated. */ readonly timestamp: bigint; /** * The difficulty level of the block (relevant in PoW chains). */ readonly difficulty: bigint; /** * The gas limit for the block, i.e., the maximum amount of gas that can be used by the transactions in the block. */ readonly gasLimit: bigint; /** * (Optional) The base fee per gas in the block, introduced in EIP-1559 for dynamic transaction fee calculation. */ readonly baseFeePerGas?: bigint; /** * The gas price for the block; may be undefined in blocks after EIP-1559. */ readonly blobGasPrice?: bigint; }; /** * Properties shared accross call-like params */ type BaseCallParams = { /** * Set caller to msg.value of less than msg.value * Defaults to false exceipt for when running scripts * where it is set to true */ skipBalance?: boolean; /** * Refund counter. Defaults to `0` */ gasRefund?: bigint; /** * The `block` the `tx` belongs to. If omitted a default blank block will be used. */ block?: Partial; /** * The gas price for the call. Defaults to `0` */ gasPrice?: bigint; /** * The address where the call originated from. Defaults to the zero address. */ origin?: Address$1; /** * The address that ran this code (`msg.sender`). Defaults to the zero address. */ caller?: Address$1; /** * The gas limit for the call. Defaults to `16777215` (`0xffffff`) */ gasLimit?: bigint; /** * The value in ether that is being sent to `opts.address`. Defaults to `0` */ value?: bigint; /** * The call depth. Defaults to `0` */ depth?: number; /** * Addresses to selfdestruct. Defaults to the empty set. */ selfdestruct?: Set; /** * The address of the account that is executing this code (`address(this)`). Defaults to the zero address. */ to?: Address$1; /** * Versioned hashes for each blob in a blob transaction */ blobVersionedHashes?: Hex[]; }; /** * Tevm params to execute a call on the vm * Call is the lowest level method to interact with the vm * and other messages such as contract and script are using call * under the hood * @example * const callParams: import('@tevm/api').CallParams = { * data: '0x...', * bytecode: '0x...', * gasLimit: 420n, * } */ type CallParams = BaseCallParams & { /** * An optional CREATE2 salt. */ salt?: Hex; /** * The input data. */ data?: Hex; /** * The EVM code to run. */ deployedBytecode?: Hex; }; /** * Tevm params to execute a call on a contract */ type ContractParams = ContractFunctionName> = EncodeFunctionDataParameters & BaseCallParams & { /** * The address to call. */ to: Address; }; /** * Tevm params for deploying and running a script */ type ScriptParams = ContractFunctionName> = EncodeFunctionDataParameters & BaseCallParams & { /** * The EVM code to run. */ deployedBytecode: Hex; }; /** * An event filter optionsobject */ type FilterParams = { readonly fromBlock: BlockTag | Hex; readonly toBlock: BlockTag | Hex; readonly address: Address; readonly topics: ReadonlyArray; }; /*** * TODO I didn't update any of these jsdocs */ type EmptyParams = readonly [] | {} | undefined | never; /** * Params taken by `eth_accounts` handler */ type EthAccountsParams = EmptyParams; /** * JSON-RPC request for `eth_blockNumber` procedure */ type EthBlockNumberParams = EmptyParams; /** * JSON-RPC request for `eth_call` procedure */ type EthCallParams = CallParameters; /** * JSON-RPC request for `eth_chainId` procedure */ type EthChainIdParams = EmptyParams; /** * JSON-RPC request for `eth_coinbase` procedure */ type EthCoinbaseParams = EmptyParams; /** * JSON-RPC request for `eth_estimateGas` procedure */ type EthEstimateGasParams = EstimateGasParameters; /** * JSON-RPC request for `eth_hashrate` procedure */ type EthHashrateParams = EmptyParams; /** * JSON-RPC request for `eth_gasPrice` procedure */ type EthGasPriceParams = EmptyParams; /** * JSON-RPC request for `eth_getBalance` procedure */ type EthGetBalanceParams = GetBalanceParameters; /** * JSON-RPC request for `eth_getBlockByHash` procedure */ type EthGetBlockByHashParams = { blockHash: Hex; fullTransactionObjects: boolean; }; /** * JSON-RPC request for `eth_getBlockByNumber` procedure */ type EthGetBlockByNumberParams = { tag: BlockTag | Hex; fullTransactionObjects: boolean; }; /** * JSON-RPC request for `eth_getBlockTransactionCountByHash` procedure */ type EthGetBlockTransactionCountByHashParams = { hash: Hex; }; /** * JSON-RPC request for `eth_getBlockTransactionCountByNumber` procedure */ type EthGetBlockTransactionCountByNumberParams = { tag: BlockTag | Hex; }; /** * JSON-RPC request for `eth_getCode` procedure */ type EthGetCodeParams = { address: Address; tag: BlockTag | Hex; }; /** * JSON-RPC request for `eth_getFilterChanges` procedure */ type EthGetFilterChangesParams = { filterId: Hex; }; /** * JSON-RPC request for `eth_getFilterLogs` procedure */ type EthGetFilterLogsParams = { filterId: Hex; }; /** * JSON-RPC request for `eth_getLogs` procedure */ type EthGetLogsParams = { filterParams: FilterParams; }; /** * JSON-RPC request for `eth_getStorageAt` procedure */ type EthGetStorageAtParams = { address: Address; position: Hex; tag: BlockTag | Hex; }; /** * JSON-RPC request for `eth_getTransactionCount` procedure */ type EthGetTransactionCountParams = { address: Address; tag: BlockTag | Hex; }; /** * JSON-RPC request for `eth_getUncleCountByBlockHash` procedure */ type EthGetUncleCountByBlockHashParams = { hash: Hex; }; /** * JSON-RPC request for `eth_getUncleCountByBlockNumber` procedure */ type EthGetUncleCountByBlockNumberParams = { tag: BlockTag | Hex; }; /** * JSON-RPC request for `eth_getTransactionByHash` procedure */ type EthGetTransactionByHashParams = { data: Hex; }; /** * JSON-RPC request for `eth_getTransactionByBlockHashAndIndex` procedure */ type EthGetTransactionByBlockHashAndIndexParams = { tag: Hex; index: Hex; }; /** * JSON-RPC request for `eth_getTransactionByBlockNumberAndIndex` procedure */ type EthGetTransactionByBlockNumberAndIndexParams = { tag: BlockTag | Hex; index: Hex; }; /** * JSON-RPC request for `eth_getTransactionReceipt` procedure */ type EthGetTransactionReceiptParams = GetTransactionParameters; /** * JSON-RPC request for `eth_getUncleByBlockHashAndIndex` procedure */ type EthGetUncleByBlockHashAndIndexParams = { blockHash: Hex; uncleIndex: Hex; }; /** * JSON-RPC request for `eth_getUncleByBlockNumberAndIndex` procedure */ type EthGetUncleByBlockNumberAndIndexParams = { tag: BlockTag | Hex; uncleIndex: Hex; }; /** * JSON-RPC request for `eth_mining` procedure */ type EthMiningParams = EmptyParams; /** * JSON-RPC request for `eth_protocolVersion` procedure */ type EthProtocolVersionParams = EmptyParams; /** * JSON-RPC request for `eth_sendRawTransaction` procedure */ type EthSendRawTransactionParams = SendRawTransactionParameters; /** * JSON-RPC request for `eth_sendTransaction` procedure */ type EthSendTransactionParams = SendTransactionParameters; /** * JSON-RPC request for `eth_sign` procedure */ type EthSignParams = SignMessageParameters; /** * JSON-RPC request for `eth_signTransaction` procedure */ type EthSignTransactionParams = SignMessageParameters; /** * JSON-RPC request for `eth_syncing` procedure */ type EthSyncingParams = EmptyParams; /** * JSON-RPC request for `eth_newFilter` procedure */ type EthNewFilterParams = FilterParams; /** * JSON-RPC request for `eth_newBlockFilter` procedure */ type EthNewBlockFilterParams = EmptyParams; /** * JSON-RPC request for `eth_newPendingTransactionFilter` procedure */ type EthNewPendingTransactionFilterParams = EmptyParams; /** * JSON-RPC request for `eth_uninstallFilter` procedure */ type EthUninstallFilterParams = { filterId: Hex; }; type EthParams = EthAccountsParams | EthAccountsParams | EthBlockNumberParams | EthCallParams | EthChainIdParams | EthCoinbaseParams | EthEstimateGasParams | EthHashrateParams | EthGasPriceParams | EthGetBalanceParams | EthGetBlockByHashParams | EthGetBlockByNumberParams | EthGetBlockTransactionCountByHashParams | EthGetBlockTransactionCountByNumberParams | EthGetCodeParams | EthGetFilterChangesParams | EthGetFilterLogsParams | EthGetLogsParams | EthGetStorageAtParams | EthGetTransactionCountParams | EthGetUncleCountByBlockHashParams | EthGetUncleCountByBlockNumberParams | EthGetTransactionByHashParams | EthGetTransactionByBlockHashAndIndexParams | EthGetTransactionByBlockNumberAndIndexParams | EthGetTransactionReceiptParams | EthGetUncleByBlockHashAndIndexParams | EthGetUncleByBlockNumberAndIndexParams | EthMiningParams | EthProtocolVersionParams | EthSendRawTransactionParams | EthSendTransactionParams | EthSignParams | EthSignTransactionParams | EthSyncingParams | EthNewFilterParams | EthNewBlockFilterParams | EthNewPendingTransactionFilterParams | EthUninstallFilterParams; /*** * TODO I didn't update any of these jsdocs */ /** * Params fro `anvil_impersonateAccount` handler */ type AnvilImpersonateAccountParams = { /** * The address to impersonate */ address: Address; }; /** * Params for `anvil_stopImpersonatingAccount` handler */ type AnvilStopImpersonatingAccountParams = { /** * The address to stop impersonating */ address: Address; }; /** * Params for `anvil_autoImpersonateAccount` handler * Not included atm because tevm_call supports it and i was getting methodNotFound errors trying it in anvil */ /** * Params for `anvil_getAutomine` handler */ type AnvilGetAutomineParams = {} | undefined | never; /** * Params for `anvil_mine` handler */ type AnvilMineParams = { /** * Number of blocks to mine. Defaults to 1 */ blockCount?: number; /** * mineing interval */ interval?: number; }; /** * Params for `anvil_reset` handler */ type AnvilResetParams = { fork: { /** * The url to fork if forking */ url?: string; /** * The block number */ block?: BlockTag | Hex | BigInt; }; }; /** * Params for `anvil_dropTransaction` handler */ type AnvilDropTransactionParams = { /** * The transaction hash */ transactionHash: Hex; }; /** * Params for `anvil_setBalance` handler */ type AnvilSetBalanceParams = { /** * The address to set the balance for */ address: Address; /** * The balance to set */ balance: Hex | BigInt; }; /** * Params for `anvil_setCode` handler */ type AnvilSetCodeParams = { /** * The address to set the code for */ address: Address; /** * The code to set */ code: Hex; }; /** * Params for `anvil_setNonce` handler */ type AnvilSetNonceParams = { /** * The address to set the nonce for */ address: Address; /** * The nonce to set */ nonce: BigInt; }; /** * Params for `anvil_setStorageAt` handler */ type AnvilSetStorageAtParams = { /** * The address to set the storage for */ address: Address; /** * The position in storage to set */ position: Hex | BigInt; /** * The value to set */ value: Hex | BigInt; }; /** * Params for `anvil_setChainId` handler */ type AnvilSetChainIdParams = { /** * The chain id to set */ chainId: number; }; /** * Params for `anvil_dumpState` handler */ type AnvilDumpStateParams = {} | undefined | never; /** * Params for `anvil_loadState` handler */ type AnvilLoadStateParams = { /** * The state to load */ state: Record; }; /** * Config params for trace calls */ type TraceParams = { /** * The type of tracer * Currently only callTracer supported */ readonly tracer: 'callTracer' | 'prestateTracer'; /** * A duration string of decimal numbers that overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Max timeout is "10s". Valid time units are "ns", "us", "ms", "s" each with optional fraction, such as "300ms" or "2s45ms". * @example "10s" */ readonly timeout?: string; /** * object to specify configurations for the tracer */ readonly tracerConfig?: {}; }; /** * Params taken by `debug_traceTransaction` handler */ type DebugTraceTransactionParams = TraceParams & { /** * The transaction hash */ transactionHash: Hex; }; /** * Params taken by `debug_traceCall` handler */ type DebugTraceCallParams = TraceParams & { /** * The transaction to debug */ transaction: CallParameters; /** * Block information */ block?: BlockTag | Hex | BigInt; }; /** * Generic log information */ type Log = { readonly address: Address; readonly topics: Hex[]; readonly data: Hex; }; /** * The type returned by block related * json rpc procedures */ type BlockResult = { readonly number: Hex; readonly hash: Hex; readonly parentHash: Hex; readonly nonce: Hex; readonly sha3Uncles: Hex; readonly logsBloom: Hex; readonly transactionsRoot: Hex; readonly stateRoot: Hex; readonly miner: Hex; readonly difficulty: Hex; readonly totalDifficulty: Hex; readonly extraData: Hex; readonly size: Hex; readonly gasLimit: Hex; readonly gasUsed: Hex; readonly timestamp: Hex; readonly transactions: Hex[]; readonly uncles: Hex[]; }; /** * FilterLog type for eth JSON-RPC procedures */ type FilterLog = { readonly address: Hex; readonly blockHash: Hex; readonly blockNumber: Hex; readonly data: Hex; readonly logIndex: Hex; readonly removed: boolean; readonly topics: readonly Hex[]; readonly transactionHash: Hex; readonly transactionIndex: Hex; }; /** * A transaction request object */ type TransactionParams = { readonly from: Address; readonly to?: Address; readonly gas?: Hex; readonly gasPrice?: Hex; readonly value?: Hex; readonly input: Hex; readonly nonce?: Hex; }; /** * Transaction receipt result type for eth JSON-RPC procedures */ type TransactionReceiptResult = { readonly blockHash: Hex; readonly blockNumber: Hex; readonly contractAddress: Hex; readonly cumulativeGasUsed: Hex; readonly from: Hex; readonly gasUsed: Hex; readonly logs: readonly FilterLog[]; readonly logsBloom: Hex; readonly status: Hex; readonly to: Hex; readonly transactionHash: Hex; readonly transactionIndex: Hex; }; /** * The type returned by transaction related * json rpc procedures */ type TransactionResult = { readonly blockHash: Hex; readonly blockNumber: Hex; readonly from: Hex; readonly gas: Hex; readonly gasPrice: Hex; readonly hash: Hex; readonly input: Hex; readonly nonce: Hex; readonly to: Hex; readonly transactionIndex: Hex; readonly value: Hex; readonly v: Hex; readonly r: Hex; readonly s: Hex; }; type TraceType = 'CALL' | 'DELEGATECALL' | 'STATICCALL' | 'CREATE' | 'CREATE2' | 'SELFDESTRUCT' | 'REWARD'; type TraceCall = { type: TraceType; from: Address; to: Address; gas?: bigint; gasUsed?: bigint; input: Hex; output: Hex; calls?: TraceCall[]; value?: bigint; }; type TraceResult = { type: TraceType; from: Address; to: Address; value: bigint; gas: bigint; gasUsed: bigint; input: Hex; output: Hex; calls?: TraceCall[]; }; /** * Internal utility for creating a typed error as typed by Tevm * `name` is analogous to `code` in a JSON RPC error and is the value used to discriminate errors * for tevm users. * `_tag` is same as name and used internally so it can be changed in non breaking way with regard to name * `message` is a human readable error message * `meta` is an optional object containing additional information about the error */ type TypedError = { _tag: TName; name: TName; message: string; meta?: TMeta; }; /** * Error thrown when bytecode parameter is invalid */ type InvalidBytecodeError = TypedError<'InvalidBytecodeError'>; /** * Error thrown when storage root parameter is invalid */ type InvalidStorageRootError = TypedError<'InvalidStorageRootError'>; /** * Error thrown when data parameter is invalid */ type InvalidDataError = TypedError<'InvalidDataError'>; /** * Error thrown when balance parameter is invalid */ type InvalidBalanceError = TypedError<'InvalidBalanceError'>; /** * Error thrown when function name is invalid */ type InvalidFunctionNameError = TypedError<'InvalidFunctionNameError'>; type TevmEVMErrorMessage = 'out of gas' | 'code store out of gas' | 'code size to deposit exceeds maximum code size' | 'stack underflow' | 'stack overflow' | 'invalid JUMP' | 'invalid opcode' | 'value out of range' | 'revert' | 'static state change' | 'internal error' | 'create collision' | 'stop' | 'refund exhausted' | 'value overflow' | 'insufficient balance' | 'invalid BEGINSUB' | 'invalid RETURNSUB' | 'invalid JUMPSUB' | 'invalid bytecode deployed' | 'invalid EOF format' | 'initcode exceeds max initcode size' | 'invalid input length' | 'attempting to AUTHCALL without AUTH set' | 'attempting to execute AUTHCALL with nonzero external value' | 'invalid Signature: s-values greater than secp256k1n/2 are considered invalid' | 'invalid input length' | 'point not on curve' | 'input is empty' | 'fp point not in field' | 'kzg commitment does not match versioned hash' | 'kzg inputs invalid' | 'kzg proof invalid'; /** * Error type of errors thrown while internally executing a call in the EVM */ type EvmError = TypedError; /** * Error thrown when address is invalid */ type InvalidAddressError = TypedError<'InvalidAddressError'>; /** * Error thrown when blobVersionedHashes parameter is invalid */ type InvalidBlobVersionedHashesError = TypedError<'InvalidBlobVersionedHashesError'>; /** * Error thrown when block parameter is invalid */ type InvalidBlockError = TypedError<'InvalidBlockError'>; /** * Error thrown when caller parameter is invalid */ type InvalidCallerError = TypedError<'InvalidCallerError'>; /** * Error thrown when depth parameter is invalid */ type InvalidDepthError = TypedError<'InvalidDepthError'>; /** * Error thrown when gas limit is invalid */ type InvalidGasLimitError = TypedError<'InvalidGasLimitError'>; /** * Error thrown when gasPrice parameter is invalid */ type InvalidGasPriceError = TypedError<'InvalidGasPriceError'>; /** * Error thrown when gas refund is invalid */ type InvalidGasRefundError = TypedError<'InvalidGasRefundError'>; /** * Error thrown when nonce parameter is invalid */ type InvalidNonceError = TypedError<'InvalidNonceError'>; /** * Error thrown when origin parameter is invalid */ type InvalidOriginError = TypedError<'InvalidOriginError'>; /** * Error thrown when request is invalid */ type InvalidRequestError = TypedError<'InvalidRequestError'>; /** * Error thrown when selfdestruct parameter is invalid */ type InvalidSelfdestructError = TypedError<'InvalidSelfdestructError'>; /** * Error thrown when skipBalance parameter is invalid */ type InvalidSkipBalanceError = TypedError<'InvalidSkipBalanceError'>; /** * Error thrown when `to` parameter is invalid */ type InvalidToError = TypedError<'InvalidToError'>; /** * Error thrown when value parameter is invalid */ type InvalidValueError = TypedError<'InvalidValueError'>; /** * Error representing an unknown error occurred * It should never get thrown. This error being thrown * means an error wasn't properly handled already */ type UnexpectedError = TypedError<'UnexpectedError'>; /** * Errors returned by all call based tevm procedures including call, contract, and script */ type BaseCallError = EvmError | InvalidRequestError | InvalidAddressError | InvalidBalanceError | InvalidBlobVersionedHashesError | InvalidBlockError | InvalidCallerError | InvalidDepthError | InvalidGasLimitError | InvalidGasPriceError | InvalidGasRefundError | InvalidNonceError | InvalidOriginError | InvalidSelfdestructError | InvalidSkipBalanceError | InvalidStorageRootError | InvalidToError | InvalidValueError | UnexpectedError; /** * Error thrown when decoding function data fails * Not expected to be thrown unless ABI is incorrect * @example * const {errors} = await tevm.call({address: '0x1234'}) * errors.forEach(error => { * if (error.name === 'DecodeFunctionDataError') { * console.log(error.message) * } * }) */ type DecodeFunctionDataError = TypedError<'DecodeFunctionDataError'>; /** * Error thrown when encoding function data fails * Not expected to be thrown because the initial validation * should have caught any errors and thrown more specific errors */ type EncodeFunctionReturnDataError = TypedError<'EncodeFunctionReturnDataError'>; /** * Error thrown when ABI shape is invalid */ type InvalidAbiError = TypedError<'InvalidAbiError'>; /** * Error thrown when arguments provided to a contract or script call are invalid */ type InvalidArgsError = TypedError<'InvalidArgsError'>; /*** * Errors returned by contract tevm procedure * @example * const {errors} = await tevm.contract({address: '0x1234'}) * if (errors?.length) { * console.log(errors[0].name) // InvalidAddressError * } */ type ContractError = BaseCallError | InvalidAddressError | EvmError | InvalidRequestError | UnexpectedError | InvalidAbiError | InvalidDataError | InvalidFunctionNameError | InvalidArgsError | DecodeFunctionDataError | EncodeFunctionReturnDataError; /** * Error thrown when deployedBytecode parameter is invalid */ type InvalidDeployedBytecodeError = TypedError<'InvalidDeployedBytecodeError'>; /** * Error type of errors thrown by the script procedure * @example * const {errors} = await tevm.script({address: '0x1234'}) * if (errors?.length) { * console.log(errors[0].name) // InvalidBytecodeError * console.log(errors[0].message) // Invalid bytecode should be a hex string: 1234 * } */ type ScriptError = ContractError | InvalidBytecodeError | InvalidDeployedBytecodeError; /** * Errors returned by account tevm procedure * @example * const {errors} = await tevm.account({address: '0x1234'}) * * if (errors?.length) { * console.log(errors[0].name) // InvalidAddressError * console.log(errors[0].message) // Invalid address: 0x1234 * } */ type AccountError = InvalidAddressError | InvalidBalanceError | InvalidNonceError | InvalidStorageRootError | InvalidBytecodeError | InvalidRequestError | UnexpectedError; /** * Error thrown when salt parameter is invalid */ type InvalidSaltError = TypedError<'InvalidSaltError'>; /** * Error returned by call tevm procedure * @example * const {errors} = await tevm.call({address: '0x1234'}) * if (errors?.length) { * console.log(errors[0].name) // InvalidDataError * } */ type CallError = BaseCallError | InvalidSaltError | InvalidDataError | InvalidDeployedBytecodeError; /** * Handler for account tevm procedure */ type AccountHandler = (params: AccountParams) => Promise; /** * Handler for call tevm procedure */ type CallHandler = (action: CallParams) => Promise; /** * Handler for contract tevm procedure * It's API resuses the viem `contractRead`/`contractWrite` API to encode abi, functionName, and args */ type ContractHandler = = ContractFunctionName>(action: ContractParams) => Promise>; /** * Handler for script tevm procedure */ type ScriptHandler = = ContractFunctionName>(params: ScriptParams) => Promise>; type AnvilImpersonateAccountResult = null; type AnvilStopImpersonatingAccountResult = null; type AnvilGetAutomineResult = boolean; type AnvilMineResult = null; type AnvilResetResult = null; type AnvilDropTransactionResult = null; type AnvilSetBalanceResult = null; type AnvilSetCodeResult = null; type AnvilSetNonceResult = null; type AnvilSetStorageAtResult = null; type AnvilSetChainIdResult = null; type AnvilDumpStateResult = Hex; type AnvilLoadStateResult = null; type AnvilImpersonateAccountHandler = (params: AnvilImpersonateAccountParams) => Promise; type AnvilStopImpersonatingAccountHandler = (params: AnvilStopImpersonatingAccountParams) => Promise; type AnvilGetAutomineHandler = (params: AnvilGetAutomineParams) => Promise; type AnvilMineHandler = (params: AnvilMineParams) => Promise; type AnvilResetHandler = (params: AnvilResetParams) => Promise; type AnvilDropTransactionHandler = (params: AnvilDropTransactionParams) => Promise; type AnvilSetBalanceHandler = (params: AnvilSetBalanceParams) => Promise; type AnvilSetCodeHandler = (params: AnvilSetCodeParams) => Promise; type AnvilSetNonceHandler = (params: AnvilSetNonceParams) => Promise; type AnvilSetStorageAtHandler = (params: AnvilSetStorageAtParams) => Promise; type AnvilSetChainIdHandler = (params: AnvilSetChainIdParams) => Promise; type AnvilDumpStateHandler = (params: AnvilDumpStateParams) => Promise; type AnvilLoadStateHandler = (params: AnvilLoadStateParams) => Promise; /** * Result of Account Action */ type AccountResult = { /** * Description of the exception, if any occurred */ errors?: ErrorType[]; }; /** * Result of a Tevm VM Call method */ type CallResult = { /** * Amount of gas left */ gas?: bigint; /** * Amount of gas the code used to run */ executionGasUsed: bigint; /** * Array of logs that the contract emitted */ logs?: Log[]; /** * The gas refund counter as a uint256 */ gasRefund?: bigint; /** * Amount of blob gas consumed by the transaction */ blobGasUsed?: bigint; /** * Address of created account during transaction, if any */ createdAddress?: Address; /** * A set of accounts to selfdestruct */ selfdestruct?: Set
; /** * Map of addresses which were created (used in EIP 6780) */ createdAddresses?: Set
; /** * Encoded return value from the contract as hex string */ rawData: Hex; /** * Description of the exception, if any occurred */ errors?: ErrorType[]; }; type ContractResult = ContractFunctionName, ErrorType = ContractError> = (Omit & { errors?: never; /** * The parsed data */ data: DecodeFunctionResultReturnType; }) | (CallResult & { data?: never; }); type ScriptResult = ContractFunctionName, TErrorType = ScriptError> = ContractResult; /*** * TODO I didn't update any of these jsdocs * TODO some of these types are not deserialized and/or don't match viem types and will * need to be updated as t hey are implemented */ type EthAccountsResult = Array; /** * JSON-RPC response for `eth_blockNumber` procedure */ type EthBlockNumberResult = bigint; /** * JSON-RPC response for `eth_call` procedure */ type EthCallResult = Hex; /** * JSON-RPC response for `eth_chainId` procedure */ type EthChainIdResult = bigint; /** * JSON-RPC response for `eth_coinbase` procedure */ type EthCoinbaseResult = Address$1; /** * JSON-RPC response for `eth_estimateGas` procedure */ type EthEstimateGasResult = bigint; /** * JSON-RPC response for `eth_hashrate` procedure */ type EthHashrateResult = Hex; /** * JSON-RPC response for `eth_gasPrice` procedure */ type EthGasPriceResult = bigint; /** * JSON-RPC response for `eth_getBalance` procedure */ type EthGetBalanceResult = bigint; /** * JSON-RPC response for `eth_getBlockByHash` procedure */ type EthGetBlockByHashResult = BlockResult; /** * JSON-RPC response for `eth_getBlockByNumber` procedure */ type EthGetBlockByNumberResult = BlockResult; /** * JSON-RPC response for `eth_getBlockTransactionCountByHash` procedure */ type EthGetBlockTransactionCountByHashResult = Hex; /** * JSON-RPC response for `eth_getBlockTransactionCountByNumber` procedure */ type EthGetBlockTransactionCountByNumberResult = Hex; /** * JSON-RPC response for `eth_getCode` procedure */ type EthGetCodeResult = Hex; /** * JSON-RPC response for `eth_getFilterChanges` procedure */ type EthGetFilterChangesResult = Array; /** * JSON-RPC response for `eth_getFilterLogs` procedure */ type EthGetFilterLogsResult = Array; /** * JSON-RPC response for `eth_getLogs` procedure */ type EthGetLogsResult = Array; /** * JSON-RPC response for `eth_getStorageAt` procedure */ type EthGetStorageAtResult = Hex; /** * JSON-RPC response for `eth_getTransactionCount` procedure */ type EthGetTransactionCountResult = Hex; /** * JSON-RPC response for `eth_getUncleCountByBlockHash` procedure */ type EthGetUncleCountByBlockHashResult = Hex; /** * JSON-RPC response for `eth_getUncleCountByBlockNumber` procedure */ type EthGetUncleCountByBlockNumberResult = Hex; /** * JSON-RPC response for `eth_getTransactionByHash` procedure */ type EthGetTransactionByHashResult = TransactionResult; /** * JSON-RPC response for `eth_getTransactionByBlockHashAndIndex` procedure */ type EthGetTransactionByBlockHashAndIndexResult = TransactionResult; /** * JSON-RPC response for `eth_getTransactionByBlockNumberAndIndex` procedure */ type EthGetTransactionByBlockNumberAndIndexResult = TransactionResult; /** * JSON-RPC response for `eth_getTransactionReceipt` procedure */ type EthGetTransactionReceiptResult = TransactionReceiptResult; /** * JSON-RPC response for `eth_getUncleByBlockHashAndIndex` procedure */ type EthGetUncleByBlockHashAndIndexResult = Hex; /** * JSON-RPC response for `eth_getUncleByBlockNumberAndIndex` procedure */ type EthGetUncleByBlockNumberAndIndexResult = Hex; /** * JSON-RPC response for `eth_mining` procedure */ type EthMiningResult = boolean; /** * JSON-RPC response for `eth_protocolVersion` procedure */ type EthProtocolVersionResult = Hex; /** * JSON-RPC response for `eth_sendRawTransaction` procedure */ type EthSendRawTransactionResult = Hex; /** * JSON-RPC response for `eth_sendTransaction` procedure */ type EthSendTransactionResult = Hex; /** * JSON-RPC response for `eth_sign` procedure */ type EthSignResult = Hex; /** * JSON-RPC response for `eth_signTransaction` procedure */ type EthSignTransactionResult = Hex; /** * JSON-RPC response for `eth_syncing` procedure */ type EthSyncingResult = boolean | { startingBlock: Hex; currentBlock: Hex; highestBlock: Hex; headedBytecodebytes?: Hex; healedBytecodes?: Hex; healedTrienodes?: Hex; healingBytecode?: Hex; healingTrienodes?: Hex; syncedBytecodeBytes?: Hex; syncedBytecodes?: Hex; syncedStorage?: Hex; syncedStorageBytes?: Hex; pulledStates: Hex; knownStates: Hex; }; /** * JSON-RPC response for `eth_newFilter` procedure */ type EthNewFilterResult = Hex; /** * JSON-RPC response for `eth_newBlockFilter` procedure */ type EthNewBlockFilterResult = Hex; /** * JSON-RPC response for `eth_newPendingTransactionFilter` procedure */ type EthNewPendingTransactionFilterResult = Hex; /** * JSON-RPC response for `eth_uninstallFilter` procedure */ type EthUninstallFilterResult = boolean; type StructLog = { readonly depth: number; readonly gas: bigint; readonly gasCost: bigint; readonly op: string; readonly pc: number; readonly stack: ReadonlyArray; }; type DebugTraceTransactionResult = TraceResult; type DebugTraceCallResult = { readonly failed: boolean; readonly gas: bigint; readonly returnValue: Hex; readonly structLogs: ReadonlyArray; }; type DebugTraceTransactionHandler = (params: DebugTraceTransactionParams) => Promise; type DebugTraceCallHandler = (params: DebugTraceCallParams) => Promise; type EthAccountsHandler = (request?: EthAccountsParams) => Promise; type EthBlockNumberHandler = (request?: EthBlockNumberParams) => Promise; type EthCallHandler = (request: EthCallParams) => Promise; type EthChainIdHandler = (request?: EthChainIdParams) => Promise; type EthCoinbaseHandler = (request: EthCoinbaseParams) => Promise; type EthEstimateGasHandler = (request: EthEstimateGasParams) => Promise; type EthHashrateHandler = (request?: EthHashrateParams) => Promise; type EthGasPriceHandler = (request?: EthGasPriceParams) => Promise; type EthGetBalanceHandler = (request: EthGetBalanceParams) => Promise; type EthGetBlockByHashHandler = (request: EthGetBlockByHashParams) => Promise; type EthGetBlockByNumberHandler = (request: EthGetBlockByNumberParams) => Promise; type EthGetBlockTransactionCountByHashHandler = (request: EthGetBlockTransactionCountByHashParams) => Promise; type EthGetBlockTransactionCountByNumberHandler = (request: EthGetBlockTransactionCountByNumberParams) => Promise; type EthGetCodeHandler = (request: EthGetCodeParams) => Promise; type EthGetFilterChangesHandler = (request: EthGetFilterChangesParams) => Promise; type EthGetFilterLogsHandler = (request: EthGetFilterLogsParams) => Promise; type EthGetLogsHandler = (request: EthGetLogsParams) => Promise; type EthGetStorageAtHandler = (request: EthGetStorageAtParams) => Promise; type EthGetTransactionCountHandler = (request: EthGetTransactionCountParams) => Promise; type EthGetUncleCountByBlockHashHandler = (request: EthGetUncleCountByBlockHashParams) => Promise; type EthGetUncleCountByBlockNumberHandler = (request: EthGetUncleCountByBlockNumberParams) => Promise; type EthGetTransactionByHashHandler = (request: EthGetTransactionByHashParams) => Promise; type EthGetTransactionByBlockHashAndIndexHandler = (request: EthGetTransactionByBlockHashAndIndexParams) => Promise; type EthGetTransactionByBlockNumberAndIndexHandler = (request: EthGetTransactionByBlockNumberAndIndexParams) => Promise; type EthGetTransactionReceiptHandler = (request: EthGetTransactionReceiptParams) => Promise; type EthGetUncleByBlockHashAndIndexHandler = (request: EthGetUncleByBlockHashAndIndexParams) => Promise; type EthGetUncleByBlockNumberAndIndexHandler = (request: EthGetUncleByBlockNumberAndIndexParams) => Promise; type EthMiningHandler = (request: EthMiningParams) => Promise; type EthProtocolVersionHandler = (request: EthProtocolVersionParams) => Promise; type EthSendRawTransactionHandler = (request: EthSendRawTransactionParams) => Promise; type EthSendTransactionHandler = (request: EthSendTransactionParams) => Promise; type EthSignHandler = (request: EthSignParams) => Promise; type EthSignTransactionHandler = (request: EthSignTransactionParams) => Promise; type EthSyncingHandler = (request: EthSyncingParams) => Promise; type EthNewFilterHandler = (request: EthNewFilterParams) => Promise; type EthNewBlockFilterHandler = (request: EthNewBlockFilterParams) => Promise; type EthNewPendingTransactionFilterHandler = (request: EthNewPendingTransactionFilterParams) => Promise; type EthUninstallFilterHandler = (request: EthUninstallFilterParams) => Promise; type JsonSerializable = bigint | string | number | boolean | null | JsonSerializableArray | JsonSerializableObject | JsonSerializableSet; type JsonSerializableArray = ReadonlyArray; type JsonSerializableObject = { [key: string]: JsonSerializable; }; type JsonSerializableSet = Set; type BigIntToHex = T extends bigint ? Hex : T; type SetToHex = T extends Set ? Hex : T; type SerializeToJson = T extends JsonSerializableSet ? ReadonlyArray : T extends JsonSerializableObject ? { [P in keyof T]: SerializeToJson; } : T extends JsonSerializableArray ? SerializeToJson[] : BigIntToHex>; /** * Helper type for creating JSON-RPC request types */ type JsonRpcRequest = { jsonrpc: '2.0'; method: TMethod; id?: string | number | null; } & (TParams extends readonly [] ? { params?: TParams; } : { params: TParams; }); /** * JSON-RPC request for `tevm_account` method */ type AccountJsonRpcRequest = JsonRpcRequest<'tevm_account', SerializeToJson>; /** * JSON-RPC request for `tevm_call` */ type CallJsonRpcRequest = JsonRpcRequest<'tevm_call', SerializeToJson>; /** * Since contract calls are just a quality of life wrapper around call we avoid using tevm_contract * in favor of overloading tevm_call */ type ContractJsonRpcRequest = CallJsonRpcRequest; /** * The parameters for the `tevm_script` method * The higher level handler method takes abi functionName and args * But to serialize it over jsonrpc we need to serialize the data * the same way normal contract calls are serialized into functionData */ type SerializedParams = SerializeToJson & { /** * The raw call data */ data: Hex; /** * The deployed bytecode of the contract. */ deployedBytecode: Hex; }; /** * The JSON-RPC request for the `tevm_script` method */ type ScriptJsonRpcRequest = JsonRpcRequest<'tevm_script', SerializedParams>; /** * A Tevm JSON-RPC request * `tevm_account`, `tevm_call`, `tevm_contract`, `tevm_script` */ type TevmJsonRpcRequest = AccountJsonRpcRequest | CallJsonRpcRequest | ContractJsonRpcRequest | ScriptJsonRpcRequest; /** * JSON-RPC request for `eth_accounts` procedure */ type EthAccountsJsonRpcRequest = JsonRpcRequest<'eth_accounts', readonly []>; /** * JSON-RPC request for `eth_blockNumber` procedure */ type EthBlockNumberJsonRpcRequest = JsonRpcRequest<'eth_blockNumber', readonly []>; /** * JSON-RPC request for `eth_call` procedure */ type EthCallJsonRpcRequest = JsonRpcRequest<'eth_call', readonly [tx: Transaction, tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_chainId` procedure */ type EthChainIdJsonRpcRequest = JsonRpcRequest<'eth_chainId', readonly []>; /** * JSON-RPC request for `eth_coinbase` procedure */ type EthCoinbaseJsonRpcRequest = JsonRpcRequest<'eth_coinbase', readonly []>; /** * JSON-RPC request for `eth_estimateGas` procedure */ type EthEstimateGasJsonRpcRequest = JsonRpcRequest<'eth_estimateGas', readonly [tx: Transaction]>; /** * JSON-RPC request for `eth_hashrate` procedure */ type EthHashrateJsonRpcRequest = JsonRpcRequest<'eth_hashrate', readonly []>; /** * JSON-RPC request for `eth_gasPrice` procedure */ type EthGasPriceJsonRpcRequest = JsonRpcRequest<'eth_gasPrice', readonly []>; /** * JSON-RPC request for `eth_getBalance` procedure */ type EthGetBalanceJsonRpcRequest = JsonRpcRequest<'eth_getBalance', [ address: Address, tag: BlockTag | Hex ]>; /** * JSON-RPC request for `eth_getBlockByHash` procedure */ type EthGetBlockByHashJsonRpcRequest = JsonRpcRequest<'eth_getBlockByHash', readonly [blockHash: Hex, fullTransactionObjects: boolean]>; /** * JSON-RPC request for `eth_getBlockByNumber` procedure */ type EthGetBlockByNumberJsonRpcRequest = JsonRpcRequest<'eth_getBlockByNumber', readonly [tag: BlockTag | Hex, fullTransactionObjects: boolean]>; /** * JSON-RPC request for `eth_getBlockTransactionCountByHash` procedure */ type EthGetBlockTransactionCountByHashJsonRpcRequest = JsonRpcRequest<'eth_getBlockTransactionCountByHash', readonly [hash: Hex]>; /** * JSON-RPC request for `eth_getBlockTransactionCountByNumber` procedure */ type EthGetBlockTransactionCountByNumberJsonRpcRequest = JsonRpcRequest<'eth_getBlockTransactionCountByNumber', readonly [tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_getCode` procedure */ type EthGetCodeJsonRpcRequest = JsonRpcRequest<'eth_getCode', readonly [address: Address, tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_getFilterChanges` procedure */ type EthGetFilterChangesJsonRpcRequest = JsonRpcRequest<'eth_getFilterChanges', [ filterId: Hex ]>; /** * JSON-RPC request for `eth_getFilterLogs` procedure */ type EthGetFilterLogsJsonRpcRequest = JsonRpcRequest<'eth_getFilterLogs', [ filterId: Hex ]>; /** * JSON-RPC request for `eth_getLogs` procedure */ type EthGetLogsJsonRpcRequest = JsonRpcRequest<'eth_getLogs', [ filterParams: FilterParams ]>; /** * JSON-RPC request for `eth_getStorageAt` procedure */ type EthGetStorageAtJsonRpcRequest = JsonRpcRequest<'eth_getStorageAt', readonly [address: Address, position: Hex, tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_getTransactionCount` procedure */ type EthGetTransactionCountJsonRpcRequest = JsonRpcRequest<'eth_getTransactionCount', readonly [address: Address, tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_getUncleCountByBlockHash` procedure */ type EthGetUncleCountByBlockHashJsonRpcRequest = JsonRpcRequest<'eth_getUncleCountByBlockHash', readonly [hash: Hex]>; /** * JSON-RPC request for `eth_getUncleCountByBlockNumber` procedure */ type EthGetUncleCountByBlockNumberJsonRpcRequest = JsonRpcRequest<'eth_getUncleCountByBlockNumber', readonly [tag: BlockTag | Hex]>; /** * JSON-RPC request for `eth_getTransactionByHash` procedure */ type EthGetTransactionByHashJsonRpcRequest = JsonRpcRequest<'eth_getTransactionByHash', readonly [data: Hex]>; /** * JSON-RPC request for `eth_getTransactionByBlockHashAndIndex` procedure */ type EthGetTransactionByBlockHashAndIndexJsonRpcRequest = JsonRpcRequest<'eth_getTransactionByBlockHashAndIndex', readonly [tag: Hex, index: Hex]>; /** * JSON-RPC request for `eth_getTransactionByBlockNumberAndIndex` procedure */ type EthGetTransactionByBlockNumberAndIndexJsonRpcRequest = JsonRpcRequest<'eth_getTransactionByBlockNumberAndIndex', readonly [tag: BlockTag | Hex, index: Hex]>; /** * JSON-RPC request for `eth_getTransactionReceipt` procedure */ type EthGetTransactionReceiptJsonRpcRequest = JsonRpcRequest<'eth_getTransactionReceipt', [ txHash: Hex ]>; /** * JSON-RPC request for `eth_getUncleByBlockHashAndIndex` procedure */ type EthGetUncleByBlockHashAndIndexJsonRpcRequest = JsonRpcRequest<'eth_getUncleByBlockHashAndIndex', readonly [blockHash: Hex, uncleIndex: Hex]>; /** * JSON-RPC request for `eth_getUncleByBlockNumberAndIndex` procedure */ type EthGetUncleByBlockNumberAndIndexJsonRpcRequest = JsonRpcRequest<'eth_getUncleByBlockNumberAndIndex', readonly [tag: BlockTag | Hex, uncleIndex: Hex]>; /** * JSON-RPC request for `eth_mining` procedure */ type EthMiningJsonRpcRequest = JsonRpcRequest<'eth_mining', readonly []>; /** * JSON-RPC request for `eth_protocolVersion` procedure */ type EthProtocolVersionJsonRpcRequest = JsonRpcRequest<'eth_protocolVersion', readonly []>; /** * JSON-RPC request for `eth_sendRawTransaction` procedure */ type EthSendRawTransactionJsonRpcRequest = JsonRpcRequest<'eth_sendRawTransaction', [ data: Hex ]>; /** * JSON-RPC request for `eth_sendTransaction` procedure */ type EthSendTransactionJsonRpcRequest = JsonRpcRequest<'eth_sendTransaction', [ tx: Transaction ]>; /** * JSON-RPC request for `eth_sign` procedure */ type EthSignJsonRpcRequest = JsonRpcRequest<'eth_sign', [ address: Address, message: Hex ]>; /** * JSON-RPC request for `eth_signTransaction` procedure */ type EthSignTransactionJsonRpcRequest = JsonRpcRequest<'eth_signTransaction', [ { from: Address; to?: Address; gas?: Hex; gasPrice?: Hex; value?: Hex; data?: Hex; nonce?: Hex; chainId?: Hex; } ]>; /** * JSON-RPC request for `eth_syncing` procedure */ type EthSyncingJsonRpcRequest = JsonRpcRequest<'eth_syncing', readonly []>; /** * JSON-RPC request for `eth_newFilter` procedure */ type EthNewFilterJsonRpcRequest = JsonRpcRequest<'eth_newFilter', SerializeToJson>; /** * JSON-RPC request for `eth_newBlockFilter` procedure */ type EthNewBlockFilterJsonRpcRequest = JsonRpcRequest<'eth_newBlockFilter', readonly []>; /** * JSON-RPC request for `eth_newPendingTransactionFilter` procedure */ type EthNewPendingTransactionFilterJsonRpcRequest = JsonRpcRequest<'eth_newPendingTransactionFilter', readonly []>; /** * JSON-RPC request for `eth_uninstallFilter` procedure */ type EthUninstallFilterJsonRpcRequest = JsonRpcRequest<'eth_uninstallFilter', [ filterId: Hex ]>; type EthJsonRpcRequest = EthAccountsJsonRpcRequest | EthAccountsJsonRpcRequest | EthBlockNumberJsonRpcRequest | EthCallJsonRpcRequest | EthChainIdJsonRpcRequest | EthCoinbaseJsonRpcRequest | EthEstimateGasJsonRpcRequest | EthHashrateJsonRpcRequest | EthGasPriceJsonRpcRequest | EthGetBalanceJsonRpcRequest | EthGetBlockByHashJsonRpcRequest | EthGetBlockByNumberJsonRpcRequest | EthGetBlockTransactionCountByHashJsonRpcRequest | EthGetBlockTransactionCountByNumberJsonRpcRequest | EthGetCodeJsonRpcRequest | EthGetFilterChangesJsonRpcRequest | EthGetFilterLogsJsonRpcRequest | EthGetLogsJsonRpcRequest | EthGetStorageAtJsonRpcRequest | EthGetTransactionCountJsonRpcRequest | EthGetUncleCountByBlockHashJsonRpcRequest | EthGetUncleCountByBlockNumberJsonRpcRequest | EthGetTransactionByHashJsonRpcRequest | EthGetTransactionByBlockHashAndIndexJsonRpcRequest | EthGetTransactionByBlockNumberAndIndexJsonRpcRequest | EthGetTransactionReceiptJsonRpcRequest | EthGetUncleByBlockHashAndIndexJsonRpcRequest | EthGetUncleByBlockNumberAndIndexJsonRpcRequest | EthMiningJsonRpcRequest | EthProtocolVersionJsonRpcRequest | EthSendRawTransactionJsonRpcRequest | EthSendTransactionJsonRpcRequest | EthSignJsonRpcRequest | EthSignTransactionJsonRpcRequest | EthSyncingJsonRpcRequest | EthNewFilterJsonRpcRequest | EthNewBlockFilterJsonRpcRequest | EthNewPendingTransactionFilterJsonRpcRequest | EthUninstallFilterJsonRpcRequest; /** * JSON-RPC request for `anvil_impersonateAccount` method */ type AnvilImpersonateAccountJsonRpcRequest = JsonRpcRequest<'anvil_impersonateAccount', SerializeToJson>; /** * JSON-RPC request for `anvil_stopImpersonatingAccount` method */ type AnvilStopImpersonatingAccountJsonRpcRequest = JsonRpcRequest<'anvil_stopImpersonatingAccount', SerializeToJson>; /** * JSON-RPC request for `anvil_autoImpersonateAccount` method * Not included atm because tevm_call supports it and i was getting methodNotFound errors trying it in anvil */ /** * JSON-RPC request for `anvil_getAutomine` method */ type AnvilGetAutomineJsonRpcRequest = JsonRpcRequest<'anvil_getAutomine', SerializeToJson>; /** * JSON-RPC request for `anvil_mine` method */ type AnvilMineJsonRpcRequest = JsonRpcRequest<'anvil_mine', SerializeToJson>; /** * JSON-RPC request for `anvil_reset` method */ type AnvilResetJsonRpcRequest = JsonRpcRequest<'anvil_reset', SerializeToJson>; /** * JSON-RPC request for `anvil_dropTransaction` method */ type AnvilDropTransactionJsonRpcRequest = JsonRpcRequest<'anvil_dropTransaction', SerializeToJson>; /** * JSON-RPC request for `anvil_setBalance` method */ type AnvilSetBalanceJsonRpcRequest = JsonRpcRequest<'anvil_setBalance', SerializeToJson>; /** * JSON-RPC request for `anvil_setCode` method */ type AnvilSetCodeJsonRpcRequest = JsonRpcRequest<'anvil_setCode', SerializeToJson>; /** * JSON-RPC request for `anvil_setNonce` method */ type AnvilSetNonceJsonRpcRequest = JsonRpcRequest<'anvil_setNonce', SerializeToJson>; /** * JSON-RPC request for `anvil_setStorageAt` method */ type AnvilSetStorageAtJsonRpcRequest = JsonRpcRequest<'anvil_setStorageAt', SerializeToJson>; /** * JSON-RPC request for `anvil_setChainId` method */ type AnvilSetChainIdJsonRpcRequest = JsonRpcRequest<'anvil_setChainId', SerializeToJson>; /** * JSON-RPC request for `anvil_dumpState` method */ type AnvilDumpStateJsonRpcRequest = JsonRpcRequest<'anvil_dumpState', SerializeToJson>; /** * JSON-RPC request for `anvil_loadState` method */ type AnvilLoadStateJsonRpcRequest = JsonRpcRequest<'anvil_loadState', SerializeToJson>; type AnvilJsonRpcRequest = AnvilImpersonateAccountJsonRpcRequest | AnvilStopImpersonatingAccountJsonRpcRequest | AnvilGetAutomineJsonRpcRequest | AnvilMineJsonRpcRequest | AnvilResetJsonRpcRequest | AnvilDropTransactionJsonRpcRequest | AnvilSetBalanceJsonRpcRequest | AnvilSetCodeJsonRpcRequest | AnvilSetNonceJsonRpcRequest | AnvilSetStorageAtJsonRpcRequest | AnvilSetChainIdJsonRpcRequest | AnvilDumpStateJsonRpcRequest | AnvilLoadStateJsonRpcRequest; /** * JSON-RPC request for `debug_traceTransaction` method */ type DebugTraceTransactionJsonRpcRequest = JsonRpcRequest<'debug_traceTransaction', SerializeToJson>; /** * JSON-RPC request for `debug_traceCall` method */ type DebugTraceCallJsonRpcRequest = JsonRpcRequest<'debug_traceCall', SerializeToJson>; type DebugJsonRpcRequest = DebugTraceTransactionJsonRpcRequest | DebugTraceCallJsonRpcRequest; type JsonRpcResponse = { jsonrpc: '2.0'; method: TMethod; result: TResult; id?: string | number | null; error?: never; } | { jsonrpc: '2.0'; method: TMethod; error: { code: TErrorCode; message: string; }; id?: string | number | null; result?: never; }; /** * JSON-RPC response for `tevm_account` procedure */ type AccountJsonRpcResponse = JsonRpcResponse<'tevm_account', SerializeToJson, AccountError['_tag']>; /** * JSON-RPC response for `tevm_call` procedure */ type CallJsonRpcResponse = JsonRpcResponse<'tevm_call', SerializeToJson, CallError['_tag']>; /** * Since contract calls are just a quality of life wrapper around call we avoid using tevm_contract * in favor of overloading tevm_call */ type ContractJsonRpcResponse = CallJsonRpcResponse; /** * JSON-RPC response for `tevm_script` procedure */ type ScriptJsonRpcResponse = JsonRpcResponse<'tevm_script', SerializeToJson, ScriptError['_tag']>; /** * JSON-RPC response for `eth_accounts` procedure */ type EthAccountsJsonRpcResponse = JsonRpcResponse<'eth_accounts', Address[], string>; /** * JSON-RPC response for `eth_blockNumber` procedure */ type EthBlockNumberJsonRpcResponse = JsonRpcResponse<'eth_blockNumber', SerializeToJson, string>; /** * JSON-RPC response for `eth_call` procedure */ type EthCallJsonRpcResponse = JsonRpcResponse<'eth_call', Hex, string>; /** * JSON-RPC response for `eth_chainId` procedure */ type EthChainIdJsonRpcResponse = JsonRpcResponse<'eth_chainId', Hex, string>; /** * JSON-RPC response for `eth_coinbase` procedure */ type EthCoinbaseJsonRpcResponse = JsonRpcResponse<'eth_coinbase', Hex, string>; /** * JSON-RPC response for `eth_estimateGas` procedure */ type EthEstimateGasJsonRpcResponse = JsonRpcResponse<'eth_estimateGas', Hex, string>; /** * JSON-RPC response for `eth_hashrate` procedure */ type EthHashrateJsonRpcResponse = JsonRpcResponse<'eth_hashrate', Hex, string>; /** * JSON-RPC response for `eth_gasPrice` procedure */ type EthGasPriceJsonRpcResponse = JsonRpcResponse<'eth_gasPrice', Hex, string>; /** * JSON-RPC response for `eth_getBalance` procedure */ type EthGetBalanceJsonRpcResponse = JsonRpcResponse<'eth_getBalance', Hex, string>; /** * JSON-RPC response for `eth_getBlockByHash` procedure */ type EthGetBlockByHashJsonRpcResponse = JsonRpcResponse<'eth_getBlockByHash', BlockResult, string>; /** * JSON-RPC response for `eth_getBlockByNumber` procedure */ type EthGetBlockByNumberJsonRpcResponse = JsonRpcResponse<'eth_getBlockByNumber', BlockResult, string>; /** * JSON-RPC response for `eth_getBlockTransactionCountByHash` procedure */ type EthGetBlockTransactionCountByHashJsonRpcResponse = JsonRpcResponse<'eth_getBlockTransactionCountByHash', Hex, string>; /** * JSON-RPC response for `eth_getBlockTransactionCountByNumber` procedure */ type EthGetBlockTransactionCountByNumberJsonRpcResponse = JsonRpcResponse<'eth_getBlockTransactionCountByNumber', Hex, string>; /** * JSON-RPC response for `eth_getCode` procedure */ type EthGetCodeJsonRpcResponse = JsonRpcResponse<'eth_getCode', Hex, string>; /** * JSON-RPC response for `eth_getFilterChanges` procedure */ type EthGetFilterChangesJsonRpcResponse = JsonRpcResponse<'eth_getFilterChanges', Array, string>; /** * JSON-RPC response for `eth_getFilterLogs` procedure */ type EthGetFilterLogsJsonRpcResponse = JsonRpcResponse<'eth_getFilterLogs', Array, string>; /** * JSON-RPC response for `eth_getLogs` procedure */ type EthGetLogsJsonRpcResponse = JsonRpcResponse<'eth_getLogs', Array, string>; /** * JSON-RPC response for `eth_getStorageAt` procedure */ type EthGetStorageAtJsonRpcResponse = JsonRpcResponse<'eth_getStorageAt', Hex, string>; /** * JSON-RPC response for `eth_getTransactionCount` procedure */ type EthGetTransactionCountJsonRpcResponse = JsonRpcResponse<'eth_getTransactionCount', Hex, string>; /** * JSON-RPC response for `eth_getUncleCountByBlockHash` procedure */ type EthGetUncleCountByBlockHashJsonRpcResponse = JsonRpcResponse<'eth_getUncleCountByBlockHash', Hex, string>; /** * JSON-RPC response for `eth_getUncleCountByBlockNumber` procedure */ type EthGetUncleCountByBlockNumberJsonRpcResponse = JsonRpcResponse<'eth_getUncleCountByBlockNumber', Hex, string>; /** * JSON-RPC response for `eth_getTransactionByHash` procedure */ type EthGetTransactionByHashJsonRpcResponse = JsonRpcResponse<'eth_getTransactionByHash', TransactionResult, string>; /** * JSON-RPC response for `eth_getTransactionByBlockHashAndIndex` procedure */ type EthGetTransactionByBlockHashAndIndexJsonRpcResponse = JsonRpcResponse<'eth_getTransactionByBlockHashAndIndex', TransactionResult, string>; /** * JSON-RPC response for `eth_getTransactionByBlockNumberAndIndex` procedure */ type EthGetTransactionByBlockNumberAndIndexJsonRpcResponse = JsonRpcResponse<'eth_getTransactionByBlockNumberAndIndex', TransactionResult, string>; /** * JSON-RPC response for `eth_getTransactionReceipt` procedure */ type EthGetTransactionReceiptJsonRpcResponse = JsonRpcResponse<'eth_getTransactionReceipt', TransactionReceiptResult, string>; /** * JSON-RPC response for `eth_getUncleByBlockHashAndIndex` procedure */ type EthGetUncleByBlockHashAndIndexJsonRpcResponse = JsonRpcResponse<'eth_getUncleByBlockHashAndIndex', Hex, string>; /** * JSON-RPC response for `eth_getUncleByBlockNumberAndIndex` procedure */ type EthGetUncleByBlockNumberAndIndexJsonRpcResponse = JsonRpcResponse<'eth_getUncleByBlockNumberAndIndex', Hex, string>; /** * JSON-RPC response for `eth_mining` procedure */ type EthMiningJsonRpcResponse = JsonRpcResponse<'eth_mining', boolean, string>; /** * JSON-RPC response for `eth_protocolVersion` procedure */ type EthProtocolVersionJsonRpcResponse = JsonRpcResponse<'eth_protocolVersion', Hex, string>; /** * JSON-RPC response for `eth_sendRawTransaction` procedure */ type EthSendRawTransactionJsonRpcResponse = JsonRpcResponse<'eth_sendRawTransaction', Hex, string>; /** * JSON-RPC response for `eth_sendTransaction` procedure */ type EthSendTransactionJsonRpcResponse = JsonRpcResponse<'eth_sendTransaction', Hex, string>; /** * JSON-RPC response for `eth_sign` procedure */ type EthSignJsonRpcResponse = JsonRpcResponse<'eth_sign', Hex, string>; /** * JSON-RPC response for `eth_signTransaction` procedure */ type EthSignTransactionJsonRpcResponse = JsonRpcResponse<'eth_signTransaction', Hex, string>; /** * JSON-RPC response for `eth_syncing` procedure */ type EthSyncingJsonRpcResponse = JsonRpcResponse<'eth_syncing', boolean | { startingBlock: Hex; currentBlock: Hex; highestBlock: Hex; headedBytecodebytes?: Hex; healedBytecodes?: Hex; healedTrienodes?: Hex; healingBytecode?: Hex; healingTrienodes?: Hex; syncedBytecodeBytes?: Hex; syncedBytecodes?: Hex; syncedStorage?: Hex; syncedStorageBytes?: Hex; pulledStates: Hex; knownStates: Hex; }, string>; /** * JSON-RPC response for `eth_newFilter` procedure */ type EthNewFilterJsonRpcResponse = JsonRpcResponse<'eth_newFilter', Hex, string>; /** * JSON-RPC response for `eth_newBlockFilter` procedure */ type EthNewBlockFilterJsonRpcResponse = JsonRpcResponse<'eth_newBlockFilter', Hex, string>; /** * JSON-RPC response for `eth_newPendingTransactionFilter` procedure */ type EthNewPendingTransactionFilterJsonRpcResponse = JsonRpcResponse<'eth_newPendingTransactionFilter', Hex, string>; /** * JSON-RPC response for `eth_uninstallFilter` procedure */ type EthUninstallFilterJsonRpcResponse = JsonRpcResponse<'eth_uninstallFilter', boolean, string>; type AnvilError = string; /** * JSON-RPC response for `anvil_impersonateAccount` procedure */ type AnvilImpersonateAccountJsonRpcResponse = JsonRpcResponse<'anvil_impersonateAccount', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_stopImpersonatingAccount` procedure */ type AnvilStopImpersonatingAccountJsonRpcResponse = JsonRpcResponse<'anvil_stopImpersonatingAccount', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_autoImpersonateAccount` procedure * Not included atm because tevm_call supports it and i was getting methodNotFound errors trying it in anvil */ /** * JSON-RPC response for `anvil_getAutomine` procedure */ type AnvilGetAutomineJsonRpcResponse = JsonRpcResponse<'anvil_getAutomine', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_mine` procedure */ type AnvilMineJsonRpcResponse = JsonRpcResponse<'anvil_mine', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_reset` procedure */ type AnvilResetJsonRpcResponse = JsonRpcResponse<'anvil_reset', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_dropTransaction` procedure */ type AnvilDropTransactionJsonRpcResponse = JsonRpcResponse<'anvil_dropTransaction', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_setBalance` procedure */ type AnvilSetBalanceJsonRpcResponse = JsonRpcResponse<'anvil_setBalance', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_setCode` procedure */ type AnvilSetCodeJsonRpcResponse = JsonRpcResponse<'anvil_setCode', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_setNonce` procedure */ type AnvilSetNonceJsonRpcResponse = JsonRpcResponse<'anvil_setNonce', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_setStorageAt` procedure */ type AnvilSetStorageAtJsonRpcResponse = JsonRpcResponse<'anvil_setStorageAt', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_setChainId` procedure */ type AnvilSetChainIdJsonRpcResponse = JsonRpcResponse<'anvil_setChainId', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_dumpState` procedure */ type AnvilDumpStateJsonRpcResponse = JsonRpcResponse<'anvil_dumpState', SerializeToJson, AnvilError>; /** * JSON-RPC response for `anvil_loadState` procedure */ type AnvilLoadStateJsonRpcResponse = JsonRpcResponse<'anvil_loadState', SerializeToJson, AnvilError>; type DebugError = string; /** * JSON-RPC response for `debug_traceTransaction` procedure */ type DebugTraceTransactionJsonRpcResponse = JsonRpcResponse<'debug_traceTransaction', SerializeToJson, DebugError>; /** * JSON-RPC response for `debug_traceCall` procedure */ type DebugTraceCallJsonRpcResponse = JsonRpcResponse<'debug_traceCall', SerializeToJson, DebugError>; /** * Account JSON-RPC tevm procedure puts an account or contract into the tevm state */ type AccountJsonRpcProcedure = (request: AccountJsonRpcRequest) => Promise; /** * Call JSON-RPC procedure executes a call against the tevm EVM */ type CallJsonRpcProcedure = (request: CallJsonRpcRequest) => Promise; /** * Since ContractJsonRpcProcedure is a quality of life wrapper around CallJsonRpcProcedure * We choose to overload the type instead of creating a new one. Tevm contract handlers encode their * contract call as a normal call request over JSON-rpc */ type ContractJsonRpcProcedure = CallJsonRpcRequest; /** * Procedure for handling script JSON-RPC requests */ type ScriptJsonRpcProcedure = (request: ScriptJsonRpcRequest) => Promise; type EthAccountsJsonRpcProcedure = (request: EthAccountsJsonRpcRequest) => Promise; type EthBlockNumberJsonRpcProcedure = (request: EthBlockNumberJsonRpcRequest) => Promise; type EthCallJsonRpcProcedure = (request: EthCallJsonRpcRequest) => Promise; type EthChainIdJsonRpcProcedure = (request: EthChainIdJsonRpcRequest) => Promise; type EthCoinbaseJsonRpcProcedure = (request: EthCoinbaseJsonRpcRequest) => Promise; type EthEstimateGasJsonRpcProcedure = (request: EthEstimateGasJsonRpcRequest) => Promise; type EthHashrateJsonRpcProcedure = (request: EthHashrateJsonRpcRequest) => Promise; type EthGasPriceJsonRpcProcedure = (request: EthGasPriceJsonRpcRequest) => Promise; type EthGetBalanceJsonRpcProcedure = (request: EthGetBalanceJsonRpcRequest) => Promise; type EthGetBlockByHashJsonRpcProcedure = (request: EthGetBlockByHashJsonRpcRequest) => Promise; type EthGetBlockByNumberJsonRpcProcedure = (request: EthGetBlockByNumberJsonRpcRequest) => Promise; type EthGetBlockTransactionCountByHashJsonRpcProcedure = (request: EthGetBlockTransactionCountByHashJsonRpcRequest) => Promise; type EthGetBlockTransactionCountByNumberJsonRpcProcedure = (request: EthGetBlockTransactionCountByNumberJsonRpcRequest) => Promise; type EthGetCodeJsonRpcProcedure = (request: EthGetCodeJsonRpcRequest) => Promise; type EthGetFilterChangesJsonRpcProcedure = (request: EthGetFilterChangesJsonRpcRequest) => Promise; type EthGetFilterLogsJsonRpcProcedure = (request: EthGetFilterLogsJsonRpcRequest) => Promise; type EthGetLogsJsonRpcProcedure = (request: EthGetLogsJsonRpcRequest) => Promise; type EthGetStorageAtJsonRpcProcedure = (request: EthGetStorageAtJsonRpcRequest) => Promise; type EthGetTransactionCountJsonRpcProcedure = (request: EthGetTransactionCountJsonRpcRequest) => Promise; type EthGetUncleCountByBlockHashJsonRpcProcedure = (request: EthGetUncleCountByBlockHashJsonRpcRequest) => Promise; type EthGetUncleCountByBlockNumberJsonRpcProcedure = (request: EthGetUncleCountByBlockNumberJsonRpcRequest) => Promise; type EthGetTransactionByHashJsonRpcProcedure = (request: EthGetTransactionByHashJsonRpcRequest) => Promise; type EthGetTransactionByBlockHashAndIndexJsonRpcProcedure = (request: EthGetTransactionByBlockHashAndIndexJsonRpcRequest) => Promise; type EthGetTransactionByBlockNumberAndIndexJsonRpcProcedure = (request: EthGetTransactionByBlockNumberAndIndexJsonRpcRequest) => Promise; type EthGetTransactionReceiptJsonRpcProcedure = (request: EthGetTransactionReceiptJsonRpcRequest) => Promise; type EthGetUncleByBlockHashAndIndexJsonRpcProcedure = (request: EthGetUncleByBlockHashAndIndexJsonRpcRequest) => Promise; type EthGetUncleByBlockNumberAndIndexJsonRpcProcedure = (request: EthGetUncleByBlockNumberAndIndexJsonRpcRequest) => Promise; type EthMiningJsonRpcProcedure = (request: EthMiningJsonRpcRequest) => Promise; type EthProtocolVersionJsonRpcProcedure = (request: EthProtocolVersionJsonRpcRequest) => Promise; type EthSendRawTransactionJsonRpcProcedure = (request: EthSendRawTransactionJsonRpcRequest) => Promise; type EthSendTransactionJsonRpcProcedure = (request: EthSendTransactionJsonRpcRequest) => Promise; type EthSignJsonRpcProcedure = (request: EthSignJsonRpcRequest) => Promise; type EthSignTransactionJsonRpcProcedure = (request: EthSignTransactionJsonRpcRequest) => Promise; type EthSyncingJsonRpcProcedure = (request: EthSyncingJsonRpcRequest) => Promise; type EthNewFilterJsonRpcProcedure = (request: EthNewFilterJsonRpcRequest) => Promise; type EthNewBlockFilterJsonRpcProcedure = (request: EthNewBlockFilterJsonRpcRequest) => Promise; type EthNewPendingTransactionFilterJsonRpcProcedure = (request: EthNewPendingTransactionFilterJsonRpcRequest) => Promise; type EthUninstallFilterJsonRpcProcedure = (request: EthUninstallFilterJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_impersonateAccount` */ type AnvilImpersonateAccountProcedure = (request: AnvilImpersonateAccountJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_stopImpersonatingAccount` */ type AnvilStopImpersonatingAccountProcedure = (request: AnvilStopImpersonatingAccountJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_autoImpersonateAccount` * Not included atm because tevm_call supports it and i was getting methodNotFound errors trying it in anvil */ /** * JSON-RPC procedure for `anvil_getAutomine` */ type AnvilGetAutomineProcedure = (request: AnvilGetAutomineJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_mine` */ type AnvilMineProcedure = (request: AnvilMineJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_reset` */ type AnvilResetProcedure = (request: AnvilResetJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_dropTransaction` */ type AnvilDropTransactionProcedure = (request: AnvilDropTransactionJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_setBalance` */ type AnvilSetBalanceProcedure = (request: AnvilSetBalanceJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_setCode` */ type AnvilSetCodeProcedure = (request: AnvilSetCodeJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_setNonce` */ type AnvilSetNonceProcedure = (request: AnvilSetNonceJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_setStorageAt` */ type AnvilSetStorageAtProcedure = (request: AnvilSetStorageAtJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_setChainId` */ type AnvilSetChainIdProcedure = (request: AnvilSetChainIdJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_dumpState` */ type AnvilDumpStateProcedure = (request: AnvilDumpStateJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `anvil_loadState` */ type AnvilLoadStateProcedure = (request: AnvilLoadStateJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `debug_traceTransaction` */ type DebugTraceTransactionProcedure = (request: DebugTraceTransactionJsonRpcRequest) => Promise; /** * JSON-RPC procedure for `debug_traceCall` */ type DebugTraceCallProcedure = (request: DebugTraceCallJsonRpcRequest) => Promise; type DebugReturnType = { debug_traceTransaction: DebugTraceTransactionJsonRpcResponse; debug_traceCall: DebugTraceCallJsonRpcResponse; }; type AnvilReturnType = { anvil_impersonateAccount: AnvilImpersonateAccountJsonRpcResponse; anvil_stopImpersonatingAccount: AnvilStopImpersonatingAccountJsonRpcResponse; anvil_getAutomine: AnvilGetAutomineJsonRpcResponse; anvil_mine: AnvilMineJsonRpcResponse; anvil_reset: AnvilResetJsonRpcResponse; anvil_dropTransaction: AnvilDropTransactionJsonRpcResponse; anvil_setBalance: AnvilSetBalanceJsonRpcResponse; anvil_setCode: AnvilSetCodeJsonRpcResponse; anvil_setNonce: AnvilSetNonceJsonRpcResponse; anvil_setStorageAt: AnvilSetStorageAtJsonRpcResponse; anvil_setChainId: AnvilSetChainIdJsonRpcResponse; anvil_dumpState: AnvilDumpStateJsonRpcResponse; anvil_loadState: AnvilLoadStateJsonRpcResponse; }; type EthReturnType = { eth_call: EthCallJsonRpcResponse; eth_gasPrice: EthGasPriceJsonRpcResponse; eth_sign: EthSignJsonRpcResponse; eth_newBlockFilter: EthNewBlockFilterJsonRpcResponse; eth_mining: EthMiningJsonRpcResponse; eth_chainId: EthChainIdJsonRpcResponse; eth_getCode: EthGetCodeJsonRpcResponse; eth_getLogs: EthGetLogsJsonRpcResponse; eth_syncing: EthSyncingJsonRpcResponse; eth_accounts: EthAccountsJsonRpcResponse; eth_coinbase: EthCoinbaseJsonRpcResponse; eth_hashrate: EthHashrateJsonRpcResponse; eth_newFilter: EthNewFilterJsonRpcResponse; eth_getBalance: EthGetBalanceJsonRpcResponse; eth_blockNumber: EthBlockNumberJsonRpcResponse; eth_estimateGas: EthEstimateGasJsonRpcResponse; eth_getStorageAt: EthGetStorageAtJsonRpcResponse; eth_getFilterLogs: EthGetFilterLogsJsonRpcResponse; eth_getBlockByHash: EthGetBlockByHashJsonRpcResponse; eth_protocolVersion: EthProtocolVersionJsonRpcResponse; eth_sendTransaction: EthSendTransactionJsonRpcResponse; eth_signTransaction: EthSignTransactionJsonRpcResponse; eth_uninstallFilter: EthUninstallFilterJsonRpcResponse; eth_getBlockByNumber: EthGetBlockByNumberJsonRpcResponse; eth_getFilterChanges: EthGetFilterChangesJsonRpcResponse; eth_sendRawTransaction: EthSendRawTransactionJsonRpcResponse; eth_getTransactionCount: EthGetTransactionCountJsonRpcResponse; eth_getTransactionByHash: EthGetTransactionByHashJsonRpcResponse; eth_getTransactionReceipt: EthGetTransactionReceiptJsonRpcResponse; eth_getUncleCountByBlockHash: EthGetUncleCountByBlockHashJsonRpcResponse; eth_getUncleCountByBlockNumber: EthGetUncleCountByBlockNumberJsonRpcResponse; eth_getUncleByBlockHashAndIndex: EthGetUncleByBlockHashAndIndexJsonRpcResponse; eth_newPendingTransactionFilter: EthNewPendingTransactionFilterJsonRpcResponse; eth_getUncleByBlockNumberAndIndex: EthGetUncleByBlockNumberAndIndexJsonRpcResponse; eth_getBlockTransactionCountByHash: EthGetBlockTransactionCountByHashJsonRpcResponse; eth_getBlockTransactionCountByNumber: EthGetBlockTransactionCountByNumberJsonRpcResponse; eth_getTransactionByBlockHashAndIndex: EthGetTransactionByBlockHashAndIndexJsonRpcResponse; eth_getTransactionByBlockNumberAndIndex: EthGetTransactionByBlockNumberAndIndexJsonRpcResponse; }; type TevmReturnType = { tevm_call: CallJsonRpcResponse; tevm_script: ScriptJsonRpcResponse; tevm_account: AccountJsonRpcResponse; }; type ReturnType = (EthReturnType & TevmReturnType & AnvilReturnType & DebugReturnType)[TMethod]; /** * Type of a JSON-RPC request handler for tevm procedures * Generic and returns the correct response type for a given request */ type TevmJsonRpcRequestHandler = (request: TRequest) => Promise>; type EthJsonRpcRequestHandler = (request: TRequest) => Promise; /** * The specification for the Tevm api * It has a request method for JSON-RPC requests and more ergonomic handler methods * for each type of request */ type Tevm = { request: TevmJsonRpcRequestHandler; script: ScriptHandler; account: AccountHandler; call: CallHandler; contract: ContractHandler; eth: { blockNumber: EthBlockNumberHandler; chainId: EthChainIdHandler; getCode: EthGetCodeHandler; getStorageAt: EthGetStorageAtHandler; gasPrice: EthGasPriceHandler; getBalance: EthGetBalanceHandler; }; }; export type { AccountError, AccountHandler, AccountJsonRpcProcedure, AccountJsonRpcRequest, AccountJsonRpcResponse, AccountParams, AccountResult, AnvilDropTransactionHandler, AnvilDropTransactionJsonRpcRequest, AnvilDropTransactionJsonRpcResponse, AnvilDropTransactionParams, AnvilDropTransactionProcedure, AnvilDropTransactionResult, AnvilDumpStateHandler, AnvilDumpStateJsonRpcRequest, AnvilDumpStateJsonRpcResponse, AnvilDumpStateParams, AnvilDumpStateProcedure, AnvilDumpStateResult, AnvilGetAutomineHandler, AnvilGetAutomineJsonRpcRequest, AnvilGetAutomineJsonRpcResponse, AnvilGetAutomineParams, AnvilGetAutomineProcedure, AnvilGetAutomineResult, AnvilImpersonateAccountHandler, AnvilImpersonateAccountJsonRpcRequest, AnvilImpersonateAccountJsonRpcResponse, AnvilImpersonateAccountParams, AnvilImpersonateAccountProcedure, AnvilImpersonateAccountResult, AnvilLoadStateHandler, AnvilLoadStateJsonRpcRequest, AnvilLoadStateJsonRpcResponse, AnvilLoadStateParams, AnvilLoadStateProcedure, AnvilLoadStateResult, AnvilMineHandler, AnvilMineJsonRpcRequest, AnvilMineJsonRpcResponse, AnvilMineParams, AnvilMineProcedure, AnvilMineResult, AnvilResetHandler, AnvilResetJsonRpcRequest, AnvilResetJsonRpcResponse, AnvilResetParams, AnvilResetProcedure, AnvilResetResult, AnvilSetBalanceHandler, AnvilSetBalanceJsonRpcRequest, AnvilSetBalanceJsonRpcResponse, AnvilSetBalanceParams, AnvilSetBalanceProcedure, AnvilSetBalanceResult, AnvilSetChainIdHandler, AnvilSetChainIdJsonRpcRequest, AnvilSetChainIdJsonRpcResponse, AnvilSetChainIdParams, AnvilSetChainIdProcedure, AnvilSetChainIdResult, AnvilSetCodeHandler, AnvilSetCodeJsonRpcRequest, AnvilSetCodeJsonRpcResponse, AnvilSetCodeParams, AnvilSetCodeProcedure, AnvilSetCodeResult, AnvilSetNonceHandler, AnvilSetNonceJsonRpcRequest, AnvilSetNonceJsonRpcResponse, AnvilSetNonceParams, AnvilSetNonceProcedure, AnvilSetNonceResult, AnvilSetStorageAtHandler, AnvilSetStorageAtJsonRpcRequest, AnvilSetStorageAtJsonRpcResponse, AnvilSetStorageAtParams, AnvilSetStorageAtProcedure, AnvilSetStorageAtResult, AnvilStopImpersonatingAccountHandler, AnvilStopImpersonatingAccountJsonRpcRequest, AnvilStopImpersonatingAccountJsonRpcResponse, AnvilStopImpersonatingAccountParams, AnvilStopImpersonatingAccountProcedure, AnvilStopImpersonatingAccountResult, BaseCallError, BaseCallParams, Block, BlockResult, CallError, CallHandler, CallJsonRpcProcedure, CallJsonRpcRequest, CallJsonRpcResponse, CallParams, CallResult, ContractError, ContractHandler, ContractJsonRpcProcedure, ContractJsonRpcRequest, ContractJsonRpcResponse, ContractParams, ContractResult, DebugTraceCallHandler, DebugTraceCallJsonRpcRequest, DebugTraceCallJsonRpcResponse, DebugTraceCallParams, DebugTraceCallProcedure, DebugTraceCallResult, DebugTraceTransactionHandler, DebugTraceTransactionJsonRpcRequest, DebugTraceTransactionJsonRpcResponse, DebugTraceTransactionParams, DebugTraceTransactionProcedure, DebugTraceTransactionResult, EthAccountsHandler, EthAccountsJsonRpcProcedure, EthAccountsJsonRpcRequest, EthAccountsJsonRpcResponse, EthAccountsParams, EthAccountsResult, EthBlockNumberHandler, EthBlockNumberJsonRpcProcedure, EthBlockNumberJsonRpcRequest, EthBlockNumberJsonRpcResponse, EthBlockNumberParams, EthBlockNumberResult, EthCallHandler, EthCallJsonRpcProcedure, EthCallJsonRpcRequest, EthCallJsonRpcResponse, EthCallParams, EthCallResult, EthChainIdHandler, EthChainIdJsonRpcProcedure, EthChainIdJsonRpcRequest, EthChainIdJsonRpcResponse, EthChainIdParams, EthChainIdResult, EthCoinbaseHandler, EthCoinbaseJsonRpcProcedure, EthCoinbaseJsonRpcRequest, EthCoinbaseJsonRpcResponse, EthCoinbaseParams, EthCoinbaseResult, EthEstimateGasHandler, EthEstimateGasJsonRpcProcedure, EthEstimateGasJsonRpcRequest, EthEstimateGasJsonRpcResponse, EthEstimateGasParams, EthEstimateGasResult, EthGasPriceHandler, EthGasPriceJsonRpcProcedure, EthGasPriceJsonRpcRequest, EthGasPriceJsonRpcResponse, EthGasPriceParams, EthGasPriceResult, EthGetBalanceHandler, EthGetBalanceJsonRpcProcedure, EthGetBalanceJsonRpcRequest, EthGetBalanceJsonRpcResponse, EthGetBalanceParams, EthGetBalanceResult, EthGetBlockByHashHandler, EthGetBlockByHashJsonRpcProcedure, EthGetBlockByHashJsonRpcRequest, EthGetBlockByHashJsonRpcResponse, EthGetBlockByHashParams, EthGetBlockByHashResult, EthGetBlockByNumberHandler, EthGetBlockByNumberJsonRpcProcedure, EthGetBlockByNumberJsonRpcRequest, EthGetBlockByNumberJsonRpcResponse, EthGetBlockByNumberParams, EthGetBlockByNumberResult, EthGetBlockTransactionCountByHashHandler, EthGetBlockTransactionCountByHashJsonRpcProcedure, EthGetBlockTransactionCountByHashJsonRpcRequest, EthGetBlockTransactionCountByHashJsonRpcResponse, EthGetBlockTransactionCountByHashParams, EthGetBlockTransactionCountByHashResult, EthGetBlockTransactionCountByNumberHandler, EthGetBlockTransactionCountByNumberJsonRpcProcedure, EthGetBlockTransactionCountByNumberJsonRpcRequest, EthGetBlockTransactionCountByNumberJsonRpcResponse, EthGetBlockTransactionCountByNumberParams, EthGetBlockTransactionCountByNumberResult, EthGetCodeHandler, EthGetCodeJsonRpcProcedure, EthGetCodeJsonRpcRequest, EthGetCodeJsonRpcResponse, EthGetCodeParams, EthGetCodeResult, EthGetFilterChangesHandler, EthGetFilterChangesJsonRpcProcedure, EthGetFilterChangesJsonRpcRequest, EthGetFilterChangesJsonRpcResponse, EthGetFilterChangesParams, EthGetFilterChangesResult, EthGetFilterLogsHandler, EthGetFilterLogsJsonRpcProcedure, EthGetFilterLogsJsonRpcRequest, EthGetFilterLogsJsonRpcResponse, EthGetFilterLogsParams, EthGetFilterLogsResult, EthGetLogsHandler, EthGetLogsJsonRpcProcedure, EthGetLogsJsonRpcRequest, EthGetLogsJsonRpcResponse, EthGetLogsParams, EthGetLogsResult, EthGetStorageAtHandler, EthGetStorageAtJsonRpcProcedure, EthGetStorageAtJsonRpcRequest, EthGetStorageAtJsonRpcResponse, EthGetStorageAtParams, EthGetStorageAtResult, EthGetTransactionByBlockHashAndIndexHandler, EthGetTransactionByBlockHashAndIndexJsonRpcProcedure, EthGetTransactionByBlockHashAndIndexJsonRpcRequest, EthGetTransactionByBlockHashAndIndexJsonRpcResponse, EthGetTransactionByBlockHashAndIndexParams, EthGetTransactionByBlockHashAndIndexResult, EthGetTransactionByBlockNumberAndIndexHandler, EthGetTransactionByBlockNumberAndIndexJsonRpcProcedure, EthGetTransactionByBlockNumberAndIndexJsonRpcRequest, EthGetTransactionByBlockNumberAndIndexJsonRpcResponse, EthGetTransactionByBlockNumberAndIndexParams, EthGetTransactionByBlockNumberAndIndexResult, EthGetTransactionByHashHandler, EthGetTransactionByHashJsonRpcProcedure, EthGetTransactionByHashJsonRpcRequest, EthGetTransactionByHashJsonRpcResponse, EthGetTransactionByHashParams, EthGetTransactionByHashResult, EthGetTransactionCountHandler, EthGetTransactionCountJsonRpcProcedure, EthGetTransactionCountJsonRpcRequest, EthGetTransactionCountJsonRpcResponse, EthGetTransactionCountParams, EthGetTransactionCountResult, EthGetTransactionReceiptHandler, EthGetTransactionReceiptJsonRpcProcedure, EthGetTransactionReceiptJsonRpcRequest, EthGetTransactionReceiptJsonRpcResponse, EthGetTransactionReceiptParams, EthGetTransactionReceiptResult, EthGetUncleByBlockHashAndIndexHandler, EthGetUncleByBlockHashAndIndexJsonRpcProcedure, EthGetUncleByBlockHashAndIndexJsonRpcRequest, EthGetUncleByBlockHashAndIndexJsonRpcResponse, EthGetUncleByBlockHashAndIndexParams, EthGetUncleByBlockHashAndIndexResult, EthGetUncleByBlockNumberAndIndexHandler, EthGetUncleByBlockNumberAndIndexJsonRpcProcedure, EthGetUncleByBlockNumberAndIndexJsonRpcRequest, EthGetUncleByBlockNumberAndIndexJsonRpcResponse, EthGetUncleByBlockNumberAndIndexParams, EthGetUncleByBlockNumberAndIndexResult, EthGetUncleCountByBlockHashHandler, EthGetUncleCountByBlockHashJsonRpcProcedure, EthGetUncleCountByBlockHashJsonRpcRequest, EthGetUncleCountByBlockHashJsonRpcResponse, EthGetUncleCountByBlockHashParams, EthGetUncleCountByBlockHashResult, EthGetUncleCountByBlockNumberHandler, EthGetUncleCountByBlockNumberJsonRpcProcedure, EthGetUncleCountByBlockNumberJsonRpcRequest, EthGetUncleCountByBlockNumberJsonRpcResponse, EthGetUncleCountByBlockNumberParams, EthGetUncleCountByBlockNumberResult, EthHashrateHandler, EthHashrateJsonRpcProcedure, EthHashrateJsonRpcRequest, EthHashrateJsonRpcResponse, EthHashrateParams, EthHashrateResult, EthJsonRpcRequest, EthJsonRpcRequestHandler, EthMiningHandler, EthMiningJsonRpcProcedure, EthMiningJsonRpcRequest, EthMiningJsonRpcResponse, EthMiningParams, EthMiningResult, EthNewBlockFilterHandler, EthNewBlockFilterJsonRpcProcedure, EthNewBlockFilterJsonRpcRequest, EthNewBlockFilterJsonRpcResponse, EthNewBlockFilterParams, EthNewBlockFilterResult, EthNewFilterHandler, EthNewFilterJsonRpcProcedure, EthNewFilterJsonRpcRequest, EthNewFilterJsonRpcResponse, EthNewFilterParams, EthNewFilterResult, EthNewPendingTransactionFilterHandler, EthNewPendingTransactionFilterJsonRpcProcedure, EthNewPendingTransactionFilterJsonRpcRequest, EthNewPendingTransactionFilterJsonRpcResponse, EthNewPendingTransactionFilterParams, EthNewPendingTransactionFilterResult, EthParams, EthProtocolVersionHandler, EthProtocolVersionJsonRpcProcedure, EthProtocolVersionJsonRpcRequest, EthProtocolVersionJsonRpcResponse, EthProtocolVersionParams, EthProtocolVersionResult, EthSendRawTransactionHandler, EthSendRawTransactionJsonRpcProcedure, EthSendRawTransactionJsonRpcRequest, EthSendRawTransactionJsonRpcResponse, EthSendRawTransactionParams, EthSendRawTransactionResult, EthSendTransactionHandler, EthSendTransactionJsonRpcProcedure, EthSendTransactionJsonRpcRequest, EthSendTransactionJsonRpcResponse, EthSendTransactionParams, EthSendTransactionResult, EthSignHandler, EthSignJsonRpcProcedure, EthSignJsonRpcRequest, EthSignJsonRpcResponse, EthSignParams, EthSignResult, EthSignTransactionHandler, EthSignTransactionJsonRpcProcedure, EthSignTransactionJsonRpcRequest, EthSignTransactionJsonRpcResponse, EthSignTransactionParams, EthSignTransactionResult, EthSyncingHandler, EthSyncingJsonRpcProcedure, EthSyncingJsonRpcRequest, EthSyncingJsonRpcResponse, EthSyncingParams, EthSyncingResult, EthUninstallFilterHandler, EthUninstallFilterJsonRpcProcedure, EthUninstallFilterJsonRpcRequest, EthUninstallFilterJsonRpcResponse, EthUninstallFilterParams, EthUninstallFilterResult, EvmError, FilterLog, InvalidAddressError, InvalidBalanceError, InvalidBlobVersionedHashesError, InvalidBlockError, InvalidBytecodeError, InvalidCallerError, InvalidDataError, InvalidDeployedBytecodeError, InvalidDepthError, InvalidFunctionNameError, InvalidGasLimitError, InvalidGasPriceError, InvalidGasRefundError, InvalidNonceError, InvalidOriginError, InvalidRequestError, InvalidSaltError, InvalidSelfdestructError, InvalidSkipBalanceError, InvalidStorageRootError, InvalidToError, InvalidValueError, JsonRpcRequest, JsonRpcResponse, Log, ScriptError, ScriptHandler, ScriptJsonRpcProcedure, ScriptJsonRpcRequest, ScriptJsonRpcResponse, ScriptParams, ScriptResult, Tevm, TevmEVMErrorMessage, TevmJsonRpcRequest, TevmJsonRpcRequestHandler, TraceCall, TraceParams, TraceResult, TraceType, TransactionParams, TransactionReceiptResult, TransactionResult, TypedError, UnexpectedError };