Skip to content

Commit 413cd69

Browse files
committed
Use input source names in the link references
1 parent 5401a88 commit 413cd69

File tree

3 files changed

+4
-38
lines changed

3 files changed

+4
-38
lines changed

v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/artifacts.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
Artifact,
3-
BuildInfo,
4-
LinkReferences,
5-
} from "../../../../types/artifacts.js";
1+
import type { Artifact, BuildInfo } from "../../../../types/artifacts.js";
62
import type { CompilationJob } from "../../../../types/solidity/compilation-job.js";
73
import type {
84
CompilerOutput,
@@ -21,7 +17,6 @@ export function getContractArtifact(
2117
inputSourceName: string,
2218
contractName: string,
2319
contract: CompilerOutputContract,
24-
userSourceNameMap: Record<string, string>,
2520
): Artifact {
2621
const evmBytecode = contract.evm?.bytecode;
2722
const bytecode: string =
@@ -47,14 +42,8 @@ export function getContractArtifact(
4742
abi: contract.abi,
4843
bytecode,
4944
deployedBytecode,
50-
linkReferences: applyUserSourceNamesToLinkReferences(
51-
linkReferences,
52-
userSourceNameMap,
53-
),
54-
deployedLinkReferences: applyUserSourceNamesToLinkReferences(
55-
deployedLinkReferences,
56-
userSourceNameMap,
57-
),
45+
linkReferences,
46+
deployedLinkReferences,
5847
immutableReferences,
5948
inputSourceName,
6049
buildInfoId,
@@ -63,18 +52,6 @@ export function getContractArtifact(
6352
return artifact;
6453
}
6554

66-
function applyUserSourceNamesToLinkReferences(
67-
linkReferences: LinkReferences,
68-
userSourceNameMap: Record<string, string>,
69-
): LinkReferences {
70-
return Object.fromEntries(
71-
Object.entries(linkReferences).map(([sourceName, references]) => [
72-
userSourceNameMap[sourceName] ?? sourceName,
73-
references,
74-
]),
75-
);
76-
}
77-
7855
export function getArtifactsDeclarationFile(artifacts: Artifact[]): string {
7956
if (artifacts.length === 0) {
8057
return "";

v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,6 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
471471
const result = new Map<string, string[]>();
472472
const buildId = await compilationJob.getBuildId();
473473

474-
const userSourceNameMap = Object.fromEntries(
475-
compilationJob.dependencyGraph
476-
.getRoots()
477-
.entries()
478-
.map(([userSourceName, root]) => [
479-
root.inputSourceName,
480-
userSourceName,
481-
]),
482-
);
483-
484474
// We emit the artifacts for each root file, first emitting one artifact
485475
// for each contract, and then one declaration file for the entire file,
486476
// which defines their types and augments the ArtifactMap type.
@@ -511,7 +501,6 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
511501
root.inputSourceName,
512502
contractName,
513503
contract,
514-
userSourceNameMap,
515504
);
516505

517506
await writeUtf8File(

v-next/hardhat/src/types/artifacts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export interface Artifact<AbiT extends Abi = Abi> {
218218
* The link references of a contract, which need to be resolved before using it.
219219
*/
220220
export interface LinkReferences {
221-
[librarySourceName: string]: {
221+
[libraryInputSourceName: string]: {
222222
[libraryName: string]: Array<{ length: number; start: number }>;
223223
};
224224
}

0 commit comments

Comments
 (0)