/// import { utils } from 'ethers'; import { KnownSequence } from './compiler'; export interface IStorage { get(location: bigint): Promise | bigint; set(location: bigint, value: bigint): IStorage; getBalance(): Promise | bigint; decrementBalance(value: bigint): IStorage; incrementBalance(value: bigint): IStorage; } export declare type CompiledCode = ((exec: IExecutor) => () => void) & { readonly code: IMemReader; readonly contractName: string; readonly contractAbi: utils.Interface | undefined; readonly contractAddress: bigint; }; export interface IMemReader { readonly size: number; get(offset: number): bigint; getByte(offset: number): number; slice(offset: number, size: number): Uint8Array; sliceNoPad(offset: number, size: number): Uint8Array; } export interface NewTxData { contract: bigint; retdatasize: number; calldata: Uint8Array; gasPrice: bigint; static: boolean; origin: bigint; caller?: bigint; address?: bigint; callvalue: bigint; gasLimit: bigint; timestamp?: number; timestampDelta?: number; difficulty?: bigint; baseFee?: bigint; } export declare type OnRpcFetch = (opName: string, method: string, params: any[]) => void; export interface IRpc { onFetch(handler: OnRpcFetch): void; getChainId(): Promise; getBlock(): Promise; getCode(contract: HexString): Promise; getStorageAt(address: HexString, key: bigint): Promise; getBalance(key: HexString): Promise; getTimestamp(): Promise; } export interface ExecState { readonly forceTimestamp: number | undefined; readonly timestampDelta: number | undefined; readonly forceBasefee: bigint | undefined; readonly difficulty: bigint; readonly address: bigint; readonly caller: bigint; readonly origin: bigint; readonly gasPrice: bigint; readonly callvalue: bigint; readonly calldata: IMemReader; readonly static: boolean; readonly session: ISession; newTx(data: NewTxData): Promise; getStorage(location: bigint): Promise | bigint; getStorageOf(dummy: HexString | bigint): IStorage; getBalance(): Promise | bigint; getContract(hex: HexString | bigint): Promise; setContract(contract: CompiledCode): ExecState; setStorage(location: bigint, value: bigint): ExecState; setStorageLocation(address: bigint, storage: IStorage): ExecState; transfer(to: bigint, value: bigint): Promise; mintValue(to: bigint, value: bigint): ExecState; pushCallTo(contract: bigint, callValue: bigint, calldata: Uint8Array, returnDataSize: number): Promise; pushDelegatecallTo(contract: bigint, calldata: Uint8Array, returnDataSize: number): ExecState; pushStaticcallTo(contract: bigint, calldata: Uint8Array, returnDataSize: number): ExecState; popCallStack(): ExecState; } export declare type HexString = `0x${string}`; export interface DeployOpts { balance?: bigint; name?: string; knownSequences?: KnownSequence[]; forceId?: bigint; } export interface SessionOpts { rpcUrl?: string; cacheDir?: string; rpcBlock?: HexString | number; contractsNames?: { [key: string]: string | { name: string; abi: utils.Interface; }; }; eips?: 'all' | EIP; } export interface EIP { eip_3855_push0?: boolean; } export interface ISession { readonly rpc: IRpc; readonly state: ExecState; readonly opts?: SessionOpts | undefined; getContract(contract: HexString | bigint): Promise; prepareCall(input: NewTxData): Promise; prepareStaticCall(contract: HexString | bigint, calldata: string | Uint8Array, returnDataSize: number): Promise; addNames(names?: SessionOpts['contractsNames']): this; deploy(code: string | Buffer | Uint8Array, opts: Omit, deployOpts?: DeployOpts): Promise; supports(eip: keyof EIP): boolean; checkSupports(eip: keyof EIP): void; } export declare type StopReason = { type: 'stop'; data?: null; newState: ExecState; gas: bigint; } | { type: 'return'; data: Uint8Array; newState: ExecState; gas: bigint; } | { type: 'end of code'; data?: null; newState: ExecState; gas: bigint; } | Revert; declare type Revert = { type: 'revert'; data: Uint8Array; gas: bigint; }; export declare function isSuccess(result: StopReason): boolean; export declare function isFailure(result: StopReason): result is Revert; export interface IExecutor { readonly contractName: string; readonly contractAbi: utils.Interface | undefined; readonly state: ExecState; readonly contractAddress: bigint; readonly logs: readonly Log[]; readonly gas: bigint; copyStack(): readonly bigint[]; execute(): Promise; watch(handler: (opcode: number, opName: string, paddedOpName: string, opSpy: string[], inKnownSequence: string | null) => any): void; onMemChange(fn: (bytes: () => number[]) => void): void; onStartingCall(fn: OnStartingCall): void; onLog(fn: OnLog): void; onEndingCall(fn: OnEndedCall): void; onResult(handler: (ret: StopReason) => void | Promise): void; pop(): bigint; popAsNum(): number; popAsBool(): boolean; dumpCalldata(): string[]; dumpMemory(): string[]; dumpStack(): string[]; } export declare type OnStartingCall = (exec: IExecutor, callType: 'call' | 'callcode' | 'staticcall' | 'delegatecall' | 'create2') => void; export declare type OnEndedCall = (exec: IExecutor, callType: 'call' | 'callcode' | 'staticcall' | 'delegatecall' | 'create2', success: boolean, reason: StopReason | undefined) => void; export declare type OnLog = (log: Log) => void; export interface Log { readonly topics: readonly bigint[]; readonly data: Uint8Array; readonly address: bigint; } export {};