@stellar/stellar-sdk 14.3.3 → 14.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/dist/stellar-sdk-minimal.js +7220 -7111
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +3454 -3345
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +7471 -7362
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +7972 -7863
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/config.d.ts +2 -6
- package/lib/contract/assembled_transaction.d.ts +16 -132
- package/lib/contract/assembled_transaction.js +14 -114
- package/lib/contract/errors.d.ts +26 -0
- package/lib/contract/errors.js +126 -0
- package/lib/contract/sent_transaction.d.ts +1 -1
- package/lib/contract/spec.d.ts +2 -2
- package/lib/contract/spec.js +31 -28
- package/lib/contract/types.d.ts +47 -8
- package/lib/contract/utils.d.ts +1 -1
- package/lib/contract/utils.js +18 -53
- package/lib/contract/wasm_spec_parser.d.ts +7 -0
- package/lib/contract/wasm_spec_parser.js +15 -0
- package/lib/errors/network.d.ts +1 -1
- package/lib/federation/server.d.ts +7 -7
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/server.d.ts +1 -1
- package/lib/horizon/server.js +2 -2
- package/lib/index.d.ts +0 -3
- package/lib/minimal/config.d.ts +2 -6
- package/lib/minimal/contract/assembled_transaction.d.ts +16 -132
- package/lib/minimal/contract/assembled_transaction.js +14 -114
- package/lib/minimal/contract/errors.d.ts +26 -0
- package/lib/minimal/contract/errors.js +126 -0
- package/lib/minimal/contract/sent_transaction.d.ts +1 -1
- package/lib/minimal/contract/spec.d.ts +2 -2
- package/lib/minimal/contract/spec.js +31 -28
- package/lib/minimal/contract/types.d.ts +47 -8
- package/lib/minimal/contract/utils.d.ts +1 -1
- package/lib/minimal/contract/utils.js +18 -53
- package/lib/minimal/contract/wasm_spec_parser.d.ts +7 -0
- package/lib/minimal/contract/wasm_spec_parser.js +15 -0
- package/lib/minimal/errors/network.d.ts +1 -1
- package/lib/minimal/federation/server.d.ts +7 -7
- package/lib/minimal/horizon/horizon_axios_client.js +1 -1
- package/lib/minimal/horizon/server.d.ts +1 -1
- package/lib/minimal/horizon/server.js +2 -2
- package/lib/minimal/index.d.ts +0 -3
- package/lib/minimal/rpc/api.d.ts +28 -4
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/jsonrpc.d.ts +2 -1
- package/lib/minimal/rpc/jsonrpc.js +1 -1
- package/lib/minimal/rpc/parsers.js +8 -5
- package/lib/minimal/rpc/server.d.ts +46 -7
- package/lib/minimal/rpc/server.js +290 -211
- package/lib/minimal/rpc/utils.js +1 -1
- package/lib/minimal/webauth/challenge_transaction.d.ts +235 -0
- package/lib/minimal/webauth/challenge_transaction.js +307 -0
- package/lib/minimal/webauth/index.d.ts +1 -0
- package/lib/minimal/webauth/index.js +13 -1
- package/lib/minimal/webauth/utils.d.ts +28 -273
- package/lib/minimal/webauth/utils.js +12 -288
- package/lib/no-axios/config.d.ts +2 -6
- package/lib/no-axios/contract/assembled_transaction.d.ts +16 -132
- package/lib/no-axios/contract/assembled_transaction.js +14 -114
- package/lib/no-axios/contract/errors.d.ts +26 -0
- package/lib/no-axios/contract/errors.js +126 -0
- package/lib/no-axios/contract/sent_transaction.d.ts +1 -1
- package/lib/no-axios/contract/spec.d.ts +2 -2
- package/lib/no-axios/contract/spec.js +31 -28
- package/lib/no-axios/contract/types.d.ts +47 -8
- package/lib/no-axios/contract/utils.d.ts +1 -1
- package/lib/no-axios/contract/utils.js +18 -53
- package/lib/no-axios/contract/wasm_spec_parser.d.ts +7 -0
- package/lib/no-axios/contract/wasm_spec_parser.js +15 -0
- package/lib/no-axios/errors/network.d.ts +1 -1
- package/lib/no-axios/federation/server.d.ts +7 -7
- package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
- package/lib/no-axios/horizon/server.d.ts +1 -1
- package/lib/no-axios/horizon/server.js +2 -2
- package/lib/no-axios/index.d.ts +0 -3
- package/lib/no-axios/rpc/api.d.ts +28 -4
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/jsonrpc.d.ts +2 -1
- package/lib/no-axios/rpc/jsonrpc.js +1 -1
- package/lib/no-axios/rpc/parsers.js +8 -5
- package/lib/no-axios/rpc/server.d.ts +46 -7
- package/lib/no-axios/rpc/server.js +290 -211
- package/lib/no-axios/rpc/utils.js +1 -1
- package/lib/no-axios/webauth/challenge_transaction.d.ts +235 -0
- package/lib/no-axios/webauth/challenge_transaction.js +307 -0
- package/lib/no-axios/webauth/index.d.ts +1 -0
- package/lib/no-axios/webauth/index.js +13 -1
- package/lib/no-axios/webauth/utils.d.ts +28 -273
- package/lib/no-axios/webauth/utils.js +12 -288
- package/lib/no-eventsource/config.d.ts +2 -6
- package/lib/no-eventsource/contract/assembled_transaction.d.ts +16 -132
- package/lib/no-eventsource/contract/assembled_transaction.js +14 -114
- package/lib/no-eventsource/contract/errors.d.ts +26 -0
- package/lib/no-eventsource/contract/errors.js +126 -0
- package/lib/no-eventsource/contract/sent_transaction.d.ts +1 -1
- package/lib/no-eventsource/contract/spec.d.ts +2 -2
- package/lib/no-eventsource/contract/spec.js +31 -28
- package/lib/no-eventsource/contract/types.d.ts +47 -8
- package/lib/no-eventsource/contract/utils.d.ts +1 -1
- package/lib/no-eventsource/contract/utils.js +18 -53
- package/lib/no-eventsource/contract/wasm_spec_parser.d.ts +7 -0
- package/lib/no-eventsource/contract/wasm_spec_parser.js +15 -0
- package/lib/no-eventsource/errors/network.d.ts +1 -1
- package/lib/no-eventsource/federation/server.d.ts +7 -7
- package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
- package/lib/no-eventsource/horizon/server.d.ts +1 -1
- package/lib/no-eventsource/horizon/server.js +2 -2
- package/lib/no-eventsource/index.d.ts +0 -3
- package/lib/no-eventsource/rpc/api.d.ts +28 -4
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/jsonrpc.d.ts +2 -1
- package/lib/no-eventsource/rpc/jsonrpc.js +1 -1
- package/lib/no-eventsource/rpc/parsers.js +8 -5
- package/lib/no-eventsource/rpc/server.d.ts +46 -7
- package/lib/no-eventsource/rpc/server.js +290 -211
- package/lib/no-eventsource/rpc/utils.js +1 -1
- package/lib/no-eventsource/webauth/challenge_transaction.d.ts +235 -0
- package/lib/no-eventsource/webauth/challenge_transaction.js +307 -0
- package/lib/no-eventsource/webauth/index.d.ts +1 -0
- package/lib/no-eventsource/webauth/index.js +13 -1
- package/lib/no-eventsource/webauth/utils.d.ts +28 -273
- package/lib/no-eventsource/webauth/utils.js +12 -288
- package/lib/rpc/api.d.ts +28 -4
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/jsonrpc.d.ts +2 -1
- package/lib/rpc/jsonrpc.js +1 -1
- package/lib/rpc/parsers.js +8 -5
- package/lib/rpc/server.d.ts +46 -7
- package/lib/rpc/server.js +290 -211
- package/lib/rpc/utils.js +1 -1
- package/lib/webauth/challenge_transaction.d.ts +235 -0
- package/lib/webauth/challenge_transaction.js +307 -0
- package/lib/webauth/index.d.ts +1 -0
- package/lib/webauth/index.js +13 -1
- package/lib/webauth/utils.d.ts +28 -273
- package/lib/webauth/utils.js +12 -288
- package/package.json +14 -14
- package/types/dom-monkeypatch.d.ts +1 -1
package/lib/rpc/server.js
CHANGED
|
@@ -18,6 +18,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
20
|
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; }
|
|
21
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
22
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
26
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
21
27
|
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
22
28
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
23
29
|
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); }
|
|
@@ -220,16 +226,89 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
220
226
|
return getClaimableBalance;
|
|
221
227
|
}())
|
|
222
228
|
}, {
|
|
223
|
-
key: "
|
|
229
|
+
key: "getAssetBalance",
|
|
224
230
|
value: (function () {
|
|
225
|
-
var
|
|
231
|
+
var _getAssetBalance = _asyncToGenerator(_regenerator().m(function _callee5(address, asset, networkPassphrase) {
|
|
232
|
+
var addr, _yield$Promise$all, _yield$Promise$all2, tl, ll;
|
|
226
233
|
return _regenerator().w(function (_context5) {
|
|
227
234
|
while (1) switch (_context5.n) {
|
|
228
235
|
case 0:
|
|
229
|
-
|
|
236
|
+
addr = address;
|
|
237
|
+
if (!(typeof address === "string")) {
|
|
238
|
+
_context5.n = 1;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
addr = address;
|
|
242
|
+
_context5.n = 4;
|
|
243
|
+
break;
|
|
244
|
+
case 1:
|
|
245
|
+
if (!(address instanceof _stellarBase.Address)) {
|
|
246
|
+
_context5.n = 2;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
addr = address.toString();
|
|
250
|
+
_context5.n = 4;
|
|
251
|
+
break;
|
|
252
|
+
case 2:
|
|
253
|
+
if (!(address instanceof _stellarBase.Contract)) {
|
|
254
|
+
_context5.n = 3;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
addr = address.toString();
|
|
258
|
+
_context5.n = 4;
|
|
259
|
+
break;
|
|
260
|
+
case 3:
|
|
261
|
+
throw new TypeError("invalid address: ".concat(address));
|
|
262
|
+
case 4:
|
|
263
|
+
if (!_stellarBase.StrKey.isValidEd25519PublicKey(addr)) {
|
|
264
|
+
_context5.n = 6;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
_context5.n = 5;
|
|
268
|
+
return Promise.all([this.getTrustline(addr, asset), this.getLatestLedger()]);
|
|
269
|
+
case 5:
|
|
270
|
+
_yield$Promise$all = _context5.v;
|
|
271
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
272
|
+
tl = _yield$Promise$all2[0];
|
|
273
|
+
ll = _yield$Promise$all2[1];
|
|
274
|
+
return _context5.a(2, {
|
|
275
|
+
latestLedger: ll.sequence,
|
|
276
|
+
balanceEntry: {
|
|
277
|
+
amount: tl.balance().toString(),
|
|
278
|
+
authorized: Boolean(tl.flags() & _stellarBase.AuthRequiredFlag),
|
|
279
|
+
clawback: Boolean(tl.flags() & _stellarBase.AuthClawbackEnabledFlag),
|
|
280
|
+
revocable: Boolean(tl.flags() & _stellarBase.AuthRevocableFlag)
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
case 6:
|
|
284
|
+
if (!_stellarBase.StrKey.isValidContract(addr)) {
|
|
285
|
+
_context5.n = 7;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
return _context5.a(2, this.getSACBalance(addr, asset, networkPassphrase));
|
|
289
|
+
case 7:
|
|
290
|
+
throw new Error("invalid address: ".concat(address));
|
|
291
|
+
case 8:
|
|
292
|
+
return _context5.a(2);
|
|
230
293
|
}
|
|
231
294
|
}, _callee5, this);
|
|
232
295
|
}));
|
|
296
|
+
function getAssetBalance(_x6, _x7, _x8) {
|
|
297
|
+
return _getAssetBalance.apply(this, arguments);
|
|
298
|
+
}
|
|
299
|
+
return getAssetBalance;
|
|
300
|
+
}())
|
|
301
|
+
}, {
|
|
302
|
+
key: "getHealth",
|
|
303
|
+
value: (function () {
|
|
304
|
+
var _getHealth = _asyncToGenerator(_regenerator().m(function _callee6() {
|
|
305
|
+
return _regenerator().w(function (_context6) {
|
|
306
|
+
while (1) switch (_context6.n) {
|
|
307
|
+
case 0:
|
|
308
|
+
return _context6.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getHealth"));
|
|
309
|
+
}
|
|
310
|
+
}, _callee6, this);
|
|
311
|
+
}));
|
|
233
312
|
function getHealth() {
|
|
234
313
|
return _getHealth.apply(this, arguments);
|
|
235
314
|
}
|
|
@@ -238,53 +317,53 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
238
317
|
}, {
|
|
239
318
|
key: "getContractData",
|
|
240
319
|
value: (function () {
|
|
241
|
-
var _getContractData = _asyncToGenerator(_regenerator().m(function
|
|
320
|
+
var _getContractData = _asyncToGenerator(_regenerator().m(function _callee7(contract, key) {
|
|
242
321
|
var durability,
|
|
243
322
|
scAddress,
|
|
244
323
|
xdrDurability,
|
|
245
324
|
contractKey,
|
|
246
|
-
|
|
325
|
+
_args7 = arguments,
|
|
247
326
|
_t4,
|
|
248
327
|
_t5;
|
|
249
|
-
return _regenerator().w(function (
|
|
250
|
-
while (1) switch (
|
|
328
|
+
return _regenerator().w(function (_context7) {
|
|
329
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
251
330
|
case 0:
|
|
252
|
-
durability =
|
|
331
|
+
durability = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : Durability.Persistent;
|
|
253
332
|
if (!(typeof contract === "string")) {
|
|
254
|
-
|
|
333
|
+
_context7.n = 1;
|
|
255
334
|
break;
|
|
256
335
|
}
|
|
257
336
|
scAddress = new _stellarBase.Contract(contract).address().toScAddress();
|
|
258
|
-
|
|
337
|
+
_context7.n = 4;
|
|
259
338
|
break;
|
|
260
339
|
case 1:
|
|
261
340
|
if (!(contract instanceof _stellarBase.Address)) {
|
|
262
|
-
|
|
341
|
+
_context7.n = 2;
|
|
263
342
|
break;
|
|
264
343
|
}
|
|
265
344
|
scAddress = contract.toScAddress();
|
|
266
|
-
|
|
345
|
+
_context7.n = 4;
|
|
267
346
|
break;
|
|
268
347
|
case 2:
|
|
269
348
|
if (!(contract instanceof _stellarBase.Contract)) {
|
|
270
|
-
|
|
349
|
+
_context7.n = 3;
|
|
271
350
|
break;
|
|
272
351
|
}
|
|
273
352
|
scAddress = contract.address().toScAddress();
|
|
274
|
-
|
|
353
|
+
_context7.n = 4;
|
|
275
354
|
break;
|
|
276
355
|
case 3:
|
|
277
356
|
throw new TypeError("unknown contract type: ".concat(contract));
|
|
278
357
|
case 4:
|
|
279
358
|
_t4 = durability;
|
|
280
|
-
|
|
359
|
+
_context7.n = _t4 === Durability.Temporary ? 5 : _t4 === Durability.Persistent ? 6 : 7;
|
|
281
360
|
break;
|
|
282
361
|
case 5:
|
|
283
362
|
xdrDurability = _stellarBase.xdr.ContractDataDurability.temporary();
|
|
284
|
-
return
|
|
363
|
+
return _context7.a(3, 8);
|
|
285
364
|
case 6:
|
|
286
365
|
xdrDurability = _stellarBase.xdr.ContractDataDurability.persistent();
|
|
287
|
-
return
|
|
366
|
+
return _context7.a(3, 8);
|
|
288
367
|
case 7:
|
|
289
368
|
throw new TypeError("invalid durability: ".concat(durability));
|
|
290
369
|
case 8:
|
|
@@ -293,24 +372,24 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
293
372
|
contract: scAddress,
|
|
294
373
|
durability: xdrDurability
|
|
295
374
|
}));
|
|
296
|
-
|
|
297
|
-
|
|
375
|
+
_context7.p = 9;
|
|
376
|
+
_context7.n = 10;
|
|
298
377
|
return this.getLedgerEntry(contractKey);
|
|
299
378
|
case 10:
|
|
300
|
-
return
|
|
379
|
+
return _context7.a(2, _context7.v);
|
|
301
380
|
case 11:
|
|
302
|
-
|
|
303
|
-
_t5 =
|
|
381
|
+
_context7.p = 11;
|
|
382
|
+
_t5 = _context7.v;
|
|
304
383
|
throw {
|
|
305
384
|
code: 404,
|
|
306
385
|
message: "Contract data not found for ".concat(_stellarBase.Address.fromScAddress(scAddress).toString(), " with key ").concat(key.toXDR("base64"), " and durability: ").concat(durability)
|
|
307
386
|
};
|
|
308
387
|
case 12:
|
|
309
|
-
return
|
|
388
|
+
return _context7.a(2);
|
|
310
389
|
}
|
|
311
|
-
},
|
|
390
|
+
}, _callee7, this, [[9, 11]]);
|
|
312
391
|
}));
|
|
313
|
-
function getContractData(
|
|
392
|
+
function getContractData(_x9, _x0) {
|
|
314
393
|
return _getContractData.apply(this, arguments);
|
|
315
394
|
}
|
|
316
395
|
return getContractData;
|
|
@@ -318,32 +397,32 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
318
397
|
}, {
|
|
319
398
|
key: "getContractWasmByContractId",
|
|
320
399
|
value: (function () {
|
|
321
|
-
var _getContractWasmByContractId = _asyncToGenerator(_regenerator().m(function
|
|
400
|
+
var _getContractWasmByContractId = _asyncToGenerator(_regenerator().m(function _callee8(contractId) {
|
|
322
401
|
var _response$entries$;
|
|
323
402
|
var contractLedgerKey, response, wasmHash;
|
|
324
|
-
return _regenerator().w(function (
|
|
325
|
-
while (1) switch (
|
|
403
|
+
return _regenerator().w(function (_context8) {
|
|
404
|
+
while (1) switch (_context8.n) {
|
|
326
405
|
case 0:
|
|
327
406
|
contractLedgerKey = new _stellarBase.Contract(contractId).getFootprint();
|
|
328
|
-
|
|
407
|
+
_context8.n = 1;
|
|
329
408
|
return this.getLedgerEntries(contractLedgerKey);
|
|
330
409
|
case 1:
|
|
331
|
-
response =
|
|
410
|
+
response = _context8.v;
|
|
332
411
|
if (!(!response.entries.length || !((_response$entries$ = response.entries[0]) !== null && _response$entries$ !== void 0 && _response$entries$.val))) {
|
|
333
|
-
|
|
412
|
+
_context8.n = 2;
|
|
334
413
|
break;
|
|
335
414
|
}
|
|
336
|
-
return
|
|
415
|
+
return _context8.a(2, Promise.reject({
|
|
337
416
|
code: 404,
|
|
338
417
|
message: "Could not obtain contract hash from server"
|
|
339
418
|
}));
|
|
340
419
|
case 2:
|
|
341
420
|
wasmHash = response.entries[0].val.contractData().val().instance().executable().wasmHash();
|
|
342
|
-
return
|
|
421
|
+
return _context8.a(2, this.getContractWasmByHash(wasmHash));
|
|
343
422
|
}
|
|
344
|
-
},
|
|
423
|
+
}, _callee8, this);
|
|
345
424
|
}));
|
|
346
|
-
function getContractWasmByContractId(
|
|
425
|
+
function getContractWasmByContractId(_x1) {
|
|
347
426
|
return _getContractWasmByContractId.apply(this, arguments);
|
|
348
427
|
}
|
|
349
428
|
return getContractWasmByContractId;
|
|
@@ -351,41 +430,41 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
351
430
|
}, {
|
|
352
431
|
key: "getContractWasmByHash",
|
|
353
432
|
value: (function () {
|
|
354
|
-
var _getContractWasmByHash = _asyncToGenerator(_regenerator().m(function
|
|
433
|
+
var _getContractWasmByHash = _asyncToGenerator(_regenerator().m(function _callee9(wasmHash) {
|
|
355
434
|
var _responseWasm$entries;
|
|
356
435
|
var format,
|
|
357
436
|
wasmHashBuffer,
|
|
358
437
|
ledgerKeyWasmHash,
|
|
359
438
|
responseWasm,
|
|
360
439
|
wasmBuffer,
|
|
361
|
-
|
|
362
|
-
return _regenerator().w(function (
|
|
363
|
-
while (1) switch (
|
|
440
|
+
_args9 = arguments;
|
|
441
|
+
return _regenerator().w(function (_context9) {
|
|
442
|
+
while (1) switch (_context9.n) {
|
|
364
443
|
case 0:
|
|
365
|
-
format =
|
|
444
|
+
format = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : undefined;
|
|
366
445
|
wasmHashBuffer = typeof wasmHash === "string" ? Buffer.from(wasmHash, format) : wasmHash;
|
|
367
446
|
ledgerKeyWasmHash = _stellarBase.xdr.LedgerKey.contractCode(new _stellarBase.xdr.LedgerKeyContractCode({
|
|
368
447
|
hash: wasmHashBuffer
|
|
369
448
|
}));
|
|
370
|
-
|
|
449
|
+
_context9.n = 1;
|
|
371
450
|
return this.getLedgerEntries(ledgerKeyWasmHash);
|
|
372
451
|
case 1:
|
|
373
|
-
responseWasm =
|
|
452
|
+
responseWasm = _context9.v;
|
|
374
453
|
if (!(!responseWasm.entries.length || !((_responseWasm$entries = responseWasm.entries[0]) !== null && _responseWasm$entries !== void 0 && _responseWasm$entries.val))) {
|
|
375
|
-
|
|
454
|
+
_context9.n = 2;
|
|
376
455
|
break;
|
|
377
456
|
}
|
|
378
|
-
return
|
|
457
|
+
return _context9.a(2, Promise.reject({
|
|
379
458
|
code: 404,
|
|
380
459
|
message: "Could not obtain contract wasm from server"
|
|
381
460
|
}));
|
|
382
461
|
case 2:
|
|
383
462
|
wasmBuffer = responseWasm.entries[0].val.contractCode().code();
|
|
384
|
-
return
|
|
463
|
+
return _context9.a(2, wasmBuffer);
|
|
385
464
|
}
|
|
386
|
-
},
|
|
465
|
+
}, _callee9, this);
|
|
387
466
|
}));
|
|
388
|
-
function getContractWasmByHash(
|
|
467
|
+
function getContractWasmByHash(_x10) {
|
|
389
468
|
return _getContractWasmByHash.apply(this, arguments);
|
|
390
469
|
}
|
|
391
470
|
return getContractWasmByHash;
|
|
@@ -410,26 +489,26 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
410
489
|
}, {
|
|
411
490
|
key: "getLedgerEntry",
|
|
412
491
|
value: function () {
|
|
413
|
-
var _getLedgerEntry = _asyncToGenerator(_regenerator().m(function
|
|
492
|
+
var _getLedgerEntry = _asyncToGenerator(_regenerator().m(function _callee0(key) {
|
|
414
493
|
var results;
|
|
415
|
-
return _regenerator().w(function (
|
|
416
|
-
while (1) switch (
|
|
494
|
+
return _regenerator().w(function (_context0) {
|
|
495
|
+
while (1) switch (_context0.n) {
|
|
417
496
|
case 0:
|
|
418
|
-
|
|
497
|
+
_context0.n = 1;
|
|
419
498
|
return this._getLedgerEntries(key).then(_parsers.parseRawLedgerEntries);
|
|
420
499
|
case 1:
|
|
421
|
-
results =
|
|
500
|
+
results = _context0.v;
|
|
422
501
|
if (!(results.entries.length !== 1)) {
|
|
423
|
-
|
|
502
|
+
_context0.n = 2;
|
|
424
503
|
break;
|
|
425
504
|
}
|
|
426
505
|
throw new Error("failed to find an entry for key ".concat(key.toXDR("base64")));
|
|
427
506
|
case 2:
|
|
428
|
-
return
|
|
507
|
+
return _context0.a(2, results.entries[0]);
|
|
429
508
|
}
|
|
430
|
-
},
|
|
509
|
+
}, _callee0, this);
|
|
431
510
|
}));
|
|
432
|
-
function getLedgerEntry(
|
|
511
|
+
function getLedgerEntry(_x11) {
|
|
433
512
|
return _getLedgerEntry.apply(this, arguments);
|
|
434
513
|
}
|
|
435
514
|
return getLedgerEntry;
|
|
@@ -437,41 +516,41 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
437
516
|
}, {
|
|
438
517
|
key: "pollTransaction",
|
|
439
518
|
value: (function () {
|
|
440
|
-
var _pollTransaction = _asyncToGenerator(_regenerator().m(function
|
|
519
|
+
var _pollTransaction = _asyncToGenerator(_regenerator().m(function _callee1(hash, opts) {
|
|
441
520
|
var _opts$attempts, _opts$attempts2;
|
|
442
521
|
var maxAttempts, foundInfo, attempt, _opts$sleepStrategy;
|
|
443
|
-
return _regenerator().w(function (
|
|
444
|
-
while (1) switch (
|
|
522
|
+
return _regenerator().w(function (_context1) {
|
|
523
|
+
while (1) switch (_context1.n) {
|
|
445
524
|
case 0:
|
|
446
525
|
maxAttempts = ((_opts$attempts = opts === null || opts === void 0 ? void 0 : opts.attempts) !== null && _opts$attempts !== void 0 ? _opts$attempts : 0) < 1 ? DEFAULT_GET_TRANSACTION_TIMEOUT : (_opts$attempts2 = opts === null || opts === void 0 ? void 0 : opts.attempts) !== null && _opts$attempts2 !== void 0 ? _opts$attempts2 : DEFAULT_GET_TRANSACTION_TIMEOUT;
|
|
447
526
|
attempt = 1;
|
|
448
527
|
case 1:
|
|
449
528
|
if (!(attempt < maxAttempts)) {
|
|
450
|
-
|
|
529
|
+
_context1.n = 5;
|
|
451
530
|
break;
|
|
452
531
|
}
|
|
453
|
-
|
|
532
|
+
_context1.n = 2;
|
|
454
533
|
return this.getTransaction(hash);
|
|
455
534
|
case 2:
|
|
456
|
-
foundInfo =
|
|
535
|
+
foundInfo = _context1.v;
|
|
457
536
|
if (!(foundInfo.status !== _api.Api.GetTransactionStatus.NOT_FOUND)) {
|
|
458
|
-
|
|
537
|
+
_context1.n = 3;
|
|
459
538
|
break;
|
|
460
539
|
}
|
|
461
|
-
return
|
|
540
|
+
return _context1.a(2, foundInfo);
|
|
462
541
|
case 3:
|
|
463
|
-
|
|
542
|
+
_context1.n = 4;
|
|
464
543
|
return _utils.Utils.sleep(((_opts$sleepStrategy = opts === null || opts === void 0 ? void 0 : opts.sleepStrategy) !== null && _opts$sleepStrategy !== void 0 ? _opts$sleepStrategy : BasicSleepStrategy)(attempt));
|
|
465
544
|
case 4:
|
|
466
545
|
attempt++;
|
|
467
|
-
|
|
546
|
+
_context1.n = 1;
|
|
468
547
|
break;
|
|
469
548
|
case 5:
|
|
470
|
-
return
|
|
549
|
+
return _context1.a(2, foundInfo);
|
|
471
550
|
}
|
|
472
|
-
},
|
|
551
|
+
}, _callee1, this);
|
|
473
552
|
}));
|
|
474
|
-
function pollTransaction(
|
|
553
|
+
function pollTransaction(_x12, _x13) {
|
|
475
554
|
return _pollTransaction.apply(this, arguments);
|
|
476
555
|
}
|
|
477
556
|
return pollTransaction;
|
|
@@ -479,11 +558,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
479
558
|
}, {
|
|
480
559
|
key: "getTransaction",
|
|
481
560
|
value: (function () {
|
|
482
|
-
var _getTransaction2 = _asyncToGenerator(_regenerator().m(function
|
|
483
|
-
return _regenerator().w(function (
|
|
484
|
-
while (1) switch (
|
|
561
|
+
var _getTransaction2 = _asyncToGenerator(_regenerator().m(function _callee10(hash) {
|
|
562
|
+
return _regenerator().w(function (_context10) {
|
|
563
|
+
while (1) switch (_context10.n) {
|
|
485
564
|
case 0:
|
|
486
|
-
return
|
|
565
|
+
return _context10.a(2, this._getTransaction(hash).then(function (raw) {
|
|
487
566
|
var foundInfo = {};
|
|
488
567
|
if (raw.status !== _api.Api.GetTransactionStatus.NOT_FOUND) {
|
|
489
568
|
Object.assign(foundInfo, (0, _parsers.parseTransactionInfo)(raw));
|
|
@@ -499,9 +578,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
499
578
|
return result;
|
|
500
579
|
}));
|
|
501
580
|
}
|
|
502
|
-
},
|
|
581
|
+
}, _callee10, this);
|
|
503
582
|
}));
|
|
504
|
-
function getTransaction(
|
|
583
|
+
function getTransaction(_x14) {
|
|
505
584
|
return _getTransaction2.apply(this, arguments);
|
|
506
585
|
}
|
|
507
586
|
return getTransaction;
|
|
@@ -509,17 +588,17 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
509
588
|
}, {
|
|
510
589
|
key: "_getTransaction",
|
|
511
590
|
value: function () {
|
|
512
|
-
var _getTransaction3 = _asyncToGenerator(_regenerator().m(function
|
|
513
|
-
return _regenerator().w(function (
|
|
514
|
-
while (1) switch (
|
|
591
|
+
var _getTransaction3 = _asyncToGenerator(_regenerator().m(function _callee11(hash) {
|
|
592
|
+
return _regenerator().w(function (_context11) {
|
|
593
|
+
while (1) switch (_context11.n) {
|
|
515
594
|
case 0:
|
|
516
|
-
return
|
|
595
|
+
return _context11.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getTransaction", {
|
|
517
596
|
hash: hash
|
|
518
597
|
}));
|
|
519
598
|
}
|
|
520
|
-
},
|
|
599
|
+
}, _callee11, this);
|
|
521
600
|
}));
|
|
522
|
-
function _getTransaction(
|
|
601
|
+
function _getTransaction(_x15) {
|
|
523
602
|
return _getTransaction3.apply(this, arguments);
|
|
524
603
|
}
|
|
525
604
|
return _getTransaction;
|
|
@@ -527,11 +606,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
527
606
|
}, {
|
|
528
607
|
key: "getTransactions",
|
|
529
608
|
value: (function () {
|
|
530
|
-
var _getTransactions2 = _asyncToGenerator(_regenerator().m(function
|
|
531
|
-
return _regenerator().w(function (
|
|
532
|
-
while (1) switch (
|
|
609
|
+
var _getTransactions2 = _asyncToGenerator(_regenerator().m(function _callee12(request) {
|
|
610
|
+
return _regenerator().w(function (_context12) {
|
|
611
|
+
while (1) switch (_context12.n) {
|
|
533
612
|
case 0:
|
|
534
|
-
return
|
|
613
|
+
return _context12.a(2, this._getTransactions(request).then(function (raw) {
|
|
535
614
|
var result = {
|
|
536
615
|
transactions: (raw.transactions || []).map(_parsers.parseRawTransactions),
|
|
537
616
|
latestLedger: raw.latestLedger,
|
|
@@ -543,9 +622,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
543
622
|
return result;
|
|
544
623
|
}));
|
|
545
624
|
}
|
|
546
|
-
},
|
|
625
|
+
}, _callee12, this);
|
|
547
626
|
}));
|
|
548
|
-
function getTransactions(
|
|
627
|
+
function getTransactions(_x16) {
|
|
549
628
|
return _getTransactions2.apply(this, arguments);
|
|
550
629
|
}
|
|
551
630
|
return getTransactions;
|
|
@@ -553,15 +632,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
553
632
|
}, {
|
|
554
633
|
key: "_getTransactions",
|
|
555
634
|
value: function () {
|
|
556
|
-
var _getTransactions3 = _asyncToGenerator(_regenerator().m(function
|
|
557
|
-
return _regenerator().w(function (
|
|
558
|
-
while (1) switch (
|
|
635
|
+
var _getTransactions3 = _asyncToGenerator(_regenerator().m(function _callee13(request) {
|
|
636
|
+
return _regenerator().w(function (_context13) {
|
|
637
|
+
while (1) switch (_context13.n) {
|
|
559
638
|
case 0:
|
|
560
|
-
return
|
|
639
|
+
return _context13.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getTransactions", request));
|
|
561
640
|
}
|
|
562
|
-
},
|
|
641
|
+
}, _callee13, this);
|
|
563
642
|
}));
|
|
564
|
-
function _getTransactions(
|
|
643
|
+
function _getTransactions(_x17) {
|
|
565
644
|
return _getTransactions3.apply(this, arguments);
|
|
566
645
|
}
|
|
567
646
|
return _getTransactions;
|
|
@@ -569,15 +648,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
569
648
|
}, {
|
|
570
649
|
key: "getEvents",
|
|
571
650
|
value: (function () {
|
|
572
|
-
var _getEvents2 = _asyncToGenerator(_regenerator().m(function
|
|
573
|
-
return _regenerator().w(function (
|
|
574
|
-
while (1) switch (
|
|
651
|
+
var _getEvents2 = _asyncToGenerator(_regenerator().m(function _callee14(request) {
|
|
652
|
+
return _regenerator().w(function (_context14) {
|
|
653
|
+
while (1) switch (_context14.n) {
|
|
575
654
|
case 0:
|
|
576
|
-
return
|
|
655
|
+
return _context14.a(2, this._getEvents(request).then(_parsers.parseRawEvents));
|
|
577
656
|
}
|
|
578
|
-
},
|
|
657
|
+
}, _callee14, this);
|
|
579
658
|
}));
|
|
580
|
-
function getEvents(
|
|
659
|
+
function getEvents(_x18) {
|
|
581
660
|
return _getEvents2.apply(this, arguments);
|
|
582
661
|
}
|
|
583
662
|
return getEvents;
|
|
@@ -585,12 +664,12 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
585
664
|
}, {
|
|
586
665
|
key: "_getEvents",
|
|
587
666
|
value: function () {
|
|
588
|
-
var _getEvents3 = _asyncToGenerator(_regenerator().m(function
|
|
667
|
+
var _getEvents3 = _asyncToGenerator(_regenerator().m(function _callee15(request) {
|
|
589
668
|
var _request$filters;
|
|
590
|
-
return _regenerator().w(function (
|
|
591
|
-
while (1) switch (
|
|
669
|
+
return _regenerator().w(function (_context15) {
|
|
670
|
+
while (1) switch (_context15.n) {
|
|
592
671
|
case 0:
|
|
593
|
-
return
|
|
672
|
+
return _context15.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getEvents", _objectSpread(_objectSpread({
|
|
594
673
|
filters: (_request$filters = request.filters) !== null && _request$filters !== void 0 ? _request$filters : [],
|
|
595
674
|
pagination: _objectSpread(_objectSpread({}, request.cursor && {
|
|
596
675
|
cursor: request.cursor
|
|
@@ -603,9 +682,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
603
682
|
endLedger: request.endLedger
|
|
604
683
|
})));
|
|
605
684
|
}
|
|
606
|
-
},
|
|
685
|
+
}, _callee15, this);
|
|
607
686
|
}));
|
|
608
|
-
function _getEvents(
|
|
687
|
+
function _getEvents(_x19) {
|
|
609
688
|
return _getEvents3.apply(this, arguments);
|
|
610
689
|
}
|
|
611
690
|
return _getEvents;
|
|
@@ -613,13 +692,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
613
692
|
}, {
|
|
614
693
|
key: "getNetwork",
|
|
615
694
|
value: (function () {
|
|
616
|
-
var _getNetwork = _asyncToGenerator(_regenerator().m(function
|
|
617
|
-
return _regenerator().w(function (
|
|
618
|
-
while (1) switch (
|
|
695
|
+
var _getNetwork = _asyncToGenerator(_regenerator().m(function _callee16() {
|
|
696
|
+
return _regenerator().w(function (_context16) {
|
|
697
|
+
while (1) switch (_context16.n) {
|
|
619
698
|
case 0:
|
|
620
|
-
return
|
|
699
|
+
return _context16.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getNetwork"));
|
|
621
700
|
}
|
|
622
|
-
},
|
|
701
|
+
}, _callee16, this);
|
|
623
702
|
}));
|
|
624
703
|
function getNetwork() {
|
|
625
704
|
return _getNetwork.apply(this, arguments);
|
|
@@ -629,13 +708,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
629
708
|
}, {
|
|
630
709
|
key: "getLatestLedger",
|
|
631
710
|
value: (function () {
|
|
632
|
-
var _getLatestLedger = _asyncToGenerator(_regenerator().m(function
|
|
633
|
-
return _regenerator().w(function (
|
|
634
|
-
while (1) switch (
|
|
711
|
+
var _getLatestLedger = _asyncToGenerator(_regenerator().m(function _callee17() {
|
|
712
|
+
return _regenerator().w(function (_context17) {
|
|
713
|
+
while (1) switch (_context17.n) {
|
|
635
714
|
case 0:
|
|
636
|
-
return
|
|
715
|
+
return _context17.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLatestLedger"));
|
|
637
716
|
}
|
|
638
|
-
},
|
|
717
|
+
}, _callee17, this);
|
|
639
718
|
}));
|
|
640
719
|
function getLatestLedger() {
|
|
641
720
|
return _getLatestLedger.apply(this, arguments);
|
|
@@ -645,15 +724,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
645
724
|
}, {
|
|
646
725
|
key: "simulateTransaction",
|
|
647
726
|
value: (function () {
|
|
648
|
-
var _simulateTransaction2 = _asyncToGenerator(_regenerator().m(function
|
|
649
|
-
return _regenerator().w(function (
|
|
650
|
-
while (1) switch (
|
|
727
|
+
var _simulateTransaction2 = _asyncToGenerator(_regenerator().m(function _callee18(tx, addlResources, authMode) {
|
|
728
|
+
return _regenerator().w(function (_context18) {
|
|
729
|
+
while (1) switch (_context18.n) {
|
|
651
730
|
case 0:
|
|
652
|
-
return
|
|
731
|
+
return _context18.a(2, this._simulateTransaction(tx, addlResources, authMode).then(_parsers.parseRawSimulation));
|
|
653
732
|
}
|
|
654
|
-
},
|
|
733
|
+
}, _callee18, this);
|
|
655
734
|
}));
|
|
656
|
-
function simulateTransaction(
|
|
735
|
+
function simulateTransaction(_x20, _x21, _x22) {
|
|
657
736
|
return _simulateTransaction2.apply(this, arguments);
|
|
658
737
|
}
|
|
659
738
|
return simulateTransaction;
|
|
@@ -661,11 +740,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
661
740
|
}, {
|
|
662
741
|
key: "_simulateTransaction",
|
|
663
742
|
value: function () {
|
|
664
|
-
var _simulateTransaction3 = _asyncToGenerator(_regenerator().m(function
|
|
665
|
-
return _regenerator().w(function (
|
|
666
|
-
while (1) switch (
|
|
743
|
+
var _simulateTransaction3 = _asyncToGenerator(_regenerator().m(function _callee19(transaction, addlResources, authMode) {
|
|
744
|
+
return _regenerator().w(function (_context19) {
|
|
745
|
+
while (1) switch (_context19.n) {
|
|
667
746
|
case 0:
|
|
668
|
-
return
|
|
747
|
+
return _context19.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "simulateTransaction", _objectSpread({
|
|
669
748
|
transaction: transaction.toXDR(),
|
|
670
749
|
authMode: authMode
|
|
671
750
|
}, addlResources !== undefined && {
|
|
@@ -674,9 +753,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
674
753
|
}
|
|
675
754
|
})));
|
|
676
755
|
}
|
|
677
|
-
},
|
|
756
|
+
}, _callee19, this);
|
|
678
757
|
}));
|
|
679
|
-
function _simulateTransaction(
|
|
758
|
+
function _simulateTransaction(_x23, _x24, _x25) {
|
|
680
759
|
return _simulateTransaction3.apply(this, arguments);
|
|
681
760
|
}
|
|
682
761
|
return _simulateTransaction;
|
|
@@ -684,26 +763,26 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
684
763
|
}, {
|
|
685
764
|
key: "prepareTransaction",
|
|
686
765
|
value: (function () {
|
|
687
|
-
var _prepareTransaction = _asyncToGenerator(_regenerator().m(function
|
|
766
|
+
var _prepareTransaction = _asyncToGenerator(_regenerator().m(function _callee20(tx) {
|
|
688
767
|
var simResponse;
|
|
689
|
-
return _regenerator().w(function (
|
|
690
|
-
while (1) switch (
|
|
768
|
+
return _regenerator().w(function (_context20) {
|
|
769
|
+
while (1) switch (_context20.n) {
|
|
691
770
|
case 0:
|
|
692
|
-
|
|
771
|
+
_context20.n = 1;
|
|
693
772
|
return this.simulateTransaction(tx);
|
|
694
773
|
case 1:
|
|
695
|
-
simResponse =
|
|
774
|
+
simResponse = _context20.v;
|
|
696
775
|
if (!_api.Api.isSimulationError(simResponse)) {
|
|
697
|
-
|
|
776
|
+
_context20.n = 2;
|
|
698
777
|
break;
|
|
699
778
|
}
|
|
700
779
|
throw new Error(simResponse.error);
|
|
701
780
|
case 2:
|
|
702
|
-
return
|
|
781
|
+
return _context20.a(2, (0, _transaction.assembleTransaction)(tx, simResponse).build());
|
|
703
782
|
}
|
|
704
|
-
},
|
|
783
|
+
}, _callee20, this);
|
|
705
784
|
}));
|
|
706
|
-
function prepareTransaction(
|
|
785
|
+
function prepareTransaction(_x26) {
|
|
707
786
|
return _prepareTransaction.apply(this, arguments);
|
|
708
787
|
}
|
|
709
788
|
return prepareTransaction;
|
|
@@ -711,15 +790,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
711
790
|
}, {
|
|
712
791
|
key: "sendTransaction",
|
|
713
792
|
value: (function () {
|
|
714
|
-
var _sendTransaction2 = _asyncToGenerator(_regenerator().m(function
|
|
715
|
-
return _regenerator().w(function (
|
|
716
|
-
while (1) switch (
|
|
793
|
+
var _sendTransaction2 = _asyncToGenerator(_regenerator().m(function _callee21(transaction) {
|
|
794
|
+
return _regenerator().w(function (_context21) {
|
|
795
|
+
while (1) switch (_context21.n) {
|
|
717
796
|
case 0:
|
|
718
|
-
return
|
|
797
|
+
return _context21.a(2, this._sendTransaction(transaction).then(_parsers.parseRawSendTransaction));
|
|
719
798
|
}
|
|
720
|
-
},
|
|
799
|
+
}, _callee21, this);
|
|
721
800
|
}));
|
|
722
|
-
function sendTransaction(
|
|
801
|
+
function sendTransaction(_x27) {
|
|
723
802
|
return _sendTransaction2.apply(this, arguments);
|
|
724
803
|
}
|
|
725
804
|
return sendTransaction;
|
|
@@ -727,17 +806,17 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
727
806
|
}, {
|
|
728
807
|
key: "_sendTransaction",
|
|
729
808
|
value: function () {
|
|
730
|
-
var _sendTransaction3 = _asyncToGenerator(_regenerator().m(function
|
|
731
|
-
return _regenerator().w(function (
|
|
732
|
-
while (1) switch (
|
|
809
|
+
var _sendTransaction3 = _asyncToGenerator(_regenerator().m(function _callee22(transaction) {
|
|
810
|
+
return _regenerator().w(function (_context22) {
|
|
811
|
+
while (1) switch (_context22.n) {
|
|
733
812
|
case 0:
|
|
734
|
-
return
|
|
813
|
+
return _context22.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "sendTransaction", {
|
|
735
814
|
transaction: transaction.toXDR()
|
|
736
815
|
}));
|
|
737
816
|
}
|
|
738
|
-
},
|
|
817
|
+
}, _callee22, this);
|
|
739
818
|
}));
|
|
740
|
-
function _sendTransaction(
|
|
819
|
+
function _sendTransaction(_x28) {
|
|
741
820
|
return _sendTransaction3.apply(this, arguments);
|
|
742
821
|
}
|
|
743
822
|
return _sendTransaction;
|
|
@@ -745,76 +824,76 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
745
824
|
}, {
|
|
746
825
|
key: "requestAirdrop",
|
|
747
826
|
value: (function () {
|
|
748
|
-
var _requestAirdrop = _asyncToGenerator(_regenerator().m(function
|
|
827
|
+
var _requestAirdrop = _asyncToGenerator(_regenerator().m(function _callee23(address, friendbotUrl) {
|
|
749
828
|
var account, response, meta, txMeta, sequence, _error$response, _error$response$detai, _t6, _t7;
|
|
750
|
-
return _regenerator().w(function (
|
|
751
|
-
while (1) switch (
|
|
829
|
+
return _regenerator().w(function (_context23) {
|
|
830
|
+
while (1) switch (_context23.p = _context23.n) {
|
|
752
831
|
case 0:
|
|
753
832
|
account = typeof address === "string" ? address : address.accountId();
|
|
754
833
|
_t6 = friendbotUrl;
|
|
755
834
|
if (_t6) {
|
|
756
|
-
|
|
835
|
+
_context23.n = 2;
|
|
757
836
|
break;
|
|
758
837
|
}
|
|
759
|
-
|
|
838
|
+
_context23.n = 1;
|
|
760
839
|
return this.getNetwork();
|
|
761
840
|
case 1:
|
|
762
|
-
_t6 =
|
|
841
|
+
_t6 = _context23.v.friendbotUrl;
|
|
763
842
|
case 2:
|
|
764
843
|
friendbotUrl = _t6;
|
|
765
844
|
if (friendbotUrl) {
|
|
766
|
-
|
|
845
|
+
_context23.n = 3;
|
|
767
846
|
break;
|
|
768
847
|
}
|
|
769
848
|
throw new Error("No friendbot URL configured for current network");
|
|
770
849
|
case 3:
|
|
771
|
-
|
|
772
|
-
|
|
850
|
+
_context23.p = 3;
|
|
851
|
+
_context23.n = 4;
|
|
773
852
|
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
774
853
|
case 4:
|
|
775
|
-
response =
|
|
854
|
+
response = _context23.v;
|
|
776
855
|
if (response.data.result_meta_xdr) {
|
|
777
|
-
|
|
856
|
+
_context23.n = 7;
|
|
778
857
|
break;
|
|
779
858
|
}
|
|
780
|
-
|
|
859
|
+
_context23.n = 5;
|
|
781
860
|
return this.getTransaction(response.data.hash);
|
|
782
861
|
case 5:
|
|
783
|
-
txMeta =
|
|
862
|
+
txMeta = _context23.v;
|
|
784
863
|
if (!(txMeta.status !== _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
785
|
-
|
|
864
|
+
_context23.n = 6;
|
|
786
865
|
break;
|
|
787
866
|
}
|
|
788
867
|
throw new Error("Funding account ".concat(address, " failed"));
|
|
789
868
|
case 6:
|
|
790
869
|
meta = txMeta.resultMetaXdr;
|
|
791
|
-
|
|
870
|
+
_context23.n = 8;
|
|
792
871
|
break;
|
|
793
872
|
case 7:
|
|
794
873
|
meta = _stellarBase.xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, "base64");
|
|
795
874
|
case 8:
|
|
796
875
|
sequence = findCreatedAccountSequenceInTransactionMeta(meta);
|
|
797
|
-
return
|
|
876
|
+
return _context23.a(2, new _stellarBase.Account(account, sequence));
|
|
798
877
|
case 9:
|
|
799
|
-
|
|
800
|
-
_t7 =
|
|
878
|
+
_context23.p = 9;
|
|
879
|
+
_t7 = _context23.v;
|
|
801
880
|
if (!(((_error$response = _t7.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 400)) {
|
|
802
|
-
|
|
881
|
+
_context23.n = 10;
|
|
803
882
|
break;
|
|
804
883
|
}
|
|
805
884
|
if (!((_error$response$detai = _t7.response.detail) !== null && _error$response$detai !== void 0 && _error$response$detai.includes("createAccountAlreadyExist"))) {
|
|
806
|
-
|
|
885
|
+
_context23.n = 10;
|
|
807
886
|
break;
|
|
808
887
|
}
|
|
809
|
-
return
|
|
888
|
+
return _context23.a(2, this.getAccount(account));
|
|
810
889
|
case 10:
|
|
811
890
|
throw _t7;
|
|
812
891
|
case 11:
|
|
813
|
-
return
|
|
892
|
+
return _context23.a(2);
|
|
814
893
|
}
|
|
815
|
-
},
|
|
894
|
+
}, _callee23, this, [[3, 9]]);
|
|
816
895
|
}));
|
|
817
|
-
function requestAirdrop(
|
|
896
|
+
function requestAirdrop(_x29, _x30) {
|
|
818
897
|
return _requestAirdrop.apply(this, arguments);
|
|
819
898
|
}
|
|
820
899
|
return requestAirdrop;
|
|
@@ -822,13 +901,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
822
901
|
}, {
|
|
823
902
|
key: "getFeeStats",
|
|
824
903
|
value: (function () {
|
|
825
|
-
var _getFeeStats = _asyncToGenerator(_regenerator().m(function
|
|
826
|
-
return _regenerator().w(function (
|
|
827
|
-
while (1) switch (
|
|
904
|
+
var _getFeeStats = _asyncToGenerator(_regenerator().m(function _callee24() {
|
|
905
|
+
return _regenerator().w(function (_context24) {
|
|
906
|
+
while (1) switch (_context24.n) {
|
|
828
907
|
case 0:
|
|
829
|
-
return
|
|
908
|
+
return _context24.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getFeeStats"));
|
|
830
909
|
}
|
|
831
|
-
},
|
|
910
|
+
}, _callee24, this);
|
|
832
911
|
}));
|
|
833
912
|
function getFeeStats() {
|
|
834
913
|
return _getFeeStats.apply(this, arguments);
|
|
@@ -838,13 +917,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
838
917
|
}, {
|
|
839
918
|
key: "getVersionInfo",
|
|
840
919
|
value: (function () {
|
|
841
|
-
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function
|
|
842
|
-
return _regenerator().w(function (
|
|
843
|
-
while (1) switch (
|
|
920
|
+
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function _callee25() {
|
|
921
|
+
return _regenerator().w(function (_context25) {
|
|
922
|
+
while (1) switch (_context25.n) {
|
|
844
923
|
case 0:
|
|
845
|
-
return
|
|
924
|
+
return _context25.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getVersionInfo"));
|
|
846
925
|
}
|
|
847
|
-
},
|
|
926
|
+
}, _callee25, this);
|
|
848
927
|
}));
|
|
849
928
|
function getVersionInfo() {
|
|
850
929
|
return _getVersionInfo.apply(this, arguments);
|
|
@@ -854,32 +933,32 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
854
933
|
}, {
|
|
855
934
|
key: "getSACBalance",
|
|
856
935
|
value: (function () {
|
|
857
|
-
var _getSACBalance = _asyncToGenerator(_regenerator().m(function
|
|
936
|
+
var _getSACBalance = _asyncToGenerator(_regenerator().m(function _callee26(address, sac, networkPassphrase) {
|
|
858
937
|
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry, _t8;
|
|
859
|
-
return _regenerator().w(function (
|
|
860
|
-
while (1) switch (
|
|
938
|
+
return _regenerator().w(function (_context26) {
|
|
939
|
+
while (1) switch (_context26.n) {
|
|
861
940
|
case 0:
|
|
862
941
|
addressString = address instanceof _stellarBase.Address ? address.toString() : address;
|
|
863
942
|
if (_stellarBase.StrKey.isValidContract(addressString)) {
|
|
864
|
-
|
|
943
|
+
_context26.n = 1;
|
|
865
944
|
break;
|
|
866
945
|
}
|
|
867
946
|
throw new TypeError("expected contract ID, got ".concat(addressString));
|
|
868
947
|
case 1:
|
|
869
948
|
if (!(networkPassphrase !== null && networkPassphrase !== void 0)) {
|
|
870
|
-
|
|
949
|
+
_context26.n = 2;
|
|
871
950
|
break;
|
|
872
951
|
}
|
|
873
952
|
_t8 = networkPassphrase;
|
|
874
|
-
|
|
953
|
+
_context26.n = 4;
|
|
875
954
|
break;
|
|
876
955
|
case 2:
|
|
877
|
-
|
|
956
|
+
_context26.n = 3;
|
|
878
957
|
return this.getNetwork().then(function (n) {
|
|
879
958
|
return n.passphrase;
|
|
880
959
|
});
|
|
881
960
|
case 3:
|
|
882
|
-
_t8 =
|
|
961
|
+
_t8 = _context26.v;
|
|
883
962
|
case 4:
|
|
884
963
|
passphrase = _t8;
|
|
885
964
|
sacId = sac.contractId(passphrase);
|
|
@@ -891,29 +970,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
891
970
|
durability: _stellarBase.xdr.ContractDataDurability.persistent(),
|
|
892
971
|
key: key
|
|
893
972
|
}));
|
|
894
|
-
|
|
973
|
+
_context26.n = 5;
|
|
895
974
|
return this.getLedgerEntries(ledgerKey);
|
|
896
975
|
case 5:
|
|
897
|
-
response =
|
|
976
|
+
response = _context26.v;
|
|
898
977
|
if (!(response.entries.length === 0)) {
|
|
899
|
-
|
|
978
|
+
_context26.n = 6;
|
|
900
979
|
break;
|
|
901
980
|
}
|
|
902
|
-
return
|
|
981
|
+
return _context26.a(2, {
|
|
903
982
|
latestLedger: response.latestLedger
|
|
904
983
|
});
|
|
905
984
|
case 6:
|
|
906
985
|
_response$entries$2 = response.entries[0], lastModifiedLedgerSeq = _response$entries$2.lastModifiedLedgerSeq, liveUntilLedgerSeq = _response$entries$2.liveUntilLedgerSeq, val = _response$entries$2.val;
|
|
907
986
|
if (!(val.switch().value !== _stellarBase.xdr.LedgerEntryType.contractData().value)) {
|
|
908
|
-
|
|
987
|
+
_context26.n = 7;
|
|
909
988
|
break;
|
|
910
989
|
}
|
|
911
|
-
return
|
|
990
|
+
return _context26.a(2, {
|
|
912
991
|
latestLedger: response.latestLedger
|
|
913
992
|
});
|
|
914
993
|
case 7:
|
|
915
994
|
entry = (0, _stellarBase.scValToNative)(val.contractData().val());
|
|
916
|
-
return
|
|
995
|
+
return _context26.a(2, {
|
|
917
996
|
latestLedger: response.latestLedger,
|
|
918
997
|
balanceEntry: {
|
|
919
998
|
liveUntilLedgerSeq: liveUntilLedgerSeq,
|
|
@@ -924,9 +1003,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
924
1003
|
}
|
|
925
1004
|
});
|
|
926
1005
|
}
|
|
927
|
-
},
|
|
1006
|
+
}, _callee26, this);
|
|
928
1007
|
}));
|
|
929
|
-
function getSACBalance(
|
|
1008
|
+
function getSACBalance(_x31, _x32, _x33) {
|
|
930
1009
|
return _getSACBalance.apply(this, arguments);
|
|
931
1010
|
}
|
|
932
1011
|
return getSACBalance;
|
|
@@ -934,11 +1013,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
934
1013
|
}, {
|
|
935
1014
|
key: "getLedgers",
|
|
936
1015
|
value: (function () {
|
|
937
|
-
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function
|
|
938
|
-
return _regenerator().w(function (
|
|
939
|
-
while (1) switch (
|
|
1016
|
+
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee27(request) {
|
|
1017
|
+
return _regenerator().w(function (_context27) {
|
|
1018
|
+
while (1) switch (_context27.n) {
|
|
940
1019
|
case 0:
|
|
941
|
-
return
|
|
1020
|
+
return _context27.a(2, this._getLedgers(request).then(function (raw) {
|
|
942
1021
|
var result = {
|
|
943
1022
|
ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
|
|
944
1023
|
latestLedger: raw.latestLedger,
|
|
@@ -950,9 +1029,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
950
1029
|
return result;
|
|
951
1030
|
}));
|
|
952
1031
|
}
|
|
953
|
-
},
|
|
1032
|
+
}, _callee27, this);
|
|
954
1033
|
}));
|
|
955
|
-
function getLedgers(
|
|
1034
|
+
function getLedgers(_x34) {
|
|
956
1035
|
return _getLedgers2.apply(this, arguments);
|
|
957
1036
|
}
|
|
958
1037
|
return getLedgers;
|
|
@@ -960,15 +1039,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
960
1039
|
}, {
|
|
961
1040
|
key: "_getLedgers",
|
|
962
1041
|
value: function () {
|
|
963
|
-
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function
|
|
964
|
-
return _regenerator().w(function (
|
|
965
|
-
while (1) switch (
|
|
1042
|
+
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee28(request) {
|
|
1043
|
+
return _regenerator().w(function (_context28) {
|
|
1044
|
+
while (1) switch (_context28.n) {
|
|
966
1045
|
case 0:
|
|
967
|
-
return
|
|
1046
|
+
return _context28.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgers", request));
|
|
968
1047
|
}
|
|
969
|
-
},
|
|
1048
|
+
}, _callee28, this);
|
|
970
1049
|
}));
|
|
971
|
-
function _getLedgers(
|
|
1050
|
+
function _getLedgers(_x35) {
|
|
972
1051
|
return _getLedgers3.apply(this, arguments);
|
|
973
1052
|
}
|
|
974
1053
|
return _getLedgers;
|