@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.
- package/CHANGELOG.md +1275 -0
- package/LICENSE +228 -0
- package/README.md +274 -0
- package/dist/stellar-sdk.js +56470 -0
- package/dist/stellar-sdk.min.js +2 -0
- package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
- package/lib/browser.d.ts +6 -0
- package/lib/browser.js +37 -0
- package/lib/config.d.ts +52 -0
- package/lib/config.js +49 -0
- package/lib/contract_spec.d.ts +130 -0
- package/lib/contract_spec.js +549 -0
- package/lib/errors.d.ts +59 -0
- package/lib/errors.js +105 -0
- package/lib/federation/api.d.ts +11 -0
- package/lib/federation/api.js +7 -0
- package/lib/federation/index.d.ts +2 -0
- package/lib/federation/index.js +24 -0
- package/lib/federation/server.d.ts +118 -0
- package/lib/federation/server.js +253 -0
- package/lib/friendbot/index.d.ts +5 -0
- package/lib/friendbot/index.js +7 -0
- package/lib/horizon/account_call_builder.d.ts +55 -0
- package/lib/horizon/account_call_builder.js +64 -0
- package/lib/horizon/account_response.d.ts +58 -0
- package/lib/horizon/account_response.js +50 -0
- package/lib/horizon/assets_call_builder.d.ts +27 -0
- package/lib/horizon/assets_call_builder.js +45 -0
- package/lib/horizon/call_builder.d.ts +128 -0
- package/lib/horizon/call_builder.js +360 -0
- package/lib/horizon/claimable_balances_call_builder.d.ts +49 -0
- package/lib/horizon/claimable_balances_call_builder.js +58 -0
- package/lib/horizon/effect_call_builder.d.ts +53 -0
- package/lib/horizon/effect_call_builder.js +58 -0
- package/lib/horizon/friendbot_builder.d.ts +5 -0
- package/lib/horizon/friendbot_builder.js +33 -0
- package/lib/horizon/horizon_api.d.ts +523 -0
- package/lib/horizon/horizon_api.js +96 -0
- package/lib/horizon/horizon_axios_client.d.ts +30 -0
- package/lib/horizon/horizon_axios_client.js +48 -0
- package/lib/horizon/index.d.ts +7 -0
- package/lib/horizon/index.js +78 -0
- package/lib/horizon/ledger_call_builder.d.ts +22 -0
- package/lib/horizon/ledger_call_builder.js +39 -0
- package/lib/horizon/liquidity_pool_call_builder.d.ts +38 -0
- package/lib/horizon/liquidity_pool_call_builder.js +61 -0
- package/lib/horizon/offer_call_builder.d.ts +64 -0
- package/lib/horizon/offer_call_builder.js +81 -0
- package/lib/horizon/operation_call_builder.d.ts +68 -0
- package/lib/horizon/operation_call_builder.js +71 -0
- package/lib/horizon/orderbook_call_builder.d.ts +16 -0
- package/lib/horizon/orderbook_call_builder.js +46 -0
- package/lib/horizon/path_call_builder.d.ts +31 -0
- package/lib/horizon/path_call_builder.js +42 -0
- package/lib/horizon/payment_call_builder.d.ts +36 -0
- package/lib/horizon/payment_call_builder.js +48 -0
- package/lib/horizon/server.d.ts +361 -0
- package/lib/horizon/server.js +507 -0
- package/lib/horizon/server_api.d.ts +279 -0
- package/lib/horizon/server_api.js +19 -0
- package/lib/horizon/strict_receive_path_call_builder.d.ts +34 -0
- package/lib/horizon/strict_receive_path_call_builder.js +51 -0
- package/lib/horizon/strict_send_path_call_builder.d.ts +34 -0
- package/lib/horizon/strict_send_path_call_builder.js +51 -0
- package/lib/horizon/trade_aggregation_call_builder.d.ts +48 -0
- package/lib/horizon/trade_aggregation_call_builder.js +82 -0
- package/lib/horizon/trades_call_builder.d.ts +50 -0
- package/lib/horizon/trades_call_builder.js +74 -0
- package/lib/horizon/transaction_call_builder.d.ts +58 -0
- package/lib/horizon/transaction_call_builder.js +66 -0
- package/lib/horizon/types/account.d.ts +5 -0
- package/lib/horizon/types/account.js +5 -0
- package/lib/horizon/types/assets.d.ts +19 -0
- package/lib/horizon/types/assets.js +5 -0
- package/lib/horizon/types/effects.d.ts +285 -0
- package/lib/horizon/types/effects.js +62 -0
- package/lib/horizon/types/offer.d.ts +20 -0
- package/lib/horizon/types/offer.js +5 -0
- package/lib/horizon/types/trade.d.ts +13 -0
- package/lib/horizon/types/trade.js +5 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +79 -0
- package/lib/soroban/api.d.ts +247 -0
- package/lib/soroban/api.js +32 -0
- package/lib/soroban/axios.d.ts +3 -0
- package/lib/soroban/axios.js +16 -0
- package/lib/soroban/browser.d.ts +6 -0
- package/lib/soroban/browser.js +37 -0
- package/lib/soroban/index.d.ts +8 -0
- package/lib/soroban/index.js +72 -0
- package/lib/soroban/jsonrpc.d.ts +33 -0
- package/lib/soroban/jsonrpc.js +93 -0
- package/lib/soroban/parsers.d.ts +17 -0
- package/lib/soroban/parsers.js +111 -0
- package/lib/soroban/server.d.ts +427 -0
- package/lib/soroban/server.js +598 -0
- package/lib/soroban/transaction.d.ts +20 -0
- package/lib/soroban/transaction.js +55 -0
- package/lib/soroban/utils.d.ts +1 -0
- package/lib/soroban/utils.js +9 -0
- package/lib/stellartoml/index.d.ts +121 -0
- package/lib/stellartoml/index.js +78 -0
- package/lib/utils.d.ts +12 -0
- package/lib/utils.js +32 -0
- package/lib/webauth/errors.d.ts +4 -0
- package/lib/webauth/errors.js +37 -0
- package/lib/webauth/index.d.ts +2 -0
- package/lib/webauth/index.js +27 -0
- package/lib/webauth/utils.d.ts +294 -0
- package/lib/webauth/utils.js +332 -0
- package/package.json +153 -0
- package/types/dom-monkeypatch.d.ts +126 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Server = exports.SUBMIT_TRANSACTION_TIMEOUT = exports.Durability = void 0;
|
|
7
|
+
var _urijs = _interopRequireDefault(require("urijs"));
|
|
8
|
+
var _stellarBase = require("@stellar/stellar-base");
|
|
9
|
+
var _axios = _interopRequireDefault(require("./axios"));
|
|
10
|
+
var jsonrpc = _interopRequireWildcard(require("./jsonrpc"));
|
|
11
|
+
var _api = require("./api");
|
|
12
|
+
var _transaction = require("./transaction");
|
|
13
|
+
var _parsers = require("./parsers");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
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 && Object.prototype.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; }
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
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 new 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 new 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 new 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; }
|
|
25
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
26
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
27
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
+
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); } }
|
|
29
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
31
|
+
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); }
|
|
32
|
+
var SUBMIT_TRANSACTION_TIMEOUT = exports.SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000;
|
|
33
|
+
var Durability = exports.Durability = function (Durability) {
|
|
34
|
+
Durability["Temporary"] = "temporary";
|
|
35
|
+
Durability["Persistent"] = "persistent";
|
|
36
|
+
return Durability;
|
|
37
|
+
}({});
|
|
38
|
+
var Server = exports.Server = function () {
|
|
39
|
+
function Server(serverURL) {
|
|
40
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
|
+
_classCallCheck(this, Server);
|
|
42
|
+
this.serverURL = (0, _urijs.default)(serverURL);
|
|
43
|
+
if (opts.headers && Object.keys(opts.headers).length === 0) {
|
|
44
|
+
_axios.default.interceptors.request.use(function (config) {
|
|
45
|
+
config.headers = Object.assign(config.headers, opts.headers);
|
|
46
|
+
return config;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (this.serverURL.protocol() !== 'https' && !opts.allowHttp) {
|
|
50
|
+
throw new Error("Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_createClass(Server, [{
|
|
54
|
+
key: "getAccount",
|
|
55
|
+
value: (function () {
|
|
56
|
+
var _getAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(address) {
|
|
57
|
+
var ledgerKey, resp, accountEntry;
|
|
58
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
|
+
while (1) switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
ledgerKey = _stellarBase.xdr.LedgerKey.account(new _stellarBase.xdr.LedgerKeyAccount({
|
|
62
|
+
accountId: _stellarBase.Keypair.fromPublicKey(address).xdrPublicKey()
|
|
63
|
+
}));
|
|
64
|
+
_context.next = 3;
|
|
65
|
+
return this.getLedgerEntries(ledgerKey);
|
|
66
|
+
case 3:
|
|
67
|
+
resp = _context.sent;
|
|
68
|
+
if (!(resp.entries.length === 0)) {
|
|
69
|
+
_context.next = 6;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return _context.abrupt("return", Promise.reject({
|
|
73
|
+
code: 404,
|
|
74
|
+
message: "Account not found: ".concat(address)
|
|
75
|
+
}));
|
|
76
|
+
case 6:
|
|
77
|
+
accountEntry = resp.entries[0].val.account();
|
|
78
|
+
return _context.abrupt("return", new _stellarBase.Account(address, accountEntry.seqNum().toString()));
|
|
79
|
+
case 8:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee, this);
|
|
84
|
+
}));
|
|
85
|
+
function getAccount(_x) {
|
|
86
|
+
return _getAccount.apply(this, arguments);
|
|
87
|
+
}
|
|
88
|
+
return getAccount;
|
|
89
|
+
}())
|
|
90
|
+
}, {
|
|
91
|
+
key: "getHealth",
|
|
92
|
+
value: (function () {
|
|
93
|
+
var _getHealth = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
|
|
94
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
95
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
96
|
+
case 0:
|
|
97
|
+
return _context2.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'getHealth'));
|
|
98
|
+
case 1:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee2, this);
|
|
103
|
+
}));
|
|
104
|
+
function getHealth() {
|
|
105
|
+
return _getHealth.apply(this, arguments);
|
|
106
|
+
}
|
|
107
|
+
return getHealth;
|
|
108
|
+
}())
|
|
109
|
+
}, {
|
|
110
|
+
key: "getContractData",
|
|
111
|
+
value: (function () {
|
|
112
|
+
var _getContractData = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3(contract, key) {
|
|
113
|
+
var durability,
|
|
114
|
+
scAddress,
|
|
115
|
+
xdrDurability,
|
|
116
|
+
contractKey,
|
|
117
|
+
_args3 = arguments;
|
|
118
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
119
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
durability = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : Durability.Persistent;
|
|
122
|
+
if (!(typeof contract === 'string')) {
|
|
123
|
+
_context3.next = 5;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
scAddress = new _stellarBase.Contract(contract).address().toScAddress();
|
|
127
|
+
_context3.next = 14;
|
|
128
|
+
break;
|
|
129
|
+
case 5:
|
|
130
|
+
if (!(contract instanceof _stellarBase.Address)) {
|
|
131
|
+
_context3.next = 9;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
scAddress = contract.toScAddress();
|
|
135
|
+
_context3.next = 14;
|
|
136
|
+
break;
|
|
137
|
+
case 9:
|
|
138
|
+
if (!(contract instanceof _stellarBase.Contract)) {
|
|
139
|
+
_context3.next = 13;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
scAddress = contract.address().toScAddress();
|
|
143
|
+
_context3.next = 14;
|
|
144
|
+
break;
|
|
145
|
+
case 13:
|
|
146
|
+
throw new TypeError("unknown contract type: ".concat(contract));
|
|
147
|
+
case 14:
|
|
148
|
+
_context3.t0 = durability;
|
|
149
|
+
_context3.next = _context3.t0 === Durability.Temporary ? 17 : _context3.t0 === Durability.Persistent ? 19 : 21;
|
|
150
|
+
break;
|
|
151
|
+
case 17:
|
|
152
|
+
xdrDurability = _stellarBase.xdr.ContractDataDurability.temporary();
|
|
153
|
+
return _context3.abrupt("break", 22);
|
|
154
|
+
case 19:
|
|
155
|
+
xdrDurability = _stellarBase.xdr.ContractDataDurability.persistent();
|
|
156
|
+
return _context3.abrupt("break", 22);
|
|
157
|
+
case 21:
|
|
158
|
+
throw new TypeError("invalid durability: ".concat(durability));
|
|
159
|
+
case 22:
|
|
160
|
+
contractKey = _stellarBase.xdr.LedgerKey.contractData(new _stellarBase.xdr.LedgerKeyContractData({
|
|
161
|
+
key: key,
|
|
162
|
+
contract: scAddress,
|
|
163
|
+
durability: xdrDurability
|
|
164
|
+
}));
|
|
165
|
+
return _context3.abrupt("return", this.getLedgerEntries(contractKey).then(function (r) {
|
|
166
|
+
if (r.entries.length === 0) {
|
|
167
|
+
return Promise.reject({
|
|
168
|
+
code: 404,
|
|
169
|
+
message: "Contract data not found. Contract: ".concat(_stellarBase.Address.fromScAddress(scAddress).toString(), ", Key: ").concat(key.toXDR('base64'), ", Durability: ").concat(durability)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return r.entries[0];
|
|
173
|
+
}));
|
|
174
|
+
case 24:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context3.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee3, this);
|
|
179
|
+
}));
|
|
180
|
+
function getContractData(_x2, _x3) {
|
|
181
|
+
return _getContractData.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
return getContractData;
|
|
184
|
+
}())
|
|
185
|
+
}, {
|
|
186
|
+
key: "getLedgerEntries",
|
|
187
|
+
value: (function () {
|
|
188
|
+
var _getLedgerEntries2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
|
|
189
|
+
var _args4 = arguments;
|
|
190
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
191
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
192
|
+
case 0:
|
|
193
|
+
return _context4.abrupt("return", this._getLedgerEntries.apply(this, _args4).then(_parsers.parseRawLedgerEntries));
|
|
194
|
+
case 1:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context4.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee4, this);
|
|
199
|
+
}));
|
|
200
|
+
function getLedgerEntries() {
|
|
201
|
+
return _getLedgerEntries2.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
return getLedgerEntries;
|
|
204
|
+
}())
|
|
205
|
+
}, {
|
|
206
|
+
key: "_getLedgerEntries",
|
|
207
|
+
value: function () {
|
|
208
|
+
var _getLedgerEntries3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5() {
|
|
209
|
+
var _len,
|
|
210
|
+
keys,
|
|
211
|
+
_key,
|
|
212
|
+
_args5 = arguments;
|
|
213
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
214
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
215
|
+
case 0:
|
|
216
|
+
for (_len = _args5.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
217
|
+
keys[_key] = _args5[_key];
|
|
218
|
+
}
|
|
219
|
+
return _context5.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'getLedgerEntries', keys.map(function (k) {
|
|
220
|
+
return k.toXDR('base64');
|
|
221
|
+
})));
|
|
222
|
+
case 2:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context5.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee5, this);
|
|
227
|
+
}));
|
|
228
|
+
function _getLedgerEntries() {
|
|
229
|
+
return _getLedgerEntries3.apply(this, arguments);
|
|
230
|
+
}
|
|
231
|
+
return _getLedgerEntries;
|
|
232
|
+
}()
|
|
233
|
+
}, {
|
|
234
|
+
key: "getTransaction",
|
|
235
|
+
value: (function () {
|
|
236
|
+
var _getTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(hash) {
|
|
237
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
238
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
return _context6.abrupt("return", this._getTransaction(hash).then(function (raw) {
|
|
241
|
+
var foundInfo = {};
|
|
242
|
+
if (raw.status !== _api.Api.GetTransactionStatus.NOT_FOUND) {
|
|
243
|
+
var _meta$v3$sorobanMeta;
|
|
244
|
+
var meta = _stellarBase.xdr.TransactionMeta.fromXDR(raw.resultMetaXdr, 'base64');
|
|
245
|
+
foundInfo = _objectSpread({
|
|
246
|
+
ledger: raw.ledger,
|
|
247
|
+
createdAt: raw.createdAt,
|
|
248
|
+
applicationOrder: raw.applicationOrder,
|
|
249
|
+
feeBump: raw.feeBump,
|
|
250
|
+
envelopeXdr: _stellarBase.xdr.TransactionEnvelope.fromXDR(raw.envelopeXdr, 'base64'),
|
|
251
|
+
resultXdr: _stellarBase.xdr.TransactionResult.fromXDR(raw.resultXdr, 'base64'),
|
|
252
|
+
resultMetaXdr: meta
|
|
253
|
+
}, meta.switch() === 3 && meta.v3().sorobanMeta() !== null && raw.status === _api.Api.GetTransactionStatus.SUCCESS && {
|
|
254
|
+
returnValue: (_meta$v3$sorobanMeta = meta.v3().sorobanMeta()) === null || _meta$v3$sorobanMeta === void 0 ? void 0 : _meta$v3$sorobanMeta.returnValue()
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
var result = _objectSpread({
|
|
258
|
+
status: raw.status,
|
|
259
|
+
latestLedger: raw.latestLedger,
|
|
260
|
+
latestLedgerCloseTime: raw.latestLedgerCloseTime,
|
|
261
|
+
oldestLedger: raw.oldestLedger,
|
|
262
|
+
oldestLedgerCloseTime: raw.oldestLedgerCloseTime
|
|
263
|
+
}, foundInfo);
|
|
264
|
+
return result;
|
|
265
|
+
}));
|
|
266
|
+
case 1:
|
|
267
|
+
case "end":
|
|
268
|
+
return _context6.stop();
|
|
269
|
+
}
|
|
270
|
+
}, _callee6, this);
|
|
271
|
+
}));
|
|
272
|
+
function getTransaction(_x4) {
|
|
273
|
+
return _getTransaction2.apply(this, arguments);
|
|
274
|
+
}
|
|
275
|
+
return getTransaction;
|
|
276
|
+
}())
|
|
277
|
+
}, {
|
|
278
|
+
key: "_getTransaction",
|
|
279
|
+
value: function () {
|
|
280
|
+
var _getTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7(hash) {
|
|
281
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
282
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
return _context7.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'getTransaction', hash));
|
|
285
|
+
case 1:
|
|
286
|
+
case "end":
|
|
287
|
+
return _context7.stop();
|
|
288
|
+
}
|
|
289
|
+
}, _callee7, this);
|
|
290
|
+
}));
|
|
291
|
+
function _getTransaction(_x5) {
|
|
292
|
+
return _getTransaction3.apply(this, arguments);
|
|
293
|
+
}
|
|
294
|
+
return _getTransaction;
|
|
295
|
+
}()
|
|
296
|
+
}, {
|
|
297
|
+
key: "getEvents",
|
|
298
|
+
value: (function () {
|
|
299
|
+
var _getEvents2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(request) {
|
|
300
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
301
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
return _context8.abrupt("return", this._getEvents(request).then(_parsers.parseRawEvents));
|
|
304
|
+
case 1:
|
|
305
|
+
case "end":
|
|
306
|
+
return _context8.stop();
|
|
307
|
+
}
|
|
308
|
+
}, _callee8, this);
|
|
309
|
+
}));
|
|
310
|
+
function getEvents(_x6) {
|
|
311
|
+
return _getEvents2.apply(this, arguments);
|
|
312
|
+
}
|
|
313
|
+
return getEvents;
|
|
314
|
+
}())
|
|
315
|
+
}, {
|
|
316
|
+
key: "_getEvents",
|
|
317
|
+
value: function () {
|
|
318
|
+
var _getEvents3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(request) {
|
|
319
|
+
var _request$filters;
|
|
320
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
321
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
return _context9.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getEvents', _objectSpread({
|
|
324
|
+
filters: (_request$filters = request.filters) !== null && _request$filters !== void 0 ? _request$filters : [],
|
|
325
|
+
pagination: _objectSpread(_objectSpread({}, request.cursor && {
|
|
326
|
+
cursor: request.cursor
|
|
327
|
+
}), request.limit && {
|
|
328
|
+
limit: request.limit
|
|
329
|
+
})
|
|
330
|
+
}, request.startLedger && {
|
|
331
|
+
startLedger: request.startLedger.toString()
|
|
332
|
+
})));
|
|
333
|
+
case 1:
|
|
334
|
+
case "end":
|
|
335
|
+
return _context9.stop();
|
|
336
|
+
}
|
|
337
|
+
}, _callee9, this);
|
|
338
|
+
}));
|
|
339
|
+
function _getEvents(_x7) {
|
|
340
|
+
return _getEvents3.apply(this, arguments);
|
|
341
|
+
}
|
|
342
|
+
return _getEvents;
|
|
343
|
+
}()
|
|
344
|
+
}, {
|
|
345
|
+
key: "getNetwork",
|
|
346
|
+
value: (function () {
|
|
347
|
+
var _getNetwork = _asyncToGenerator(_regeneratorRuntime().mark(function _callee10() {
|
|
348
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
349
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
350
|
+
case 0:
|
|
351
|
+
_context10.next = 2;
|
|
352
|
+
return jsonrpc.post(this.serverURL.toString(), 'getNetwork');
|
|
353
|
+
case 2:
|
|
354
|
+
return _context10.abrupt("return", _context10.sent);
|
|
355
|
+
case 3:
|
|
356
|
+
case "end":
|
|
357
|
+
return _context10.stop();
|
|
358
|
+
}
|
|
359
|
+
}, _callee10, this);
|
|
360
|
+
}));
|
|
361
|
+
function getNetwork() {
|
|
362
|
+
return _getNetwork.apply(this, arguments);
|
|
363
|
+
}
|
|
364
|
+
return getNetwork;
|
|
365
|
+
}())
|
|
366
|
+
}, {
|
|
367
|
+
key: "getLatestLedger",
|
|
368
|
+
value: (function () {
|
|
369
|
+
var _getLatestLedger = _asyncToGenerator(_regeneratorRuntime().mark(function _callee11() {
|
|
370
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
371
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
372
|
+
case 0:
|
|
373
|
+
return _context11.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'getLatestLedger'));
|
|
374
|
+
case 1:
|
|
375
|
+
case "end":
|
|
376
|
+
return _context11.stop();
|
|
377
|
+
}
|
|
378
|
+
}, _callee11, this);
|
|
379
|
+
}));
|
|
380
|
+
function getLatestLedger() {
|
|
381
|
+
return _getLatestLedger.apply(this, arguments);
|
|
382
|
+
}
|
|
383
|
+
return getLatestLedger;
|
|
384
|
+
}())
|
|
385
|
+
}, {
|
|
386
|
+
key: "simulateTransaction",
|
|
387
|
+
value: (function () {
|
|
388
|
+
var _simulateTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee12(transaction) {
|
|
389
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
390
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
391
|
+
case 0:
|
|
392
|
+
return _context12.abrupt("return", this._simulateTransaction(transaction).then(_parsers.parseRawSimulation));
|
|
393
|
+
case 1:
|
|
394
|
+
case "end":
|
|
395
|
+
return _context12.stop();
|
|
396
|
+
}
|
|
397
|
+
}, _callee12, this);
|
|
398
|
+
}));
|
|
399
|
+
function simulateTransaction(_x8) {
|
|
400
|
+
return _simulateTransaction2.apply(this, arguments);
|
|
401
|
+
}
|
|
402
|
+
return simulateTransaction;
|
|
403
|
+
}())
|
|
404
|
+
}, {
|
|
405
|
+
key: "_simulateTransaction",
|
|
406
|
+
value: function () {
|
|
407
|
+
var _simulateTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee13(transaction) {
|
|
408
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
409
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
410
|
+
case 0:
|
|
411
|
+
return _context13.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'simulateTransaction', transaction.toXDR()));
|
|
412
|
+
case 1:
|
|
413
|
+
case "end":
|
|
414
|
+
return _context13.stop();
|
|
415
|
+
}
|
|
416
|
+
}, _callee13, this);
|
|
417
|
+
}));
|
|
418
|
+
function _simulateTransaction(_x9) {
|
|
419
|
+
return _simulateTransaction3.apply(this, arguments);
|
|
420
|
+
}
|
|
421
|
+
return _simulateTransaction;
|
|
422
|
+
}()
|
|
423
|
+
}, {
|
|
424
|
+
key: "prepareTransaction",
|
|
425
|
+
value: (function () {
|
|
426
|
+
var _prepareTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee14(tx) {
|
|
427
|
+
var simResponse;
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
429
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
_context14.next = 2;
|
|
432
|
+
return this.simulateTransaction(tx);
|
|
433
|
+
case 2:
|
|
434
|
+
simResponse = _context14.sent;
|
|
435
|
+
if (!_api.Api.isSimulationError(simResponse)) {
|
|
436
|
+
_context14.next = 5;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
throw simResponse.error;
|
|
440
|
+
case 5:
|
|
441
|
+
return _context14.abrupt("return", (0, _transaction.assembleTransaction)(tx, simResponse).build());
|
|
442
|
+
case 6:
|
|
443
|
+
case "end":
|
|
444
|
+
return _context14.stop();
|
|
445
|
+
}
|
|
446
|
+
}, _callee14, this);
|
|
447
|
+
}));
|
|
448
|
+
function prepareTransaction(_x10) {
|
|
449
|
+
return _prepareTransaction.apply(this, arguments);
|
|
450
|
+
}
|
|
451
|
+
return prepareTransaction;
|
|
452
|
+
}())
|
|
453
|
+
}, {
|
|
454
|
+
key: "sendTransaction",
|
|
455
|
+
value: (function () {
|
|
456
|
+
var _sendTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee15(transaction) {
|
|
457
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
458
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
459
|
+
case 0:
|
|
460
|
+
return _context15.abrupt("return", this._sendTransaction(transaction).then(_parsers.parseRawSendTransaction));
|
|
461
|
+
case 1:
|
|
462
|
+
case "end":
|
|
463
|
+
return _context15.stop();
|
|
464
|
+
}
|
|
465
|
+
}, _callee15, this);
|
|
466
|
+
}));
|
|
467
|
+
function sendTransaction(_x11) {
|
|
468
|
+
return _sendTransaction2.apply(this, arguments);
|
|
469
|
+
}
|
|
470
|
+
return sendTransaction;
|
|
471
|
+
}())
|
|
472
|
+
}, {
|
|
473
|
+
key: "_sendTransaction",
|
|
474
|
+
value: function () {
|
|
475
|
+
var _sendTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee16(transaction) {
|
|
476
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
477
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
478
|
+
case 0:
|
|
479
|
+
return _context16.abrupt("return", jsonrpc.post(this.serverURL.toString(), 'sendTransaction', transaction.toXDR()));
|
|
480
|
+
case 1:
|
|
481
|
+
case "end":
|
|
482
|
+
return _context16.stop();
|
|
483
|
+
}
|
|
484
|
+
}, _callee16, this);
|
|
485
|
+
}));
|
|
486
|
+
function _sendTransaction(_x12) {
|
|
487
|
+
return _sendTransaction3.apply(this, arguments);
|
|
488
|
+
}
|
|
489
|
+
return _sendTransaction;
|
|
490
|
+
}()
|
|
491
|
+
}, {
|
|
492
|
+
key: "requestAirdrop",
|
|
493
|
+
value: (function () {
|
|
494
|
+
var _requestAirdrop = _asyncToGenerator(_regeneratorRuntime().mark(function _callee17(address, friendbotUrl) {
|
|
495
|
+
var account, response, meta, sequence, _error$response, _error$response$detai;
|
|
496
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
497
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
498
|
+
case 0:
|
|
499
|
+
account = typeof address === 'string' ? address : address.accountId();
|
|
500
|
+
_context17.t0 = friendbotUrl;
|
|
501
|
+
if (_context17.t0) {
|
|
502
|
+
_context17.next = 6;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
_context17.next = 5;
|
|
506
|
+
return this.getNetwork();
|
|
507
|
+
case 5:
|
|
508
|
+
_context17.t0 = _context17.sent.friendbotUrl;
|
|
509
|
+
case 6:
|
|
510
|
+
friendbotUrl = _context17.t0;
|
|
511
|
+
if (friendbotUrl) {
|
|
512
|
+
_context17.next = 9;
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
throw new Error('No friendbot URL configured for current network');
|
|
516
|
+
case 9:
|
|
517
|
+
_context17.prev = 9;
|
|
518
|
+
_context17.next = 12;
|
|
519
|
+
return _axios.default.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
520
|
+
case 12:
|
|
521
|
+
response = _context17.sent;
|
|
522
|
+
meta = _stellarBase.xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, 'base64');
|
|
523
|
+
sequence = findCreatedAccountSequenceInTransactionMeta(meta);
|
|
524
|
+
return _context17.abrupt("return", new _stellarBase.Account(account, sequence));
|
|
525
|
+
case 18:
|
|
526
|
+
_context17.prev = 18;
|
|
527
|
+
_context17.t1 = _context17["catch"](9);
|
|
528
|
+
if (!(((_error$response = _context17.t1.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 400)) {
|
|
529
|
+
_context17.next = 23;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
if (!((_error$response$detai = _context17.t1.response.detail) !== null && _error$response$detai !== void 0 && _error$response$detai.includes('createAccountAlreadyExist'))) {
|
|
533
|
+
_context17.next = 23;
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
return _context17.abrupt("return", this.getAccount(account));
|
|
537
|
+
case 23:
|
|
538
|
+
throw _context17.t1;
|
|
539
|
+
case 24:
|
|
540
|
+
case "end":
|
|
541
|
+
return _context17.stop();
|
|
542
|
+
}
|
|
543
|
+
}, _callee17, this, [[9, 18]]);
|
|
544
|
+
}));
|
|
545
|
+
function requestAirdrop(_x13, _x14) {
|
|
546
|
+
return _requestAirdrop.apply(this, arguments);
|
|
547
|
+
}
|
|
548
|
+
return requestAirdrop;
|
|
549
|
+
}())
|
|
550
|
+
}]);
|
|
551
|
+
return Server;
|
|
552
|
+
}();
|
|
553
|
+
function findCreatedAccountSequenceInTransactionMeta(meta) {
|
|
554
|
+
var operations = [];
|
|
555
|
+
switch (meta.switch()) {
|
|
556
|
+
case 0:
|
|
557
|
+
operations = meta.operations();
|
|
558
|
+
break;
|
|
559
|
+
case 1:
|
|
560
|
+
case 2:
|
|
561
|
+
case 3:
|
|
562
|
+
operations = meta.value().operations();
|
|
563
|
+
break;
|
|
564
|
+
default:
|
|
565
|
+
throw new Error('Unexpected transaction meta switch value');
|
|
566
|
+
}
|
|
567
|
+
var _iterator = _createForOfIteratorHelper(operations),
|
|
568
|
+
_step;
|
|
569
|
+
try {
|
|
570
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
571
|
+
var op = _step.value;
|
|
572
|
+
var _iterator2 = _createForOfIteratorHelper(op.changes()),
|
|
573
|
+
_step2;
|
|
574
|
+
try {
|
|
575
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
576
|
+
var c = _step2.value;
|
|
577
|
+
if (c.switch() !== _stellarBase.xdr.LedgerEntryChangeType.ledgerEntryCreated()) {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
var data = c.created().data();
|
|
581
|
+
if (data.switch() !== _stellarBase.xdr.LedgerEntryType.account()) {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
return data.account().seqNum().toString();
|
|
585
|
+
}
|
|
586
|
+
} catch (err) {
|
|
587
|
+
_iterator2.e(err);
|
|
588
|
+
} finally {
|
|
589
|
+
_iterator2.f();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
} catch (err) {
|
|
593
|
+
_iterator.e(err);
|
|
594
|
+
} finally {
|
|
595
|
+
_iterator.f();
|
|
596
|
+
}
|
|
597
|
+
throw new Error('No account created in transaction');
|
|
598
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FeeBumpTransaction, Transaction, TransactionBuilder } from '@stellar/stellar-base';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
/**
|
|
4
|
+
* Combines the given raw transaction alongside the simulation results.
|
|
5
|
+
*
|
|
6
|
+
* @param raw the initial transaction, w/o simulation applied
|
|
7
|
+
* @param simulation the Soroban RPC simulation result (see
|
|
8
|
+
* {@link Server.simulateTransaction})
|
|
9
|
+
*
|
|
10
|
+
* @returns a new, cloned transaction with the proper auth and resource (fee,
|
|
11
|
+
* footprint) simulation data applied
|
|
12
|
+
*
|
|
13
|
+
* @note if the given transaction already has authorization entries in a host
|
|
14
|
+
* function invocation (see {@link Operation.invokeHostFunction}), **the
|
|
15
|
+
* simulation entries are ignored**.
|
|
16
|
+
*
|
|
17
|
+
* @see {Server.simulateTransaction}
|
|
18
|
+
* @see {Server.prepareTransaction}
|
|
19
|
+
*/
|
|
20
|
+
export declare function assembleTransaction(raw: Transaction | FeeBumpTransaction, simulation: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): TransactionBuilder;
|