import { ethers } from "ethers";
import { pad0xBegin } from "@evo/utils/common/utils";
import { triggerContractByContractName } from "@evo/utils/ethers/contractHelper";
import type { CallbackType } from "@evo/utils/ethers/contractHelper";
import { LandId } from "@evo/config/constants";
import { TransactionResponse } from "@ethersproject/providers";
/**
* Equipment transfer
* @param landId Land Id
* @param signer Signer
* @param from Equipment owner
* @param to Recipient
* @param tokenId Equipment TokenId
* @param callback Callback
* @returns any
*/
export const equipmentTransfer = (
landId: LandId,
signer: ethers.Signer,
from: string,
to: string,
tokenId: string,
callback?: CallbackType
): Promise<TransactionResponse> => {
return triggerContractByContractName(
landId,
signer,
"objectOwnership",
"transferFrom",
[from, to, pad0xBegin(tokenId)],
callback
);
};
/**
* Divest the props on the index slot on the tokenid apostle
* @param landId Land Id
* @param signer Signer
* @param tokenId Apostle token Id
* @param index The index of slot
* @param callback Callback
* @returns any
*/
export const equipmentUnequip = (
landId: LandId,
signer: ethers.Signer,
tokenId: string,
index: number,
callback?: CallbackType
): Promise<TransactionResponse> => {
return triggerContractByContractName(
landId,
signer,
"apostleBaseV5",
"divest",
[pad0xBegin(tokenId), index],
callback
);
};