Skip to content

Commit 87a467e

Browse files
committed
feat: Setup repo to compile contracts
1 parent 1e38a09 commit 87a467e

File tree

10 files changed

+43025
-0
lines changed

10 files changed

+43025
-0
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## NODE URLS
2+
MAINNET_URL=https://eth-mainnet.alchemyapi.io/v2/API_KEY
3+
POLYGON_MAINNET_URL=https://polygon-mainnet.g.alchemy.com/v2/API_KEY
4+
RINKEBY_URL=
5+
DEFAULT_FORK_BLOCK=15001901
6+
7+
## Always consider these compromised
8+
MNEMONIC=
9+
PRIVATE_KEY=

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# files
2+
.DS_Store
3+
node_modules
4+
5+
# env
6+
.env
7+
8+
# foundry
9+
out
10+
cache
11+
12+
# hardhat
13+
artifacts
14+
15+
# typechain
16+
typechain

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/ds-test"]
5+
path = lib/ds-test
6+
url = https://github.com/dapphub/ds-test

foundry.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[profile.default]
2+
src = 'src/contracts'
3+
test = 'src/test'
4+
out = 'out'
5+
libs = ['node_modules', 'lib']
6+
#block number
7+
block_number = 100
8+
# The block timestamp in tests
9+
block_timestamp = 1500
10+
# allow ffi
11+
ffi = true
12+
# gas limit in tests
13+
gas_limit = 30000000
14+
# optimizer
15+
optimizer = true
16+
# optimizer runs
17+
optimizer_runs = 200
18+
# use via-ir optimizer
19+
# via_ir = true
20+
21+
# See more config options https://github.com/gakonst/foundry/tree/master/config

hardhat.config.ts

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import * as fs from "fs";
2+
import { config as dotenvConfig } from "dotenv";
3+
import "@nomiclabs/hardhat-ethers";
4+
import '@typechain/hardhat'
5+
import '@nomiclabs/hardhat-ethers'
6+
import '@nomiclabs/hardhat-waffle'
7+
import { HardhatUserConfig } from "hardhat/config";
8+
import "hardhat-gas-reporter";
9+
import "hardhat-preprocessor";
10+
import "solidity-coverage";
11+
12+
dotenvConfig();
13+
14+
// Ensure that we have all the environment variables we need.
15+
const mnemonic = process.env.MNEMONIC as string;
16+
const mainnetUrl = process.env.MAINNET_URL as string;
17+
18+
const chainIds = {
19+
hardhat: 1337,
20+
mainnet: 1,
21+
"polygon-mainnet": 137,
22+
rinkeby: 4,
23+
};
24+
25+
function getRemappings() {
26+
return fs
27+
.readFileSync("remappings.txt", "utf8")
28+
.split("\n")
29+
.map((line) => line.trim().split("="));
30+
}
31+
32+
const config: HardhatUserConfig = {
33+
defaultNetwork: "hardhat",
34+
gasReporter: {
35+
currency: "USD",
36+
enabled: true,
37+
excludeContracts: [],
38+
src: "./contracts",
39+
},
40+
networks: {
41+
hardhat: {
42+
gas: "auto",
43+
accounts: {
44+
mnemonic,
45+
},
46+
chainId: chainIds.hardhat,
47+
// forking: {
48+
// url: mainnetUrl,
49+
// blockNumber: Number.parseInt(process.env.DEFAULT_FORK_BLOCK as string),
50+
// },
51+
},
52+
// mainnet: {
53+
// accounts: [process.env.PRIVATE_KEY as string],
54+
// chainId: chainIds.mainnet,
55+
// url: mainnetUrl,
56+
// },
57+
// "polygon-mainnet": {
58+
// accounts: [process.env.PRIVATE_KEY as string],
59+
// chainId: chainIds["polygon-mainnet"],
60+
// url: process.env.POLYGON_MAINNET_URL,
61+
// timeout: 100000,
62+
// },
63+
// rinkeby: {
64+
// accounts: {
65+
// mnemonic
66+
// },
67+
// chainId: chainIds.rinkeby,
68+
// url: process.env.RINKEBY_URL,
69+
// },
70+
},
71+
paths: {
72+
artifacts: "./artifacts",
73+
cache: "./cache",
74+
sources: "./src",
75+
tests: "./src/test",
76+
},
77+
solidity: {
78+
compilers: [
79+
{
80+
version: "0.8.15",
81+
settings: {
82+
// viaIR: true,
83+
metadata: {
84+
// Not including the metadata hash
85+
// https://github.com/paulrberg/solidity-template/issues/31
86+
bytecodeHash: "none",
87+
},
88+
// Disable the optimizer when debugging
89+
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
90+
optimizer: {
91+
enabled: true,
92+
runs: 200,
93+
},
94+
},
95+
},
96+
],
97+
},
98+
typechain: {
99+
outDir: "./typechain/types",
100+
target: "ethers-v5",
101+
},
102+
preprocess: {
103+
eachLine: (hre) => ({
104+
transform: (line: string) => {
105+
if (line.match(/^\s*import /i)) {
106+
getRemappings().forEach(([find, replace]) => {
107+
if (line.match('"' + find)) {
108+
line = line.replace('"' + find, '"' + replace);
109+
}
110+
});
111+
}
112+
return line;
113+
},
114+
}),
115+
},
116+
};
117+
118+
export default config;

lib/ds-test

Submodule ds-test added at 9310e87

lib/forge-std

Submodule forge-std added at 2c7cbfc

0 commit comments

Comments
 (0)