@sentio/truffle-source-fetcher
Version:
Fetches verified source code from services such as Etherscan
127 lines (126 loc) • 3.23 kB
TypeScript
export interface FetcherConstructor {
readonly fetcherName: string;
forNetworkId(networkId: number, options?: FetcherOptions): Promise<Fetcher>;
getSupportedNetworks(): SupportedNetworks;
}
export interface Fetcher {
/**
* should have same name as the static version
*/
readonly fetcherName: string;
/**
* returns null if no sources for address
* (also may return null if the sources fall under an unsupported
* case, although currently there are no such cases)
*/
fetchSourcesForAddress(address: string): Promise<SourceInfo | null>;
}
export interface NetworkInfo {
name: string;
networkId: number;
chainId: number;
}
export interface SupportedNetworks {
[name: string]: NetworkInfo;
}
export interface FetcherOptions {
apiKey?: string;
}
export interface SourceInfo {
contractName?: string;
sources: SourcesByPath;
options: CompilerOptions;
}
export interface SourcesByPath {
[sourcePath: string]: string;
}
export type CompilerOptions = SolcOptions | VyperOptions;
export interface SolcOptions {
language: "Solidity" | "Yul";
version: string;
settings: SolcSettings;
specializations: SolcSpecializations;
}
export interface VyperOptions {
language: "Vyper";
version: string;
settings: VyperSettings;
specializations: VyperSpecializations;
}
export interface SolcSettings {
remappings?: string[];
optimizer?: OptimizerSettings;
evmVersion?: string;
debug?: DebugSettings;
metadata?: MetadataSettings;
viaIR?: boolean;
libraries?: LibrarySettings;
compilationTarget?: {
[sourcePath: string]: string;
};
}
export interface VyperSettings {
evmVersion?: string;
optimize?: boolean;
}
export interface SolcSpecializations {
libraries?: LibrarySettings;
constructorArguments?: string;
}
export interface VyperSpecializations {
constructorArguments?: string;
}
export interface SolcSources {
[sourcePath: string]: {
keccak256?: string;
content?: string;
urls?: string;
};
}
export interface SolcInput {
language: "Solidity";
sources: SolcSources;
settings: SolcSettings;
}
export interface SolcMetadata {
language: "Solidity" | "Yul";
compiler: {
version: string;
};
settings: SolcSettings;
sources: SolcSources;
version: number;
}
export interface LibrarySettings {
[contractPath: string]: Libraries;
}
export interface Libraries {
[libraryName: string]: string;
}
export interface MetadataSettings {
useLiteralContent?: boolean;
bytecodeHash?: "none" | "ipfs" | "bzzr1";
appendCBOR?: boolean;
}
export interface DebugSettings {
revertStrings?: "default" | "strip" | "debug" | "verboseDebug";
}
export interface OptimizerSettings {
enabled?: boolean;
runs?: number;
details?: OptimizerDetails;
}
export interface OptimizerDetails {
peephole?: boolean;
jumpdestRemover?: boolean;
orderLiterals?: boolean;
deduplicate?: boolean;
cse?: boolean;
constantOptimizer?: boolean;
yul?: boolean;
yulDetails?: YulDetails;
}
export interface YulDetails {
stackAllocation?: boolean;
optimizerSteps?: string;
}