MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / resolveLinkedBytecode

Function resolveLinkedBytecode

packages/hardhat-utils/src/bytecode.ts:32–61  ·  view source on GitHub ↗
(
  artifact: Artifact,
  providedLibraries: LibraryAddresses,
)

Source from the content-addressed store, hash-verified

30 * @throws MissingLibrariesError If any needed library address is missing.
31 */
32export function resolveLinkedBytecode(
33 artifact: Artifact,
34 providedLibraries: LibraryAddresses,
35): PrefixedHexString {
36 checkProvidedLibraryAddresses(providedLibraries);
37
38 const neededLibraries: LibraryLink[] = [];
39 for (const [sourceName, sourceLibraries] of Object.entries(
40 artifact.linkReferences,
41 )) {
42 for (const libraryName of Object.keys(sourceLibraries)) {
43 const libraryFqn = `${sourceName}:${libraryName}`;
44 const address =
45 providedLibraries[libraryFqn] ?? providedLibraries[libraryName];
46
47 neededLibraries.push({
48 sourceName,
49 libraryName,
50 libraryFqn,
51 address,
52 });
53 }
54 }
55
56 checkAmbiguousOrUnnecessaryLinks(providedLibraries, neededLibraries);
57 checkOverlappingLibraryNames(providedLibraries, neededLibraries);
58 checkMissingLibraryAddresses(neededLibraries);
59
60 return linkBytecode(artifact, neededLibraries);
61}
62
63/**
64 * Links the bytecode of a contract artifact with the provided library addresses.

Callers 2

bytecode.tsFile · 0.85

Calls 5

linkBytecodeFunction · 0.85

Tested by

no test coverage detected