# All files / src/utils readSlots.js

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 7/7

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43

    14x

    14x
    1x
    1x
    2x

    1x

    2x

     /**
     * Copyright (c) 2018-present, Leap DAO (leapdao.org)
     *
     * This source code is licensed under the Mozilla Public License Version 2.0
     * found in the LICENSE file in the root directory of this source tree.
     */
    const range = require('./range');

    module.exports = async bridge => {
      const epochLength = await bridge.methods.epochLength().call();
      const slots = await Promise.all(
        range(0, epochLength - 1).map(slotId => bridge.methods.slots(slotId).call())
      );

      return slots.map(
        (
          {
            owner,
            stake,
            signer,
            tendermint,
            activationEpoch,
            newOwner,
            newStake,
            newSigner,
            newTendermint,
          },
          i
        ) => ({
          id: i,
          owner,
          stake,
          signerAddr: signer,
          tenderKey: tendermint,
          activationEpoch,
          newOwner,
          newStake,
          newSigner,
          newTendermint,
        })
      );
    };