@rabbitio/ui-kit 1.0.0-beta.32 → 1.0.0-beta.34
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/dist/index.cjs +106 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +80 -27
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +106 -44
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +106 -44
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/swaps-lib/external-apis/swapProvider.js +15 -2
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +23 -12
- package/src/swaps-lib/models/existingSwap.js +13 -1
- package/src/swaps-lib/models/existingSwapWithFiatData.js +16 -1
- package/src/swaps-lib/services/publicSwapService.js +34 -7
package/dist/index.module.js
CHANGED
|
@@ -2617,18 +2617,24 @@ var ExistingSwap =
|
|
|
2617
2617
|
* @param confirmations {number}
|
|
2618
2618
|
* @param rate {string}
|
|
2619
2619
|
* @param refundAddress {string}
|
|
2620
|
+
* @param payToAddress {string}
|
|
2620
2621
|
* @param fromCoin {Coin}
|
|
2621
2622
|
* @param fromAmount {string}
|
|
2622
2623
|
* @param fromTransactionId {string}
|
|
2624
|
+
* @param fromTransactionLink {string}
|
|
2623
2625
|
* @param toCoin {Coin}
|
|
2624
2626
|
* @param toAmount {string}
|
|
2625
2627
|
* @param toTransactionId {string|null}
|
|
2628
|
+
* @param toTransactionLink {string}
|
|
2626
2629
|
* @param toAddress {string}
|
|
2627
2630
|
* @param partner {string}
|
|
2631
|
+
* @param fromExtraId {string}
|
|
2632
|
+
* @param toExtraId {string}
|
|
2633
|
+
* @param refundExtraId {string}
|
|
2628
2634
|
*/
|
|
2629
2635
|
function ExistingSwap(swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress,
|
|
2630
2636
|
// TODO: [refactoring, moderate] toAddress is not quite clear. How about recipientAddress? task_id=0815a111c99543b78d374217eadbde4f
|
|
2631
|
-
partner) {
|
|
2637
|
+
partner, fromExtraId, toExtraId, refundExtraId) {
|
|
2632
2638
|
this.swapId = swapId;
|
|
2633
2639
|
this.status = status;
|
|
2634
2640
|
this.createdAt = createdAt;
|
|
@@ -2647,6 +2653,9 @@ partner) {
|
|
|
2647
2653
|
this.toAmount = toAmount;
|
|
2648
2654
|
this.toAddress = toAddress;
|
|
2649
2655
|
this.partner = partner;
|
|
2656
|
+
this.fromExtraId = fromExtraId;
|
|
2657
|
+
this.toExtraId = toExtraId;
|
|
2658
|
+
this.refundExtraId = refundExtraId;
|
|
2650
2659
|
};
|
|
2651
2660
|
|
|
2652
2661
|
var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
@@ -2659,22 +2668,28 @@ var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
|
2659
2668
|
* @param confirmations {number}
|
|
2660
2669
|
* @param rate {string}
|
|
2661
2670
|
* @param refundAddress {string}
|
|
2671
|
+
* @param payToAddress {string}
|
|
2662
2672
|
* @param fromCoin {Coin}
|
|
2663
2673
|
* @param fromAmount {string}
|
|
2664
2674
|
* @param fromTransactionId {string}
|
|
2675
|
+
* @param fromTransactionLink {string}
|
|
2665
2676
|
* @param toCoin {Coin}
|
|
2666
2677
|
* @param toAmount {string}
|
|
2667
2678
|
* @param toTransactionId {string|null}
|
|
2679
|
+
* @param toTransactionLink
|
|
2668
2680
|
* @param toAddress {string}
|
|
2669
2681
|
* @param partner {string}
|
|
2682
|
+
* @param fromExtraId {string}
|
|
2683
|
+
* @param toExtraId {string}
|
|
2684
|
+
* @param refundExtraId {string}
|
|
2670
2685
|
* @param fromAmountFiat {number}
|
|
2671
2686
|
* @param toAmountFiat {number}
|
|
2672
2687
|
* @param fiatCurrencyCode {string}
|
|
2673
2688
|
* @param fiatCurrencyDecimals {number}
|
|
2674
2689
|
*/
|
|
2675
|
-
function ExistingSwapWithFiatData(swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
2690
|
+
function ExistingSwapWithFiatData(swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner, fromExtraId, toExtraId, refundExtraId, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
2676
2691
|
var _this;
|
|
2677
|
-
_this = _ExistingSwap.call(this, swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner) || this;
|
|
2692
|
+
_this = _ExistingSwap.call(this, swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner, fromExtraId, toExtraId, refundExtraId) || this;
|
|
2678
2693
|
_this.fromAmountFiat = fromAmountFiat;
|
|
2679
2694
|
_this.toAmountFiat = toAmountFiat;
|
|
2680
2695
|
_this.fiatCurrencyCode = fiatCurrencyCode;
|
|
@@ -2691,7 +2706,7 @@ var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
|
2691
2706
|
* @return {ExistingSwapWithFiatData}
|
|
2692
2707
|
*/
|
|
2693
2708
|
ExistingSwapWithFiatData.fromExistingSwap = function fromExistingSwap(existingSwap, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
2694
|
-
return new ExistingSwapWithFiatData(existingSwap.swapId, existingSwap.status, existingSwap.createdAt, existingSwap.expiresAt, existingSwap.confirmations, existingSwap.rate, existingSwap.refundAddress, existingSwap.payToAddress, existingSwap.fromCoin, existingSwap.fromAmount, existingSwap.fromTransactionId, existingSwap.fromTransactionLink, existingSwap.toCoin, existingSwap.toAmount, existingSwap.toTransactionId, existingSwap.toTransactionLink, existingSwap.toAddress, existingSwap.partner, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals);
|
|
2709
|
+
return new ExistingSwapWithFiatData(existingSwap.swapId, existingSwap.status, existingSwap.createdAt, existingSwap.expiresAt, existingSwap.confirmations, existingSwap.rate, existingSwap.refundAddress, existingSwap.payToAddress, existingSwap.fromCoin, existingSwap.fromAmount, existingSwap.fromTransactionId, existingSwap.fromTransactionLink, existingSwap.toCoin, existingSwap.toAmount, existingSwap.toTransactionId, existingSwap.toTransactionLink, existingSwap.toAddress, existingSwap.partner, existingSwap.fromExtraId, existingSwap.toExtraId, existingSwap.refundExtraId, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals);
|
|
2695
2710
|
};
|
|
2696
2711
|
return ExistingSwapWithFiatData;
|
|
2697
2712
|
}(ExistingSwap);
|
|
@@ -2856,6 +2871,8 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2856
2871
|
* @param refundAddress {string}
|
|
2857
2872
|
* @param rawSwapData {Object|null}
|
|
2858
2873
|
* @param clientIpAddress {string}
|
|
2874
|
+
* @param [toCurrencyExtraId=""] {string} optional extra ID
|
|
2875
|
+
* @param [refundExtraId=""] {string} optional extra ID for refund address
|
|
2859
2876
|
* @return {Promise<({
|
|
2860
2877
|
* result: true,
|
|
2861
2878
|
* swapId: string,
|
|
@@ -2865,7 +2882,8 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2865
2882
|
* toCoin: Coin,
|
|
2866
2883
|
* toAmount: string,
|
|
2867
2884
|
* toAddress: string,
|
|
2868
|
-
* rate: string
|
|
2885
|
+
* rate: string,
|
|
2886
|
+
* fromCurrencyExtraId: string|undefined
|
|
2869
2887
|
* }|{
|
|
2870
2888
|
* result: false,
|
|
2871
2889
|
* reason: string,
|
|
@@ -2873,7 +2891,7 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2873
2891
|
* })>}
|
|
2874
2892
|
*/
|
|
2875
2893
|
;
|
|
2876
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress) {
|
|
2894
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress, toCurrencyExtraId, refundExtraId) {
|
|
2877
2895
|
try {
|
|
2878
2896
|
throw new Error("Not implemented in base");
|
|
2879
2897
|
} catch (e) {
|
|
@@ -2911,6 +2929,14 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2911
2929
|
*/;
|
|
2912
2930
|
_proto.isAddressValidForAsset = function isAddressValidForAsset(asset, address) {
|
|
2913
2931
|
throw new Error("Not implemented in base");
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
/**
|
|
2935
|
+
* @param asset {Coin}
|
|
2936
|
+
* @return {string|null}
|
|
2937
|
+
*/;
|
|
2938
|
+
_proto.getExtraIdNameIfPresent = function getExtraIdNameIfPresent(asset) {
|
|
2939
|
+
throw new Error("Not implemented in base");
|
|
2914
2940
|
};
|
|
2915
2941
|
return SwapProvider;
|
|
2916
2942
|
}();
|
|
@@ -2969,7 +2995,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
2969
2995
|
}
|
|
2970
2996
|
_this = _SwapProvider.call(this) || this;
|
|
2971
2997
|
_this._supportedCoins = [];
|
|
2972
|
-
_this._URL =
|
|
2998
|
+
_this._URL = apiKeysProxyUrl + "/swapspace";
|
|
2973
2999
|
_this._maxRateDigits = 20;
|
|
2974
3000
|
_this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
2975
3001
|
_this._customCoinBuilder = customCoinBuilder;
|
|
@@ -3115,10 +3141,6 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3115
3141
|
var _rawResponse$data, _rawResponse$data2;
|
|
3116
3142
|
Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data = rawResponse.data) == null ? void 0 : _rawResponse$data.length), loggerSource);
|
|
3117
3143
|
var allowedCoins = (_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : [];
|
|
3118
|
-
// TODO: [feature, critical] add support for extra ID. task_id=7219d65d41c242a292dfa47479b8d63f
|
|
3119
|
-
allowedCoins = allowedCoins.filter(function (c) {
|
|
3120
|
-
return c.hasExtraId !== true && c.hasExtraId !== "true";
|
|
3121
|
-
});
|
|
3122
3144
|
Logger.log("Allowed cnt " + allowedCoins.length, loggerSource);
|
|
3123
3145
|
_this6._supportedCoins = allowedCoins.map(function (item) {
|
|
3124
3146
|
var coin = _this6._customCoinBuilder(item.code, item.network);
|
|
@@ -3147,7 +3169,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3147
3169
|
coin: coin,
|
|
3148
3170
|
code: item.code,
|
|
3149
3171
|
network: item.network,
|
|
3150
|
-
|
|
3172
|
+
hasExtraId: item.hasExtraId,
|
|
3173
|
+
extraIdName: item.extraIdName,
|
|
3151
3174
|
isPopular: !!(item != null && item.popular),
|
|
3152
3175
|
iconURL: item.icon ? "https://storage.swapspace.co" + item.icon : FALLBACK_ICON_URL,
|
|
3153
3176
|
deposit: (_item$deposit = item.deposit) != null ? _item$deposit : false,
|
|
@@ -3375,7 +3398,13 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3375
3398
|
return Promise.reject(e);
|
|
3376
3399
|
}
|
|
3377
3400
|
};
|
|
3378
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress) {
|
|
3401
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress, toCurrencyExtraId, refundExtraId) {
|
|
3402
|
+
if (toCurrencyExtraId === void 0) {
|
|
3403
|
+
toCurrencyExtraId = "";
|
|
3404
|
+
}
|
|
3405
|
+
if (refundExtraId === void 0) {
|
|
3406
|
+
refundExtraId = "";
|
|
3407
|
+
}
|
|
3379
3408
|
try {
|
|
3380
3409
|
var _this9 = this;
|
|
3381
3410
|
var loggerSource = "createSwap";
|
|
@@ -3389,11 +3418,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3389
3418
|
throw new Error("Invalid raw swap data: " + safeStringify(rawSwapData));
|
|
3390
3419
|
}
|
|
3391
3420
|
return Promise.resolve(_this9._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
3392
|
-
var
|
|
3393
|
-
var toCurrencyExtraId = (_this9$_supportedCoin = (_this9$_supportedCoin2 = _this9._supportedCoins.find(function (item) {
|
|
3394
|
-
var _item$coin4;
|
|
3395
|
-
return ((_item$coin4 = item.coin) == null ? void 0 : _item$coin4.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
3396
|
-
})) == null ? void 0 : _this9$_supportedCoin2.extraId) != null ? _this9$_supportedCoin : "";
|
|
3421
|
+
var _toCurrencyExtraId, _refundExtraId;
|
|
3397
3422
|
var requestData = {
|
|
3398
3423
|
partner: partner,
|
|
3399
3424
|
fromCurrency: rawSwapData == null ? void 0 : rawSwapData.fromCurrency,
|
|
@@ -3403,7 +3428,9 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3403
3428
|
address: toAddress,
|
|
3404
3429
|
amount: amount,
|
|
3405
3430
|
fixed: false,
|
|
3406
|
-
extraId: toCurrencyExtraId != null ?
|
|
3431
|
+
extraId: (_toCurrencyExtraId = toCurrencyExtraId) != null ? _toCurrencyExtraId : "",
|
|
3432
|
+
refundExtraId: (_refundExtraId = refundExtraId) != null ? _refundExtraId : "",
|
|
3433
|
+
// This param is not documented. But the refund is usually manual so this is not critical.
|
|
3407
3434
|
rateId: rawSwapData == null ? void 0 : rawSwapData.id,
|
|
3408
3435
|
userIp: clientIpAddress,
|
|
3409
3436
|
refund: refundAddress
|
|
@@ -3413,7 +3440,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3413
3440
|
var result = response.data;
|
|
3414
3441
|
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
3415
3442
|
if (result != null && result.id) {
|
|
3416
|
-
var _result$from, _result$from2, _result$to, _result$to2, _result$from4, _result$from5, _result$to4, _result$to5;
|
|
3443
|
+
var _result$from, _result$from2, _result$to, _result$to2, _result$from4, _result$from5, _result$to4, _result$to5, _result$from$extraId, _result$from6;
|
|
3417
3444
|
if (typeof (result == null || (_result$from = result.from) == null ? void 0 : _result$from.amount) !== "number" || typeof (result == null || (_result$from2 = result.from) == null ? void 0 : _result$from2.address) !== "string" || typeof (result == null || (_result$to = result.to) == null ? void 0 : _result$to.amount) !== "number" || typeof (result == null || (_result$to2 = result.to) == null ? void 0 : _result$to2.address) !== "string") throw new Error("Wrong swap creation result " + result);
|
|
3418
3445
|
/* We use the returned rate preferably but if the retrieved
|
|
3419
3446
|
* rate 0/null/undefined we calculate it manually */
|
|
@@ -3433,6 +3460,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3433
3460
|
toCoin: toCoin,
|
|
3434
3461
|
toAmount: AmountUtils.trim(result == null || (_result$to4 = result.to) == null ? void 0 : _result$to4.amount, toCoin.digits),
|
|
3435
3462
|
toAddress: result == null || (_result$to5 = result.to) == null ? void 0 : _result$to5.address,
|
|
3463
|
+
fromCurrencyExtraId: (_result$from$extraId = result == null || (_result$from6 = result.from) == null ? void 0 : _result$from6.extraId) != null ? _result$from$extraId : "",
|
|
3436
3464
|
rate: AmountUtils.trim(rate, _this9._maxRateDigits)
|
|
3437
3465
|
};
|
|
3438
3466
|
}
|
|
@@ -3532,7 +3560,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3532
3560
|
var swaps = wo404.map(function (r) {
|
|
3533
3561
|
return r.data;
|
|
3534
3562
|
}).map(function (swap, index) {
|
|
3535
|
-
var _this10$_supportedCoi, _this10$_supportedCoi2;
|
|
3563
|
+
var _this10$_supportedCoi, _this10$_supportedCoi2, _swap$from$extraId, _swap$to$extraId, _swap$refundExtraId;
|
|
3536
3564
|
var fromCoin = (_this10$_supportedCoi = _this10._supportedCoins.find(function (i) {
|
|
3537
3565
|
return i.code === swap.from.code && i.network === swap.from.network;
|
|
3538
3566
|
})) == null ? void 0 : _this10$_supportedCoi.coin;
|
|
@@ -3550,7 +3578,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3550
3578
|
var status = _this10._mapSwapspaceStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
3551
3579
|
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
3552
3580
|
var addressToSendCoinsToSwapspace = swap.from.address;
|
|
3553
|
-
return new ExistingSwap(swapIds[index], status, toUtcTimestamp(swap.timestamps.createdAt), expiresAt, swap.confirmations, AmountUtils.trim(swap.rate, _this10._maxRateDigits), swap.refundAddress, addressToSendCoinsToSwapspace, fromCoin, AmountUtils.trim(swap.from.amount, fromCoin.digits), swap.from.transactionHash, swap.blockExplorerTransactionUrl.from, toCoin, AmountUtils.trim(swap.to.amount, toDigits), swap.to.transactionHash, swap.blockExplorerTransactionUrl.to, swap.to.address, swap.partner);
|
|
3581
|
+
return new ExistingSwap(swapIds[index], status, toUtcTimestamp(swap.timestamps.createdAt), expiresAt, swap.confirmations, AmountUtils.trim(swap.rate, _this10._maxRateDigits), swap.refundAddress, addressToSendCoinsToSwapspace, fromCoin, AmountUtils.trim(swap.from.amount, fromCoin.digits), swap.from.transactionHash, swap.blockExplorerTransactionUrl.from, toCoin, AmountUtils.trim(swap.to.amount, toDigits), swap.to.transactionHash, swap.blockExplorerTransactionUrl.to, swap.to.address, swap.partner, (_swap$from$extraId = swap.from.extraId) != null ? _swap$from$extraId : null, (_swap$to$extraId = swap.to.extraId) != null ? _swap$to$extraId : null, (_swap$refundExtraId = swap.refundExtraId) != null ? _swap$refundExtraId : null);
|
|
3554
3582
|
}).flat();
|
|
3555
3583
|
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
3556
3584
|
return {
|
|
@@ -3596,6 +3624,17 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3596
3624
|
}
|
|
3597
3625
|
return false;
|
|
3598
3626
|
};
|
|
3627
|
+
_proto.getExtraIdNameIfPresent = function getExtraIdNameIfPresent(asset) {
|
|
3628
|
+
try {
|
|
3629
|
+
var assetData = this._supportedCoins.find(function (i) {
|
|
3630
|
+
var _i$coin4;
|
|
3631
|
+
return ((_i$coin4 = i.coin) == null ? void 0 : _i$coin4.ticker) === (asset == null ? void 0 : asset.ticker);
|
|
3632
|
+
});
|
|
3633
|
+
return assetData != null && assetData.hasExtraId ? assetData == null ? void 0 : assetData.extraIdName : null;
|
|
3634
|
+
} catch (e) {
|
|
3635
|
+
improveAndRethrow(e, "getExtraIdNameIfPresent");
|
|
3636
|
+
}
|
|
3637
|
+
};
|
|
3599
3638
|
return SwapspaceSwapProvider;
|
|
3600
3639
|
}(SwapProvider);
|
|
3601
3640
|
|
|
@@ -4090,6 +4129,7 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4090
4129
|
* @param fromCoin {Coin}
|
|
4091
4130
|
* @param toCoin {Coin}
|
|
4092
4131
|
* @param fromAmountCoins {string}
|
|
4132
|
+
* @param [withoutFiat=false] {boolean} pass true if you don't need the fiat equivalent - this will diminish requests count
|
|
4093
4133
|
* @return {Promise<{
|
|
4094
4134
|
* result: false,
|
|
4095
4135
|
* reason: string,
|
|
@@ -4104,14 +4144,17 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4104
4144
|
* }>}
|
|
4105
4145
|
*/
|
|
4106
4146
|
;
|
|
4107
|
-
_proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
|
|
4147
|
+
_proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins, withoutFiat) {
|
|
4148
|
+
if (withoutFiat === void 0) {
|
|
4149
|
+
withoutFiat = false;
|
|
4150
|
+
}
|
|
4108
4151
|
try {
|
|
4109
4152
|
var _this7 = this;
|
|
4110
4153
|
var loggerSource = "getPublicSwapDetails";
|
|
4111
4154
|
return Promise.resolve(_catch(function () {
|
|
4112
|
-
|
|
4155
|
+
function _temp2(_this7$_swapProvider$) {
|
|
4113
4156
|
var _this7$_swapProvider$2;
|
|
4114
|
-
var coinUsdtRate = (_this7$_swapProvider$2 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$2 : null;
|
|
4157
|
+
var coinUsdtRate = withoutFiat ? _this7$_swapProvider$ : (_this7$_swapProvider$2 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$2 : null;
|
|
4115
4158
|
return Promise.resolve(_this7._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
|
|
4116
4159
|
var _result$swapCreationI, _result$swapCreationI2;
|
|
4117
4160
|
var min = details.result ? details.min : details.smallestMin;
|
|
@@ -4164,7 +4207,8 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4164
4207
|
}), loggerSource);
|
|
4165
4208
|
return result;
|
|
4166
4209
|
});
|
|
4167
|
-
}
|
|
4210
|
+
}
|
|
4211
|
+
return withoutFiat ? _temp2(null) : Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(_temp2);
|
|
4168
4212
|
}, function (e) {
|
|
4169
4213
|
improveAndRethrow(e, loggerSource);
|
|
4170
4214
|
}));
|
|
@@ -4182,6 +4226,8 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4182
4226
|
* @param toAddress {string}
|
|
4183
4227
|
* @param refundAddress {string}
|
|
4184
4228
|
* @param clientIp {string}
|
|
4229
|
+
* @param [toCurrencyExtraId] {string}
|
|
4230
|
+
* @param [refundExtraId] {string}
|
|
4185
4231
|
* @return {Promise<{
|
|
4186
4232
|
* result: true,
|
|
4187
4233
|
* fiatCurrencyCode: string,
|
|
@@ -4195,14 +4241,15 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4195
4241
|
* fiatCurrencyDecimals: number,
|
|
4196
4242
|
* fromCoin: Coin,
|
|
4197
4243
|
* rate: string,
|
|
4198
|
-
* swapId: string
|
|
4244
|
+
* swapId: string,
|
|
4245
|
+
* fromCurrencyExtraId: string
|
|
4199
4246
|
* }|{
|
|
4200
4247
|
* result: false,
|
|
4201
4248
|
* reason: string
|
|
4202
4249
|
* }>}
|
|
4203
4250
|
*/
|
|
4204
4251
|
;
|
|
4205
|
-
_proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
|
|
4252
|
+
_proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp, toCurrencyExtraId, refundExtraId) {
|
|
4206
4253
|
try {
|
|
4207
4254
|
var _this8 = this;
|
|
4208
4255
|
var loggerSource = "createPublicSwap";
|
|
@@ -4215,9 +4262,9 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4215
4262
|
fromCoin: swapCreationInfo == null || (_swapCreationInfo$fro = swapCreationInfo.fromCoin) == null ? void 0 : _swapCreationInfo$fro.ticker,
|
|
4216
4263
|
toCoin: swapCreationInfo == null || (_swapCreationInfo$toC = swapCreationInfo.toCoin) == null ? void 0 : _swapCreationInfo$toC.ticker
|
|
4217
4264
|
})), loggerSource);
|
|
4218
|
-
return Promise.resolve(_this8._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
|
|
4265
|
+
return Promise.resolve(_this8._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp, toCurrencyExtraId, refundExtraId)).then(function (result) {
|
|
4219
4266
|
var _exit;
|
|
4220
|
-
function
|
|
4267
|
+
function _temp6(_result8) {
|
|
4221
4268
|
if (_exit) return _result8;
|
|
4222
4269
|
throw new Error("Unexpected result from provider " + safeStringify(result));
|
|
4223
4270
|
}
|
|
@@ -4241,9 +4288,10 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4241
4288
|
// };
|
|
4242
4289
|
}
|
|
4243
4290
|
}
|
|
4244
|
-
var
|
|
4291
|
+
var _temp5 = function () {
|
|
4245
4292
|
if (result.result && result != null && result.swapId) {
|
|
4246
|
-
var
|
|
4293
|
+
var _temp4 = function _temp4() {
|
|
4294
|
+
var _result$fromCurrencyE;
|
|
4247
4295
|
EventBusInstance.dispatch(PublicSwapService.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
|
|
4248
4296
|
var toReturn = {
|
|
4249
4297
|
result: true,
|
|
@@ -4258,7 +4306,9 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4258
4306
|
fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
|
|
4259
4307
|
rate: result.rate,
|
|
4260
4308
|
durationMinutesRange: swapCreationInfo.durationMinutesRange,
|
|
4261
|
-
address: result.fromAddress
|
|
4309
|
+
address: result.fromAddress,
|
|
4310
|
+
// CRITICAL: this is the address to send coins to swaps provider
|
|
4311
|
+
fromCurrencyExtraId: (_result$fromCurrencyE = result.fromCurrencyExtraId) != null ? _result$fromCurrencyE : "" // CRITICAL: this is the extra ID for address to send coins to swaps provider
|
|
4262
4312
|
};
|
|
4263
4313
|
_this8._savePublicSwapIdLocally(result.swapId);
|
|
4264
4314
|
Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
|
|
@@ -4270,7 +4320,7 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4270
4320
|
};
|
|
4271
4321
|
var _fromAmountFiat = null,
|
|
4272
4322
|
_toAmountFiat = null;
|
|
4273
|
-
var
|
|
4323
|
+
var _temp3 = _catch(function () {
|
|
4274
4324
|
return Promise.resolve(_this8._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this8$_swapProvider$) {
|
|
4275
4325
|
var _this8$_swapProvider$3;
|
|
4276
4326
|
var fromCoinUsdtRate = (_this8$_swapProvider$3 = _this8$_swapProvider$ == null ? void 0 : _this8$_swapProvider$.rate) != null ? _this8$_swapProvider$3 : null;
|
|
@@ -4288,10 +4338,10 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4288
4338
|
}, function (e) {
|
|
4289
4339
|
Logger.logError(e, loggerSource, "Failed to calculate fiat amounts for result");
|
|
4290
4340
|
});
|
|
4291
|
-
return
|
|
4341
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
4292
4342
|
}
|
|
4293
4343
|
}();
|
|
4294
|
-
return
|
|
4344
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
4295
4345
|
});
|
|
4296
4346
|
}, function (e) {
|
|
4297
4347
|
improveAndRethrow(e, loggerSource);
|
|
@@ -4356,14 +4406,14 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4356
4406
|
var _exit2;
|
|
4357
4407
|
var _this10 = this;
|
|
4358
4408
|
return Promise.resolve(_catch(function () {
|
|
4359
|
-
function
|
|
4409
|
+
function _temp8(_result10) {
|
|
4360
4410
|
return _exit2 ? _result10 : {
|
|
4361
4411
|
result: true,
|
|
4362
4412
|
swaps: []
|
|
4363
4413
|
};
|
|
4364
4414
|
}
|
|
4365
4415
|
var swapIds = _this10._getPublicSwapIdsSavedLocally();
|
|
4366
|
-
var
|
|
4416
|
+
var _temp7 = function () {
|
|
4367
4417
|
if (swapIds.length) {
|
|
4368
4418
|
return Promise.resolve(_this10.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this10$getPub) {
|
|
4369
4419
|
_exit2 = 1;
|
|
@@ -4371,7 +4421,7 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4371
4421
|
});
|
|
4372
4422
|
}
|
|
4373
4423
|
}();
|
|
4374
|
-
return
|
|
4424
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
4375
4425
|
}, function (e) {
|
|
4376
4426
|
improveAndRethrow(e, "getPublicSwapsHistory");
|
|
4377
4427
|
}));
|
|
@@ -4472,11 +4522,11 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4472
4522
|
try {
|
|
4473
4523
|
var _exit3;
|
|
4474
4524
|
var _this12 = this;
|
|
4475
|
-
var
|
|
4525
|
+
var _temp10 = _catch(function () {
|
|
4476
4526
|
if (!addressString) {
|
|
4477
|
-
var
|
|
4527
|
+
var _temp9 = null;
|
|
4478
4528
|
_exit3 = 1;
|
|
4479
|
-
return
|
|
4529
|
+
return _temp9;
|
|
4480
4530
|
}
|
|
4481
4531
|
var addressLowerCase = addressString.toLowerCase();
|
|
4482
4532
|
return Promise.resolve(_this12._swapProvider.getAllSupportedCurrencies()).then(function (allCoins) {
|
|
@@ -4491,12 +4541,24 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4491
4541
|
}, function (e) {
|
|
4492
4542
|
Logger.logError(e, "getTokenByContractAddress");
|
|
4493
4543
|
});
|
|
4494
|
-
return Promise.resolve(
|
|
4544
|
+
return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function (_result13) {
|
|
4495
4545
|
return _exit3 ? _result13 : null;
|
|
4496
|
-
}) : _exit3 ?
|
|
4546
|
+
}) : _exit3 ? _temp10 : null);
|
|
4497
4547
|
} catch (e) {
|
|
4498
4548
|
return Promise.reject(e);
|
|
4499
4549
|
}
|
|
4550
|
+
}
|
|
4551
|
+
/**
|
|
4552
|
+
* @param asset {Coin}
|
|
4553
|
+
* @return {string|null}
|
|
4554
|
+
*/
|
|
4555
|
+
;
|
|
4556
|
+
_proto.getExtraIdNameIfPresentForAsset = function getExtraIdNameIfPresentForAsset(asset) {
|
|
4557
|
+
try {
|
|
4558
|
+
return this._swapProvider.getExtraIdNameIfPresent(asset);
|
|
4559
|
+
} catch (e) {
|
|
4560
|
+
improveAndRethrow(e, "getExtraIdNameIfPresentForAsset");
|
|
4561
|
+
}
|
|
4500
4562
|
};
|
|
4501
4563
|
return PublicSwapService;
|
|
4502
4564
|
}();
|