Skip to content

Commit 48efed9

Browse files
feat: setup hardhat foundry template
1 parent 0b873b2 commit 48efed9

File tree

7 files changed

+8353
-178
lines changed

7 files changed

+8353
-178
lines changed

.env.example

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
RINKEBY_RPC_URL=
2-
ETHERSCAN_API_KEY=abcabcabcbabcbac
3-
SOCKET_OWNER_PRIVATE_KEY=0xabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbac
4-
PLUG_OWNER_PRIVATE_KEY= 0xabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbac
5-
PAUSER_PRIVATE_KEY=0xabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbacabcabcabcbabcbac
6-
7-
# deployment config
8-
PAUSER_ADDRESS=0xabcabcabcbabcbacabcabcabcbabcbacabcabcab
9-
IS_SEQUENTIAL=true
2+
ETHERSCAN_API_KEY=
3+
SOCKET_OWNER_PRIVATE_KEY=0x
4+
PLUG_OWNER_PRIVATE_KEY= 0x
5+
PAUSER_PRIVATE_KEY=0x

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
cache/
22
out/
33
node_modules/
4-
broadcast/
54
deployments/
65

6+
#Hardhat files
7+
cache_hardhat/
8+
artifacts/
9+
10+
#Hardhat plugin files
11+
typechain-types/
12+
713
.env

hardhat.config.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import "@nomiclabs/hardhat-waffle";
2+
import "@nomiclabs/hardhat-ethers"
3+
import "@typechain/hardhat";
4+
import "hardhat-preprocessor";
5+
import "hardhat-deploy";
6+
7+
import fs from "fs";
8+
import { HardhatUserConfig } from "hardhat/config";
9+
require("dotenv");
10+
11+
const accounts = [process.env.SOCKET_OWNER_PRIVATE_KEY, process.env.PLUG_OWNER_PRIVATE_KEY, process.env.PAUSER_PRIVATE_KEY];
12+
13+
function getRemappings() {
14+
return fs
15+
.readFileSync("remappings.txt", "utf8")
16+
.split("\n")
17+
.filter(Boolean)
18+
.map((line) => line.trim().split("="));
19+
}
20+
21+
const config: HardhatUserConfig = {
22+
solidity: {
23+
version: "0.8.13",
24+
settings: {
25+
optimizer: {
26+
enabled: true,
27+
runs: 200,
28+
},
29+
},
30+
},
31+
networks: {
32+
hardhat: {
33+
accounts: {},
34+
chainId: 31337,
35+
},
36+
},
37+
paths: {
38+
sources: "./src", // Use ./src rather than ./contracts as Hardhat expects
39+
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
40+
},
41+
// This fully resolves paths for imports in the ./lib directory for Hardhat
42+
preprocess: {
43+
eachLine: (hre) => ({
44+
transform: (line: string) => {
45+
if (line.match(/^\s*import /i)) {
46+
getRemappings().forEach(([find, replace]) => {
47+
if (line.match(find)) {
48+
line = line.replace(find, replace);
49+
}
50+
});
51+
}
52+
return line;
53+
},
54+
}),
55+
},
56+
namedAccounts: {
57+
socketOwner: {
58+
default: 0,
59+
},
60+
counterOwner: {
61+
default: 1,
62+
},
63+
pauser: {
64+
default: 2,
65+
}
66+
}
67+
};
68+
69+
export default config;

package.json

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,33 @@
1111
"url": "git+https://github.com/SocketDotTech/socket-DL.git"
1212
},
1313
"devDependencies": {
14+
"@nomiclabs/hardhat-ethers": "^2.1.1",
15+
"@nomiclabs/hardhat-waffle": "^2.0.3",
16+
"@typechain/ethers-v5": "^10.0.0",
17+
"@typechain/hardhat": "^6.0.0",
18+
"@types/chai": "^4.3.0",
19+
"@types/mocha": "^9.1.0",
20+
"@types/node": "^17.0.35",
21+
"chai": "^4.3.6",
22+
"ethereum-waffle": "^3.2.0",
23+
"ethers": "^5.6.6",
24+
"hardhat": "^2.9.5",
25+
"hardhat-preprocessor": "^0.1.4",
1426
"pre-commit": "^1.2.2",
1527
"prettier": "^2.3.1",
16-
"prettier-plugin-solidity": "^1.0.0-beta.13"
28+
"prettier-plugin-solidity": "^1.0.0-beta.13",
29+
"ts-node": "^10.7.0",
30+
"typechain": "^8.0.0",
31+
"typescript": "^4.6.4"
1732
},
1833
"scripts": {
1934
"lint": "prettier --write **.sol"
2035
},
21-
"pre-commit": [ "lint" ]
36+
"pre-commit": [
37+
"lint"
38+
],
39+
"dependencies": {
40+
"dotenv": "^16.0.1",
41+
"hardhat-deploy": "^0.11.12"
42+
}
2243
}

tasks/accounts.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
2+
3+
export default async function accounts(
4+
params: any,
5+
hre: HardhatRuntimeEnvironment
6+
): Promise<void> {
7+
const [account] = await hre.ethers.getSigners();
8+
9+
console.log(
10+
`Balance for 1st account ${await account.getAddress()}: ${await account.getBalance()}`
11+
);
12+
}

tsconfig.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2018",
4+
"module": "commonjs",
5+
"strict": true,
6+
"esModuleInterop": true,
7+
"outDir": "dist",
8+
"declaration": true,
9+
"resolveJsonModule": true
10+
},
11+
"include": ["./tasks", "./test", "./typechain-types", "scratchpad/configure.ts"],
12+
"files": ["./hardhat.config.ts"]
13+
}

0 commit comments

Comments
 (0)