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());
    });
};
import { ethers } from "ethers";
import { pad0xBegin } from "../../../utils/common/utils";
import { triggerContractByContractName, viewContractByContractName } from "../../../utils/ethers/contractHelper";
/**
 * PVE Team Join
 * @param signer Ethers signer
 * @param slot Slot
 * @param tokenId Apostle token id
 * @param callback Callback
 */
export const pveTeamJoin = (landId, signer, slot, tokenId, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "join", [slot, pad0xBegin(tokenId)], callback);
};
/**
 * PVE Team Joins
 * @param signer Ethers signer
 * @param slots Slot
 * @param tokenIds Apostles token id
 * @param callback Callback
 */
export const pveTeamJoins = (landId, signer, slots, tokenIds, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "joins", [slots, tokenIds.map((tokenId) => pad0xBegin(tokenId))], callback);
};
/**
 * PVE Team Exit
 * @param signer Ethers signer
 * @param tokenId Apostle token id
 * @param callback Callback
 */
export const pveTeamExit = (landId, signer, tokenId, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "exit", [pad0xBegin(tokenId)], callback);
};
/**
 * PVE Team Exits
 * @param signer Ethers signer
 * @param tokenIds Apostles token id
 * @param callback Callback
 */
export const pveTeamExits = (landId, signer, tokenIds, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "exits", [tokenIds.map((tokenId) => pad0xBegin(tokenId))], callback);
};
/**
 * PVE Team Swap
 * @param signer Ethers signer
 * @param slot Slot
 * @param newTokenId Apostle token id
 * @param callback Callback
 */
export const pveTeamSwap = (landId, signer, slot, newTokenId, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "swap", [slot, pad0xBegin(newTokenId)], callback);
};
/**
 * PVE Team Evict (Force exit after the end of the lease period)
 * @param signer Ethers signer
 * @param tokenId Apostle token id
 * @param callback Callback
 */
export const pveTeamEvict = (landId, signer, tokenId, callback) => {
    return triggerContractByContractName(landId, signer, "pveTeam", "evict", [pad0xBegin(tokenId)], callback);
};
/**
 * PVE Team At
 * @param provider Ethers provider
 * @param user Account address
 * @param slot Slot
 * @param callback Callback
 * @returns Apostle token id or hex 0
 */
export const pveTeamAt = (landId, provider, user, slot, callback) => __awaiter(void 0, void 0, void 0, function* () {
    const results = yield viewContractByContractName(landId, provider, "pveTeam", "at", [user, slot], callback);
    return results[0].toHexString();
});
/**
 * PVE Team Exist
 * @param provider Ethers provider
 * @param user Account address
 * @param slot Slot
 * @param callback Callback
 * @returns Boolean true or false
 */
export const pveTeamExist = (landId, provider, user, slot, callback) => __awaiter(void 0, void 0, void 0, function* () {
    const results = yield viewContractByContractName(landId, provider, "pveTeam", "exist", [user, slot], callback);
    return results[0];
});
export const pveForgeBatch = (landId, signer, equipmentTypeList, rarityList, tokenContractAddressList, callback) => {
    return triggerContractByContractName(landId, signer, "pveCraft", "craft_batch", [equipmentTypeList, rarityList, tokenContractAddressList], callback, {
        gasLimit: ethers.BigNumber.from(210000).mul(equipmentTypeList.length).add(ethers.BigNumber.from(350000)),
    });
};
