"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("@pcd/util");
const logger_1 = require("../../../ts/logger");
const constants_1 = require("../../helpers/constants");
const ContractStorage_1 = require("../../helpers/ContractStorage");
const Deployment_1 = require("../../helpers/Deployment");
const types_1 = require("../../helpers/types");
const deployment = Deployment_1.Deployment.getInstance();
const storage = ContractStorage_1.ContractStorage.getInstance();
/**
 * Deploy step registration and task itself
 */
deployment.deployTask(constants_1.EDeploySteps.PollPolicy, "Deploy Poll policies").then((task) => task.setAction(async ({ incremental }, hre) => {
    deployment.setHre(hre);
    const deployer = await deployment.getDeployer();
    const { deployFreeForAllSignUpPolicy, deployZupassSignUpPolicy, deployEASSignUpPolicy, deployGitcoinPassportPolicy, deployMerkleProofPolicy, deploySemaphoreSignupPolicy, deployHatsSignupPolicy, getDeployedPolicyProxyFactories, deployERC20VotesPolicy, deployERC20Policy, } = await Promise.resolve().then(() => __importStar(require("../../../ts/deploy")));
    const maciContract = await deployment.getContract({ name: types_1.EContracts.MACI });
    const pollId = await maciContract.nextPollId();
    const freeForAllPolicyContractAddress = storage.getAddress(types_1.EPolicies.FreeForAll, hre.network.name, `poll-${pollId}`);
    const easPolicyContractAddress = storage.getAddress(types_1.EPolicies.EAS, hre.network.name, `poll-${pollId}`);
    const hatsPolicyContractAddress = storage.getAddress(types_1.EPolicies.Hats, hre.network.name, `poll-${pollId}`);
    const gitcoinPolicyContractAddress = storage.getAddress(types_1.EPolicies.GitcoinPassport, hre.network.name, `poll-${pollId}`);
    const zupassPolicyContractAddress = storage.getAddress(types_1.EPolicies.Zupass, hre.network.name, `poll-${pollId}`);
    const semaphorePolicyContractAddress = storage.getAddress(types_1.EPolicies.Semaphore, hre.network.name, `poll-${pollId}`);
    const merkleProofPolicyContractAddress = storage.getAddress(types_1.EPolicies.MerkleProof, hre.network.name, `poll-${pollId}`);
    const erc20VotesPolicyContractAddress = storage.getAddress(types_1.EPolicies.ERC20Votes, hre.network.name, `poll-${pollId}`);
    const erc20PolicyContractAddress = storage.getAddress(types_1.EPolicies.ERC20, hre.network.name, `poll-${pollId}`);
    const policyToDeploy = deployment.getDeployConfigField(types_1.EContracts.Poll, "policy") || types_1.EContracts.FreeForAllPolicy;
    const skipDeployFreeForAllPolicy = policyToDeploy !== types_1.EContracts.FreeForAllPolicy;
    const skipDeployEASPolicy = policyToDeploy !== types_1.EContracts.EASPolicy;
    const skipDeployGitcoinPolicy = policyToDeploy !== types_1.EContracts.GitcoinPassportPolicy;
    const skipDeployZupassPolicy = policyToDeploy !== types_1.EContracts.ZupassPolicy;
    const skipDeploySemaphorePolicy = policyToDeploy !== types_1.EContracts.SemaphorePolicy;
    const skipDeployHatsPolicy = policyToDeploy !== types_1.EContracts.HatsPolicy;
    const skipDeployMerkleProofPolicy = policyToDeploy !== types_1.EContracts.MerkleProofPolicy;
    const skipDeployERC20VotesPolicy = policyToDeploy !== types_1.EContracts.ERC20VotesPolicy;
    const skipDeployERC20Policy = policyToDeploy !== types_1.EContracts.ERC20Policy;
    const hasPolicyAddress = [
        freeForAllPolicyContractAddress,
        easPolicyContractAddress,
        gitcoinPolicyContractAddress,
        zupassPolicyContractAddress,
        semaphorePolicyContractAddress,
        hatsPolicyContractAddress,
        merkleProofPolicyContractAddress,
        erc20VotesPolicyContractAddress,
        erc20PolicyContractAddress,
    ].some(Boolean);
    const isSkippable = [
        skipDeployFreeForAllPolicy,
        skipDeployEASPolicy,
        skipDeployGitcoinPolicy,
        skipDeployZupassPolicy,
        skipDeploySemaphorePolicy,
        skipDeployHatsPolicy,
        skipDeployMerkleProofPolicy,
        skipDeployERC20VotesPolicy,
        skipDeployERC20Policy,
    ].some((skip) => !skip);
    const canSkipDeploy = incremental && hasPolicyAddress && isSkippable;
    if (canSkipDeploy) {
        // eslint-disable-next-line no-console
        (0, logger_1.logGreen)({ text: (0, logger_1.info)(`Skipping deployment of the Policy contract`) });
        return;
    }
    if (!skipDeployFreeForAllPolicy) {
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.FreeForAll,
            checker: types_1.ECheckerFactories.FreeForAll,
            network: hre.network.name,
            signer: deployer,
        });
        const [freeForAllPolicyContract, freeForAllCheckerContract, freeForAllPolicyFactoryContract, freeForAllCheckerFactoryContract,] = await deployFreeForAllSignUpPolicy(factories, deployer);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            freeForAllPolicyFactoryContract.IMPLEMENTATION(),
            freeForAllCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.FreeForAll,
                key: `poll-${pollId}`,
                name: types_1.EPolicies.FreeForAll,
                implementation: policyContractImplementation,
                contract: freeForAllPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.FreeForAll,
                name: types_1.ECheckers.FreeForAll,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: freeForAllCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.FreeForAll,
                name: types_1.EPolicyFactories.FreeForAll,
                key: `poll-${pollId}`,
                contract: freeForAllPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.FreeForAll,
                name: types_1.ECheckerFactories.FreeForAll,
                key: `poll-${pollId}`,
                contract: freeForAllCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    const isSupportedEASPolicyNetwork = ![constants_1.ESupportedChains.Hardhat, constants_1.ESupportedChains.Coverage].includes(hre.network.name);
    if (!skipDeployEASPolicy && isSupportedEASPolicyNetwork) {
        const easAddress = deployment.getDeployConfigField(types_1.EContracts.EASPolicy, "easAddress", true);
        const encodedSchema = deployment.getDeployConfigField(types_1.EContracts.EASPolicy, "schema", true);
        const attester = deployment.getDeployConfigField(types_1.EContracts.EASPolicy, "attester", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.EAS,
            checker: types_1.ECheckerFactories.EAS,
            network: hre.network.name,
            signer: deployer,
        });
        const [easPolicyContract, easCheckerContract, easPolicyFactoryContract, easCheckerFactoryContract] = await deployEASSignUpPolicy({
            eas: easAddress,
            attester,
            schema: encodedSchema,
        }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            easPolicyFactoryContract.IMPLEMENTATION(),
            easCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.EAS,
                name: types_1.EPolicies.EAS,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: easPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.EAS,
                name: types_1.ECheckers.EAS,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: easCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.EAS,
                name: types_1.EPolicyFactories.EAS,
                key: `poll-${pollId}`,
                contract: easPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.EAS,
                name: types_1.ECheckerFactories.EAS,
                key: `poll-${pollId}`,
                contract: easCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    const isSupportedGitcoinPolicyNetwork = ![
        constants_1.ESupportedChains.Hardhat,
        constants_1.ESupportedChains.Coverage,
        constants_1.ESupportedChains.Sepolia,
        constants_1.ESupportedChains.Mainnet,
    ].includes(hre.network.name);
    if (!skipDeployGitcoinPolicy && isSupportedGitcoinPolicyNetwork) {
        const gitcoinPolicyDecoderAddress = deployment.getDeployConfigField(types_1.EContracts.GitcoinPassportPolicy, "decoderAddress", true);
        const gitcoinPolicyPassingScore = deployment.getDeployConfigField(types_1.EContracts.GitcoinPassportPolicy, "passingScore", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.GitcoinPassport,
            checker: types_1.ECheckerFactories.GitcoinPassport,
            network: hre.network.name,
            signer: deployer,
        });
        const [gitcoinPolicyContract, gitcoinCheckerContract, gitcoinPolicyFactoryContract, gitcoinCheckerFactoryContract,] = await deployGitcoinPassportPolicy({
            decoderAddress: gitcoinPolicyDecoderAddress,
            minimumScore: gitcoinPolicyPassingScore,
        }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            gitcoinPolicyFactoryContract.IMPLEMENTATION(),
            gitcoinCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.GitcoinPassport,
                name: types_1.EPolicies.GitcoinPassport,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: gitcoinPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.GitcoinPassport,
                name: types_1.ECheckers.GitcoinPassport,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: gitcoinCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.GitcoinPassport,
                name: types_1.EPolicyFactories.GitcoinPassport,
                key: `poll-${pollId}`,
                contract: gitcoinPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.GitcoinPassport,
                name: types_1.ECheckerFactories.GitcoinPassport,
                key: `poll-${pollId}`,
                contract: gitcoinCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeployZupassPolicy) {
        const eventId = deployment.getDeployConfigField(types_1.EContracts.ZupassPolicy, "eventId", true);
        const validEventId = (0, util_1.uuidToBigInt)(eventId);
        const signer1 = deployment.getDeployConfigField(types_1.EContracts.ZupassPolicy, "signer1", true);
        const validSigner1 = (0, util_1.hexToBigInt)(signer1);
        const signer2 = deployment.getDeployConfigField(types_1.EContracts.ZupassPolicy, "signer2", true);
        const validSigner2 = (0, util_1.hexToBigInt)(signer2);
        let verifier = deployment.getDeployConfigField(types_1.EContracts.ZupassPolicy, "zupassVerifier");
        if (!verifier) {
            const verifierContract = await deployment.deployContract({
                name: types_1.EContracts.ZupassGroth16Verifier,
                signer: deployer,
            });
            verifier = await verifierContract.getAddress();
        }
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.Zupass,
            checker: types_1.ECheckerFactories.Zupass,
            network: hre.network.name,
            signer: deployer,
        });
        const [zupassPolicyContract, zupassCheckerContract, zupassPolicyFactoryContract, zupassCheckerFactoryContract] = await deployZupassSignUpPolicy({ eventId: validEventId, signer1: validSigner1, signer2: validSigner2, verifier }, factories, deployer);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            zupassPolicyFactoryContract.IMPLEMENTATION(),
            zupassCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.Zupass,
                name: types_1.EPolicies.Zupass,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: zupassPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.Zupass,
                name: types_1.ECheckers.Zupass,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: zupassCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.Zupass,
                name: types_1.EPolicyFactories.Zupass,
                key: `poll-${pollId}`,
                contract: zupassPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.Zupass,
                name: types_1.ECheckerFactories.Zupass,
                key: `poll-${pollId}`,
                contract: zupassCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeploySemaphorePolicy) {
        const semaphoreContractAddress = deployment.getDeployConfigField(types_1.EContracts.SemaphorePolicy, "semaphoreContract", true);
        const groupId = deployment.getDeployConfigField(types_1.EContracts.SemaphorePolicy, "groupId", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.Semaphore,
            checker: types_1.ECheckerFactories.Semaphore,
            network: hre.network.name,
            signer: deployer,
        });
        const [semaphorePolicyContract, semaphoreCheckerContract, semaphorePolicyFactoryContract, semaphoreCheckerFactoryContract,] = await deploySemaphoreSignupPolicy({ semaphore: semaphoreContractAddress, groupId }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            semaphorePolicyFactoryContract.IMPLEMENTATION(),
            semaphoreCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.Semaphore,
                name: types_1.EPolicies.Semaphore,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: semaphorePolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.Semaphore,
                name: types_1.ECheckers.Semaphore,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: semaphoreCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.Semaphore,
                name: types_1.EPolicyFactories.Semaphore,
                key: `poll-${pollId}`,
                contract: semaphorePolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.Semaphore,
                name: types_1.ECheckerFactories.Semaphore,
                key: `poll-${pollId}`,
                contract: semaphoreCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeployHatsPolicy) {
        // get args
        const criterionHats = deployment.getDeployConfigField(types_1.EContracts.HatsPolicy, "criterionHats", true);
        const hatsProtocolAddress = deployment.getDeployConfigField(types_1.EContracts.HatsPolicy, "hatsProtocolAddress", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.Hats,
            checker: types_1.ECheckerFactories.Hats,
            network: hre.network.name,
            signer: deployer,
        });
        const [hatsPolicyContract, hatsCheckerContract, hatsPolicyFactoryContract, hatsCheckerFactoryContract] = await deployHatsSignupPolicy({ hats: hatsProtocolAddress, criterionHats }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            hatsPolicyFactoryContract.IMPLEMENTATION(),
            hatsCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.Hats,
                name: types_1.EPolicies.Hats,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: hatsPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.Hats,
                name: types_1.ECheckers.Hats,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: hatsCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.Hats,
                name: types_1.EPolicyFactories.Hats,
                key: `poll-${pollId}`,
                contract: hatsPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.Hats,
                name: types_1.ECheckerFactories.Hats,
                key: `poll-${pollId}`,
                contract: hatsCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeployMerkleProofPolicy) {
        const root = deployment.getDeployConfigField(types_1.EContracts.MerkleProofPolicy, "root", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.MerkleProof,
            checker: types_1.ECheckerFactories.MerkleProof,
            network: hre.network.name,
            signer: deployer,
        });
        const [merkleProofPolicyContract, merkleProofCheckerContract, merkleProofPolicyFactoryContract, merkleProofCheckerFactoryContract,] = await deployMerkleProofPolicy({ root }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            merkleProofPolicyFactoryContract.IMPLEMENTATION(),
            merkleProofCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.MerkleProof,
                name: types_1.EPolicies.MerkleProof,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                contract: merkleProofPolicyContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.MerkleProof,
                name: types_1.ECheckers.MerkleProof,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                contract: merkleProofCheckerContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.MerkleProof,
                name: types_1.EPolicyFactories.MerkleProof,
                key: `poll-${pollId}`,
                contract: merkleProofPolicyFactoryContract,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.MerkleProof,
                name: types_1.ECheckerFactories.MerkleProof,
                key: `poll-${pollId}`,
                contract: merkleProofCheckerFactoryContract,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeployERC20VotesPolicy) {
        const token = deployment.getDeployConfigField(types_1.EContracts.ERC20VotesPolicy, "token", true);
        const threshold = deployment.getDeployConfigField(types_1.EContracts.ERC20VotesPolicy, "threshold", true);
        const snapshotBlock = deployment.getDeployConfigField(types_1.EContracts.ERC20VotesPolicy, "snapshotBlock", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.ERC20Votes,
            checker: types_1.ECheckerFactories.ERC20Votes,
            network: hre.network.name,
            signer: deployer,
        });
        const [erc20VotesPolicyContract, erc20VotesCheckerContract, erc20VotesPolicyFactoryContract, erc20VotesCheckerFactoryContract,] = await deployERC20VotesPolicy({
            token,
            threshold: BigInt(threshold),
            snapshotBlock: BigInt(snapshotBlock),
        }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            erc20VotesPolicyFactoryContract.IMPLEMENTATION(),
            erc20VotesCheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.ERC20Votes,
                contract: erc20VotesPolicyContract,
                name: types_1.EPolicies.ERC20Votes,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.ERC20Votes,
                contract: erc20VotesCheckerContract,
                name: types_1.ECheckers.ERC20Votes,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.ERC20Votes,
                contract: erc20VotesPolicyFactoryContract,
                name: types_1.EPolicyFactories.ERC20Votes,
                key: `poll-${pollId}`,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.ERC20Votes,
                contract: erc20VotesCheckerFactoryContract,
                name: types_1.ECheckerFactories.ERC20Votes,
                key: `poll-${pollId}`,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
    if (!skipDeployERC20Policy) {
        const token = deployment.getDeployConfigField(types_1.EContracts.ERC20Policy, "token", true);
        const threshold = deployment.getDeployConfigField(types_1.EContracts.ERC20Policy, "threshold", true);
        const factories = await getDeployedPolicyProxyFactories({
            policy: types_1.EPolicyFactories.ERC20,
            checker: types_1.ECheckerFactories.ERC20,
            network: hre.network.name,
            signer: deployer,
        });
        const [erc20PolicyContract, erc20CheckerContract, erc20PolicyFactoryContract, erc20CheckerFactoryContract] = await deployERC20Policy({
            token,
            threshold: BigInt(threshold),
        }, factories, deployer, true);
        const [policyContractImplementation, checkerContractImplementation] = await Promise.all([
            erc20PolicyFactoryContract.IMPLEMENTATION(),
            erc20CheckerFactoryContract.IMPLEMENTATION(),
        ]);
        await Promise.all([
            storage.register({
                id: types_1.EPolicies.ERC20,
                contract: erc20PolicyContract,
                name: types_1.EPolicies.ERC20,
                key: `poll-${pollId}`,
                implementation: policyContractImplementation,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckers.ERC20,
                contract: erc20CheckerContract,
                name: types_1.ECheckers.ERC20,
                key: `poll-${pollId}`,
                implementation: checkerContractImplementation,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.EPolicyFactories.ERC20,
                contract: erc20PolicyFactoryContract,
                name: types_1.EPolicyFactories.ERC20,
                key: `poll-${pollId}`,
                args: [],
                network: hre.network.name,
            }),
            storage.register({
                id: types_1.ECheckerFactories.ERC20,
                contract: erc20CheckerFactoryContract,
                name: types_1.ECheckerFactories.ERC20,
                key: `poll-${pollId}`,
                args: [],
                network: hre.network.name,
            }),
        ]);
    }
}));
//# sourceMappingURL=02-policies.js.map