text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const xrp_ledger_grpc_web_pb_1 = require("../generated/web/legacy/xrp_ledger_grpc_web_pb");
  const get_fee_request_pb_1 = require("../generated/web/legacy/get_fee_request_pb");
  const get_account_info_request_pb_1 = require("../generated/web/legacy/get_account_info_request_pb");
  const submit_signed_transaction_request_pb_1 = require("../generated/web/legacy/submit_signed_transaction_request_pb");
  const get_latest_validated_ledger_sequence_request_pb_1 = require("../generated/web/legacy/get_latest_validated_ledger_sequence_request_pb");
  const get_transaction_status_request_pb_1 = require("../generated/web/legacy/get_transaction_status_request_pb");
  const xrp_amount_pb_1 = require("../generated/node/legacy/xrp_amount_pb");
  const payment_pb_1 = require("../generated/node/legacy/payment_pb");
  const transaction_pb_1 = require("../generated/node/legacy/transaction_pb");
  const utils_1 = __importDefault(require("../utils"));
  /**
   * A GRPC Based network client.
   */
  class LegacyGRPCNetworkClient {
      constructor(grpcURL) {
          if (utils_1.default()) {
              try {
                  // This polyfill hack enables XMLHttpRequest on the global node.js state
                  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
                  // @ts-ignore eslint-disable-line
                  global.XMLHttpRequest = require('xhr2'); // eslint-disable-line
              }
              catch (_a) {
                  // Swallow the error here for browsers
              }
          }
          this.grpcClient = new xrp_ledger_grpc_web_pb_1.XRPLedgerAPIClient(grpcURL);
      }
      async getAccountInfo(getAccountInfoRequest) {
          return new Promise((resolve, reject) => {
              this.grpcClient.getAccountInfo(getAccountInfoRequest, {}, (error, response) => {
                  if (error != null || response == null) {
                      reject(error);
                      return;
                  }
                  resolve(response);
              });
          });
      }
      async getFee(getFeeRequest) {
          return new Promise((resolve, reject) => {
              this.grpcClient.getFee(getFeeRequest, {}, (error, response) => {
                  if (error != null || response == null) {
                      reject(error);
                      return;
                  }
                  resolve(response);
              });
          });
      }
      async submitSignedTransaction(submitSignedTransactionRequest) {
          return new Promise((resolve, reject) => {
              this.grpcClient.submitSignedTransaction(submitSignedTransactionRequest, {}, (error, response) => {
                  if (error !== null || response === null) {
                      reject(error);
                      return;
                  }
                  resolve(response);
              });
          });
      }
      async getLatestValidatedLedgerSequence(getLatestValidatedLedgerSequenceRequest) {
          return new Promise((resolve, reject) => {
              this.grpcClient.getLatestValidatedLedgerSequence(getLatestValidatedLedgerSequenceRequest, {}, (error, response) => {
                  if (error != null || response == null) {
                      reject(error);
                      return;
                  }
                  resolve(response);
              });
          });
      }
      async getTransactionStatus(getTransactionStatusRequest) {
          return new Promise((resolve, reject) => {
              this.grpcClient.getTransactionStatus(getTransactionStatusRequest, {}, (error, response) => {
                  if (error != null || response == null) {
                      reject(error);
                      return;
                  }
                  resolve(response);
              });
          });
      }
      /* eslint-disable class-methods-use-this */
      XRPAmount() {
          return new xrp_amount_pb_1.XRPAmount();
      }
      Payment() {
          return new payment_pb_1.Payment();
      }
      Transaction() {
          return new transaction_pb_1.Transaction();
      }
      SubmitSignedTransactionRequest() {
          return new submit_signed_transaction_request_pb_1.SubmitSignedTransactionRequest();
      }
      GetLatestValidatedLedgerSequenceRequest() {
          return new get_latest_validated_ledger_sequence_request_pb_1.GetLatestValidatedLedgerSequenceRequest();
      }
      GetTransactionStatusRequest() {
          return new get_transaction_status_request_pb_1.GetTransactionStatusRequest();
      }
      GetAccountInfoRequest() {
          return new get_account_info_request_pb_1.GetAccountInfoRequest();
      }
      GetFeeRequest() {
          return new get_fee_request_pb_1.GetFeeRequest();
      }
  }
  exports.default = LegacyGRPCNetworkClient;
  //# sourceMappingURL=legacy-grpc-network-client.web.js.map