@stellar/stellar-sdk 13.0.0-beta.1 → 13.0.0-rc.2
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 +63 -0
- package/dist/stellar-sdk-minimal.js +585 -253
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +602 -256
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +585 -253
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +602 -256
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract/assembled_transaction.d.ts +75 -3
- package/lib/contract/assembled_transaction.js +124 -35
- package/lib/contract/basic_node_signer.d.ts +3 -2
- package/lib/contract/basic_node_signer.js +16 -8
- package/lib/contract/client.d.ts +13 -1
- package/lib/contract/client.js +159 -48
- package/lib/contract/sent_transaction.d.ts +2 -3
- package/lib/contract/sent_transaction.js +4 -4
- package/lib/contract/types.d.ts +72 -8
- package/lib/contract/types.js +1 -0
- package/lib/horizon/call_builder.d.ts +1 -1
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/server_api.d.ts +1 -15
- package/lib/horizon/server_api.js +5 -0
- package/lib/horizon/types/assets.d.ts +0 -2
- package/lib/horizon/types/effects.d.ts +51 -51
- package/lib/horizon/types/trade.d.ts +3 -2
- package/lib/http-client/types.d.ts +1 -0
- package/lib/index.d.ts +0 -4
- package/lib/index.js +1 -4
- package/lib/minimal/contract/assembled_transaction.d.ts +75 -3
- package/lib/minimal/contract/assembled_transaction.js +124 -35
- package/lib/minimal/contract/basic_node_signer.d.ts +3 -2
- package/lib/minimal/contract/basic_node_signer.js +16 -8
- package/lib/minimal/contract/client.d.ts +13 -1
- package/lib/minimal/contract/client.js +159 -48
- package/lib/minimal/contract/sent_transaction.d.ts +2 -3
- package/lib/minimal/contract/sent_transaction.js +4 -4
- package/lib/minimal/contract/types.d.ts +72 -8
- package/lib/minimal/contract/types.js +1 -0
- package/lib/minimal/horizon/call_builder.d.ts +1 -1
- package/lib/minimal/horizon/horizon_axios_client.js +1 -1
- package/lib/minimal/horizon/server_api.d.ts +1 -15
- package/lib/minimal/horizon/server_api.js +5 -0
- package/lib/minimal/horizon/types/assets.d.ts +0 -2
- package/lib/minimal/horizon/types/effects.d.ts +51 -51
- package/lib/minimal/horizon/types/trade.d.ts +3 -2
- package/lib/minimal/http-client/types.d.ts +1 -0
- package/lib/minimal/index.d.ts +0 -4
- package/lib/minimal/index.js +1 -4
- package/lib/minimal/rpc/api.d.ts +12 -9
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/index.d.ts +1 -1
- package/lib/minimal/rpc/index.js +14 -0
- package/lib/minimal/rpc/parsers.d.ts +1 -1
- package/lib/minimal/rpc/parsers.js +3 -3
- package/lib/minimal/rpc/server.d.ts +41 -3
- package/lib/minimal/rpc/server.js +203 -149
- package/lib/minimal/stellartoml/index.d.ts +1 -0
- package/lib/minimal/stellartoml/index.js +2 -0
- package/lib/minimal/utils.d.ts +1 -0
- package/lib/minimal/utils.js +7 -0
- package/lib/no-axios/contract/assembled_transaction.d.ts +75 -3
- package/lib/no-axios/contract/assembled_transaction.js +124 -35
- package/lib/no-axios/contract/basic_node_signer.d.ts +3 -2
- package/lib/no-axios/contract/basic_node_signer.js +16 -8
- package/lib/no-axios/contract/client.d.ts +13 -1
- package/lib/no-axios/contract/client.js +159 -48
- package/lib/no-axios/contract/sent_transaction.d.ts +2 -3
- package/lib/no-axios/contract/sent_transaction.js +4 -4
- package/lib/no-axios/contract/types.d.ts +72 -8
- package/lib/no-axios/contract/types.js +1 -0
- package/lib/no-axios/horizon/call_builder.d.ts +1 -1
- package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
- package/lib/no-axios/horizon/server_api.d.ts +1 -15
- package/lib/no-axios/horizon/server_api.js +5 -0
- package/lib/no-axios/horizon/types/assets.d.ts +0 -2
- package/lib/no-axios/horizon/types/effects.d.ts +51 -51
- package/lib/no-axios/horizon/types/trade.d.ts +3 -2
- package/lib/no-axios/http-client/types.d.ts +1 -0
- package/lib/no-axios/index.d.ts +0 -4
- package/lib/no-axios/index.js +1 -4
- package/lib/no-axios/rpc/api.d.ts +12 -9
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/index.d.ts +1 -1
- package/lib/no-axios/rpc/index.js +14 -0
- package/lib/no-axios/rpc/parsers.d.ts +1 -1
- package/lib/no-axios/rpc/parsers.js +3 -3
- package/lib/no-axios/rpc/server.d.ts +41 -3
- package/lib/no-axios/rpc/server.js +203 -149
- package/lib/no-axios/stellartoml/index.d.ts +1 -0
- package/lib/no-axios/stellartoml/index.js +2 -0
- package/lib/no-axios/utils.d.ts +1 -0
- package/lib/no-axios/utils.js +7 -0
- package/lib/no-eventsource/contract/assembled_transaction.d.ts +75 -3
- package/lib/no-eventsource/contract/assembled_transaction.js +124 -35
- package/lib/no-eventsource/contract/basic_node_signer.d.ts +3 -2
- package/lib/no-eventsource/contract/basic_node_signer.js +16 -8
- package/lib/no-eventsource/contract/client.d.ts +13 -1
- package/lib/no-eventsource/contract/client.js +159 -48
- package/lib/no-eventsource/contract/sent_transaction.d.ts +2 -3
- package/lib/no-eventsource/contract/sent_transaction.js +4 -4
- package/lib/no-eventsource/contract/types.d.ts +72 -8
- package/lib/no-eventsource/contract/types.js +1 -0
- package/lib/no-eventsource/horizon/call_builder.d.ts +1 -1
- package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
- package/lib/no-eventsource/horizon/server_api.d.ts +1 -15
- package/lib/no-eventsource/horizon/server_api.js +5 -0
- package/lib/no-eventsource/horizon/types/assets.d.ts +0 -2
- package/lib/no-eventsource/horizon/types/effects.d.ts +51 -51
- package/lib/no-eventsource/horizon/types/trade.d.ts +3 -2
- package/lib/no-eventsource/http-client/types.d.ts +1 -0
- package/lib/no-eventsource/index.d.ts +0 -4
- package/lib/no-eventsource/index.js +1 -4
- package/lib/no-eventsource/rpc/api.d.ts +12 -9
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/index.d.ts +1 -1
- package/lib/no-eventsource/rpc/index.js +14 -0
- package/lib/no-eventsource/rpc/parsers.d.ts +1 -1
- package/lib/no-eventsource/rpc/parsers.js +3 -3
- package/lib/no-eventsource/rpc/server.d.ts +41 -3
- package/lib/no-eventsource/rpc/server.js +203 -149
- package/lib/no-eventsource/stellartoml/index.d.ts +1 -0
- package/lib/no-eventsource/stellartoml/index.js +2 -0
- package/lib/no-eventsource/utils.d.ts +1 -0
- package/lib/no-eventsource/utils.js +7 -0
- package/lib/rpc/api.d.ts +12 -9
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/index.d.ts +1 -1
- package/lib/rpc/index.js +14 -0
- package/lib/rpc/parsers.d.ts +1 -1
- package/lib/rpc/parsers.js +3 -3
- package/lib/rpc/server.d.ts +41 -3
- package/lib/rpc/server.js +203 -149
- package/lib/stellartoml/index.d.ts +1 -0
- package/lib/stellartoml/index.js +2 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +7 -0
- package/package.json +16 -16
package/lib/rpc/server.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SUBMIT_TRANSACTION_TIMEOUT = exports.RpcServer = exports.Durability = void 0;
|
|
6
|
+
exports.SUBMIT_TRANSACTION_TIMEOUT = exports.RpcServer = exports.LinearSleepStrategy = exports.Durability = exports.BasicSleepStrategy = void 0;
|
|
7
7
|
var _urijs = _interopRequireDefault(require("urijs"));
|
|
8
8
|
var _stellarBase = require("@stellar/stellar-base");
|
|
9
9
|
var _axios = _interopRequireDefault(require("./axios"));
|
|
@@ -11,6 +11,7 @@ var jsonrpc = _interopRequireWildcard(require("./jsonrpc"));
|
|
|
11
11
|
var _api = require("./api");
|
|
12
12
|
var _transaction = require("./transaction");
|
|
13
13
|
var _parsers = require("./parsers");
|
|
14
|
+
var _utils = require("../utils");
|
|
14
15
|
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
16
|
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
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -32,6 +33,13 @@ var Durability = exports.Durability = function (Durability) {
|
|
|
32
33
|
Durability["Persistent"] = "persistent";
|
|
33
34
|
return Durability;
|
|
34
35
|
}({});
|
|
36
|
+
var DEFAULT_GET_TRANSACTION_TIMEOUT = 30;
|
|
37
|
+
var BasicSleepStrategy = exports.BasicSleepStrategy = function BasicSleepStrategy(_iter) {
|
|
38
|
+
return 1000;
|
|
39
|
+
};
|
|
40
|
+
var LinearSleepStrategy = exports.LinearSleepStrategy = function LinearSleepStrategy(iter) {
|
|
41
|
+
return 1000 * iter;
|
|
42
|
+
};
|
|
35
43
|
function findCreatedAccountSequenceInTransactionMeta(meta) {
|
|
36
44
|
var _operations$flatMap$f;
|
|
37
45
|
var operations = [];
|
|
@@ -336,19 +344,65 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
336
344
|
return _getLedgerEntries;
|
|
337
345
|
}()
|
|
338
346
|
}, {
|
|
339
|
-
key: "
|
|
347
|
+
key: "pollTransaction",
|
|
340
348
|
value: (function () {
|
|
341
|
-
var
|
|
349
|
+
var _pollTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(hash, opts) {
|
|
350
|
+
var _opts$attempts, _opts$attempts2;
|
|
351
|
+
var maxAttempts, foundInfo, attempt, _opts$sleepStrategy;
|
|
342
352
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
343
353
|
while (1) switch (_context8.prev = _context8.next) {
|
|
344
354
|
case 0:
|
|
345
|
-
|
|
355
|
+
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;
|
|
356
|
+
attempt = 1;
|
|
357
|
+
case 2:
|
|
358
|
+
if (!(attempt < maxAttempts)) {
|
|
359
|
+
_context8.next = 13;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
_context8.next = 5;
|
|
363
|
+
return this.getTransaction(hash);
|
|
364
|
+
case 5:
|
|
365
|
+
foundInfo = _context8.sent;
|
|
366
|
+
if (!(foundInfo.status !== _api.Api.GetTransactionStatus.NOT_FOUND)) {
|
|
367
|
+
_context8.next = 8;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
return _context8.abrupt("return", foundInfo);
|
|
371
|
+
case 8:
|
|
372
|
+
_context8.next = 10;
|
|
373
|
+
return _utils.Utils.sleep(((_opts$sleepStrategy = opts === null || opts === void 0 ? void 0 : opts.sleepStrategy) !== null && _opts$sleepStrategy !== void 0 ? _opts$sleepStrategy : BasicSleepStrategy)(attempt));
|
|
374
|
+
case 10:
|
|
375
|
+
attempt++;
|
|
376
|
+
_context8.next = 2;
|
|
377
|
+
break;
|
|
378
|
+
case 13:
|
|
379
|
+
return _context8.abrupt("return", foundInfo);
|
|
380
|
+
case 14:
|
|
381
|
+
case "end":
|
|
382
|
+
return _context8.stop();
|
|
383
|
+
}
|
|
384
|
+
}, _callee8, this);
|
|
385
|
+
}));
|
|
386
|
+
function pollTransaction(_x6, _x7) {
|
|
387
|
+
return _pollTransaction.apply(this, arguments);
|
|
388
|
+
}
|
|
389
|
+
return pollTransaction;
|
|
390
|
+
}())
|
|
391
|
+
}, {
|
|
392
|
+
key: "getTransaction",
|
|
393
|
+
value: (function () {
|
|
394
|
+
var _getTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(hash) {
|
|
395
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
396
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
397
|
+
case 0:
|
|
398
|
+
return _context9.abrupt("return", this._getTransaction(hash).then(function (raw) {
|
|
346
399
|
var foundInfo = {};
|
|
347
400
|
if (raw.status !== _api.Api.GetTransactionStatus.NOT_FOUND) {
|
|
348
401
|
Object.assign(foundInfo, (0, _parsers.parseTransactionInfo)(raw));
|
|
349
402
|
}
|
|
350
403
|
var result = _objectSpread({
|
|
351
404
|
status: raw.status,
|
|
405
|
+
txHash: hash,
|
|
352
406
|
latestLedger: raw.latestLedger,
|
|
353
407
|
latestLedgerCloseTime: raw.latestLedgerCloseTime,
|
|
354
408
|
oldestLedger: raw.oldestLedger,
|
|
@@ -358,11 +412,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
358
412
|
}));
|
|
359
413
|
case 1:
|
|
360
414
|
case "end":
|
|
361
|
-
return
|
|
415
|
+
return _context9.stop();
|
|
362
416
|
}
|
|
363
|
-
},
|
|
417
|
+
}, _callee9, this);
|
|
364
418
|
}));
|
|
365
|
-
function getTransaction(
|
|
419
|
+
function getTransaction(_x8) {
|
|
366
420
|
return _getTransaction2.apply(this, arguments);
|
|
367
421
|
}
|
|
368
422
|
return getTransaction;
|
|
@@ -370,20 +424,20 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
370
424
|
}, {
|
|
371
425
|
key: "_getTransaction",
|
|
372
426
|
value: function () {
|
|
373
|
-
var _getTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
374
|
-
return _regeneratorRuntime().wrap(function
|
|
375
|
-
while (1) switch (
|
|
427
|
+
var _getTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee10(hash) {
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
429
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
376
430
|
case 0:
|
|
377
|
-
return
|
|
431
|
+
return _context10.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getTransaction', {
|
|
378
432
|
hash: hash
|
|
379
433
|
}));
|
|
380
434
|
case 1:
|
|
381
435
|
case "end":
|
|
382
|
-
return
|
|
436
|
+
return _context10.stop();
|
|
383
437
|
}
|
|
384
|
-
},
|
|
438
|
+
}, _callee10, this);
|
|
385
439
|
}));
|
|
386
|
-
function _getTransaction(
|
|
440
|
+
function _getTransaction(_x9) {
|
|
387
441
|
return _getTransaction3.apply(this, arguments);
|
|
388
442
|
}
|
|
389
443
|
return _getTransaction;
|
|
@@ -391,11 +445,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
391
445
|
}, {
|
|
392
446
|
key: "getTransactions",
|
|
393
447
|
value: (function () {
|
|
394
|
-
var _getTransactions2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
395
|
-
return _regeneratorRuntime().wrap(function
|
|
396
|
-
while (1) switch (
|
|
448
|
+
var _getTransactions2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee11(request) {
|
|
449
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
450
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
397
451
|
case 0:
|
|
398
|
-
return
|
|
452
|
+
return _context11.abrupt("return", this._getTransactions(request).then(function (raw) {
|
|
399
453
|
var result = {
|
|
400
454
|
transactions: raw.transactions.map(_parsers.parseRawTransactions),
|
|
401
455
|
latestLedger: raw.latestLedger,
|
|
@@ -408,11 +462,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
408
462
|
}));
|
|
409
463
|
case 1:
|
|
410
464
|
case "end":
|
|
411
|
-
return
|
|
465
|
+
return _context11.stop();
|
|
412
466
|
}
|
|
413
|
-
},
|
|
467
|
+
}, _callee11, this);
|
|
414
468
|
}));
|
|
415
|
-
function getTransactions(
|
|
469
|
+
function getTransactions(_x10) {
|
|
416
470
|
return _getTransactions2.apply(this, arguments);
|
|
417
471
|
}
|
|
418
472
|
return getTransactions;
|
|
@@ -420,18 +474,18 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
420
474
|
}, {
|
|
421
475
|
key: "_getTransactions",
|
|
422
476
|
value: function () {
|
|
423
|
-
var _getTransactions3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
424
|
-
return _regeneratorRuntime().wrap(function
|
|
425
|
-
while (1) switch (
|
|
477
|
+
var _getTransactions3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee12(request) {
|
|
478
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
479
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
426
480
|
case 0:
|
|
427
|
-
return
|
|
481
|
+
return _context12.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getTransactions', request));
|
|
428
482
|
case 1:
|
|
429
483
|
case "end":
|
|
430
|
-
return
|
|
484
|
+
return _context12.stop();
|
|
431
485
|
}
|
|
432
|
-
},
|
|
486
|
+
}, _callee12, this);
|
|
433
487
|
}));
|
|
434
|
-
function _getTransactions(
|
|
488
|
+
function _getTransactions(_x11) {
|
|
435
489
|
return _getTransactions3.apply(this, arguments);
|
|
436
490
|
}
|
|
437
491
|
return _getTransactions;
|
|
@@ -439,18 +493,18 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
439
493
|
}, {
|
|
440
494
|
key: "getEvents",
|
|
441
495
|
value: (function () {
|
|
442
|
-
var _getEvents2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
443
|
-
return _regeneratorRuntime().wrap(function
|
|
444
|
-
while (1) switch (
|
|
496
|
+
var _getEvents2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee13(request) {
|
|
497
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
498
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
445
499
|
case 0:
|
|
446
|
-
return
|
|
500
|
+
return _context13.abrupt("return", this._getEvents(request).then(_parsers.parseRawEvents));
|
|
447
501
|
case 1:
|
|
448
502
|
case "end":
|
|
449
|
-
return
|
|
503
|
+
return _context13.stop();
|
|
450
504
|
}
|
|
451
|
-
},
|
|
505
|
+
}, _callee13, this);
|
|
452
506
|
}));
|
|
453
|
-
function getEvents(
|
|
507
|
+
function getEvents(_x12) {
|
|
454
508
|
return _getEvents2.apply(this, arguments);
|
|
455
509
|
}
|
|
456
510
|
return getEvents;
|
|
@@ -458,12 +512,12 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
458
512
|
}, {
|
|
459
513
|
key: "_getEvents",
|
|
460
514
|
value: function () {
|
|
461
|
-
var _getEvents3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
515
|
+
var _getEvents3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee14(request) {
|
|
462
516
|
var _request$filters;
|
|
463
|
-
return _regeneratorRuntime().wrap(function
|
|
464
|
-
while (1) switch (
|
|
517
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
518
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
465
519
|
case 0:
|
|
466
|
-
return
|
|
520
|
+
return _context14.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getEvents', _objectSpread(_objectSpread({
|
|
467
521
|
filters: (_request$filters = request.filters) !== null && _request$filters !== void 0 ? _request$filters : [],
|
|
468
522
|
pagination: _objectSpread(_objectSpread({}, request.cursor && {
|
|
469
523
|
cursor: request.cursor
|
|
@@ -477,11 +531,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
477
531
|
})));
|
|
478
532
|
case 1:
|
|
479
533
|
case "end":
|
|
480
|
-
return
|
|
534
|
+
return _context14.stop();
|
|
481
535
|
}
|
|
482
|
-
},
|
|
536
|
+
}, _callee14, this);
|
|
483
537
|
}));
|
|
484
|
-
function _getEvents(
|
|
538
|
+
function _getEvents(_x13) {
|
|
485
539
|
return _getEvents3.apply(this, arguments);
|
|
486
540
|
}
|
|
487
541
|
return _getEvents;
|
|
@@ -489,16 +543,16 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
489
543
|
}, {
|
|
490
544
|
key: "getNetwork",
|
|
491
545
|
value: (function () {
|
|
492
|
-
var _getNetwork = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
493
|
-
return _regeneratorRuntime().wrap(function
|
|
494
|
-
while (1) switch (
|
|
546
|
+
var _getNetwork = _asyncToGenerator(_regeneratorRuntime().mark(function _callee15() {
|
|
547
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
548
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
495
549
|
case 0:
|
|
496
|
-
return
|
|
550
|
+
return _context15.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getNetwork'));
|
|
497
551
|
case 1:
|
|
498
552
|
case "end":
|
|
499
|
-
return
|
|
553
|
+
return _context15.stop();
|
|
500
554
|
}
|
|
501
|
-
},
|
|
555
|
+
}, _callee15, this);
|
|
502
556
|
}));
|
|
503
557
|
function getNetwork() {
|
|
504
558
|
return _getNetwork.apply(this, arguments);
|
|
@@ -508,16 +562,16 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
508
562
|
}, {
|
|
509
563
|
key: "getLatestLedger",
|
|
510
564
|
value: (function () {
|
|
511
|
-
var _getLatestLedger = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
512
|
-
return _regeneratorRuntime().wrap(function
|
|
513
|
-
while (1) switch (
|
|
565
|
+
var _getLatestLedger = _asyncToGenerator(_regeneratorRuntime().mark(function _callee16() {
|
|
566
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
567
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
514
568
|
case 0:
|
|
515
|
-
return
|
|
569
|
+
return _context16.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getLatestLedger'));
|
|
516
570
|
case 1:
|
|
517
571
|
case "end":
|
|
518
|
-
return
|
|
572
|
+
return _context16.stop();
|
|
519
573
|
}
|
|
520
|
-
},
|
|
574
|
+
}, _callee16, this);
|
|
521
575
|
}));
|
|
522
576
|
function getLatestLedger() {
|
|
523
577
|
return _getLatestLedger.apply(this, arguments);
|
|
@@ -527,18 +581,18 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
527
581
|
}, {
|
|
528
582
|
key: "simulateTransaction",
|
|
529
583
|
value: (function () {
|
|
530
|
-
var _simulateTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
531
|
-
return _regeneratorRuntime().wrap(function
|
|
532
|
-
while (1) switch (
|
|
584
|
+
var _simulateTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee17(tx, addlResources) {
|
|
585
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
586
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
533
587
|
case 0:
|
|
534
|
-
return
|
|
588
|
+
return _context17.abrupt("return", this._simulateTransaction(tx, addlResources).then(_parsers.parseRawSimulation));
|
|
535
589
|
case 1:
|
|
536
590
|
case "end":
|
|
537
|
-
return
|
|
591
|
+
return _context17.stop();
|
|
538
592
|
}
|
|
539
|
-
},
|
|
593
|
+
}, _callee17, this);
|
|
540
594
|
}));
|
|
541
|
-
function simulateTransaction(
|
|
595
|
+
function simulateTransaction(_x14, _x15) {
|
|
542
596
|
return _simulateTransaction2.apply(this, arguments);
|
|
543
597
|
}
|
|
544
598
|
return simulateTransaction;
|
|
@@ -546,11 +600,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
546
600
|
}, {
|
|
547
601
|
key: "_simulateTransaction",
|
|
548
602
|
value: function () {
|
|
549
|
-
var _simulateTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
550
|
-
return _regeneratorRuntime().wrap(function
|
|
551
|
-
while (1) switch (
|
|
603
|
+
var _simulateTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee18(transaction, addlResources) {
|
|
604
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
605
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
552
606
|
case 0:
|
|
553
|
-
return
|
|
607
|
+
return _context18.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'simulateTransaction', _objectSpread({
|
|
554
608
|
transaction: transaction.toXDR()
|
|
555
609
|
}, addlResources !== undefined && {
|
|
556
610
|
resourceConfig: {
|
|
@@ -559,11 +613,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
559
613
|
})));
|
|
560
614
|
case 1:
|
|
561
615
|
case "end":
|
|
562
|
-
return
|
|
616
|
+
return _context18.stop();
|
|
563
617
|
}
|
|
564
|
-
},
|
|
618
|
+
}, _callee18, this);
|
|
565
619
|
}));
|
|
566
|
-
function _simulateTransaction(
|
|
620
|
+
function _simulateTransaction(_x16, _x17) {
|
|
567
621
|
return _simulateTransaction3.apply(this, arguments);
|
|
568
622
|
}
|
|
569
623
|
return _simulateTransaction;
|
|
@@ -571,29 +625,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
571
625
|
}, {
|
|
572
626
|
key: "prepareTransaction",
|
|
573
627
|
value: (function () {
|
|
574
|
-
var _prepareTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
628
|
+
var _prepareTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee19(tx) {
|
|
575
629
|
var simResponse;
|
|
576
|
-
return _regeneratorRuntime().wrap(function
|
|
577
|
-
while (1) switch (
|
|
630
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
631
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
578
632
|
case 0:
|
|
579
|
-
|
|
633
|
+
_context19.next = 2;
|
|
580
634
|
return this.simulateTransaction(tx);
|
|
581
635
|
case 2:
|
|
582
|
-
simResponse =
|
|
636
|
+
simResponse = _context19.sent;
|
|
583
637
|
if (!_api.Api.isSimulationError(simResponse)) {
|
|
584
|
-
|
|
638
|
+
_context19.next = 5;
|
|
585
639
|
break;
|
|
586
640
|
}
|
|
587
641
|
throw new Error(simResponse.error);
|
|
588
642
|
case 5:
|
|
589
|
-
return
|
|
643
|
+
return _context19.abrupt("return", (0, _transaction.assembleTransaction)(tx, simResponse).build());
|
|
590
644
|
case 6:
|
|
591
645
|
case "end":
|
|
592
|
-
return
|
|
646
|
+
return _context19.stop();
|
|
593
647
|
}
|
|
594
|
-
},
|
|
648
|
+
}, _callee19, this);
|
|
595
649
|
}));
|
|
596
|
-
function prepareTransaction(
|
|
650
|
+
function prepareTransaction(_x18) {
|
|
597
651
|
return _prepareTransaction.apply(this, arguments);
|
|
598
652
|
}
|
|
599
653
|
return prepareTransaction;
|
|
@@ -601,18 +655,18 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
601
655
|
}, {
|
|
602
656
|
key: "sendTransaction",
|
|
603
657
|
value: (function () {
|
|
604
|
-
var _sendTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
605
|
-
return _regeneratorRuntime().wrap(function
|
|
606
|
-
while (1) switch (
|
|
658
|
+
var _sendTransaction2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee20(transaction) {
|
|
659
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
660
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
607
661
|
case 0:
|
|
608
|
-
return
|
|
662
|
+
return _context20.abrupt("return", this._sendTransaction(transaction).then(_parsers.parseRawSendTransaction));
|
|
609
663
|
case 1:
|
|
610
664
|
case "end":
|
|
611
|
-
return
|
|
665
|
+
return _context20.stop();
|
|
612
666
|
}
|
|
613
|
-
},
|
|
667
|
+
}, _callee20, this);
|
|
614
668
|
}));
|
|
615
|
-
function sendTransaction(
|
|
669
|
+
function sendTransaction(_x19) {
|
|
616
670
|
return _sendTransaction2.apply(this, arguments);
|
|
617
671
|
}
|
|
618
672
|
return sendTransaction;
|
|
@@ -620,20 +674,20 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
620
674
|
}, {
|
|
621
675
|
key: "_sendTransaction",
|
|
622
676
|
value: function () {
|
|
623
|
-
var _sendTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
624
|
-
return _regeneratorRuntime().wrap(function
|
|
625
|
-
while (1) switch (
|
|
677
|
+
var _sendTransaction3 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee21(transaction) {
|
|
678
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
679
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
626
680
|
case 0:
|
|
627
|
-
return
|
|
681
|
+
return _context21.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'sendTransaction', {
|
|
628
682
|
transaction: transaction.toXDR()
|
|
629
683
|
}));
|
|
630
684
|
case 1:
|
|
631
685
|
case "end":
|
|
632
|
-
return
|
|
686
|
+
return _context21.stop();
|
|
633
687
|
}
|
|
634
|
-
},
|
|
688
|
+
}, _callee21, this);
|
|
635
689
|
}));
|
|
636
|
-
function _sendTransaction(
|
|
690
|
+
function _sendTransaction(_x20) {
|
|
637
691
|
return _sendTransaction3.apply(this, arguments);
|
|
638
692
|
}
|
|
639
693
|
return _sendTransaction;
|
|
@@ -641,58 +695,58 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
641
695
|
}, {
|
|
642
696
|
key: "requestAirdrop",
|
|
643
697
|
value: (function () {
|
|
644
|
-
var _requestAirdrop = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
698
|
+
var _requestAirdrop = _asyncToGenerator(_regeneratorRuntime().mark(function _callee22(address, friendbotUrl) {
|
|
645
699
|
var account, response, meta, sequence, _error$response, _error$response$detai;
|
|
646
|
-
return _regeneratorRuntime().wrap(function
|
|
647
|
-
while (1) switch (
|
|
700
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
701
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
648
702
|
case 0:
|
|
649
703
|
account = typeof address === 'string' ? address : address.accountId();
|
|
650
|
-
|
|
651
|
-
if (
|
|
652
|
-
|
|
704
|
+
_context22.t0 = friendbotUrl;
|
|
705
|
+
if (_context22.t0) {
|
|
706
|
+
_context22.next = 6;
|
|
653
707
|
break;
|
|
654
708
|
}
|
|
655
|
-
|
|
709
|
+
_context22.next = 5;
|
|
656
710
|
return this.getNetwork();
|
|
657
711
|
case 5:
|
|
658
|
-
|
|
712
|
+
_context22.t0 = _context22.sent.friendbotUrl;
|
|
659
713
|
case 6:
|
|
660
|
-
friendbotUrl =
|
|
714
|
+
friendbotUrl = _context22.t0;
|
|
661
715
|
if (friendbotUrl) {
|
|
662
|
-
|
|
716
|
+
_context22.next = 9;
|
|
663
717
|
break;
|
|
664
718
|
}
|
|
665
719
|
throw new Error('No friendbot URL configured for current network');
|
|
666
720
|
case 9:
|
|
667
|
-
|
|
668
|
-
|
|
721
|
+
_context22.prev = 9;
|
|
722
|
+
_context22.next = 12;
|
|
669
723
|
return _axios.default.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
670
724
|
case 12:
|
|
671
|
-
response =
|
|
725
|
+
response = _context22.sent;
|
|
672
726
|
meta = _stellarBase.xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, 'base64');
|
|
673
727
|
sequence = findCreatedAccountSequenceInTransactionMeta(meta);
|
|
674
|
-
return
|
|
728
|
+
return _context22.abrupt("return", new _stellarBase.Account(account, sequence));
|
|
675
729
|
case 18:
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (!(((_error$response =
|
|
679
|
-
|
|
730
|
+
_context22.prev = 18;
|
|
731
|
+
_context22.t1 = _context22["catch"](9);
|
|
732
|
+
if (!(((_error$response = _context22.t1.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 400)) {
|
|
733
|
+
_context22.next = 23;
|
|
680
734
|
break;
|
|
681
735
|
}
|
|
682
|
-
if (!((_error$response$detai =
|
|
683
|
-
|
|
736
|
+
if (!((_error$response$detai = _context22.t1.response.detail) !== null && _error$response$detai !== void 0 && _error$response$detai.includes('createAccountAlreadyExist'))) {
|
|
737
|
+
_context22.next = 23;
|
|
684
738
|
break;
|
|
685
739
|
}
|
|
686
|
-
return
|
|
740
|
+
return _context22.abrupt("return", this.getAccount(account));
|
|
687
741
|
case 23:
|
|
688
|
-
throw
|
|
742
|
+
throw _context22.t1;
|
|
689
743
|
case 24:
|
|
690
744
|
case "end":
|
|
691
|
-
return
|
|
745
|
+
return _context22.stop();
|
|
692
746
|
}
|
|
693
|
-
},
|
|
747
|
+
}, _callee22, this, [[9, 18]]);
|
|
694
748
|
}));
|
|
695
|
-
function requestAirdrop(
|
|
749
|
+
function requestAirdrop(_x21, _x22) {
|
|
696
750
|
return _requestAirdrop.apply(this, arguments);
|
|
697
751
|
}
|
|
698
752
|
return requestAirdrop;
|
|
@@ -700,16 +754,16 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
700
754
|
}, {
|
|
701
755
|
key: "getFeeStats",
|
|
702
756
|
value: (function () {
|
|
703
|
-
var _getFeeStats = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
704
|
-
return _regeneratorRuntime().wrap(function
|
|
705
|
-
while (1) switch (
|
|
757
|
+
var _getFeeStats = _asyncToGenerator(_regeneratorRuntime().mark(function _callee23() {
|
|
758
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
759
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
706
760
|
case 0:
|
|
707
|
-
return
|
|
761
|
+
return _context23.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getFeeStats'));
|
|
708
762
|
case 1:
|
|
709
763
|
case "end":
|
|
710
|
-
return
|
|
764
|
+
return _context23.stop();
|
|
711
765
|
}
|
|
712
|
-
},
|
|
766
|
+
}, _callee23, this);
|
|
713
767
|
}));
|
|
714
768
|
function getFeeStats() {
|
|
715
769
|
return _getFeeStats.apply(this, arguments);
|
|
@@ -719,16 +773,16 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
719
773
|
}, {
|
|
720
774
|
key: "getVersionInfo",
|
|
721
775
|
value: (function () {
|
|
722
|
-
var _getVersionInfo = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
723
|
-
return _regeneratorRuntime().wrap(function
|
|
724
|
-
while (1) switch (
|
|
776
|
+
var _getVersionInfo = _asyncToGenerator(_regeneratorRuntime().mark(function _callee24() {
|
|
777
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
778
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
725
779
|
case 0:
|
|
726
|
-
return
|
|
780
|
+
return _context24.abrupt("return", jsonrpc.postObject(this.serverURL.toString(), 'getVersionInfo'));
|
|
727
781
|
case 1:
|
|
728
782
|
case "end":
|
|
729
|
-
return
|
|
783
|
+
return _context24.stop();
|
|
730
784
|
}
|
|
731
|
-
},
|
|
785
|
+
}, _callee24, this);
|
|
732
786
|
}));
|
|
733
787
|
function getVersionInfo() {
|
|
734
788
|
return _getVersionInfo.apply(this, arguments);
|
|
@@ -738,33 +792,33 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
738
792
|
}, {
|
|
739
793
|
key: "getSACBalance",
|
|
740
794
|
value: (function () {
|
|
741
|
-
var _getSACBalance = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
795
|
+
var _getSACBalance = _asyncToGenerator(_regeneratorRuntime().mark(function _callee25(contractId, sac, networkPassphrase) {
|
|
742
796
|
var passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry;
|
|
743
|
-
return _regeneratorRuntime().wrap(function
|
|
744
|
-
while (1) switch (
|
|
797
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
798
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
745
799
|
case 0:
|
|
746
800
|
if (_stellarBase.StrKey.isValidContract(contractId)) {
|
|
747
|
-
|
|
801
|
+
_context25.next = 2;
|
|
748
802
|
break;
|
|
749
803
|
}
|
|
750
804
|
throw new TypeError("expected contract ID, got ".concat(contractId));
|
|
751
805
|
case 2:
|
|
752
806
|
if (!(networkPassphrase !== null && networkPassphrase !== void 0)) {
|
|
753
|
-
|
|
807
|
+
_context25.next = 6;
|
|
754
808
|
break;
|
|
755
809
|
}
|
|
756
|
-
|
|
757
|
-
|
|
810
|
+
_context25.t0 = networkPassphrase;
|
|
811
|
+
_context25.next = 9;
|
|
758
812
|
break;
|
|
759
813
|
case 6:
|
|
760
|
-
|
|
814
|
+
_context25.next = 8;
|
|
761
815
|
return this.getNetwork().then(function (n) {
|
|
762
816
|
return n.passphrase;
|
|
763
817
|
});
|
|
764
818
|
case 8:
|
|
765
|
-
|
|
819
|
+
_context25.t0 = _context25.sent;
|
|
766
820
|
case 9:
|
|
767
|
-
passphrase =
|
|
821
|
+
passphrase = _context25.t0;
|
|
768
822
|
sacId = sac.contractId(passphrase);
|
|
769
823
|
key = _stellarBase.xdr.ScVal.scvVec([(0, _stellarBase.nativeToScVal)("Balance", {
|
|
770
824
|
type: "symbol"
|
|
@@ -776,29 +830,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
776
830
|
durability: _stellarBase.xdr.ContractDataDurability.persistent(),
|
|
777
831
|
key: key
|
|
778
832
|
}));
|
|
779
|
-
|
|
833
|
+
_context25.next = 15;
|
|
780
834
|
return this.getLedgerEntries(ledgerKey);
|
|
781
835
|
case 15:
|
|
782
|
-
response =
|
|
836
|
+
response = _context25.sent;
|
|
783
837
|
if (!(response.entries.length === 0)) {
|
|
784
|
-
|
|
838
|
+
_context25.next = 18;
|
|
785
839
|
break;
|
|
786
840
|
}
|
|
787
|
-
return
|
|
841
|
+
return _context25.abrupt("return", {
|
|
788
842
|
latestLedger: response.latestLedger
|
|
789
843
|
});
|
|
790
844
|
case 18:
|
|
791
845
|
_response$entries$2 = response.entries[0], lastModifiedLedgerSeq = _response$entries$2.lastModifiedLedgerSeq, liveUntilLedgerSeq = _response$entries$2.liveUntilLedgerSeq, val = _response$entries$2.val;
|
|
792
846
|
if (!(val.switch().value !== _stellarBase.xdr.LedgerEntryType.contractData().value)) {
|
|
793
|
-
|
|
847
|
+
_context25.next = 21;
|
|
794
848
|
break;
|
|
795
849
|
}
|
|
796
|
-
return
|
|
850
|
+
return _context25.abrupt("return", {
|
|
797
851
|
latestLedger: response.latestLedger
|
|
798
852
|
});
|
|
799
853
|
case 21:
|
|
800
854
|
entry = (0, _stellarBase.scValToNative)(val.contractData().val());
|
|
801
|
-
return
|
|
855
|
+
return _context25.abrupt("return", {
|
|
802
856
|
latestLedger: response.latestLedger,
|
|
803
857
|
balanceEntry: {
|
|
804
858
|
liveUntilLedgerSeq: liveUntilLedgerSeq,
|
|
@@ -810,11 +864,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
810
864
|
});
|
|
811
865
|
case 23:
|
|
812
866
|
case "end":
|
|
813
|
-
return
|
|
867
|
+
return _context25.stop();
|
|
814
868
|
}
|
|
815
|
-
},
|
|
869
|
+
}, _callee25, this);
|
|
816
870
|
}));
|
|
817
|
-
function getSACBalance(
|
|
871
|
+
function getSACBalance(_x23, _x24, _x25) {
|
|
818
872
|
return _getSACBalance.apply(this, arguments);
|
|
819
873
|
}
|
|
820
874
|
return getSACBalance;
|