@stellar/stellar-sdk 12.1.0 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +1 -1
- package/dist/stellar-sdk.js +1336 -1101
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/browser.d.ts +1 -1
- package/lib/browser.js +4 -4
- package/lib/config.js +5 -2
- package/lib/contract/assembled_transaction.d.ts +26 -30
- package/lib/contract/assembled_transaction.js +28 -36
- package/lib/contract/client.d.ts +0 -1
- package/lib/contract/client.js +2 -2
- package/lib/contract/index.d.ts +0 -1
- package/lib/contract/index.js +1 -18
- package/lib/contract/sent_transaction.d.ts +9 -10
- package/lib/contract/sent_transaction.js +2 -1
- package/lib/contract/spec.d.ts +1 -1
- package/lib/contract/spec.js +921 -956
- package/lib/contract/types.d.ts +5 -0
- package/lib/contract/types.js +4 -1
- package/lib/contract/utils.d.ts +0 -5
- package/lib/contract/utils.js +4 -18
- package/lib/errors.d.ts +4 -4
- package/lib/federation/server.d.ts +1 -1
- package/lib/horizon/account_call_builder.d.ts +2 -3
- package/lib/horizon/account_response.d.ts +1 -1
- package/lib/horizon/assets_call_builder.d.ts +2 -3
- package/lib/horizon/call_builder.d.ts +8 -8
- package/lib/horizon/call_builder.js +10 -13
- package/lib/horizon/claimable_balances_call_builder.d.ts +3 -4
- package/lib/horizon/effect_call_builder.d.ts +2 -3
- package/lib/horizon/friendbot_builder.d.ts +0 -1
- package/lib/horizon/horizon_api.d.ts +5 -1
- package/lib/horizon/horizon_axios_client.js +6 -6
- package/lib/horizon/ledger_call_builder.d.ts +2 -3
- package/lib/horizon/liquidity_pool_call_builder.d.ts +2 -4
- package/lib/horizon/offer_call_builder.d.ts +2 -3
- package/lib/horizon/operation_call_builder.d.ts +3 -4
- package/lib/horizon/orderbook_call_builder.d.ts +0 -1
- package/lib/horizon/path_call_builder.d.ts +1 -2
- package/lib/horizon/payment_call_builder.d.ts +2 -3
- package/lib/horizon/server.d.ts +29 -10
- package/lib/horizon/server.js +98 -55
- package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -2
- package/lib/horizon/strict_send_path_call_builder.d.ts +1 -2
- package/lib/horizon/trade_aggregation_call_builder.d.ts +9 -10
- package/lib/horizon/trade_aggregation_call_builder.js +3 -7
- package/lib/horizon/trades_call_builder.d.ts +2 -3
- package/lib/horizon/transaction_call_builder.d.ts +3 -4
- package/lib/horizon/types/assets.d.ts +1 -1
- package/lib/horizon/types/effects.d.ts +1 -1
- package/lib/horizon/types/offer.d.ts +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/rpc/api.d.ts +89 -11
- package/lib/rpc/browser.d.ts +1 -1
- package/lib/rpc/browser.js +4 -4
- package/lib/rpc/index.d.ts +0 -1
- package/lib/rpc/jsonrpc.js +3 -3
- package/lib/rpc/parsers.d.ts +5 -3
- package/lib/rpc/parsers.js +52 -23
- package/lib/rpc/server.d.ts +51 -18
- package/lib/rpc/server.js +200 -153
- package/lib/rpc/transaction.d.ts +3 -4
- package/lib/rpc/transaction.js +23 -25
- package/lib/webauth/utils.js +3 -3
- package/package.json +24 -24
package/lib/rpc/server.js
CHANGED
|
@@ -15,9 +15,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
15
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 && {}.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
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
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(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
19
|
-
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; } }
|
|
20
|
-
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; }
|
|
21
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; }
|
|
22
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; }
|
|
23
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; }
|
|
@@ -35,12 +32,37 @@ var Durability = exports.Durability = function (Durability) {
|
|
|
35
32
|
Durability["Persistent"] = "persistent";
|
|
36
33
|
return Durability;
|
|
37
34
|
}({});
|
|
35
|
+
function findCreatedAccountSequenceInTransactionMeta(meta) {
|
|
36
|
+
var _operations$flatMap$f;
|
|
37
|
+
var operations = [];
|
|
38
|
+
switch (meta.switch()) {
|
|
39
|
+
case 0:
|
|
40
|
+
operations = meta.operations();
|
|
41
|
+
break;
|
|
42
|
+
case 1:
|
|
43
|
+
case 2:
|
|
44
|
+
case 3:
|
|
45
|
+
operations = meta.value().operations();
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
throw new Error('Unexpected transaction meta switch value');
|
|
49
|
+
}
|
|
50
|
+
var sequenceNumber = (_operations$flatMap$f = operations.flatMap(function (op) {
|
|
51
|
+
return op.changes();
|
|
52
|
+
}).find(function (c) {
|
|
53
|
+
return c.switch() === _stellarBase.xdr.LedgerEntryChangeType.ledgerEntryCreated() && c.created().data().switch() === _stellarBase.xdr.LedgerEntryType.account();
|
|
54
|
+
})) === null || _operations$flatMap$f === void 0 || (_operations$flatMap$f = _operations$flatMap$f.created()) === null || _operations$flatMap$f === void 0 || (_operations$flatMap$f = _operations$flatMap$f.data()) === null || _operations$flatMap$f === void 0 || (_operations$flatMap$f = _operations$flatMap$f.account()) === null || _operations$flatMap$f === void 0 || (_operations$flatMap$f = _operations$flatMap$f.seqNum()) === null || _operations$flatMap$f === void 0 ? void 0 : _operations$flatMap$f.toString();
|
|
55
|
+
if (sequenceNumber) {
|
|
56
|
+
return sequenceNumber;
|
|
57
|
+
}
|
|
58
|
+
throw new Error('No account created in transaction');
|
|
59
|
+
}
|
|
38
60
|
var Server = exports.Server = function () {
|
|
39
61
|
function Server(serverURL) {
|
|
40
62
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
63
|
_classCallCheck(this, Server);
|
|
42
64
|
this.serverURL = (0, _urijs.default)(serverURL);
|
|
43
|
-
if (opts.headers && Object.keys(opts.headers).length
|
|
65
|
+
if (opts.headers && Object.keys(opts.headers).length !== 0) {
|
|
44
66
|
_axios.default.interceptors.request.use(function (config) {
|
|
45
67
|
config.headers = Object.assign(config.headers, opts.headers);
|
|
46
68
|
return config;
|
|
@@ -323,19 +345,7 @@ var Server = exports.Server = function () {
|
|
|
323
345
|
return _context8.abrupt("return", this._getTransaction(hash).then(function (raw) {
|
|
324
346
|
var foundInfo = {};
|
|
325
347
|
if (raw.status !== _api.Api.GetTransactionStatus.NOT_FOUND) {
|
|
326
|
-
|
|
327
|
-
var meta = _stellarBase.xdr.TransactionMeta.fromXDR(raw.resultMetaXdr, 'base64');
|
|
328
|
-
foundInfo = _objectSpread({
|
|
329
|
-
ledger: raw.ledger,
|
|
330
|
-
createdAt: raw.createdAt,
|
|
331
|
-
applicationOrder: raw.applicationOrder,
|
|
332
|
-
feeBump: raw.feeBump,
|
|
333
|
-
envelopeXdr: _stellarBase.xdr.TransactionEnvelope.fromXDR(raw.envelopeXdr, 'base64'),
|
|
334
|
-
resultXdr: _stellarBase.xdr.TransactionResult.fromXDR(raw.resultXdr, 'base64'),
|
|
335
|
-
resultMetaXdr: meta
|
|
336
|
-
}, meta.switch() === 3 && meta.v3().sorobanMeta() !== null && raw.status === _api.Api.GetTransactionStatus.SUCCESS && {
|
|
337
|
-
returnValue: (_meta$v3$sorobanMeta = meta.v3().sorobanMeta()) === null || _meta$v3$sorobanMeta === void 0 ? void 0 : _meta$v3$sorobanMeta.returnValue()
|
|
338
|
-
});
|
|
348
|
+
Object.assign(foundInfo, (0, _parsers.parseTransactionInfo)(raw));
|
|
339
349
|
}
|
|
340
350
|
var result = _objectSpread({
|
|
341
351
|
status: raw.status,
|
|
@@ -379,20 +389,68 @@ var Server = exports.Server = function () {
|
|
|
379
389
|
return _getTransaction;
|
|
380
390
|
}()
|
|
381
391
|
}, {
|
|
382
|
-
key: "
|
|
392
|
+
key: "getTransactions",
|
|
383
393
|
value: (function () {
|
|
384
|
-
var
|
|
394
|
+
var _getTransactions2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee10(request) {
|
|
385
395
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
386
396
|
while (1) switch (_context10.prev = _context10.next) {
|
|
387
397
|
case 0:
|
|
388
|
-
return _context10.abrupt("return", this.
|
|
398
|
+
return _context10.abrupt("return", this._getTransactions(request).then(function (raw) {
|
|
399
|
+
var result = {
|
|
400
|
+
transactions: raw.transactions.map(_parsers.parseRawTransactions),
|
|
401
|
+
latestLedger: raw.latestLedger,
|
|
402
|
+
latestLedgerCloseTimestamp: raw.latestLedgerCloseTimestamp,
|
|
403
|
+
oldestLedger: raw.oldestLedger,
|
|
404
|
+
oldestLedgerCloseTimestamp: raw.oldestLedgerCloseTimestamp,
|
|
405
|
+
cursor: raw.cursor
|
|
406
|
+
};
|
|
407
|
+
return result;
|
|
408
|
+
}));
|
|
389
409
|
case 1:
|
|
390
410
|
case "end":
|
|
391
411
|
return _context10.stop();
|
|
392
412
|
}
|
|
393
413
|
}, _callee10, this);
|
|
394
414
|
}));
|
|
395
|
-
function
|
|
415
|
+
function getTransactions(_x8) {
|
|
416
|
+
return _getTransactions2.apply(this, arguments);
|
|
417
|
+
}
|
|
418
|
+
return getTransactions;
|
|
419
|
+
}())
|
|
420
|
+
}, {
|
|
421
|
+
key: "_getTransactions",
|
|
422
|
+
value: function () {
|
|
423
|
+
var _getTransactions3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee11(request) {
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
425
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
426
|
+
case 0:
|
|
427
|
+
return _context11.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getTransactions', request));
|
|
428
|
+
case 1:
|
|
429
|
+
case "end":
|
|
430
|
+
return _context11.stop();
|
|
431
|
+
}
|
|
432
|
+
}, _callee11, this);
|
|
433
|
+
}));
|
|
434
|
+
function _getTransactions(_x9) {
|
|
435
|
+
return _getTransactions3.apply(this, arguments);
|
|
436
|
+
}
|
|
437
|
+
return _getTransactions;
|
|
438
|
+
}()
|
|
439
|
+
}, {
|
|
440
|
+
key: "getEvents",
|
|
441
|
+
value: (function () {
|
|
442
|
+
var _getEvents2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee12(request) {
|
|
443
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
444
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
445
|
+
case 0:
|
|
446
|
+
return _context12.abrupt("return", this._getEvents(request).then(_parsers.parseRawEvents));
|
|
447
|
+
case 1:
|
|
448
|
+
case "end":
|
|
449
|
+
return _context12.stop();
|
|
450
|
+
}
|
|
451
|
+
}, _callee12, this);
|
|
452
|
+
}));
|
|
453
|
+
function getEvents(_x10) {
|
|
396
454
|
return _getEvents2.apply(this, arguments);
|
|
397
455
|
}
|
|
398
456
|
return getEvents;
|
|
@@ -400,12 +458,12 @@ var Server = exports.Server = function () {
|
|
|
400
458
|
}, {
|
|
401
459
|
key: "_getEvents",
|
|
402
460
|
value: function () {
|
|
403
|
-
var _getEvents3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
461
|
+
var _getEvents3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee13(request) {
|
|
404
462
|
var _request$filters;
|
|
405
|
-
return _regeneratorRuntime().wrap(function
|
|
406
|
-
while (1) switch (
|
|
463
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
464
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
407
465
|
case 0:
|
|
408
|
-
return
|
|
466
|
+
return _context13.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getEvents', _objectSpread({
|
|
409
467
|
filters: (_request$filters = request.filters) !== null && _request$filters !== void 0 ? _request$filters : [],
|
|
410
468
|
pagination: _objectSpread(_objectSpread({}, request.cursor && {
|
|
411
469
|
cursor: request.cursor
|
|
@@ -417,11 +475,11 @@ var Server = exports.Server = function () {
|
|
|
417
475
|
})));
|
|
418
476
|
case 1:
|
|
419
477
|
case "end":
|
|
420
|
-
return
|
|
478
|
+
return _context13.stop();
|
|
421
479
|
}
|
|
422
|
-
},
|
|
480
|
+
}, _callee13, this);
|
|
423
481
|
}));
|
|
424
|
-
function _getEvents(
|
|
482
|
+
function _getEvents(_x11) {
|
|
425
483
|
return _getEvents3.apply(this, arguments);
|
|
426
484
|
}
|
|
427
485
|
return _getEvents;
|
|
@@ -429,19 +487,16 @@ var Server = exports.Server = function () {
|
|
|
429
487
|
}, {
|
|
430
488
|
key: "getNetwork",
|
|
431
489
|
value: (function () {
|
|
432
|
-
var _getNetwork = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
433
|
-
return _regeneratorRuntime().wrap(function
|
|
434
|
-
while (1) switch (
|
|
490
|
+
var _getNetwork = _asyncToGenerator(_regeneratorRuntime().mark(function _callee14() {
|
|
491
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
492
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
435
493
|
case 0:
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
case 2:
|
|
439
|
-
return _context12.abrupt("return", _context12.sent);
|
|
440
|
-
case 3:
|
|
494
|
+
return _context14.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getNetwork'));
|
|
495
|
+
case 1:
|
|
441
496
|
case "end":
|
|
442
|
-
return
|
|
497
|
+
return _context14.stop();
|
|
443
498
|
}
|
|
444
|
-
},
|
|
499
|
+
}, _callee14, this);
|
|
445
500
|
}));
|
|
446
501
|
function getNetwork() {
|
|
447
502
|
return _getNetwork.apply(this, arguments);
|
|
@@ -451,16 +506,16 @@ var Server = exports.Server = function () {
|
|
|
451
506
|
}, {
|
|
452
507
|
key: "getLatestLedger",
|
|
453
508
|
value: (function () {
|
|
454
|
-
var _getLatestLedger = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
455
|
-
return _regeneratorRuntime().wrap(function
|
|
456
|
-
while (1) switch (
|
|
509
|
+
var _getLatestLedger = _asyncToGenerator(_regeneratorRuntime().mark(function _callee15() {
|
|
510
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
511
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
457
512
|
case 0:
|
|
458
|
-
return
|
|
513
|
+
return _context15.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getLatestLedger'));
|
|
459
514
|
case 1:
|
|
460
515
|
case "end":
|
|
461
|
-
return
|
|
516
|
+
return _context15.stop();
|
|
462
517
|
}
|
|
463
|
-
},
|
|
518
|
+
}, _callee15, this);
|
|
464
519
|
}));
|
|
465
520
|
function getLatestLedger() {
|
|
466
521
|
return _getLatestLedger.apply(this, arguments);
|
|
@@ -470,18 +525,18 @@ var Server = exports.Server = function () {
|
|
|
470
525
|
}, {
|
|
471
526
|
key: "simulateTransaction",
|
|
472
527
|
value: (function () {
|
|
473
|
-
var _simulateTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
474
|
-
return _regeneratorRuntime().wrap(function
|
|
475
|
-
while (1) switch (
|
|
528
|
+
var _simulateTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee16(tx, addlResources) {
|
|
529
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
530
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
476
531
|
case 0:
|
|
477
|
-
return
|
|
532
|
+
return _context16.abrupt("return", this._simulateTransaction(tx, addlResources).then(_parsers.parseRawSimulation));
|
|
478
533
|
case 1:
|
|
479
534
|
case "end":
|
|
480
|
-
return
|
|
535
|
+
return _context16.stop();
|
|
481
536
|
}
|
|
482
|
-
},
|
|
537
|
+
}, _callee16, this);
|
|
483
538
|
}));
|
|
484
|
-
function simulateTransaction(
|
|
539
|
+
function simulateTransaction(_x12, _x13) {
|
|
485
540
|
return _simulateTransaction2.apply(this, arguments);
|
|
486
541
|
}
|
|
487
542
|
return simulateTransaction;
|
|
@@ -489,11 +544,11 @@ var Server = exports.Server = function () {
|
|
|
489
544
|
}, {
|
|
490
545
|
key: "_simulateTransaction",
|
|
491
546
|
value: function () {
|
|
492
|
-
var _simulateTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
493
|
-
return _regeneratorRuntime().wrap(function
|
|
494
|
-
while (1) switch (
|
|
547
|
+
var _simulateTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee17(transaction, addlResources) {
|
|
548
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
549
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
495
550
|
case 0:
|
|
496
|
-
return
|
|
551
|
+
return _context17.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'simulateTransaction', _objectSpread({
|
|
497
552
|
transaction: transaction.toXDR()
|
|
498
553
|
}, addlResources !== undefined && {
|
|
499
554
|
resourceConfig: {
|
|
@@ -502,11 +557,11 @@ var Server = exports.Server = function () {
|
|
|
502
557
|
})));
|
|
503
558
|
case 1:
|
|
504
559
|
case "end":
|
|
505
|
-
return
|
|
560
|
+
return _context17.stop();
|
|
506
561
|
}
|
|
507
|
-
},
|
|
562
|
+
}, _callee17, this);
|
|
508
563
|
}));
|
|
509
|
-
function _simulateTransaction(
|
|
564
|
+
function _simulateTransaction(_x14, _x15) {
|
|
510
565
|
return _simulateTransaction3.apply(this, arguments);
|
|
511
566
|
}
|
|
512
567
|
return _simulateTransaction;
|
|
@@ -514,29 +569,29 @@ var Server = exports.Server = function () {
|
|
|
514
569
|
}, {
|
|
515
570
|
key: "prepareTransaction",
|
|
516
571
|
value: (function () {
|
|
517
|
-
var _prepareTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
572
|
+
var _prepareTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee18(tx) {
|
|
518
573
|
var simResponse;
|
|
519
|
-
return _regeneratorRuntime().wrap(function
|
|
520
|
-
while (1) switch (
|
|
574
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
575
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
521
576
|
case 0:
|
|
522
|
-
|
|
577
|
+
_context18.next = 2;
|
|
523
578
|
return this.simulateTransaction(tx);
|
|
524
579
|
case 2:
|
|
525
|
-
simResponse =
|
|
580
|
+
simResponse = _context18.sent;
|
|
526
581
|
if (!_api.Api.isSimulationError(simResponse)) {
|
|
527
|
-
|
|
582
|
+
_context18.next = 5;
|
|
528
583
|
break;
|
|
529
584
|
}
|
|
530
|
-
throw simResponse.error;
|
|
585
|
+
throw new Error(simResponse.error);
|
|
531
586
|
case 5:
|
|
532
|
-
return
|
|
587
|
+
return _context18.abrupt("return", (0, _transaction.assembleTransaction)(tx, simResponse).build());
|
|
533
588
|
case 6:
|
|
534
589
|
case "end":
|
|
535
|
-
return
|
|
590
|
+
return _context18.stop();
|
|
536
591
|
}
|
|
537
|
-
},
|
|
592
|
+
}, _callee18, this);
|
|
538
593
|
}));
|
|
539
|
-
function prepareTransaction(
|
|
594
|
+
function prepareTransaction(_x16) {
|
|
540
595
|
return _prepareTransaction.apply(this, arguments);
|
|
541
596
|
}
|
|
542
597
|
return prepareTransaction;
|
|
@@ -544,18 +599,18 @@ var Server = exports.Server = function () {
|
|
|
544
599
|
}, {
|
|
545
600
|
key: "sendTransaction",
|
|
546
601
|
value: (function () {
|
|
547
|
-
var _sendTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
548
|
-
return _regeneratorRuntime().wrap(function
|
|
549
|
-
while (1) switch (
|
|
602
|
+
var _sendTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee19(transaction) {
|
|
603
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
604
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
550
605
|
case 0:
|
|
551
|
-
return
|
|
606
|
+
return _context19.abrupt("return", this._sendTransaction(transaction).then(_parsers.parseRawSendTransaction));
|
|
552
607
|
case 1:
|
|
553
608
|
case "end":
|
|
554
|
-
return
|
|
609
|
+
return _context19.stop();
|
|
555
610
|
}
|
|
556
|
-
},
|
|
611
|
+
}, _callee19, this);
|
|
557
612
|
}));
|
|
558
|
-
function sendTransaction(
|
|
613
|
+
function sendTransaction(_x17) {
|
|
559
614
|
return _sendTransaction2.apply(this, arguments);
|
|
560
615
|
}
|
|
561
616
|
return sendTransaction;
|
|
@@ -563,20 +618,20 @@ var Server = exports.Server = function () {
|
|
|
563
618
|
}, {
|
|
564
619
|
key: "_sendTransaction",
|
|
565
620
|
value: function () {
|
|
566
|
-
var _sendTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
567
|
-
return _regeneratorRuntime().wrap(function
|
|
568
|
-
while (1) switch (
|
|
621
|
+
var _sendTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee20(transaction) {
|
|
622
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
623
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
569
624
|
case 0:
|
|
570
|
-
return
|
|
625
|
+
return _context20.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'sendTransaction', {
|
|
571
626
|
transaction: transaction.toXDR()
|
|
572
627
|
}));
|
|
573
628
|
case 1:
|
|
574
629
|
case "end":
|
|
575
|
-
return
|
|
630
|
+
return _context20.stop();
|
|
576
631
|
}
|
|
577
|
-
},
|
|
632
|
+
}, _callee20, this);
|
|
578
633
|
}));
|
|
579
|
-
function _sendTransaction(
|
|
634
|
+
function _sendTransaction(_x18) {
|
|
580
635
|
return _sendTransaction3.apply(this, arguments);
|
|
581
636
|
}
|
|
582
637
|
return _sendTransaction;
|
|
@@ -584,107 +639,99 @@ var Server = exports.Server = function () {
|
|
|
584
639
|
}, {
|
|
585
640
|
key: "requestAirdrop",
|
|
586
641
|
value: (function () {
|
|
587
|
-
var _requestAirdrop = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
642
|
+
var _requestAirdrop = _asyncToGenerator(_regeneratorRuntime().mark(function _callee21(address, friendbotUrl) {
|
|
588
643
|
var account, response, meta, sequence, _error$response, _error$response$detai;
|
|
589
|
-
return _regeneratorRuntime().wrap(function
|
|
590
|
-
while (1) switch (
|
|
644
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
645
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
591
646
|
case 0:
|
|
592
647
|
account = typeof address === 'string' ? address : address.accountId();
|
|
593
|
-
|
|
594
|
-
if (
|
|
595
|
-
|
|
648
|
+
_context21.t0 = friendbotUrl;
|
|
649
|
+
if (_context21.t0) {
|
|
650
|
+
_context21.next = 6;
|
|
596
651
|
break;
|
|
597
652
|
}
|
|
598
|
-
|
|
653
|
+
_context21.next = 5;
|
|
599
654
|
return this.getNetwork();
|
|
600
655
|
case 5:
|
|
601
|
-
|
|
656
|
+
_context21.t0 = _context21.sent.friendbotUrl;
|
|
602
657
|
case 6:
|
|
603
|
-
friendbotUrl =
|
|
658
|
+
friendbotUrl = _context21.t0;
|
|
604
659
|
if (friendbotUrl) {
|
|
605
|
-
|
|
660
|
+
_context21.next = 9;
|
|
606
661
|
break;
|
|
607
662
|
}
|
|
608
663
|
throw new Error('No friendbot URL configured for current network');
|
|
609
664
|
case 9:
|
|
610
|
-
|
|
611
|
-
|
|
665
|
+
_context21.prev = 9;
|
|
666
|
+
_context21.next = 12;
|
|
612
667
|
return _axios.default.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
613
668
|
case 12:
|
|
614
|
-
response =
|
|
669
|
+
response = _context21.sent;
|
|
615
670
|
meta = _stellarBase.xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, 'base64');
|
|
616
671
|
sequence = findCreatedAccountSequenceInTransactionMeta(meta);
|
|
617
|
-
return
|
|
672
|
+
return _context21.abrupt("return", new _stellarBase.Account(account, sequence));
|
|
618
673
|
case 18:
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
if (!(((_error$response =
|
|
622
|
-
|
|
674
|
+
_context21.prev = 18;
|
|
675
|
+
_context21.t1 = _context21["catch"](9);
|
|
676
|
+
if (!(((_error$response = _context21.t1.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 400)) {
|
|
677
|
+
_context21.next = 23;
|
|
623
678
|
break;
|
|
624
679
|
}
|
|
625
|
-
if (!((_error$response$detai =
|
|
626
|
-
|
|
680
|
+
if (!((_error$response$detai = _context21.t1.response.detail) !== null && _error$response$detai !== void 0 && _error$response$detai.includes('createAccountAlreadyExist'))) {
|
|
681
|
+
_context21.next = 23;
|
|
627
682
|
break;
|
|
628
683
|
}
|
|
629
|
-
return
|
|
684
|
+
return _context21.abrupt("return", this.getAccount(account));
|
|
630
685
|
case 23:
|
|
631
|
-
throw
|
|
686
|
+
throw _context21.t1;
|
|
632
687
|
case 24:
|
|
633
688
|
case "end":
|
|
634
|
-
return
|
|
689
|
+
return _context21.stop();
|
|
635
690
|
}
|
|
636
|
-
},
|
|
691
|
+
}, _callee21, this, [[9, 18]]);
|
|
637
692
|
}));
|
|
638
|
-
function requestAirdrop(
|
|
693
|
+
function requestAirdrop(_x19, _x20) {
|
|
639
694
|
return _requestAirdrop.apply(this, arguments);
|
|
640
695
|
}
|
|
641
696
|
return requestAirdrop;
|
|
642
697
|
}())
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
function
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
operations = meta.value().operations();
|
|
655
|
-
break;
|
|
656
|
-
default:
|
|
657
|
-
throw new Error('Unexpected transaction meta switch value');
|
|
658
|
-
}
|
|
659
|
-
var _iterator = _createForOfIteratorHelper(operations),
|
|
660
|
-
_step;
|
|
661
|
-
try {
|
|
662
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
663
|
-
var op = _step.value;
|
|
664
|
-
var _iterator2 = _createForOfIteratorHelper(op.changes()),
|
|
665
|
-
_step2;
|
|
666
|
-
try {
|
|
667
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
668
|
-
var c = _step2.value;
|
|
669
|
-
if (c.switch() !== _stellarBase.xdr.LedgerEntryChangeType.ledgerEntryCreated()) {
|
|
670
|
-
continue;
|
|
698
|
+
}, {
|
|
699
|
+
key: "getFeeStats",
|
|
700
|
+
value: (function () {
|
|
701
|
+
var _getFeeStats = _asyncToGenerator(_regeneratorRuntime().mark(function _callee22() {
|
|
702
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
703
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
704
|
+
case 0:
|
|
705
|
+
return _context22.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getFeeStats'));
|
|
706
|
+
case 1:
|
|
707
|
+
case "end":
|
|
708
|
+
return _context22.stop();
|
|
671
709
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
710
|
+
}, _callee22, this);
|
|
711
|
+
}));
|
|
712
|
+
function getFeeStats() {
|
|
713
|
+
return _getFeeStats.apply(this, arguments);
|
|
714
|
+
}
|
|
715
|
+
return getFeeStats;
|
|
716
|
+
}())
|
|
717
|
+
}, {
|
|
718
|
+
key: "getVersionInfo",
|
|
719
|
+
value: (function () {
|
|
720
|
+
var _getVersionInfo = _asyncToGenerator(_regeneratorRuntime().mark(function _callee23() {
|
|
721
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
722
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
723
|
+
case 0:
|
|
724
|
+
return _context23.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getVersionInfo'));
|
|
725
|
+
case 1:
|
|
726
|
+
case "end":
|
|
727
|
+
return _context23.stop();
|
|
675
728
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
} finally {
|
|
681
|
-
_iterator2.f();
|
|
729
|
+
}, _callee23, this);
|
|
730
|
+
}));
|
|
731
|
+
function getVersionInfo() {
|
|
732
|
+
return _getVersionInfo.apply(this, arguments);
|
|
682
733
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
_iterator.f();
|
|
688
|
-
}
|
|
689
|
-
throw new Error('No account created in transaction');
|
|
690
|
-
}
|
|
734
|
+
return getVersionInfo;
|
|
735
|
+
}())
|
|
736
|
+
}]);
|
|
737
|
+
}();
|
package/lib/rpc/transaction.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { FeeBumpTransaction, Transaction, TransactionBuilder } from '@stellar/st
|
|
|
2
2
|
import { Api } from './api';
|
|
3
3
|
/**
|
|
4
4
|
* Combines the given raw transaction alongside the simulation results.
|
|
5
|
+
* If the given transaction already has authorization entries in a host
|
|
6
|
+
* function invocation (see {@link Operation.invokeHostFunction}), **the
|
|
7
|
+
* simulation entries are ignored**.
|
|
5
8
|
*
|
|
6
9
|
* @param raw the initial transaction, w/o simulation applied
|
|
7
10
|
* @param simulation the Soroban RPC simulation result (see
|
|
@@ -10,10 +13,6 @@ import { Api } from './api';
|
|
|
10
13
|
* @returns a new, cloned transaction with the proper auth and resource (fee,
|
|
11
14
|
* footprint) simulation data applied
|
|
12
15
|
*
|
|
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
16
|
* @see {Server.simulateTransaction}
|
|
18
17
|
* @see {Server.prepareTransaction}
|
|
19
18
|
*/
|
package/lib/rpc/transaction.js
CHANGED
|
@@ -7,8 +7,20 @@ exports.assembleTransaction = assembleTransaction;
|
|
|
7
7
|
var _stellarBase = require("@stellar/stellar-base");
|
|
8
8
|
var _api = require("./api");
|
|
9
9
|
var _parsers = require("./parsers");
|
|
10
|
+
function isSorobanTransaction(tx) {
|
|
11
|
+
if (tx.operations.length !== 1) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
switch (tx.operations[0].type) {
|
|
15
|
+
case 'invokeHostFunction':
|
|
16
|
+
case 'extendFootprintTtl':
|
|
17
|
+
case 'restoreFootprint':
|
|
18
|
+
return true;
|
|
19
|
+
default:
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
function assembleTransaction(raw, simulation) {
|
|
11
|
-
var _invokeOp$auth;
|
|
12
24
|
if ('innerTransaction' in raw) {
|
|
13
25
|
return assembleTransaction(raw.innerTransaction, simulation);
|
|
14
26
|
}
|
|
@@ -26,30 +38,16 @@ function assembleTransaction(raw, simulation) {
|
|
|
26
38
|
sorobanData: success.transactionData.build(),
|
|
27
39
|
networkPassphrase: raw.networkPassphrase
|
|
28
40
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
break;
|
|
41
|
+
if (raw.operations[0].type === 'invokeHostFunction') {
|
|
42
|
+
var _invokeOp$auth;
|
|
43
|
+
txnBuilder.clearOperations();
|
|
44
|
+
var invokeOp = raw.operations[0];
|
|
45
|
+
var existingAuth = (_invokeOp$auth = invokeOp.auth) !== null && _invokeOp$auth !== void 0 ? _invokeOp$auth : [];
|
|
46
|
+
txnBuilder.addOperation(_stellarBase.Operation.invokeHostFunction({
|
|
47
|
+
source: invokeOp.source,
|
|
48
|
+
func: invokeOp.func,
|
|
49
|
+
auth: existingAuth.length > 0 ? existingAuth : success.result.auth
|
|
50
|
+
}));
|
|
40
51
|
}
|
|
41
52
|
return txnBuilder;
|
|
42
|
-
}
|
|
43
|
-
function isSorobanTransaction(tx) {
|
|
44
|
-
if (tx.operations.length !== 1) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
switch (tx.operations[0].type) {
|
|
48
|
-
case 'invokeHostFunction':
|
|
49
|
-
case 'extendFootprintTtl':
|
|
50
|
-
case 'restoreFootprint':
|
|
51
|
-
return true;
|
|
52
|
-
default:
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
53
|
}
|
package/lib/webauth/utils.js
CHANGED
|
@@ -214,7 +214,7 @@ function verifyChallengeTxSigners(challengeTx, serverAccountID, networkPassphras
|
|
|
214
214
|
try {
|
|
215
215
|
serverKP = _stellarBase.Keypair.fromPublicKey(serverAccountID);
|
|
216
216
|
} catch (err) {
|
|
217
|
-
throw new Error("Couldn't infer keypair from the provided 'serverAccountID': "
|
|
217
|
+
throw new Error("Couldn't infer keypair from the provided 'serverAccountID': ".concat(err.message));
|
|
218
218
|
}
|
|
219
219
|
var clientSigners = new Set();
|
|
220
220
|
var _iterator2 = _createForOfIteratorHelper(signers),
|
|
@@ -273,7 +273,7 @@ function verifyChallengeTxSigners(challengeTx, serverAccountID, networkPassphras
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
if (!serverSignatureFound) {
|
|
276
|
-
throw new _errors.InvalidChallengeError("Transaction not signed by server: '"
|
|
276
|
+
throw new _errors.InvalidChallengeError("Transaction not signed by server: '".concat(serverKP.publicKey(), "'"));
|
|
277
277
|
}
|
|
278
278
|
if (clientSigningKey && !clientSigningKeySignatureFound) {
|
|
279
279
|
throw new _errors.InvalidChallengeError("Transaction not signed by the source account of the 'client_domain' " + "ManageData operation");
|
|
@@ -309,7 +309,7 @@ function gatherTxSigners(transaction, signers) {
|
|
|
309
309
|
try {
|
|
310
310
|
keypair = _stellarBase.Keypair.fromPublicKey(signer);
|
|
311
311
|
} catch (err) {
|
|
312
|
-
throw new _errors.InvalidChallengeError("Signer is not a valid address: "
|
|
312
|
+
throw new _errors.InvalidChallengeError("Signer is not a valid address: ".concat(err.message));
|
|
313
313
|
}
|
|
314
314
|
for (var i = 0; i < txSignatures.length; i++) {
|
|
315
315
|
var decSig = txSignatures[i];
|