@stellar/stellar-sdk 12.1.0 → 12.2.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.
- package/CHANGELOG.md +52 -0
- package/dist/stellar-sdk.js +848 -815
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/browser.d.ts +1 -1
- package/lib/browser.js +4 -4
- package/lib/config.js +5 -2
- package/lib/contract/assembled_transaction.d.ts +25 -27
- package/lib/contract/assembled_transaction.js +6 -6
- package/lib/contract/client.d.ts +0 -1
- package/lib/contract/client.js +2 -2
- package/lib/contract/index.d.ts +0 -1
- package/lib/contract/index.js +1 -18
- package/lib/contract/sent_transaction.d.ts +9 -10
- package/lib/contract/sent_transaction.js +2 -1
- package/lib/contract/spec.d.ts +1 -1
- package/lib/contract/spec.js +921 -956
- package/lib/contract/types.d.ts +5 -0
- package/lib/contract/types.js +4 -1
- package/lib/contract/utils.d.ts +0 -5
- package/lib/contract/utils.js +4 -18
- package/lib/errors.d.ts +4 -4
- package/lib/federation/server.d.ts +1 -1
- package/lib/horizon/account_call_builder.d.ts +2 -3
- package/lib/horizon/account_response.d.ts +1 -1
- package/lib/horizon/assets_call_builder.d.ts +2 -3
- package/lib/horizon/call_builder.d.ts +8 -8
- package/lib/horizon/call_builder.js +2 -6
- package/lib/horizon/claimable_balances_call_builder.d.ts +3 -4
- package/lib/horizon/effect_call_builder.d.ts +2 -3
- package/lib/horizon/friendbot_builder.d.ts +0 -1
- package/lib/horizon/horizon_api.d.ts +5 -1
- package/lib/horizon/horizon_axios_client.js +6 -6
- package/lib/horizon/ledger_call_builder.d.ts +2 -3
- package/lib/horizon/liquidity_pool_call_builder.d.ts +2 -4
- package/lib/horizon/offer_call_builder.d.ts +2 -3
- package/lib/horizon/operation_call_builder.d.ts +3 -4
- package/lib/horizon/orderbook_call_builder.d.ts +0 -1
- package/lib/horizon/path_call_builder.d.ts +1 -2
- package/lib/horizon/payment_call_builder.d.ts +2 -3
- package/lib/horizon/server.d.ts +29 -10
- package/lib/horizon/server.js +98 -55
- package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -2
- package/lib/horizon/strict_send_path_call_builder.d.ts +1 -2
- package/lib/horizon/trade_aggregation_call_builder.d.ts +9 -10
- package/lib/horizon/trade_aggregation_call_builder.js +3 -7
- package/lib/horizon/trades_call_builder.d.ts +2 -3
- package/lib/horizon/transaction_call_builder.d.ts +3 -4
- package/lib/horizon/types/assets.d.ts +1 -1
- package/lib/horizon/types/effects.d.ts +1 -1
- package/lib/horizon/types/offer.d.ts +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/rpc/api.d.ts +29 -5
- package/lib/rpc/browser.d.ts +1 -1
- package/lib/rpc/browser.js +4 -4
- package/lib/rpc/index.d.ts +0 -1
- package/lib/rpc/jsonrpc.js +3 -3
- package/lib/rpc/parsers.d.ts +3 -3
- package/lib/rpc/parsers.js +23 -23
- package/lib/rpc/server.d.ts +13 -7
- package/lib/rpc/server.js +48 -56
- package/lib/rpc/transaction.d.ts +3 -4
- package/lib/rpc/transaction.js +23 -25
- package/lib/webauth/utils.js +3 -3
- package/package.json +17 -17
package/lib/contract/types.d.ts
CHANGED
|
@@ -105,3 +105,8 @@ export type AssembledTransactionOptions<T = string> = MethodOptions & ClientOpti
|
|
|
105
105
|
args?: any[];
|
|
106
106
|
parseResultXdr: (xdr: xdr.ScVal) => T;
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* The default timeout for waiting for a transaction to be included in a block.
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEFAULT_TIMEOUT: number;
|
|
112
|
+
export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
package/lib/contract/types.js
CHANGED
|
@@ -2,4 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
exports.NULL_ACCOUNT = exports.DEFAULT_TIMEOUT = void 0;
|
|
7
|
+
var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
|
|
8
|
+
var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
package/lib/contract/utils.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { xdr, Account } from "@stellar/stellar-base";
|
|
3
2
|
import { Server } from "../rpc/server";
|
|
4
3
|
import { AssembledTransactionOptions } from "./types";
|
|
5
|
-
/**
|
|
6
|
-
* The default timeout for waiting for a transaction to be included in a block.
|
|
7
|
-
*/
|
|
8
|
-
export declare const DEFAULT_TIMEOUT: number;
|
|
9
4
|
/**
|
|
10
5
|
* Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is
|
|
11
6
|
* true. Returns an array of all attempts to call the function.
|
package/lib/contract/utils.js
CHANGED
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.contractErrorPattern =
|
|
6
|
+
exports.contractErrorPattern = void 0;
|
|
7
7
|
exports.getAccount = getAccount;
|
|
8
8
|
exports.implementsToString = implementsToString;
|
|
9
9
|
exports.processSpecEntryStream = processSpecEntryStream;
|
|
10
10
|
exports.withExponentialBackoff = withExponentialBackoff;
|
|
11
11
|
var _stellarBase = require("@stellar/stellar-base");
|
|
12
|
-
var
|
|
12
|
+
var _types = require("./types");
|
|
13
13
|
function _regeneratorRuntime() { "use strict"; _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
14
|
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); }
|
|
15
15
|
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); }
|
|
16
16
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
17
|
-
var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
|
|
18
17
|
function withExponentialBackoff(_x, _x2, _x3) {
|
|
19
18
|
return _withExponentialBackoff.apply(this, arguments);
|
|
20
19
|
}
|
|
@@ -113,21 +112,8 @@ function _getAccount() {
|
|
|
113
112
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
114
113
|
while (1) switch (_context2.prev = _context2.next) {
|
|
115
114
|
case 0:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
_context2.next = 3;
|
|
121
|
-
return server.getAccount(options.publicKey);
|
|
122
|
-
case 3:
|
|
123
|
-
_context2.t0 = _context2.sent;
|
|
124
|
-
_context2.next = 7;
|
|
125
|
-
break;
|
|
126
|
-
case 6:
|
|
127
|
-
_context2.t0 = new _stellarBase.Account(_assembled_transaction.NULL_ACCOUNT, "0");
|
|
128
|
-
case 7:
|
|
129
|
-
return _context2.abrupt("return", _context2.t0);
|
|
130
|
-
case 8:
|
|
115
|
+
return _context2.abrupt("return", options.publicKey ? server.getAccount(options.publicKey) : new _stellarBase.Account(_types.NULL_ACCOUNT, "0"));
|
|
116
|
+
case 1:
|
|
131
117
|
case "end":
|
|
132
118
|
return _context2.stop();
|
|
133
119
|
}
|
package/lib/errors.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare class NetworkError extends Error {
|
|
|
9
9
|
__proto__: NetworkError;
|
|
10
10
|
constructor(message: string, response: any);
|
|
11
11
|
getResponse(): {
|
|
12
|
-
data?: HorizonApi.ErrorResponseData
|
|
13
|
-
status?: number
|
|
14
|
-
statusText?: string
|
|
15
|
-
url?: string
|
|
12
|
+
data?: HorizonApi.ErrorResponseData;
|
|
13
|
+
status?: number;
|
|
14
|
+
statusText?: string;
|
|
15
|
+
url?: string;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
export declare class NotFoundError extends NetworkError {
|
|
@@ -4,7 +4,7 @@ export declare const FEDERATION_RESPONSE_MAX_SIZE: number;
|
|
|
4
4
|
* FederationServer handles a network connection to a
|
|
5
5
|
* [federation server](https://developers.stellar.org/docs/glossary/federation/)
|
|
6
6
|
* instance and exposes an interface for requests to that instance.
|
|
7
|
-
* @
|
|
7
|
+
* @class
|
|
8
8
|
* @param {string} serverURL The federation server URL (ex. `https://acme.com/federation`).
|
|
9
9
|
* @param {string} domain Domain this server represents
|
|
10
10
|
* @param {object} [opts] options object
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { Asset } from "@stellar/stellar-base";
|
|
3
2
|
import { CallBuilder } from "./call_builder";
|
|
4
3
|
import { ServerApi } from "./server_api";
|
|
@@ -8,8 +7,8 @@ import { ServerApi } from "./server_api";
|
|
|
8
7
|
*
|
|
9
8
|
* @see [All Accounts](https://developers.stellar.org/api/resources/accounts/)
|
|
10
9
|
* @class AccountCallBuilder
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
10
|
+
* @augments CallBuilder
|
|
11
|
+
* @class
|
|
13
12
|
* @param {string} serverUrl Horizon server URL.
|
|
14
13
|
*/
|
|
15
14
|
export declare class AccountCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.AccountRecord>> {
|
|
@@ -5,7 +5,7 @@ import { ServerApi } from "./server_api";
|
|
|
5
5
|
*
|
|
6
6
|
* Returns information and links relating to a single account.
|
|
7
7
|
* The balances section in the returned JSON will also list all the trust lines this account has set up.
|
|
8
|
-
* It also contains {@link
|
|
8
|
+
* It also contains {@link BaseAccount} object and exposes it's methods so can be used in {@link TransactionBuilder}.
|
|
9
9
|
*
|
|
10
10
|
* @see [Account Details](https://developers.stellar.org/api/resources/accounts/object/)
|
|
11
11
|
* @param {string} response Response from horizon account endpoint.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { CallBuilder } from "./call_builder";
|
|
3
2
|
import { ServerApi } from "./server_api";
|
|
4
3
|
/**
|
|
@@ -6,8 +5,8 @@ import { ServerApi } from "./server_api";
|
|
|
6
5
|
*
|
|
7
6
|
* Do not create this object directly, use {@link Server#assets}.
|
|
8
7
|
* @class AssetsCallBuilder
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
8
|
+
* @class
|
|
9
|
+
* @augments CallBuilder
|
|
11
10
|
* @param {string} serverUrl Horizon server URL.
|
|
12
11
|
*/
|
|
13
12
|
export declare class AssetsCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.AssetRecord>> {
|
|
@@ -30,10 +30,10 @@ export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | Horizon
|
|
|
30
30
|
* @see [Horizon Response Format](https://developers.stellar.org/api/introduction/response-format/)
|
|
31
31
|
* @see [MDN EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)
|
|
32
32
|
* @param {object} [options] EventSource options.
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
33
|
+
* @param {Function} [options.onmessage] Callback function to handle incoming messages.
|
|
34
|
+
* @param {Function} [options.onerror] Callback function to handle errors.
|
|
35
35
|
* @param {number} [options.reconnectTimeout] Custom stream connection timeout in ms, default is 15 seconds.
|
|
36
|
-
* @returns {
|
|
36
|
+
* @returns {Function} Close function. Run to close the connection and stop listening for new events.
|
|
37
37
|
*/
|
|
38
38
|
stream(options?: EventSourceOptions<T>): () => void;
|
|
39
39
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | Horizon
|
|
|
46
46
|
/**
|
|
47
47
|
* Sets `limit` parameter for the current call. Returns the CallBuilder object on which this method has been called.
|
|
48
48
|
* @see [Paging](https://developers.stellar.org/api/introduction/pagination/)
|
|
49
|
-
* @param {number}
|
|
49
|
+
* @param {number} recordsNumber Number of records the server should return.
|
|
50
50
|
* @returns {object} current CallBuilder instance
|
|
51
51
|
*/
|
|
52
52
|
limit(recordsNumber: number): this;
|
|
@@ -64,7 +64,7 @@ export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | Horizon
|
|
|
64
64
|
* will include a `transaction` field for each operation in the
|
|
65
65
|
* response.
|
|
66
66
|
*
|
|
67
|
-
* @param
|
|
67
|
+
* @param "include" join Records to be included in the response.
|
|
68
68
|
* @returns {object} current CallBuilder instance.
|
|
69
69
|
*/
|
|
70
70
|
join(include: "transactions"): this;
|
|
@@ -93,9 +93,9 @@ export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | Horizon
|
|
|
93
93
|
* Convert a link object to a function that fetches that link.
|
|
94
94
|
* @private
|
|
95
95
|
* @param {object} link A link object
|
|
96
|
-
* @param {
|
|
97
|
-
* @param {
|
|
98
|
-
* @returns {
|
|
96
|
+
* @param {boolean} link.href the URI of the link
|
|
97
|
+
* @param {boolean} [link.templated] Whether the link is templated
|
|
98
|
+
* @returns {Function} A function that requests the link
|
|
99
99
|
*/
|
|
100
100
|
private _requestFnForLink;
|
|
101
101
|
/**
|
|
@@ -199,8 +199,7 @@ var CallBuilder = exports.CallBuilder = function () {
|
|
|
199
199
|
if (!json._links) {
|
|
200
200
|
return json;
|
|
201
201
|
}
|
|
202
|
-
|
|
203
|
-
var key = _Object$keys[_i];
|
|
202
|
+
Object.keys(json._links).forEach(function (key) {
|
|
204
203
|
var n = json._links[key];
|
|
205
204
|
var included = false;
|
|
206
205
|
if (typeof json[key] !== "undefined") {
|
|
@@ -223,10 +222,7 @@ var CallBuilder = exports.CallBuilder = function () {
|
|
|
223
222
|
} else {
|
|
224
223
|
json[key] = _this4._requestFnForLink(n);
|
|
225
224
|
}
|
|
226
|
-
};
|
|
227
|
-
for (var _i = 0, _Object$keys = Object.keys(json._links); _i < _Object$keys.length; _i++) {
|
|
228
|
-
_loop();
|
|
229
|
-
}
|
|
225
|
+
});
|
|
230
226
|
return json;
|
|
231
227
|
}
|
|
232
228
|
}, {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { Asset } from "@stellar/stellar-base";
|
|
3
2
|
import { CallBuilder } from "./call_builder";
|
|
4
3
|
import { ServerApi } from "./server_api";
|
|
@@ -8,8 +7,8 @@ import { ServerApi } from "./server_api";
|
|
|
8
7
|
*
|
|
9
8
|
* @see [Claimable Balances](https://developers.stellar.org/api/resources/claimablebalances/)
|
|
10
9
|
* @class ClaimableBalanceCallBuilder
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
10
|
+
* @class
|
|
11
|
+
* @augments CallBuilder
|
|
13
12
|
* @param {string} serverUrl Horizon server URL.
|
|
14
13
|
*/
|
|
15
14
|
export declare class ClaimableBalanceCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.ClaimableBalanceRecord>> {
|
|
@@ -42,7 +41,7 @@ export declare class ClaimableBalanceCallBuilder extends CallBuilder<ServerApi.C
|
|
|
42
41
|
* Returns all claimable balances which provide a balance for the given asset.
|
|
43
42
|
*
|
|
44
43
|
* @see [Claimable Balances](https://developers.stellar.org/api/resources/claimablebalances/list/)
|
|
45
|
-
* @param {Asset} The Asset held by the claimable balance
|
|
44
|
+
* @param {Asset} asset The Asset held by the claimable balance
|
|
46
45
|
* @returns {ClaimableBalanceCallBuilder} current ClaimableBalanceCallBuilder instance
|
|
47
46
|
*/
|
|
48
47
|
asset(asset: Asset): this;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { CallBuilder } from "./call_builder";
|
|
3
2
|
import { ServerApi } from "./server_api";
|
|
4
3
|
/**
|
|
@@ -6,9 +5,9 @@ import { ServerApi } from "./server_api";
|
|
|
6
5
|
* Do not create this object directly, use {@link Server#effects}.
|
|
7
6
|
*
|
|
8
7
|
* @class EffectCallBuilder
|
|
9
|
-
* @
|
|
8
|
+
* @augments CallBuilder
|
|
10
9
|
* @see [All Effects](https://developers.stellar.org/api/resources/effects/)
|
|
11
|
-
* @
|
|
10
|
+
* @class
|
|
12
11
|
* @param {string} serverUrl Horizon server URL.
|
|
13
12
|
*/
|
|
14
13
|
export declare class EffectCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.EffectRecord>> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { AssetType, MemoType } from "@stellar/stellar-base";
|
|
3
2
|
export declare namespace HorizonApi {
|
|
4
3
|
interface ResponseLink {
|
|
@@ -19,6 +18,11 @@ export declare namespace HorizonApi {
|
|
|
19
18
|
result_meta_xdr: string;
|
|
20
19
|
paging_token: string;
|
|
21
20
|
}
|
|
21
|
+
interface SubmitAsyncTransactionResponse {
|
|
22
|
+
hash: string;
|
|
23
|
+
tx_status: string;
|
|
24
|
+
error_result_xdr: string;
|
|
25
|
+
}
|
|
22
26
|
interface FeeBumpTransactionResponse {
|
|
23
27
|
hash: string;
|
|
24
28
|
signatures: string[];
|
|
@@ -17,14 +17,14 @@ var AxiosClient = exports.AxiosClient = _axios.default.create({
|
|
|
17
17
|
"X-Client-Version": version
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
function
|
|
20
|
+
function toSeconds(ms) {
|
|
21
21
|
return Math.floor(ms / 1000);
|
|
22
22
|
}
|
|
23
|
-
AxiosClient.interceptors.response.use(function
|
|
23
|
+
AxiosClient.interceptors.response.use(function (response) {
|
|
24
24
|
var hostname = (0, _urijs.default)(response.config.url).hostname();
|
|
25
|
-
var serverTime =
|
|
26
|
-
var localTimeRecorded =
|
|
27
|
-
if (!isNaN(serverTime)) {
|
|
25
|
+
var serverTime = toSeconds(Date.parse(response.headers.date));
|
|
26
|
+
var localTimeRecorded = toSeconds(new Date().getTime());
|
|
27
|
+
if (!Number.isNaN(serverTime)) {
|
|
28
28
|
SERVER_TIME_MAP[hostname] = {
|
|
29
29
|
serverTime: serverTime,
|
|
30
30
|
localTimeRecorded: localTimeRecorded
|
|
@@ -40,7 +40,7 @@ function getCurrentServerTime(hostname) {
|
|
|
40
40
|
}
|
|
41
41
|
var serverTime = entry.serverTime,
|
|
42
42
|
localTimeRecorded = entry.localTimeRecorded;
|
|
43
|
-
var currentTime =
|
|
43
|
+
var currentTime = toSeconds(new Date().getTime());
|
|
44
44
|
if (currentTime - localTimeRecorded > 60 * 5) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { CallBuilder } from "./call_builder";
|
|
3
2
|
import { ServerApi } from "./server_api";
|
|
4
3
|
/**
|
|
@@ -6,9 +5,9 @@ import { ServerApi } from "./server_api";
|
|
|
6
5
|
* Do not create this object directly, use {@link Server#ledgers}.
|
|
7
6
|
*
|
|
8
7
|
* @see [All Ledgers](https://developers.stellar.org/api/resources/ledgers/list/)
|
|
9
|
-
* @
|
|
8
|
+
* @class
|
|
10
9
|
* @class LedgerCallBuilder
|
|
11
|
-
* @
|
|
10
|
+
* @augments CallBuilder
|
|
12
11
|
* @param {string} serverUrl Horizon server URL.
|
|
13
12
|
*/
|
|
14
13
|
export declare class LedgerCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.LedgerRecord>> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { Asset } from "@stellar/stellar-base";
|
|
3
2
|
import { CallBuilder } from "./call_builder";
|
|
4
3
|
import { ServerApi } from "./server_api";
|
|
@@ -7,8 +6,8 @@ import { ServerApi } from "./server_api";
|
|
|
7
6
|
* Do not create this object directly, use {@link Server#liquidityPools}.
|
|
8
7
|
*
|
|
9
8
|
* @class LiquidityPoolCallBuilder
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
9
|
+
* @augments CallBuilder
|
|
10
|
+
* @class
|
|
12
11
|
* @param {string} serverUrl Horizon server URL.
|
|
13
12
|
*/
|
|
14
13
|
export declare class LiquidityPoolCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.LiquidityPoolRecord>> {
|
|
@@ -17,7 +16,6 @@ export declare class LiquidityPoolCallBuilder extends CallBuilder<ServerApi.Coll
|
|
|
17
16
|
* Filters out pools whose reserves don't exactly match these assets.
|
|
18
17
|
*
|
|
19
18
|
* @see Asset
|
|
20
|
-
* @param {Asset[]} assets
|
|
21
19
|
* @returns {LiquidityPoolCallBuilder} current LiquidityPoolCallBuilder instance
|
|
22
20
|
*/
|
|
23
21
|
forAssets(...assets: Asset[]): this;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { Asset } from "@stellar/stellar-base";
|
|
3
2
|
import { CallBuilder } from "./call_builder";
|
|
4
3
|
import { ServerApi } from "./server_api";
|
|
@@ -8,8 +7,8 @@ import { ServerApi } from "./server_api";
|
|
|
8
7
|
*
|
|
9
8
|
* @see [Offers](https://developers.stellar.org/api/resources/offers/)
|
|
10
9
|
* @class OfferCallBuilder
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
10
|
+
* @class
|
|
11
|
+
* @augments CallBuilder
|
|
13
12
|
* @param {string} serverUrl Horizon server URL.
|
|
14
13
|
*/
|
|
15
14
|
export declare class OfferCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.OfferRecord>> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { CallBuilder } from "./call_builder";
|
|
3
2
|
import { ServerApi } from "./server_api";
|
|
4
3
|
/**
|
|
@@ -7,8 +6,8 @@ import { ServerApi } from "./server_api";
|
|
|
7
6
|
*
|
|
8
7
|
* @see [All Operations](https://developers.stellar.org/api/resources/operations/)
|
|
9
8
|
* @class OperationCallBuilder
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
9
|
+
* @class
|
|
10
|
+
* @augments CallBuilder
|
|
12
11
|
* @param {string} serverUrl Horizon server URL.
|
|
13
12
|
*/
|
|
14
13
|
export declare class OperationCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.OperationRecord>> {
|
|
@@ -61,7 +60,7 @@ export declare class OperationCallBuilder extends CallBuilder<ServerApi.Collecti
|
|
|
61
60
|
* Adds a parameter defining whether to include failed transactions.
|
|
62
61
|
* By default, only operations of successful transactions are returned.
|
|
63
62
|
*
|
|
64
|
-
* @param {
|
|
63
|
+
* @param {boolean} value Set to `true` to include operations of failed transactions.
|
|
65
64
|
* @returns {OperationCallBuilder} this OperationCallBuilder instance
|
|
66
65
|
*/
|
|
67
66
|
includeFailed(value: boolean): this;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { Asset } from "@stellar/stellar-base";
|
|
3
2
|
import { CallBuilder } from "./call_builder";
|
|
4
3
|
import { ServerApi } from "./server_api";
|
|
@@ -19,7 +18,7 @@ import { ServerApi } from "./server_api";
|
|
|
19
18
|
*
|
|
20
19
|
* Do not create this object directly, use {@link Server#paths}.
|
|
21
20
|
* @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
|
|
22
|
-
* @
|
|
21
|
+
* @augments CallBuilder
|
|
23
22
|
* @param {string} serverUrl Horizon server URL.
|
|
24
23
|
* @param {string} source The sender's account ID. Any returned path must use a source that the sender can hold.
|
|
25
24
|
* @param {string} destination The destination account ID that any returned path should use.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="urijs" />
|
|
2
1
|
import { CallBuilder } from "./call_builder";
|
|
3
2
|
import { ServerApi } from "./server_api";
|
|
4
3
|
/**
|
|
@@ -6,8 +5,8 @@ import { ServerApi } from "./server_api";
|
|
|
6
5
|
*
|
|
7
6
|
* Do not create this object directly, use {@link Server#payments}.
|
|
8
7
|
* @see [All Payments](https://developers.stellar.org/api/horizon/resources/list-all-payments/)
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
8
|
+
* @class
|
|
9
|
+
* @augments CallBuilder
|
|
11
10
|
* @param {string} serverUrl Horizon server URL.
|
|
12
11
|
*/
|
|
13
12
|
export declare class PaymentCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentOperationRecord | ServerApi.CreateAccountOperationRecord | ServerApi.AccountMergeOperationRecord | ServerApi.PathPaymentOperationRecord | ServerApi.PathPaymentStrictSendOperationRecord | ServerApi.InvokeHostFunctionOperationRecord>> {
|
package/lib/horizon/server.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const SUBMIT_TRANSACTION_TIMEOUT: number;
|
|
|
21
21
|
/**
|
|
22
22
|
* Server handles the network connection to a [Horizon](https://developers.stellar.org/api/introduction/)
|
|
23
23
|
* instance and exposes an interface for requests to that instance.
|
|
24
|
-
* @
|
|
24
|
+
* @class
|
|
25
25
|
* @param {string} serverURL Horizon Server URL (ex. `https://horizon-testnet.stellar.org`).
|
|
26
26
|
* @param {object} [opts] Options object
|
|
27
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.
|
|
@@ -61,10 +61,10 @@ export declare class Server {
|
|
|
61
61
|
* // earlier does the trick!
|
|
62
62
|
* .build();
|
|
63
63
|
* ```
|
|
64
|
-
* @
|
|
65
|
-
* @
|
|
64
|
+
* @param {number} seconds Number of seconds past the current time to wait.
|
|
65
|
+
* @param {boolean} [_isRetry] True if this is a retry. Only set this internally!
|
|
66
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
|
|
67
|
+
* @returns {Promise<Server.Timebounds>} Promise that resolves a `timebounds` object
|
|
68
68
|
* (with the shape `{ minTime: 0, maxTime: N }`) that you can set the `timebounds` option to.
|
|
69
69
|
*/
|
|
70
70
|
fetchTimebounds(seconds: number, _isRetry?: boolean): Promise<Server.Timebounds>;
|
|
@@ -175,8 +175,7 @@ export declare class Server {
|
|
|
175
175
|
* * If `wasPartiallyFilled` is true, you can tell the user that
|
|
176
176
|
* `amountBought` or `amountSold` have already been transferred.
|
|
177
177
|
*
|
|
178
|
-
* @see [
|
|
179
|
-
* Transaction](https://developers.stellar.org/api/resources/transactions/post/)
|
|
178
|
+
* @see [PostTransaction](https://developers.stellar.org/api/resources/transactions/post/)
|
|
180
179
|
* @param {Transaction|FeeBumpTransaction} transaction - The transaction to submit.
|
|
181
180
|
* @param {object} [opts] Options object
|
|
182
181
|
* @param {boolean} [opts.skipMemoRequiredCheck] - Allow skipping memo
|
|
@@ -186,6 +185,25 @@ export declare class Server {
|
|
|
186
185
|
* horizon.
|
|
187
186
|
*/
|
|
188
187
|
submitTransaction(transaction: Transaction | FeeBumpTransaction, opts?: Server.SubmitTransactionOptions): Promise<HorizonApi.SubmitTransactionResponse>;
|
|
188
|
+
/**
|
|
189
|
+
* Submits an asynchronous transaction to the network. Unlike the synchronous version, which blocks
|
|
190
|
+
* and waits for the transaction to be ingested in Horizon, this endpoint relays the response from
|
|
191
|
+
* core directly back to the user.
|
|
192
|
+
*
|
|
193
|
+
* By default, this function calls {@link Server#checkMemoRequired}, you can
|
|
194
|
+
* skip this check by setting the option `skipMemoRequiredCheck` to `true`.
|
|
195
|
+
*
|
|
196
|
+
* @see [Submit
|
|
197
|
+
* Async Transaction](https://developers.stellar.org/docs/data/horizon/api-reference/resources/submit-async-transaction)
|
|
198
|
+
* @param {Transaction|FeeBumpTransaction} transaction - The transaction to submit.
|
|
199
|
+
* @param {object} [opts] Options object
|
|
200
|
+
* @param {boolean} [opts.skipMemoRequiredCheck] - Allow skipping memo
|
|
201
|
+
* required check, default: `false`. See
|
|
202
|
+
* [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md).
|
|
203
|
+
* @returns {Promise} Promise that resolves or rejects with response from
|
|
204
|
+
* horizon.
|
|
205
|
+
*/
|
|
206
|
+
submitAsyncTransaction(transaction: Transaction | FeeBumpTransaction, opts?: Server.SubmitTransactionOptions): Promise<HorizonApi.SubmitAsyncTransactionResponse>;
|
|
189
207
|
/**
|
|
190
208
|
* @returns {AccountCallBuilder} New {@link AccountCallBuilder} object configured by a current Horizon server configuration.
|
|
191
209
|
*/
|
|
@@ -317,10 +335,10 @@ export declare class Server {
|
|
|
317
335
|
*
|
|
318
336
|
* @param {Asset} base base asset
|
|
319
337
|
* @param {Asset} counter counter asset
|
|
320
|
-
* @param {
|
|
321
|
-
* @param {
|
|
322
|
-
* @param {
|
|
323
|
-
* @param {
|
|
338
|
+
* @param {number} start_time lower time boundary represented as millis since epoch
|
|
339
|
+
* @param {number} end_time upper time boundary represented as millis since epoch
|
|
340
|
+
* @param {number} 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).
|
|
341
|
+
* @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.
|
|
324
342
|
* Returns new {@link TradeAggregationCallBuilder} object configured with the current Horizon server configuration.
|
|
325
343
|
* @returns {TradeAggregationCallBuilder} New TradeAggregationCallBuilder instance
|
|
326
344
|
*/
|
|
@@ -350,6 +368,7 @@ export declare namespace Server {
|
|
|
350
368
|
appName?: string;
|
|
351
369
|
appVersion?: string;
|
|
352
370
|
authToken?: string;
|
|
371
|
+
headers?: Record<string, string>;
|
|
353
372
|
}
|
|
354
373
|
interface Timebounds {
|
|
355
374
|
minTime: number;
|