@stellar/stellar-sdk 11.0.0

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 (112) hide show
  1. package/CHANGELOG.md +1275 -0
  2. package/LICENSE +228 -0
  3. package/README.md +274 -0
  4. package/dist/stellar-sdk.js +56470 -0
  5. package/dist/stellar-sdk.min.js +2 -0
  6. package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
  7. package/lib/browser.d.ts +6 -0
  8. package/lib/browser.js +37 -0
  9. package/lib/config.d.ts +52 -0
  10. package/lib/config.js +49 -0
  11. package/lib/contract_spec.d.ts +130 -0
  12. package/lib/contract_spec.js +549 -0
  13. package/lib/errors.d.ts +59 -0
  14. package/lib/errors.js +105 -0
  15. package/lib/federation/api.d.ts +11 -0
  16. package/lib/federation/api.js +7 -0
  17. package/lib/federation/index.d.ts +2 -0
  18. package/lib/federation/index.js +24 -0
  19. package/lib/federation/server.d.ts +118 -0
  20. package/lib/federation/server.js +253 -0
  21. package/lib/friendbot/index.d.ts +5 -0
  22. package/lib/friendbot/index.js +7 -0
  23. package/lib/horizon/account_call_builder.d.ts +55 -0
  24. package/lib/horizon/account_call_builder.js +64 -0
  25. package/lib/horizon/account_response.d.ts +58 -0
  26. package/lib/horizon/account_response.js +50 -0
  27. package/lib/horizon/assets_call_builder.d.ts +27 -0
  28. package/lib/horizon/assets_call_builder.js +45 -0
  29. package/lib/horizon/call_builder.d.ts +128 -0
  30. package/lib/horizon/call_builder.js +360 -0
  31. package/lib/horizon/claimable_balances_call_builder.d.ts +49 -0
  32. package/lib/horizon/claimable_balances_call_builder.js +58 -0
  33. package/lib/horizon/effect_call_builder.d.ts +53 -0
  34. package/lib/horizon/effect_call_builder.js +58 -0
  35. package/lib/horizon/friendbot_builder.d.ts +5 -0
  36. package/lib/horizon/friendbot_builder.js +33 -0
  37. package/lib/horizon/horizon_api.d.ts +523 -0
  38. package/lib/horizon/horizon_api.js +96 -0
  39. package/lib/horizon/horizon_axios_client.d.ts +30 -0
  40. package/lib/horizon/horizon_axios_client.js +48 -0
  41. package/lib/horizon/index.d.ts +7 -0
  42. package/lib/horizon/index.js +78 -0
  43. package/lib/horizon/ledger_call_builder.d.ts +22 -0
  44. package/lib/horizon/ledger_call_builder.js +39 -0
  45. package/lib/horizon/liquidity_pool_call_builder.d.ts +38 -0
  46. package/lib/horizon/liquidity_pool_call_builder.js +61 -0
  47. package/lib/horizon/offer_call_builder.d.ts +64 -0
  48. package/lib/horizon/offer_call_builder.js +81 -0
  49. package/lib/horizon/operation_call_builder.d.ts +68 -0
  50. package/lib/horizon/operation_call_builder.js +71 -0
  51. package/lib/horizon/orderbook_call_builder.d.ts +16 -0
  52. package/lib/horizon/orderbook_call_builder.js +46 -0
  53. package/lib/horizon/path_call_builder.d.ts +31 -0
  54. package/lib/horizon/path_call_builder.js +42 -0
  55. package/lib/horizon/payment_call_builder.d.ts +36 -0
  56. package/lib/horizon/payment_call_builder.js +48 -0
  57. package/lib/horizon/server.d.ts +361 -0
  58. package/lib/horizon/server.js +507 -0
  59. package/lib/horizon/server_api.d.ts +279 -0
  60. package/lib/horizon/server_api.js +19 -0
  61. package/lib/horizon/strict_receive_path_call_builder.d.ts +34 -0
  62. package/lib/horizon/strict_receive_path_call_builder.js +51 -0
  63. package/lib/horizon/strict_send_path_call_builder.d.ts +34 -0
  64. package/lib/horizon/strict_send_path_call_builder.js +51 -0
  65. package/lib/horizon/trade_aggregation_call_builder.d.ts +48 -0
  66. package/lib/horizon/trade_aggregation_call_builder.js +82 -0
  67. package/lib/horizon/trades_call_builder.d.ts +50 -0
  68. package/lib/horizon/trades_call_builder.js +74 -0
  69. package/lib/horizon/transaction_call_builder.d.ts +58 -0
  70. package/lib/horizon/transaction_call_builder.js +66 -0
  71. package/lib/horizon/types/account.d.ts +5 -0
  72. package/lib/horizon/types/account.js +5 -0
  73. package/lib/horizon/types/assets.d.ts +19 -0
  74. package/lib/horizon/types/assets.js +5 -0
  75. package/lib/horizon/types/effects.d.ts +285 -0
  76. package/lib/horizon/types/effects.js +62 -0
  77. package/lib/horizon/types/offer.d.ts +20 -0
  78. package/lib/horizon/types/offer.js +5 -0
  79. package/lib/horizon/types/trade.d.ts +13 -0
  80. package/lib/horizon/types/trade.js +5 -0
  81. package/lib/index.d.ts +14 -0
  82. package/lib/index.js +79 -0
  83. package/lib/soroban/api.d.ts +247 -0
  84. package/lib/soroban/api.js +32 -0
  85. package/lib/soroban/axios.d.ts +3 -0
  86. package/lib/soroban/axios.js +16 -0
  87. package/lib/soroban/browser.d.ts +6 -0
  88. package/lib/soroban/browser.js +37 -0
  89. package/lib/soroban/index.d.ts +8 -0
  90. package/lib/soroban/index.js +72 -0
  91. package/lib/soroban/jsonrpc.d.ts +33 -0
  92. package/lib/soroban/jsonrpc.js +93 -0
  93. package/lib/soroban/parsers.d.ts +17 -0
  94. package/lib/soroban/parsers.js +111 -0
  95. package/lib/soroban/server.d.ts +427 -0
  96. package/lib/soroban/server.js +598 -0
  97. package/lib/soroban/transaction.d.ts +20 -0
  98. package/lib/soroban/transaction.js +55 -0
  99. package/lib/soroban/utils.d.ts +1 -0
  100. package/lib/soroban/utils.js +9 -0
  101. package/lib/stellartoml/index.d.ts +121 -0
  102. package/lib/stellartoml/index.js +78 -0
  103. package/lib/utils.d.ts +12 -0
  104. package/lib/utils.js +32 -0
  105. package/lib/webauth/errors.d.ts +4 -0
  106. package/lib/webauth/errors.js +37 -0
  107. package/lib/webauth/index.d.ts +2 -0
  108. package/lib/webauth/index.js +27 -0
  109. package/lib/webauth/utils.d.ts +294 -0
  110. package/lib/webauth/utils.js +332 -0
  111. package/package.json +153 -0
  112. package/types/dom-monkeypatch.d.ts +126 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.OrderbookCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ var OrderbookCallBuilder = exports.OrderbookCallBuilder = function (_CallBuilder) {
22
+ _inherits(OrderbookCallBuilder, _CallBuilder);
23
+ var _super = _createSuper(OrderbookCallBuilder);
24
+ function OrderbookCallBuilder(serverUrl, selling, buying) {
25
+ var _this;
26
+ _classCallCheck(this, OrderbookCallBuilder);
27
+ _this = _super.call(this, serverUrl);
28
+ _this.url.segment("order_book");
29
+ if (!selling.isNative()) {
30
+ _this.url.setQuery("selling_asset_type", selling.getAssetType());
31
+ _this.url.setQuery("selling_asset_code", selling.getCode());
32
+ _this.url.setQuery("selling_asset_issuer", selling.getIssuer());
33
+ } else {
34
+ _this.url.setQuery("selling_asset_type", "native");
35
+ }
36
+ if (!buying.isNative()) {
37
+ _this.url.setQuery("buying_asset_type", buying.getAssetType());
38
+ _this.url.setQuery("buying_asset_code", buying.getCode());
39
+ _this.url.setQuery("buying_asset_issuer", buying.getIssuer());
40
+ } else {
41
+ _this.url.setQuery("buying_asset_type", "native");
42
+ }
43
+ return _this;
44
+ }
45
+ return _createClass(OrderbookCallBuilder);
46
+ }(_call_builder.CallBuilder);
@@ -0,0 +1,31 @@
1
+ /// <reference types="urijs" />
2
+ import { Asset } from "@stellar/stellar-base";
3
+ import { CallBuilder } from "./call_builder";
4
+ import { ServerApi } from "./server_api";
5
+ /**
6
+ * The Stellar Network allows payments to be made across assets through path payments. A path payment specifies a
7
+ * series of assets to route a payment through, from source asset (the asset debited from the payer) to destination
8
+ * asset (the asset credited to the payee).
9
+ *
10
+ * A path search is specified using:
11
+ *
12
+ * * The destination address
13
+ * * The source address
14
+ * * The asset and amount that the destination account should receive
15
+ *
16
+ * As part of the search, horizon will load a list of assets available to the source address and will find any
17
+ * payment paths from those source assets to the desired destination asset. The search's amount parameter will be
18
+ * used to determine if there a given path can satisfy a payment of the desired amount.
19
+ *
20
+ * Do not create this object directly, use {@link Server#paths}.
21
+ * @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
22
+ * @extends CallBuilder
23
+ * @param {string} serverUrl Horizon server URL.
24
+ * @param {string} source The sender's account ID. Any returned path must use a source that the sender can hold.
25
+ * @param {string} destination The destination account ID that any returned path should use.
26
+ * @param {Asset} destinationAsset The destination asset.
27
+ * @param {string} destinationAmount The amount, denominated in the destination asset, that any returned path should be able to satisfy.
28
+ */
29
+ export declare class PathCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentPathRecord>> {
30
+ constructor(serverUrl: URI, source: string, destination: string, destinationAsset: Asset, destinationAmount: string);
31
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PathCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ var PathCallBuilder = exports.PathCallBuilder = function (_CallBuilder) {
22
+ _inherits(PathCallBuilder, _CallBuilder);
23
+ var _super = _createSuper(PathCallBuilder);
24
+ function PathCallBuilder(serverUrl, source, destination, destinationAsset, destinationAmount) {
25
+ var _this;
26
+ _classCallCheck(this, PathCallBuilder);
27
+ _this = _super.call(this, serverUrl);
28
+ _this.url.segment("paths");
29
+ _this.url.setQuery("destination_account", destination);
30
+ _this.url.setQuery("source_account", source);
31
+ _this.url.setQuery("destination_amount", destinationAmount);
32
+ if (!destinationAsset.isNative()) {
33
+ _this.url.setQuery("destination_asset_type", destinationAsset.getAssetType());
34
+ _this.url.setQuery("destination_asset_code", destinationAsset.getCode());
35
+ _this.url.setQuery("destination_asset_issuer", destinationAsset.getIssuer());
36
+ } else {
37
+ _this.url.setQuery("destination_asset_type", "native");
38
+ }
39
+ return _this;
40
+ }
41
+ return _createClass(PathCallBuilder);
42
+ }(_call_builder.CallBuilder);
@@ -0,0 +1,36 @@
1
+ /// <reference types="urijs" />
2
+ import { CallBuilder } from "./call_builder";
3
+ import { ServerApi } from "./server_api";
4
+ /**
5
+ * Creates a new {@link PaymentCallBuilder} pointed to server defined by serverUrl.
6
+ *
7
+ * Do not create this object directly, use {@link Server#payments}.
8
+ * @see [All Payments](https://developers.stellar.org/api/horizon/resources/list-all-payments/)
9
+ * @constructor
10
+ * @extends CallBuilder
11
+ * @param {string} serverUrl Horizon server URL.
12
+ */
13
+ export declare class PaymentCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentOperationRecord | ServerApi.CreateAccountOperationRecord | ServerApi.AccountMergeOperationRecord | ServerApi.PathPaymentOperationRecord | ServerApi.PathPaymentStrictSendOperationRecord | ServerApi.InvokeHostFunctionOperationRecord>> {
14
+ constructor(serverUrl: URI);
15
+ /**
16
+ * This endpoint responds with a collection of Payment operations where the given account was either the sender or receiver.
17
+ * @see [Payments for Account](https://developers.stellar.org/api/horizon/resources/get-payments-by-account-id)
18
+ * @param {string} accountId For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
19
+ * @returns {PaymentCallBuilder} this PaymentCallBuilder instance
20
+ */
21
+ forAccount(accountId: string): this;
22
+ /**
23
+ * This endpoint represents all payment operations that are part of a valid transactions in a given ledger.
24
+ * @see [Payments for Ledger](https://developers.stellar.org/api/horizon/resources/retrieve-a-ledgers-payments)
25
+ * @param {number|string} sequence Ledger sequence
26
+ * @returns {PaymentCallBuilder} this PaymentCallBuilder instance
27
+ */
28
+ forLedger(sequence: number | string): this;
29
+ /**
30
+ * This endpoint represents all payment operations that are part of a given transaction.
31
+ * @see [Payments for Transaction](https://developers.stellar.org/api/resources/transactions/payments/)
32
+ * @param {string} transactionId Transaction ID
33
+ * @returns {PaymentCallBuilder} this PaymentCallBuilder instance
34
+ */
35
+ forTransaction(transactionId: string): this;
36
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PaymentCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ var PaymentCallBuilder = exports.PaymentCallBuilder = function (_CallBuilder) {
22
+ _inherits(PaymentCallBuilder, _CallBuilder);
23
+ var _super = _createSuper(PaymentCallBuilder);
24
+ function PaymentCallBuilder(serverUrl) {
25
+ var _this;
26
+ _classCallCheck(this, PaymentCallBuilder);
27
+ _this = _super.call(this, serverUrl, "payments");
28
+ _this.url.segment("payments");
29
+ return _this;
30
+ }
31
+ _createClass(PaymentCallBuilder, [{
32
+ key: "forAccount",
33
+ value: function forAccount(accountId) {
34
+ return this.forEndpoint("accounts", accountId);
35
+ }
36
+ }, {
37
+ key: "forLedger",
38
+ value: function forLedger(sequence) {
39
+ return this.forEndpoint("ledgers", sequence.toString());
40
+ }
41
+ }, {
42
+ key: "forTransaction",
43
+ value: function forTransaction(transactionId) {
44
+ return this.forEndpoint("transactions", transactionId);
45
+ }
46
+ }]);
47
+ return PaymentCallBuilder;
48
+ }(_call_builder.CallBuilder);
@@ -0,0 +1,361 @@
1
+ import { Asset, FeeBumpTransaction, Transaction } from "@stellar/stellar-base";
2
+ import URI from "urijs";
3
+ import { AccountCallBuilder } from "./account_call_builder";
4
+ import { AccountResponse } from "./account_response";
5
+ import { AssetsCallBuilder } from "./assets_call_builder";
6
+ import { ClaimableBalanceCallBuilder } from "./claimable_balances_call_builder";
7
+ import { EffectCallBuilder } from "./effect_call_builder";
8
+ import { FriendbotBuilder } from "./friendbot_builder";
9
+ import { HorizonApi } from "./horizon_api";
10
+ import { LedgerCallBuilder } from "./ledger_call_builder";
11
+ import { LiquidityPoolCallBuilder } from "./liquidity_pool_call_builder";
12
+ import { OfferCallBuilder } from "./offer_call_builder";
13
+ import { OperationCallBuilder } from "./operation_call_builder";
14
+ import { OrderbookCallBuilder } from "./orderbook_call_builder";
15
+ import { PathCallBuilder } from "./path_call_builder";
16
+ import { PaymentCallBuilder } from "./payment_call_builder";
17
+ import { TradeAggregationCallBuilder } from "./trade_aggregation_call_builder";
18
+ import { TradesCallBuilder } from "./trades_call_builder";
19
+ import { TransactionCallBuilder } from "./transaction_call_builder";
20
+ export declare const SUBMIT_TRANSACTION_TIMEOUT: number;
21
+ /**
22
+ * Server handles the network connection to a [Horizon](https://developers.stellar.org/api/introduction/)
23
+ * instance and exposes an interface for requests to that instance.
24
+ * @constructor
25
+ * @param {string} serverURL Horizon Server URL (ex. `https://horizon-testnet.stellar.org`).
26
+ * @param {object} [opts] Options object
27
+ * @param {boolean} [opts.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.
28
+ * @param {string} [opts.appName] - Allow set custom header `X-App-Name`, default: `undefined`.
29
+ * @param {string} [opts.appVersion] - Allow set custom header `X-App-Version`, default: `undefined`.
30
+ * @param {string} [opts.authToken] - Allow set custom header `X-Auth-Token`, default: `undefined`.
31
+ */
32
+ export declare class Server {
33
+ /**
34
+ * serverURL Horizon Server URL (ex. `https://horizon-testnet.stellar.org`).
35
+ *
36
+ * TODO: Solve `URI(this.serverURL as any)`.
37
+ */
38
+ readonly serverURL: URI;
39
+ constructor(serverURL: string, opts?: Server.Options);
40
+ /**
41
+ * Get timebounds for N seconds from now, when you're creating a transaction
42
+ * with {@link TransactionBuilder}.
43
+ *
44
+ * By default, {@link TransactionBuilder} uses the current local time, but
45
+ * your machine's local time could be different from Horizon's. This gives you
46
+ * more assurance that your timebounds will reflect what you want.
47
+ *
48
+ * Note that this will generate your timebounds when you **init the transaction**,
49
+ * not when you build or submit the transaction! So give yourself enough time to get
50
+ * the transaction built and signed before submitting.
51
+ *
52
+ * Example:
53
+ *
54
+ * ```javascript
55
+ * const transaction = new StellarSdk.TransactionBuilder(accountId, {
56
+ * fee: await StellarSdk.Server.fetchBaseFee(),
57
+ * timebounds: await StellarSdk.Server.fetchTimebounds(100)
58
+ * })
59
+ * .addOperation(operation)
60
+ * // normally we would need to call setTimeout here, but setting timebounds
61
+ * // earlier does the trick!
62
+ * .build();
63
+ * ```
64
+ * @argument {number} seconds Number of seconds past the current time to wait.
65
+ * @argument {bool} [_isRetry=false] True if this is a retry. Only set this internally!
66
+ * This is to avoid a scenario where Horizon is horking up the wrong date.
67
+ * @returns {Promise<Timebounds>} Promise that resolves a `timebounds` object
68
+ * (with the shape `{ minTime: 0, maxTime: N }`) that you can set the `timebounds` option to.
69
+ */
70
+ fetchTimebounds(seconds: number, _isRetry?: boolean): Promise<Server.Timebounds>;
71
+ /**
72
+ * Fetch the base fee. Since this hits the server, if the server call fails,
73
+ * you might get an error. You should be prepared to use a default value if
74
+ * that happens!
75
+ * @returns {Promise<number>} Promise that resolves to the base fee.
76
+ */
77
+ fetchBaseFee(): Promise<number>;
78
+ /**
79
+ * Fetch the fee stats endpoint.
80
+ * @see [Fee Stats](https://developers.stellar.org/api/aggregations/fee-stats/)
81
+ * @returns {Promise<HorizonApi.FeeStatsResponse>} Promise that resolves to the fee stats returned by Horizon.
82
+ */
83
+ feeStats(): Promise<HorizonApi.FeeStatsResponse>;
84
+ /**
85
+ * Submits a transaction to the network.
86
+ *
87
+ * By default this function calls {@link Server#checkMemoRequired}, you can
88
+ * skip this check by setting the option `skipMemoRequiredCheck` to `true`.
89
+ *
90
+ * If you submit any number of `manageOffer` operations, this will add an
91
+ * attribute to the response that will help you analyze what happened with
92
+ * your offers.
93
+ *
94
+ * Ex:
95
+ * ```javascript
96
+ * const res = {
97
+ * ...response,
98
+ * offerResults: [
99
+ * {
100
+ * // Exact ordered list of offers that executed, with the exception
101
+ * // that the last one may not have executed entirely.
102
+ * offersClaimed: [
103
+ * sellerId: String,
104
+ * offerId: String,
105
+ * assetSold: {
106
+ * type: 'native|credit_alphanum4|credit_alphanum12',
107
+ *
108
+ * // these are only present if the asset is not native
109
+ * assetCode: String,
110
+ * issuer: String,
111
+ * },
112
+ *
113
+ * // same shape as assetSold
114
+ * assetBought: {}
115
+ * ],
116
+ *
117
+ * // What effect your manageOffer op had
118
+ * effect: "manageOfferCreated|manageOfferUpdated|manageOfferDeleted",
119
+ *
120
+ * // Whether your offer immediately got matched and filled
121
+ * wasImmediatelyFilled: Boolean,
122
+ *
123
+ * // Whether your offer immediately got deleted, if for example the order was too small
124
+ * wasImmediatelyDeleted: Boolean,
125
+ *
126
+ * // Whether the offer was partially, but not completely, filled
127
+ * wasPartiallyFilled: Boolean,
128
+ *
129
+ * // The full requested amount of the offer is open for matching
130
+ * isFullyOpen: Boolean,
131
+ *
132
+ * // The total amount of tokens bought / sold during transaction execution
133
+ * amountBought: Number,
134
+ * amountSold: Number,
135
+ *
136
+ * // if the offer was created, updated, or partially filled, this is
137
+ * // the outstanding offer
138
+ * currentOffer: {
139
+ * offerId: String,
140
+ * amount: String,
141
+ * price: {
142
+ * n: String,
143
+ * d: String,
144
+ * },
145
+ *
146
+ * selling: {
147
+ * type: 'native|credit_alphanum4|credit_alphanum12',
148
+ *
149
+ * // these are only present if the asset is not native
150
+ * assetCode: String,
151
+ * issuer: String,
152
+ * },
153
+ *
154
+ * // same as `selling`
155
+ * buying: {},
156
+ * },
157
+ *
158
+ * // the index of this particular operation in the op stack
159
+ * operationIndex: Number
160
+ * }
161
+ * ]
162
+ * }
163
+ * ```
164
+ *
165
+ * For example, you'll want to examine `offerResults` to add affordances like
166
+ * these to your app:
167
+ * * If `wasImmediatelyFilled` is true, then no offer was created. So if you
168
+ * normally watch the `Server.offers` endpoint for offer updates, you
169
+ * instead need to check `Server.trades` to find the result of this filled
170
+ * offer.
171
+ * * If `wasImmediatelyDeleted` is true, then the offer you submitted was
172
+ * deleted without reaching the orderbook or being matched (possibly because
173
+ * your amounts were rounded down to zero). So treat the just-submitted
174
+ * offer request as if it never happened.
175
+ * * If `wasPartiallyFilled` is true, you can tell the user that
176
+ * `amountBought` or `amountSold` have already been transferred.
177
+ *
178
+ * @see [Post
179
+ * Transaction](https://developers.stellar.org/api/resources/transactions/post/)
180
+ * @param {Transaction|FeeBumpTransaction} transaction - The transaction to submit.
181
+ * @param {object} [opts] Options object
182
+ * @param {boolean} [opts.skipMemoRequiredCheck] - Allow skipping memo
183
+ * required check, default: `false`. See
184
+ * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md).
185
+ * @returns {Promise} Promise that resolves or rejects with response from
186
+ * horizon.
187
+ */
188
+ submitTransaction(transaction: Transaction | FeeBumpTransaction, opts?: Server.SubmitTransactionOptions): Promise<HorizonApi.SubmitTransactionResponse>;
189
+ /**
190
+ * @returns {AccountCallBuilder} New {@link AccountCallBuilder} object configured by a current Horizon server configuration.
191
+ */
192
+ accounts(): AccountCallBuilder;
193
+ /**
194
+ * @returns {ClaimableBalanceCallBuilder} New {@link ClaimableBalanceCallBuilder} object configured by a current Horizon server configuration.
195
+ */
196
+ claimableBalances(): ClaimableBalanceCallBuilder;
197
+ /**
198
+ * @returns {LedgerCallBuilder} New {@link LedgerCallBuilder} object configured by a current Horizon server configuration.
199
+ */
200
+ ledgers(): LedgerCallBuilder;
201
+ /**
202
+ * @returns {TransactionCallBuilder} New {@link TransactionCallBuilder} object configured by a current Horizon server configuration.
203
+ */
204
+ transactions(): TransactionCallBuilder;
205
+ /**
206
+ * People on the Stellar network can make offers to buy or sell assets. This endpoint represents all the offers on the DEX.
207
+ *
208
+ * You can query all offers for account using the function `.accountId`:
209
+ *
210
+ * ```
211
+ * server.offers()
212
+ * .forAccount(accountId).call()
213
+ * .then(function(offers) {
214
+ * console.log(offers);
215
+ * });
216
+ * ```
217
+ * @returns {OfferCallBuilder} New {@link OfferCallBuilder} object
218
+ */
219
+ offers(): OfferCallBuilder;
220
+ /**
221
+ * @param {Asset} selling Asset being sold
222
+ * @param {Asset} buying Asset being bought
223
+ * @returns {OrderbookCallBuilder} New {@link OrderbookCallBuilder} object configured by a current Horizon server configuration.
224
+ */
225
+ orderbook(selling: Asset, buying: Asset): OrderbookCallBuilder;
226
+ /**
227
+ * Returns
228
+ * @returns {TradesCallBuilder} New {@link TradesCallBuilder} object configured by a current Horizon server configuration.
229
+ */
230
+ trades(): TradesCallBuilder;
231
+ /**
232
+ * @returns {OperationCallBuilder} New {@link OperationCallBuilder} object configured by a current Horizon server configuration.
233
+ */
234
+ operations(): OperationCallBuilder;
235
+ /**
236
+ * @returns {LiquidityPoolCallBuilder} New {@link LiquidityPoolCallBuilder}
237
+ * object configured to the current Horizon server settings.
238
+ */
239
+ liquidityPools(): LiquidityPoolCallBuilder;
240
+ /**
241
+ * The Stellar Network allows payments to be made between assets through path
242
+ * payments. A strict receive path payment specifies a series of assets to
243
+ * route a payment through, from source asset (the asset debited from the
244
+ * payer) to destination asset (the asset credited to the payee).
245
+ *
246
+ * A strict receive path search is specified using:
247
+ *
248
+ * * The destination address.
249
+ * * The source address or source assets.
250
+ * * The asset and amount that the destination account should receive.
251
+ *
252
+ * As part of the search, horizon will load a list of assets available to the
253
+ * source address and will find any payment paths from those source assets to
254
+ * the desired destination asset. The search's amount parameter will be used
255
+ * to determine if there a given path can satisfy a payment of the desired
256
+ * amount.
257
+ *
258
+ * If a list of assets is passed as the source, horizon will find any payment
259
+ * paths from those source assets to the desired destination asset.
260
+ *
261
+ * @param {string|Asset[]} source The sender's account ID or a list of assets. Any returned path will use a source that the sender can hold.
262
+ * @param {Asset} destinationAsset The destination asset.
263
+ * @param {string} destinationAmount The amount, denominated in the destination asset, that any returned path should be able to satisfy.
264
+ * @returns {StrictReceivePathCallBuilder} New {@link StrictReceivePathCallBuilder} object configured with the current Horizon server configuration.
265
+ */
266
+ strictReceivePaths(source: string | Asset[], destinationAsset: Asset, destinationAmount: string): PathCallBuilder;
267
+ /**
268
+ * The Stellar Network allows payments to be made between assets through path payments. A strict send path payment specifies a
269
+ * series of assets to route a payment through, from source asset (the asset debited from the payer) to destination
270
+ * asset (the asset credited to the payee).
271
+ *
272
+ * A strict send path search is specified using:
273
+ *
274
+ * The asset and amount that is being sent.
275
+ * The destination account or the destination assets.
276
+ *
277
+ * @param {Asset} sourceAsset The asset to be sent.
278
+ * @param {string} sourceAmount The amount, denominated in the source asset, that any returned path should be able to satisfy.
279
+ * @param {string|Asset[]} destination The destination account or the destination assets.
280
+ * @returns {StrictSendPathCallBuilder} New {@link StrictSendPathCallBuilder} object configured with the current Horizon server configuration.
281
+ */
282
+ strictSendPaths(sourceAsset: Asset, sourceAmount: string, destination: string | Asset[]): PathCallBuilder;
283
+ /**
284
+ * @returns {PaymentCallBuilder} New {@link PaymentCallBuilder} instance configured with the current
285
+ * Horizon server configuration.
286
+ */
287
+ payments(): PaymentCallBuilder;
288
+ /**
289
+ * @returns {EffectCallBuilder} New {@link EffectCallBuilder} instance configured with the current
290
+ * Horizon server configuration
291
+ */
292
+ effects(): EffectCallBuilder;
293
+ /**
294
+ * @param {string} address The Stellar ID that you want Friendbot to send lumens to
295
+ * @returns {FriendbotBuilder} New {@link FriendbotBuilder} instance configured with the current
296
+ * Horizon server configuration
297
+ * @private
298
+ */
299
+ friendbot(address: string): FriendbotBuilder;
300
+ /**
301
+ * Get a new {@link AssetsCallBuilder} instance configured with the current
302
+ * Horizon server configuration.
303
+ * @returns {AssetsCallBuilder} New AssetsCallBuilder instance
304
+ */
305
+ assets(): AssetsCallBuilder;
306
+ /**
307
+ * Fetches an account's most current state in the ledger, then creates and
308
+ * returns an {@link AccountResponse} object.
309
+ *
310
+ * @param {string} accountId - The account to load.
311
+ *
312
+ * @returns {Promise} Returns a promise to the {@link AccountResponse} object
313
+ * with populated sequence number.
314
+ */
315
+ loadAccount(accountId: string): Promise<AccountResponse>;
316
+ /**
317
+ *
318
+ * @param {Asset} base base asset
319
+ * @param {Asset} counter counter asset
320
+ * @param {long} start_time lower time boundary represented as millis since epoch
321
+ * @param {long} end_time upper time boundary represented as millis since epoch
322
+ * @param {long} resolution segment duration as millis since epoch. *Supported values are 5 minutes (300000), 15 minutes (900000), 1 hour (3600000), 1 day (86400000) and 1 week (604800000).
323
+ * @param {long} 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.
324
+ * Returns new {@link TradeAggregationCallBuilder} object configured with the current Horizon server configuration.
325
+ * @returns {TradeAggregationCallBuilder} New TradeAggregationCallBuilder instance
326
+ */
327
+ tradeAggregation(base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number): TradeAggregationCallBuilder;
328
+ /**
329
+ * Check if any of the destination accounts requires a memo.
330
+ *
331
+ * This function implements a memo required check as defined in
332
+ * [SEP-29](https://stellar.org/protocol/sep-29). It will load each account
333
+ * which is the destination and check if it has the data field
334
+ * `config.memo_required` set to `"MQ=="`.
335
+ *
336
+ * Each account is checked sequentially instead of loading multiple accounts
337
+ * at the same time from Horizon.
338
+ *
339
+ * @see https://stellar.org/protocol/sep-29
340
+ * @param {Transaction} transaction - The transaction to check.
341
+ * @returns {Promise<void, Error>} - If any of the destination account
342
+ * requires a memo, the promise will throw {@link AccountRequiresMemoError}.
343
+ * @throws {AccountRequiresMemoError}
344
+ */
345
+ checkMemoRequired(transaction: Transaction | FeeBumpTransaction): Promise<void>;
346
+ }
347
+ export declare namespace Server {
348
+ interface Options {
349
+ allowHttp?: boolean;
350
+ appName?: string;
351
+ appVersion?: string;
352
+ authToken?: string;
353
+ }
354
+ interface Timebounds {
355
+ minTime: number;
356
+ maxTime: number;
357
+ }
358
+ interface SubmitTransactionOptions {
359
+ skipMemoRequiredCheck?: boolean;
360
+ }
361
+ }