-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.mjs
35 lines (25 loc) · 1.15 KB
/
test.mjs
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
import { VRFHelper } from "./VRF-helper.mjs";
import { getParticipantsFileHash, pickAllRaffleWinners, assignRangesToUsers,pickAllRaffleWinnersForTheSecondRaffle } from "./utils.mjs";
import fs from 'fs';
import { toBigInt } from 'ethers';
import logger from './logger.mjs';
async function main() {
const snapshotHash = getParticipantsFileHash('./data/filtered_second_raffle_snapshot.json');
const ranges = assignRangesToUsers('./data/filtered_second_raffle_snapshot.json');
fs.writeFileSync('ranges_second_raffle.json',JSON.stringify(ranges));
const contract = new VRFHelper(
'https://api.avax-test.network/ext/bc/C/rpc',
'', // Be sure to keep your private key secure!
'0x9b10a7a745eDD7317c0b173D5F63Da639E25C89C',
'./contractABI.json'
);
try {
const requestId = await contract.rollDice(snapshotHash);
const result = await contract.checkRollFinalization(requestId);
logger.info(`Dice Result : ${result}`);
pickAllRaffleWinnersForTheSecondRaffle(ranges, result,'winners-test_second_raffle.json');
} catch (error) {
console.error("Error in main:", error);
}
}
main();