"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const es6_promisify_1 = require("es6-promisify");
const utils_1 = require("./utils");
/**
 * Utils not meant to be exported to the public
 */
class UtilsInternal {
    static sleep(milliseconds) {
        return new Promise((resolve) => setTimeout(resolve, milliseconds));
    }
    static ensureArray(arr) {
        if (!Array.isArray(arr)) {
            arr = [arr];
        }
        return arr;
    }
    /**
     * Returns the last mined block in the chain.
     */
    static lastBlock() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const web3 = yield utils_1.Utils.getWeb3();
            return es6_promisify_1.promisify(web3.eth.getBlockNumber)();
        });
    }
    /**
     * For environments that don't allow synchronous functions
     * @param filter
     */
    static stopWatchingAsync(filter) {
        return es6_promisify_1.promisify((callback) => filter.stopWatching(callback))();
    }
    static getRandomNumber() {
        return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
    }
    static getWeb3Sync() {
        return utils_1.Utils.web3;
    }
}
exports.UtilsInternal = UtilsInternal;
//# sourceMappingURL=utilsInternal.js.map