"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.controllers = controllers;

var _rxjs = require("rxjs");

var _operators = require("rxjs/operators");

var _drr = require("../util/drr");

// Copyright 2017-2019 @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.

/**
 * @description From the list of stash accounts, retrieve the list of controllers
 */
function controllers(api) {
  return () => api.query.staking.validators().pipe((0, _operators.switchMap)((_ref) => {
    let [stashIds] = _ref;
    return (0, _rxjs.combineLatest)([(0, _rxjs.of)(stashIds), // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
    api.query.staking.bonded.multi(stashIds)]);
  }), (0, _drr.drr)());
}