UNPKG

6.37 kBTypeScriptView Raw
1import { Artifact, Artifacts as IArtifacts, BuildInfo, CompilerInput, CompilerOutput } from "../types";
2export declare class Artifacts implements IArtifacts {
3 private _artifactsPath;
4 private _validArtifacts;
5 private _cache?;
6 constructor(_artifactsPath: string);
7 addValidArtifacts(validArtifacts: Array<{
8 sourceName: string;
9 artifacts: string[];
10 }>): void;
11 readArtifact(name: string): Promise<Artifact>;
12 readArtifactSync(name: string): Artifact;
13 artifactExists(name: string): Promise<boolean>;
14 getAllFullyQualifiedNames(): Promise<string[]>;
15 getBuildInfo(fullyQualifiedName: string): Promise<BuildInfo | undefined>;
16 getBuildInfoSync(fullyQualifiedName: string): BuildInfo | undefined;
17 getArtifactPaths(): Promise<string[]>;
18 getBuildInfoPaths(): Promise<string[]>;
19 getDebugFilePaths(): Promise<string[]>;
20 saveArtifactAndDebugFile(artifact: Artifact, pathToBuildInfo?: string): Promise<void>;
21 saveBuildInfo(solcVersion: string, solcLongVersion: string, input: CompilerInput, output: CompilerOutput): Promise<string>;
22 /**
23 * Remove all artifacts that don't correspond to the current solidity files
24 */
25 removeObsoleteArtifacts(): Promise<void>;
26 /**
27 * Returns the absolute path to the given artifact
28 * @throws {HardhatError} If the name is not fully qualified.
29 */
30 formArtifactPathFromFullyQualifiedName(fullyQualifiedName: string): string;
31 clearCache(): void;
32 disableCache(): void;
33 /**
34 * Remove all build infos that aren't used by any debug file
35 */
36 private _removeObsoleteBuildInfos;
37 private _getBuildInfoName;
38 /**
39 * Returns the absolute path to the artifact that corresponds to the given
40 * name.
41 *
42 * If the name is fully qualified, the path is computed from it. If not, an
43 * artifact that matches the given name is searched in the existing artifacts.
44 * If there is an ambiguity, an error is thrown.
45 *
46 * @throws {HardhatError} with descriptor:
47 * - {@link ERRORS.ARTIFACTS.WRONG_CASING} if the path case doesn't match the one in the filesystem.
48 * - {@link ERRORS.ARTIFACTS.MULTIPLE_FOUND} if there are multiple artifacts matching the given contract name.
49 * - {@link ERRORS.ARTIFACTS.NOT_FOUND} if the artifact is not found.
50 */
51 private _getArtifactPath;
52 private _createBuildInfo;
53 private _createDebugFile;
54 private _getArtifactPathsSync;
55 /**
56 * Sync version of _getArtifactPath
57 */
58 private _getArtifactPathSync;
59 /**
60 * DO NOT DELETE OR CHANGE
61 *
62 * use this.formArtifactPathFromFullyQualifiedName instead
63 * @deprecated until typechain migrates to public version
64 * @see https://github.com/dethcrypto/TypeChain/issues/544
65 */
66 private _getArtifactPathFromFullyQualifiedName;
67 /**
68 * Returns the absolute path to the artifact that corresponds to the given
69 * fully qualified name.
70 * @param fullyQualifiedName The fully qualified name of the contract.
71 * @returns The absolute path to the artifact.
72 * @throws {HardhatError} with descriptor:
73 * - {@link ERRORS.CONTRACT_NAMES.INVALID_FULLY_QUALIFIED_NAME} If the name is not fully qualified.
74 * - {@link ERRORS.ARTIFACTS.WRONG_CASING} If the path case doesn't match the one in the filesystem.
75 * - {@link ERRORS.ARTIFACTS.NOT_FOUND} If the artifact is not found.
76 */
77 private _getValidArtifactPathFromFullyQualifiedName;
78 private _getAllContractNamesFromFiles;
79 private _getAllFullyQualifiedNamesSync;
80 private _formatSuggestions;
81 /**
82 * @throws {HardhatError} with a list of similar contract names.
83 */
84 private _handleWrongArtifactForFullyQualifiedName;
85 /**
86 * @throws {HardhatError} with a list of similar contract names.
87 */
88 private _handleWrongArtifactForContractName;
89 /**
90 * If the project has these contracts:
91 * - 'contracts/Greeter.sol:Greeter'
92 * - 'contracts/Meeter.sol:Greeter'
93 * - 'contracts/Greater.sol:Greater'
94 * And the user tries to get an artifact with the name 'Greter', then
95 * the suggestions will be 'Greeter', 'Greeter', and 'Greater'.
96 *
97 * We don't want to show duplicates here, so we use FQNs for those. The
98 * suggestions will then be:
99 * - 'contracts/Greeter.sol:Greeter'
100 * - 'contracts/Meeter.sol:Greeter'
101 * - 'Greater'
102 */
103 private _filterDuplicatesAsFullyQualifiedNames;
104 /**
105 *
106 * @param givenName can be FQN or contract name
107 * @param names MUST match type of givenName (i.e. array of FQN's if givenName is FQN)
108 * @returns
109 */
110 private _getSimilarContractNames;
111 private _getValidArtifactPathFromFullyQualifiedNameSync;
112 private _getDebugFilePath;
113 /**
114 * Gets the path to the artifact file for the given contract name.
115 * @throws {HardhatError} with descriptor:
116 * - {@link ERRORS.ARTIFACTS.NOT_FOUND} if there are no artifacts matching the given contract name.
117 * - {@link ERRORS.ARTIFACTS.MULTIPLE_FOUND} if there are multiple artifacts matching the given contract name.
118 */
119 private _getArtifactPathFromFiles;
120 /**
121 * Returns the FQN of a contract giving the absolute path to its artifact.
122 *
123 * For example, given a path like
124 * `/path/to/project/artifacts/contracts/Foo.sol/Bar.json`, it'll return the
125 * FQN `contracts/Foo.sol:Bar`
126 */
127 private _getFullyQualifiedNameFromPath;
128 /**
129 * Remove the artifact file and its debug file.
130 */
131 private _removeArtifactFiles;
132 /**
133 * Given the path to a debug file, returns the absolute path to its
134 * corresponding build info file if it exists, or undefined otherwise.
135 */
136 private _getBuildInfoFromDebugFile;
137 /**
138 * Sync version of _getBuildInfoFromDebugFile
139 */
140 private _getBuildInfoFromDebugFileSync;
141 private _isArtifactPath;
142}
143/**
144 * Retrieves an artifact for the given `contractName` from the compilation output.
145 *
146 * @param sourceName The contract's source name.
147 * @param contractName the contract's name.
148 * @param contractOutput the contract's compilation output as emitted by `solc`.
149 */
150export declare function getArtifactFromContractOutput(sourceName: string, contractName: string, contractOutput: any): Artifact;
151//# sourceMappingURL=artifacts.d.ts.map
\No newline at end of file