import { ethers } from "./connection";
/**
 * Register an operator for sortition: mint license, bond, register,
 * fund ticket balance, and add to the ciphernode registry.
 */
export async function setupOperatorForSortition(operator, bondingRegistry, licenseToken, usdcToken, ticketToken, registry) {
    const operatorAddress = await operator.getAddress();
    await licenseToken.mintAllocation(operatorAddress, ethers.parseEther("10000"), "Test allocation");
    await usdcToken.mint(operatorAddress, ethers.parseUnits("100000", 6));
    await licenseToken
        .connect(operator)
        .approve(await bondingRegistry.getAddress(), ethers.parseEther("2000"));
    await bondingRegistry
        .connect(operator)
        .bondLicense(ethers.parseEther("1000"));
    await bondingRegistry.connect(operator).registerOperator();
    const ticketAmount = ethers.parseUnits("100", 6);
    await usdcToken
        .connect(operator)
        .approve(await ticketToken.getAddress(), ticketAmount);
    await bondingRegistry.connect(operator).addTicketBalance(ticketAmount);
    await registry.addCiphernode(operatorAddress);
}
