"use strict";
/**
 * @file Compound
 * @desc This file defines the constructor of the `Compound` class.
 * @hidden
 */
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 (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
const ethers_1 = require("ethers");
const eth = __importStar(require("./eth"));
const util = __importStar(require("./util"));
const comptroller = __importStar(require("./comptroller"));
const cToken = __importStar(require("./cToken"));
const priceFeed = __importStar(require("./priceFeed"));
const comp = __importStar(require("./comp"));
const gov = __importStar(require("./gov"));
const api = __importStar(require("./api"));
const constants_1 = require("./constants");
// Turn off Ethers.js warnings
// ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR)
/**
 * Creates an instance of the Compound.js SDK.
 *
 * @param {Provider | string} [provider] Optional Ethereum network provider.
 *     Defaults to Ethers.js fallback mainnet provider.
 * @param {object} [options] Optional provider options.
 *
 * @example
 * ```
 * var compound = new Compound(window.ethereum); // web browser
 *
 * var compound = new Compound('http://127.0.0.1:8545'); // HTTP provider
 *
 * var compound = new Compound(); // Uses Ethers.js fallback mainnet (for testing only)
 *
 * var compound = new Compound('ropsten'); // Uses Ethers.js fallback (for testing only)
 *
 * // Init with private key (server side)
 * var compound = new Compound('https://mainnet.infura.io/v3/_your_project_id_', {
 *   privateKey: '0x_your_private_key_', // preferably with environment variable
 * });
 *
 * // Init with HD mnemonic (server side)
 * var compound = new Compound('mainnet' {
 *   mnemonic: 'clutch captain shoe...', // preferably with environment variable
 * });
 * ```
 *
 * @returns {object} Returns an instance of the Compound.js SDK.
 */
const Compound = function (provider = 'mainnet', options = {}) {
    const originalProvider = provider;
    options.provider = provider || options.provider;
    provider = eth._createProvider(options);
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    const instance = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ _originalProvider: originalProvider, _provider: provider }, comptroller), cToken), priceFeed), gov), { claimComp: comp.claimComp, delegate: comp.delegate, delegateBySig: comp.delegateBySig, createDelegateSignature: comp.createDelegateSignature, _network: {
            id: options.networkId,
            name: options.networkName
        } });
    // Instance needs to know which network the provider connects to, so it can
    //     use the correct contract addresses.
    // instance._networkPromise = eth.getProviderNetwork(provider).then((network) => {
    //   delete instance._networkPromise
    //   instance._network = network
    // })
    return instance;
};
Compound.eth = eth;
Compound.api = api;
Compound.util = util;
Compound._ethers = ethers_1.ethers;
Compound.getDecimals = constants_1.getDecimals;
Compound.getAddress = constants_1.getAddress;
Compound.getName = constants_1.getName;
Compound.getTokenPairs = constants_1.getTokenPairs;
Compound.getRateModals = constants_1.getRateModals;
Compound.isUnderlyAllowed = constants_1.isUnderlyAllowed;
Compound.isCTokenAllowed = constants_1.isCTokenAllowed;
Compound.isEther = constants_1.isEther;
Compound.comp = {
    getCompBalance: comp.getCompBalance,
    getCompAccrued: comp.getCompAccrued,
};
Object.assign(Compound, constants_1.constants);
module.exports = Compound;
//# sourceMappingURL=index.js.map