( artifact: Artifact, providedLibraries: LibraryAddresses, )
| 30 | * @throws MissingLibrariesError If any needed library address is missing. |
| 31 | */ |
| 32 | export 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. |
no test coverage detected