-
Notifications
You must be signed in to change notification settings - Fork 1
/
proof.ts
50 lines (43 loc) · 1.43 KB
/
proof.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
import { ethers, network, rigsConfig } from "hardhat";
import { buildTree, getListFromCSVs, hashEntry } from "../helpers/allowlist";
async function main() {
console.log(`\nGetting proof for '${network.name}'...`);
// Get owner account
const [account] = await ethers.getSigners();
if (account.provider === undefined) {
throw Error("missing provider");
}
// Build merkle tree for allowlist
const allowlist = await getListFromCSVs(rigsConfig.allowlistFiles);
const allowlistTree = buildTree(allowlist);
const waitlist = await getListFromCSVs(rigsConfig.waitlistFiles);
const waitlistTree = buildTree(waitlist);
// Get address
let address = process.env.PROOF_ADDRESS;
if (!address) {
throw Error("no address found for proof (use env var PROOF_ADDRESS)");
}
address = address.toLowerCase();
// Check allowlist
let allowance = allowlist[address];
if (allowance === undefined) {
console.log("Allowlist: no allowance");
} else {
const proof = allowlistTree.getHexProof(hashEntry(address, allowance));
console.log("Allowlist:", proof);
}
// Check waitlist
allowance = waitlist[address];
if (allowance === undefined) {
console.log("Waitlist: no allowance");
} else {
const proof = waitlistTree.getHexProof(hashEntry(address, allowance));
console.log("Waitlist:", proof);
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});