Skip to content

Commit

Permalink
compile hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
aazhou1 committed Dec 20, 2024
1 parent 431cd8c commit 5771f90
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-strategy-hardhat-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
with:
fetch-depth: 0
- uses: foundry-rs/foundry-toolchain@v1
- run: forge install
- run: forge remappings > remappings.txt
- id: nodeversion
run: echo "version=$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')" >> $GITHUB_OUTPUT
- run: corepack enable
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-strategy-hardhat-sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
with:
fetch-depth: 0
- uses: foundry-rs/foundry-toolchain@v1
- run: forge install
- run: forge remappings > remappings.txt
- id: nodeversion
run: echo "version=$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')" >> $GITHUB_OUTPUT
- run: corepack enable
Expand Down
24 changes: 24 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ import "@nomicfoundation/hardhat-ethers";
import { task } from "hardhat/config";
import path from "path";
import glob from "glob";
import fs from "fs";

const remappings = fs
.readFileSync("remappings.txt", "utf-8")
.split("\n")
.filter((line) => line.trim() !== "") // Remove empty lines
.map((line) => line.trim().split("="));

const resolveImportPath = (importPath: string): string => {
for (const [prefix, target] of remappings) {
if (importPath.startsWith(prefix)) {
return path.join(target, importPath.slice(prefix.length));
}
}
return importPath;
};

task("compile", "Compiles the project, excluding specific files", async (_, { run }) => {
const excludedPaths = [
Expand Down Expand Up @@ -33,6 +49,14 @@ const config: HardhatUserConfig = {
paths: {
sources: "./src", // Specify the main directory for source files
},
solidity: "0.8.23",
paths: {
sources: "./src", // Your contract source directory
libraries: "./lib", // Point Hardhat to Foundry's lib folder
cache: "./cache", // Keep Foundry and Hardhat caches separate
artifacts: "./artifacts", // Keep artifacts separate
},

networks: {
sepolia: {
url: process.env.SEPOLIA_RPC_URL || "",
Expand Down

0 comments on commit 5771f90

Please sign in to comment.