forked from ensdomains/governance-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardhat.config.js
86 lines (81 loc) · 2.7 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
const { task } = require('hardhat/config');
const config = require('./config');
const { ShardedMerkleTree } = require('./src/merkle');
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require('hardhat-deploy');
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-waffle");
// Load environment variables from .env file. Suppress warnings using silent
// if this file is missing. dotenv will never modify any environment variables
// that have already been set.
// https://github.com/motdotla/dotenv
require('dotenv').config({silent: true});
real_accounts = undefined;
if(process.env.DEPLOYER_KEY) {
real_accounts = [process.env.DEPLOYER_KEY];
}
task("maketree", "Generates a merkle airdrop tree")
.addParam("file", "File to read airdrop data from")
.addOptionalParam("name", "Output filename for the airdrop", undefined)
.addOptionalParam("shardnybbles", "Number of nybbles to use for sharding", 2, types.int)
.setAction(async ({ file, name, shardnybbles }) => {
if(name === undefined) {
name = hre.network.name;
}
let airdrops;
if(hre.network.tags.test) {
shardnybbles = 1;
const signers = await ethers.getSigners();
airdrops = signers.slice(0, 20).map((signer, index) => [
signer.address,
{
past_tokens: '625000000000000000000000',
future_tokens: '625000000000000000000000',
longest_owned_name: '0x04f740db81dc36c853ab4205bddd785f46e79ccedca351fc6dfcbd8cc9a33dd6', // keccak256('test')
last_expiring_name: '0x04f740db81dc36c853ab4205bddd785f46e79ccedca351fc6dfcbd8cc9a33dd6',
balance: '1250000000000000000000000',
has_reverse_record: index % 2 == 0,
}
]);
} else {
const fs = require('fs');
airdrops = fs.readFileSync(file, {encoding: 'utf-8'}).split('\n').filter((x) => x.length > 0).map((line) => {
const data = JSON.parse(line);
const owner = data.owner;
delete data.owner;
data.balance = ethers.BigNumber.from(data.past_tokens.toString().split('.')[0]).add(ethers.BigNumber.from(data.future_tokens.toString().split('.')[0])).toString();
return [owner, data];
});
}
ShardedMerkleTree.build(
airdrops,
shardnybbles,
`airdrops/${name}`
);
}
);
module.exports = {
solidity: "0.8.7",
namedAccounts: {
deployer: {
default: 0
},
},
networks: {
hardhat: {
initialDate: config.UNLOCK_BEGIN,
tags: ["test"],
},
mainnet: {
url: "http://localhost:8545/",
chainId: 1,
accounts: real_accounts,
maxPriorityFeePerGas: 1000000000
},
tenderly: {
url: "https://rpc.tenderly.co/fork/bd704e15-7f2c-4f12-8c1a-9bedf536c336"
}
},
};