"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = __importDefault(require("hardhat"));
const inquirer_1 = __importDefault(require("inquirer"));
const PermissionFetcher_1 = require("./PermissionFetcher");
const config_1 = require("./config");
const network = hardhat_1.default.network.name;
(() => __awaiter(void 0, void 0, void 0, function* () {
    const params = yield inquirer_1.default.prompt([
        {
            name: "BNBFunctionSignatureFile",
            message: "Please enter path of the .json file containing contract addresses and function signatures of BNB mainnet {optional}",
            default: "scripts/ACMPermissions/networks/bscmainnet/BNBPermissions.json",
        },
        {
            name: "chunkSize",
            message: "Please enter the block chunk size for fetching the events. This is important as some RPCs fail to return logs for a large chunk of blocks",
            default: 40000,
        },
        {
            name: "startBlock",
            message: "Please enter starting block of given network from which you want the logs. Will be ignored if permissions.json is already created. Log fetching start from the previous stored block {optional}",
            default: config_1.startingBlockForACM[network],
        },
        {
            name: "endBlock",
            message: "Please enter ending block of given network till which you want the logs {optional}",
            default: "latest",
        },
    ]);
    const startingBlock = parseInt(params.startBlock, 10);
    const endingBlock = parseInt(params.endBlock, 10);
    const permissionFetcher = new PermissionFetcher_1.PermissionFetcher(network, params.BNBFunctionSignatureFile, params.chunkSize);
    yield permissionFetcher.getPastEvents(startingBlock, endingBlock);
}))();
//# sourceMappingURL=index.js.map