-
Notifications
You must be signed in to change notification settings - Fork 12
/
hardhat.config.ts
321 lines (304 loc) · 9.31 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-ethers';
import dotenv from 'dotenv';
import 'hardhat-contract-sizer';
import 'hardhat-docgen';
import 'hardhat-watcher';
import { HardhatUserConfig, task } from 'hardhat/config';
import { HttpNetworkUserConfig } from 'hardhat/types';
import { mint, MintArgs } from './tasks/mint';
import {
AllowedTokensArgs,
allowTokens,
} from './tasks/tokenHandler/allowTokens';
import {
AllowedContractsArgs,
allowContracts,
} from './tasks/destinationContractHandler/allowContracts';
import {
changePartnerShares,
ChangePartnerSharesArg,
} from './tasks/changePartnerShares';
import { DeployArg, deploy } from './tasks/deploy';
import {
deployCollector,
DeployCollectorArg,
} from './tasks/collector/deployCollector';
import {
GetAllowedTokensArgs,
getAllowedTokens,
} from './tasks/tokenHandler/getAllowedTokens';
import { removeTokens } from './tasks/tokenHandler/removeTokens';
import { withdraw, WithdrawSharesArg } from './tasks/withdraw';
import {
addTokenToCollector,
ManageCollectorTokenArgs,
} from './tasks/collector/addToken';
import {
getCollectorTokens,
GetCollectorTokensArgs,
} from './tasks/collector/getTokens';
import { removeTokenFromCollector } from './tasks/collector/removeToken';
import {
GetAllowedContractsArgs,
getAllowedContracts,
} from './tasks/destinationContractHandler/getAllowedContracts';
import { removeContracts } from './tasks/destinationContractHandler/removeContracts';
dotenv.config();
const DEFAULT_MNEMONIC =
'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
const { PK, MNEMONIC } = process.env;
const sharedNetworkConfig: HttpNetworkUserConfig = {};
if (PK) {
sharedNetworkConfig.accounts = [PK];
} else {
sharedNetworkConfig.accounts = {
mnemonic: MNEMONIC || DEFAULT_MNEMONIC,
};
}
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.6.12',
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
outputSelection: {
'*': {
'*': ['storageLayout'],
},
},
},
},
],
},
networks: {
regtest: {
url: 'http://localhost:4444',
chainId: 33,
},
testnet: {
...sharedNetworkConfig,
url: 'https://public-node.testnet.rsk.co',
chainId: 31,
},
mainnet: {
...sharedNetworkConfig,
url: 'https://public-node.rsk.co',
chainId: 30,
},
},
typechain: {
target: 'ethers-v5',
outDir: 'typechain-types',
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: false,
},
watcher: {
compilation: {
tasks: ['compile'],
files: ['./contracts'],
verbose: true,
},
tdd: {
tasks: [
'clean',
{ command: 'compile', params: { quiet: true } },
{
command: 'test',
params: {
noCompile: true,
testFiles: ['{path}'],
},
},
],
files: ['./contracts/*.sol', './test/**/*.ts', './tasks/**/*.ts'],
verbose: true,
clearOnStart: true,
},
},
docgen: {
path: './docs',
clear: true,
runOnCompile: false,
},
mocha: {
timeout: 20000,
},
};
task(
'deploy',
'Deploys rif-relay contracts to selected network. If no flags are specified, all contracts will be deployed'
)
.addFlag(
'relayHub',
'If specified, it will deploy the relayHub and the penalizer'
)
.addFlag(
'defaultSmartWallet',
'If specified, it will deploy the default smart wallet with the factory and the verifiers (deploy, relay)'
)
.addFlag(
'customSmartWallet',
'If specified, it will deploy the custom smart wallet with the factory and the verifiers (deploy, relay)'
)
.addFlag(
'nativeHolderSmartWallet',
'If specified, it will deploy the native holder smart wallet with the factory and the verifiers (deploy, relay)'
)
.addFlag(
'utilToken',
'If specified, it will deploy an ERC20 token to be used for testing purposes; it does not deploy the token on mainnet'
)
.addFlag(
'versionRegistry',
'If specified, it will deploy the version registry'
)
.addFlag(
'boltzSmartWallet',
'If specified, it will deploy the boltz smart wallet with the factory and the verifiers (deploy, relay)'
)
.addFlag(
'minimalBoltzSmartWallet',
'If specified, it will deploy the minimal boltz smart wallet with the factory and the verifiers (deploy, relay)'
)
.setAction(async (taskArgs: DeployArg, hre) => {
await deploy(taskArgs, hre);
});
task('collector:deploy', 'Deploys the collector')
.addOptionalParam('configFileName', 'Path of the collector config file')
.addOptionalParam('outputFileName', 'Path of the output file')
.setAction(async (taskArgs: DeployCollectorArg, hre) => {
await deployCollector(taskArgs, hre);
});
task('allow-tokens', 'Allows a list of tokens')
.addParam(
'tokenList',
'list of tokens in a comma-separated format (e.g.: "address1,address2")'
)
.addOptionalParam(
'verifierList',
'list of tokens in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: AllowedTokensArgs, hre) => {
await allowTokens(taskArgs, hre);
});
task('allowed-tokens', 'Retrieves a list of allowed tokens')
.addOptionalParam(
'verifierList',
'list of tokens in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: GetAllowedTokensArgs, hre) => {
await getAllowedTokens(taskArgs, hre);
});
task('remove-tokens', 'Removes a list of tokens')
.addParam(
'tokenList',
'list of tokens in a comma-separated format (e.g.: "address1,address2")'
)
.addOptionalParam(
'verifierList',
'list of tokens in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: AllowedTokensArgs, hre) => {
await removeTokens(taskArgs, hre);
});
task('allow-contracts', 'Allows a list of contracts')
.addParam(
'contractList',
'list of contracts in a comma-separated format (e.g.: "address1,address2")'
)
.addOptionalParam(
'verifierList',
'list of contracts in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: AllowedContractsArgs, hre) => {
await allowContracts(taskArgs, hre);
});
task('allowed-contracts', 'Retrieves a list of allowed contracts')
.addOptionalParam(
'verifierList',
'list of contracts in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: GetAllowedContractsArgs, hre) => {
await getAllowedContracts(taskArgs, hre);
});
task('remove-contracts', 'Removes a list of contracts')
.addParam(
'contractList',
'list of contracts in a comma-separated format (e.g.: "address1,address2")'
)
.addOptionalParam(
'verifierList',
'list of contracts in a comma-separated format (e.g.: "address1,address2")'
)
.setAction(async (taskArgs: AllowedContractsArgs, hre) => {
await removeContracts(taskArgs, hre);
});
task('collector:withdraw', 'Withdraws funds from a collector contract')
.addParam(
'collectorAddress',
'address of the collector we want to withdraw from'
)
.addOptionalParam(
'tokenAddress',
'Token to withdraw. If undefined, all tokens will be withdrawn'
)
.addOptionalParam('gasLimit', 'gasLimit to be used for the transaction')
.setAction(async (taskArgs: WithdrawSharesArg, hre) => {
await withdraw(taskArgs, hre);
});
task(
'collector:addToken',
'Allow the collector to receive payments in additional tokens'
)
.addParam('collectorAddress', 'address of the collector contract to modify')
.addParam(
'tokenAddress',
'address of the token we want to allow in the collector'
)
.setAction(async (taskArgs: ManageCollectorTokenArgs, hre) => {
await addTokenToCollector(taskArgs, hre);
});
task('collector:getTokens', 'Retrieve tokens managed by the collector')
.addParam('collectorAddress', 'address of the collector contract to modify')
.setAction(async (taskArgs: GetCollectorTokensArgs, hre) => {
await getCollectorTokens(taskArgs, hre);
});
task(
'collector:removeToken',
'Remove a token from the ones that the collector can accept to receive payments'
)
.addParam('collectorAddress', 'address of the collector contract to modify')
.addParam(
'tokenAddress',
'address of the token we want to remove in the collector'
)
.setAction(async (taskArgs: ManageCollectorTokenArgs, hre) => {
await removeTokenFromCollector(taskArgs, hre);
});
task('collector:change-partners', 'Change collector partners')
.addParam('collectorAddress', 'address of the collector contract to modify')
.addParam(
'partnerConfig',
'path of the file that includes the partner shares configuration'
)
.addOptionalParam('gasLimit', 'gasLimit to be used for the transaction')
.setAction(async (taskArgs: ChangePartnerSharesArg, hre) => {
await changePartnerShares(taskArgs, hre);
});
task('mint', 'Mint some tokens')
.addParam('tokenAddress', 'address of the token we want to mint')
.addParam('amount', 'amount of tokens we want to mint')
.addParam('receiver', 'the address that will receive the minted tokens')
.setAction(async (taskArgs: MintArgs, hre) => {
await mint(taskArgs, hre);
});
export default config;