-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
83 lines (71 loc) · 2.42 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
import {task, HardhatUserConfig} from 'hardhat/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-ethers';
import '@typechain/hardhat';
import 'hardhat-watcher';
import * as fs from 'fs';
import * as path from 'path';
export const ownerAddress = '0xAB82910FE0a55E4Aa680DBc08bae45113566c309';
export const managerAddress = '0x1D7607a314BeD674BBd99B46469005f8Baead6cD';
task('dev', 'Main Development Task', async (args, hre) => {
const watchProm = hre.run('watch', {watcherTask: 'rebuild'});
hre.run('node');
await hre.run('compile');
await hre.run('init');
await watchProm;
});
task('init', 'Initialized the contract state, and updates address reference', async (args, hre: HardhatRuntimeEnvironment) => {
const {ethers} = hre;
hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ownerAddress],
});
const signer = ethers.provider.getSigner(ownerAddress);
const balance = await signer.getBalance();
if (balance.lt(ethers.utils.parseEther('100'))) {
const internalAccounts = await ethers.getSigners();
const internalBalance = await internalAccounts[0].getBalance();
if (internalBalance.gte(ethers.utils.parseEther('100'))) {
await internalAccounts[0].sendTransaction({to: ownerAddress, value: ethers.utils.parseEther('100')});
}
}
const lempiraFactory = await ethers.getContractFactory('LempiraCoin', signer);
const lempira = await lempiraFactory.deploy();
await lempira.addManager(managerAddress, 'manager1');
const out = {address: lempira.address};
fs.writeFileSync(path.join(__dirname, 'src', 'address.json'), JSON.stringify(out));
});
const config: HardhatUserConfig = {
solidity: '0.8.4',
networks: {
rinkeby: {
url: 'https://eth-rinkeby.alchemyapi.io/v2/PveVnhbB-ISvPOPFxkdDb9YJpdXWc3xm',
// This is a dedicated Rinkeby wallet. Don't get any ideas.
accounts: ['0xafa2bcc292857e4e4ab380511485829f2d2b4f3c947e875ef8f0a661e3bfbc52'],
},
hardhat: {
forking: {
url: 'https://eth-mainnet.alchemyapi.io/v2/V0nBEYPNRBYaZmLGh9psiWwTDwGEXlk7',
blockNumber: 13000429,
},
logging: {
omitMethods: ['eth_chainId', 'eth_blockNumber', 'eth_getFilterChanges'],
},
initialBaseFeePerGas: 0,
},
},
watcher: {
rebuild: {
tasks: ['compile', 'init'],
},
},
typechain: {
outDir: './src/types',
target: 'ethers-v5',
},
paths: {
sources: './src/contracts',
},
};
export default config;