sevm
Version:
A Symbolic Ethereum Virtual Machine (EVM) bytecode decompiler & analyzer library & CLI
106 lines (105 loc) • 3.08 kB
TypeScript
import { Throw, type Expr, type Inst, type Stmt } from './ast';
import type { IEvents } from './ast/log';
import { type IStore } from './ast/storage';
import type { Revert } from './ast/system';
import { arrayify } from './.bytes';
import { EVM } from './evm';
import { type Metadata } from './metadata';
import { State } from './state';
import { type Members, type Opcode } from './step';
/**
*
*/
export declare const ERCIds: ("ERC165" | "ERC173" | "ERC20" | "ERC20Metadata" | "ERC721")[];
/**
*
*/
export declare class Contract {
/**
* The `bytecode` used to create this `Contract`.
*/
readonly bytecode: Uint8Array;
/**
* The `metadataHash` part from the `bytecode`.
* That is, if present, the `bytecode` without its `code`.
*/
readonly metadata: Metadata | undefined;
/**
*
*/
readonly main: Stmt[];
readonly events: IEvents;
readonly variables: IStore['variables'];
readonly mappings: IStore['mappings'];
readonly functionBranches: Members['functionBranches'];
readonly errors: Throw[];
readonly blocks: EVM<string>['blocks'];
readonly chunks: EVM<string>['chunks'];
/**
* Returns the `opcode`s present in the **reacheable blocks** of `this` Contract's `bytecode`.
*/
readonly opcodes: () => Opcode<string>[];
/**
*
*/
readonly functions: {
[selector: string]: PublicFunction;
};
readonly payable: boolean;
/**
*
* @param bytecode the bytecode to analyze in hexadecimal format.
*/
constructor(bytecode: Parameters<typeof arrayify>[0], _insts?: {});
reduce(): Contract;
/**
*
* @returns
*/
getFunctions(): string[];
/**
*
* @returns
*/
getEvents(): string[];
/**
* https://eips.ethereum.org/EIPS/eip-165
* https://eips.ethereum.org/EIPS/eip-20
* https://eips.ethereum.org/EIPS/eip-20
* https://eips.ethereum.org/EIPS/eip-721
*
* @param ercid
* @returns
*/
isERC(ercid: (typeof ERCIds)[number], checkEvents?: boolean): boolean;
}
export declare function isRevertBlock(falseBlock: Stmt[]): falseBlock is [...Inst[], Revert];
export declare class PublicFunction {
readonly contract: Contract;
readonly stmts: Stmt[];
readonly selector: string;
/**
*
*/
private _label;
readonly payable: boolean;
readonly visibility: string;
readonly constant: boolean;
readonly returns: string[];
constructor(contract: Contract, stmts: Stmt[], selector: string, payable?: boolean);
get label(): string | undefined;
set label(value: string | undefined);
private isGetter;
private isMappingGetter;
private static findReturns;
private static patchCallDataLoad;
}
export declare function build(state: State<Inst, Expr>): Stmt[];
export declare function reduce0(stmts: Inst[]): Stmt[];
export * from './evm';
export * from './metadata';
export * from './sol';
export * from './state';
export * from './step';
export * from './type';
export * from './yul';