import { decodeGetAvailablePreMints, decodeGetRangeByOfferId, decodeIsApprovedForAll, decodeIsTrustedForwarder, decodeOwner, encodeBurnPremintedVouchers, encodeCallExternalContract, encodeGetAvailablePreMints, encodeGetRangeByOfferId, encodeIsApprovedForAll, encodeIsTrustedForwarder, encodeOwner, encodePreMint, encodeSetApprovalForAllToContract, encodeSetContractURI, encodeTransferFrom, encodeWithdrawToProtocol } from "./interface";
export async function burnPremintedVouchers(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeBurnPremintedVouchers(args.offerId, args.amount)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function owner(args) {
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data: encodeOwner()
    });
    return decodeOwner(result);
}
export async function isTrustedForwarder(args) {
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data: encodeIsTrustedForwarder(args.forwarder)
    });
    return decodeIsTrustedForwarder(result);
}
export async function getAvailablePreMints(args) {
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data: encodeGetAvailablePreMints(args.offerId)
    });
    const [count] = decodeGetAvailablePreMints(result);
    return String(count);
}
export async function getRangeByOfferId(args) {
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data: encodeGetRangeByOfferId(args.offerId)
    });
    const [range] = decodeGetRangeByOfferId(result);
    return {
        start: range.start,
        length: range._length,
        minted: range.minted,
        lastBurnedTokenId: range.lastBurnedTokenId
    };
}
export async function preMint(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodePreMint(args.offerId, args.amount)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function transferFrom(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeTransferFrom(args.from, args.to, args.tokenId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function isApprovedForAll(args) {
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data: encodeIsApprovedForAll(args.owner, args.operator)
    });
    const [isApproved] = decodeIsApprovedForAll(result);
    return isApproved;
}
export async function setContractURI(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeSetContractURI(args.contractURI)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function callExternalContract(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeCallExternalContract(args.to, args.data)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function setApprovalForAllToContract(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeSetApprovalForAllToContract(args.operator, args.approved)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function withdrawToProtocol(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeWithdrawToProtocol(args.tokenList)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
//# sourceMappingURL=handler.js.map