@stellar/stellar-sdk 14.3.0 → 14.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/stellar-sdk-minimal.js +191 -170
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +191 -170
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +191 -170
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +191 -170
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/contract/assembled_transaction.js +9 -4
  11. package/lib/contract/client.d.ts +1 -1
  12. package/lib/contract/client.js +25 -14
  13. package/lib/contract/sent_transaction.js +9 -4
  14. package/lib/contract/types.d.ts +9 -1
  15. package/lib/horizon/account_call_builder.d.ts +2 -1
  16. package/lib/horizon/account_call_builder.js +3 -3
  17. package/lib/horizon/assets_call_builder.d.ts +2 -1
  18. package/lib/horizon/assets_call_builder.js +2 -2
  19. package/lib/horizon/call_builder.d.ts +3 -1
  20. package/lib/horizon/call_builder.js +4 -3
  21. package/lib/horizon/claimable_balances_call_builder.d.ts +2 -1
  22. package/lib/horizon/claimable_balances_call_builder.js +3 -3
  23. package/lib/horizon/effect_call_builder.d.ts +2 -1
  24. package/lib/horizon/effect_call_builder.js +2 -2
  25. package/lib/horizon/friendbot_builder.d.ts +2 -1
  26. package/lib/horizon/friendbot_builder.js +2 -2
  27. package/lib/horizon/horizon_axios_client.d.ts +2 -2
  28. package/lib/horizon/horizon_axios_client.js +38 -30
  29. package/lib/horizon/index.d.ts +1 -1
  30. package/lib/horizon/index.js +1 -10
  31. package/lib/horizon/ledger_call_builder.d.ts +2 -1
  32. package/lib/horizon/ledger_call_builder.js +2 -2
  33. package/lib/horizon/liquidity_pool_call_builder.d.ts +2 -1
  34. package/lib/horizon/liquidity_pool_call_builder.js +3 -3
  35. package/lib/horizon/offer_call_builder.d.ts +2 -1
  36. package/lib/horizon/offer_call_builder.js +3 -3
  37. package/lib/horizon/operation_call_builder.d.ts +2 -1
  38. package/lib/horizon/operation_call_builder.js +3 -3
  39. package/lib/horizon/orderbook_call_builder.d.ts +2 -1
  40. package/lib/horizon/orderbook_call_builder.js +2 -2
  41. package/lib/horizon/path_call_builder.d.ts +2 -1
  42. package/lib/horizon/path_call_builder.js +2 -2
  43. package/lib/horizon/payment_call_builder.d.ts +2 -1
  44. package/lib/horizon/payment_call_builder.js +2 -2
  45. package/lib/horizon/server.d.ts +25 -10
  46. package/lib/horizon/server.js +23 -30
  47. package/lib/horizon/strict_receive_path_call_builder.d.ts +2 -1
  48. package/lib/horizon/strict_receive_path_call_builder.js +2 -2
  49. package/lib/horizon/strict_send_path_call_builder.d.ts +2 -1
  50. package/lib/horizon/strict_send_path_call_builder.js +2 -2
  51. package/lib/horizon/trade_aggregation_call_builder.d.ts +2 -1
  52. package/lib/horizon/trade_aggregation_call_builder.js +2 -2
  53. package/lib/horizon/trades_call_builder.d.ts +2 -1
  54. package/lib/horizon/trades_call_builder.js +2 -2
  55. package/lib/horizon/transaction_call_builder.d.ts +2 -1
  56. package/lib/horizon/transaction_call_builder.js +3 -3
  57. package/lib/minimal/contract/assembled_transaction.js +9 -4
  58. package/lib/minimal/contract/client.d.ts +1 -1
  59. package/lib/minimal/contract/client.js +25 -14
  60. package/lib/minimal/contract/sent_transaction.js +9 -4
  61. package/lib/minimal/contract/types.d.ts +9 -1
  62. package/lib/minimal/horizon/account_call_builder.d.ts +2 -1
  63. package/lib/minimal/horizon/account_call_builder.js +3 -3
  64. package/lib/minimal/horizon/assets_call_builder.d.ts +2 -1
  65. package/lib/minimal/horizon/assets_call_builder.js +2 -2
  66. package/lib/minimal/horizon/call_builder.d.ts +3 -1
  67. package/lib/minimal/horizon/call_builder.js +4 -3
  68. package/lib/minimal/horizon/claimable_balances_call_builder.d.ts +2 -1
  69. package/lib/minimal/horizon/claimable_balances_call_builder.js +3 -3
  70. package/lib/minimal/horizon/effect_call_builder.d.ts +2 -1
  71. package/lib/minimal/horizon/effect_call_builder.js +2 -2
  72. package/lib/minimal/horizon/friendbot_builder.d.ts +2 -1
  73. package/lib/minimal/horizon/friendbot_builder.js +2 -2
  74. package/lib/minimal/horizon/horizon_axios_client.d.ts +2 -2
  75. package/lib/minimal/horizon/horizon_axios_client.js +38 -30
  76. package/lib/minimal/horizon/index.d.ts +1 -1
  77. package/lib/minimal/horizon/index.js +1 -10
  78. package/lib/minimal/horizon/ledger_call_builder.d.ts +2 -1
  79. package/lib/minimal/horizon/ledger_call_builder.js +2 -2
  80. package/lib/minimal/horizon/liquidity_pool_call_builder.d.ts +2 -1
  81. package/lib/minimal/horizon/liquidity_pool_call_builder.js +3 -3
  82. package/lib/minimal/horizon/offer_call_builder.d.ts +2 -1
  83. package/lib/minimal/horizon/offer_call_builder.js +3 -3
  84. package/lib/minimal/horizon/operation_call_builder.d.ts +2 -1
  85. package/lib/minimal/horizon/operation_call_builder.js +3 -3
  86. package/lib/minimal/horizon/orderbook_call_builder.d.ts +2 -1
  87. package/lib/minimal/horizon/orderbook_call_builder.js +2 -2
  88. package/lib/minimal/horizon/path_call_builder.d.ts +2 -1
  89. package/lib/minimal/horizon/path_call_builder.js +2 -2
  90. package/lib/minimal/horizon/payment_call_builder.d.ts +2 -1
  91. package/lib/minimal/horizon/payment_call_builder.js +2 -2
  92. package/lib/minimal/horizon/server.d.ts +25 -10
  93. package/lib/minimal/horizon/server.js +23 -30
  94. package/lib/minimal/horizon/strict_receive_path_call_builder.d.ts +2 -1
  95. package/lib/minimal/horizon/strict_receive_path_call_builder.js +2 -2
  96. package/lib/minimal/horizon/strict_send_path_call_builder.d.ts +2 -1
  97. package/lib/minimal/horizon/strict_send_path_call_builder.js +2 -2
  98. package/lib/minimal/horizon/trade_aggregation_call_builder.d.ts +2 -1
  99. package/lib/minimal/horizon/trade_aggregation_call_builder.js +2 -2
  100. package/lib/minimal/horizon/trades_call_builder.d.ts +2 -1
  101. package/lib/minimal/horizon/trades_call_builder.js +2 -2
  102. package/lib/minimal/horizon/transaction_call_builder.d.ts +2 -1
  103. package/lib/minimal/horizon/transaction_call_builder.js +3 -3
  104. package/lib/minimal/rpc/axios.d.ts +1 -2
  105. package/lib/minimal/rpc/axios.js +17 -9
  106. package/lib/minimal/rpc/index.d.ts +0 -1
  107. package/lib/minimal/rpc/index.js +0 -9
  108. package/lib/minimal/rpc/jsonrpc.d.ts +2 -1
  109. package/lib/minimal/rpc/jsonrpc.js +4 -6
  110. package/lib/minimal/rpc/server.d.ts +31 -0
  111. package/lib/minimal/rpc/server.js +15 -20
  112. package/lib/no-axios/contract/assembled_transaction.js +9 -4
  113. package/lib/no-axios/contract/client.d.ts +1 -1
  114. package/lib/no-axios/contract/client.js +25 -14
  115. package/lib/no-axios/contract/sent_transaction.js +9 -4
  116. package/lib/no-axios/contract/types.d.ts +9 -1
  117. package/lib/no-axios/horizon/account_call_builder.d.ts +2 -1
  118. package/lib/no-axios/horizon/account_call_builder.js +3 -3
  119. package/lib/no-axios/horizon/assets_call_builder.d.ts +2 -1
  120. package/lib/no-axios/horizon/assets_call_builder.js +2 -2
  121. package/lib/no-axios/horizon/call_builder.d.ts +3 -1
  122. package/lib/no-axios/horizon/call_builder.js +4 -3
  123. package/lib/no-axios/horizon/claimable_balances_call_builder.d.ts +2 -1
  124. package/lib/no-axios/horizon/claimable_balances_call_builder.js +3 -3
  125. package/lib/no-axios/horizon/effect_call_builder.d.ts +2 -1
  126. package/lib/no-axios/horizon/effect_call_builder.js +2 -2
  127. package/lib/no-axios/horizon/friendbot_builder.d.ts +2 -1
  128. package/lib/no-axios/horizon/friendbot_builder.js +2 -2
  129. package/lib/no-axios/horizon/horizon_axios_client.d.ts +2 -2
  130. package/lib/no-axios/horizon/horizon_axios_client.js +38 -30
  131. package/lib/no-axios/horizon/index.d.ts +1 -1
  132. package/lib/no-axios/horizon/index.js +1 -10
  133. package/lib/no-axios/horizon/ledger_call_builder.d.ts +2 -1
  134. package/lib/no-axios/horizon/ledger_call_builder.js +2 -2
  135. package/lib/no-axios/horizon/liquidity_pool_call_builder.d.ts +2 -1
  136. package/lib/no-axios/horizon/liquidity_pool_call_builder.js +3 -3
  137. package/lib/no-axios/horizon/offer_call_builder.d.ts +2 -1
  138. package/lib/no-axios/horizon/offer_call_builder.js +3 -3
  139. package/lib/no-axios/horizon/operation_call_builder.d.ts +2 -1
  140. package/lib/no-axios/horizon/operation_call_builder.js +3 -3
  141. package/lib/no-axios/horizon/orderbook_call_builder.d.ts +2 -1
  142. package/lib/no-axios/horizon/orderbook_call_builder.js +2 -2
  143. package/lib/no-axios/horizon/path_call_builder.d.ts +2 -1
  144. package/lib/no-axios/horizon/path_call_builder.js +2 -2
  145. package/lib/no-axios/horizon/payment_call_builder.d.ts +2 -1
  146. package/lib/no-axios/horizon/payment_call_builder.js +2 -2
  147. package/lib/no-axios/horizon/server.d.ts +25 -10
  148. package/lib/no-axios/horizon/server.js +23 -30
  149. package/lib/no-axios/horizon/strict_receive_path_call_builder.d.ts +2 -1
  150. package/lib/no-axios/horizon/strict_receive_path_call_builder.js +2 -2
  151. package/lib/no-axios/horizon/strict_send_path_call_builder.d.ts +2 -1
  152. package/lib/no-axios/horizon/strict_send_path_call_builder.js +2 -2
  153. package/lib/no-axios/horizon/trade_aggregation_call_builder.d.ts +2 -1
  154. package/lib/no-axios/horizon/trade_aggregation_call_builder.js +2 -2
  155. package/lib/no-axios/horizon/trades_call_builder.d.ts +2 -1
  156. package/lib/no-axios/horizon/trades_call_builder.js +2 -2
  157. package/lib/no-axios/horizon/transaction_call_builder.d.ts +2 -1
  158. package/lib/no-axios/horizon/transaction_call_builder.js +3 -3
  159. package/lib/no-axios/rpc/axios.d.ts +1 -2
  160. package/lib/no-axios/rpc/axios.js +17 -9
  161. package/lib/no-axios/rpc/index.d.ts +0 -1
  162. package/lib/no-axios/rpc/index.js +0 -9
  163. package/lib/no-axios/rpc/jsonrpc.d.ts +2 -1
  164. package/lib/no-axios/rpc/jsonrpc.js +4 -6
  165. package/lib/no-axios/rpc/server.d.ts +31 -0
  166. package/lib/no-axios/rpc/server.js +15 -20
  167. package/lib/no-eventsource/contract/assembled_transaction.js +9 -4
  168. package/lib/no-eventsource/contract/client.d.ts +1 -1
  169. package/lib/no-eventsource/contract/client.js +25 -14
  170. package/lib/no-eventsource/contract/sent_transaction.js +9 -4
  171. package/lib/no-eventsource/contract/types.d.ts +9 -1
  172. package/lib/no-eventsource/horizon/account_call_builder.d.ts +2 -1
  173. package/lib/no-eventsource/horizon/account_call_builder.js +3 -3
  174. package/lib/no-eventsource/horizon/assets_call_builder.d.ts +2 -1
  175. package/lib/no-eventsource/horizon/assets_call_builder.js +2 -2
  176. package/lib/no-eventsource/horizon/call_builder.d.ts +3 -1
  177. package/lib/no-eventsource/horizon/call_builder.js +4 -3
  178. package/lib/no-eventsource/horizon/claimable_balances_call_builder.d.ts +2 -1
  179. package/lib/no-eventsource/horizon/claimable_balances_call_builder.js +3 -3
  180. package/lib/no-eventsource/horizon/effect_call_builder.d.ts +2 -1
  181. package/lib/no-eventsource/horizon/effect_call_builder.js +2 -2
  182. package/lib/no-eventsource/horizon/friendbot_builder.d.ts +2 -1
  183. package/lib/no-eventsource/horizon/friendbot_builder.js +2 -2
  184. package/lib/no-eventsource/horizon/horizon_axios_client.d.ts +2 -2
  185. package/lib/no-eventsource/horizon/horizon_axios_client.js +38 -30
  186. package/lib/no-eventsource/horizon/index.d.ts +1 -1
  187. package/lib/no-eventsource/horizon/index.js +1 -10
  188. package/lib/no-eventsource/horizon/ledger_call_builder.d.ts +2 -1
  189. package/lib/no-eventsource/horizon/ledger_call_builder.js +2 -2
  190. package/lib/no-eventsource/horizon/liquidity_pool_call_builder.d.ts +2 -1
  191. package/lib/no-eventsource/horizon/liquidity_pool_call_builder.js +3 -3
  192. package/lib/no-eventsource/horizon/offer_call_builder.d.ts +2 -1
  193. package/lib/no-eventsource/horizon/offer_call_builder.js +3 -3
  194. package/lib/no-eventsource/horizon/operation_call_builder.d.ts +2 -1
  195. package/lib/no-eventsource/horizon/operation_call_builder.js +3 -3
  196. package/lib/no-eventsource/horizon/orderbook_call_builder.d.ts +2 -1
  197. package/lib/no-eventsource/horizon/orderbook_call_builder.js +2 -2
  198. package/lib/no-eventsource/horizon/path_call_builder.d.ts +2 -1
  199. package/lib/no-eventsource/horizon/path_call_builder.js +2 -2
  200. package/lib/no-eventsource/horizon/payment_call_builder.d.ts +2 -1
  201. package/lib/no-eventsource/horizon/payment_call_builder.js +2 -2
  202. package/lib/no-eventsource/horizon/server.d.ts +25 -10
  203. package/lib/no-eventsource/horizon/server.js +23 -30
  204. package/lib/no-eventsource/horizon/strict_receive_path_call_builder.d.ts +2 -1
  205. package/lib/no-eventsource/horizon/strict_receive_path_call_builder.js +2 -2
  206. package/lib/no-eventsource/horizon/strict_send_path_call_builder.d.ts +2 -1
  207. package/lib/no-eventsource/horizon/strict_send_path_call_builder.js +2 -2
  208. package/lib/no-eventsource/horizon/trade_aggregation_call_builder.d.ts +2 -1
  209. package/lib/no-eventsource/horizon/trade_aggregation_call_builder.js +2 -2
  210. package/lib/no-eventsource/horizon/trades_call_builder.d.ts +2 -1
  211. package/lib/no-eventsource/horizon/trades_call_builder.js +2 -2
  212. package/lib/no-eventsource/horizon/transaction_call_builder.d.ts +2 -1
  213. package/lib/no-eventsource/horizon/transaction_call_builder.js +3 -3
  214. package/lib/no-eventsource/rpc/axios.d.ts +1 -2
  215. package/lib/no-eventsource/rpc/axios.js +17 -9
  216. package/lib/no-eventsource/rpc/index.d.ts +0 -1
  217. package/lib/no-eventsource/rpc/index.js +0 -9
  218. package/lib/no-eventsource/rpc/jsonrpc.d.ts +2 -1
  219. package/lib/no-eventsource/rpc/jsonrpc.js +4 -6
  220. package/lib/no-eventsource/rpc/server.d.ts +31 -0
  221. package/lib/no-eventsource/rpc/server.js +15 -20
  222. package/lib/rpc/axios.d.ts +1 -2
  223. package/lib/rpc/axios.js +17 -9
  224. package/lib/rpc/index.d.ts +0 -1
  225. package/lib/rpc/index.js +0 -9
  226. package/lib/rpc/jsonrpc.d.ts +2 -1
  227. package/lib/rpc/jsonrpc.js +4 -6
  228. package/lib/rpc/server.d.ts +31 -0
  229. package/lib/rpc/server.js +15 -20
  230. package/package.json +18 -43
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var PathCallBuilder = exports.PathCallBuilder = function (_CallBuilder) {
22
- function PathCallBuilder(serverUrl, source, destination, destinationAsset, destinationAmount) {
22
+ function PathCallBuilder(serverUrl, httpClient, source, destination, destinationAsset, destinationAmount) {
23
23
  var _this;
24
24
  _classCallCheck(this, PathCallBuilder);
25
- _this = _callSuper(this, PathCallBuilder, [serverUrl]);
25
+ _this = _callSuper(this, PathCallBuilder, [serverUrl, httpClient]);
26
26
  _this.url.segment("paths");
27
27
  _this.url.setQuery("destination_account", destination);
28
28
  _this.url.setQuery("source_account", source);
@@ -1,5 +1,6 @@
1
1
  import { CallBuilder } from "./call_builder";
2
2
  import { ServerApi } from "./server_api";
3
+ import { HttpClient } from "../http-client";
3
4
  /**
4
5
  * Creates a new {@link PaymentCallBuilder} pointed to server defined by serverUrl.
5
6
  *
@@ -14,7 +15,7 @@ import { ServerApi } from "./server_api";
14
15
  * @param {string} serverUrl Horizon server URL.
15
16
  */
16
17
  export declare class PaymentCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentOperationRecord | ServerApi.CreateAccountOperationRecord | ServerApi.AccountMergeOperationRecord | ServerApi.PathPaymentOperationRecord | ServerApi.PathPaymentStrictSendOperationRecord | ServerApi.InvokeHostFunctionOperationRecord>> {
17
- constructor(serverUrl: URI);
18
+ constructor(serverUrl: URI, httpClient: HttpClient);
18
19
  /**
19
20
  * This endpoint responds with a collection of Payment operations where the given account was either the sender or receiver.
20
21
  * @see {@link https://developers.stellar.org/docs/data/horizon/api-reference/horizon/resources/get-payments-by-account-id|Payments for Account}
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var PaymentCallBuilder = exports.PaymentCallBuilder = function (_CallBuilder) {
22
- function PaymentCallBuilder(serverUrl) {
22
+ function PaymentCallBuilder(serverUrl, httpClient) {
23
23
  var _this;
24
24
  _classCallCheck(this, PaymentCallBuilder);
25
- _this = _callSuper(this, PaymentCallBuilder, [serverUrl, "payments"]);
25
+ _this = _callSuper(this, PaymentCallBuilder, [serverUrl, httpClient, "payments"]);
26
26
  _this.url.segment("payments");
27
27
  return _this;
28
28
  }
@@ -17,6 +17,7 @@ import { PaymentCallBuilder } from "./payment_call_builder";
17
17
  import { TradeAggregationCallBuilder } from "./trade_aggregation_call_builder";
18
18
  import { TradesCallBuilder } from "./trades_call_builder";
19
19
  import { TransactionCallBuilder } from "./transaction_call_builder";
20
+ import { HttpClient } from "../http-client";
20
21
  /**
21
22
  * Default transaction submission timeout for Horizon requests, in milliseconds
22
23
  * @constant {number}
@@ -38,9 +39,24 @@ export declare class HorizonServer {
38
39
  /**
39
40
  * Horizon Server URL (ex. `https://horizon-testnet.stellar.org`)
40
41
  *
41
- * @todo Solve `URI(this.serverURL as any)`.
42
+ * @todo Solve `this.serverURL`.
42
43
  */
43
44
  readonly serverURL: URI;
45
+ /**
46
+ * HTTP client instance for making requests to Horizon.
47
+ * Exposes interceptors, defaults, and other configuration options.
48
+ *
49
+ * @example
50
+ * // Add authentication header
51
+ * server.httpClient.defaults.headers['Authorization'] = 'Bearer token';
52
+ *
53
+ * // Add request interceptor
54
+ * server.httpClient.interceptors.request.use((config) => {
55
+ * console.log('Request:', config.url);
56
+ * return config;
57
+ * });
58
+ */
59
+ readonly httpClient: HttpClient;
44
60
  constructor(serverURL: string, opts?: HorizonServer.Options);
45
61
  /**
46
62
  * Get timebounds for N seconds from now, when you're creating a transaction
@@ -367,16 +383,15 @@ export declare class HorizonServer {
367
383
  */
368
384
  checkMemoRequired(transaction: Transaction | FeeBumpTransaction): Promise<void>;
369
385
  }
370
- /**
371
- * Options for configuring connections to Horizon servers.
372
- * @typedef {object} Options
373
- * @memberof module:Horizon.Server
374
- * @property {boolean} [allowHttp] Allow connecting to http servers, default: `false`. This must be set to false in production deployments! You can also use {@link Config} class to set this globally.
375
- * @property {string} [appName] Allow set custom header `X-App-Name`, default: `undefined`.
376
- * @property {string} [appVersion] Allow set custom header `X-App-Version`, default: `undefined`.
377
- * @property {string} [authToken] Allow set custom header `X-Auth-Token`, default: `undefined`.
378
- */
379
386
  export declare namespace HorizonServer {
387
+ /**
388
+ * Options for configuring connections to Horizon servers.
389
+ * @memberof module:Horizon.Server
390
+ * @property {boolean} [allowHttp] Allow connecting to http servers, default: `false`. This must be set to false in production deployments! You can also use {@link Config} class to set this globally.
391
+ * @property {string} [appName] Allow set custom header `X-App-Name`, default: `undefined`.
392
+ * @property {string} [appVersion] Allow set custom header `X-App-Version`, default: `undefined`.
393
+ * @property {string} [authToken] Allow set custom header `X-Auth-Token`, default: `undefined`.
394
+ */
380
395
  interface Options {
381
396
  allowHttp?: boolean;
382
397
  appName?: string;
@@ -27,8 +27,7 @@ var _strict_send_path_call_builder = require("./strict_send_path_call_builder");
27
27
  var _trade_aggregation_call_builder = require("./trade_aggregation_call_builder");
28
28
  var _trades_call_builder = require("./trades_call_builder");
29
29
  var _transaction_call_builder = require("./transaction_call_builder");
30
- var _horizon_axios_client = _interopRequireWildcard(require("./horizon_axios_client"));
31
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
30
+ var _horizon_axios_client = require("./horizon_axios_client");
32
31
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
32
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
34
33
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -68,13 +67,7 @@ var HorizonServer = exports.HorizonServer = function () {
68
67
  if (opts.headers) {
69
68
  Object.assign(customHeaders, opts.headers);
70
69
  }
71
- if (Object.keys(customHeaders).length > 0) {
72
- _horizon_axios_client.default.interceptors.request.use(function (config) {
73
- config.headers = config.headers || {};
74
- config.headers = Object.assign(config.headers, customHeaders);
75
- return config;
76
- });
77
- }
70
+ this.httpClient = (0, _horizon_axios_client.createHttpClient)(customHeaders);
78
71
  if (this.serverURL.protocol() !== "https" && !allowHttp) {
79
72
  throw new Error("Cannot connect to insecure horizon server");
80
73
  }
@@ -110,7 +103,7 @@ var HorizonServer = exports.HorizonServer = function () {
110
103
  });
111
104
  case 2:
112
105
  _context.n = 3;
113
- return _horizon_axios_client.default.get((0, _urijs.default)(this.serverURL).toString());
106
+ return this.httpClient.get(this.serverURL.toString());
114
107
  case 3:
115
108
  return _context.a(2, this.fetchTimebounds(seconds, true));
116
109
  }
@@ -150,7 +143,7 @@ var HorizonServer = exports.HorizonServer = function () {
150
143
  return _regenerator().w(function (_context3) {
151
144
  while (1) switch (_context3.n) {
152
145
  case 0:
153
- cb = new _call_builder.CallBuilder((0, _urijs.default)(this.serverURL));
146
+ cb = new _call_builder.CallBuilder(this.serverURL, this.httpClient);
154
147
  cb.filter.push(["fee_stats"]);
155
148
  return _context3.a(2, cb.call());
156
149
  }
@@ -169,7 +162,7 @@ var HorizonServer = exports.HorizonServer = function () {
169
162
  return _regenerator().w(function (_context4) {
170
163
  while (1) switch (_context4.n) {
171
164
  case 0:
172
- cb = new _call_builder.CallBuilder((0, _urijs.default)(this.serverURL));
165
+ cb = new _call_builder.CallBuilder(this.serverURL, this.httpClient);
173
166
  return _context4.a(2, cb.call());
174
167
  }
175
168
  }, _callee4, this);
@@ -200,7 +193,7 @@ var HorizonServer = exports.HorizonServer = function () {
200
193
  return this.checkMemoRequired(transaction);
201
194
  case 1:
202
195
  tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
203
- return _context5.a(2, _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions").toString(), "tx=".concat(tx), {
196
+ return _context5.a(2, this.httpClient.post(this.serverURL.segment("transactions").toString(), "tx=".concat(tx), {
204
197
  timeout: SUBMIT_TRANSACTION_TIMEOUT,
205
198
  headers: {
206
199
  "Content-Type": "application/x-www-form-urlencoded"
@@ -341,7 +334,7 @@ var HorizonServer = exports.HorizonServer = function () {
341
334
  return this.checkMemoRequired(transaction);
342
335
  case 1:
343
336
  tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
344
- return _context6.a(2, _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions_async").toString(), "tx=".concat(tx), {
337
+ return _context6.a(2, this.httpClient.post(this.serverURL.segment("transactions_async").toString(), "tx=".concat(tx), {
345
338
  headers: {
346
339
  "Content-Type": "application/x-www-form-urlencoded"
347
340
  }
@@ -364,77 +357,77 @@ var HorizonServer = exports.HorizonServer = function () {
364
357
  }, {
365
358
  key: "accounts",
366
359
  value: function accounts() {
367
- return new _account_call_builder.AccountCallBuilder((0, _urijs.default)(this.serverURL));
360
+ return new _account_call_builder.AccountCallBuilder(this.serverURL, this.httpClient);
368
361
  }
369
362
  }, {
370
363
  key: "claimableBalances",
371
364
  value: function claimableBalances() {
372
- return new _claimable_balances_call_builder.ClaimableBalanceCallBuilder((0, _urijs.default)(this.serverURL));
365
+ return new _claimable_balances_call_builder.ClaimableBalanceCallBuilder(this.serverURL, this.httpClient);
373
366
  }
374
367
  }, {
375
368
  key: "ledgers",
376
369
  value: function ledgers() {
377
- return new _ledger_call_builder.LedgerCallBuilder((0, _urijs.default)(this.serverURL));
370
+ return new _ledger_call_builder.LedgerCallBuilder(this.serverURL, this.httpClient);
378
371
  }
379
372
  }, {
380
373
  key: "transactions",
381
374
  value: function transactions() {
382
- return new _transaction_call_builder.TransactionCallBuilder((0, _urijs.default)(this.serverURL));
375
+ return new _transaction_call_builder.TransactionCallBuilder(this.serverURL, this.httpClient);
383
376
  }
384
377
  }, {
385
378
  key: "offers",
386
379
  value: function offers() {
387
- return new _offer_call_builder.OfferCallBuilder((0, _urijs.default)(this.serverURL));
380
+ return new _offer_call_builder.OfferCallBuilder(this.serverURL, this.httpClient);
388
381
  }
389
382
  }, {
390
383
  key: "orderbook",
391
384
  value: function orderbook(selling, buying) {
392
- return new _orderbook_call_builder.OrderbookCallBuilder((0, _urijs.default)(this.serverURL), selling, buying);
385
+ return new _orderbook_call_builder.OrderbookCallBuilder(this.serverURL, this.httpClient, selling, buying);
393
386
  }
394
387
  }, {
395
388
  key: "trades",
396
389
  value: function trades() {
397
- return new _trades_call_builder.TradesCallBuilder((0, _urijs.default)(this.serverURL));
390
+ return new _trades_call_builder.TradesCallBuilder(this.serverURL, this.httpClient);
398
391
  }
399
392
  }, {
400
393
  key: "operations",
401
394
  value: function operations() {
402
- return new _operation_call_builder.OperationCallBuilder((0, _urijs.default)(this.serverURL));
395
+ return new _operation_call_builder.OperationCallBuilder(this.serverURL, this.httpClient);
403
396
  }
404
397
  }, {
405
398
  key: "liquidityPools",
406
399
  value: function liquidityPools() {
407
- return new _liquidity_pool_call_builder.LiquidityPoolCallBuilder((0, _urijs.default)(this.serverURL));
400
+ return new _liquidity_pool_call_builder.LiquidityPoolCallBuilder(this.serverURL, this.httpClient);
408
401
  }
409
402
  }, {
410
403
  key: "strictReceivePaths",
411
404
  value: function strictReceivePaths(source, destinationAsset, destinationAmount) {
412
- return new _strict_receive_path_call_builder.StrictReceivePathCallBuilder((0, _urijs.default)(this.serverURL), source, destinationAsset, destinationAmount);
405
+ return new _strict_receive_path_call_builder.StrictReceivePathCallBuilder(this.serverURL, this.httpClient, source, destinationAsset, destinationAmount);
413
406
  }
414
407
  }, {
415
408
  key: "strictSendPaths",
416
409
  value: function strictSendPaths(sourceAsset, sourceAmount, destination) {
417
- return new _strict_send_path_call_builder.StrictSendPathCallBuilder((0, _urijs.default)(this.serverURL), sourceAsset, sourceAmount, destination);
410
+ return new _strict_send_path_call_builder.StrictSendPathCallBuilder(this.serverURL, this.httpClient, sourceAsset, sourceAmount, destination);
418
411
  }
419
412
  }, {
420
413
  key: "payments",
421
414
  value: function payments() {
422
- return new _payment_call_builder.PaymentCallBuilder((0, _urijs.default)(this.serverURL));
415
+ return new _payment_call_builder.PaymentCallBuilder(this.serverURL, this.httpClient);
423
416
  }
424
417
  }, {
425
418
  key: "effects",
426
419
  value: function effects() {
427
- return new _effect_call_builder.EffectCallBuilder((0, _urijs.default)(this.serverURL));
420
+ return new _effect_call_builder.EffectCallBuilder(this.serverURL, this.httpClient);
428
421
  }
429
422
  }, {
430
423
  key: "friendbot",
431
424
  value: function friendbot(address) {
432
- return new _friendbot_builder.FriendbotBuilder((0, _urijs.default)(this.serverURL), address);
425
+ return new _friendbot_builder.FriendbotBuilder(this.serverURL, this.httpClient, address);
433
426
  }
434
427
  }, {
435
428
  key: "assets",
436
429
  value: function assets() {
437
- return new _assets_call_builder.AssetsCallBuilder((0, _urijs.default)(this.serverURL));
430
+ return new _assets_call_builder.AssetsCallBuilder(this.serverURL, this.httpClient);
438
431
  }
439
432
  }, {
440
433
  key: "loadAccount",
@@ -460,7 +453,7 @@ var HorizonServer = exports.HorizonServer = function () {
460
453
  }, {
461
454
  key: "tradeAggregation",
462
455
  value: function tradeAggregation(base, counter, start_time, end_time, resolution, offset) {
463
- return new _trade_aggregation_call_builder.TradeAggregationCallBuilder((0, _urijs.default)(this.serverURL), base, counter, start_time, end_time, resolution, offset);
456
+ return new _trade_aggregation_call_builder.TradeAggregationCallBuilder(this.serverURL, this.httpClient, base, counter, start_time, end_time, resolution, offset);
464
457
  }
465
458
  }, {
466
459
  key: "checkMemoRequired",
@@ -1,6 +1,7 @@
1
1
  import { Asset } from "@stellar/stellar-base";
2
2
  import { CallBuilder } from "./call_builder";
3
3
  import { ServerApi } from "./server_api";
4
+ import { HttpClient } from "../http-client";
4
5
  /**
5
6
  * The Stellar Network allows payments to be made across assets through path
6
7
  * payments. A strict receive path payment specifies a series of assets to route
@@ -34,5 +35,5 @@ import { ServerApi } from "./server_api";
34
35
  * @param {string} destinationAmount The amount, denominated in the destination asset, that any returned path should be able to satisfy.
35
36
  */
36
37
  export declare class StrictReceivePathCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentPathRecord>> {
37
- constructor(serverUrl: URI, source: string | Asset[], destinationAsset: Asset, destinationAmount: string);
38
+ constructor(serverUrl: URI, httpClient: HttpClient, source: string | Asset[], destinationAsset: Asset, destinationAmount: string);
38
39
  }
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var StrictReceivePathCallBuilder = exports.StrictReceivePathCallBuilder = function (_CallBuilder) {
22
- function StrictReceivePathCallBuilder(serverUrl, source, destinationAsset, destinationAmount) {
22
+ function StrictReceivePathCallBuilder(serverUrl, httpClient, source, destinationAsset, destinationAmount) {
23
23
  var _this;
24
24
  _classCallCheck(this, StrictReceivePathCallBuilder);
25
- _this = _callSuper(this, StrictReceivePathCallBuilder, [serverUrl]);
25
+ _this = _callSuper(this, StrictReceivePathCallBuilder, [serverUrl, httpClient]);
26
26
  _this.url.segment("paths/strict-receive");
27
27
  if (typeof source === "string") {
28
28
  _this.url.setQuery("source_account", source);
@@ -1,6 +1,7 @@
1
1
  import { Asset } from "@stellar/stellar-base";
2
2
  import { CallBuilder } from "./call_builder";
3
3
  import { ServerApi } from "./server_api";
4
+ import { HttpClient } from "../http-client";
4
5
  /**
5
6
  * The Stellar Network allows payments to be made across assets through path
6
7
  * payments. A strict send path payment specifies a series of assets to route a
@@ -34,5 +35,5 @@ import { ServerApi } from "./server_api";
34
35
  *
35
36
  */
36
37
  export declare class StrictSendPathCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentPathRecord>> {
37
- constructor(serverUrl: URI, sourceAsset: Asset, sourceAmount: string, destination: string | Asset[]);
38
+ constructor(serverUrl: URI, httpClient: HttpClient, sourceAsset: Asset, sourceAmount: string, destination: string | Asset[]);
38
39
  }
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var StrictSendPathCallBuilder = exports.StrictSendPathCallBuilder = function (_CallBuilder) {
22
- function StrictSendPathCallBuilder(serverUrl, sourceAsset, sourceAmount, destination) {
22
+ function StrictSendPathCallBuilder(serverUrl, httpClient, sourceAsset, sourceAmount, destination) {
23
23
  var _this;
24
24
  _classCallCheck(this, StrictSendPathCallBuilder);
25
- _this = _callSuper(this, StrictSendPathCallBuilder, [serverUrl]);
25
+ _this = _callSuper(this, StrictSendPathCallBuilder, [serverUrl, httpClient]);
26
26
  _this.url.segment("paths/strict-send");
27
27
  if (sourceAsset.isNative()) {
28
28
  _this.url.setQuery("source_asset_type", "native");
@@ -2,6 +2,7 @@ import { Asset } from "@stellar/stellar-base";
2
2
  import { CallBuilder } from "./call_builder";
3
3
  import { HorizonApi } from "./horizon_api";
4
4
  import { ServerApi } from "./server_api";
5
+ import { HttpClient } from "../http-client";
5
6
  /**
6
7
  * Trade Aggregations facilitate efficient gathering of historical trade data.
7
8
  *
@@ -20,7 +21,7 @@ import { ServerApi } from "./server_api";
20
21
  * @param {number} offset segments can be offset using this parameter. Expressed in milliseconds. *Can only be used if the resolution is greater than 1 hour. Value must be in whole hours, less than the provided resolution, and less than 24 hours.
21
22
  */
22
23
  export declare class TradeAggregationCallBuilder extends CallBuilder<ServerApi.CollectionPage<TradeAggregationRecord>> {
23
- constructor(serverUrl: URI, base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number);
24
+ constructor(serverUrl: URI, httpClient: HttpClient, base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number);
24
25
  /**
25
26
  * @private
26
27
  * @param {number} resolution Trade data resolution in milliseconds
@@ -21,10 +21,10 @@ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new T
21
21
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
22
22
  var allowedResolutions = [60000, 300000, 900000, 3600000, 86400000, 604800000];
23
23
  var TradeAggregationCallBuilder = exports.TradeAggregationCallBuilder = function (_CallBuilder) {
24
- function TradeAggregationCallBuilder(serverUrl, base, counter, start_time, end_time, resolution, offset) {
24
+ function TradeAggregationCallBuilder(serverUrl, httpClient, base, counter, start_time, end_time, resolution, offset) {
25
25
  var _this;
26
26
  _classCallCheck(this, TradeAggregationCallBuilder);
27
- _this = _callSuper(this, TradeAggregationCallBuilder, [serverUrl]);
27
+ _this = _callSuper(this, TradeAggregationCallBuilder, [serverUrl, httpClient]);
28
28
  _this.url.segment("trade_aggregations");
29
29
  if (!base.isNative()) {
30
30
  _this.url.setQuery("base_asset_type", base.getAssetType());
@@ -1,6 +1,7 @@
1
1
  import { Asset } from "@stellar/stellar-base";
2
2
  import { CallBuilder } from "./call_builder";
3
3
  import { ServerApi } from "./server_api";
4
+ import { HttpClient } from "../http-client";
4
5
  /**
5
6
  * Creates a new {@link TradesCallBuilder} pointed to server defined by serverUrl.
6
7
  *
@@ -15,7 +16,7 @@ import { ServerApi } from "./server_api";
15
16
  * @param {string} serverUrl serverUrl Horizon server URL.
16
17
  */
17
18
  export declare class TradesCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.TradeRecord>> {
18
- constructor(serverUrl: URI);
19
+ constructor(serverUrl: URI, httpClient: HttpClient);
19
20
  /**
20
21
  * Filter trades for a specific asset pair (orderbook)
21
22
  * @param {Asset} base asset
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var TradesCallBuilder = exports.TradesCallBuilder = function (_CallBuilder) {
22
- function TradesCallBuilder(serverUrl) {
22
+ function TradesCallBuilder(serverUrl, httpClient) {
23
23
  var _this;
24
24
  _classCallCheck(this, TradesCallBuilder);
25
- _this = _callSuper(this, TradesCallBuilder, [serverUrl, "trades"]);
25
+ _this = _callSuper(this, TradesCallBuilder, [serverUrl, httpClient, "trades"]);
26
26
  _this.url.segment("trades");
27
27
  return _this;
28
28
  }
@@ -1,5 +1,6 @@
1
1
  import { CallBuilder } from "./call_builder";
2
2
  import { ServerApi } from "./server_api";
3
+ import { HttpClient } from "../http-client";
3
4
  /**
4
5
  * Creates a new {@link TransactionCallBuilder} pointed to server defined by serverUrl.
5
6
  *
@@ -14,7 +15,7 @@ import { ServerApi } from "./server_api";
14
15
  * @param {string} serverUrl Horizon server URL.
15
16
  */
16
17
  export declare class TransactionCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.TransactionRecord>> {
17
- constructor(serverUrl: URI);
18
+ constructor(serverUrl: URI, httpClient: HttpClient);
18
19
  /**
19
20
  * The transaction details endpoint provides information on a single transaction. The transaction hash provided in the hash argument specifies which transaction to load.
20
21
  * @see {@link https://developers.stellar.org/docs/data/horizon/api-reference/resources/retrieve-a-transaction|Transaction Details}
@@ -19,10 +19,10 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var TransactionCallBuilder = exports.TransactionCallBuilder = function (_CallBuilder) {
22
- function TransactionCallBuilder(serverUrl) {
22
+ function TransactionCallBuilder(serverUrl, httpClient) {
23
23
  var _this;
24
24
  _classCallCheck(this, TransactionCallBuilder);
25
- _this = _callSuper(this, TransactionCallBuilder, [serverUrl, "transactions"]);
25
+ _this = _callSuper(this, TransactionCallBuilder, [serverUrl, httpClient, "transactions"]);
26
26
  _this.url.segment("transactions");
27
27
  return _this;
28
28
  }
@@ -30,7 +30,7 @@ var TransactionCallBuilder = exports.TransactionCallBuilder = function (_CallBui
30
30
  return _createClass(TransactionCallBuilder, [{
31
31
  key: "transaction",
32
32
  value: function transaction(transactionId) {
33
- var builder = new _call_builder.CallBuilder(this.url.clone());
33
+ var builder = new _call_builder.CallBuilder(this.url.clone(), this.httpClient);
34
34
  builder.filter.push([transactionId]);
35
35
  return builder;
36
36
  }
@@ -1,4 +1,3 @@
1
1
  import { HttpClient } from "../http-client";
2
2
  export declare const version: string;
3
- export declare const AxiosClient: HttpClient;
4
- export default AxiosClient;
3
+ export declare function createHttpClient(headers?: Record<string, string>): HttpClient;
@@ -3,13 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.version = exports.default = exports.AxiosClient = void 0;
6
+ exports.createHttpClient = createHttpClient;
7
+ exports.version = void 0;
7
8
  var _httpClient = require("../http-client");
8
- var version = exports.version = "14.3.0";
9
- var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
10
- headers: {
11
- "X-Client-Name": "js-soroban-client",
12
- "X-Client-Version": version
13
- }
14
- });
15
- var _default = exports.default = AxiosClient;
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ var version = exports.version = "14.3.1";
16
+ function createHttpClient(headers) {
17
+ return (0, _httpClient.create)({
18
+ headers: _objectSpread(_objectSpread({}, headers), {}, {
19
+ "X-Client-Name": "js-stellar-sdk",
20
+ "X-Client-Version": version
21
+ })
22
+ });
23
+ }
@@ -1,7 +1,6 @@
1
1
  /** @module rpc */
2
2
  export * from "./api";
3
3
  export { RpcServer as Server, BasicSleepStrategy, LinearSleepStrategy, Durability, } from "./server";
4
- export { default as AxiosClient } from "./axios";
5
4
  export { parseRawSimulation, parseRawEvents } from "./parsers";
6
5
  export * from "./transaction";
7
6
  declare const _default: any;
@@ -8,16 +8,9 @@ var _exportNames = {
8
8
  BasicSleepStrategy: true,
9
9
  LinearSleepStrategy: true,
10
10
  Durability: true,
11
- AxiosClient: true,
12
11
  parseRawSimulation: true,
13
12
  parseRawEvents: true
14
13
  };
15
- Object.defineProperty(exports, "AxiosClient", {
16
- enumerable: true,
17
- get: function get() {
18
- return _axios.default;
19
- }
20
- });
21
14
  Object.defineProperty(exports, "BasicSleepStrategy", {
22
15
  enumerable: true,
23
16
  get: function get() {
@@ -68,7 +61,6 @@ Object.keys(_api).forEach(function (key) {
68
61
  });
69
62
  });
70
63
  var _server = require("./server");
71
- var _axios = _interopRequireDefault(require("./axios"));
72
64
  var _parsers = require("./parsers");
73
65
  var _transaction = require("./transaction");
74
66
  Object.keys(_transaction).forEach(function (key) {
@@ -82,5 +74,4 @@ Object.keys(_transaction).forEach(function (key) {
82
74
  }
83
75
  });
84
76
  });
85
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
86
77
  var _default = exports.default = module.exports;
@@ -1,3 +1,4 @@
1
+ import { HttpClient } from "../http-client";
1
2
  export type Id = string | number;
2
3
  export interface Request<T> {
3
4
  jsonrpc: "2.0";
@@ -32,4 +33,4 @@ export interface Error<E = any> {
32
33
  * @returns {Promise<T>}
33
34
  * @private
34
35
  */
35
- export declare function postObject<T>(url: string, method: string, param?: any): Promise<T>;
36
+ export declare function postObject<T>(client: HttpClient, url: string, method: string, param?: any): Promise<T>;
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.postObject = postObject;
7
- var _axios = _interopRequireDefault(require("./axios"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
7
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
10
8
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
11
9
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
@@ -13,11 +11,11 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
13
11
  function hasOwnProperty(obj, prop) {
14
12
  return obj.hasOwnProperty(prop);
15
13
  }
16
- function postObject(_x, _x2) {
14
+ function postObject(_x, _x2, _x3) {
17
15
  return _postObject.apply(this, arguments);
18
16
  }
19
17
  function _postObject() {
20
- _postObject = _asyncToGenerator(_regenerator().m(function _callee(url, method) {
18
+ _postObject = _asyncToGenerator(_regenerator().m(function _callee(client, url, method) {
21
19
  var param,
22
20
  response,
23
21
  _response$data,
@@ -25,9 +23,9 @@ function _postObject() {
25
23
  return _regenerator().w(function (_context) {
26
24
  while (1) switch (_context.n) {
27
25
  case 0:
28
- param = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
26
+ param = _args.length > 3 && _args[3] !== undefined ? _args[3] : null;
29
27
  _context.n = 1;
30
- return _axios.default.post(url, {
28
+ return client.post(url, {
31
29
  jsonrpc: "2.0",
32
30
  id: 1,
33
31
  method: method,
@@ -1,6 +1,7 @@
1
1
  import URI from "urijs";
2
2
  import { Account, Address, Asset, Contract, FeeBumpTransaction, Transaction, xdr } from "@stellar/stellar-base";
3
3
  import { Api } from "./api";
4
+ import { HttpClient } from "../http-client";
4
5
  /**
5
6
  * Default transaction submission timeout for RPC requests, in milliseconds
6
7
  * @constant {number}
@@ -42,9 +43,24 @@ export declare namespace RpcServer {
42
43
  attempts?: number;
43
44
  sleepStrategy?: SleepStrategy;
44
45
  }
46
+ /**
47
+ * Describes additional resource leeways for transaction simulation.
48
+ * @property {number} cpuInstructions Simulate the transaction with more CPU instructions available.
49
+ * @memberof module:rpc.Server
50
+ */
45
51
  interface ResourceLeeway {
46
52
  cpuInstructions: number;
47
53
  }
54
+ /**
55
+ * Options for configuring connections to RPC servers.
56
+ *
57
+ * @property {boolean} allowHttp - Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
58
+ * @property {number} timeout - Allow a timeout, default: 0. Allows user to avoid nasty lag.
59
+ * @property {Record<string, string>} headers - Additional headers that should be added to any requests to the RPC server.
60
+ *
61
+ * @alias module:rpc.Server.Options
62
+ * @memberof module:rpc.Server
63
+ */
48
64
  interface Options {
49
65
  allowHttp?: boolean;
50
66
  timeout?: number;
@@ -76,6 +92,21 @@ export type SleepStrategy = (iter: number) => number;
76
92
  */
77
93
  export declare class RpcServer {
78
94
  readonly serverURL: URI;
95
+ /**
96
+ * HTTP client instance for making requests to Horizon.
97
+ * Exposes interceptors, defaults, and other configuration options.
98
+ *
99
+ * @example
100
+ * // Add authentication header
101
+ * server.httpClient.defaults.headers['Authorization'] = 'Bearer token';
102
+ *
103
+ * // Add request interceptor
104
+ * server.httpClient.interceptors.request.use((config) => {
105
+ * console.log('Request:', config.url);
106
+ * return config;
107
+ * });
108
+ */
109
+ readonly httpClient: HttpClient;
79
110
  constructor(serverURL: string, opts?: RpcServer.Options);
80
111
  /**
81
112
  * Fetch a minimal set of current info about a Stellar account.