"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountsMixin = void 0;
const base_core_sdk_1 = require("./../mixins/base-core-sdk");
const accounts = __importStar(require("."));
const erc721 = __importStar(require("../erc721"));
const common_1 = require("@bosonprotocol/common");
const bignumber_1 = require("@ethersproject/bignumber");
const constants_1 = require("@ethersproject/constants");
const __1 = require("..");
const logs_1 = require("../utils/logs");
class AccountsMixin extends base_core_sdk_1.BaseCoreSDK {
    /* -------------------------------------------------------------------------- */
    /*                           Account related methods                          */
    /* -------------------------------------------------------------------------- */
    /* --------------------------------- Seller --------------------------------- */
    /**
     * Returns seller entity from subgraph.
     * @param sellerId - ID of seller entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entity from subgraph.
     */
    getSellerById(sellerId, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getSellerById(this._subgraphUrl, sellerId, queryVars);
        });
    }
    /**
     * Returns seller entity from subgraph.
     * @param assistant - Assistant address of seller entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entity from subgraph.
     */
    getSellerByAssistant(assistant, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getSellerByAssistant(this._subgraphUrl, assistant, queryVars);
        });
    }
    /**
     * Returns seller entity from subgraph.
     * @param admin - Admin address of seller entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entity from subgraph.
     */
    getSellerByAdmin(admin, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getSellerByAdmin(this._subgraphUrl, admin, queryVars);
        });
    }
    /**
     * Returns seller entities from subgraph.
     * @param treasury - Treasury address of seller entities to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entities from subgraph.
     */
    getSellersByTreasury(treasury, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getSellersByTreasury(this._subgraphUrl, treasury, queryVars);
        });
    }
    /**
     * Returns seller entity from subgraph. Matches `assistant`, `clerk`, `admin` or `treasury`.
     * @param address - Address of seller entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entity from subgraph.
     */
    getSellersByAddress(address, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a;
            if (address === constants_1.AddressZero) {
                throw new Error(`Unsupported search address '${constants_1.AddressZero}'`);
            }
            let seller = yield accounts.subgraph.getSellerByAddress(this._subgraphUrl, address, queryVars);
            if (!seller && ((_a = this._lens) === null || _a === void 0 ? void 0 : _a.LENS_HUB_CONTRACT)) {
                // If seller is not found per address, try to find per authToken
                const tokenType = common_1.AuthTokenType.LENS; // only LENS for now
                const sellerId = yield this.searchSellerFromAuthToken(address, tokenType);
                seller = sellerId
                    ? yield accounts.subgraph.getSellerById(this._subgraphUrl, sellerId, queryVars)
                    : null;
            }
            return [seller].filter((seller) => !!seller);
        });
    }
    /**
     * Returns the seller id found in the subgraph, if any, based on an authTokenId owned by the specified address
     * @param address - Address of seller entity to query for.
     * @param tokenType - type of authToken to look for.
     * @returns sellerId if found
     */
    searchSellerFromAuthToken(address, tokenType) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c;
            if (tokenType !== common_1.AuthTokenType.LENS) {
                // only LENS for now
                throw new Error(`Unsupported authTokenType '${tokenType}'`);
            }
            if (!this._lens || !((_a = this._lens) === null || _a === void 0 ? void 0 : _a.LENS_HUB_CONTRACT)) {
                throw new Error("LENS contract is not configured in Core-SDK");
            }
            const balance = yield erc721.handler.balanceOf({
                contractAddress: (_b = this._lens) === null || _b === void 0 ? void 0 : _b.LENS_HUB_CONTRACT,
                owner: address,
                web3Lib: this._web3Lib
            });
            const balanceBN = bignumber_1.BigNumber.from(balance);
            // If balanceBN is > 0, fetch all LENS authTokenId from the subgraph and check owner for each of them
            if (balanceBN.gt(0)) {
                const authTokenIdSellers = yield accounts.subgraph.getAuthTokenIds(this._subgraphUrl, {
                    authTokenType: common_1.AuthTokenType.LENS
                });
                for (const seller of authTokenIdSellers) {
                    const owner = yield erc721.handler.ownerOf({
                        contractAddress: (_c = this._lens) === null || _c === void 0 ? void 0 : _c.LENS_HUB_CONTRACT,
                        tokenId: seller.authTokenId,
                        web3Lib: this._web3Lib
                    });
                    if (owner.toLowerCase() === address.toLowerCase()) {
                        return seller.id;
                    }
                }
            }
            return;
        });
    }
    /**
     * Returns seller entity from subgraph that owns the given auth token (if any).
     * @param tokenId - tokenId of the Auth Token.
     * @param tokenType - Type of the Auth Token (1 for LENS, ...).
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entity from subgraph.
     */
    getSellerByAuthToken(tokenId, tokenType, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            if (tokenType !== common_1.AuthTokenType.LENS) {
                // only LENS for now
                throw new Error(`Unsupported authTokenType '${tokenType}'`);
            }
            return accounts.subgraph.getSellerByAuthToken(this._subgraphUrl, tokenId, tokenType, queryVars);
        });
    }
    /**
     * Returns seller entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Seller entities from subgraph.
     */
    getSellers(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getSellers(this._subgraphUrl, queryVars);
        });
    }
    // Implementation
    createSeller(sellerToCreate_1) {
        return __awaiter(this, arguments, void 0, function* (sellerToCreate, overrides = {}) {
            const { returnTxInfo } = overrides;
            const sellerArgs = {
                sellerToCreate,
                web3Lib: this._web3Lib,
                theGraphStorage: this._theGraphStorage,
                metadataStorage: this._metadataStorage,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.createSeller(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.createSeller(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    createSellerAndOffer(sellerToCreate_1, offerToCreate_1) {
        return __awaiter(this, arguments, void 0, function* (sellerToCreate, offerToCreate, overrides = {}) {
            const { returnTxInfo } = overrides;
            const orchestrationArgs = {
                sellerToCreate,
                offerToCreate,
                web3Lib: this._web3Lib,
                theGraphStorage: this._theGraphStorage,
                metadataStorage: this._metadataStorage,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return __1.orchestration.handler.createOfferAndSeller(Object.assign(Object.assign({}, orchestrationArgs), { returnTxInfo: true }));
            }
            else {
                return __1.orchestration.handler.createOfferAndSeller(Object.assign(Object.assign({}, orchestrationArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    updateSeller(sellerUpdates_1) {
        return __awaiter(this, arguments, void 0, function* (sellerUpdates, overrides = {}) {
            const { returnTxInfo } = overrides;
            const sellerArgs = {
                sellerUpdates,
                web3Lib: this._web3Lib,
                theGraphStorage: this._theGraphStorage,
                metadataStorage: this._metadataStorage,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.updateSeller(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.updateSeller(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    optInToSellerUpdate(sellerUpdates_1) {
        return __awaiter(this, arguments, void 0, function* (sellerUpdates, overrides = {}) {
            const { returnTxInfo } = overrides;
            const sellerArgs = {
                sellerUpdates,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.optInToSellerUpdate(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.optInToSellerUpdate(Object.assign(Object.assign({}, sellerArgs), { returnTxInfo: false }));
            }
        });
    }
    /**
     * Updates seller account by calling the `AccountHandlerFacet` contract,
     * then optIn for all updates doable by the same account. Only callable
     * by admin.
     * @param sellerUpdates - Values to update.
     * @param overrides - Optional overrides.
     * @returns Transaction response.
     */
    updateSellerAndOptIn(sellerUpdates_1) {
        return __awaiter(this, arguments, void 0, function* (sellerUpdates, overrides = {}) {
            var _a, _b;
            const updateTx = yield this.updateSeller(sellerUpdates, Object.assign(Object.assign({}, overrides), { returnTxInfo: false }));
            const txReceipt = yield updateTx.wait();
            const pendingSellerUpdate = this.getPendingSellerUpdateFromLogs(txReceipt.logs);
            // Find all updates that can be opted in by the current account
            const currentAccount = (yield this._web3Lib.getSignerAddress()).toLowerCase();
            const fieldsToUpdate = {
                assistant: currentAccount === ((_a = pendingSellerUpdate.assistant) === null || _a === void 0 ? void 0 : _a.toLowerCase()),
                admin: currentAccount === ((_b = pendingSellerUpdate.admin) === null || _b === void 0 ? void 0 : _b.toLowerCase()),
                authToken: pendingSellerUpdate.tokenType !== undefined &&
                    pendingSellerUpdate.tokenType !== null &&
                    pendingSellerUpdate.tokenType !== common_1.AuthTokenType.NONE
            };
            if (fieldsToUpdate.assistant ||
                fieldsToUpdate.admin ||
                fieldsToUpdate.authToken) {
                return this.optInToSellerUpdate({
                    id: sellerUpdates.id,
                    fieldsToUpdate: {
                        assistant: currentAccount === pendingSellerUpdate.assistant.toLowerCase(),
                        admin: currentAccount === pendingSellerUpdate.admin.toLowerCase(),
                        authToken: pendingSellerUpdate.tokenType !== common_1.AuthTokenType.NONE
                    }
                });
            }
            // If there is nothing to optIn from the current account, then return the response from updateSeller
            return updateTx;
        });
    }
    /* ---------------------------------- Buyer --------------------------------- */
    /**
     * Returns buyer entity from subgraph.
     * @param buyerId - ID of buyer entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Buyer entity from subgraph.
     */
    getBuyerById(buyerId, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getBuyerById(this._subgraphUrl, buyerId, queryVars);
        });
    }
    /**
     * Returns buyer entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Buyer entities from subgraph.
     */
    getBuyers(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getBuyers(this._subgraphUrl, queryVars);
        });
    }
    // Implementation
    createBuyer(buyerToCreate_1) {
        return __awaiter(this, arguments, void 0, function* (buyerToCreate, overrides = {}) {
            const { returnTxInfo } = overrides;
            const buyerArgs = {
                buyerToCreate,
                web3Lib: this._web3Lib,
                theGraphStorage: this._theGraphStorage,
                metadataStorage: this._metadataStorage,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.createBuyer(Object.assign(Object.assign({}, buyerArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.createBuyer(Object.assign(Object.assign({}, buyerArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    createDisputeResolver(disputeResolverToCreate_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverToCreate, overrides = {}) {
            const { returnTxInfo } = overrides;
            const disputeArgs = {
                disputeResolverToCreate,
                contractAddress: overrides.contractAddress || this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.createDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.createDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: false }));
            }
        });
    }
    /**
     * Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer`.
     * @param logs - Logs to search in.
     * @returns Created exchange id.
     */
    getDisputeResolverIdFromLogs(logs) {
        return (0, logs_1.getValueFromLogs)({
            iface: accounts.iface.bosonAccountHandlerIface,
            logs,
            eventArgsKey: "disputeResolverId",
            eventName: "DisputeResolverCreated"
        });
    }
    /**
     * Utility method to retrieve the pending seller update fields from logs after calling `updateSeller`.
     * @param logs - Logs to search in.
     * @returns Created exchange id.
     */
    getPendingSellerUpdateFromLogs(logs) {
        var _a, _b, _c;
        // Extract fields pendingSeller and pendingAuthToken from
        // SellerUpdatePending or SellerUpdateApplied events
        const valuesFromLogs = (0, logs_1.getValuesFromLogsExt)({
            iface: accounts.iface.bosonAccountHandlerIface,
            logs,
            eventArgsKeys: ["pendingSeller", "pendingAuthToken", "sellerId"],
            eventNames: ["SellerUpdatePending", "SellerUpdateApplied"]
        });
        const pendingSellerStruct = (_a = valuesFromLogs["pendingSeller"]) === null || _a === void 0 ? void 0 : _a[0];
        const pendingAuthTokenStruct = (_b = valuesFromLogs["pendingAuthToken"]) === null || _b === void 0 ? void 0 : _b[0];
        const sellerId = (_c = valuesFromLogs["sellerId"]) === null || _c === void 0 ? void 0 : _c[0];
        return {
            sellerId,
            assistant: pendingSellerStruct === null || pendingSellerStruct === void 0 ? void 0 : pendingSellerStruct.assistant,
            admin: pendingSellerStruct === null || pendingSellerStruct === void 0 ? void 0 : pendingSellerStruct.admin,
            clerk: pendingSellerStruct === null || pendingSellerStruct === void 0 ? void 0 : pendingSellerStruct.clerk,
            tokenId: pendingAuthTokenStruct === null || pendingAuthTokenStruct === void 0 ? void 0 : pendingAuthTokenStruct.tokenId,
            tokenType: pendingAuthTokenStruct === null || pendingAuthTokenStruct === void 0 ? void 0 : pendingAuthTokenStruct.tokenType
        };
    }
    // Implementation
    updateDisputeResolver(disputeResolverId_1, updates_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverId, updates, overrides = {}) {
            const { returnTxInfo } = overrides;
            const disputeArgs = {
                disputeResolverId,
                updates,
                subgraphUrl: this._subgraphUrl,
                contractAddress: overrides.contractAddress || this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.updateDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.updateDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    optInToDisputeResolverUpdate(disputeResolverUpdates_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverUpdates, overrides = {}) {
            const { returnTxInfo } = overrides;
            const disputeArgs = {
                disputeResolverUpdates,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.optInToDisputeResolverUpdate(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.optInToDisputeResolverUpdate(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    addFeesToDisputeResolver(disputeResolverId_1, fees_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverId, fees, overrides = {}) {
            const { returnTxInfo } = overrides;
            const disputeArgs = {
                disputeResolverId,
                fees,
                contractAddress: overrides.contractAddress || this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.addFeesToDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.addFeesToDisputeResolver(Object.assign(Object.assign({}, disputeArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    addSellersToDisputeResolverAllowList(disputeResolverId_1, sellerAllowList_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverId, sellerAllowList, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                disputeResolverId,
                sellerAllowList,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.addSellersToAllowList(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.addSellersToAllowList(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    removeFeesFromDisputeResolver(disputeResolverId_1, feeTokenAddresses_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverId, feeTokenAddresses, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                disputeResolverId,
                feeTokenAddresses,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.removeFeesFromDisputeResolver(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.removeFeesFromDisputeResolver(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    removeSellersFromDisputeResolverAllowList(disputeResolverId_1, sellerAllowList_1) {
        return __awaiter(this, arguments, void 0, function* (disputeResolverId, sellerAllowList, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                disputeResolverId,
                sellerAllowList,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return accounts.handler.removeSellersFromAllowList(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.removeSellersFromAllowList(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    /**
     * Returns dispute resolver entity from subgraph.
     * @param disputeResolverId - ID of dispute resolver entity to query for.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Dispute resolver entity from subgraph.
     */
    getDisputeResolverById(disputeResolverId, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getDisputeResolverById(this._subgraphUrl, disputeResolverId, queryVars);
        });
    }
    /**
     * Returns dispute resolver entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Dispute resolver entities from subgraph.
     */
    getDisputeResolvers(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getDisputeResolvers(this._subgraphUrl, queryVars);
        });
    }
    createNewCollection(collectionToCreate_1) {
        return __awaiter(this, arguments, void 0, function* (collectionToCreate, overrides = {}) {
            const { returnTxInfo } = overrides;
            if (!collectionToCreate.sellerId) {
                const { id: sellerId } = yield this.getSellerByAssistant(yield this._web3Lib.getSignerAddress());
                // If the caller is not a seller, the sellerId remains undefined
                collectionToCreate.sellerId = sellerId;
            }
            const args = {
                collectionToCreate,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond,
                theGraphStorage: this._theGraphStorage,
                metadataStorage: this._metadataStorage
            };
            if (returnTxInfo === true) {
                return accounts.handler.createNewCollection(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.createNewCollection(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    getOfferCollections(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return accounts.subgraph.getOfferCollections(this._subgraphUrl, queryVars);
        });
    }
    addRoyaltyRecipients(sellerId_1, royaltyRecipients_1) {
        return __awaiter(this, arguments, void 0, function* (sellerId, royaltyRecipients, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                sellerId,
                royaltyRecipients,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.addRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.addRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    updateRoyaltyRecipients(sellerId_1, royaltyRecipientIds_1, royaltyRecipients_1) {
        return __awaiter(this, arguments, void 0, function* (sellerId, royaltyRecipientIds, royaltyRecipients, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                sellerId,
                royaltyRecipientIds,
                royaltyRecipients,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.updateRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.updateRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    removeRoyaltyRecipients(sellerId_1, royaltyRecipientIds_1) {
        return __awaiter(this, arguments, void 0, function* (sellerId, royaltyRecipientIds, overrides = {}) {
            const { returnTxInfo } = overrides;
            const args = {
                sellerId,
                royaltyRecipientIds,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return accounts.handler.removeRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: true }));
            }
            else {
                return accounts.handler.removeRoyaltyRecipients(Object.assign(Object.assign({}, args), { returnTxInfo: false }));
            }
        });
    }
    getRoyaltyRecipients(sellerId_1) {
        return __awaiter(this, arguments, void 0, function* (sellerId, overrides = {}) {
            return accounts.handler.getRoyaltyRecipients({
                sellerId,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            });
        });
    }
}
exports.AccountsMixin = AccountsMixin;
//# sourceMappingURL=mixin.js.map