import { StorageViewer } from './storage/storageViewer'; import { StorageResolver } from './storage/storageResolver'; import { TraceManager } from './trace/traceManager'; import { CodeManager } from './code/codeManager'; import { EventManager } from './eventManager'; import { SolidityProxy, InternalCallTree } from './solidity-decoder'; import { type BreakpointManager } from './code/breakpointManager'; import { CompilerAbstract } from '@remix-project/remix-solidity'; import { BrowserProvider } from 'ethers'; import type { OffsetToLineColumnConverterFn } from './types'; /** * Ethdebugger is a wrapper around a few classes that helps debug a transaction * * - TraceManager - Load / Analyze the trace and retrieve details of specific test * - CodeManager - Retrieve loaded byte code and help to resolve AST item from vmtrace index * - SolidityProxy - Basically used to extract state variable from AST * - Breakpoint Manager - Used to add / remove / jump to breakpoint * - InternalCallTree - Used to retrieve local variables * - StorageResolver - Help resolving the storage across different steps * * @param {Map} opts - { function compilationResult } // */ export declare class Ethdebugger { compilationResult: (contractAddress: string) => Promise; web3: BrowserProvider; opts: any; event: EventManager; tx: any; traceManager: TraceManager; codeManager: CodeManager; solidityProxy: SolidityProxy; storageResolver: StorageResolver; callTree: InternalCallTree; breakpointManager: BreakpointManager; offsetToLineColumnConverter: OffsetToLineColumnConverterFn; /** * Creates a new Ethdebugger instance with the specified options. * Initializes all necessary managers for debugging including TraceManager, CodeManager, * SolidityProxy, and InternalCallTree. * * @param {Object} opts - Configuration options * @param {Function} opts.compilationResult - Function to retrieve compilation results for a contract address * @param {Object} opts.offsetToLineColumnConverter - Converter for source code positions * @param {Object} opts.web3 - Web3 instance for blockchain interaction */ constructor(opts: any); /** * Reinitializes all manager instances with current web3 provider. * This resets TraceManager, CodeManager, SolidityProxy, InternalCallTree, and StorageResolver. * Typically called when the web3 provider changes. */ setManagers(): void; /** * resolve the code of the given @arg stepIndex and trigger appropriate event * * @param {String} stepIndex - vm trace step */ resolveStep(index: any): void; /** * Retrieves the source location (file, line, column) from a VM trace step index. * * @param {String} address - Contract address * @param {Number} stepIndex - VM trace step index * @returns {Promise} Source location object with file, start, and length information */ sourceLocationFromVMTraceIndex(address: any, stepIndex: any): Promise<{}>; /** * Retrieves a valid source location from a VM trace step index. * Similar to sourceLocationFromVMTraceIndex but ensures the location is valid (non-empty). * * @param {String} address - Contract address * @param {Number} stepIndex - VM trace step index * @returns {Promise} Valid source location object with file, start, and length information */ getValidSourceLocationFromVMTraceIndex(address: any, stepIndex: any): Promise>; /** * Retrieves the source location from an instruction index (bytecode position). * * @param {String} address - Contract address * @param {Number} instIndex - Instruction index in the bytecode * @returns {Promise} Source location object with file, start, and length information */ sourceLocationFromInstructionIndex(address: any, instIndex: any): Promise<{}>; /** * Sets the breakpoint manager for debugging sessions. * * @param {Object} breakpointManager - Breakpoint manager instance to handle breakpoints */ setBreakpointManager(breakpointManager: any): void; /** * Extracts the scope information (local variables context) at a specific execution step. * * @param {Number} step - Execution step index * @returns {Object} Scope information containing local variables for the given step */ extractLocalsAt(step: any): { slot: import("./solidity-decoder/symbolicStack").SymbolicStackSlot; position: number; }[]; /** * Decodes a local variable by its ID at a specific execution step. * Retrieves the variable from the call tree and decodes its value from the EVM stack and memory. * * @param {number} step - Execution step index * @param {number} id - Unique identifier of the local variable * @returns {Promise} Decoded variable value, or null if variable not found */ decodeLocalVariableById(step: number, id: number): Promise; /** * Decodes a state variable by its ID at a specific execution step. * Retrieves the state variable and decodes its value from contract storage. * * @param {number} step - Execution step index * @param {number} id - Unique identifier of the state variable * @returns {Promise} Decoded variable value, or null if variable not found */ decodeStateVariableById(step: number, id: number): Promise; /** * Decodes all local variables at a specific execution step and source location. * Uses the EVM stack, memory, storage, and calldata to reconstruct variable values. * * @param {Number} step - Execution step index * @param {Object} sourceLocation - Source code location for context * @param {Function} callback - Callback function with signature (error, locals) * @returns {Promise} Calls callback with decoded locals or error */ decodeLocalsAt(step: any, sourceLocation: any, callback: any): Promise; /** * Extracts all state variables at a specific execution step. * Returns metadata about the state variables without decoding their values. * * @param {Number} step - Execution step index * @returns {Promise} Array of state variable metadata objects */ extractStateAt(step: any): Promise; /** * Decodes the values of specified state variables at a specific execution step. * Retrieves values from contract storage and decodes them according to their types. * * @param {Number} step - Execution step index * @param {Array} stateVars - Array of state variable metadata to decode * @param {Function} [callback] - Optional callback function receiving the result or error * @returns {Promise} Object mapping variable names to their decoded values */ decodeStateAt(step: any, stateVars: any, callback?: any): Promise<{}>; /** * Creates a StorageViewer instance for inspecting contract storage at a specific step. * * @param {Number} step - Execution step index * @param {String} address - Contract address whose storage to view * @returns {StorageViewer} StorageViewer instance configured for the given step and address */ storageViewAt(step: any, address: any): StorageViewer; /** * Updates the Web3 provider and reinitializes all managers. * Call this when switching networks or providers. * * @param {Object} web3 - New Web3 instance */ updateWeb3(web3: any): void; /** * Unloads the current debugging session and clears all cached data. * Resets the trace manager, code manager, and solidity proxy to their initial states. * Triggers a 'traceUnloaded' event. */ unLoad(): void; /** * Starts debugging a transaction by loading and analyzing its execution trace. * Resolves the trace, triggers events, handles breakpoints, and initializes storage resolution. * * @param {Object} tx - Transaction object to debug * @param {String} tx.hash - Transaction hash * @param {String} [tx.to] - Recipient address (defaults to contract creation token if not provided) * @returns {Promise} Resolves when trace is loaded and ready for debugging */ debug(tx: any): Promise; /** * Retrieves the currently loaded execution trace. * * @returns {Array|undefined} The execution trace array, or undefined if no trace is loaded */ getTrace(): import("./types").StructLog[]; }