"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const getContract_1 = require("./solidity/getContract");
const Contracts_1 = require("../Contracts");
exports.getFundComponents = (environment, hubAddress) => __awaiter(this, void 0, void 0, function* () {
    let components = {};
    components.hub = yield getContract_1.getContract(environment, Contracts_1.Contracts.Hub, hubAddress);
    const routes = yield components.hub.methods.routes().call();
    components = Object.assign(components, {
        accounting: yield getContract_1.getContract(environment, Contracts_1.Contracts.Accounting, routes.accounting),
        engine: yield getContract_1.getContract(environment, Contracts_1.Contracts.Engine, routes.engine),
        feeManager: yield getContract_1.getContract(environment, Contracts_1.Contracts.FeeManager, routes.feeManager),
        participation: yield getContract_1.getContract(environment, Contracts_1.Contracts.Participation, routes.participation),
        policyManager: yield getContract_1.getContract(environment, Contracts_1.Contracts.PolicyManager, routes.policyManager),
        priceSource: yield getContract_1.getContract(environment, Contracts_1.Contracts.PriceSourceInterface, routes.priceSource),
        registry: yield getContract_1.getContract(environment, Contracts_1.Contracts.Registry, routes.registry),
        shares: yield getContract_1.getContract(environment, Contracts_1.Contracts.Shares, routes.shares),
        trading: yield getContract_1.getContract(environment, Contracts_1.Contracts.Trading, routes.trading),
        vault: yield getContract_1.getContract(environment, Contracts_1.Contracts.Vault, routes.vault),
        version: yield getContract_1.getContract(environment, Contracts_1.Contracts.Version, routes.version),
    });
    return components;
});
