rango-sdk-basic 0.1.51 → 0.1.53
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/README.md +4 -4
- package/lib/rango-sdk-basic.cjs.development.js +104 -378
- package/lib/rango-sdk-basic.cjs.development.js.map +1 -1
- package/lib/rango-sdk-basic.cjs.production.min.js +1 -1
- package/lib/rango-sdk-basic.cjs.production.min.js.map +1 -1
- package/lib/rango-sdk-basic.esm.js +105 -378
- package/lib/rango-sdk-basic.esm.js.map +1 -1
- package/lib/services/client.d.ts +3 -2
- package/lib/services/client.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/services/client.ts +25 -24
- package/src/types/index.ts +0 -1
- package/lib/services/executor.d.ts +0 -8
- package/lib/services/executor.d.ts.map +0 -1
- package/lib/types/utils/errors.d.ts +0 -23
- package/lib/types/utils/errors.d.ts.map +0 -1
- package/lib/utils/errors.d.ts +0 -2
- package/lib/utils/errors.d.ts.map +0 -1
- package/lib/utils/promise.d.ts +0 -2
- package/lib/utils/promise.d.ts.map +0 -1
- package/src/services/executor.ts +0 -140
- package/src/types/utils/errors.ts +0 -22
- package/src/utils/errors.ts +0 -29
- package/src/utils/promise.ts +0 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Rango Exchange SDK
|
|
2
2
|
|
|
3
|
-
- [Basic-SDK Integration Tutorial](https://docs.rango.exchange/integration-
|
|
4
|
-
- [Basic-SDK Reference](https://docs.rango.exchange/api-integration/
|
|
3
|
+
- [Basic-SDK Integration Tutorial](https://docs.rango.exchange/api-integration/basic-api-single-step/tutorial/sdk-example)
|
|
4
|
+
- [Basic-SDK Reference](https://docs.rango.exchange/api-integration/basic-api-single-step/api-reference)
|
|
5
5
|
|
|
6
6
|
## Basic SDK (Single Step Tx)
|
|
7
7
|
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
|
|
21
21
|
Please checkout the examples' folder for sample usage of the SDK. We will add more examples there soon.
|
|
22
22
|
|
|
23
|
-
- [Documents](https://docs.rango.exchange/integration/
|
|
24
|
-
- [Examples](https://github.com/rango-exchange/rango-sdk/tree/master/examples/basic
|
|
23
|
+
- [Documents](https://docs.rango.exchange/api-integration/basic-api-single-step/tutorial/sdk-example)
|
|
24
|
+
- [Examples](https://github.com/rango-exchange/rango-sdk/tree/master/examples/basic)
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var uuid = _interopDefault(require('uuid-random'));
|
|
8
|
-
var ethRpcErrors = require('eth-rpc-errors');
|
|
9
8
|
var axios = _interopDefault(require('axios'));
|
|
10
9
|
|
|
11
10
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
@@ -400,6 +399,7 @@ var tonBlockchain = function tonBlockchain(blockchains) {
|
|
|
400
399
|
RoutingResultType["HIGH_IMPACT"] = "HIGH_IMPACT";
|
|
401
400
|
RoutingResultType["NO_ROUTE"] = "NO_ROUTE";
|
|
402
401
|
RoutingResultType["INPUT_LIMIT_ISSUE"] = "INPUT_LIMIT_ISSUE";
|
|
402
|
+
RoutingResultType["HIGH_IMPACT_FOR_CREATE_TX"] = "HIGH_IMPACT_FOR_CREATE_TX";
|
|
403
403
|
})(exports.RoutingResultType || (exports.RoutingResultType = {}));
|
|
404
404
|
|
|
405
405
|
/**
|
|
@@ -448,286 +448,6 @@ var isEvmTransaction = function isEvmTransaction(transaction) {
|
|
|
448
448
|
return transaction.type === exports.TransactionType.EVM;
|
|
449
449
|
};
|
|
450
450
|
|
|
451
|
-
var MetamaskErrorCodes = {
|
|
452
|
-
rpc: {
|
|
453
|
-
invalidInput: -32000,
|
|
454
|
-
resourceNotFound: -32001,
|
|
455
|
-
resourceUnavailable: -32002,
|
|
456
|
-
transactionRejected: -32003,
|
|
457
|
-
methodNotSupported: -32004,
|
|
458
|
-
limitExceeded: -32005,
|
|
459
|
-
parse: -32700,
|
|
460
|
-
invalidRequest: -32600,
|
|
461
|
-
methodNotFound: -32601,
|
|
462
|
-
invalidParams: -32602,
|
|
463
|
-
internal: -32603
|
|
464
|
-
},
|
|
465
|
-
provider: {
|
|
466
|
-
userRejectedRequest: 4001,
|
|
467
|
-
unauthorized: 4100,
|
|
468
|
-
unsupportedMethod: 4200,
|
|
469
|
-
disconnected: 4900,
|
|
470
|
-
chainDisconnected: 4901
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
function sleep(ms) {
|
|
475
|
-
return new Promise(function (resolve) {
|
|
476
|
-
return setTimeout(resolve, ms);
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
function prepareEvmTransaction(evmTx, isApprove) {
|
|
481
|
-
var gasPrice = !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x') ? '0x' + parseInt(evmTx.gasPrice).toString(16) : null;
|
|
482
|
-
var manipulatedTx = _extends({}, evmTx, {
|
|
483
|
-
gasPrice: gasPrice
|
|
484
|
-
});
|
|
485
|
-
var tx = {};
|
|
486
|
-
if (!!manipulatedTx.from) tx = _extends({}, tx, {
|
|
487
|
-
from: manipulatedTx.from
|
|
488
|
-
});
|
|
489
|
-
if (isApprove) {
|
|
490
|
-
if (!!manipulatedTx.approveTo) tx = _extends({}, tx, {
|
|
491
|
-
to: manipulatedTx.approveTo
|
|
492
|
-
});
|
|
493
|
-
if (!!manipulatedTx.approveData) tx = _extends({}, tx, {
|
|
494
|
-
data: manipulatedTx.approveData
|
|
495
|
-
});
|
|
496
|
-
} else {
|
|
497
|
-
if (!!manipulatedTx.txTo) tx = _extends({}, tx, {
|
|
498
|
-
to: manipulatedTx.txTo
|
|
499
|
-
});
|
|
500
|
-
if (!!manipulatedTx.txData) tx = _extends({}, tx, {
|
|
501
|
-
data: manipulatedTx.txData
|
|
502
|
-
});
|
|
503
|
-
if (!!manipulatedTx.value) tx = _extends({}, tx, {
|
|
504
|
-
value: manipulatedTx.value
|
|
505
|
-
});
|
|
506
|
-
if (!!manipulatedTx.gasLimit) tx = _extends({}, tx, {
|
|
507
|
-
gasLimit: manipulatedTx.gasLimit
|
|
508
|
-
});
|
|
509
|
-
if (!!manipulatedTx.gasPrice) tx = _extends({}, tx, {
|
|
510
|
-
gasPrice: manipulatedTx.gasPrice
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
return tx;
|
|
514
|
-
}
|
|
515
|
-
function checkApprovalSync(_x, _x2, _x3) {
|
|
516
|
-
return _checkApprovalSync.apply(this, arguments);
|
|
517
|
-
}
|
|
518
|
-
function _checkApprovalSync() {
|
|
519
|
-
_checkApprovalSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(requestId, txId, rangoClient) {
|
|
520
|
-
var approvalResponse;
|
|
521
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
522
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
523
|
-
case 0:
|
|
524
|
-
_context3.prev = 1;
|
|
525
|
-
_context3.next = 4;
|
|
526
|
-
return rangoClient.isApproved(requestId, txId);
|
|
527
|
-
case 4:
|
|
528
|
-
approvalResponse = _context3.sent;
|
|
529
|
-
if (!(approvalResponse != null && approvalResponse.isApproved)) {
|
|
530
|
-
_context3.next = 7;
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
return _context3.abrupt("return", true);
|
|
534
|
-
case 7:
|
|
535
|
-
if (!(!(approvalResponse != null && approvalResponse.isApproved) && (approvalResponse == null ? void 0 : approvalResponse.txStatus) === exports.TransactionStatus.FAILED)) {
|
|
536
|
-
_context3.next = 9;
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
return _context3.abrupt("return", false);
|
|
540
|
-
case 9:
|
|
541
|
-
_context3.next = 14;
|
|
542
|
-
break;
|
|
543
|
-
case 11:
|
|
544
|
-
_context3.prev = 11;
|
|
545
|
-
_context3.t0 = _context3["catch"](1);
|
|
546
|
-
console.log('ignorinig error', {
|
|
547
|
-
err: _context3.t0
|
|
548
|
-
});
|
|
549
|
-
case 14:
|
|
550
|
-
_context3.next = 16;
|
|
551
|
-
return sleep(3000);
|
|
552
|
-
case 16:
|
|
553
|
-
_context3.next = 0;
|
|
554
|
-
break;
|
|
555
|
-
case 18:
|
|
556
|
-
case "end":
|
|
557
|
-
return _context3.stop();
|
|
558
|
-
}
|
|
559
|
-
}, _callee3, null, [[1, 11]]);
|
|
560
|
-
}));
|
|
561
|
-
return _checkApprovalSync.apply(this, arguments);
|
|
562
|
-
}
|
|
563
|
-
var checkTransactionStatusSync = /*#__PURE__*/function () {
|
|
564
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestId, txId, rangoClient) {
|
|
565
|
-
var txStatus;
|
|
566
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
567
|
-
while (1) switch (_context.prev = _context.next) {
|
|
568
|
-
case 0:
|
|
569
|
-
_context.prev = 1;
|
|
570
|
-
_context.next = 4;
|
|
571
|
-
return rangoClient.status({
|
|
572
|
-
requestId: requestId,
|
|
573
|
-
txId: txId
|
|
574
|
-
});
|
|
575
|
-
case 4:
|
|
576
|
-
txStatus = _context.sent;
|
|
577
|
-
_context.next = 10;
|
|
578
|
-
break;
|
|
579
|
-
case 7:
|
|
580
|
-
_context.prev = 7;
|
|
581
|
-
_context.t0 = _context["catch"](1);
|
|
582
|
-
console.log('ignorinig error', {
|
|
583
|
-
err: _context.t0
|
|
584
|
-
});
|
|
585
|
-
case 10:
|
|
586
|
-
if (!txStatus) {
|
|
587
|
-
_context.next = 13;
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
if (!(!!txStatus.status && [exports.TransactionStatus.FAILED, exports.TransactionStatus.SUCCESS].includes(txStatus.status))) {
|
|
591
|
-
_context.next = 13;
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
594
|
-
return _context.abrupt("return", txStatus);
|
|
595
|
-
case 13:
|
|
596
|
-
_context.next = 15;
|
|
597
|
-
return sleep(3000);
|
|
598
|
-
case 15:
|
|
599
|
-
_context.next = 0;
|
|
600
|
-
break;
|
|
601
|
-
case 17:
|
|
602
|
-
case "end":
|
|
603
|
-
return _context.stop();
|
|
604
|
-
}
|
|
605
|
-
}, _callee, null, [[1, 7]]);
|
|
606
|
-
}));
|
|
607
|
-
return function checkTransactionStatusSync(_x4, _x5, _x6) {
|
|
608
|
-
return _ref.apply(this, arguments);
|
|
609
|
-
};
|
|
610
|
-
}();
|
|
611
|
-
var executeEvmRoute = /*#__PURE__*/function () {
|
|
612
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, signer, route) {
|
|
613
|
-
var tx, requestId, error, resultType, evmTransaction, txChainId, signerChainId, approveTxData, approveTx, isApproved, mainTxData, mainTx, status;
|
|
614
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
615
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
616
|
-
case 0:
|
|
617
|
-
tx = route.tx, requestId = route.requestId, error = route.error, resultType = route.resultType;
|
|
618
|
-
if (!(resultType != 'OK')) {
|
|
619
|
-
_context2.next = 3;
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
throw new Error(resultType);
|
|
623
|
-
case 3:
|
|
624
|
-
if (!(!!error || !tx)) {
|
|
625
|
-
_context2.next = 5;
|
|
626
|
-
break;
|
|
627
|
-
}
|
|
628
|
-
throw new Error(error || 'Error creating the transaction.');
|
|
629
|
-
case 5:
|
|
630
|
-
if (!((tx == null ? void 0 : tx.type) !== exports.TransactionType.EVM)) {
|
|
631
|
-
_context2.next = 7;
|
|
632
|
-
break;
|
|
633
|
-
}
|
|
634
|
-
throw new Error('Non Evm transactions are not supported yet.');
|
|
635
|
-
case 7:
|
|
636
|
-
evmTransaction = tx;
|
|
637
|
-
if (evmTransaction) {
|
|
638
|
-
_context2.next = 10;
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
throw new Error('Transaction is null. Please try again!');
|
|
642
|
-
case 10:
|
|
643
|
-
txChainId = parseInt(evmTransaction.blockChain.chainId || '-1');
|
|
644
|
-
_context2.next = 13;
|
|
645
|
-
return signer.getChainId();
|
|
646
|
-
case 13:
|
|
647
|
-
signerChainId = _context2.sent;
|
|
648
|
-
if (!(signerChainId !== txChainId)) {
|
|
649
|
-
_context2.next = 16;
|
|
650
|
-
break;
|
|
651
|
-
}
|
|
652
|
-
throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
|
|
653
|
-
case 16:
|
|
654
|
-
if (!(!!evmTransaction.approveTo && !!evmTransaction.approveData)) {
|
|
655
|
-
_context2.next = 27;
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
approveTxData = prepareEvmTransaction(evmTransaction, true);
|
|
659
|
-
_context2.next = 20;
|
|
660
|
-
return signer.sendTransaction(approveTxData);
|
|
661
|
-
case 20:
|
|
662
|
-
approveTx = _context2.sent;
|
|
663
|
-
approveTx.wait();
|
|
664
|
-
_context2.next = 24;
|
|
665
|
-
return checkApprovalSync(requestId, approveTx.hash, client);
|
|
666
|
-
case 24:
|
|
667
|
-
isApproved = _context2.sent;
|
|
668
|
-
if (isApproved) {
|
|
669
|
-
_context2.next = 27;
|
|
670
|
-
break;
|
|
671
|
-
}
|
|
672
|
-
throw new Error('Error in approve transaction.');
|
|
673
|
-
case 27:
|
|
674
|
-
_context2.next = 29;
|
|
675
|
-
return signer.getChainId();
|
|
676
|
-
case 29:
|
|
677
|
-
signerChainId = _context2.sent;
|
|
678
|
-
if (!(signerChainId !== txChainId)) {
|
|
679
|
-
_context2.next = 32;
|
|
680
|
-
break;
|
|
681
|
-
}
|
|
682
|
-
throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
|
|
683
|
-
case 32:
|
|
684
|
-
mainTxData = prepareEvmTransaction(evmTransaction, false);
|
|
685
|
-
_context2.next = 35;
|
|
686
|
-
return signer.sendTransaction(mainTxData);
|
|
687
|
-
case 35:
|
|
688
|
-
mainTx = _context2.sent;
|
|
689
|
-
mainTx.wait();
|
|
690
|
-
_context2.next = 39;
|
|
691
|
-
return checkTransactionStatusSync(requestId, mainTx.hash, client);
|
|
692
|
-
case 39:
|
|
693
|
-
status = _context2.sent;
|
|
694
|
-
if (!(status.status !== exports.TransactionStatus.SUCCESS)) {
|
|
695
|
-
_context2.next = 42;
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
throw new Error("Cross-chain swap failed. " + (status.error || ''));
|
|
699
|
-
case 42:
|
|
700
|
-
return _context2.abrupt("return", status);
|
|
701
|
-
case 43:
|
|
702
|
-
case "end":
|
|
703
|
-
return _context2.stop();
|
|
704
|
-
}
|
|
705
|
-
}, _callee2);
|
|
706
|
-
}));
|
|
707
|
-
return function executeEvmRoute(_x7, _x8, _x9) {
|
|
708
|
-
return _ref2.apply(this, arguments);
|
|
709
|
-
};
|
|
710
|
-
}();
|
|
711
|
-
|
|
712
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
713
|
-
var prettifyError = function prettifyError(error) {
|
|
714
|
-
if (!error) return error;
|
|
715
|
-
if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001)) return new Error('Transaction Rejected');
|
|
716
|
-
if (error && typeof error.code === 'number') {
|
|
717
|
-
if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {
|
|
718
|
-
return new Error(ethRpcErrors.getMessageFromCode(error.code));
|
|
719
|
-
}
|
|
720
|
-
if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {
|
|
721
|
-
var _error$message, _error$message2, _error$message3;
|
|
722
|
-
if (error.code === MetamaskErrorCodes.rpc.internal && (_error$message = error.message) != null && _error$message.includes('underpriced')) return new Error('Transaction underpriced');
|
|
723
|
-
if ((_error$message2 = error.message) != null && _error$message2.includes('intrinsic gas too low') || (_error$message3 = error.message) != null && _error$message3.includes('out of gas')) return new Error('This Gas limit is low.');
|
|
724
|
-
return new Error(ethRpcErrors.getMessageFromCode(error.code));
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
if (error.message) return new Error(error.message);
|
|
728
|
-
return error;
|
|
729
|
-
};
|
|
730
|
-
|
|
731
451
|
var RangoClient = /*#__PURE__*/function () {
|
|
732
452
|
function RangoClient(apiKey, debug, apiUrl) {
|
|
733
453
|
if (debug === void 0) {
|
|
@@ -863,11 +583,35 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
863
583
|
}
|
|
864
584
|
return messagingProtocols;
|
|
865
585
|
}();
|
|
866
|
-
_proto.
|
|
867
|
-
var
|
|
868
|
-
var
|
|
586
|
+
_proto.token = /*#__PURE__*/function () {
|
|
587
|
+
var _token = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(customTokenRequest, options) {
|
|
588
|
+
var axiosResponse;
|
|
869
589
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
870
590
|
while (1) switch (_context5.prev = _context5.next) {
|
|
591
|
+
case 0:
|
|
592
|
+
_context5.next = 2;
|
|
593
|
+
return this.httpService.get("/basic/meta/custom-token?apiKey=" + this.apiKey, _extends({
|
|
594
|
+
params: customTokenRequest
|
|
595
|
+
}, options));
|
|
596
|
+
case 2:
|
|
597
|
+
axiosResponse = _context5.sent;
|
|
598
|
+
return _context5.abrupt("return", axiosResponse.data);
|
|
599
|
+
case 4:
|
|
600
|
+
case "end":
|
|
601
|
+
return _context5.stop();
|
|
602
|
+
}
|
|
603
|
+
}, _callee5, this);
|
|
604
|
+
}));
|
|
605
|
+
function token(_x6, _x7) {
|
|
606
|
+
return _token.apply(this, arguments);
|
|
607
|
+
}
|
|
608
|
+
return token;
|
|
609
|
+
}();
|
|
610
|
+
_proto.quote = /*#__PURE__*/function () {
|
|
611
|
+
var _quote = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(quoteRequest, options) {
|
|
612
|
+
var body, axiosResponse;
|
|
613
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
614
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
871
615
|
case 0:
|
|
872
616
|
body = _extends({}, quoteRequest, {
|
|
873
617
|
from: assetToString(quoteRequest.from),
|
|
@@ -876,7 +620,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
876
620
|
swapperGroups: !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0 ? quoteRequest.swapperGroups.join(',') : undefined,
|
|
877
621
|
messagingProtocols: !!quoteRequest.messagingProtocols && quoteRequest.messagingProtocols.length > 0 ? quoteRequest.messagingProtocols.join(',') : undefined
|
|
878
622
|
});
|
|
879
|
-
|
|
623
|
+
_context6.next = 3;
|
|
880
624
|
return this.httpService.get("/basic/quote?apiKey=" + this.apiKey, _extends({
|
|
881
625
|
params: body,
|
|
882
626
|
headers: {
|
|
@@ -884,26 +628,26 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
884
628
|
}
|
|
885
629
|
}, options));
|
|
886
630
|
case 3:
|
|
887
|
-
axiosResponse =
|
|
888
|
-
return
|
|
631
|
+
axiosResponse = _context6.sent;
|
|
632
|
+
return _context6.abrupt("return", axiosResponse.data);
|
|
889
633
|
case 5:
|
|
890
634
|
case "end":
|
|
891
|
-
return
|
|
635
|
+
return _context6.stop();
|
|
892
636
|
}
|
|
893
|
-
},
|
|
637
|
+
}, _callee6, this);
|
|
894
638
|
}));
|
|
895
|
-
function quote(
|
|
639
|
+
function quote(_x8, _x9) {
|
|
896
640
|
return _quote.apply(this, arguments);
|
|
897
641
|
}
|
|
898
642
|
return quote;
|
|
899
643
|
}();
|
|
900
644
|
_proto.isApproved = /*#__PURE__*/function () {
|
|
901
|
-
var _isApproved = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
645
|
+
var _isApproved = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(requestId, txId, options) {
|
|
902
646
|
var axiosResponse;
|
|
903
|
-
return _regeneratorRuntime().wrap(function
|
|
904
|
-
while (1) switch (
|
|
647
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
648
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
905
649
|
case 0:
|
|
906
|
-
|
|
650
|
+
_context7.next = 2;
|
|
907
651
|
return this.httpService.get("/basic/is-approved?apiKey=" + this.apiKey, _extends({
|
|
908
652
|
params: {
|
|
909
653
|
requestId: requestId,
|
|
@@ -914,26 +658,26 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
914
658
|
}
|
|
915
659
|
}, options));
|
|
916
660
|
case 2:
|
|
917
|
-
axiosResponse =
|
|
918
|
-
return
|
|
661
|
+
axiosResponse = _context7.sent;
|
|
662
|
+
return _context7.abrupt("return", axiosResponse.data);
|
|
919
663
|
case 4:
|
|
920
664
|
case "end":
|
|
921
|
-
return
|
|
665
|
+
return _context7.stop();
|
|
922
666
|
}
|
|
923
|
-
},
|
|
667
|
+
}, _callee7, this);
|
|
924
668
|
}));
|
|
925
|
-
function isApproved(
|
|
669
|
+
function isApproved(_x10, _x11, _x12) {
|
|
926
670
|
return _isApproved.apply(this, arguments);
|
|
927
671
|
}
|
|
928
672
|
return isApproved;
|
|
929
673
|
}();
|
|
930
674
|
_proto.status = /*#__PURE__*/function () {
|
|
931
|
-
var _status = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
675
|
+
var _status = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(statusRequest, options) {
|
|
932
676
|
var axiosResponse;
|
|
933
|
-
return _regeneratorRuntime().wrap(function
|
|
934
|
-
while (1) switch (
|
|
677
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
678
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
935
679
|
case 0:
|
|
936
|
-
|
|
680
|
+
_context8.next = 2;
|
|
937
681
|
return this.httpService.get("/basic/status?apiKey=" + this.apiKey, _extends({
|
|
938
682
|
params: statusRequest,
|
|
939
683
|
headers: {
|
|
@@ -941,24 +685,24 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
941
685
|
}
|
|
942
686
|
}, options));
|
|
943
687
|
case 2:
|
|
944
|
-
axiosResponse =
|
|
945
|
-
return
|
|
688
|
+
axiosResponse = _context8.sent;
|
|
689
|
+
return _context8.abrupt("return", axiosResponse.data);
|
|
946
690
|
case 4:
|
|
947
691
|
case "end":
|
|
948
|
-
return
|
|
692
|
+
return _context8.stop();
|
|
949
693
|
}
|
|
950
|
-
},
|
|
694
|
+
}, _callee8, this);
|
|
951
695
|
}));
|
|
952
|
-
function status(
|
|
696
|
+
function status(_x13, _x14) {
|
|
953
697
|
return _status.apply(this, arguments);
|
|
954
698
|
}
|
|
955
699
|
return status;
|
|
956
700
|
}();
|
|
957
701
|
_proto.swap = /*#__PURE__*/function () {
|
|
958
|
-
var _swap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
702
|
+
var _swap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(swapRequest, options) {
|
|
959
703
|
var body, axiosResponse;
|
|
960
|
-
return _regeneratorRuntime().wrap(function
|
|
961
|
-
while (1) switch (
|
|
704
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
705
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
962
706
|
case 0:
|
|
963
707
|
body = _extends({}, swapRequest, {
|
|
964
708
|
from: assetToString(swapRequest.from),
|
|
@@ -970,7 +714,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
970
714
|
swapperGroups: !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0 ? swapRequest.swapperGroups.join(',') : undefined,
|
|
971
715
|
messagingProtocols: !!swapRequest.messagingProtocols && swapRequest.messagingProtocols.length > 0 ? swapRequest.messagingProtocols.join(',') : undefined
|
|
972
716
|
});
|
|
973
|
-
|
|
717
|
+
_context9.next = 3;
|
|
974
718
|
return this.httpService.get("/basic/swap?apiKey=" + this.apiKey, _extends({
|
|
975
719
|
params: body,
|
|
976
720
|
headers: {
|
|
@@ -978,25 +722,25 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
978
722
|
}
|
|
979
723
|
}, options));
|
|
980
724
|
case 3:
|
|
981
|
-
axiosResponse =
|
|
982
|
-
return
|
|
725
|
+
axiosResponse = _context9.sent;
|
|
726
|
+
return _context9.abrupt("return", axiosResponse.data);
|
|
983
727
|
case 5:
|
|
984
728
|
case "end":
|
|
985
|
-
return
|
|
729
|
+
return _context9.stop();
|
|
986
730
|
}
|
|
987
|
-
},
|
|
731
|
+
}, _callee9, this);
|
|
988
732
|
}));
|
|
989
|
-
function swap(
|
|
733
|
+
function swap(_x15, _x16) {
|
|
990
734
|
return _swap.apply(this, arguments);
|
|
991
735
|
}
|
|
992
736
|
return swap;
|
|
993
737
|
}();
|
|
994
738
|
_proto.reportFailure = /*#__PURE__*/function () {
|
|
995
|
-
var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
996
|
-
return _regeneratorRuntime().wrap(function
|
|
997
|
-
while (1) switch (
|
|
739
|
+
var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(requestBody, options) {
|
|
740
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
741
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
998
742
|
case 0:
|
|
999
|
-
|
|
743
|
+
_context10.next = 2;
|
|
1000
744
|
return this.httpService.post("/basic/report-tx?apiKey=" + this.apiKey, requestBody, _extends({
|
|
1001
745
|
headers: {
|
|
1002
746
|
'X-Rango-Id': this.deviceId
|
|
@@ -1004,22 +748,22 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1004
748
|
}, options));
|
|
1005
749
|
case 2:
|
|
1006
750
|
case "end":
|
|
1007
|
-
return
|
|
751
|
+
return _context10.stop();
|
|
1008
752
|
}
|
|
1009
|
-
},
|
|
753
|
+
}, _callee10, this);
|
|
1010
754
|
}));
|
|
1011
|
-
function reportFailure(
|
|
755
|
+
function reportFailure(_x17, _x18) {
|
|
1012
756
|
return _reportFailure.apply(this, arguments);
|
|
1013
757
|
}
|
|
1014
758
|
return reportFailure;
|
|
1015
759
|
}();
|
|
1016
760
|
_proto.balance = /*#__PURE__*/function () {
|
|
1017
|
-
var _balance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
761
|
+
var _balance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(walletAddress, options) {
|
|
1018
762
|
var axiosResponse;
|
|
1019
|
-
return _regeneratorRuntime().wrap(function
|
|
1020
|
-
while (1) switch (
|
|
763
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
764
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1021
765
|
case 0:
|
|
1022
|
-
|
|
766
|
+
_context11.next = 2;
|
|
1023
767
|
return this.httpService.get("/basic/balance?apiKey=" + this.apiKey, _extends({
|
|
1024
768
|
params: walletAddress,
|
|
1025
769
|
headers: {
|
|
@@ -1027,70 +771,53 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1027
771
|
}
|
|
1028
772
|
}, options));
|
|
1029
773
|
case 2:
|
|
1030
|
-
axiosResponse =
|
|
1031
|
-
return
|
|
774
|
+
axiosResponse = _context11.sent;
|
|
775
|
+
return _context11.abrupt("return", axiosResponse.data);
|
|
1032
776
|
case 4:
|
|
1033
777
|
case "end":
|
|
1034
|
-
return
|
|
778
|
+
return _context11.stop();
|
|
1035
779
|
}
|
|
1036
|
-
},
|
|
780
|
+
}, _callee11, this);
|
|
1037
781
|
}));
|
|
1038
|
-
function balance(
|
|
782
|
+
function balance(_x19, _x20) {
|
|
1039
783
|
return _balance.apply(this, arguments);
|
|
1040
784
|
}
|
|
1041
785
|
return balance;
|
|
1042
786
|
}();
|
|
1043
|
-
_proto.
|
|
1044
|
-
var
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1049
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
787
|
+
_proto.tokenBalance = /*#__PURE__*/function () {
|
|
788
|
+
var _tokenBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(tokenBalanceRequest, options) {
|
|
789
|
+
var axiosResponse;
|
|
790
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
791
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1050
792
|
case 0:
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
prettifiedError = prettifyError(_context11.t0);
|
|
1060
|
-
try {
|
|
1061
|
-
message = (prettifiedError == null ? void 0 : prettifiedError.message) || 'Error executing the route';
|
|
1062
|
-
this.reportFailure({
|
|
1063
|
-
requestId: route.requestId,
|
|
1064
|
-
eventType: 'TX_FAIL',
|
|
1065
|
-
reason: message
|
|
1066
|
-
});
|
|
1067
|
-
} catch (err) {
|
|
1068
|
-
console.log({
|
|
1069
|
-
err: err
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
throw prettifiedError;
|
|
1073
|
-
case 11:
|
|
793
|
+
_context12.next = 2;
|
|
794
|
+
return this.httpService.get("/basic/token-balance?apiKey=" + this.apiKey, _extends({
|
|
795
|
+
params: tokenBalanceRequest
|
|
796
|
+
}, options));
|
|
797
|
+
case 2:
|
|
798
|
+
axiosResponse = _context12.sent;
|
|
799
|
+
return _context12.abrupt("return", axiosResponse.data);
|
|
800
|
+
case 4:
|
|
1074
801
|
case "end":
|
|
1075
|
-
return
|
|
802
|
+
return _context12.stop();
|
|
1076
803
|
}
|
|
1077
|
-
},
|
|
804
|
+
}, _callee12, this);
|
|
1078
805
|
}));
|
|
1079
|
-
function
|
|
1080
|
-
return
|
|
806
|
+
function tokenBalance(_x21, _x22) {
|
|
807
|
+
return _tokenBalance.apply(this, arguments);
|
|
1081
808
|
}
|
|
1082
|
-
return
|
|
809
|
+
return tokenBalance;
|
|
1083
810
|
}();
|
|
1084
811
|
_proto.connectedAssets = /*#__PURE__*/function () {
|
|
1085
|
-
var _connectedAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
812
|
+
var _connectedAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(connectedAssetsRequest, options) {
|
|
1086
813
|
var body, axiosResponse;
|
|
1087
|
-
return _regeneratorRuntime().wrap(function
|
|
1088
|
-
while (1) switch (
|
|
814
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
815
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1089
816
|
case 0:
|
|
1090
817
|
body = {
|
|
1091
818
|
from: assetToString(connectedAssetsRequest.from)
|
|
1092
819
|
};
|
|
1093
|
-
|
|
820
|
+
_context13.next = 3;
|
|
1094
821
|
return this.httpService.get("/basic/connected-assets?apiKey=" + this.apiKey, _extends({
|
|
1095
822
|
params: body,
|
|
1096
823
|
headers: {
|
|
@@ -1098,15 +825,15 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1098
825
|
}
|
|
1099
826
|
}, options));
|
|
1100
827
|
case 3:
|
|
1101
|
-
axiosResponse =
|
|
1102
|
-
return
|
|
828
|
+
axiosResponse = _context13.sent;
|
|
829
|
+
return _context13.abrupt("return", axiosResponse.data);
|
|
1103
830
|
case 5:
|
|
1104
831
|
case "end":
|
|
1105
|
-
return
|
|
832
|
+
return _context13.stop();
|
|
1106
833
|
}
|
|
1107
|
-
},
|
|
834
|
+
}, _callee13, this);
|
|
1108
835
|
}));
|
|
1109
|
-
function connectedAssets(
|
|
836
|
+
function connectedAssets(_x23, _x24) {
|
|
1110
837
|
return _connectedAssets.apply(this, arguments);
|
|
1111
838
|
}
|
|
1112
839
|
return connectedAssets;
|
|
@@ -1114,7 +841,6 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1114
841
|
return RangoClient;
|
|
1115
842
|
}();
|
|
1116
843
|
|
|
1117
|
-
exports.MetamaskErrorCodes = MetamaskErrorCodes;
|
|
1118
844
|
exports.RangoClient = RangoClient;
|
|
1119
845
|
exports.assetToString = assetToString;
|
|
1120
846
|
exports.cosmosBlockchains = cosmosBlockchains;
|