@paraspell/sdk 5.0.1 → 5.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/dist/index.cjs +306 -114
- package/dist/index.d.ts +103 -18
- package/dist/index.mjs +306 -114
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -336,6 +336,15 @@ function _toPropertyKey(t) {
|
|
|
336
336
|
var i = _toPrimitive(t, "string");
|
|
337
337
|
return "symbol" == typeof i ? i : i + "";
|
|
338
338
|
}
|
|
339
|
+
function _typeof(o) {
|
|
340
|
+
"@babel/helpers - typeof";
|
|
341
|
+
|
|
342
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
343
|
+
return typeof o;
|
|
344
|
+
} : function (o) {
|
|
345
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
346
|
+
}, _typeof(o);
|
|
347
|
+
}
|
|
339
348
|
function _classCallCheck(instance, Constructor) {
|
|
340
349
|
if (!(instance instanceof Constructor)) {
|
|
341
350
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -496,6 +505,57 @@ function _arrayLikeToArray(arr, len) {
|
|
|
496
505
|
function _nonIterableSpread() {
|
|
497
506
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
498
507
|
}
|
|
508
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
509
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
510
|
+
if (!it) {
|
|
511
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
512
|
+
if (it) o = it;
|
|
513
|
+
var i = 0;
|
|
514
|
+
var F = function () {};
|
|
515
|
+
return {
|
|
516
|
+
s: F,
|
|
517
|
+
n: function () {
|
|
518
|
+
if (i >= o.length) return {
|
|
519
|
+
done: true
|
|
520
|
+
};
|
|
521
|
+
return {
|
|
522
|
+
done: false,
|
|
523
|
+
value: o[i++]
|
|
524
|
+
};
|
|
525
|
+
},
|
|
526
|
+
e: function (e) {
|
|
527
|
+
throw e;
|
|
528
|
+
},
|
|
529
|
+
f: F
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
533
|
+
}
|
|
534
|
+
var normalCompletion = true,
|
|
535
|
+
didErr = false,
|
|
536
|
+
err;
|
|
537
|
+
return {
|
|
538
|
+
s: function () {
|
|
539
|
+
it = it.call(o);
|
|
540
|
+
},
|
|
541
|
+
n: function () {
|
|
542
|
+
var step = it.next();
|
|
543
|
+
normalCompletion = step.done;
|
|
544
|
+
return step;
|
|
545
|
+
},
|
|
546
|
+
e: function (e) {
|
|
547
|
+
didErr = true;
|
|
548
|
+
err = e;
|
|
549
|
+
},
|
|
550
|
+
f: function () {
|
|
551
|
+
try {
|
|
552
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
553
|
+
} finally {
|
|
554
|
+
if (didErr) throw err;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
499
559
|
|
|
500
560
|
/******************************************************************************
|
|
501
561
|
Copyright (c) Microsoft Corporation.
|
|
@@ -5597,18 +5657,18 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
|
|
|
5597
5657
|
amount = _ref.amount,
|
|
5598
5658
|
paraIdTo = _ref.paraIdTo;
|
|
5599
5659
|
var includeFee = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
5600
|
-
var paraId = paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination);
|
|
5601
|
-
var parameters = [createPolkadotXcmHeader('RelayToPara', version, paraId), generateAddressPayload(api, 'RelayToPara', null, address, version, paraId), createCurrencySpec(amount, version, Parents.ZERO), 0];
|
|
5660
|
+
var paraId = destination !== undefined && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
5661
|
+
var parameters = [createPolkadotXcmHeader('RelayToPara', version, destination, paraId), generateAddressPayload(api, 'RelayToPara', null, address, version, paraId), createCurrencySpec(amount, version, Parents.ZERO), 0];
|
|
5602
5662
|
if (includeFee) {
|
|
5603
5663
|
parameters.push('Unlimited');
|
|
5604
5664
|
}
|
|
5605
5665
|
return parameters;
|
|
5606
5666
|
};
|
|
5607
|
-
var createCurrencySpec = function createCurrencySpec(amount, version, parents) {
|
|
5608
|
-
var interior = arguments.length >
|
|
5667
|
+
var createCurrencySpec = function createCurrencySpec(amount, version, parents, overridedMultiLocation) {
|
|
5668
|
+
var interior = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'Here';
|
|
5609
5669
|
return _defineProperty({}, version, [{
|
|
5610
5670
|
id: {
|
|
5611
|
-
Concrete: {
|
|
5671
|
+
Concrete: overridedMultiLocation !== null && overridedMultiLocation !== void 0 ? overridedMultiLocation : {
|
|
5612
5672
|
parents: parents,
|
|
5613
5673
|
interior: interior
|
|
5614
5674
|
}
|
|
@@ -5618,14 +5678,15 @@ var createCurrencySpec = function createCurrencySpec(amount, version, parents) {
|
|
|
5618
5678
|
}
|
|
5619
5679
|
}]);
|
|
5620
5680
|
};
|
|
5621
|
-
var createPolkadotXcmHeader = function createPolkadotXcmHeader(scenario, version, nodeId) {
|
|
5681
|
+
var createPolkadotXcmHeader = function createPolkadotXcmHeader(scenario, version, destination, nodeId) {
|
|
5622
5682
|
var parents = scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
5623
5683
|
var interior = scenario === 'ParaToRelay' ? 'Here' : {
|
|
5624
5684
|
X1: {
|
|
5625
5685
|
Parachain: nodeId
|
|
5626
5686
|
}
|
|
5627
5687
|
};
|
|
5628
|
-
|
|
5688
|
+
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5689
|
+
return _defineProperty({}, scenario === 'RelayToPara' ? Version.V3 : version, isMultiLocationDestination ? destination : {
|
|
5629
5690
|
parents: parents,
|
|
5630
5691
|
interior: interior
|
|
5631
5692
|
});
|
|
@@ -5649,6 +5710,42 @@ var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
|
5649
5710
|
}, _callee);
|
|
5650
5711
|
}));
|
|
5651
5712
|
};
|
|
5713
|
+
var findParachainJunction = function findParachainJunction(multilocation) {
|
|
5714
|
+
var interior = multilocation.interior;
|
|
5715
|
+
for (var key in interior) {
|
|
5716
|
+
var junctions = interior[key];
|
|
5717
|
+
if (Array.isArray(junctions)) {
|
|
5718
|
+
var _iterator = _createForOfIteratorHelper(junctions),
|
|
5719
|
+
_step;
|
|
5720
|
+
try {
|
|
5721
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5722
|
+
var junction = _step.value;
|
|
5723
|
+
if ('Parachain' in junction) {
|
|
5724
|
+
return Number(junction.Parachain);
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5727
|
+
} catch (err) {
|
|
5728
|
+
_iterator.e(err);
|
|
5729
|
+
} finally {
|
|
5730
|
+
_iterator.f();
|
|
5731
|
+
}
|
|
5732
|
+
} else if (junctions !== undefined && 'Parachain' in junctions) {
|
|
5733
|
+
return Number(junctions.Parachain);
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
return null;
|
|
5737
|
+
};
|
|
5738
|
+
var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(multiLocation) {
|
|
5739
|
+
var parachainId = findParachainJunction(multiLocation);
|
|
5740
|
+
if (parachainId === null) {
|
|
5741
|
+
throw new Error('Parachain ID not found in destination multi location.');
|
|
5742
|
+
}
|
|
5743
|
+
var node = getTNode(parachainId);
|
|
5744
|
+
if (node === null) {
|
|
5745
|
+
throw new Error('Node with specified paraId not found in destination multi location.');
|
|
5746
|
+
}
|
|
5747
|
+
return node;
|
|
5748
|
+
};
|
|
5652
5749
|
|
|
5653
5750
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
5654
5751
|
return 'transferXTokens' in obj;
|
|
@@ -5703,10 +5800,11 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
5703
5800
|
address = options.address,
|
|
5704
5801
|
destination = options.destination,
|
|
5705
5802
|
paraIdTo = options.paraIdTo,
|
|
5803
|
+
overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
|
|
5706
5804
|
_options$serializedAp = options.serializedApiCallEnabled,
|
|
5707
5805
|
serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
|
|
5708
5806
|
var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
|
|
5709
|
-
var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
5807
|
+
var paraId = destination !== undefined && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
5710
5808
|
if (supportsXTokens(this)) {
|
|
5711
5809
|
return this.transferXTokens({
|
|
5712
5810
|
api: api,
|
|
@@ -5719,6 +5817,7 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
5719
5817
|
scenario: scenario,
|
|
5720
5818
|
paraIdTo: paraId,
|
|
5721
5819
|
destination: destination,
|
|
5820
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
5722
5821
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
5723
5822
|
});
|
|
5724
5823
|
} else if (supportsXTransfer(this)) {
|
|
@@ -5731,14 +5830,15 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
5731
5830
|
paraId: paraId,
|
|
5732
5831
|
origin: this.node,
|
|
5733
5832
|
destination: destination,
|
|
5833
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
5734
5834
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
5735
5835
|
});
|
|
5736
5836
|
} else if (supportsPolkadotXCM(this)) {
|
|
5737
5837
|
return this.transferPolkadotXCM({
|
|
5738
5838
|
api: api,
|
|
5739
|
-
header: this.createPolkadotXcmHeader(scenario, paraId),
|
|
5839
|
+
header: this.createPolkadotXcmHeader(scenario, destination, paraId),
|
|
5740
5840
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
|
|
5741
|
-
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
|
|
5841
|
+
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
|
|
5742
5842
|
scenario: scenario,
|
|
5743
5843
|
currencySymbol: currencySymbol,
|
|
5744
5844
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
@@ -5781,13 +5881,13 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
5781
5881
|
}
|
|
5782
5882
|
}, {
|
|
5783
5883
|
key: "createCurrencySpec",
|
|
5784
|
-
value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
|
|
5785
|
-
return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO);
|
|
5884
|
+
value: function createCurrencySpec$1(amount, scenario, version, currencyId, overridedMultiLocation) {
|
|
5885
|
+
return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO, overridedMultiLocation);
|
|
5786
5886
|
}
|
|
5787
5887
|
}, {
|
|
5788
5888
|
key: "createPolkadotXcmHeader",
|
|
5789
|
-
value: function createPolkadotXcmHeader$1(scenario, paraId) {
|
|
5790
|
-
return createPolkadotXcmHeader(scenario, this.version, paraId);
|
|
5889
|
+
value: function createPolkadotXcmHeader$1(scenario, destination, paraId) {
|
|
5890
|
+
return createPolkadotXcmHeader(scenario, this.version, destination, paraId);
|
|
5791
5891
|
}
|
|
5792
5892
|
}]);
|
|
5793
5893
|
}();
|
|
@@ -5813,6 +5913,20 @@ var getModifiedCurrencySelection = function getModifiedCurrencySelection(version
|
|
|
5813
5913
|
}
|
|
5814
5914
|
});
|
|
5815
5915
|
};
|
|
5916
|
+
var getCurrencySelection = function getCurrencySelection(_ref2, isAssetHub, currencySelection) {
|
|
5917
|
+
var origin = _ref2.origin,
|
|
5918
|
+
amount = _ref2.amount,
|
|
5919
|
+
currencyID = _ref2.currencyID,
|
|
5920
|
+
paraIdTo = _ref2.paraIdTo,
|
|
5921
|
+
overridedCurrencyMultiLocation = _ref2.overridedCurrencyMultiLocation;
|
|
5922
|
+
var _getNode = getNode(origin),
|
|
5923
|
+
version = _getNode.version;
|
|
5924
|
+
if (overridedCurrencyMultiLocation !== undefined) return _defineProperty({}, version, overridedCurrencyMultiLocation);
|
|
5925
|
+
if (isAssetHub) {
|
|
5926
|
+
return getModifiedCurrencySelection(version, amount, currencyID, paraIdTo);
|
|
5927
|
+
}
|
|
5928
|
+
return currencySelection;
|
|
5929
|
+
};
|
|
5816
5930
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
5817
5931
|
var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
5818
5932
|
function XTokensTransferImpl() {
|
|
@@ -5820,30 +5934,30 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
5820
5934
|
}
|
|
5821
5935
|
return _createClass(XTokensTransferImpl, null, [{
|
|
5822
5936
|
key: "transferXTokens",
|
|
5823
|
-
value: function transferXTokens(
|
|
5824
|
-
var api = _ref2.api,
|
|
5825
|
-
amount = _ref2.amount,
|
|
5826
|
-
currencyID = _ref2.currencyID,
|
|
5827
|
-
addressSelection = _ref2.addressSelection,
|
|
5828
|
-
origin = _ref2.origin,
|
|
5829
|
-
destination = _ref2.destination,
|
|
5830
|
-
paraIdTo = _ref2.paraIdTo,
|
|
5831
|
-
serializedApiCallEnabled = _ref2.serializedApiCallEnabled;
|
|
5937
|
+
value: function transferXTokens(input, currencySelection) {
|
|
5832
5938
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
|
|
5833
5939
|
var pallet = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'XTokens';
|
|
5940
|
+
var api = input.api,
|
|
5941
|
+
amount = input.amount,
|
|
5942
|
+
addressSelection = input.addressSelection,
|
|
5943
|
+
destination = input.destination,
|
|
5944
|
+
serializedApiCallEnabled = input.serializedApiCallEnabled;
|
|
5945
|
+
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5946
|
+
if (isMultiLocationDestination) {
|
|
5947
|
+
throw new Error('Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.');
|
|
5948
|
+
}
|
|
5834
5949
|
var module = lowercaseFirstLetter(pallet.toString());
|
|
5835
5950
|
var isAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
5836
|
-
var
|
|
5837
|
-
var modifiedCurrencySelection = isAssetHub ? getModifiedCurrencySelection(node.version, amount, currencyID, paraIdTo) : currencySelection;
|
|
5951
|
+
var modifiedCurrencySelection = getCurrencySelection(input, isAssetHub, currencySelection);
|
|
5838
5952
|
var section = isAssetHub ? 'transferMultiasset' : 'transfer';
|
|
5839
5953
|
if (serializedApiCallEnabled === true) {
|
|
5840
5954
|
return {
|
|
5841
5955
|
module: module,
|
|
5842
5956
|
section: section,
|
|
5843
|
-
parameters: isAssetHub ? [modifiedCurrencySelection, addressSelection, fees] : [
|
|
5957
|
+
parameters: isAssetHub ? [modifiedCurrencySelection, addressSelection, fees] : [modifiedCurrencySelection, amount, addressSelection, fees]
|
|
5844
5958
|
};
|
|
5845
5959
|
}
|
|
5846
|
-
return isAssetHub ? api.tx[module][section](modifiedCurrencySelection, addressSelection, fees) : api.tx[module][section](
|
|
5960
|
+
return isAssetHub ? api.tx[module][section](modifiedCurrencySelection, addressSelection, fees) : api.tx[module][section](modifiedCurrencySelection, amount, addressSelection, fees);
|
|
5847
5961
|
}
|
|
5848
5962
|
}]);
|
|
5849
5963
|
}();
|
|
@@ -6558,7 +6672,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6558
6672
|
}
|
|
6559
6673
|
}, {
|
|
6560
6674
|
key: "createCurrencySpec",
|
|
6561
|
-
value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
|
|
6675
|
+
value: function createCurrencySpec$1(amount, scenario, version, currencyId, overridedMultiLocation) {
|
|
6562
6676
|
if (scenario === 'ParaToPara') {
|
|
6563
6677
|
var interior = {
|
|
6564
6678
|
X2: [{
|
|
@@ -6567,7 +6681,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6567
6681
|
GeneralIndex: currencyId
|
|
6568
6682
|
}]
|
|
6569
6683
|
};
|
|
6570
|
-
return createCurrencySpec(amount, version, Parents.ZERO, interior);
|
|
6684
|
+
return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
|
|
6571
6685
|
} else {
|
|
6572
6686
|
return _get(_getPrototypeOf(AssetHubPolkadot.prototype), "createCurrencySpec", this).call(this, amount, scenario, version, currencyId);
|
|
6573
6687
|
}
|
|
@@ -6717,10 +6831,11 @@ var Astar$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6717
6831
|
address = options.address,
|
|
6718
6832
|
destination = options.destination,
|
|
6719
6833
|
paraIdTo = options.paraIdTo,
|
|
6834
|
+
overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
|
|
6720
6835
|
_options$serializedAp = options.serializedApiCallEnabled,
|
|
6721
6836
|
serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
|
|
6722
6837
|
var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
|
|
6723
|
-
var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
6838
|
+
var paraId = destination !== undefined && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
6724
6839
|
var node = this.node;
|
|
6725
6840
|
if (supportsXTokens(this) && currencySymbol !== 'ASTR') {
|
|
6726
6841
|
return this.transferXTokens({
|
|
@@ -6734,14 +6849,15 @@ var Astar$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6734
6849
|
scenario: scenario,
|
|
6735
6850
|
paraIdTo: paraId,
|
|
6736
6851
|
destination: destination,
|
|
6852
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
6737
6853
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
6738
6854
|
});
|
|
6739
6855
|
} else if (supportsPolkadotXCM(this)) {
|
|
6740
6856
|
return this.transferPolkadotXCM({
|
|
6741
6857
|
api: api,
|
|
6742
|
-
header: this.createPolkadotXcmHeader(scenario, paraId),
|
|
6858
|
+
header: this.createPolkadotXcmHeader(scenario, destination, paraId),
|
|
6743
6859
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
|
|
6744
|
-
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
|
|
6860
|
+
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
|
|
6745
6861
|
scenario: scenario,
|
|
6746
6862
|
currencySymbol: currencySymbol,
|
|
6747
6863
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
@@ -6772,14 +6888,14 @@ var Darwinia$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6772
6888
|
}
|
|
6773
6889
|
}, {
|
|
6774
6890
|
key: "createCurrencySpec",
|
|
6775
|
-
value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
|
|
6891
|
+
value: function createCurrencySpec$1(amount, scenario, version, currencyId, overridedMultiLocation) {
|
|
6776
6892
|
if (scenario === 'ParaToPara') {
|
|
6777
6893
|
var interior = {
|
|
6778
6894
|
X1: {
|
|
6779
6895
|
PalletInstance: 5
|
|
6780
6896
|
}
|
|
6781
6897
|
};
|
|
6782
|
-
return createCurrencySpec(amount, version, Parents.ZERO, interior);
|
|
6898
|
+
return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
|
|
6783
6899
|
} else {
|
|
6784
6900
|
return _get(_getPrototypeOf(Darwinia.prototype), "createCurrencySpec", this).call(this, amount, scenario, version, currencyId);
|
|
6785
6901
|
}
|
|
@@ -6864,10 +6980,11 @@ var Shiden$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6864
6980
|
address = options.address,
|
|
6865
6981
|
destination = options.destination,
|
|
6866
6982
|
paraIdTo = options.paraIdTo,
|
|
6983
|
+
overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
|
|
6867
6984
|
_options$serializedAp = options.serializedApiCallEnabled,
|
|
6868
6985
|
serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
|
|
6869
6986
|
var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
|
|
6870
|
-
var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
6987
|
+
var paraId = destination !== undefined && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
6871
6988
|
var node = this.node;
|
|
6872
6989
|
if (supportsXTokens(this) && currencySymbol !== 'SDN') {
|
|
6873
6990
|
return this.transferXTokens({
|
|
@@ -6877,18 +6994,19 @@ var Shiden$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6877
6994
|
amount: amount,
|
|
6878
6995
|
addressSelection: generateAddressPayload(api, scenario, 'XTokens', address, this.version, paraId),
|
|
6879
6996
|
fees: getFees(scenario),
|
|
6997
|
+
origin: this.node,
|
|
6880
6998
|
scenario: scenario,
|
|
6881
6999
|
paraIdTo: paraId,
|
|
6882
|
-
origin: this.node,
|
|
6883
7000
|
destination: destination,
|
|
7001
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
6884
7002
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
6885
7003
|
});
|
|
6886
7004
|
} else if (supportsPolkadotXCM(this)) {
|
|
6887
7005
|
return this.transferPolkadotXCM({
|
|
6888
7006
|
api: api,
|
|
6889
|
-
header: this.createPolkadotXcmHeader(scenario, paraId),
|
|
7007
|
+
header: this.createPolkadotXcmHeader(scenario, destination, paraId),
|
|
6890
7008
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
|
|
6891
|
-
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
|
|
7009
|
+
currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
|
|
6892
7010
|
scenario: scenario,
|
|
6893
7011
|
currencySymbol: currencySymbol,
|
|
6894
7012
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
@@ -7068,6 +7186,28 @@ var determineDestWeight = function determineDestWeight(destNode) {
|
|
|
7068
7186
|
}
|
|
7069
7187
|
throw new NodeNotSupportedError("Node ".concat(destNode, " is not supported"));
|
|
7070
7188
|
};
|
|
7189
|
+
var getDestination = function getDestination(_ref) {
|
|
7190
|
+
var recipientAddress = _ref.recipientAddress,
|
|
7191
|
+
paraId = _ref.paraId,
|
|
7192
|
+
api = _ref.api;
|
|
7193
|
+
var isMultiLocation = _typeof(recipientAddress) === 'object';
|
|
7194
|
+
if (isMultiLocation) {
|
|
7195
|
+
return recipientAddress;
|
|
7196
|
+
}
|
|
7197
|
+
var isEthAddress = ethers.utils.isAddress(recipientAddress);
|
|
7198
|
+
return {
|
|
7199
|
+
parents: 1,
|
|
7200
|
+
interior: {
|
|
7201
|
+
X2: [{
|
|
7202
|
+
Parachain: paraId
|
|
7203
|
+
}, _defineProperty({}, isEthAddress ? 'AccountKey20' : 'AccountId32', Object.assign({}, isEthAddress ? {
|
|
7204
|
+
key: recipientAddress
|
|
7205
|
+
} : {
|
|
7206
|
+
id: createAccID(api, recipientAddress)
|
|
7207
|
+
}))]
|
|
7208
|
+
}
|
|
7209
|
+
};
|
|
7210
|
+
};
|
|
7071
7211
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
7072
7212
|
var XTransferTransferImpl = /*#__PURE__*/function () {
|
|
7073
7213
|
function XTransferTransferImpl() {
|
|
@@ -7075,28 +7215,19 @@ var XTransferTransferImpl = /*#__PURE__*/function () {
|
|
|
7075
7215
|
}
|
|
7076
7216
|
return _createClass(XTransferTransferImpl, null, [{
|
|
7077
7217
|
key: "transferXTransfer",
|
|
7078
|
-
value: function transferXTransfer(
|
|
7079
|
-
var api =
|
|
7080
|
-
amount =
|
|
7081
|
-
origin =
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
X2: [{
|
|
7092
|
-
Parachain: paraId
|
|
7093
|
-
}, _defineProperty({}, isEthAddress ? 'AccountKey20' : 'AccountId32', Object.assign({}, isEthAddress ? {
|
|
7094
|
-
key: recipientAddress
|
|
7095
|
-
} : {
|
|
7096
|
-
id: createAccID(api, recipientAddress)
|
|
7097
|
-
}))]
|
|
7098
|
-
}
|
|
7099
|
-
};
|
|
7218
|
+
value: function transferXTransfer(input) {
|
|
7219
|
+
var api = input.api,
|
|
7220
|
+
amount = input.amount,
|
|
7221
|
+
origin = input.origin,
|
|
7222
|
+
destination = input.destination,
|
|
7223
|
+
serializedApiCallEnabled = input.serializedApiCallEnabled,
|
|
7224
|
+
overridedCurrencyMultiLocation = input.overridedCurrencyMultiLocation;
|
|
7225
|
+
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
7226
|
+
if (isMultiLocationDestination) {
|
|
7227
|
+
throw new Error('Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.');
|
|
7228
|
+
}
|
|
7229
|
+
var currencySpec = createCurrencySpec(amount, Version.V1, Parents.ZERO, overridedCurrencyMultiLocation)[Version.V1][0];
|
|
7230
|
+
var dest = getDestination(input);
|
|
7100
7231
|
if (serializedApiCallEnabled === true) {
|
|
7101
7232
|
return {
|
|
7102
7233
|
module: 'xTransfer',
|
|
@@ -7227,6 +7358,10 @@ var getFees = function getFees(scenario) {
|
|
|
7227
7358
|
throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
|
|
7228
7359
|
};
|
|
7229
7360
|
var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
|
|
7361
|
+
var isMultiLocation = _typeof(recipientAddress) === 'object';
|
|
7362
|
+
if (isMultiLocation) {
|
|
7363
|
+
return _defineProperty({}, version, recipientAddress);
|
|
7364
|
+
}
|
|
7230
7365
|
var isEthAddress = ethers.utils.isAddress(recipientAddress);
|
|
7231
7366
|
if (scenario === 'ParaToRelay') {
|
|
7232
7367
|
return _defineProperty({}, version, {
|
|
@@ -7292,8 +7427,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
|
|
|
7292
7427
|
var _getNode = getNode(node),
|
|
7293
7428
|
type = _getNode.type,
|
|
7294
7429
|
name = _getNode.name;
|
|
7295
|
-
var
|
|
7296
|
-
linked =
|
|
7430
|
+
var _ref6 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
|
|
7431
|
+
linked = _ref6.linked;
|
|
7297
7432
|
if (linked === undefined) return undefined;
|
|
7298
7433
|
var preferredOption = linked.find(function (o) {
|
|
7299
7434
|
return o.info === name && Object.values(o.providers).length > 0;
|
|
@@ -7304,8 +7439,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
|
|
|
7304
7439
|
};
|
|
7305
7440
|
var getAllNodeProviders = function getAllNodeProviders(node) {
|
|
7306
7441
|
var _a;
|
|
7307
|
-
var
|
|
7308
|
-
providers =
|
|
7442
|
+
var _ref7 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
|
|
7443
|
+
providers = _ref7.providers;
|
|
7309
7444
|
if (providers.length < 1) {
|
|
7310
7445
|
throw new Error("Node ".concat(node, " does not have any providers."));
|
|
7311
7446
|
}
|
|
@@ -7365,18 +7500,22 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
|
7365
7500
|
var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
|
|
7366
7501
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
7367
7502
|
};
|
|
7368
|
-
var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api,
|
|
7503
|
+
var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref8) {
|
|
7369
7504
|
var _api$tx$module;
|
|
7370
|
-
var module =
|
|
7371
|
-
section =
|
|
7372
|
-
parameters =
|
|
7505
|
+
var module = _ref8.module,
|
|
7506
|
+
section = _ref8.section,
|
|
7507
|
+
parameters = _ref8.parameters;
|
|
7373
7508
|
return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
|
|
7374
7509
|
};
|
|
7375
7510
|
var determineRelayChain = function determineRelayChain(node) {
|
|
7376
7511
|
return getRelayChainSymbol(node) === 'KSM' ? 'Kusama' : 'Polkadot';
|
|
7377
7512
|
};
|
|
7378
7513
|
|
|
7379
|
-
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node,
|
|
7514
|
+
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
|
|
7515
|
+
if (_typeof(currency) === 'object') {
|
|
7516
|
+
return null;
|
|
7517
|
+
}
|
|
7518
|
+
var currencyString = currency.toString();
|
|
7380
7519
|
var _getAssetsObject = getAssetsObject(node),
|
|
7381
7520
|
otherAssets = _getAssetsObject.otherAssets,
|
|
7382
7521
|
nativeAssets = _getAssetsObject.nativeAssets,
|
|
@@ -7384,7 +7523,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
|
7384
7523
|
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (_ref) {
|
|
7385
7524
|
var symbol = _ref.symbol,
|
|
7386
7525
|
assetId = _ref.assetId;
|
|
7387
|
-
return symbol ===
|
|
7526
|
+
return symbol === currencyString || assetId === currencyString;
|
|
7388
7527
|
});
|
|
7389
7528
|
if (asset !== undefined) {
|
|
7390
7529
|
var symbol = asset.symbol,
|
|
@@ -7394,7 +7533,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
|
7394
7533
|
assetId: assetId
|
|
7395
7534
|
};
|
|
7396
7535
|
}
|
|
7397
|
-
if (relayChainAssetSymbol ===
|
|
7536
|
+
if (relayChainAssetSymbol === currencyString) return {
|
|
7398
7537
|
symbol: relayChainAssetSymbol
|
|
7399
7538
|
};
|
|
7400
7539
|
return null;
|
|
@@ -7722,6 +7861,9 @@ var OpenChannelBuilder = /*#__PURE__*/function () {
|
|
|
7722
7861
|
}, {
|
|
7723
7862
|
key: "buildOptions",
|
|
7724
7863
|
value: function buildOptions() {
|
|
7864
|
+
if (_typeof(this.to) === 'object') {
|
|
7865
|
+
throw new Error('Channels do not support multi-location destinations');
|
|
7866
|
+
}
|
|
7725
7867
|
return {
|
|
7726
7868
|
api: this.api,
|
|
7727
7869
|
origin: this.from,
|
|
@@ -8234,71 +8376,98 @@ var checkKeepAlive = function checkKeepAlive(_ref) {
|
|
|
8234
8376
|
|
|
8235
8377
|
var sendCommon = function sendCommon(options) {
|
|
8236
8378
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8237
|
-
var _a, api, origin,
|
|
8379
|
+
var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, _options$serializedAp, serializedApiCallEnabled, asset, isMultiLocationDestination, isMultiLocationCurrency, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, apiWithFallback, amountStr, currencyStr, currencyId;
|
|
8238
8380
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8239
8381
|
while (1) switch (_context.prev = _context.next) {
|
|
8240
8382
|
case 0:
|
|
8241
|
-
api = options.api, origin = options.origin,
|
|
8242
|
-
if (!(typeof
|
|
8383
|
+
api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, _options$serializedAp = options.serializedApiCallEnabled, serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
|
|
8384
|
+
if (!(typeof currency === 'number' && currency > Number.MAX_SAFE_INTEGER)) {
|
|
8243
8385
|
_context.next = 3;
|
|
8244
8386
|
break;
|
|
8245
8387
|
}
|
|
8246
8388
|
throw new InvalidCurrencyError('The provided asset ID is larger than the maximum safe integer value. Please provide it as a string.');
|
|
8247
8389
|
case 3:
|
|
8248
|
-
asset = getAssetBySymbolOrId(origin,
|
|
8249
|
-
|
|
8250
|
-
|
|
8390
|
+
asset = getAssetBySymbolOrId(origin, currency);
|
|
8391
|
+
isMultiLocationDestination = _typeof(destination) === 'object';
|
|
8392
|
+
isMultiLocationCurrency = _typeof(currency) === 'object';
|
|
8393
|
+
if (!(destination !== undefined && !isMultiLocationDestination)) {
|
|
8394
|
+
_context.next = 11;
|
|
8251
8395
|
break;
|
|
8252
8396
|
}
|
|
8253
8397
|
originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
8254
8398
|
destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
8255
8399
|
if (!(originRelayChainSymbol !== destinationRelayChainSymbol)) {
|
|
8256
|
-
_context.next =
|
|
8400
|
+
_context.next = 11;
|
|
8257
8401
|
break;
|
|
8258
8402
|
}
|
|
8259
8403
|
throw new IncompatibleNodesError();
|
|
8260
|
-
case
|
|
8404
|
+
case 11:
|
|
8261
8405
|
originNode = getNode(origin);
|
|
8262
|
-
assetCheckEnabled = destination === 'AssetHubKusama' || destination === 'AssetHubPolkadot' ? false : originNode.assetCheckEnabled;
|
|
8406
|
+
assetCheckEnabled = destination === 'AssetHubKusama' || destination === 'AssetHubPolkadot' || isMultiLocationCurrency ? false : originNode.assetCheckEnabled;
|
|
8263
8407
|
if (!(asset === null && assetCheckEnabled)) {
|
|
8264
|
-
_context.next = 13;
|
|
8265
|
-
break;
|
|
8266
|
-
}
|
|
8267
|
-
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
|
|
8268
|
-
case 13:
|
|
8269
|
-
if (!(destination !== undefined && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !hasSupportForAsset(destination, asset.symbol))) {
|
|
8270
8408
|
_context.next = 15;
|
|
8271
8409
|
break;
|
|
8272
8410
|
}
|
|
8273
|
-
throw new InvalidCurrencyError("
|
|
8411
|
+
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
|
|
8274
8412
|
case 15:
|
|
8413
|
+
if (!(destination !== undefined && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !hasSupportForAsset(destination, asset.symbol))) {
|
|
8414
|
+
_context.next = 17;
|
|
8415
|
+
break;
|
|
8416
|
+
}
|
|
8417
|
+
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
|
|
8418
|
+
case 17:
|
|
8275
8419
|
if (!(api !== null && api !== void 0)) {
|
|
8276
|
-
_context.next =
|
|
8420
|
+
_context.next = 21;
|
|
8277
8421
|
break;
|
|
8278
8422
|
}
|
|
8279
8423
|
_context.t0 = api;
|
|
8280
|
-
_context.next =
|
|
8424
|
+
_context.next = 24;
|
|
8281
8425
|
break;
|
|
8282
|
-
case 19:
|
|
8283
|
-
_context.next = 21;
|
|
8284
|
-
return createApiInstanceForNode(origin);
|
|
8285
8426
|
case 21:
|
|
8427
|
+
_context.next = 23;
|
|
8428
|
+
return createApiInstanceForNode(origin);
|
|
8429
|
+
case 23:
|
|
8286
8430
|
_context.t0 = _context.sent;
|
|
8287
|
-
case
|
|
8431
|
+
case 24:
|
|
8288
8432
|
apiWithFallback = _context.t0;
|
|
8289
8433
|
amountStr = amount.toString();
|
|
8290
|
-
|
|
8434
|
+
if (!(_typeof(currency) === 'object')) {
|
|
8435
|
+
_context.next = 30;
|
|
8436
|
+
break;
|
|
8437
|
+
}
|
|
8438
|
+
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
8439
|
+
_context.next = 40;
|
|
8440
|
+
break;
|
|
8441
|
+
case 30:
|
|
8442
|
+
if (!(_typeof(address) === 'object')) {
|
|
8443
|
+
_context.next = 34;
|
|
8444
|
+
break;
|
|
8445
|
+
}
|
|
8446
|
+
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
8447
|
+
_context.next = 40;
|
|
8448
|
+
break;
|
|
8449
|
+
case 34:
|
|
8450
|
+
if (!(_typeof(destination) === 'object')) {
|
|
8451
|
+
_context.next = 38;
|
|
8452
|
+
break;
|
|
8453
|
+
}
|
|
8454
|
+
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
8455
|
+
_context.next = 40;
|
|
8456
|
+
break;
|
|
8457
|
+
case 38:
|
|
8458
|
+
_context.next = 40;
|
|
8291
8459
|
return checkKeepAlive({
|
|
8292
8460
|
originApi: apiWithFallback,
|
|
8293
8461
|
address: address,
|
|
8294
8462
|
amount: amountStr,
|
|
8295
8463
|
originNode: origin,
|
|
8296
8464
|
destApi: destApiForKeepAlive,
|
|
8297
|
-
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a :
|
|
8465
|
+
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : currency.toString(),
|
|
8298
8466
|
destNode: destination
|
|
8299
8467
|
});
|
|
8300
|
-
case
|
|
8301
|
-
|
|
8468
|
+
case 40:
|
|
8469
|
+
currencyStr = _typeof(currency) === 'object' ? undefined : currency.toString();
|
|
8470
|
+
currencyId = assetCheckEnabled ? asset === null || asset === void 0 ? void 0 : asset.assetId : currencyStr;
|
|
8302
8471
|
return _context.abrupt("return", originNode.transfer({
|
|
8303
8472
|
api: apiWithFallback,
|
|
8304
8473
|
currencySymbol: asset === null || asset === void 0 ? void 0 : asset.symbol,
|
|
@@ -8307,9 +8476,10 @@ var sendCommon = function sendCommon(options) {
|
|
|
8307
8476
|
address: address,
|
|
8308
8477
|
destination: destination,
|
|
8309
8478
|
paraIdTo: paraIdTo,
|
|
8479
|
+
overridedCurrencyMultiLocation: _typeof(currency) === 'object' ? currency : undefined,
|
|
8310
8480
|
serializedApiCallEnabled: serializedApiCallEnabled
|
|
8311
8481
|
}));
|
|
8312
|
-
case
|
|
8482
|
+
case 43:
|
|
8313
8483
|
case "end":
|
|
8314
8484
|
return _context.stop();
|
|
8315
8485
|
}
|
|
@@ -8352,39 +8522,61 @@ var send = function send(options) {
|
|
|
8352
8522
|
};
|
|
8353
8523
|
var transferRelayToParaCommon = function transferRelayToParaCommon(options) {
|
|
8354
8524
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
8355
|
-
var api, destination, amount, address, paraIdTo, destApiForKeepAlive, _options$serializedAp2, serializedApiCallEnabled,
|
|
8525
|
+
var api, destination, amount, address, paraIdTo, destApiForKeepAlive, _options$serializedAp2, serializedApiCallEnabled, isMultiLocationDestination, isAddressMultiLocation, apiWithFallback, amountStr, serializedApiCall;
|
|
8356
8526
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
8357
8527
|
while (1) switch (_context4.prev = _context4.next) {
|
|
8358
8528
|
case 0:
|
|
8359
8529
|
api = options.api, destination = options.destination, amount = options.amount, address = options.address, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, _options$serializedAp2 = options.serializedApiCallEnabled, serializedApiCallEnabled = _options$serializedAp2 === void 0 ? false : _options$serializedAp2;
|
|
8360
|
-
|
|
8361
|
-
|
|
8530
|
+
isMultiLocationDestination = _typeof(destination) === 'object';
|
|
8531
|
+
isAddressMultiLocation = _typeof(address) === 'object';
|
|
8532
|
+
if (!(api === undefined && isMultiLocationDestination)) {
|
|
8533
|
+
_context4.next = 5;
|
|
8534
|
+
break;
|
|
8535
|
+
}
|
|
8536
|
+
throw new Error('API is required when using MultiLocation as destination.');
|
|
8537
|
+
case 5:
|
|
8362
8538
|
if (!(api !== null && api !== void 0)) {
|
|
8363
|
-
_context4.next =
|
|
8539
|
+
_context4.next = 9;
|
|
8364
8540
|
break;
|
|
8365
8541
|
}
|
|
8366
8542
|
_context4.t0 = api;
|
|
8367
|
-
_context4.next =
|
|
8543
|
+
_context4.next = 12;
|
|
8368
8544
|
break;
|
|
8369
|
-
case 7:
|
|
8370
|
-
_context4.next = 9;
|
|
8371
|
-
return createApiInstanceForNode(relayNode);
|
|
8372
8545
|
case 9:
|
|
8546
|
+
_context4.next = 11;
|
|
8547
|
+
return createApiInstanceForNode(determineRelayChain(destination));
|
|
8548
|
+
case 11:
|
|
8373
8549
|
_context4.t0 = _context4.sent;
|
|
8374
|
-
case
|
|
8550
|
+
case 12:
|
|
8375
8551
|
apiWithFallback = _context4.t0;
|
|
8376
8552
|
amountStr = amount.toString();
|
|
8377
|
-
|
|
8553
|
+
if (!isMultiLocationDestination) {
|
|
8554
|
+
_context4.next = 18;
|
|
8555
|
+
break;
|
|
8556
|
+
}
|
|
8557
|
+
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
8558
|
+
_context4.next = 24;
|
|
8559
|
+
break;
|
|
8560
|
+
case 18:
|
|
8561
|
+
if (!isAddressMultiLocation) {
|
|
8562
|
+
_context4.next = 22;
|
|
8563
|
+
break;
|
|
8564
|
+
}
|
|
8565
|
+
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
8566
|
+
_context4.next = 24;
|
|
8567
|
+
break;
|
|
8568
|
+
case 22:
|
|
8569
|
+
_context4.next = 24;
|
|
8378
8570
|
return checkKeepAlive({
|
|
8379
8571
|
originApi: apiWithFallback,
|
|
8380
8572
|
address: address,
|
|
8381
8573
|
amount: amountStr,
|
|
8382
8574
|
destApi: destApiForKeepAlive,
|
|
8383
|
-
currencySymbol:
|
|
8575
|
+
currencySymbol: getRelayChainSymbol(destination),
|
|
8384
8576
|
destNode: destination
|
|
8385
8577
|
});
|
|
8386
|
-
case
|
|
8387
|
-
serializedApiCall = getNode(destination).transferRelayToPara({
|
|
8578
|
+
case 24:
|
|
8579
|
+
serializedApiCall = getNode(isMultiLocationDestination ? resolveTNodeFromMultiLocation(destination) : destination).transferRelayToPara({
|
|
8388
8580
|
api: apiWithFallback,
|
|
8389
8581
|
destination: destination,
|
|
8390
8582
|
address: address,
|
|
@@ -8393,13 +8585,13 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options) {
|
|
|
8393
8585
|
destApiForKeepAlive: destApiForKeepAlive
|
|
8394
8586
|
});
|
|
8395
8587
|
if (!serializedApiCallEnabled) {
|
|
8396
|
-
_context4.next =
|
|
8588
|
+
_context4.next = 27;
|
|
8397
8589
|
break;
|
|
8398
8590
|
}
|
|
8399
8591
|
return _context4.abrupt("return", serializedApiCall);
|
|
8400
|
-
case
|
|
8592
|
+
case 27:
|
|
8401
8593
|
return _context4.abrupt("return", callPolkadotJsTxFunction(apiWithFallback, serializedApiCall));
|
|
8402
|
-
case
|
|
8594
|
+
case 28:
|
|
8403
8595
|
case "end":
|
|
8404
8596
|
return _context4.stop();
|
|
8405
8597
|
}
|