import { BaseCoreSDK } from "./../mixins/base-core-sdk";
import { raiseDispute, retractDispute, extendDisputeTimeout, expireDispute, expireDisputeBatch, resolveDispute, escalateDispute, decideDispute, refuseEscalatedDispute, expireEscalatedDispute, signResolutionProposal } from "./handler";
import { getDisputeById, getDisputes } from "./subgraph";
export class DisputesMixin extends BaseCoreSDK {
    /* -------------------------------------------------------------------------- */
    /*                           Dispute related methods                          */
    /* -------------------------------------------------------------------------- */
    /**
     * Returns dispute entity from subgraph.
     * @param disputeId - ID of dispute entity.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Dispute entity from subgraph.
     */
    async getDisputeById(disputeId, queryVars) {
        return getDisputeById(this._subgraphUrl, disputeId, queryVars);
    }
    /**
     * Returns dispute entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Dispute entities from subgraph.
     */
    async getDisputes(queryVars) {
        return getDisputes(this._subgraphUrl, queryVars);
    }
    async raiseDispute(exchangeId, returnTxInfo) {
        const raiseArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return raiseDispute({
                ...raiseArgs,
                returnTxInfo: true
            });
        }
        else {
            return raiseDispute({
                ...raiseArgs,
                returnTxInfo: false
            });
        }
    }
    async retractDispute(exchangeId, returnTxInfo) {
        const retractArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return retractDispute({
                ...retractArgs,
                returnTxInfo: true
            });
        }
        else {
            return retractDispute({
                ...retractArgs,
                returnTxInfo: false
            });
        }
    }
    async extendDisputeTimeout(exchangeId, newDisputeTimeout, returnTxInfo) {
        const extendArgs = {
            exchangeId,
            newDisputeTimeout,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return extendDisputeTimeout({
                ...extendArgs,
                returnTxInfo: true
            });
        }
        else {
            return extendDisputeTimeout({
                ...extendArgs,
                returnTxInfo: false
            });
        }
    }
    async expireDispute(exchangeId, returnTxInfo) {
        const expireArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return expireDispute({
                ...expireArgs,
                returnTxInfo: true
            });
        }
        else {
            return expireDispute({
                ...expireArgs,
                returnTxInfo: false
            });
        }
    }
    async expireDisputeBatch(exchangeIds, returnTxInfo) {
        const batchArgs = {
            exchangeIds,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return expireDisputeBatch({
                ...batchArgs,
                returnTxInfo: true
            });
        }
        else {
            return expireDisputeBatch({
                ...batchArgs,
                returnTxInfo: false
            });
        }
    }
    async resolveDispute(args) {
        const { returnTxInfo } = args;
        const resolveArgs = "signature" in args
            ? {
                exchangeId: args.exchangeId,
                buyerPercentBasisPoints: args.buyerPercentBasisPoints,
                signature: args.signature,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            }
            : {
                exchangeId: args.exchangeId,
                buyerPercentBasisPoints: args.buyerPercentBasisPoints,
                sigR: args.sigR,
                sigS: args.sigS,
                sigV: args.sigV,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
        if (returnTxInfo === true) {
            return resolveDispute({
                ...resolveArgs,
                returnTxInfo: true
            });
        }
        else {
            return resolveDispute({
                ...resolveArgs,
                returnTxInfo: false
            });
        }
    }
    async escalateDispute(exchangeId, returnTxInfo) {
        const escalateArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return escalateDispute({
                ...escalateArgs,
                returnTxInfo: true
            });
        }
        else {
            return escalateDispute({
                ...escalateArgs,
                returnTxInfo: false
            });
        }
    }
    async decideDispute(exchangeId, buyerPercent, returnTxInfo) {
        const decideArgs = {
            exchangeId,
            buyerPercent,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return decideDispute({
                ...decideArgs,
                returnTxInfo: true
            });
        }
        else {
            return decideDispute({
                ...decideArgs,
                returnTxInfo: false
            });
        }
    }
    async refuseEscalatedDispute(exchangeId, returnTxInfo) {
        const refuseArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return refuseEscalatedDispute({
                ...refuseArgs,
                returnTxInfo: true
            });
        }
        else {
            return refuseEscalatedDispute({
                ...refuseArgs,
                returnTxInfo: false
            });
        }
    }
    async expireEscalatedDispute(exchangeId, returnTxInfo) {
        const expireEscalatedArgs = {
            exchangeId,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return expireEscalatedDispute({
                ...expireEscalatedArgs,
                returnTxInfo: true
            });
        }
        else {
            return expireEscalatedDispute({
                ...expireEscalatedArgs,
                returnTxInfo: false
            });
        }
    }
    async signDisputeResolutionProposal(args) {
        const { returnTypedDataToSign, ...argsWithoutReturnTypedDataToSign } = args;
        const params = {
            ...argsWithoutReturnTypedDataToSign,
            web3Lib: this._web3Lib,
            contractAddress: this._protocolDiamond,
            chainId: this._chainId
        };
        if (returnTypedDataToSign === true) {
            return signResolutionProposal({
                ...params,
                returnTypedDataToSign: true
            });
        }
        else {
            return signResolutionProposal({
                ...params,
                returnTypedDataToSign: false
            });
        }
    }
}
//# sourceMappingURL=mixin.js.map