import { encodeRaiseDispute, encodeDecideDispute, encodeEscalateDispute, encodeExpireDispute, encodeExpireDisputeBatch, encodeExpireEscalatedDispute, encodeExtendDisputeTimeout, encodeRefuseEscalatedDispute, encodeResolveDispute, encodeRetractDispute } from "./interface";
import { prepareDataSignatureParameters } from "../utils/signature";
// Implementation
export async function raiseDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeRaiseDispute(args)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function retractDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeRetractDispute(args.exchangeId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function extendDisputeTimeout(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeExtendDisputeTimeout(args)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function expireDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeExpireDispute(args.exchangeId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function expireDisputeBatch(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeExpireDisputeBatch(args.exchangeIds)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function resolveDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeResolveDispute(args)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function escalateDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeEscalateDispute(args.exchangeId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function decideDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeDecideDispute(args)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function refuseEscalatedDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeRefuseEscalatedDispute(args.exchangeId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
// Implementation
export async function expireEscalatedDispute(args) {
    const transactionRequest = {
        to: args.contractAddress,
        data: encodeExpireEscalatedDispute(args.exchangeId)
    };
    if (args.returnTxInfo) {
        return transactionRequest;
    }
    else {
        return args.web3Lib.sendTransaction(transactionRequest);
    }
}
export async function signResolutionProposal(args) {
    const customSignatureType = {
        Resolution: [
            { name: "exchangeId", type: "uint256" },
            { name: "buyerPercentBasisPoints", type: "uint256" }
        ]
    };
    const message = {
        exchangeId: args.exchangeId.toString(),
        buyerPercentBasisPoints: args.buyerPercentBasisPoints.toString()
    };
    const signatureArgs = {
        message,
        customSignatureType,
        web3Lib: args.web3Lib,
        verifyingContractAddress: args.contractAddress,
        chainId: args.chainId,
        primaryType: "Resolution"
    };
    if (args.returnTypedDataToSign) {
        return prepareDataSignatureParameters({
            ...signatureArgs,
            returnTypedDataToSign: true
        });
    }
    else {
        return prepareDataSignatureParameters({
            ...signatureArgs,
            returnTypedDataToSign: false
        });
    }
}
//# sourceMappingURL=handler.js.map