-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
124 lines (114 loc) · 3.39 KB
/
hardhat.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import "@nomicfoundation/hardhat-toolbox"
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-waffle"
import "@typechain/hardhat"
import "hardhat-deploy"
import "hardhat-gas-reporter"
import { HardhatUserConfig, task } from "hardhat/config"
import createCategory from "./scripts/createCategory"
import createComment from "./scripts/createComment"
import createPost from "./scripts/createPost"
import fetchCategories from "./scripts/fetchCategories"
import fetchComments from "./scripts/fetchComments"
import fetchPost from "./scripts/fetchPost"
import fetchPosts from "./scripts/fetchPosts"
import "dotenv/config"
task("fetchCategories", "Fetches all categories")
.addParam("address", "The address of the contract")
.setAction(async (taskArgs, hre) => {
return fetchCategories(taskArgs, hre)
})
task("createCategory", "Creates a new category")
.addParam("address", "The address of the contract")
.addParam("name", "The name of the new category")
.setAction(async (taskArgs, hre) => {
return createCategory(taskArgs, hre)
})
task("fetchPosts", "Fetches all posts")
.addParam("address", "The address of the contract")
.setAction(async (taskArgs, hre) => {
return fetchPosts(taskArgs, hre)
})
task("fetchPost", "Fetches one post")
.addParam("address", "The address of the contract")
.addOptionalParam("postid", "The postid of the post")
.addOptionalParam("hash", "The hash of the post")
.setAction(async (taskArgs, hre) => {
return fetchPost(taskArgs, hre)
})
task("createPost", "Creates a new post")
.addParam("address", "The address of the contract")
.addParam("title", "The title of the post")
.addParam("content", "The content of the post")
.addParam("categoryindex", "The index of the category the post belongs to")
.setAction(async (taskArgs, hre) => {
return createPost(taskArgs, hre)
})
task("fetchComments", "Fetches all comments")
.addParam("address", "The address of the contract")
.addParam("postid", "The postid of the post")
.setAction(async (taskArgs, hre) => {
return fetchComments(taskArgs, hre)
})
task("createComment", "Creates a new comment")
.addParam("address", "The address of the contract")
.addParam("postid", "The id of the post")
.addParam("content", "The content of the post")
.setAction(async (taskArgs, hre) => {
return createComment(taskArgs, hre)
})
const accounts =
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : []
const config: HardhatUserConfig = {
solidity: {
version: "0.8.14",
settings: {
optimizer: {
enabled: true,
runs: 20,
},
},
},
paths: { tests: "tests" },
networks: {
hardhat: {
chainId: 1337,
},
localhost: {
url: "http://localhost:8545",
chainId: 1337,
},
rinkeby: {
url: process.env.RINKEBY_URL || "",
accounts,
chainId: 4,
},
mumbai: {
url: process.env.POLYGON_MUMBAI || "",
accounts,
chainId: 80001,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS === "true",
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
mocha: {
timeout: 100000,
},
namedAccounts: {
deployer: {
default: 0,
1: 0, // use first account for mainnet (chainId 1)
},
},
typechain: {
outDir: "typechain-types",
target: "ethers-v5",
},
}
export default config