@stellar/stellar-sdk 12.1.0 → 12.3.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 +74 -0
- package/README.md +1 -1
- package/dist/stellar-sdk.js +1336 -1101
- 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 +26 -30
- package/lib/contract/assembled_transaction.js +28 -36
- 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 +10 -13
- 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 +89 -11
- 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 +5 -3
- package/lib/rpc/parsers.js +52 -23
- package/lib/rpc/server.d.ts +51 -18
- package/lib/rpc/server.js +200 -153
- 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 +24 -24
package/lib/horizon/server.js
CHANGED
|
@@ -32,6 +32,9 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
32
32
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
33
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
34
|
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); }
|
|
35
|
+
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; }
|
|
36
|
+
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; }
|
|
37
|
+
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; }
|
|
35
38
|
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; }
|
|
36
39
|
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); }
|
|
37
40
|
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); }); }; }
|
|
@@ -43,7 +46,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
43
46
|
var SUBMIT_TRANSACTION_TIMEOUT = exports.SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000;
|
|
44
47
|
var STROOPS_IN_LUMEN = 10000000;
|
|
45
48
|
var ACCOUNT_REQUIRES_MEMO = "MQ==";
|
|
46
|
-
function
|
|
49
|
+
function getAmountInLumens(amt) {
|
|
47
50
|
return new _bignumber.default(amt).div(STROOPS_IN_LUMEN).toString();
|
|
48
51
|
}
|
|
49
52
|
var Server = exports.Server = function () {
|
|
@@ -62,6 +65,9 @@ var Server = exports.Server = function () {
|
|
|
62
65
|
if (opts.authToken) {
|
|
63
66
|
customHeaders["X-Auth-Token"] = opts.authToken;
|
|
64
67
|
}
|
|
68
|
+
if (opts.headers) {
|
|
69
|
+
Object.assign(customHeaders, opts.headers);
|
|
70
|
+
}
|
|
65
71
|
if (Object.keys(customHeaders).length > 0) {
|
|
66
72
|
_horizon_axios_client.default.interceptors.request.use(function (config) {
|
|
67
73
|
config.headers = Object.assign(config.headers, customHeaders);
|
|
@@ -105,11 +111,8 @@ var Server = exports.Server = function () {
|
|
|
105
111
|
_context.next = 8;
|
|
106
112
|
return _horizon_axios_client.default.get((0, _urijs.default)(this.serverURL).toString());
|
|
107
113
|
case 8:
|
|
108
|
-
_context.
|
|
109
|
-
|
|
110
|
-
case 10:
|
|
111
|
-
return _context.abrupt("return", _context.sent);
|
|
112
|
-
case 11:
|
|
114
|
+
return _context.abrupt("return", this.fetchTimebounds(seconds, true));
|
|
115
|
+
case 9:
|
|
113
116
|
case "end":
|
|
114
117
|
return _context.stop();
|
|
115
118
|
}
|
|
@@ -217,7 +220,7 @@ var Server = exports.Server = function () {
|
|
|
217
220
|
sellerId = _stellarBase.StrKey.encodeEd25519PublicKey(offerClaimed.sellerId().ed25519());
|
|
218
221
|
break;
|
|
219
222
|
default:
|
|
220
|
-
throw new Error("Invalid offer result type: "
|
|
223
|
+
throw new Error("Invalid offer result type: ".concat(offerClaimedAtom.switch()));
|
|
221
224
|
}
|
|
222
225
|
var claimedOfferAmountBought = new _bignumber.default(offerClaimed.amountBought().toString());
|
|
223
226
|
var claimedOfferAmountSold = new _bignumber.default(offerClaimed.amountSold().toString());
|
|
@@ -239,9 +242,9 @@ var Server = exports.Server = function () {
|
|
|
239
242
|
sellerId: sellerId,
|
|
240
243
|
offerId: offerClaimed.offerId().toString(),
|
|
241
244
|
assetSold: assetSold,
|
|
242
|
-
amountSold:
|
|
245
|
+
amountSold: getAmountInLumens(claimedOfferAmountSold),
|
|
243
246
|
assetBought: assetBought,
|
|
244
|
-
amountBought:
|
|
247
|
+
amountBought: getAmountInLumens(claimedOfferAmountBought)
|
|
245
248
|
};
|
|
246
249
|
});
|
|
247
250
|
var effect = offerSuccess.offer().switch().name;
|
|
@@ -252,7 +255,7 @@ var Server = exports.Server = function () {
|
|
|
252
255
|
offerId: offerXDR.offerId().toString(),
|
|
253
256
|
selling: {},
|
|
254
257
|
buying: {},
|
|
255
|
-
amount:
|
|
258
|
+
amount: getAmountInLumens(offerXDR.amount().toString()),
|
|
256
259
|
price: {
|
|
257
260
|
n: offerXDR.price().n(),
|
|
258
261
|
d: offerXDR.price().d()
|
|
@@ -276,8 +279,8 @@ var Server = exports.Server = function () {
|
|
|
276
279
|
effect: effect,
|
|
277
280
|
operationIndex: i,
|
|
278
281
|
currentOffer: currentOffer,
|
|
279
|
-
amountBought:
|
|
280
|
-
amountSold:
|
|
282
|
+
amountBought: getAmountInLumens(amountBought),
|
|
283
|
+
amountSold: getAmountInLumens(amountSold),
|
|
281
284
|
isFullyOpen: !offersClaimed.length && effect !== "manageOfferDeleted",
|
|
282
285
|
wasPartiallyFilled: !!offersClaimed.length && effect !== "manageOfferDeleted",
|
|
283
286
|
wasImmediatelyFilled: !!offersClaimed.length && effect === "manageOfferDeleted",
|
|
@@ -287,7 +290,7 @@ var Server = exports.Server = function () {
|
|
|
287
290
|
return !!result;
|
|
288
291
|
});
|
|
289
292
|
}
|
|
290
|
-
return
|
|
293
|
+
return _objectSpread(_objectSpread({}, response.data), {}, {
|
|
291
294
|
offerResults: hasManageOffer ? offerResults : undefined
|
|
292
295
|
});
|
|
293
296
|
}).catch(function (response) {
|
|
@@ -307,6 +310,46 @@ var Server = exports.Server = function () {
|
|
|
307
310
|
}
|
|
308
311
|
return submitTransaction;
|
|
309
312
|
}())
|
|
313
|
+
}, {
|
|
314
|
+
key: "submitAsyncTransaction",
|
|
315
|
+
value: (function () {
|
|
316
|
+
var _submitAsyncTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(transaction) {
|
|
317
|
+
var opts,
|
|
318
|
+
tx,
|
|
319
|
+
_args5 = arguments;
|
|
320
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
321
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
opts = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {
|
|
324
|
+
skipMemoRequiredCheck: false
|
|
325
|
+
};
|
|
326
|
+
if (opts.skipMemoRequiredCheck) {
|
|
327
|
+
_context5.next = 4;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
_context5.next = 4;
|
|
331
|
+
return this.checkMemoRequired(transaction);
|
|
332
|
+
case 4:
|
|
333
|
+
tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
|
|
334
|
+
return _context5.abrupt("return", _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions_async").toString(), "tx=".concat(tx)).then(function (response) {
|
|
335
|
+
return response.data;
|
|
336
|
+
}).catch(function (response) {
|
|
337
|
+
if (response instanceof Error) {
|
|
338
|
+
return Promise.reject(response);
|
|
339
|
+
}
|
|
340
|
+
return Promise.reject(new _errors.BadResponseError("Transaction submission failed. Server responded: ".concat(response.status, " ").concat(response.statusText), response.data));
|
|
341
|
+
}));
|
|
342
|
+
case 6:
|
|
343
|
+
case "end":
|
|
344
|
+
return _context5.stop();
|
|
345
|
+
}
|
|
346
|
+
}, _callee5, this);
|
|
347
|
+
}));
|
|
348
|
+
function submitAsyncTransaction(_x3) {
|
|
349
|
+
return _submitAsyncTransaction.apply(this, arguments);
|
|
350
|
+
}
|
|
351
|
+
return submitAsyncTransaction;
|
|
352
|
+
}())
|
|
310
353
|
}, {
|
|
311
354
|
key: "accounts",
|
|
312
355
|
value: function accounts() {
|
|
@@ -385,23 +428,23 @@ var Server = exports.Server = function () {
|
|
|
385
428
|
}, {
|
|
386
429
|
key: "loadAccount",
|
|
387
430
|
value: (function () {
|
|
388
|
-
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
431
|
+
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(accountId) {
|
|
389
432
|
var res;
|
|
390
|
-
return _regeneratorRuntime().wrap(function
|
|
391
|
-
while (1) switch (
|
|
433
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
434
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
392
435
|
case 0:
|
|
393
|
-
|
|
436
|
+
_context6.next = 2;
|
|
394
437
|
return this.accounts().accountId(accountId).call();
|
|
395
438
|
case 2:
|
|
396
|
-
res =
|
|
397
|
-
return
|
|
439
|
+
res = _context6.sent;
|
|
440
|
+
return _context6.abrupt("return", new _account_response.AccountResponse(res));
|
|
398
441
|
case 4:
|
|
399
442
|
case "end":
|
|
400
|
-
return
|
|
443
|
+
return _context6.stop();
|
|
401
444
|
}
|
|
402
|
-
},
|
|
445
|
+
}, _callee6, this);
|
|
403
446
|
}));
|
|
404
|
-
function loadAccount(
|
|
447
|
+
function loadAccount(_x4) {
|
|
405
448
|
return _loadAccount.apply(this, arguments);
|
|
406
449
|
}
|
|
407
450
|
return loadAccount;
|
|
@@ -414,90 +457,90 @@ var Server = exports.Server = function () {
|
|
|
414
457
|
}, {
|
|
415
458
|
key: "checkMemoRequired",
|
|
416
459
|
value: (function () {
|
|
417
|
-
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
460
|
+
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7(transaction) {
|
|
418
461
|
var destinations, i, operation, destination, account;
|
|
419
|
-
return _regeneratorRuntime().wrap(function
|
|
420
|
-
while (1) switch (
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
463
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
421
464
|
case 0:
|
|
422
465
|
if (transaction instanceof _stellarBase.FeeBumpTransaction) {
|
|
423
466
|
transaction = transaction.innerTransaction;
|
|
424
467
|
}
|
|
425
468
|
if (!(transaction.memo.type !== "none")) {
|
|
426
|
-
|
|
469
|
+
_context7.next = 3;
|
|
427
470
|
break;
|
|
428
471
|
}
|
|
429
|
-
return
|
|
472
|
+
return _context7.abrupt("return");
|
|
430
473
|
case 3:
|
|
431
474
|
destinations = new Set();
|
|
432
475
|
i = 0;
|
|
433
476
|
case 5:
|
|
434
477
|
if (!(i < transaction.operations.length)) {
|
|
435
|
-
|
|
478
|
+
_context7.next = 36;
|
|
436
479
|
break;
|
|
437
480
|
}
|
|
438
481
|
operation = transaction.operations[i];
|
|
439
|
-
|
|
440
|
-
|
|
482
|
+
_context7.t0 = operation.type;
|
|
483
|
+
_context7.next = _context7.t0 === "payment" ? 10 : _context7.t0 === "pathPaymentStrictReceive" ? 10 : _context7.t0 === "pathPaymentStrictSend" ? 10 : _context7.t0 === "accountMerge" ? 10 : 11;
|
|
441
484
|
break;
|
|
442
485
|
case 10:
|
|
443
|
-
return
|
|
486
|
+
return _context7.abrupt("break", 12);
|
|
444
487
|
case 11:
|
|
445
|
-
return
|
|
488
|
+
return _context7.abrupt("continue", 33);
|
|
446
489
|
case 12:
|
|
447
490
|
destination = operation.destination;
|
|
448
491
|
if (!destinations.has(destination)) {
|
|
449
|
-
|
|
492
|
+
_context7.next = 15;
|
|
450
493
|
break;
|
|
451
494
|
}
|
|
452
|
-
return
|
|
495
|
+
return _context7.abrupt("continue", 33);
|
|
453
496
|
case 15:
|
|
454
497
|
destinations.add(destination);
|
|
455
498
|
if (!destination.startsWith("M")) {
|
|
456
|
-
|
|
499
|
+
_context7.next = 18;
|
|
457
500
|
break;
|
|
458
501
|
}
|
|
459
|
-
return
|
|
502
|
+
return _context7.abrupt("continue", 33);
|
|
460
503
|
case 18:
|
|
461
|
-
|
|
462
|
-
|
|
504
|
+
_context7.prev = 18;
|
|
505
|
+
_context7.next = 21;
|
|
463
506
|
return this.loadAccount(destination);
|
|
464
507
|
case 21:
|
|
465
|
-
account =
|
|
508
|
+
account = _context7.sent;
|
|
466
509
|
if (!(account.data_attr["config.memo_required"] === ACCOUNT_REQUIRES_MEMO)) {
|
|
467
|
-
|
|
510
|
+
_context7.next = 24;
|
|
468
511
|
break;
|
|
469
512
|
}
|
|
470
513
|
throw new _errors.AccountRequiresMemoError("account requires memo", destination, i);
|
|
471
514
|
case 24:
|
|
472
|
-
|
|
515
|
+
_context7.next = 33;
|
|
473
516
|
break;
|
|
474
517
|
case 26:
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (!(
|
|
478
|
-
|
|
518
|
+
_context7.prev = 26;
|
|
519
|
+
_context7.t1 = _context7["catch"](18);
|
|
520
|
+
if (!(_context7.t1 instanceof _errors.AccountRequiresMemoError)) {
|
|
521
|
+
_context7.next = 30;
|
|
479
522
|
break;
|
|
480
523
|
}
|
|
481
|
-
throw
|
|
524
|
+
throw _context7.t1;
|
|
482
525
|
case 30:
|
|
483
|
-
if (
|
|
484
|
-
|
|
526
|
+
if (_context7.t1 instanceof _errors.NotFoundError) {
|
|
527
|
+
_context7.next = 32;
|
|
485
528
|
break;
|
|
486
529
|
}
|
|
487
|
-
throw
|
|
530
|
+
throw _context7.t1;
|
|
488
531
|
case 32:
|
|
489
|
-
return
|
|
532
|
+
return _context7.abrupt("continue", 33);
|
|
490
533
|
case 33:
|
|
491
|
-
i
|
|
492
|
-
|
|
534
|
+
i += 1;
|
|
535
|
+
_context7.next = 5;
|
|
493
536
|
break;
|
|
494
537
|
case 36:
|
|
495
538
|
case "end":
|
|
496
|
-
return
|
|
539
|
+
return _context7.stop();
|
|
497
540
|
}
|
|
498
|
-
},
|
|
541
|
+
}, _callee7, this, [[18, 26]]);
|
|
499
542
|
}));
|
|
500
|
-
function checkMemoRequired(
|
|
543
|
+
function checkMemoRequired(_x5) {
|
|
501
544
|
return _checkMemoRequired.apply(this, arguments);
|
|
502
545
|
}
|
|
503
546
|
return checkMemoRequired;
|
|
@@ -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";
|
|
@@ -23,7 +22,7 @@ import { ServerApi } from "./server_api";
|
|
|
23
22
|
*
|
|
24
23
|
* Do not create this object directly, use {@link Server#strictReceivePaths}.
|
|
25
24
|
* @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
|
|
26
|
-
* @
|
|
25
|
+
* @augments CallBuilder
|
|
27
26
|
* @param {string} serverUrl Horizon server URL.
|
|
28
27
|
* @param {string|Asset[]} source The sender's account ID or a list of Assets. Any returned path must use a source that the sender can hold.
|
|
29
28
|
* @param {Asset} destinationAsset The destination asset.
|
|
@@ -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";
|
|
@@ -22,7 +21,7 @@ import { ServerApi } from "./server_api";
|
|
|
22
21
|
*
|
|
23
22
|
* Do not create this object directly, use {@link Server#strictSendPaths}.
|
|
24
23
|
* @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
|
|
25
|
-
* @
|
|
24
|
+
* @augments CallBuilder
|
|
26
25
|
* @param {string} serverUrl Horizon server URL.
|
|
27
26
|
* @param {Asset} sourceAsset The asset to be sent.
|
|
28
27
|
* @param {string} sourceAmount The amount, denominated in the source asset, that any returned path should be able to satisfy.
|
|
@@ -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 { HorizonApi } from "./horizon_api";
|
|
@@ -8,28 +7,28 @@ import { ServerApi } from "./server_api";
|
|
|
8
7
|
* Do not create this object directly, use {@link Server#tradeAggregation}.
|
|
9
8
|
*
|
|
10
9
|
* @class TradeAggregationCallBuilder
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
10
|
+
* @augments CallBuilder
|
|
11
|
+
* @class
|
|
13
12
|
* @param {string} serverUrl serverUrl Horizon server URL.
|
|
14
13
|
* @param {Asset} base base asset
|
|
15
14
|
* @param {Asset} counter counter asset
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
15
|
+
* @param {number} start_time lower time boundary represented as millis since epoch
|
|
16
|
+
* @param {number} end_time upper time boundary represented as millis since epoch
|
|
17
|
+
* @param {number} resolution segment duration as millis since epoch. *Supported values are 1 minute (60000), 5 minutes (300000), 15 minutes (900000), 1 hour (3600000), 1 day (86400000) and 1 week (604800000).
|
|
18
|
+
* @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.
|
|
20
19
|
*/
|
|
21
20
|
export declare class TradeAggregationCallBuilder extends CallBuilder<ServerApi.CollectionPage<TradeAggregationRecord>> {
|
|
22
21
|
constructor(serverUrl: URI, base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number);
|
|
23
22
|
/**
|
|
24
23
|
* @private
|
|
25
|
-
* @param {
|
|
24
|
+
* @param {number} resolution Trade data resolution in milliseconds
|
|
26
25
|
* @returns {boolean} true if the resolution is allowed
|
|
27
26
|
*/
|
|
28
27
|
private isValidResolution;
|
|
29
28
|
/**
|
|
30
29
|
* @private
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
30
|
+
* @param {number} offset Time offset in milliseconds
|
|
31
|
+
* @param {number} resolution Trade data resolution in milliseconds
|
|
33
32
|
* @returns {boolean} true if the offset is valid
|
|
34
33
|
*/
|
|
35
34
|
private isValidOffset;
|
|
@@ -62,13 +62,9 @@ var TradeAggregationCallBuilder = exports.TradeAggregationCallBuilder = function
|
|
|
62
62
|
return _createClass(TradeAggregationCallBuilder, [{
|
|
63
63
|
key: "isValidResolution",
|
|
64
64
|
value: function isValidResolution(resolution) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
65
|
+
return allowedResolutions.some(function (allowed) {
|
|
66
|
+
return allowed === resolution;
|
|
67
|
+
});
|
|
72
68
|
}
|
|
73
69
|
}, {
|
|
74
70
|
key: "isValidOffset",
|
|
@@ -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#trades}.
|
|
8
7
|
*
|
|
9
8
|
* @class TradesCallBuilder
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
9
|
+
* @augments CallBuilder
|
|
10
|
+
* @class
|
|
12
11
|
* @see [Trades](https://developers.stellar.org/api/resources/trades/)
|
|
13
12
|
* @param {string} serverUrl serverUrl Horizon server URL.
|
|
14
13
|
*/
|
|
@@ -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#transactions}.
|
|
7
6
|
*
|
|
8
7
|
* @class TransactionCallBuilder
|
|
9
|
-
* @
|
|
8
|
+
* @augments CallBuilder
|
|
10
9
|
* @see [All Transactions](https://developers.stellar.org/api/resources/transactions/)
|
|
11
|
-
* @
|
|
10
|
+
* @class
|
|
12
11
|
* @param {string} serverUrl Horizon server URL.
|
|
13
12
|
*/
|
|
14
13
|
export declare class TransactionCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.TransactionRecord>> {
|
|
@@ -51,7 +50,7 @@ export declare class TransactionCallBuilder extends CallBuilder<ServerApi.Collec
|
|
|
51
50
|
/**
|
|
52
51
|
* Adds a parameter defining whether to include failed transactions. By default only successful transactions are
|
|
53
52
|
* returned.
|
|
54
|
-
* @param {
|
|
53
|
+
* @param {boolean} value Set to `true` to include failed transactions.
|
|
55
54
|
* @returns {TransactionCallBuilder} current TransactionCallBuilder instance
|
|
56
55
|
*/
|
|
57
56
|
includeFailed(value: boolean): this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetType } from "@stellar/stellar-base";
|
|
2
|
-
import { HorizonApi } from "
|
|
2
|
+
import { HorizonApi } from "../horizon_api";
|
|
3
3
|
export interface AssetRecord extends HorizonApi.BaseResponse {
|
|
4
4
|
asset_type: AssetType.credit4 | AssetType.credit12;
|
|
5
5
|
asset_code: string;
|
package/lib/index.d.ts
CHANGED