hardhat-external-artifacts 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ronan Sandford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # hardhat-external-artifacts
2
+
3
+ A Hardhat 3 plugin that allows users to provide external contract artifacts (ABIs) to Hardhat's EDR provider for decoding events, errors, and function calls in console output.
4
+
5
+ This is useful when interacting with contracts that were not compiled by the current Hardhat project (e.g., external protocols, deployed contracts from other projects).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install hardhat-external-artifacts
11
+ # or
12
+ pnpm add hardhat-external-artifacts
13
+ # or
14
+ yarn add hardhat-external-artifacts
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Import the plugin in your Hardhat configuration file:
20
+
21
+ ```typescript
22
+ // hardhat.config.ts
23
+ import type {HardhatUserConfig} from 'hardhat/config';
24
+ import 'hardhat-external-artifacts';
25
+
26
+ const config: HardhatUserConfig = {
27
+ solidity: '0.8.20',
28
+ externalArtifacts: {
29
+ // Load specific artifact files
30
+ paths: [
31
+ './external-artifacts/WETH.json',
32
+ './external-artifacts/Uniswap/', // Loads all .json in directory
33
+ ],
34
+ // Optional: specify solc version for synthetic compilations
35
+ solcVersion: '0.8.20',
36
+ // Optional: disable warnings for invalid artifacts
37
+ warnOnInvalidArtifacts: true,
38
+ },
39
+ };
40
+
41
+ export default config;
42
+ ```
43
+
44
+ ### Using a Resolver Function
45
+
46
+ For more dynamic artifact loading, you can use a resolver function:
47
+
48
+ ```typescript
49
+ // hardhat.config.ts
50
+ import type {HardhatUserConfig} from 'hardhat/config';
51
+ import 'hardhat-external-artifacts';
52
+
53
+ const config: HardhatUserConfig = {
54
+ solidity: '0.8.20',
55
+ externalArtifacts: {
56
+ resolver: async () => {
57
+ // Fetch from API, database, or any source
58
+ return [
59
+ {
60
+ contractName: 'ERC20',
61
+ sourceName: 'openzeppelin/ERC20.sol',
62
+ abi: [
63
+ /* ... */
64
+ ],
65
+ bytecode: '0x...',
66
+ deployedBytecode: '0x...',
67
+ },
68
+ ];
69
+ },
70
+ solcVersion: '0.8.20',
71
+ },
72
+ };
73
+
74
+ export default config;
75
+ ```
76
+
77
+ ### Combined Approach
78
+
79
+ You can use both paths and resolver together:
80
+
81
+ ```typescript
82
+ // hardhat.config.ts
83
+ import type {HardhatUserConfig} from 'hardhat/config';
84
+ import 'hardhat-external-artifacts';
85
+ import {loadDefiProtocolArtifacts} from './scripts/load-defi';
86
+
87
+ const config: HardhatUserConfig = {
88
+ solidity: '0.8.20',
89
+ externalArtifacts: {
90
+ // Load from local directory
91
+ paths: ['./vendor-artifacts/'],
92
+
93
+ // Also fetch dynamically
94
+ resolver: async () => loadDefiProtocolArtifacts(),
95
+
96
+ // Use specific solc version for method ID computation
97
+ solcVersion: '0.8.19',
98
+
99
+ // Silence warnings for experimental use
100
+ warnOnInvalidArtifacts: false,
101
+ },
102
+ };
103
+
104
+ export default config;
105
+ ```
106
+
107
+ ## Configuration Options
108
+
109
+ | Option | Type | Default | Description |
110
+ | ------------------------ | ----------------------------------- | ----------- | ----------------------------------------------- |
111
+ | `paths` | `string[]` | `[]` | Paths to artifact files or directories |
112
+ | `resolver` | `() => Promise<ExternalArtifact[]>` | `undefined` | Function that returns artifacts dynamically |
113
+ | `solcVersion` | `string` | `"0.8.20"` | Solc version for synthetic compilations |
114
+ | `warnOnInvalidArtifacts` | `boolean` | `true` | Whether to log warnings for malformed artifacts |
115
+ | `debug` | `boolean` | `false` | Enable debug logging for troubleshooting |
116
+
117
+ ## Artifact Format
118
+
119
+ ### Simple Artifact
120
+
121
+ The minimum required format for an external artifact:
122
+
123
+ ```json
124
+ {
125
+ "contractName": "MyContract",
126
+ "sourceName": "contracts/MyContract.sol",
127
+ "abi": [...],
128
+ "bytecode": "0x...",
129
+ "deployedBytecode": "0x..."
130
+ }
131
+ ```
132
+
133
+ ### Rich Artifact
134
+
135
+ For better fidelity, you can provide a rich artifact with embedded compilation data:
136
+
137
+ ```json
138
+ {
139
+ "contractName": "MyContract",
140
+ "sourceName": "contracts/MyContract.sol",
141
+ "abi": [...],
142
+ "bytecode": "0x...",
143
+ "deployedBytecode": "0x...",
144
+ "solcInput": "{\"language\":\"Solidity\",...}",
145
+ "metadata": "{\"compiler\":{\"version\":\"0.8.20+commit...\"},...}",
146
+ "evm": {
147
+ "bytecode": { "object": "...", "sourceMap": "...", ... },
148
+ "deployedBytecode": { "object": "...", "sourceMap": "...", ... },
149
+ "methodIdentifiers": { "transfer(address,uint256)": "a9059cbb" }
150
+ }
151
+ }
152
+ ```
153
+
154
+ Rich artifacts are typically produced by tools like `hardhat-deploy` that preserve full compilation output.
155
+
156
+ ## How It Works
157
+
158
+ 1. When a network connection is established (specifically for EDR/Hardhat Network), the plugin loads the configured external artifacts.
159
+
160
+ 2. Simple artifacts are grouped into a synthetic compilation with computed method identifiers.
161
+
162
+ 3. Rich artifacts (with embedded `solcInput`) get their own individual compilations for maximum fidelity.
163
+
164
+ 4. The compilations are added to the EDR provider using `addCompilationResult()`, enabling:
165
+ - Event decoding in transaction logs
166
+ - Error decoding for reverts
167
+ - Function call decoding in stack traces
168
+
169
+ ## Troubleshooting
170
+
171
+ ### Contract still shows as `<UnrecognizedContract>`
172
+
173
+ If you see logs like:
174
+ ```
175
+ eth_call
176
+ Contract call: <UnrecognizedContract>
177
+ From: 0x...
178
+ To: 0x...
179
+ ```
180
+
181
+ This means EDR couldn't match the contract's bytecode. EDR identifies contracts by matching the **deployed bytecode** at the target address with bytecode from compilation results.
182
+
183
+ **Possible causes:**
184
+
185
+ 1. **Bytecode mismatch**: The `deployedBytecode` in your artifact doesn't match what's actually deployed. This can happen due to:
186
+ - Different compiler versions or optimizer settings
187
+ - Metadata hash differences (appended to bytecode by default)
188
+ - Constructor arguments that set immutable values
189
+
190
+ 2. **Missing bytecode**: Your artifact has an empty or missing `deployedBytecode` field.
191
+
192
+ **Debugging steps:**
193
+
194
+ 1. Enable debug logging:
195
+ ```typescript
196
+ externalArtifacts: {
197
+ paths: ['./artifacts/'],
198
+ debug: true, // Enable debug output
199
+ }
200
+ ```
201
+
202
+ 2. Verify bytecode exists and has reasonable length in the debug output.
203
+
204
+ 3. Compare your artifact's `deployedBytecode` with the actual bytecode at the address:
205
+ ```typescript
206
+ // In your test/script
207
+ const actualCode = await connection.provider.request({
208
+ method: 'eth_getCode',
209
+ params: [contractAddress, 'latest'],
210
+ });
211
+ console.log('Actual bytecode length:', actualCode.length);
212
+ console.log('Artifact bytecode length:', artifact.deployedBytecode.length);
213
+ ```
214
+
215
+ 4. For forked networks, ensure you have the exact artifact that was used to deploy the contract on mainnet. Minor differences (like metadata hash) will prevent matching.
216
+
217
+ ### Rich artifacts vs Simple artifacts
218
+
219
+ Rich artifacts (with `solcInput`) provide better matching because they include the complete compilation data. If you have access to the original compilation output (e.g., from `hardhat-deploy`), prefer using rich artifacts.
220
+
221
+ ## Requirements
222
+
223
+ - Hardhat 3.x
224
+ - Node.js 22+
225
+
226
+ ## License
227
+
228
+ MIT
@@ -0,0 +1,62 @@
1
+ import type { ExternalArtifact, LinkReferences } from './types.js';
2
+ export interface SyntheticCompilation {
3
+ solcVersion: string;
4
+ compilerInput: CompilerInput;
5
+ compilerOutput: CompilerOutput;
6
+ }
7
+ interface CompilerInput {
8
+ language: string;
9
+ sources: Record<string, {
10
+ content: string;
11
+ }>;
12
+ settings: {
13
+ optimizer: {
14
+ enabled: boolean;
15
+ runs?: number;
16
+ };
17
+ outputSelection: Record<string, Record<string, string[]>>;
18
+ remappings?: string[];
19
+ metadata?: {
20
+ useLiteralContent?: boolean;
21
+ bytecodeHash?: string;
22
+ };
23
+ };
24
+ }
25
+ interface CompilerOutput {
26
+ sources: Record<string, {
27
+ id: number;
28
+ ast: object;
29
+ }>;
30
+ contracts: Record<string, Record<string, {
31
+ abi: readonly any[];
32
+ evm: {
33
+ bytecode: BytecodeOutput;
34
+ deployedBytecode: BytecodeOutput;
35
+ methodIdentifiers: Record<string, string>;
36
+ };
37
+ metadata?: string;
38
+ devdoc?: any;
39
+ userdoc?: any;
40
+ storageLayout?: any;
41
+ }>>;
42
+ }
43
+ interface BytecodeOutput {
44
+ object: string;
45
+ opcodes: string;
46
+ sourceMap: string;
47
+ linkReferences: LinkReferences;
48
+ immutableReferences?: Record<string, Array<{
49
+ start: number;
50
+ length: number;
51
+ }>>;
52
+ generatedSources?: any[];
53
+ functionDebugData?: Record<string, any>;
54
+ }
55
+ /**
56
+ * Convert artifacts to compilation format.
57
+ * If artifacts are "rich" (have solcInput), use the embedded data.
58
+ * Otherwise, synthesize a minimal compilation.
59
+ */
60
+ export declare function artifactsToCompilations(artifacts: ExternalArtifact[], defaultSolcVersion: string): SyntheticCompilation[];
61
+ export {};
62
+ //# sourceMappingURL=converter.d.ts.map
@@ -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M,CAAC;QAClB,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,aAAa,CAAC,EAAE,GAAG,CAAC;KACpB,CACD,CACD,CAAC;CACF;AAED,UAAU,cAAc;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC,CAAC;IAC7E,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC;AA2CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,kBAAkB,EAAE,MAAM,GACxB,oBAAoB,EAAE,CAuBxB"}
@@ -0,0 +1,241 @@
1
+ import { isRichArtifact } from './types.js';
2
+ /**
3
+ * Creates a minimal valid AST for a source file.
4
+ * This is needed because Hardhat's contract decoder expects a valid AST structure.
5
+ */
6
+ function createMinimalAst(sourceName, sourceId, contracts) {
7
+ const nodes = [];
8
+ const exportedSymbols = {};
9
+ // Add contract definition nodes if provided
10
+ if (contracts) {
11
+ for (const contract of contracts) {
12
+ nodes.push({
13
+ nodeType: 'ContractDefinition',
14
+ id: contract.nodeId,
15
+ src: `0:0:${sourceId}`,
16
+ name: contract.name,
17
+ contractKind: 'contract',
18
+ abstract: false,
19
+ fullyImplemented: true,
20
+ linearizedBaseContracts: [contract.nodeId],
21
+ nodes: [],
22
+ scope: sourceId,
23
+ });
24
+ exportedSymbols[contract.name] = [contract.nodeId];
25
+ }
26
+ }
27
+ return {
28
+ nodeType: 'SourceUnit',
29
+ src: `0:0:${sourceId}`,
30
+ id: sourceId,
31
+ absolutePath: sourceName,
32
+ exportedSymbols,
33
+ nodes,
34
+ };
35
+ }
36
+ /**
37
+ * Convert artifacts to compilation format.
38
+ * If artifacts are "rich" (have solcInput), use the embedded data.
39
+ * Otherwise, synthesize a minimal compilation.
40
+ */
41
+ export function artifactsToCompilations(artifacts, defaultSolcVersion) {
42
+ // Group artifacts by whether they have solcInput
43
+ const richArtifacts = artifacts.filter(isRichArtifact);
44
+ const simpleArtifacts = artifacts.filter((a) => !isRichArtifact(a));
45
+ const compilations = [];
46
+ // Process rich artifacts - these have embedded solcInput
47
+ for (const artifact of richArtifacts) {
48
+ const compilation = richArtifactToCompilation(artifact);
49
+ if (compilation) {
50
+ compilations.push(compilation);
51
+ }
52
+ }
53
+ // Process simple artifacts - synthesize compilation
54
+ if (simpleArtifacts.length > 0) {
55
+ compilations.push(synthesizeCompilation(simpleArtifacts, defaultSolcVersion));
56
+ }
57
+ return compilations;
58
+ }
59
+ /**
60
+ * Convert a rich artifact (with embedded solcInput) to a compilation.
61
+ * Uses the embedded solcInput directly for maximum fidelity.
62
+ */
63
+ function richArtifactToCompilation(artifact) {
64
+ if (!artifact.solcInput) {
65
+ return null;
66
+ }
67
+ // Parse the embedded solcInput
68
+ const compilerInput = JSON.parse(artifact.solcInput);
69
+ // Extract solc version from metadata
70
+ let solcVersion = '0.8.20'; // Default
71
+ if (artifact.metadata) {
72
+ try {
73
+ const metadata = JSON.parse(artifact.metadata);
74
+ if (metadata.compiler?.version) {
75
+ // Format: "0.8.10+commit.fc410830" -> extract "0.8.10"
76
+ solcVersion = metadata.compiler.version.split('+')[0];
77
+ }
78
+ }
79
+ catch {
80
+ // Ignore parsing errors, use default
81
+ }
82
+ }
83
+ // Build compiler output from the artifact
84
+ // Only include sources that we have contract data for
85
+ // Including empty sources/contracts can cause EDR selector fixup issues
86
+ const compilerOutput = {
87
+ sources: {},
88
+ contracts: {},
89
+ };
90
+ const sourceName = artifact.sourceName;
91
+ // Track source IDs for all input sources (needed for consistent source indexing)
92
+ let sourceId = 0;
93
+ const sourceIds = {};
94
+ for (const srcName of Object.keys(compilerInput.sources)) {
95
+ sourceIds[srcName] = sourceId++;
96
+ }
97
+ // Only include the source that contains our contract
98
+ const contractSourceId = sourceIds[sourceName] ?? sourceId++;
99
+ const contractNodeId = contractSourceId + 1000; // Use an offset to avoid ID conflicts
100
+ compilerOutput.sources[sourceName] = {
101
+ id: contractSourceId,
102
+ ast: createMinimalAst(sourceName, contractSourceId, [
103
+ { name: artifact.contractName, nodeId: contractNodeId },
104
+ ]),
105
+ };
106
+ compilerOutput.contracts[sourceName] = {};
107
+ // Ensure the source is in compilerInput as well
108
+ if (!compilerInput.sources[sourceName]) {
109
+ compilerInput.sources[sourceName] = { content: '' };
110
+ }
111
+ // Build bytecode output, ensuring proper format
112
+ // Standard solc output has bytecode.object without 0x prefix
113
+ const bytecode = {
114
+ object: stripHexPrefix(artifact.evm?.bytecode?.object ?? artifact.bytecode ?? '0x'),
115
+ opcodes: artifact.evm?.bytecode?.opcodes ?? '',
116
+ sourceMap: artifact.evm?.bytecode?.sourceMap ?? '',
117
+ linkReferences: artifact.evm?.bytecode?.linkReferences ?? artifact.linkReferences ?? {},
118
+ generatedSources: artifact.evm?.bytecode?.generatedSources,
119
+ functionDebugData: artifact.evm?.bytecode?.functionDebugData,
120
+ };
121
+ const deployedBytecode = {
122
+ object: stripHexPrefix(artifact.evm?.deployedBytecode?.object ??
123
+ artifact.deployedBytecode ??
124
+ '0x'),
125
+ opcodes: artifact.evm?.deployedBytecode?.opcodes ?? '',
126
+ sourceMap: artifact.evm?.deployedBytecode?.sourceMap ?? '',
127
+ linkReferences: artifact.evm?.deployedBytecode?.linkReferences ??
128
+ artifact.deployedLinkReferences ??
129
+ {},
130
+ immutableReferences: artifact.evm?.deployedBytecode?.immutableReferences ?? {},
131
+ generatedSources: artifact.evm?.deployedBytecode?.generatedSources,
132
+ functionDebugData: artifact.evm?.deployedBytecode?.functionDebugData,
133
+ };
134
+ // IMPORTANT: Do NOT provide method identifiers - let EDR compute them
135
+ // EDR has internal "selector fixup" logic for function overloading that can fail
136
+ // if we provide method identifiers that it then tries to reconcile with AST info.
137
+ // The error "Failed to fix up the selector for ... #supportsInterface" happens
138
+ // when EDR can't match provided selectors with overloaded functions.
139
+ // By providing an empty object, EDR will compute selectors from the ABI directly.
140
+ const methodIdentifiers = {};
141
+ compilerOutput.contracts[sourceName][artifact.contractName] = {
142
+ abi: artifact.abi,
143
+ evm: {
144
+ bytecode,
145
+ deployedBytecode,
146
+ methodIdentifiers,
147
+ },
148
+ metadata: artifact.metadata,
149
+ devdoc: artifact.devdoc,
150
+ userdoc: artifact.userdoc,
151
+ storageLayout: artifact.storageLayout,
152
+ };
153
+ return {
154
+ solcVersion,
155
+ compilerInput,
156
+ compilerOutput,
157
+ };
158
+ }
159
+ /**
160
+ * Synthesize a minimal compilation from simple artifacts.
161
+ * Used when artifacts don't have embedded solcInput.
162
+ */
163
+ function synthesizeCompilation(artifacts, solcVersion) {
164
+ const sources = {};
165
+ const outputSources = {};
166
+ const contracts = {};
167
+ // First, group artifacts by source
168
+ const contractsBySource = {};
169
+ for (const artifact of artifacts) {
170
+ if (!contractsBySource[artifact.sourceName]) {
171
+ contractsBySource[artifact.sourceName] = [];
172
+ }
173
+ contractsBySource[artifact.sourceName].push({
174
+ name: artifact.contractName,
175
+ artifact,
176
+ });
177
+ }
178
+ // Track IDs for AST nodes
179
+ let nextId = 0;
180
+ // Create sources with contract definitions in AST
181
+ for (const [sourceName, sourceContracts] of Object.entries(contractsBySource)) {
182
+ const sourceId = nextId++;
183
+ sources[sourceName] = { content: '' };
184
+ contracts[sourceName] = {};
185
+ // Create contract nodes for AST
186
+ const contractNodes = [];
187
+ for (const { name } of sourceContracts) {
188
+ const nodeId = nextId++;
189
+ contractNodes.push({ name, nodeId });
190
+ }
191
+ outputSources[sourceName] = {
192
+ id: sourceId,
193
+ ast: createMinimalAst(sourceName, sourceId, contractNodes),
194
+ };
195
+ // Add contract outputs
196
+ for (const { name, artifact } of sourceContracts) {
197
+ contracts[sourceName][name] = {
198
+ abi: artifact.abi,
199
+ evm: {
200
+ bytecode: {
201
+ object: stripHexPrefix(artifact.bytecode),
202
+ opcodes: '',
203
+ sourceMap: '',
204
+ linkReferences: artifact.linkReferences ?? {},
205
+ },
206
+ deployedBytecode: {
207
+ object: stripHexPrefix(artifact.deployedBytecode),
208
+ opcodes: '',
209
+ sourceMap: '',
210
+ linkReferences: artifact.deployedLinkReferences ?? {},
211
+ immutableReferences: {},
212
+ },
213
+ // Empty object - let EDR compute selectors to avoid selector fixup issues
214
+ // with overloaded functions (consistent with richArtifactToCompilation)
215
+ methodIdentifiers: {},
216
+ },
217
+ };
218
+ }
219
+ }
220
+ return {
221
+ solcVersion,
222
+ compilerInput: {
223
+ language: 'Solidity',
224
+ sources,
225
+ settings: {
226
+ optimizer: { enabled: false },
227
+ outputSelection: {
228
+ '*': { '*': ['abi', 'evm.bytecode', 'evm.deployedBytecode'] },
229
+ },
230
+ },
231
+ },
232
+ compilerOutput: {
233
+ sources: outputSources,
234
+ contracts,
235
+ },
236
+ };
237
+ }
238
+ function stripHexPrefix(hex) {
239
+ return hex.startsWith('0x') ? hex.slice(2) : hex;
240
+ }
241
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/artifacts/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAmD1C;;;GAGG;AACH,SAAS,gBAAgB,CACxB,UAAkB,EAClB,QAAgB,EAChB,SAAiD;IAEjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,eAAe,GAA6B,EAAE,CAAC;IAErD,4CAA4C;IAC5C,IAAI,SAAS,EAAE,CAAC;QACf,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC;gBACV,QAAQ,EAAE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 export declare class ArtifactLoader {
3
+ #private;
4
+ constructor(config: ExternalArtifactsConfig, projectRoot: string);
5
+ loadAll(): Promise<ExternalArtifact[]>;
6
+ }
7
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/artifacts/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAEhB,uBAAuB,EACvB,MAAM,YAAY,CAAC;AAQpB,qBAAa,cAAc;;gBAId,MAAM,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM;IAK1D,OAAO,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CA8H5C"}