@stellar/stellar-sdk 13.0.0-rc.2 → 13.1.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 +112 -7
- package/README.md +1 -1
- package/dist/stellar-sdk-minimal.js +448 -77
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +1044 -234
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +171 -148
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +767 -305
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/friendbot/index.d.ts +1 -0
- package/lib/horizon/call_builder.d.ts +1 -1
- package/lib/horizon/horizon_api.d.ts +13 -0
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/server.d.ts +5 -0
- package/lib/horizon/server.js +80 -59
- package/lib/minimal/friendbot/index.d.ts +1 -0
- package/lib/minimal/horizon/call_builder.d.ts +1 -1
- package/lib/minimal/horizon/horizon_api.d.ts +13 -0
- package/lib/minimal/horizon/horizon_axios_client.js +1 -1
- package/lib/minimal/horizon/server.d.ts +5 -0
- package/lib/minimal/horizon/server.js +80 -59
- package/lib/minimal/rpc/api.d.ts +2 -1
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/parsers.js +1 -0
- package/lib/minimal/rpc/server.js +27 -8
- package/lib/no-axios/friendbot/index.d.ts +1 -0
- package/lib/no-axios/horizon/call_builder.d.ts +1 -1
- package/lib/no-axios/horizon/horizon_api.d.ts +13 -0
- package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
- package/lib/no-axios/horizon/server.d.ts +5 -0
- package/lib/no-axios/horizon/server.js +80 -59
- package/lib/no-axios/rpc/api.d.ts +2 -1
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/parsers.js +1 -0
- package/lib/no-axios/rpc/server.js +27 -8
- package/lib/no-eventsource/friendbot/index.d.ts +1 -0
- package/lib/no-eventsource/horizon/call_builder.d.ts +1 -1
- package/lib/no-eventsource/horizon/horizon_api.d.ts +13 -0
- package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
- package/lib/no-eventsource/horizon/server.d.ts +5 -0
- package/lib/no-eventsource/horizon/server.js +80 -59
- package/lib/no-eventsource/rpc/api.d.ts +2 -1
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/parsers.js +1 -0
- package/lib/no-eventsource/rpc/server.js +27 -8
- package/lib/rpc/api.d.ts +2 -1
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/parsers.js +1 -0
- package/lib/rpc/server.js +27 -8
- package/package.json +11 -11
package/lib/friendbot/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface EventSourceOptions<T> {
|
|
|
13
13
|
* @param {string} serverUrl URL of Horizon server
|
|
14
14
|
* @class CallBuilder
|
|
15
15
|
*/
|
|
16
|
-
export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | HorizonApi.BaseResponse | ServerApi.CollectionPage<HorizonApi.BaseResponse>> {
|
|
16
|
+
export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | HorizonApi.BaseResponse | HorizonApi.RootResponse | ServerApi.CollectionPage<HorizonApi.BaseResponse>> {
|
|
17
17
|
protected url: URI;
|
|
18
18
|
filter: string[][];
|
|
19
19
|
protected originalSegments: string[];
|
|
@@ -524,4 +524,17 @@ export declare namespace HorizonApi {
|
|
|
524
524
|
};
|
|
525
525
|
result_xdr: string;
|
|
526
526
|
}
|
|
527
|
+
interface RootResponse {
|
|
528
|
+
horizon_version: string;
|
|
529
|
+
core_version: string;
|
|
530
|
+
ingest_latest_ledger: number;
|
|
531
|
+
history_latest_ledger: number;
|
|
532
|
+
history_latest_ledger_closed_at: string;
|
|
533
|
+
history_elder_ledger: number;
|
|
534
|
+
core_latest_ledger: number;
|
|
535
|
+
network_passphrase: string;
|
|
536
|
+
current_protocol_version: number;
|
|
537
|
+
supported_protocol_version: number;
|
|
538
|
+
core_supported_protocol_version: number;
|
|
539
|
+
}
|
|
527
540
|
}
|
|
@@ -10,7 +10,7 @@ var _urijs = _interopRequireDefault(require("urijs"));
|
|
|
10
10
|
var _httpClient = require("../http-client");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
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); }
|
|
13
|
-
var version = exports.version = "13.
|
|
13
|
+
var version = exports.version = "13.1.0";
|
|
14
14
|
var SERVER_TIME_MAP = exports.SERVER_TIME_MAP = {};
|
|
15
15
|
var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
|
|
16
16
|
headers: {
|
package/lib/horizon/server.d.ts
CHANGED
|
@@ -84,6 +84,11 @@ export declare class HorizonServer {
|
|
|
84
84
|
* @returns {Promise<HorizonApi.FeeStatsResponse>} Promise that resolves to the fee stats returned by Horizon.
|
|
85
85
|
*/
|
|
86
86
|
feeStats(): Promise<HorizonApi.FeeStatsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the Horizon server's root endpoint.
|
|
89
|
+
* @returns {Promise<HorizonApi.RootResponse>} Promise that resolves to the root endpoint returned by Horizon.
|
|
90
|
+
*/
|
|
91
|
+
root(): Promise<HorizonApi.RootResponse>;
|
|
87
92
|
/**
|
|
88
93
|
* Submits a transaction to the network.
|
|
89
94
|
*
|
package/lib/horizon/server.js
CHANGED
|
@@ -170,28 +170,49 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
170
170
|
}
|
|
171
171
|
return feeStats;
|
|
172
172
|
}())
|
|
173
|
+
}, {
|
|
174
|
+
key: "root",
|
|
175
|
+
value: (function () {
|
|
176
|
+
var _root = _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
|
|
177
|
+
var cb;
|
|
178
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
179
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
cb = new _call_builder.CallBuilder((0, _urijs.default)(this.serverURL));
|
|
182
|
+
return _context4.abrupt("return", cb.call());
|
|
183
|
+
case 2:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context4.stop();
|
|
186
|
+
}
|
|
187
|
+
}, _callee4, this);
|
|
188
|
+
}));
|
|
189
|
+
function root() {
|
|
190
|
+
return _root.apply(this, arguments);
|
|
191
|
+
}
|
|
192
|
+
return root;
|
|
193
|
+
}())
|
|
173
194
|
}, {
|
|
174
195
|
key: "submitTransaction",
|
|
175
196
|
value: (function () {
|
|
176
|
-
var _submitTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
197
|
+
var _submitTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(transaction) {
|
|
177
198
|
var opts,
|
|
178
199
|
tx,
|
|
179
|
-
|
|
180
|
-
return _regeneratorRuntime().wrap(function
|
|
181
|
-
while (1) switch (
|
|
200
|
+
_args5 = arguments;
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
202
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
182
203
|
case 0:
|
|
183
|
-
opts =
|
|
204
|
+
opts = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {
|
|
184
205
|
skipMemoRequiredCheck: false
|
|
185
206
|
};
|
|
186
207
|
if (opts.skipMemoRequiredCheck) {
|
|
187
|
-
|
|
208
|
+
_context5.next = 4;
|
|
188
209
|
break;
|
|
189
210
|
}
|
|
190
|
-
|
|
211
|
+
_context5.next = 4;
|
|
191
212
|
return this.checkMemoRequired(transaction);
|
|
192
213
|
case 4:
|
|
193
214
|
tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
|
|
194
|
-
return
|
|
215
|
+
return _context5.abrupt("return", _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions").toString(), "tx=".concat(tx), {
|
|
195
216
|
timeout: SUBMIT_TRANSACTION_TIMEOUT
|
|
196
217
|
}).then(function (response) {
|
|
197
218
|
if (!response.data.result_xdr) {
|
|
@@ -302,9 +323,9 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
302
323
|
}));
|
|
303
324
|
case 6:
|
|
304
325
|
case "end":
|
|
305
|
-
return
|
|
326
|
+
return _context5.stop();
|
|
306
327
|
}
|
|
307
|
-
},
|
|
328
|
+
}, _callee5, this);
|
|
308
329
|
}));
|
|
309
330
|
function submitTransaction(_x2) {
|
|
310
331
|
return _submitTransaction.apply(this, arguments);
|
|
@@ -314,25 +335,25 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
314
335
|
}, {
|
|
315
336
|
key: "submitAsyncTransaction",
|
|
316
337
|
value: (function () {
|
|
317
|
-
var _submitAsyncTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
338
|
+
var _submitAsyncTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(transaction) {
|
|
318
339
|
var opts,
|
|
319
340
|
tx,
|
|
320
|
-
|
|
321
|
-
return _regeneratorRuntime().wrap(function
|
|
322
|
-
while (1) switch (
|
|
341
|
+
_args6 = arguments;
|
|
342
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
343
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
323
344
|
case 0:
|
|
324
|
-
opts =
|
|
345
|
+
opts = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {
|
|
325
346
|
skipMemoRequiredCheck: false
|
|
326
347
|
};
|
|
327
348
|
if (opts.skipMemoRequiredCheck) {
|
|
328
|
-
|
|
349
|
+
_context6.next = 4;
|
|
329
350
|
break;
|
|
330
351
|
}
|
|
331
|
-
|
|
352
|
+
_context6.next = 4;
|
|
332
353
|
return this.checkMemoRequired(transaction);
|
|
333
354
|
case 4:
|
|
334
355
|
tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
|
|
335
|
-
return
|
|
356
|
+
return _context6.abrupt("return", _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions_async").toString(), "tx=".concat(tx)).then(function (response) {
|
|
336
357
|
return response.data;
|
|
337
358
|
}).catch(function (response) {
|
|
338
359
|
if (response instanceof Error) {
|
|
@@ -342,9 +363,9 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
342
363
|
}));
|
|
343
364
|
case 6:
|
|
344
365
|
case "end":
|
|
345
|
-
return
|
|
366
|
+
return _context6.stop();
|
|
346
367
|
}
|
|
347
|
-
},
|
|
368
|
+
}, _callee6, this);
|
|
348
369
|
}));
|
|
349
370
|
function submitAsyncTransaction(_x3) {
|
|
350
371
|
return _submitAsyncTransaction.apply(this, arguments);
|
|
@@ -429,21 +450,21 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
429
450
|
}, {
|
|
430
451
|
key: "loadAccount",
|
|
431
452
|
value: (function () {
|
|
432
|
-
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
453
|
+
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7(accountId) {
|
|
433
454
|
var res;
|
|
434
|
-
return _regeneratorRuntime().wrap(function
|
|
435
|
-
while (1) switch (
|
|
455
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
456
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
436
457
|
case 0:
|
|
437
|
-
|
|
458
|
+
_context7.next = 2;
|
|
438
459
|
return this.accounts().accountId(accountId).call();
|
|
439
460
|
case 2:
|
|
440
|
-
res =
|
|
441
|
-
return
|
|
461
|
+
res = _context7.sent;
|
|
462
|
+
return _context7.abrupt("return", new _account_response.AccountResponse(res));
|
|
442
463
|
case 4:
|
|
443
464
|
case "end":
|
|
444
|
-
return
|
|
465
|
+
return _context7.stop();
|
|
445
466
|
}
|
|
446
|
-
},
|
|
467
|
+
}, _callee7, this);
|
|
447
468
|
}));
|
|
448
469
|
function loadAccount(_x4) {
|
|
449
470
|
return _loadAccount.apply(this, arguments);
|
|
@@ -458,88 +479,88 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
458
479
|
}, {
|
|
459
480
|
key: "checkMemoRequired",
|
|
460
481
|
value: (function () {
|
|
461
|
-
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
482
|
+
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(transaction) {
|
|
462
483
|
var destinations, i, operation, destination, account;
|
|
463
|
-
return _regeneratorRuntime().wrap(function
|
|
464
|
-
while (1) switch (
|
|
484
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
485
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
465
486
|
case 0:
|
|
466
487
|
if (transaction instanceof _stellarBase.FeeBumpTransaction) {
|
|
467
488
|
transaction = transaction.innerTransaction;
|
|
468
489
|
}
|
|
469
490
|
if (!(transaction.memo.type !== "none")) {
|
|
470
|
-
|
|
491
|
+
_context8.next = 3;
|
|
471
492
|
break;
|
|
472
493
|
}
|
|
473
|
-
return
|
|
494
|
+
return _context8.abrupt("return");
|
|
474
495
|
case 3:
|
|
475
496
|
destinations = new Set();
|
|
476
497
|
i = 0;
|
|
477
498
|
case 5:
|
|
478
499
|
if (!(i < transaction.operations.length)) {
|
|
479
|
-
|
|
500
|
+
_context8.next = 36;
|
|
480
501
|
break;
|
|
481
502
|
}
|
|
482
503
|
operation = transaction.operations[i];
|
|
483
|
-
|
|
484
|
-
|
|
504
|
+
_context8.t0 = operation.type;
|
|
505
|
+
_context8.next = _context8.t0 === "payment" ? 10 : _context8.t0 === "pathPaymentStrictReceive" ? 10 : _context8.t0 === "pathPaymentStrictSend" ? 10 : _context8.t0 === "accountMerge" ? 10 : 11;
|
|
485
506
|
break;
|
|
486
507
|
case 10:
|
|
487
|
-
return
|
|
508
|
+
return _context8.abrupt("break", 12);
|
|
488
509
|
case 11:
|
|
489
|
-
return
|
|
510
|
+
return _context8.abrupt("continue", 33);
|
|
490
511
|
case 12:
|
|
491
512
|
destination = operation.destination;
|
|
492
513
|
if (!destinations.has(destination)) {
|
|
493
|
-
|
|
514
|
+
_context8.next = 15;
|
|
494
515
|
break;
|
|
495
516
|
}
|
|
496
|
-
return
|
|
517
|
+
return _context8.abrupt("continue", 33);
|
|
497
518
|
case 15:
|
|
498
519
|
destinations.add(destination);
|
|
499
520
|
if (!destination.startsWith("M")) {
|
|
500
|
-
|
|
521
|
+
_context8.next = 18;
|
|
501
522
|
break;
|
|
502
523
|
}
|
|
503
|
-
return
|
|
524
|
+
return _context8.abrupt("continue", 33);
|
|
504
525
|
case 18:
|
|
505
|
-
|
|
506
|
-
|
|
526
|
+
_context8.prev = 18;
|
|
527
|
+
_context8.next = 21;
|
|
507
528
|
return this.loadAccount(destination);
|
|
508
529
|
case 21:
|
|
509
|
-
account =
|
|
530
|
+
account = _context8.sent;
|
|
510
531
|
if (!(account.data_attr["config.memo_required"] === ACCOUNT_REQUIRES_MEMO)) {
|
|
511
|
-
|
|
532
|
+
_context8.next = 24;
|
|
512
533
|
break;
|
|
513
534
|
}
|
|
514
535
|
throw new _errors.AccountRequiresMemoError("account requires memo", destination, i);
|
|
515
536
|
case 24:
|
|
516
|
-
|
|
537
|
+
_context8.next = 33;
|
|
517
538
|
break;
|
|
518
539
|
case 26:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (!(
|
|
522
|
-
|
|
540
|
+
_context8.prev = 26;
|
|
541
|
+
_context8.t1 = _context8["catch"](18);
|
|
542
|
+
if (!(_context8.t1 instanceof _errors.AccountRequiresMemoError)) {
|
|
543
|
+
_context8.next = 30;
|
|
523
544
|
break;
|
|
524
545
|
}
|
|
525
|
-
throw
|
|
546
|
+
throw _context8.t1;
|
|
526
547
|
case 30:
|
|
527
|
-
if (
|
|
528
|
-
|
|
548
|
+
if (_context8.t1 instanceof _errors.NotFoundError) {
|
|
549
|
+
_context8.next = 32;
|
|
529
550
|
break;
|
|
530
551
|
}
|
|
531
|
-
throw
|
|
552
|
+
throw _context8.t1;
|
|
532
553
|
case 32:
|
|
533
|
-
return
|
|
554
|
+
return _context8.abrupt("continue", 33);
|
|
534
555
|
case 33:
|
|
535
556
|
i += 1;
|
|
536
|
-
|
|
557
|
+
_context8.next = 5;
|
|
537
558
|
break;
|
|
538
559
|
case 36:
|
|
539
560
|
case "end":
|
|
540
|
-
return
|
|
561
|
+
return _context8.stop();
|
|
541
562
|
}
|
|
542
|
-
},
|
|
563
|
+
}, _callee8, this, [[18, 26]]);
|
|
543
564
|
}));
|
|
544
565
|
function checkMemoRequired(_x5) {
|
|
545
566
|
return _checkMemoRequired.apply(this, arguments);
|
|
@@ -13,7 +13,7 @@ export interface EventSourceOptions<T> {
|
|
|
13
13
|
* @param {string} serverUrl URL of Horizon server
|
|
14
14
|
* @class CallBuilder
|
|
15
15
|
*/
|
|
16
|
-
export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | HorizonApi.BaseResponse | ServerApi.CollectionPage<HorizonApi.BaseResponse>> {
|
|
16
|
+
export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | HorizonApi.BaseResponse | HorizonApi.RootResponse | ServerApi.CollectionPage<HorizonApi.BaseResponse>> {
|
|
17
17
|
protected url: URI;
|
|
18
18
|
filter: string[][];
|
|
19
19
|
protected originalSegments: string[];
|
|
@@ -524,4 +524,17 @@ export declare namespace HorizonApi {
|
|
|
524
524
|
};
|
|
525
525
|
result_xdr: string;
|
|
526
526
|
}
|
|
527
|
+
interface RootResponse {
|
|
528
|
+
horizon_version: string;
|
|
529
|
+
core_version: string;
|
|
530
|
+
ingest_latest_ledger: number;
|
|
531
|
+
history_latest_ledger: number;
|
|
532
|
+
history_latest_ledger_closed_at: string;
|
|
533
|
+
history_elder_ledger: number;
|
|
534
|
+
core_latest_ledger: number;
|
|
535
|
+
network_passphrase: string;
|
|
536
|
+
current_protocol_version: number;
|
|
537
|
+
supported_protocol_version: number;
|
|
538
|
+
core_supported_protocol_version: number;
|
|
539
|
+
}
|
|
527
540
|
}
|
|
@@ -10,7 +10,7 @@ var _urijs = _interopRequireDefault(require("urijs"));
|
|
|
10
10
|
var _httpClient = require("../http-client");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
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); }
|
|
13
|
-
var version = exports.version = "13.
|
|
13
|
+
var version = exports.version = "13.1.0";
|
|
14
14
|
var SERVER_TIME_MAP = exports.SERVER_TIME_MAP = {};
|
|
15
15
|
var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
|
|
16
16
|
headers: {
|
|
@@ -84,6 +84,11 @@ export declare class HorizonServer {
|
|
|
84
84
|
* @returns {Promise<HorizonApi.FeeStatsResponse>} Promise that resolves to the fee stats returned by Horizon.
|
|
85
85
|
*/
|
|
86
86
|
feeStats(): Promise<HorizonApi.FeeStatsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the Horizon server's root endpoint.
|
|
89
|
+
* @returns {Promise<HorizonApi.RootResponse>} Promise that resolves to the root endpoint returned by Horizon.
|
|
90
|
+
*/
|
|
91
|
+
root(): Promise<HorizonApi.RootResponse>;
|
|
87
92
|
/**
|
|
88
93
|
* Submits a transaction to the network.
|
|
89
94
|
*
|
|
@@ -170,28 +170,49 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
170
170
|
}
|
|
171
171
|
return feeStats;
|
|
172
172
|
}())
|
|
173
|
+
}, {
|
|
174
|
+
key: "root",
|
|
175
|
+
value: (function () {
|
|
176
|
+
var _root = _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
|
|
177
|
+
var cb;
|
|
178
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
179
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
cb = new _call_builder.CallBuilder((0, _urijs.default)(this.serverURL));
|
|
182
|
+
return _context4.abrupt("return", cb.call());
|
|
183
|
+
case 2:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context4.stop();
|
|
186
|
+
}
|
|
187
|
+
}, _callee4, this);
|
|
188
|
+
}));
|
|
189
|
+
function root() {
|
|
190
|
+
return _root.apply(this, arguments);
|
|
191
|
+
}
|
|
192
|
+
return root;
|
|
193
|
+
}())
|
|
173
194
|
}, {
|
|
174
195
|
key: "submitTransaction",
|
|
175
196
|
value: (function () {
|
|
176
|
-
var _submitTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
197
|
+
var _submitTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(transaction) {
|
|
177
198
|
var opts,
|
|
178
199
|
tx,
|
|
179
|
-
|
|
180
|
-
return _regeneratorRuntime().wrap(function
|
|
181
|
-
while (1) switch (
|
|
200
|
+
_args5 = arguments;
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
202
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
182
203
|
case 0:
|
|
183
|
-
opts =
|
|
204
|
+
opts = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {
|
|
184
205
|
skipMemoRequiredCheck: false
|
|
185
206
|
};
|
|
186
207
|
if (opts.skipMemoRequiredCheck) {
|
|
187
|
-
|
|
208
|
+
_context5.next = 4;
|
|
188
209
|
break;
|
|
189
210
|
}
|
|
190
|
-
|
|
211
|
+
_context5.next = 4;
|
|
191
212
|
return this.checkMemoRequired(transaction);
|
|
192
213
|
case 4:
|
|
193
214
|
tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
|
|
194
|
-
return
|
|
215
|
+
return _context5.abrupt("return", _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions").toString(), "tx=".concat(tx), {
|
|
195
216
|
timeout: SUBMIT_TRANSACTION_TIMEOUT
|
|
196
217
|
}).then(function (response) {
|
|
197
218
|
if (!response.data.result_xdr) {
|
|
@@ -302,9 +323,9 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
302
323
|
}));
|
|
303
324
|
case 6:
|
|
304
325
|
case "end":
|
|
305
|
-
return
|
|
326
|
+
return _context5.stop();
|
|
306
327
|
}
|
|
307
|
-
},
|
|
328
|
+
}, _callee5, this);
|
|
308
329
|
}));
|
|
309
330
|
function submitTransaction(_x2) {
|
|
310
331
|
return _submitTransaction.apply(this, arguments);
|
|
@@ -314,25 +335,25 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
314
335
|
}, {
|
|
315
336
|
key: "submitAsyncTransaction",
|
|
316
337
|
value: (function () {
|
|
317
|
-
var _submitAsyncTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
338
|
+
var _submitAsyncTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(transaction) {
|
|
318
339
|
var opts,
|
|
319
340
|
tx,
|
|
320
|
-
|
|
321
|
-
return _regeneratorRuntime().wrap(function
|
|
322
|
-
while (1) switch (
|
|
341
|
+
_args6 = arguments;
|
|
342
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
343
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
323
344
|
case 0:
|
|
324
|
-
opts =
|
|
345
|
+
opts = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {
|
|
325
346
|
skipMemoRequiredCheck: false
|
|
326
347
|
};
|
|
327
348
|
if (opts.skipMemoRequiredCheck) {
|
|
328
|
-
|
|
349
|
+
_context6.next = 4;
|
|
329
350
|
break;
|
|
330
351
|
}
|
|
331
|
-
|
|
352
|
+
_context6.next = 4;
|
|
332
353
|
return this.checkMemoRequired(transaction);
|
|
333
354
|
case 4:
|
|
334
355
|
tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
|
|
335
|
-
return
|
|
356
|
+
return _context6.abrupt("return", _horizon_axios_client.default.post((0, _urijs.default)(this.serverURL).segment("transactions_async").toString(), "tx=".concat(tx)).then(function (response) {
|
|
336
357
|
return response.data;
|
|
337
358
|
}).catch(function (response) {
|
|
338
359
|
if (response instanceof Error) {
|
|
@@ -342,9 +363,9 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
342
363
|
}));
|
|
343
364
|
case 6:
|
|
344
365
|
case "end":
|
|
345
|
-
return
|
|
366
|
+
return _context6.stop();
|
|
346
367
|
}
|
|
347
|
-
},
|
|
368
|
+
}, _callee6, this);
|
|
348
369
|
}));
|
|
349
370
|
function submitAsyncTransaction(_x3) {
|
|
350
371
|
return _submitAsyncTransaction.apply(this, arguments);
|
|
@@ -429,21 +450,21 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
429
450
|
}, {
|
|
430
451
|
key: "loadAccount",
|
|
431
452
|
value: (function () {
|
|
432
|
-
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
453
|
+
var _loadAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7(accountId) {
|
|
433
454
|
var res;
|
|
434
|
-
return _regeneratorRuntime().wrap(function
|
|
435
|
-
while (1) switch (
|
|
455
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
456
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
436
457
|
case 0:
|
|
437
|
-
|
|
458
|
+
_context7.next = 2;
|
|
438
459
|
return this.accounts().accountId(accountId).call();
|
|
439
460
|
case 2:
|
|
440
|
-
res =
|
|
441
|
-
return
|
|
461
|
+
res = _context7.sent;
|
|
462
|
+
return _context7.abrupt("return", new _account_response.AccountResponse(res));
|
|
442
463
|
case 4:
|
|
443
464
|
case "end":
|
|
444
|
-
return
|
|
465
|
+
return _context7.stop();
|
|
445
466
|
}
|
|
446
|
-
},
|
|
467
|
+
}, _callee7, this);
|
|
447
468
|
}));
|
|
448
469
|
function loadAccount(_x4) {
|
|
449
470
|
return _loadAccount.apply(this, arguments);
|
|
@@ -458,88 +479,88 @@ var HorizonServer = exports.HorizonServer = function () {
|
|
|
458
479
|
}, {
|
|
459
480
|
key: "checkMemoRequired",
|
|
460
481
|
value: (function () {
|
|
461
|
-
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
482
|
+
var _checkMemoRequired = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(transaction) {
|
|
462
483
|
var destinations, i, operation, destination, account;
|
|
463
|
-
return _regeneratorRuntime().wrap(function
|
|
464
|
-
while (1) switch (
|
|
484
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
485
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
465
486
|
case 0:
|
|
466
487
|
if (transaction instanceof _stellarBase.FeeBumpTransaction) {
|
|
467
488
|
transaction = transaction.innerTransaction;
|
|
468
489
|
}
|
|
469
490
|
if (!(transaction.memo.type !== "none")) {
|
|
470
|
-
|
|
491
|
+
_context8.next = 3;
|
|
471
492
|
break;
|
|
472
493
|
}
|
|
473
|
-
return
|
|
494
|
+
return _context8.abrupt("return");
|
|
474
495
|
case 3:
|
|
475
496
|
destinations = new Set();
|
|
476
497
|
i = 0;
|
|
477
498
|
case 5:
|
|
478
499
|
if (!(i < transaction.operations.length)) {
|
|
479
|
-
|
|
500
|
+
_context8.next = 36;
|
|
480
501
|
break;
|
|
481
502
|
}
|
|
482
503
|
operation = transaction.operations[i];
|
|
483
|
-
|
|
484
|
-
|
|
504
|
+
_context8.t0 = operation.type;
|
|
505
|
+
_context8.next = _context8.t0 === "payment" ? 10 : _context8.t0 === "pathPaymentStrictReceive" ? 10 : _context8.t0 === "pathPaymentStrictSend" ? 10 : _context8.t0 === "accountMerge" ? 10 : 11;
|
|
485
506
|
break;
|
|
486
507
|
case 10:
|
|
487
|
-
return
|
|
508
|
+
return _context8.abrupt("break", 12);
|
|
488
509
|
case 11:
|
|
489
|
-
return
|
|
510
|
+
return _context8.abrupt("continue", 33);
|
|
490
511
|
case 12:
|
|
491
512
|
destination = operation.destination;
|
|
492
513
|
if (!destinations.has(destination)) {
|
|
493
|
-
|
|
514
|
+
_context8.next = 15;
|
|
494
515
|
break;
|
|
495
516
|
}
|
|
496
|
-
return
|
|
517
|
+
return _context8.abrupt("continue", 33);
|
|
497
518
|
case 15:
|
|
498
519
|
destinations.add(destination);
|
|
499
520
|
if (!destination.startsWith("M")) {
|
|
500
|
-
|
|
521
|
+
_context8.next = 18;
|
|
501
522
|
break;
|
|
502
523
|
}
|
|
503
|
-
return
|
|
524
|
+
return _context8.abrupt("continue", 33);
|
|
504
525
|
case 18:
|
|
505
|
-
|
|
506
|
-
|
|
526
|
+
_context8.prev = 18;
|
|
527
|
+
_context8.next = 21;
|
|
507
528
|
return this.loadAccount(destination);
|
|
508
529
|
case 21:
|
|
509
|
-
account =
|
|
530
|
+
account = _context8.sent;
|
|
510
531
|
if (!(account.data_attr["config.memo_required"] === ACCOUNT_REQUIRES_MEMO)) {
|
|
511
|
-
|
|
532
|
+
_context8.next = 24;
|
|
512
533
|
break;
|
|
513
534
|
}
|
|
514
535
|
throw new _errors.AccountRequiresMemoError("account requires memo", destination, i);
|
|
515
536
|
case 24:
|
|
516
|
-
|
|
537
|
+
_context8.next = 33;
|
|
517
538
|
break;
|
|
518
539
|
case 26:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (!(
|
|
522
|
-
|
|
540
|
+
_context8.prev = 26;
|
|
541
|
+
_context8.t1 = _context8["catch"](18);
|
|
542
|
+
if (!(_context8.t1 instanceof _errors.AccountRequiresMemoError)) {
|
|
543
|
+
_context8.next = 30;
|
|
523
544
|
break;
|
|
524
545
|
}
|
|
525
|
-
throw
|
|
546
|
+
throw _context8.t1;
|
|
526
547
|
case 30:
|
|
527
|
-
if (
|
|
528
|
-
|
|
548
|
+
if (_context8.t1 instanceof _errors.NotFoundError) {
|
|
549
|
+
_context8.next = 32;
|
|
529
550
|
break;
|
|
530
551
|
}
|
|
531
|
-
throw
|
|
552
|
+
throw _context8.t1;
|
|
532
553
|
case 32:
|
|
533
|
-
return
|
|
554
|
+
return _context8.abrupt("continue", 33);
|
|
534
555
|
case 33:
|
|
535
556
|
i += 1;
|
|
536
|
-
|
|
557
|
+
_context8.next = 5;
|
|
537
558
|
break;
|
|
538
559
|
case 36:
|
|
539
560
|
case "end":
|
|
540
|
-
return
|
|
561
|
+
return _context8.stop();
|
|
541
562
|
}
|
|
542
|
-
},
|
|
563
|
+
}, _callee8, this, [[18, 26]]);
|
|
543
564
|
}));
|
|
544
565
|
function checkMemoRequired(_x5) {
|
|
545
566
|
return _checkMemoRequired.apply(this, arguments);
|