-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5741 from NomicFoundation/feat/hre-artifacts
add mock artifacts plugins
- Loading branch information
Showing
11 changed files
with
559 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
v-next/hardhat/src/internal/builtin-plugins/artifacts/artifacts-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { | ||
Artifact, | ||
ArtifactsManager, | ||
BuildInfo, | ||
CompilerInput, | ||
CompilerOutput, | ||
} from "../../../types/artifacts.js"; | ||
|
||
import { HardhatError } from "@ignored/hardhat-vnext-errors"; | ||
|
||
export class ArtifactsManagerImplementation implements ArtifactsManager { | ||
public readArtifact( | ||
_contractNameOrFullyQualifiedName: string, | ||
): Promise<Artifact> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public artifactExists( | ||
_contractNameOrFullyQualifiedName: string, | ||
): Promise<boolean> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public getAllFullyQualifiedNames(): Promise<string[]> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public getBuildInfo( | ||
_fullyQualifiedName: string, | ||
): Promise<BuildInfo | undefined> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public getArtifactPaths(): Promise<string[]> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public getBuildInfoPaths(): Promise<string[]> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public saveArtifact(_artifact: Artifact): Promise<void> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public saveBuildInfo( | ||
_solcVersion: string, | ||
_solcLongVersion: string, | ||
_input: CompilerInput, | ||
_output: CompilerOutput, | ||
): Promise<string> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
|
||
public getArtifactPath(_fullyQualifiedName: string): Promise<string> { | ||
throw new HardhatError(HardhatError.ERRORS.INTERNAL.NOT_IMPLEMENTED_ERROR, { | ||
message: "Not implemented in fake artifacts manager", | ||
}); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
v-next/hardhat/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { HardhatRuntimeEnvironmentHooks } from "../../../../types/hooks.js"; | ||
|
||
export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => { | ||
const handlers: Partial<HardhatRuntimeEnvironmentHooks> = { | ||
created: async (_context, hre): Promise<void> => { | ||
const { ArtifactsManagerImplementation } = await import( | ||
"../artifacts-manager.js" | ||
); | ||
|
||
hre.artifacts = new ArtifactsManagerImplementation(); | ||
}, | ||
}; | ||
|
||
return handlers; | ||
}; |
11 changes: 11 additions & 0 deletions
11
v-next/hardhat/src/internal/builtin-plugins/artifacts/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { HardhatPlugin } from "../../../types/plugins.js"; | ||
import "./type-extensions.js"; | ||
|
||
const hardhatPlugin: HardhatPlugin = { | ||
id: "artifacts", | ||
hookHandlers: { | ||
hre: import.meta.resolve("./hook-handlers/hre.js"), | ||
}, | ||
}; | ||
|
||
export default hardhatPlugin; |
7 changes: 7 additions & 0 deletions
7
v-next/hardhat/src/internal/builtin-plugins/artifacts/type-extensions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { ArtifactsManager } from "../../../types/artifacts.js"; | ||
|
||
declare module "../../../types/hre.js" { | ||
interface HardhatRuntimeEnvironment { | ||
artifacts: ArtifactsManager; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.