"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MerkleDistributor = void 0;
var tslib_1 = require("tslib");
var MerkleTree_1 = require("@across-protocol/contracts/dist/utils/MerkleTree");
var ethers_1 = require("ethers");
var MerkleDistributor = (function () {
    function MerkleDistributor() {
    }
    MerkleDistributor.createMerkleDistributionProofs = function (recipients, windowIndex) {
        var merkleTree = new MerkleTree_1.MerkleTree(recipients, MerkleDistributor.createLeaf);
        var recipientsWithProofs = recipients.reduce(function (acc, recipient) {
            var _a;
            return tslib_1.__assign(tslib_1.__assign({}, acc), (_a = {}, _a[recipient.account] = tslib_1.__assign(tslib_1.__assign({}, recipient), { proof: merkleTree.getHexProof(recipient), windowIndex: windowIndex }), _a));
        }, {});
        return { recipientsWithProofs: recipientsWithProofs, merkleRoot: merkleTree.getHexRoot() };
    };
    MerkleDistributor.createLeaf = function (recipient) {
        var account = recipient.account, amount = recipient.amount, accountIndex = recipient.accountIndex;
        return ethers_1.ethers.utils.solidityKeccak256(["address", "uint256", "uint256"], [account, amount, accountIndex]);
    };
    return MerkleDistributor;
}());
exports.MerkleDistributor = MerkleDistributor;
//# sourceMappingURL=MerkleDistributor.js.map