hardhat-external-artifacts 0.0.5 → 0.0.6
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/dist/artifacts/converter.d.ts +4 -2
- package/dist/artifacts/converter.d.ts.map +1 -1
- package/dist/artifacts/converter.js +225 -181
- package/dist/artifacts/converter.js.map +1 -1
- package/dist/artifacts/types.d.ts +20 -2
- package/dist/artifacts/types.d.ts.map +1 -1
- package/dist/artifacts/types.js +19 -3
- package/dist/artifacts/types.js.map +1 -1
- package/dist/hooks/network.js +3 -3
- package/dist/hooks/network.js.map +1 -1
- package/package.json +6 -3
- package/src/artifacts/converter.test.ts +294 -0
- package/src/artifacts/converter.ts +260 -205
- package/src/artifacts/types.ts +26 -4
- package/src/hooks/network.ts +3 -3
|
@@ -20,6 +20,8 @@ interface CompilerInput {
|
|
|
20
20
|
useLiteralContent?: boolean;
|
|
21
21
|
bytecodeHash?: string;
|
|
22
22
|
};
|
|
23
|
+
evmVersion?: string;
|
|
24
|
+
viaIR?: boolean;
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
interface CompilerOutput {
|
|
@@ -54,8 +56,8 @@ interface BytecodeOutput {
|
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Convert artifacts to compilation format.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
+
* Flexibly extracts data from each artifact - uses solcInput if available,
|
|
60
|
+
* falls back to metadata for settings, or synthesizes minimal compilation.
|
|
59
61
|
*/
|
|
60
62
|
export declare function artifactsToCompilations(artifacts: ExternalArtifact[], defaultSolcVersion: string, debug?: boolean): SyntheticCompilation[];
|
|
61
63
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../src/artifacts/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAgB,cAAc,EAAC,MAAM,YAAY,CAAC;AAG/E,MAAM,WAA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0LD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,KAAK,GAAE,OAAe,GACpB,oBAAoB,EAAE,CA6CxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasSolcInput, hasMetadata, hasEvmData } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a minimal valid AST for a source file.
|
|
4
4
|
* This is needed because Hardhat's contract decoder expects a valid AST structure.
|
|
@@ -34,162 +34,192 @@ function createMinimalAst(sourceName, sourceId, contracts) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Otherwise, synthesize a minimal compilation.
|
|
37
|
+
* Extract compilation context from an artifact.
|
|
38
|
+
* Tries solcInput first, then falls back to metadata, then defaults.
|
|
40
39
|
*/
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(` - ${artifact.contractName}: ${isRich ? 'rich' : 'simple'}, immutableReferences: ${immCount} keys`);
|
|
40
|
+
function extractCompilationContext(artifact, defaultSolcVersion, debug = false) {
|
|
41
|
+
// Try to extract from solcInput first (most complete)
|
|
42
|
+
if (hasSolcInput(artifact)) {
|
|
43
|
+
try {
|
|
44
|
+
const compilerInput = JSON.parse(artifact.solcInput);
|
|
45
|
+
const solcVersion = extractVersionFromMetadata(artifact.metadata) ?? defaultSolcVersion;
|
|
46
|
+
// Use a hash of settings to group artifacts with same compilation context
|
|
47
|
+
const settingsKey = JSON.stringify(compilerInput.settings);
|
|
48
|
+
return {
|
|
49
|
+
solcVersion,
|
|
50
|
+
compilerInput,
|
|
51
|
+
groupKey: `solcInput:${solcVersion}:${hashString(settingsKey)}`,
|
|
52
|
+
};
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (compilation) {
|
|
62
|
-
compilations.push(compilation);
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (debug) {
|
|
56
|
+
console.log(`[external-artifacts] Failed to parse solcInput for ${artifact.contractName}: ${e}`);
|
|
57
|
+
}
|
|
58
|
+
// Fall through to metadata extraction
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
|
-
//
|
|
66
|
-
if (
|
|
67
|
-
compilations.push(synthesizeCompilation(simpleArtifacts, defaultSolcVersion, debug));
|
|
68
|
-
}
|
|
69
|
-
return compilations;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Convert a rich artifact (with embedded solcInput) to a compilation.
|
|
73
|
-
* Uses the embedded solcInput directly for maximum fidelity.
|
|
74
|
-
*/
|
|
75
|
-
function richArtifactToCompilation(artifact, debug = false) {
|
|
76
|
-
if (!artifact.solcInput) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
// Parse the embedded solcInput
|
|
80
|
-
const compilerInput = JSON.parse(artifact.solcInput);
|
|
81
|
-
// Extract solc version from metadata
|
|
82
|
-
let solcVersion = '0.8.20'; // Default
|
|
83
|
-
if (artifact.metadata) {
|
|
61
|
+
// Try to extract from metadata (partial but useful)
|
|
62
|
+
if (hasMetadata(artifact)) {
|
|
84
63
|
try {
|
|
85
64
|
const metadata = JSON.parse(artifact.metadata);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
65
|
+
const solcVersion = extractVersionFromMetadataObject(metadata) ?? defaultSolcVersion;
|
|
66
|
+
const compilerInput = metadataToCompilerInput(metadata);
|
|
67
|
+
if (compilerInput) {
|
|
68
|
+
const settingsKey = JSON.stringify(compilerInput.settings);
|
|
69
|
+
return {
|
|
70
|
+
solcVersion,
|
|
71
|
+
compilerInput,
|
|
72
|
+
groupKey: `metadata:${solcVersion}:${hashString(settingsKey)}`,
|
|
73
|
+
};
|
|
89
74
|
}
|
|
90
75
|
}
|
|
91
|
-
catch {
|
|
92
|
-
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (debug) {
|
|
78
|
+
console.log(`[external-artifacts] Failed to parse metadata for ${artifact.contractName}: ${e}`);
|
|
79
|
+
}
|
|
80
|
+
// Fall through to defaults
|
|
93
81
|
}
|
|
94
82
|
}
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
contracts: {},
|
|
83
|
+
// Default: no compiler input available, use defaults
|
|
84
|
+
return {
|
|
85
|
+
solcVersion: defaultSolcVersion,
|
|
86
|
+
compilerInput: null,
|
|
87
|
+
groupKey: `default:${defaultSolcVersion}`,
|
|
101
88
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract solc version from metadata string.
|
|
92
|
+
*/
|
|
93
|
+
function extractVersionFromMetadata(metadataStr) {
|
|
94
|
+
if (!metadataStr)
|
|
95
|
+
return null;
|
|
96
|
+
try {
|
|
97
|
+
const metadata = JSON.parse(metadataStr);
|
|
98
|
+
return extractVersionFromMetadataObject(metadata);
|
|
108
99
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const contractNodeId = contractSourceId + 1000; // Use an offset to avoid ID conflicts
|
|
112
|
-
compilerOutput.sources[sourceName] = {
|
|
113
|
-
id: contractSourceId,
|
|
114
|
-
ast: createMinimalAst(sourceName, contractSourceId, [
|
|
115
|
-
{ name: artifact.contractName, nodeId: contractNodeId },
|
|
116
|
-
]),
|
|
117
|
-
};
|
|
118
|
-
compilerOutput.contracts[sourceName] = {};
|
|
119
|
-
// Ensure the source is in compilerInput as well
|
|
120
|
-
if (!compilerInput.sources[sourceName]) {
|
|
121
|
-
compilerInput.sources[sourceName] = { content: '' };
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
122
102
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Extract solc version from parsed metadata object.
|
|
106
|
+
*/
|
|
107
|
+
function extractVersionFromMetadataObject(metadata) {
|
|
108
|
+
if (metadata?.compiler?.version) {
|
|
109
|
+
// Format: "0.8.10+commit.fc410830" -> extract "0.8.10"
|
|
110
|
+
return metadata.compiler.version.split('+')[0];
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Convert metadata to compiler input.
|
|
116
|
+
* Metadata contains settings but not full source content.
|
|
117
|
+
*/
|
|
118
|
+
function metadataToCompilerInput(metadata) {
|
|
119
|
+
if (!metadata?.settings)
|
|
120
|
+
return null;
|
|
121
|
+
const settings = metadata.settings;
|
|
122
|
+
const sources = {};
|
|
123
|
+
// Metadata has source hashes but not content
|
|
124
|
+
// We'll add empty placeholders that get filled in later
|
|
125
|
+
if (metadata.sources) {
|
|
126
|
+
for (const sourceName of Object.keys(metadata.sources)) {
|
|
127
|
+
// Some metadata includes content in keccak256 only
|
|
128
|
+
// We use empty content as placeholder
|
|
129
|
+
sources[sourceName] = { content: '' };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
language: metadata.language ?? 'Solidity',
|
|
134
|
+
sources,
|
|
135
|
+
settings: {
|
|
136
|
+
optimizer: settings.optimizer ?? { enabled: false },
|
|
137
|
+
outputSelection: settings.outputSelection ?? {
|
|
138
|
+
'*': { '*': ['abi', 'evm.bytecode', 'evm.deployedBytecode'] },
|
|
139
|
+
},
|
|
140
|
+
remappings: settings.remappings,
|
|
141
|
+
metadata: settings.metadata,
|
|
142
|
+
evmVersion: settings.evmVersion,
|
|
143
|
+
viaIR: settings.viaIR,
|
|
161
144
|
},
|
|
162
|
-
metadata: artifact.metadata,
|
|
163
|
-
devdoc: artifact.devdoc,
|
|
164
|
-
userdoc: artifact.userdoc,
|
|
165
|
-
storageLayout: artifact.storageLayout,
|
|
166
145
|
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Simple string hash for grouping.
|
|
149
|
+
*/
|
|
150
|
+
function hashString(str) {
|
|
151
|
+
let hash = 0;
|
|
152
|
+
for (let i = 0; i < str.length; i++) {
|
|
153
|
+
const char = str.charCodeAt(i);
|
|
154
|
+
hash = ((hash << 5) - hash) + char;
|
|
155
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
156
|
+
}
|
|
157
|
+
return hash.toString(16);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Convert artifacts to compilation format.
|
|
161
|
+
* Flexibly extracts data from each artifact - uses solcInput if available,
|
|
162
|
+
* falls back to metadata for settings, or synthesizes minimal compilation.
|
|
163
|
+
*/
|
|
164
|
+
export function artifactsToCompilations(artifacts, defaultSolcVersion, debug = false) {
|
|
167
165
|
if (debug) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
console.log(`[external-artifacts] Processing ${artifacts.length} artifacts`);
|
|
167
|
+
}
|
|
168
|
+
// Extract context from each artifact and group by compilation context
|
|
169
|
+
const artifactsByContext = new Map();
|
|
170
|
+
for (const artifact of artifacts) {
|
|
171
|
+
const context = extractCompilationContext(artifact, defaultSolcVersion, debug);
|
|
172
|
+
const richArt = artifact;
|
|
173
|
+
const immRefs = richArt.evm?.deployedBytecode?.immutableReferences ?? artifact.immutableReferences;
|
|
174
|
+
const immCount = immRefs ? Object.keys(immRefs).length : 0;
|
|
175
|
+
if (debug) {
|
|
176
|
+
console.log(` - ${artifact.contractName}: solcInput=${hasSolcInput(artifact)}, metadata=${hasMetadata(artifact)}, immutableReferences=${immCount} keys, group=${context.groupKey}`);
|
|
177
|
+
}
|
|
178
|
+
const existing = artifactsByContext.get(context.groupKey);
|
|
179
|
+
if (existing) {
|
|
180
|
+
existing.artifacts.push(artifact);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
artifactsByContext.set(context.groupKey, {
|
|
184
|
+
context,
|
|
185
|
+
artifacts: [artifact],
|
|
186
|
+
});
|
|
175
187
|
}
|
|
176
|
-
console.log(` - deployedBytecode length: ${deployedBytecode.object.length / 2} bytes`);
|
|
177
188
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
if (debug) {
|
|
190
|
+
console.log(`[external-artifacts] Grouped into ${artifactsByContext.size} compilations`);
|
|
191
|
+
}
|
|
192
|
+
// Convert each group to a compilation
|
|
193
|
+
const compilations = [];
|
|
194
|
+
for (const { context, artifacts: groupArtifacts } of artifactsByContext.values()) {
|
|
195
|
+
const compilation = buildCompilation(groupArtifacts, context, debug);
|
|
196
|
+
compilations.push(compilation);
|
|
197
|
+
}
|
|
198
|
+
return compilations;
|
|
183
199
|
}
|
|
184
200
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
201
|
+
* Build a compilation from a group of artifacts sharing the same context.
|
|
202
|
+
* Flexibly extracts available data from each artifact.
|
|
187
203
|
*/
|
|
188
|
-
function
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
204
|
+
function buildCompilation(artifacts, context, debug = false) {
|
|
205
|
+
// Start with context's compiler input or create a minimal one
|
|
206
|
+
const compilerInput = context.compilerInput
|
|
207
|
+
? { ...context.compilerInput, sources: { ...context.compilerInput.sources } }
|
|
208
|
+
: {
|
|
209
|
+
language: 'Solidity',
|
|
210
|
+
sources: {},
|
|
211
|
+
settings: {
|
|
212
|
+
optimizer: { enabled: false },
|
|
213
|
+
outputSelection: {
|
|
214
|
+
'*': { '*': ['abi', 'evm.bytecode', 'evm.deployedBytecode'] },
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
const compilerOutput = {
|
|
219
|
+
sources: {},
|
|
220
|
+
contracts: {},
|
|
221
|
+
};
|
|
222
|
+
// Group artifacts by source for AST generation
|
|
193
223
|
const contractsBySource = {};
|
|
194
224
|
for (const artifact of artifacts) {
|
|
195
225
|
if (!contractsBySource[artifact.sourceName]) {
|
|
@@ -200,81 +230,95 @@ function synthesizeCompilation(artifacts, solcVersion, debug = false) {
|
|
|
200
230
|
artifact,
|
|
201
231
|
});
|
|
202
232
|
}
|
|
203
|
-
// Track IDs
|
|
204
|
-
let
|
|
205
|
-
|
|
233
|
+
// Track source IDs - use existing ones from compiler input if available
|
|
234
|
+
let nextSourceId = 0;
|
|
235
|
+
const sourceIds = {};
|
|
236
|
+
for (const srcName of Object.keys(compilerInput.sources)) {
|
|
237
|
+
sourceIds[srcName] = nextSourceId++;
|
|
238
|
+
}
|
|
239
|
+
// Track node IDs for AST
|
|
240
|
+
let nextNodeId = nextSourceId + 1000; // Offset to avoid conflicts
|
|
241
|
+
// Process each source
|
|
206
242
|
for (const [sourceName, sourceContracts] of Object.entries(contractsBySource)) {
|
|
207
|
-
|
|
208
|
-
sources[sourceName]
|
|
209
|
-
|
|
243
|
+
// Ensure source exists in compiler input
|
|
244
|
+
if (!compilerInput.sources[sourceName]) {
|
|
245
|
+
compilerInput.sources[sourceName] = { content: '' };
|
|
246
|
+
}
|
|
247
|
+
// Get or assign source ID
|
|
248
|
+
const sourceId = sourceIds[sourceName] ?? nextSourceId++;
|
|
249
|
+
sourceIds[sourceName] = sourceId;
|
|
210
250
|
// Create contract nodes for AST
|
|
211
251
|
const contractNodes = [];
|
|
212
252
|
for (const { name } of sourceContracts) {
|
|
213
|
-
|
|
214
|
-
contractNodes.push({ name, nodeId });
|
|
253
|
+
contractNodes.push({ name, nodeId: nextNodeId++ });
|
|
215
254
|
}
|
|
216
|
-
|
|
255
|
+
compilerOutput.sources[sourceName] = {
|
|
217
256
|
id: sourceId,
|
|
218
257
|
ast: createMinimalAst(sourceName, sourceId, contractNodes),
|
|
219
258
|
};
|
|
259
|
+
compilerOutput.contracts[sourceName] = {};
|
|
220
260
|
// Add contract outputs
|
|
221
261
|
for (const { name, artifact } of sourceContracts) {
|
|
222
|
-
// Cast to access optional evm property that may exist on artifacts
|
|
223
|
-
// without solcInput (partial RichArtifact)
|
|
224
262
|
const richArtifact = artifact;
|
|
263
|
+
// Build bytecode output, extracting from evm if available
|
|
264
|
+
const bytecode = {
|
|
265
|
+
object: stripHexPrefix(richArtifact.evm?.bytecode?.object ?? artifact.bytecode ?? '0x'),
|
|
266
|
+
opcodes: richArtifact.evm?.bytecode?.opcodes ?? '',
|
|
267
|
+
sourceMap: richArtifact.evm?.bytecode?.sourceMap ?? '',
|
|
268
|
+
linkReferences: richArtifact.evm?.bytecode?.linkReferences ?? artifact.linkReferences ?? {},
|
|
269
|
+
generatedSources: richArtifact.evm?.bytecode?.generatedSources,
|
|
270
|
+
functionDebugData: richArtifact.evm?.bytecode?.functionDebugData,
|
|
271
|
+
};
|
|
225
272
|
const immutableReferences = richArtifact.evm?.deployedBytecode?.immutableReferences ??
|
|
226
273
|
artifact.immutableReferences ??
|
|
227
274
|
{};
|
|
228
|
-
|
|
275
|
+
const deployedBytecode = {
|
|
276
|
+
object: stripHexPrefix(richArtifact.evm?.deployedBytecode?.object ??
|
|
277
|
+
artifact.deployedBytecode ??
|
|
278
|
+
'0x'),
|
|
279
|
+
opcodes: richArtifact.evm?.deployedBytecode?.opcodes ?? '',
|
|
280
|
+
sourceMap: richArtifact.evm?.deployedBytecode?.sourceMap ?? '',
|
|
281
|
+
linkReferences: richArtifact.evm?.deployedBytecode?.linkReferences ??
|
|
282
|
+
artifact.deployedLinkReferences ??
|
|
283
|
+
{},
|
|
284
|
+
immutableReferences,
|
|
285
|
+
generatedSources: richArtifact.evm?.deployedBytecode?.generatedSources,
|
|
286
|
+
functionDebugData: richArtifact.evm?.deployedBytecode?.functionDebugData,
|
|
287
|
+
};
|
|
288
|
+
// IMPORTANT: Do NOT provide method identifiers - let EDR compute them
|
|
289
|
+
// EDR has internal "selector fixup" logic for function overloading that can fail
|
|
290
|
+
// if we provide method identifiers that it then tries to reconcile with AST info.
|
|
291
|
+
compilerOutput.contracts[sourceName][name] = {
|
|
229
292
|
abi: artifact.abi,
|
|
230
293
|
evm: {
|
|
231
|
-
bytecode
|
|
232
|
-
|
|
233
|
-
opcodes: '',
|
|
234
|
-
sourceMap: '',
|
|
235
|
-
linkReferences: artifact.linkReferences ?? {},
|
|
236
|
-
},
|
|
237
|
-
deployedBytecode: {
|
|
238
|
-
object: stripHexPrefix(artifact.deployedBytecode),
|
|
239
|
-
opcodes: '',
|
|
240
|
-
sourceMap: '',
|
|
241
|
-
linkReferences: artifact.deployedLinkReferences ?? {},
|
|
242
|
-
// Check both evm.deployedBytecode.immutableReferences and top-level
|
|
243
|
-
immutableReferences,
|
|
244
|
-
},
|
|
245
|
-
// Empty object - let EDR compute selectors to avoid selector fixup issues
|
|
246
|
-
// with overloaded functions (consistent with richArtifactToCompilation)
|
|
294
|
+
bytecode,
|
|
295
|
+
deployedBytecode,
|
|
247
296
|
methodIdentifiers: {},
|
|
248
297
|
},
|
|
298
|
+
metadata: richArtifact.metadata,
|
|
299
|
+
devdoc: richArtifact.devdoc,
|
|
300
|
+
userdoc: richArtifact.userdoc,
|
|
301
|
+
storageLayout: richArtifact.storageLayout,
|
|
249
302
|
};
|
|
250
303
|
if (debug) {
|
|
251
304
|
const immRefKeys = Object.keys(immutableReferences);
|
|
252
|
-
console.log(`[external-artifacts]
|
|
305
|
+
console.log(`[external-artifacts] Built artifact: ${name}`);
|
|
253
306
|
console.log(` - sourceName: ${sourceName}`);
|
|
307
|
+
console.log(` - hasSolcInput: ${hasSolcInput(artifact)}`);
|
|
308
|
+
console.log(` - hasMetadata: ${hasMetadata(artifact)}`);
|
|
309
|
+
console.log(` - hasEvmData: ${hasEvmData(artifact)}`);
|
|
254
310
|
console.log(` - immutableReferences keys: ${immRefKeys.length}`);
|
|
255
311
|
if (immRefKeys.length > 0) {
|
|
256
312
|
console.log(` - immutableReferences sample:`, JSON.stringify(immutableReferences, null, 2).slice(0, 500));
|
|
257
313
|
}
|
|
258
|
-
console.log(` - deployedBytecode length: ${
|
|
314
|
+
console.log(` - deployedBytecode length: ${deployedBytecode.object.length / 2} bytes`);
|
|
259
315
|
}
|
|
260
316
|
}
|
|
261
317
|
}
|
|
262
318
|
return {
|
|
263
|
-
solcVersion,
|
|
264
|
-
compilerInput
|
|
265
|
-
|
|
266
|
-
sources,
|
|
267
|
-
settings: {
|
|
268
|
-
optimizer: { enabled: false },
|
|
269
|
-
outputSelection: {
|
|
270
|
-
'*': { '*': ['abi', 'evm.bytecode', 'evm.deployedBytecode'] },
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
compilerOutput: {
|
|
275
|
-
sources: outputSources,
|
|
276
|
-
contracts,
|
|
277
|
-
},
|
|
319
|
+
solcVersion: context.solcVersion,
|
|
320
|
+
compilerInput,
|
|
321
|
+
compilerOutput,
|
|
278
322
|
};
|
|
279
323
|
}
|
|
280
324
|
function stripHexPrefix(hex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/artifacts/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,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C,CAAC,CAAC;gBAC5G,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,gCAAgC,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,aAAa;QACb,cAAc;KACd,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAClD,CAAC"}
|
|
@@ -74,9 +74,27 @@ export interface LinkReferences {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Type guard to check if an artifact
|
|
77
|
+
* Type guard to check if an artifact has solcInput.
|
|
78
|
+
* Note: The converter now handles artifacts flexibly, extracting
|
|
79
|
+
* available data from solcInput, metadata, or evm fields without
|
|
80
|
+
* requiring a strict "rich" vs "simple" classification.
|
|
78
81
|
*/
|
|
79
|
-
export declare function
|
|
82
|
+
export declare function hasSolcInput(artifact: ExternalArtifact): artifact is RichArtifact & {
|
|
83
|
+
solcInput: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Type guard to check if an artifact has metadata.
|
|
87
|
+
* Metadata can be used as a fallback for compiler settings when solcInput is not available.
|
|
88
|
+
*/
|
|
89
|
+
export declare function hasMetadata(artifact: ExternalArtifact): artifact is RichArtifact & {
|
|
90
|
+
metadata: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Type guard to check if an artifact has EVM data.
|
|
94
|
+
*/
|
|
95
|
+
export declare function hasEvmData(artifact: ExternalArtifact): artifact is RichArtifact & {
|
|
96
|
+
evm: NonNullable<RichArtifact['evm']>;
|
|
97
|
+
};
|
|
80
98
|
/**
|
|
81
99
|
* Function type for dynamically resolving artifacts
|
|
82
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/artifacts/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IAErB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,mBAAmB;IACnB,GAAG,EAAE,SAAS,GAAG,EAAE,CAAC;IAEpB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IAEjB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sDAAsD;IACtD,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,cAAc,CAAC;IAExC,qEAAqE;IACrE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC,CAAC;CAC7E;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACrD,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qEAAqE;IACrE,GAAG,CAAC,EAAE;QACL,QAAQ,EAAE;YACT,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;YAClB,cAAc,EAAE,cAAc,CAAC;YAC/B,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;YACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACxC,CAAC;QACF,gBAAgB,EAAE;YACjB,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,SAA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