"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FaucetClient = void 0;
const factory_1 = require("../factory");
const types_1 = require("@polkadot/types");
const client_1 = require("./client");
const utils_1 = require("../utils");
/**
 * @category Clients
 */
class FaucetClient extends client_1.JsonRpcClient {
    constructor(api, url) {
        super(url);
        this.api = api;
        this.registry = new types_1.TypeRegistry();
        this.registry.register(factory_1.getAPITypes());
        this.constr = {
            FundAccountJsonRpcRequest: this.registry.createClass("FundAccountJsonRpcRequest"),
        };
    }
    fundAccount(account, currency) {
        return __awaiter(this, void 0, void 0, function* () {
            const currencyId = utils_1.newCurrencyId(this.api, currency);
            const request = new this.constr["FundAccountJsonRpcRequest"](this.registry, {
                account_id: account,
                currency_id: currencyId,
            });
            yield this.post("fund_account", [request.toHex()]);
        });
    }
}
exports.FaucetClient = FaucetClient;
//# sourceMappingURL=faucet.js.map