@rabbitio/ui-kit 1.0.0-beta.33 → 1.0.0-beta.35
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 +85 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +79 -25
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +85 -26
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +85 -26
- 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 +26 -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 +23 -3
package/dist/index.cjs
CHANGED
|
@@ -2623,18 +2623,24 @@ var ExistingSwap =
|
|
|
2623
2623
|
* @param confirmations {number}
|
|
2624
2624
|
* @param rate {string}
|
|
2625
2625
|
* @param refundAddress {string}
|
|
2626
|
+
* @param payToAddress {string}
|
|
2626
2627
|
* @param fromCoin {Coin}
|
|
2627
2628
|
* @param fromAmount {string}
|
|
2628
2629
|
* @param fromTransactionId {string}
|
|
2630
|
+
* @param fromTransactionLink {string}
|
|
2629
2631
|
* @param toCoin {Coin}
|
|
2630
2632
|
* @param toAmount {string}
|
|
2631
2633
|
* @param toTransactionId {string|null}
|
|
2634
|
+
* @param toTransactionLink {string}
|
|
2632
2635
|
* @param toAddress {string}
|
|
2633
2636
|
* @param partner {string}
|
|
2637
|
+
* @param fromExtraId {string}
|
|
2638
|
+
* @param toExtraId {string}
|
|
2639
|
+
* @param refundExtraId {string}
|
|
2634
2640
|
*/
|
|
2635
2641
|
function ExistingSwap(swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress,
|
|
2636
2642
|
// TODO: [refactoring, moderate] toAddress is not quite clear. How about recipientAddress? task_id=0815a111c99543b78d374217eadbde4f
|
|
2637
|
-
partner) {
|
|
2643
|
+
partner, fromExtraId, toExtraId, refundExtraId) {
|
|
2638
2644
|
this.swapId = swapId;
|
|
2639
2645
|
this.status = status;
|
|
2640
2646
|
this.createdAt = createdAt;
|
|
@@ -2653,6 +2659,9 @@ partner) {
|
|
|
2653
2659
|
this.toAmount = toAmount;
|
|
2654
2660
|
this.toAddress = toAddress;
|
|
2655
2661
|
this.partner = partner;
|
|
2662
|
+
this.fromExtraId = fromExtraId;
|
|
2663
|
+
this.toExtraId = toExtraId;
|
|
2664
|
+
this.refundExtraId = refundExtraId;
|
|
2656
2665
|
};
|
|
2657
2666
|
|
|
2658
2667
|
var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
@@ -2665,22 +2674,28 @@ var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
|
2665
2674
|
* @param confirmations {number}
|
|
2666
2675
|
* @param rate {string}
|
|
2667
2676
|
* @param refundAddress {string}
|
|
2677
|
+
* @param payToAddress {string}
|
|
2668
2678
|
* @param fromCoin {Coin}
|
|
2669
2679
|
* @param fromAmount {string}
|
|
2670
2680
|
* @param fromTransactionId {string}
|
|
2681
|
+
* @param fromTransactionLink {string}
|
|
2671
2682
|
* @param toCoin {Coin}
|
|
2672
2683
|
* @param toAmount {string}
|
|
2673
2684
|
* @param toTransactionId {string|null}
|
|
2685
|
+
* @param toTransactionLink
|
|
2674
2686
|
* @param toAddress {string}
|
|
2675
2687
|
* @param partner {string}
|
|
2688
|
+
* @param fromExtraId {string}
|
|
2689
|
+
* @param toExtraId {string}
|
|
2690
|
+
* @param refundExtraId {string}
|
|
2676
2691
|
* @param fromAmountFiat {number}
|
|
2677
2692
|
* @param toAmountFiat {number}
|
|
2678
2693
|
* @param fiatCurrencyCode {string}
|
|
2679
2694
|
* @param fiatCurrencyDecimals {number}
|
|
2680
2695
|
*/
|
|
2681
|
-
function ExistingSwapWithFiatData(swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
2696
|
+
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) {
|
|
2682
2697
|
var _this;
|
|
2683
|
-
_this = _ExistingSwap.call(this, swapId, status, createdAt, expiresAt, confirmations, rate, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner) || this;
|
|
2698
|
+
_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;
|
|
2684
2699
|
_this.fromAmountFiat = fromAmountFiat;
|
|
2685
2700
|
_this.toAmountFiat = toAmountFiat;
|
|
2686
2701
|
_this.fiatCurrencyCode = fiatCurrencyCode;
|
|
@@ -2697,7 +2712,7 @@ var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
|
2697
2712
|
* @return {ExistingSwapWithFiatData}
|
|
2698
2713
|
*/
|
|
2699
2714
|
ExistingSwapWithFiatData.fromExistingSwap = function fromExistingSwap(existingSwap, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
2700
|
-
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);
|
|
2715
|
+
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);
|
|
2701
2716
|
};
|
|
2702
2717
|
return ExistingSwapWithFiatData;
|
|
2703
2718
|
}(ExistingSwap);
|
|
@@ -2862,6 +2877,8 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2862
2877
|
* @param refundAddress {string}
|
|
2863
2878
|
* @param rawSwapData {Object|null}
|
|
2864
2879
|
* @param clientIpAddress {string}
|
|
2880
|
+
* @param [toCurrencyExtraId=""] {string} optional extra ID
|
|
2881
|
+
* @param [refundExtraId=""] {string} optional extra ID for refund address
|
|
2865
2882
|
* @return {Promise<({
|
|
2866
2883
|
* result: true,
|
|
2867
2884
|
* swapId: string,
|
|
@@ -2871,7 +2888,8 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2871
2888
|
* toCoin: Coin,
|
|
2872
2889
|
* toAmount: string,
|
|
2873
2890
|
* toAddress: string,
|
|
2874
|
-
* rate: string
|
|
2891
|
+
* rate: string,
|
|
2892
|
+
* fromCurrencyExtraId: string|undefined
|
|
2875
2893
|
* }|{
|
|
2876
2894
|
* result: false,
|
|
2877
2895
|
* reason: string,
|
|
@@ -2879,7 +2897,7 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2879
2897
|
* })>}
|
|
2880
2898
|
*/
|
|
2881
2899
|
;
|
|
2882
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress) {
|
|
2900
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress, toCurrencyExtraId, refundExtraId) {
|
|
2883
2901
|
try {
|
|
2884
2902
|
throw new Error("Not implemented in base");
|
|
2885
2903
|
} catch (e) {
|
|
@@ -2917,6 +2935,14 @@ var SwapProvider = /*#__PURE__*/function () {
|
|
|
2917
2935
|
*/;
|
|
2918
2936
|
_proto.isAddressValidForAsset = function isAddressValidForAsset(asset, address) {
|
|
2919
2937
|
throw new Error("Not implemented in base");
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
/**
|
|
2941
|
+
* @param asset {Coin}
|
|
2942
|
+
* @return {string|null}
|
|
2943
|
+
*/;
|
|
2944
|
+
_proto.getExtraIdNameIfPresent = function getExtraIdNameIfPresent(asset) {
|
|
2945
|
+
throw new Error("Not implemented in base");
|
|
2920
2946
|
};
|
|
2921
2947
|
return SwapProvider;
|
|
2922
2948
|
}();
|
|
@@ -2975,7 +3001,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
2975
3001
|
}
|
|
2976
3002
|
_this = _SwapProvider.call(this) || this;
|
|
2977
3003
|
_this._supportedCoins = [];
|
|
2978
|
-
_this._URL =
|
|
3004
|
+
_this._URL = apiKeysProxyUrl + "/swapspace";
|
|
2979
3005
|
_this._maxRateDigits = 20;
|
|
2980
3006
|
_this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
2981
3007
|
_this._customCoinBuilder = customCoinBuilder;
|
|
@@ -3121,10 +3147,6 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3121
3147
|
var _rawResponse$data, _rawResponse$data2;
|
|
3122
3148
|
Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data = rawResponse.data) == null ? void 0 : _rawResponse$data.length), loggerSource);
|
|
3123
3149
|
var allowedCoins = (_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : [];
|
|
3124
|
-
// TODO: [feature, critical] add support for extra ID. task_id=7219d65d41c242a292dfa47479b8d63f
|
|
3125
|
-
allowedCoins = allowedCoins.filter(function (c) {
|
|
3126
|
-
return c.hasExtraId !== true && c.hasExtraId !== "true";
|
|
3127
|
-
});
|
|
3128
3150
|
Logger.log("Allowed cnt " + allowedCoins.length, loggerSource);
|
|
3129
3151
|
_this6._supportedCoins = allowedCoins.map(function (item) {
|
|
3130
3152
|
var coin = _this6._customCoinBuilder(item.code, item.network);
|
|
@@ -3153,7 +3175,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3153
3175
|
coin: coin,
|
|
3154
3176
|
code: item.code,
|
|
3155
3177
|
network: item.network,
|
|
3156
|
-
|
|
3178
|
+
hasExtraId: item.hasExtraId,
|
|
3179
|
+
extraIdName: item.extraIdName,
|
|
3157
3180
|
isPopular: !!(item != null && item.popular),
|
|
3158
3181
|
iconURL: item.icon ? "https://storage.swapspace.co" + item.icon : FALLBACK_ICON_URL,
|
|
3159
3182
|
deposit: (_item$deposit = item.deposit) != null ? _item$deposit : false,
|
|
@@ -3381,7 +3404,13 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3381
3404
|
return Promise.reject(e);
|
|
3382
3405
|
}
|
|
3383
3406
|
};
|
|
3384
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress) {
|
|
3407
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress, toCurrencyExtraId, refundExtraId) {
|
|
3408
|
+
if (toCurrencyExtraId === void 0) {
|
|
3409
|
+
toCurrencyExtraId = "";
|
|
3410
|
+
}
|
|
3411
|
+
if (refundExtraId === void 0) {
|
|
3412
|
+
refundExtraId = "";
|
|
3413
|
+
}
|
|
3385
3414
|
try {
|
|
3386
3415
|
var _this9 = this;
|
|
3387
3416
|
var loggerSource = "createSwap";
|
|
@@ -3395,11 +3424,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3395
3424
|
throw new Error("Invalid raw swap data: " + safeStringify(rawSwapData));
|
|
3396
3425
|
}
|
|
3397
3426
|
return Promise.resolve(_this9._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
3398
|
-
var
|
|
3399
|
-
var toCurrencyExtraId = (_this9$_supportedCoin = (_this9$_supportedCoin2 = _this9._supportedCoins.find(function (item) {
|
|
3400
|
-
var _item$coin4;
|
|
3401
|
-
return ((_item$coin4 = item.coin) == null ? void 0 : _item$coin4.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
3402
|
-
})) == null ? void 0 : _this9$_supportedCoin2.extraId) != null ? _this9$_supportedCoin : "";
|
|
3427
|
+
var _toCurrencyExtraId, _refundExtraId;
|
|
3403
3428
|
var requestData = {
|
|
3404
3429
|
partner: partner,
|
|
3405
3430
|
fromCurrency: rawSwapData == null ? void 0 : rawSwapData.fromCurrency,
|
|
@@ -3409,7 +3434,9 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3409
3434
|
address: toAddress,
|
|
3410
3435
|
amount: amount,
|
|
3411
3436
|
fixed: false,
|
|
3412
|
-
extraId: toCurrencyExtraId != null ?
|
|
3437
|
+
extraId: (_toCurrencyExtraId = toCurrencyExtraId) != null ? _toCurrencyExtraId : "",
|
|
3438
|
+
refundExtraId: (_refundExtraId = refundExtraId) != null ? _refundExtraId : "",
|
|
3439
|
+
// This param is not documented. But the refund is usually manual so this is not critical.
|
|
3413
3440
|
rateId: rawSwapData == null ? void 0 : rawSwapData.id,
|
|
3414
3441
|
userIp: clientIpAddress,
|
|
3415
3442
|
refund: refundAddress
|
|
@@ -3419,7 +3446,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3419
3446
|
var result = response.data;
|
|
3420
3447
|
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
3421
3448
|
if (result != null && result.id) {
|
|
3422
|
-
var _result$from, _result$from2, _result$to, _result$to2, _result$from4, _result$from5, _result$to4, _result$to5;
|
|
3449
|
+
var _result$from, _result$from2, _result$to, _result$to2, _result$from4, _result$from5, _result$to4, _result$to5, _result$from$extraId, _result$from6;
|
|
3423
3450
|
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);
|
|
3424
3451
|
/* We use the returned rate preferably but if the retrieved
|
|
3425
3452
|
* rate 0/null/undefined we calculate it manually */
|
|
@@ -3439,6 +3466,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3439
3466
|
toCoin: toCoin,
|
|
3440
3467
|
toAmount: AmountUtils.trim(result == null || (_result$to4 = result.to) == null ? void 0 : _result$to4.amount, toCoin.digits),
|
|
3441
3468
|
toAddress: result == null || (_result$to5 = result.to) == null ? void 0 : _result$to5.address,
|
|
3469
|
+
fromCurrencyExtraId: (_result$from$extraId = result == null || (_result$from6 = result.from) == null ? void 0 : _result$from6.extraId) != null ? _result$from$extraId : "",
|
|
3442
3470
|
rate: AmountUtils.trim(rate, _this9._maxRateDigits)
|
|
3443
3471
|
};
|
|
3444
3472
|
}
|
|
@@ -3538,7 +3566,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3538
3566
|
var swaps = wo404.map(function (r) {
|
|
3539
3567
|
return r.data;
|
|
3540
3568
|
}).map(function (swap, index) {
|
|
3541
|
-
var _this10$_supportedCoi, _this10$_supportedCoi2;
|
|
3569
|
+
var _this10$_supportedCoi, _this10$_supportedCoi2, _swap$from$extraId, _swap$to$extraId, _swap$refundExtraId;
|
|
3542
3570
|
var fromCoin = (_this10$_supportedCoi = _this10._supportedCoins.find(function (i) {
|
|
3543
3571
|
return i.code === swap.from.code && i.network === swap.from.network;
|
|
3544
3572
|
})) == null ? void 0 : _this10$_supportedCoi.coin;
|
|
@@ -3556,7 +3584,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3556
3584
|
var status = _this10._mapSwapspaceStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
3557
3585
|
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
3558
3586
|
var addressToSendCoinsToSwapspace = swap.from.address;
|
|
3559
|
-
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);
|
|
3587
|
+
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);
|
|
3560
3588
|
}).flat();
|
|
3561
3589
|
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
3562
3590
|
return {
|
|
@@ -3602,6 +3630,19 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
|
3602
3630
|
}
|
|
3603
3631
|
return false;
|
|
3604
3632
|
};
|
|
3633
|
+
_proto.getExtraIdNameIfPresent = function getExtraIdNameIfPresent(asset) {
|
|
3634
|
+
try {
|
|
3635
|
+
var _assetData$extraIdNam;
|
|
3636
|
+
var assetData = this._supportedCoins.find(function (i) {
|
|
3637
|
+
var _i$coin4;
|
|
3638
|
+
return ((_i$coin4 = i.coin) == null ? void 0 : _i$coin4.ticker) === (asset == null ? void 0 : asset.ticker);
|
|
3639
|
+
});
|
|
3640
|
+
// We return "ID" if the extraIdName is empty
|
|
3641
|
+
return assetData != null && assetData.hasExtraId ? (_assetData$extraIdNam = assetData == null ? void 0 : assetData.extraIdName) != null ? _assetData$extraIdNam : "ID" : null;
|
|
3642
|
+
} catch (e) {
|
|
3643
|
+
improveAndRethrow(e, "getExtraIdNameIfPresent");
|
|
3644
|
+
}
|
|
3645
|
+
};
|
|
3605
3646
|
return SwapspaceSwapProvider;
|
|
3606
3647
|
}(SwapProvider);
|
|
3607
3648
|
|
|
@@ -4193,6 +4234,8 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4193
4234
|
* @param toAddress {string}
|
|
4194
4235
|
* @param refundAddress {string}
|
|
4195
4236
|
* @param clientIp {string}
|
|
4237
|
+
* @param [toCurrencyExtraId] {string}
|
|
4238
|
+
* @param [refundExtraId] {string}
|
|
4196
4239
|
* @return {Promise<{
|
|
4197
4240
|
* result: true,
|
|
4198
4241
|
* fiatCurrencyCode: string,
|
|
@@ -4206,14 +4249,15 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4206
4249
|
* fiatCurrencyDecimals: number,
|
|
4207
4250
|
* fromCoin: Coin,
|
|
4208
4251
|
* rate: string,
|
|
4209
|
-
* swapId: string
|
|
4252
|
+
* swapId: string,
|
|
4253
|
+
* fromCurrencyExtraId: string
|
|
4210
4254
|
* }|{
|
|
4211
4255
|
* result: false,
|
|
4212
4256
|
* reason: string
|
|
4213
4257
|
* }>}
|
|
4214
4258
|
*/
|
|
4215
4259
|
;
|
|
4216
|
-
_proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
|
|
4260
|
+
_proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp, toCurrencyExtraId, refundExtraId) {
|
|
4217
4261
|
try {
|
|
4218
4262
|
var _this8 = this;
|
|
4219
4263
|
var loggerSource = "createPublicSwap";
|
|
@@ -4226,7 +4270,7 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4226
4270
|
fromCoin: swapCreationInfo == null || (_swapCreationInfo$fro = swapCreationInfo.fromCoin) == null ? void 0 : _swapCreationInfo$fro.ticker,
|
|
4227
4271
|
toCoin: swapCreationInfo == null || (_swapCreationInfo$toC = swapCreationInfo.toCoin) == null ? void 0 : _swapCreationInfo$toC.ticker
|
|
4228
4272
|
})), loggerSource);
|
|
4229
|
-
return Promise.resolve(_this8._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
|
|
4273
|
+
return Promise.resolve(_this8._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp, toCurrencyExtraId, refundExtraId)).then(function (result) {
|
|
4230
4274
|
var _exit;
|
|
4231
4275
|
function _temp6(_result8) {
|
|
4232
4276
|
if (_exit) return _result8;
|
|
@@ -4255,6 +4299,7 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4255
4299
|
var _temp5 = function () {
|
|
4256
4300
|
if (result.result && result != null && result.swapId) {
|
|
4257
4301
|
var _temp4 = function _temp4() {
|
|
4302
|
+
var _result$fromCurrencyE;
|
|
4258
4303
|
EventBusInstance__default["default"].dispatch(PublicSwapService.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
|
|
4259
4304
|
var toReturn = {
|
|
4260
4305
|
result: true,
|
|
@@ -4269,7 +4314,9 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4269
4314
|
fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
|
|
4270
4315
|
rate: result.rate,
|
|
4271
4316
|
durationMinutesRange: swapCreationInfo.durationMinutesRange,
|
|
4272
|
-
address: result.fromAddress
|
|
4317
|
+
address: result.fromAddress,
|
|
4318
|
+
// CRITICAL: this is the address to send coins to swaps provider
|
|
4319
|
+
fromCurrencyExtraId: (_result$fromCurrencyE = result.fromCurrencyExtraId) != null ? _result$fromCurrencyE : "" // CRITICAL: this is the extra ID for address to send coins to swaps provider
|
|
4273
4320
|
};
|
|
4274
4321
|
_this8._savePublicSwapIdLocally(result.swapId);
|
|
4275
4322
|
Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
|
|
@@ -4508,6 +4555,18 @@ var PublicSwapService = /*#__PURE__*/function () {
|
|
|
4508
4555
|
} catch (e) {
|
|
4509
4556
|
return Promise.reject(e);
|
|
4510
4557
|
}
|
|
4558
|
+
}
|
|
4559
|
+
/**
|
|
4560
|
+
* @param asset {Coin}
|
|
4561
|
+
* @return {string|null}
|
|
4562
|
+
*/
|
|
4563
|
+
;
|
|
4564
|
+
_proto.getExtraIdNameIfPresentForAsset = function getExtraIdNameIfPresentForAsset(asset) {
|
|
4565
|
+
try {
|
|
4566
|
+
return this._swapProvider.getExtraIdNameIfPresent(asset);
|
|
4567
|
+
} catch (e) {
|
|
4568
|
+
improveAndRethrow(e, "getExtraIdNameIfPresentForAsset");
|
|
4569
|
+
}
|
|
4511
4570
|
};
|
|
4512
4571
|
return PublicSwapService;
|
|
4513
4572
|
}();
|