UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

43 lines (42 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HorizonHandlerClient = void 0; const tslib_1 = require("tslib"); const stellar_sdk_1 = require("@stellar/stellar-sdk"); const errors_1 = require("../../stellar-plus/horizon/errors"); class HorizonHandlerClient { /** * * @param {NetworkConfig} networkConfig - The network to use. * * @description - The horizon handler is used for interacting with the Horizon server. * */ constructor(networkConfig) { this.networkConfig = networkConfig; if (!this.networkConfig.horizonUrl) { throw errors_1.DHHError.missingHorizonUrl(); } const serverOpts = { allowHttp: networkConfig.allowHttp }; this.server = new stellar_sdk_1.Horizon.Server(this.networkConfig.horizonUrl, serverOpts); } /** * * @param {string} accountId - The account ID to load. * * @description - Loads the account from the Horizon server. * * @returns {AccountResponse} The account response from the Horizon server. */ loadAccount(accountId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { try { return yield this.server.loadAccount(accountId); } catch (error) { throw errors_1.DHHError.failedToLoadAccount(); } }); } } exports.HorizonHandlerClient = HorizonHandlerClient;