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