/* tslint:disable */ /* eslint-disable */ /** Represents a basic block in the control flow graph * @property id - Unique block identifier (CFG key) * @property start - Byte offset where the block's first opcode begins * @property end - Byte offset where the block's last opcode begins * @property type - Block type * @property data - Type-specific data */ export type Block = { id: number, start: number, end: number, type: 'Terminate' | 'Jump' | 'Jumpi' | 'DynamicJump' | 'DynamicJumpi'; } & ( | { type: 'Terminate'; data: { success: boolean }; } | { type: 'Jump'; data: { to: number }; } | { type: 'Jumpi'; data: { true_to: number; false_to: number }; } | { type: 'DynamicJump'; data: { to: DynamicJump[] }; } | { type: 'DynamicJumpi'; data: { true_to: DynamicJump[]; false_to: number }; } ); /** Represents a dynamic jump destination in the control flow * @property path - Path of block IDs leading to this jump * @property to - Destination block ID if known; use Block.start to get the bytecode offset */ export type DynamicJump = { path: number[]; to?: number; }; /** Represents the control flow graph of the contract bytecode * @property blocks - List of basic blocks in the control flow graph */ export type ControlFlowGraph = { blocks: Block[], }; /** * A possible implementation source: where a proxy's implementation address comes from. * `Address`: a fixed address in the code. `Storage`: an address in one of the proxy's own storage slots. * `Call`: the address a beacon or registry returns for the call. `PerSelector`: chosen by the incoming selector. * `Eip7702`: the address an EIP-7702 account delegates to. * Only a fallback that forwards the incoming calldata by DELEGATECALL counts. An implementation contract, * such as a UUPS implementation or a diamond facet, is not a proxy and gets an empty array. */ export type ProxySource = | { type: 'Address', data: string } | { type: 'Storage', data: StorageRef } | { type: 'Call', data: ProxyCall } | { type: 'PerSelector' } | { type: 'Eip7702', data: string }; /** * The call that returns the implementation address. * @property address - The callee * @property selector - 4-byte hex selector. Not present when the call sends empty calldata. * @property args - The 32-byte argument words after the selector */ export type ProxyCall = { address: ProxyValue, selector?: string, args: ProxyValue[] }; /** A callee address or argument word: a literal, or bytes of a storage slot in the word's low bytes. */ export type ProxyValue = | { type: 'Constant', data: string } | { type: 'Storage', data: StorageRef }; /** * `size` bytes of a storage slot, `offset` bytes from its low end. * @property slot - Storage slot as 64 hex digits */ export type StorageRef = { slot: string, offset: number, size: number }; /** * Analyzes contract bytecode and returns contract information based on specified options. * * @param code - Runtime bytecode as a hex string * @param args - Configuration options for the analysis * @param args.selectors - When true, includes function selectors in the output * @param args.arguments - When true, includes function arguments information * @param args.stateMutability - When true, includes state mutability information for functions * @param args.storage - When true, includes persistent and transient storage layout information * @param args.disassemble - When true, includes disassembled bytecode * @param args.basicBlocks - When true, includes basic block analysis * @param args.controlFlowGraph - When true, includes control flow graph analysis * @param args.metadata - When true, extracts terminal CBOR metadata * @param args.proxy - When true, infers possible proxy implementation sources * @returns Analyzed contract information */ export function contractInfo(code: string, args: { selectors?: boolean, arguments?: boolean, stateMutability?: boolean, storage?: boolean, disassemble?: boolean, basicBlocks?: boolean, controlFlowGraph?: boolean, metadata?: boolean, proxy?: boolean }): Contract; /** * Contains the analysis results of a contract * @property functions - Array of functions found in the contract. Not present if no functions were extracted. * @property storage - Array of persistent storage records found in the contract. Not present if storage layout was not extracted. * @property transientStorage - Array of transient storage records found in the contract. Not present if storage layout was not extracted. * @property disassembled - Array of bytecode instructions, where each element is a tuple of [offset: number, instruction: string] * @property basicBlocks - Array of basic blocks found in the contract. Not present if basic blocks were not analyzed. * @property controlFlowGraph - Control flow graph representation. Not present if CFG was not generated. * @property metadata - Terminal CBOR metadata. Not present unless requested and valid. * @property proxy - Possible implementation sources; an empty array means none was found. When several are found, the active one can depend on the caller or contract state. Not present unless requested. * @see ContractFunction * @see StorageRecord */ export type Contract = { functions?: ContractFunction[], storage?: StorageRecord[], transientStorage?: StorageRecord[], disassembled?: [number, string][], basicBlocks?: [number, number][], controlFlowGraph?: ControlFlowGraph, metadata?: CborMetadata, proxy?: ProxySource[], }; /** * Represents a function found in the contract bytecode * @property selector - Function selector as a 4-byte hex string without '0x' prefix (e.g., 'aabbccdd'). * @property bytecodeOffset - Starting byte offset within the EVM bytecode for the function body. * @property dispatch - Whether the selector is handled by the normal ABI dispatcher or fallback dispatch logic. * @property arguments - Function argument types in canonical format (e.g., 'uint256,address[]'). Not present if arguments were not extracted * @property stateMutability - Function's state mutability ("pure", "view", "payable", or "nonpayable"). Not present if state mutability were not extracted */ export type ContractFunction = { selector: string, bytecodeOffset: number, dispatch: 'abi' | 'fallback', arguments?: string, stateMutability?: string, }; /** * Represents a storage record found in the contract * @property slot - Storage slot as 64 hex digits without a '0x' prefix. * @property offset - Byte offset within the storage slot (0-31). * @property type - Variable type (e.g., 'uint256', 'mapping(address => uint256)', 'bytes32'). * @property reads - Array of function selectors that read from this storage location. * @property writes - Array of function selectors that write to this storage location. */ export type StorageRecord = { slot: string, offset: number, type: string, reads: string[], writes: string[] }; export type CborMetadata = { bytecodeOffset: number, cborLength: number, entries: CborEntry[], }; export type CborEntry = { key: string, value: CborValue }; export type CborValue = | { type: 'string', value: string } | { type: 'integer', value: number } | { type: 'bytes', value: string } | { type: 'bool', value: boolean } | { type: 'undecoded', value: string }; /** * @typedef {Object} Block * @description Represents a basic block in the control flow graph * @property {number} id - Unique block identifier (CFG key) * @property {number} start - Byte offset where the block's first opcode begins * @property {number} end - Byte offset where the block's last opcode begins * @property {('Terminate'|'Jump'|'Jumpi'|'DynamicJump'|'DynamicJumpi')} type - Block type * @property {(DataTerminate|DataJump|DataJumpi|DataDynamicJump|DataDynamicJumpi)} data - Type Type-specific block data */ export function dummy_block(): void; /** * @typedef {Object} DataDynamicJump * @property {DynamicJump[]} to - Possible computed jump destinations */ export function dummy_block_data_dynamic_jump(): void; /** * @typedef {Object} DataDynamicJumpi * @property {DynamicJump[]} true_to - Possible computed jump destinations if true * @property {number} false_to - Destination block ID if condition is false; use `Block.start` to get the bytecode offset */ export function dummy_block_data_dynamic_jumpi(): void; /** * @typedef {Object} DataJump * @property {number} to - Destination block ID; use `Block.start` to get the bytecode offset */ export function dummy_block_data_jump(): void; /** * @typedef {Object} DataJumpi * @property {number} true_to - Destination block ID if condition is true; use `Block.start` to get the bytecode offset * @property {number} false_to - Destination block ID if condition is false; use `Block.start` to get the bytecode offset */ export function dummy_block_data_jumpi(): void; /** * @typedef {Object} DataTerminate * @property {boolean} success - true for normal termination (STOP/RETURN), false for REVERT/INVALID */ export function dummy_block_data_terminate(): void; /** * @typedef {Object} CborEntry * @property {string} key * @property {CborValue} value */ export function dummy_cbor_entry(): void; /** * @typedef {Object} CborMetadata * @property {number} bytecodeOffset - Absolute byte offset of the CBOR payload * @property {number} cborLength - CBOR payload length, excluding the two-byte suffix * @property {Array} entries - Entries having text-string keys; other keys are skipped */ export function dummy_cbor_metadata(): void; /** * @typedef {Object} CborValue * @property {('string'|'integer'|'bytes'|'bool'|'undecoded')} type * @property {(string|number|boolean)} value - Decoded scalar or lowercase hex-encoded CBOR bytes */ export function dummy_cbor_value(): void; /** * @typedef {Object} Contract * @description Contains the analysis results of a contract * @property {ContractFunction[]} [functions] - Array of functions found in the contract. Not present if no functions were extracted * @property {StorageRecord[]} [storage] - Array of persistent storage records found in the contract. Not present if storage layout was not extracted * @property {StorageRecord[]} [transientStorage] - Array of transient storage records found in the contract. Not present if storage layout was not extracted * @property {Array>} [disassembled] - Array of bytecode instructions, where each element is [offset, instruction] * @property {Array>} [basicBlocks] - Array of basic blocks found in the contract. Not present if basic blocks were not analyzed. * @property {ControlFlowGraph} [controlFlowGraph] - Control flow graph representation. Not present if CFG was not generated. * @property {CborMetadata} [metadata] - Terminal CBOR metadata. Not present unless requested and valid. * @property {ProxySource[]} [proxy] - Possible implementation sources; an empty array means none was found. When several are found, the active one can depend on the caller or contract state. Not present unless requested. */ export function dummy_contract(): void; /** * @typedef {Object} ControlFlowGraph * @description Represents the control flow graph of the contract bytecode * @property {Block[]} blocks - List of basic blocks in the control flow graph */ export function dummy_control_flow_graph(): void; /** * @typedef {Object} DynamicJump * @description Represents a dynamic jump destination in the control flow * @property {number[]} path - Path of block IDs leading to this jump * @property {number} [to] - Destination block ID if known; use `Block.start` to get the bytecode offset. Optional */ export function dummy_dynamic_jump(): void; /** * @typedef {Object} ContractFunction * @description Represents a function found in the contract bytecode * @property {string} selector - Function selector as a 4-byte hex string without '0x' prefix (e.g., 'aabbccdd') * @property {number} bytecodeOffset - Starting byte offset within the EVM bytecode for the function body * @property {('abi'|'fallback')} dispatch - Whether the selector is handled by the normal ABI dispatcher or fallback dispatch logic * @property {string} [arguments] - Function argument types in canonical format (e.g., 'uint256,address[]'). Not present if arguments were not extracted * @property {string} [stateMutability] - Function's state mutability ("pure", "view", "payable", or "nonpayable"). Not present if state mutability were not extracted */ export function dummy_function(): void; /** * @typedef {Object} ProxyCall * @description The call that returns the implementation address * @property {ProxyValue} address - The callee * @property {string} [selector] - 4-byte hex selector. Not present when the call sends empty calldata * @property {ProxyValue[]} args - The 32-byte argument words after the selector */ export function dummy_proxy_call(): void; /** * @typedef {Object} ProxySource * @description A possible implementation source: where a proxy's implementation address comes from. Only a fallback that forwards the incoming calldata by DELEGATECALL counts. An implementation contract, such as a UUPS implementation or a diamond facet, is not a proxy and gets an empty array. * @property {('Address'|'Storage'|'Call'|'PerSelector'|'Eip7702')} type - `Address`: a fixed address in the code; `Storage`: an address in one of the proxy's own storage slots; `Call`: the address a beacon or registry returns for the call; `PerSelector`: chosen by the incoming selector; `Eip7702`: the address an EIP-7702 account delegates to * @property {(string|StorageRef|ProxyCall)} [data] - The address for `Address` and `Eip7702` (40 lowercase hex digits), a `StorageRef` for `Storage`, a `ProxyCall` for `Call`. Not present for `PerSelector` */ export function dummy_proxy_source(): void; /** * @typedef {Object} ProxyValue * @description A callee address or argument word * @property {('Constant'|'Storage')} type * @property {(string|StorageRef)} data - A literal (40 hex digits for a callee, 64 for an argument word), or a `StorageRef` whose bytes sit in the word's low bytes */ export function dummy_proxy_value(): void; /** * Represents a storage record found in the contract * * @typedef {Object} StorageRecord * @property {string} slot - Storage slot as 64 hex digits without a '0x' prefix * @property {number} offset - Byte offset within the storage slot (0-31) * @property {string} type - Variable type (e.g., 'uint256', 'mapping(address => uint256)', 'bytes32') * @property {string[]} reads - Array of function selectors that read from this storage location * @property {string[]} writes - Array of function selectors that write to this storage location */ export function dummy_storage_record(): void; /** * @typedef {Object} StorageRef * @description `size` bytes of a storage slot, `offset` bytes from its low end * @property {string} slot - Storage slot as 64 hex digits * @property {number} offset - Byte offset from the slot's low end * @property {number} size - Size in bytes */ export function dummy_storage_ref(): void; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly contractInfo: (a: number, b: number, c: number, d: any) => void; readonly dummy_block: () => void; readonly dummy_block_data_dynamic_jump: () => void; readonly dummy_block_data_dynamic_jumpi: () => void; readonly dummy_block_data_jump: () => void; readonly dummy_block_data_jumpi: () => void; readonly dummy_block_data_terminate: () => void; readonly dummy_cbor_entry: () => void; readonly dummy_cbor_metadata: () => void; readonly dummy_cbor_value: () => void; readonly dummy_contract: () => void; readonly dummy_control_flow_graph: () => void; readonly dummy_dynamic_jump: () => void; readonly dummy_function: () => void; readonly dummy_proxy_call: () => void; readonly dummy_proxy_source: () => void; readonly dummy_proxy_value: () => void; readonly dummy_storage_record: () => void; readonly dummy_storage_ref: () => void; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export3: (a: number, b: number, c: number) => void; readonly __wbindgen_externrefs: WebAssembly.Table; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export4: (a: number) => void; readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;