solive-compiler-utils
Version:
Solidity Compiler helper tool
373 lines • 11.5 kB
TypeScript
export type CompilerInput = {
language: Language;
sources: Source;
settings: {
remappings?: string[];
optimizer: {
enabled: boolean;
runs: number;
details?: {
peephole?: boolean;
jumpdestRemover?: boolean;
orderLiterals?: boolean;
deduplicate?: boolean;
cse?: boolean;
constantOptimizer?: boolean;
yul?: boolean;
yulDetails?: {
stackAllocation: boolean;
};
};
};
evmVersion?: EVMVersion;
debug?: {
revertStrings: 'default' | 'strip' | 'debug' | 'verboseDebug';
};
metadata?: {
useLiteralContent: boolean;
bytecodeHash: 'ipfs' | 'bzzr1' | 'none';
};
libraries?: {
[]: Record<string, string>;
};
outputSelection?: {
'*': {
'': ['ast'];
'*': [
'abi',
'metadata',
'devdoc',
'userdoc',
'storageLayout',
'evm.legacyAssembly',
'evm.bytecode',
'evm.deployedBytecode',
'evm.methodIdentifiers',
'evm.gasEstimates',
'evm.assembly'
];
};
};
};
};
export type Source = {
[]: {
keccak256?: string;
content: string;
urls?: string[];
};
};
export type CompilerInputOptions = {
optimize: boolean | number;
runs: number;
libraries?: {
[]: Record<string, string>;
};
evmVersion?: EVMVersion;
language?: Language;
};
export type EVMVersion = 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople' | 'petersburg' | 'istanbul' | 'berlin' | 'london' | 'paris' | null;
export type Language = 'Solidity' | 'Yul';
export declare enum CompilerRetriggerMode {
'none' = 0,
'retrigger' = 1
}
export type CompilerState = {
compileJSON: ((input: SourceWithTarget) => void) | null;
worker: any;
currentVersion: string | null | undefined;
compilerLicense: string | null;
optimize: boolean;
runs: number;
evmVersion: EVMVersion | null;
language: Language;
compilationStartTime: number | null;
target: string | null;
useFileConfiguration: boolean;
configFileContent: string;
compilerRetriggerMode: CompilerRetriggerMode;
lastCompilationResult: {
data: CompilationResult | null;
source: SourceWithTarget | null | undefined;
} | null;
};
export type SourceWithTarget = {
sources?: Source;
target?: string | null | undefined;
};
export type MessageToWorker = {
cmd: string;
job?: number;
input?: CompilerInput;
data?: string;
timestamp?: number;
};
export type MessageFromWorker = {
cmd: string;
license?: string;
job?: number;
missingInputs?: string[];
input?: any;
data?: string;
timestamp?: number;
};
export type visitContractsCallbackParam = {
name: string;
object: CompiledContract;
file: string;
};
export type visitContractsCallbackInterface = {
(param: visitContractsCallbackParam): boolean | void;
};
export type gatherImportsCallbackInterface = {
(err?: Error | null, result?: SourceWithTarget): any;
};
export type CompilationResult = {
error?: CompilationError;
/** not present if no errors/warnings were encountered */
errors?: CompilationError[];
/** This contains the file-level outputs. In can be limited/filtered by the outputSelection settings */
sources?: {
[]: CompilationSource;
};
/** This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings */
contracts?: {
/** If the language used has no contract names, this field should equal to an empty string. */
[]: {
[]: CompiledContract;
};
};
};
export type CompilationError = {
/** Location within the source file */
sourceLocation?: {
file: string;
start: number;
end: number;
};
/** Error type */
type?: CompilationErrorType;
/** Component where the error originated, such as "general", "ewasm", etc. */
component?: 'general' | 'ewasm' | string;
severity?: 'error' | 'warning';
message?: string;
mode?: 'panic';
/** the message formatted with source location */
formattedMessage?: string;
};
type CompilationErrorType = 'JSONError' | 'IOError' | 'ParserError' | 'DocstringParsingError' | 'SyntaxError' | 'DeclarationError' | 'TypeError' | 'UnimplementedFeatureError' | 'InternalCompilerError' | 'Exception' | 'CompilerError' | 'FatalError' | 'Warning';
export type SourcesCode = {
[]: {
content: string;
};
};
export type CompilationSourceCode = {
sources: SourcesCode;
target: string;
};
export type CompilationSource = {
/** Identifier of the source (used in source maps) */
id: number;
/** The AST object */
ast: AstNode;
};
export type AstNode = {
absolutePath?: string;
exportedSymbols?: Record<string, unknown>;
id: number;
nodeType: string;
nodes?: Array<AstNode>;
src: string;
literals?: Array<string>;
file?: string;
scope?: number;
sourceUnit?: number;
symbolAliases?: Array<string>;
[]: any;
};
export type AstNodeAtt = {
operator?: string;
string?: null;
type?: string;
value?: string;
constant?: boolean;
name?: string;
public?: boolean;
exportedSymbols?: Record<string, unknown>;
argumentTypes?: null;
absolutePath?: string;
[]: any;
};
export type CompiledContract = {
/** The Ethereum Contract ABI. If empty, it is represented as an empty array. */
abi: ABIDescription[];
metadata: string;
/** User documentation (natural specification) */
userdoc: UserDocumentation;
/** Developer documentation (natural specification) */
devdoc: DeveloperDocumentation;
/** Intermediate representation (string) */
ir: string;
/** EVM-related outputs */
evm: {
assembly: string;
legacyAssembly: Record<string, unknown>;
/** Bytecode and related details. */
bytecode: BytecodeObject;
deployedBytecode: BytecodeObject;
/** The list of function hashes */
methodIdentifiers: {
[]: string;
};
gasEstimates: {
creation: {
codeDepositCost: string;
executionCost: 'infinite' | string;
totalCost: 'infinite' | string;
};
external: {
[]: string;
};
internal: {
[]: 'infinite' | string;
};
};
};
/** eWASM related outputs */
ewasm: {
/** S-expressions format */
wast: string;
/** Binary format (hex string) */
wasm: string;
};
};
export type ABIDescription = FunctionDescription | EventDescription;
export declare const isFunctionDescription: (item: ABIDescription) => item is FunctionDescription;
export declare const isEventDescription: (item: ABIDescription) => item is EventDescription;
export type FunctionDescription = {
/** Type of the method. default is 'function' */
type?: 'function' | 'constructor' | 'fallback' | 'receive';
/** The name of the function. Constructor and fallback function never have name */
name?: string;
/** List of parameters of the method. Fallback function doesn’t have inputs. */
inputs?: ABIParameter[];
/** List of the outputs parameters for the method, if any */
outputs?: ABIParameter[];
/** State mutability of the method */
stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable';
/** true if function accepts Ether, false otherwise. Default is false */
payable?: boolean;
/** true if function is either pure or view, false otherwise. Default is false */
constant?: boolean;
};
export type EventDescription = {
type: 'event';
name: string;
inputs: ABIParameter & {
/** true if the field is part of the log’s topics, false if it one of the log’s data segment. */
indexed: boolean;
}[];
/** true if the event was declared as anonymous. */
anonymous: boolean;
};
export type ABIParameter = {
/** The name of the parameter */
name: string;
/** The canonical type of the parameter */
type: ABITypeParameter;
/** Used for tuple types */
components?: ABIParameter[];
};
export type ABITypeParameter = 'uint' | 'uint[]' | 'int' | 'int[]' | 'address' | 'address[]' | 'bool' | 'bool[]' | 'fixed' | 'fixed[]' | 'ufixed' | 'ufixed[]' | 'bytes' | 'bytes[]' | 'function' | 'function[]' | 'tuple' | 'tuple[]' | string;
export type UserDocumentation = {
methods: UserMethodList;
notice: string;
};
export type UserMethodList = {
[]: UserMethodDoc;
} & {
constructor?: string;
};
export type UserMethodDoc = {
notice: string;
};
export type DeveloperDocumentation = {
author: string;
title: string;
details: string;
methods: DevMethodList;
};
export type DevMethodList = {
[]: DevMethodDoc;
};
export type DevMethodDoc = {
author: string;
details: string;
return: string;
params: {
[]: string;
};
};
export type BytecodeObject = {
/** The bytecode as a hex string. */
object: string;
/** Opcodes list */
opcodes: string;
/** The source mapping as a string. See the source mapping definition. */
sourceMap: string;
/** If given, this is an unlinked object. */
linkReferences?: {
[]: {
/** Byte offsets into the bytecode. */
[]: {
start: number;
length: number;
}[];
};
};
};
export type EsWebWorkerHandlerInterface = {
getWorker(): Worker;
};
export type ErrorMarker = {
message: string;
severity: MarkerSeverity;
position: {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
};
};
file: string;
};
export declare enum MarkerSeverity {
Hint = 1,
Info = 2,
Warning = 4,
Error = 8
}
type position = {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
};
};
export type SearchResultLineLine = {
left: any;
center: any;
right: any;
position: position;
};
export type SearchResultLine = {
lines: SearchResultLineLine[];
};
export {};
//# sourceMappingURL=types.d.ts.map