"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/* tslint:disable-next-line:no-reference */
/// <reference path="../custom_typings/web3.d.ts" />
tslib_1.__exportStar(require("./avatarService"), exports);
tslib_1.__exportStar(require("./commonTypes"), exports);
tslib_1.__exportStar(require("./configService"), exports);
var wrapperService_1 = require("./wrapperService");
exports.ContractWrappers = wrapperService_1.ContractWrappers;
exports.ContractWrapperFactories = wrapperService_1.ContractWrapperFactories;
exports.ContractWrappersByType = wrapperService_1.ContractWrappersByType;
exports.ContractWrappersByAddress = wrapperService_1.ContractWrappersByAddress;
tslib_1.__exportStar(require("./wrapperService"), exports);
tslib_1.__exportStar(require("./wrappers/absoluteVote"), exports);
tslib_1.__exportStar(require("./wrappers/contributionReward"), exports);
tslib_1.__exportStar(require("./wrappers/daoCreator"), exports);
tslib_1.__exportStar(require("./wrappers/genesisProtocol"), exports);
tslib_1.__exportStar(require("./wrappers/globalConstraintRegistrar"), exports);
tslib_1.__exportStar(require("./wrappers/schemeRegistrar"), exports);
tslib_1.__exportStar(require("./wrappers/tokenCapGC"), exports);
tslib_1.__exportStar(require("./wrappers/upgradeScheme"), exports);
tslib_1.__exportStar(require("./wrappers/vestingScheme"), exports);
tslib_1.__exportStar(require("./wrappers/voteInOrganizationScheme"), exports);
tslib_1.__exportStar(require("./dao"), exports);
tslib_1.__exportStar(require("./contractWrapperBase"), exports);
tslib_1.__exportStar(require("./contractWrapperFactory"), exports);
tslib_1.__exportStar(require("./eventService"), exports);
tslib_1.__exportStar(require("./loggingService"), exports);
tslib_1.__exportStar(require("./transactionService"), exports);
tslib_1.__exportStar(require("./utils"), exports);
const configService_1 = require("./configService");
const loggingService_1 = require("./loggingService");
const utils_1 = require("./utils");
const wrapperService_2 = require("./wrapperService");
/**
 * initialize() must be called before doing anything with Arc.js.
 */
function InitializeArcJs(options) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        loggingService_1.LoggingService.info("Initializing Arc.js");
        try {
            if (options && options.useNetworkDefaultsFor) {
                const networkDefaults = configService_1.ConfigService.get("networkDefaults")[options.useNetworkDefaultsFor];
                if (!networkDefaults) {
                    throw new Error(`truffle network defaults not found: ${options.useNetworkDefaultsFor}`);
                }
                configService_1.ConfigService.set("network", options.useNetworkDefaultsFor);
                configService_1.ConfigService.set("providerPort", networkDefaults.port);
                configService_1.ConfigService.set("providerUrl", `http://${networkDefaults.host}`);
            }
            const web3 = yield utils_1.Utils.getWeb3();
            yield wrapperService_2.WrapperService.initialize(options);
            return web3;
        }
        catch (ex) {
            /* tslint:disable-next-line:no-bitwise */
            loggingService_1.LoggingService.message(`InitializeArcJs failed: ${ex}`, loggingService_1.LogLevel.info | loggingService_1.LogLevel.error);
            throw new Error(`InitializeArcJs failed: ${ex}`);
        }
    });
}
exports.InitializeArcJs = InitializeArcJs;
//# sourceMappingURL=index.js.map