"use strict";
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const types_1 = require("../../types");
const util_1 = require("../util");
function indexes(api) {
    return util_1.memo(() => (
    // Some chains (eg. very limited node-template), does not have session
    api.query.session && api.query.staking
        ? api.queryMulti([
            api.query.session.currentIndex,
            api.query.staking.currentEra,
            api.query.staking.validatorCount
        ])
        : rxjs_1.of([types_1.createType(api.registry, 'SessionIndex', 1), types_1.createType(api.registry, 'EraIndex', 1), types_1.createType(api.registry, 'u32')])).pipe(operators_1.map(([currentIndex, currentEra, validatorCount]) => ({
        currentIndex, currentEra, validatorCount
    }))));
}
exports.indexes = indexes;
