-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
159 lines (150 loc) · 6.23 KB
/
hardhat.config.js
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
require('dotenv').config()
require("@nomiclabs/hardhat-etherscan");
//? ~Sahil: ALL CONFIG OPTIONS IN DOCS: https://hardhat.org/hardhat-runner/docs/config
// require('@nomicfoundation/hardhat-toolbox')
// Get Assertions, Docs: https://hardhat.org/hardhat-chai-matchers/docs/overview
// require('@nomicfoundation/hardhat-chai-matchers')
require('@nomiclabs/hardhat-waffle')
// Migration Guide from "@nomicfoundation/hardhat-waffle => @nomicfoundation/hardhat-toolbox" :https://hardhat.org/hardhat-chai-matchers/docs/migrate-from-waffle
// Why migrate: https://hardhat.org/hardhat-chai-matchers/docs/migrate-from-waffle#why-migrate?
// From tutorial
// - require('@nomicfoundation/hardhat-waffle')
// + import '@nomicfoundation/hardhat-chai-matchers'
// To add capability to run tests in watch mode ~Sahil
require('hardhat-watcher')
// const fs = require('fs')
// Private key of your account you created via metamask
// const privateKeyPolygonAccount = fs.readFileSync('./p-key.txt', {
// encoding: 'utf8',
// flag: 'r',
// })
const projectId = process.env.PROJECT_ID
// This (private_key) is highly sensitive and you should get this private key from server somehow though ~ Author.
const PRIVATE_KEY = process.env.PRIVATE_KEY
const POLYGONSCAN_API_KEY = process.env.POLYGONSCAN_API_KEY
// From alchemy's "Demo App"
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: 'hardhat',
networks: {
// hardhat is like local development server.
hardhat: {
chainId: 1337, // config standard
},
//! couldn't set `polygon-mumbai` in `infura` ~Sahil
//LEARN: mumbai-testnet is live development server.
// mumbai: {
// url: `https://polygon-mumbai.infura.io/v3/add${projectId}`,
// accounts: [PRIVATE_KEY], // account from metamask
// },
//LEARN: mainnet is like production server.
mainnet: {
url: `https://mainnet.infura.io/v3/${projectId}`,
accounts: [PRIVATE_KEY], // account from metamask
},
// Learn: Deployment to polygontestnet (mumbai); source: https://docs.polygon.technology/docs/develop/hardhat#compiling-the-contract
matic: {
url: 'https://rpc-mumbai.maticvigil.com',
accounts: [PRIVATE_KEY],
},
goerli: {
url: `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [PRIVATE_KEY],
// To fix the issue - `Error: cannot estimate gas; transaction may fail or may require manual gas limit [ ...`
// Source: https://github.com/ethereum/solidity/issues/13159#issuecomment-1181803918
allowUnlimitedContractSize: true
},
},
// source: https://docs.polygon.technology/docs/develop/hardhat#compiling-the-contract
etherscan: {
// apiKey: POLYGONSCAN_API_KEY,
apiKey: ETHERSCAN_API_KEY,
},
// Adding optimizer for solidity coz its gonna simplify complicated expressions, it can reduce gas cost and a whole bunch of good stuff.
solidity: {
// version: '0.8.9', // from nft market course project
version: '0.8.16', // @latest
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
// Run it via: `npx hardhat watch compilation`
watcher: {
'learn-contracts': {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
// start: 'echo Running task now..', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
// Using Position arguments hardhat watcher: https://github.com/xanderdeseyn/hardhat-watcher#positional-arguments
tasks: [{command: 'test', params: {testFiles: ['./test/learnContracts.js']}}],
files: ['./contracts/learn-contracts', './test/learnContracts.js'],
runOnLaunch: true
},
'project-distributed-wallet': {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
tasks: [{command: 'test', params: {testFiles: ['./test/distributedWallet.js']}}],
files: ['./contracts', './test/distributedWallet.js'],
runOnLaunch: true
},
'multisig-wallet': {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
tasks: [{command: 'test', params: {testFiles: ['./test/multiSigWallet.js']}}],
files: ['./contracts/multisig-wallet/', './test/multiSigWallet.js'],
runOnLaunch: true
},
'kryptobirdz': {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
tasks: [{command: 'test', params: {testFiles: ['./test/kryptobirdz.js']}}],
files: ['./contracts', './test/kryptobirdz.js'],
runOnLaunch: true
},
dex: {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
tasks: [{command: 'test', params: {testFiles: ['./test/dex.js']}}],
files: ['./contracts/dex', './test/dex.js'],
runOnLaunch: true
},
lock: {
start: 'tmux clear-history -t $(tmux display -pt "${TMUX_PANE:?}" "#{pane_index}")', // https://github.com/sahilrajput03/flash-runner-npm/blob/main/startTesting.js#L86
clearOnStart: true,
tasks: [{command: 'test', params: {testFiles: ['./test/Lock.js']}}],
files: ['./contracts', './test/Lock.js'],
runOnLaunch: true
},
},
}
// module.exports = {
// solidity: '0.8.9',
// }
/*
LEARN ~ Sahil
COMMAND
npx hardhat test --help
# OUTPUT:
# Hardhat version 2.10.1
#
# Usage: hardhat [GLOBAL OPTIONS] test [--bail] [--grep <STRING>] [--no-compile] [--parallel] [...testFiles]
#
# OPTIONS:
#
# --bail Stop running tests after the first test failure
# --grep Only run tests matching the given string or regexp
# --no-compile Don't compile before running this task
# --parallel Run tests in parallel
#
# POSITIONAL ARGUMENTS:
#
# testFiles An optional list of files to test (default: [])
#
# test: Runs mocha tests
#
# For global options help run: hardhat help
*/