UNPKG

7.45 kBTypeScriptView Raw
1export interface Artifacts {
2 /**
3 * Reads an artifact.
4 *
5 * @param contractNameOrFullyQualifiedName The name of the contract.
6 * It can be a contract bare contract name (e.g. "Token") if it's
7 * unique in your project, or a fully qualified contract name
8 * (e.g. "contract/token.sol:Token") otherwise.
9 *
10 * @throws Throws an error if a non-unique contract name is used,
11 * indicating which fully qualified names can be used instead.
12 */
13 readArtifact(contractNameOrFullyQualifiedName: string): Promise<Artifact>;
14 /**
15 * Synchronous version of readArtifact.
16 */
17 readArtifactSync(contractNameOrFullyQualifiedName: string): Artifact;
18 /**
19 * Returns true if an artifact exists.
20 *
21 * This function doesn't throw if the name is not unique.
22 *
23 * @param contractNameOrFullyQualifiedName Contract or fully qualified name.
24 *
25 */
26 artifactExists(contractNameOrFullyQualifiedName: string): Promise<boolean>;
27 /**
28 * Returns an array with the fully qualified names of all the artifacts.
29 */
30 getAllFullyQualifiedNames(): Promise<string[]>;
31 /**
32 * Returns the BuildInfo associated with the solc run that compiled a
33 * contract.
34 *
35 * Note that if your contract hasn't been compiled with solc this method
36 * can return undefined.
37 */
38 getBuildInfo(fullyQualifiedName: string): Promise<BuildInfo | undefined>;
39 /**
40 * Synchronous version of getBuildInfo.
41 */
42 getBuildInfoSync(fullyQualifiedName: string): BuildInfo | undefined;
43 /**
44 * Returns an array with the absolute paths of all the existing artifacts.
45 *
46 * Note that there's an artifact per contract.
47 */
48 getArtifactPaths(): Promise<string[]>;
49 /**
50 * Returns an array with the absolute paths of all the existing debug files.
51 *
52 * Note that there's a debug file per Solidity contract.
53 */
54 getDebugFilePaths(): Promise<string[]>;
55 /**
56 * Returns an array with the absolute paths of all the existing build infos.
57 *
58 * Note that there's one build info per run of solc, so they can be shared
59 * by different contracts.
60 */
61 getBuildInfoPaths(): Promise<string[]>;
62 /**
63 * Saves a contract's artifact and debug file.
64 *
65 * @param artifact The artifact object.
66 * @param pathToBuildInfo The path to the build info from the solc run that
67 * compiled the contract. If the contract was built with another compiler
68 * use `undefined` and not debug file will be saved.
69 */
70 saveArtifactAndDebugFile(artifact: Artifact, pathToBuildInfo?: string): Promise<void>;
71 /**
72 * Saves the build info associated to a solc run.
73 *
74 * @param solcVersion The semver-compatible version number.
75 * @param solcLongVersion The full solc version.
76 * @param input The compiler input.
77 * @param output The compiler output.
78 */
79 saveBuildInfo(solcVersion: string, solcLongVersion: string, input: CompilerInput, output: CompilerOutput): Promise<string>;
80 /**
81 * Returns the absolute path to the given artifact.
82 *
83 * @param fullyQualifiedName The FQN of the artifact.
84 */
85 formArtifactPathFromFullyQualifiedName(fullyQualifiedName: string): string;
86 /**
87 * Starting with Hardhat 2.11.0, the artifacts object caches the information
88 * about paths that it fetches from the filesystem (e.g. the list of
89 * artifacts, the path that an artifact name resolves to, etc.). The artifacts
90 * and buildInfos themselves are not cached, only their paths.
91 *
92 * This method, if present, clears that cache.
93 */
94 clearCache?: () => void;
95 /**
96 * This method, if present, disables the artifact paths cache.
97 *
98 * We recommend NOT using this method. The only reason it exists is for
99 * backwards compatibility. If your app was assuming no cache, you can use it
100 * (e.g. from an HRE extender).
101 *
102 * @see clearCache
103 */
104 disableCache?: () => void;
105}
106/**
107 * An artifact representing the compilation output of a contract.
108 *
109 * This file has just enough information to deploy the contract and interact
110 * with an already deployed instance of it.
111 *
112 * For debugging information and other extra information, you should look for
113 * its companion DebugFile, which should be stored right next to it.
114 *
115 * Note that DebugFiles are only generated for Solidity contracts.
116 */
117export interface Artifact {
118 _format: string;
119 contractName: string;
120 sourceName: string;
121 abi: any[];
122 bytecode: string;
123 deployedBytecode: string;
124 linkReferences: LinkReferences;
125 deployedLinkReferences: LinkReferences;
126}
127/**
128 * A DebugFile contains any extra information about a Solidity contract that
129 * Hardhat and its plugins need.
130 *
131 * The current version of DebugFiles only contains a path to a BuildInfo file.
132 */
133export interface DebugFile {
134 _format: string;
135 buildInfo: string;
136}
137/**
138 * A BuildInfo is a file that contains all the information of a solc run. It
139 * includes all the necessary information to recreate that exact same run, and
140 * all of its output.
141 */
142export interface BuildInfo {
143 _format: string;
144 id: string;
145 solcVersion: string;
146 solcLongVersion: string;
147 input: CompilerInput;
148 output: CompilerOutput;
149}
150export interface LinkReferences {
151 [libraryFileName: string]: {
152 [libraryName: string]: Array<{
153 length: number;
154 start: number;
155 }>;
156 };
157}
158export interface CompilerInput {
159 language: string;
160 sources: {
161 [sourceName: string]: {
162 content: string;
163 };
164 };
165 settings: {
166 viaIR?: boolean;
167 optimizer: {
168 runs?: number;
169 enabled?: boolean;
170 details?: {
171 yulDetails: {
172 optimizerSteps: string;
173 };
174 };
175 };
176 metadata?: {
177 useLiteralContent: boolean;
178 };
179 outputSelection: {
180 [sourceName: string]: {
181 [contractName: string]: string[];
182 };
183 };
184 evmVersion?: string;
185 libraries?: {
186 [libraryFileName: string]: {
187 [libraryName: string]: string;
188 };
189 };
190 remappings?: string[];
191 };
192}
193export interface CompilerOutputContract {
194 abi: any;
195 evm: {
196 bytecode: CompilerOutputBytecode;
197 deployedBytecode: CompilerOutputBytecode;
198 methodIdentifiers: {
199 [methodSignature: string]: string;
200 };
201 };
202}
203export interface CompilerOutput {
204 sources: CompilerOutputSources;
205 contracts: {
206 [sourceName: string]: {
207 [contractName: string]: CompilerOutputContract;
208 };
209 };
210}
211export interface CompilerOutputSource {
212 id: number;
213 ast: any;
214}
215export interface CompilerOutputSources {
216 [sourceName: string]: CompilerOutputSource;
217}
218export interface CompilerOutputBytecode {
219 object: string;
220 opcodes: string;
221 sourceMap: string;
222 linkReferences: {
223 [sourceName: string]: {
224 [libraryName: string]: Array<{
225 start: number;
226 length: 20;
227 }>;
228 };
229 };
230 immutableReferences?: {
231 [key: string]: Array<{
232 start: number;
233 length: number;
234 }>;
235 };
236}
237//# sourceMappingURL=artifacts.d.ts.map
\No newline at end of file