text: const Driver = require('../models/driver');
  const Supply = require('../models/supply');
  const Coin = require('../models/coin');
  const SupplyModifier = require('../models/supply-modifier');
  const { promisesMap } = require('../util');
  
  /** Prux explorer. Supports total supply
   * and balance for specific address.
   *
   * @memberof Driver
   * @augments Driver
   */
  class Prux extends Driver {
    constructor(options) {
      super({
        timeout: 100, // 10 requests per second
        supports: {
          balances: true,
          blockchains: ['Prux'],
        },
        options,
      });
    }
  
    /** get total supply for native token
     *
     * @augments Driver.fetchTotalSupply
     * @async
     */
    async fetchTotalSupply() {
      const total = await this.request(
        'https://explorer.prux.info/ext/getmoneysupply',
      );
      return Number(total);
    }
  
    /** get balance for specific wallet address
     *
     * @augments Driver.fetchBalance
     * @param {SupplyModifier} modifier {@link SupplyModifier}
     * @async
     */
    async fetchBalance(modifier) {
      const balance = await this.request(
        `https://explorer.prux.info/ext/getbalance/${modifier}`,
      );
  
      return Number(balance);
    }
  
    /**
     * @augments Driver.getSupply
     * @param {Coin} coin {@link Coin}
     */
    async getSupply({ modifiers }) {
      const total = await this.fetchTotalSupply();
  
      const modifiersWithBalances = await promisesMap(
        modifiers,
        async (modifier) => {
          const balance = await this.fetchBalance(modifier);
          return {
            reference: modifier,
            balance,
          };
        },
      );
      const circulating = modifiersWithBalances.reduce(
        (current, modifier) => current - modifier.balance,
        total,
      );
  
      return new Supply({
        total,
        circulating,
        modifiers: modifiersWithBalances,
      });
    }
  }
  
  module.exports = Prux;
  