@paraspell/sdk 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.cjs +386 -173
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +386 -174
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -24,20 +24,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
24
24
|
});
|
|
25
25
|
return Constructor;
|
|
26
26
|
}
|
|
27
|
-
function _defineProperty(obj, key, value) {
|
|
28
|
-
key = _toPropertyKey(key);
|
|
29
|
-
if (key in obj) {
|
|
30
|
-
Object.defineProperty(obj, key, {
|
|
31
|
-
value: value,
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
obj[key] = value;
|
|
38
|
-
}
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
27
|
function _inherits(subClass, superClass) {
|
|
42
28
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
43
29
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -175,6 +161,57 @@ function _arrayLikeToArray(arr, len) {
|
|
|
175
161
|
function _nonIterableSpread() {
|
|
176
162
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
177
163
|
}
|
|
164
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
165
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
166
|
+
if (!it) {
|
|
167
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
168
|
+
if (it) o = it;
|
|
169
|
+
var i = 0;
|
|
170
|
+
var F = function () {};
|
|
171
|
+
return {
|
|
172
|
+
s: F,
|
|
173
|
+
n: function () {
|
|
174
|
+
if (i >= o.length) return {
|
|
175
|
+
done: true
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
done: false,
|
|
179
|
+
value: o[i++]
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
e: function (e) {
|
|
183
|
+
throw e;
|
|
184
|
+
},
|
|
185
|
+
f: F
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
189
|
+
}
|
|
190
|
+
var normalCompletion = true,
|
|
191
|
+
didErr = false,
|
|
192
|
+
err;
|
|
193
|
+
return {
|
|
194
|
+
s: function () {
|
|
195
|
+
it = it.call(o);
|
|
196
|
+
},
|
|
197
|
+
n: function () {
|
|
198
|
+
var step = it.next();
|
|
199
|
+
normalCompletion = step.done;
|
|
200
|
+
return step;
|
|
201
|
+
},
|
|
202
|
+
e: function (e) {
|
|
203
|
+
didErr = true;
|
|
204
|
+
err = e;
|
|
205
|
+
},
|
|
206
|
+
f: function () {
|
|
207
|
+
try {
|
|
208
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
209
|
+
} finally {
|
|
210
|
+
if (didErr) throw err;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
178
215
|
function _toPrimitive(input, hint) {
|
|
179
216
|
if (typeof input !== "object" || input === null) return input;
|
|
180
217
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -190,20 +227,6 @@ function _toPropertyKey(arg) {
|
|
|
190
227
|
return typeof key === "symbol" ? key : String(key);
|
|
191
228
|
}
|
|
192
229
|
|
|
193
|
-
// Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
|
|
194
|
-
var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
|
|
195
|
-
_inherits(NoXCMSupportImplementedError, _Error);
|
|
196
|
-
var _super = _createSuper(NoXCMSupportImplementedError);
|
|
197
|
-
function NoXCMSupportImplementedError(node) {
|
|
198
|
-
var _this;
|
|
199
|
-
_classCallCheck(this, NoXCMSupportImplementedError);
|
|
200
|
-
_this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
|
|
201
|
-
_this.name = 'NoXCMSupportImplemented';
|
|
202
|
-
return _this;
|
|
203
|
-
}
|
|
204
|
-
return _createClass(NoXCMSupportImplementedError);
|
|
205
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
206
|
-
|
|
207
230
|
var Acala$2 = {
|
|
208
231
|
paraId: 2000,
|
|
209
232
|
relayChainAssetSymbol: "DOT",
|
|
@@ -3537,67 +3560,19 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
|
3537
3560
|
default: assets
|
|
3538
3561
|
});
|
|
3539
3562
|
|
|
3540
|
-
|
|
3541
|
-
function
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
function
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
return
|
|
3552
|
-
}
|
|
3553
|
-
function getNativeAssets(node) {
|
|
3554
|
-
var info = getAssetsObject(node).nativeAssets;
|
|
3555
|
-
return info || [];
|
|
3556
|
-
}
|
|
3557
|
-
function getOtherAssets(node) {
|
|
3558
|
-
return getAssetsObject(node).otherAssets;
|
|
3559
|
-
}
|
|
3560
|
-
function getAllAssetsSymbols(node) {
|
|
3561
|
-
var _getAssetsObject = getAssetsObject(node),
|
|
3562
|
-
relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
|
|
3563
|
-
nativeAssets = _getAssetsObject.nativeAssets,
|
|
3564
|
-
otherAssets = _getAssetsObject.otherAssets;
|
|
3565
|
-
return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
|
|
3566
|
-
var symbol = _ref.symbol;
|
|
3567
|
-
return symbol;
|
|
3568
|
-
})), _toConsumableArray(otherAssets.map(function (_ref2) {
|
|
3569
|
-
var symbol = _ref2.symbol;
|
|
3570
|
-
return symbol;
|
|
3571
|
-
})));
|
|
3572
|
-
}
|
|
3573
|
-
function hasSupportForAsset(node, symbol) {
|
|
3574
|
-
return getAllAssetsSymbols(node).includes(symbol);
|
|
3575
|
-
}
|
|
3576
|
-
function getAssetDecimals(node, symbol) {
|
|
3577
|
-
var _getAssetsObject2 = getAssetsObject(node),
|
|
3578
|
-
otherAssets = _getAssetsObject2.otherAssets,
|
|
3579
|
-
nativeAssets = _getAssetsObject2.nativeAssets;
|
|
3580
|
-
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
|
|
3581
|
-
return o.symbol === symbol;
|
|
3582
|
-
});
|
|
3583
|
-
return asset ? asset.decimals : null;
|
|
3584
|
-
}
|
|
3585
|
-
function getParaId(node) {
|
|
3586
|
-
return getAssetsObject(node).paraId;
|
|
3587
|
-
}
|
|
3588
|
-
|
|
3589
|
-
var index$4 = /*#__PURE__*/Object.freeze({
|
|
3590
|
-
__proto__: null,
|
|
3591
|
-
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
3592
|
-
getAssetDecimals: getAssetDecimals,
|
|
3593
|
-
getAssetId: getAssetId,
|
|
3594
|
-
getAssetsObject: getAssetsObject,
|
|
3595
|
-
getNativeAssets: getNativeAssets,
|
|
3596
|
-
getOtherAssets: getOtherAssets,
|
|
3597
|
-
getParaId: getParaId,
|
|
3598
|
-
getRelayChainSymbol: getRelayChainSymbol,
|
|
3599
|
-
hasSupportForAsset: hasSupportForAsset
|
|
3600
|
-
});
|
|
3563
|
+
// Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
|
|
3564
|
+
var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
|
|
3565
|
+
_inherits(NoXCMSupportImplementedError, _Error);
|
|
3566
|
+
var _super = _createSuper(NoXCMSupportImplementedError);
|
|
3567
|
+
function NoXCMSupportImplementedError(node) {
|
|
3568
|
+
var _this;
|
|
3569
|
+
_classCallCheck(this, NoXCMSupportImplementedError);
|
|
3570
|
+
_this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
|
|
3571
|
+
_this.name = 'NoXCMSupportImplemented';
|
|
3572
|
+
return _this;
|
|
3573
|
+
}
|
|
3574
|
+
return _createClass(NoXCMSupportImplementedError);
|
|
3575
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
3601
3576
|
|
|
3602
3577
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
3603
3578
|
return 'transferXTokens' in obj;
|
|
@@ -4706,6 +4681,83 @@ var nodes = {
|
|
|
4706
4681
|
};
|
|
4707
4682
|
var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm'];
|
|
4708
4683
|
|
|
4684
|
+
var assetsMap = assetsMapJson;
|
|
4685
|
+
function getAssetsObject(node) {
|
|
4686
|
+
return assetsMap[node];
|
|
4687
|
+
}
|
|
4688
|
+
function getAssetId(node, symbol) {
|
|
4689
|
+
var info = getAssetsObject(node).otherAssets.find(function (o) {
|
|
4690
|
+
return o.symbol === symbol;
|
|
4691
|
+
});
|
|
4692
|
+
return info ? info.assetId : null;
|
|
4693
|
+
}
|
|
4694
|
+
function getRelayChainSymbol(node) {
|
|
4695
|
+
return getAssetsObject(node).relayChainAssetSymbol;
|
|
4696
|
+
}
|
|
4697
|
+
function getNativeAssets(node) {
|
|
4698
|
+
var info = getAssetsObject(node).nativeAssets;
|
|
4699
|
+
return info || [];
|
|
4700
|
+
}
|
|
4701
|
+
function getOtherAssets(node) {
|
|
4702
|
+
return getAssetsObject(node).otherAssets;
|
|
4703
|
+
}
|
|
4704
|
+
function getAllAssetsSymbols(node) {
|
|
4705
|
+
var _getAssetsObject = getAssetsObject(node),
|
|
4706
|
+
relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
|
|
4707
|
+
nativeAssets = _getAssetsObject.nativeAssets,
|
|
4708
|
+
otherAssets = _getAssetsObject.otherAssets;
|
|
4709
|
+
return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
|
|
4710
|
+
var symbol = _ref.symbol;
|
|
4711
|
+
return symbol;
|
|
4712
|
+
})), _toConsumableArray(otherAssets.map(function (_ref2) {
|
|
4713
|
+
var symbol = _ref2.symbol;
|
|
4714
|
+
return symbol;
|
|
4715
|
+
})));
|
|
4716
|
+
}
|
|
4717
|
+
function hasSupportForAsset(node, symbol) {
|
|
4718
|
+
return getAllAssetsSymbols(node).includes(symbol);
|
|
4719
|
+
}
|
|
4720
|
+
function getAssetDecimals(node, symbol) {
|
|
4721
|
+
var _getAssetsObject2 = getAssetsObject(node),
|
|
4722
|
+
otherAssets = _getAssetsObject2.otherAssets,
|
|
4723
|
+
nativeAssets = _getAssetsObject2.nativeAssets;
|
|
4724
|
+
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
|
|
4725
|
+
return o.symbol === symbol;
|
|
4726
|
+
});
|
|
4727
|
+
return asset ? asset.decimals : null;
|
|
4728
|
+
}
|
|
4729
|
+
function getParaId(node) {
|
|
4730
|
+
return getAssetsObject(node).paraId;
|
|
4731
|
+
}
|
|
4732
|
+
function getTNode(nodeID) {
|
|
4733
|
+
var _iterator = _createForOfIteratorHelper(NODE_NAMES),
|
|
4734
|
+
_step;
|
|
4735
|
+
try {
|
|
4736
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4737
|
+
var node = _step.value;
|
|
4738
|
+
if (getParaId(node) === nodeID) return node;
|
|
4739
|
+
}
|
|
4740
|
+
} catch (err) {
|
|
4741
|
+
_iterator.e(err);
|
|
4742
|
+
} finally {
|
|
4743
|
+
_iterator.f();
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4747
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
4748
|
+
__proto__: null,
|
|
4749
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
4750
|
+
getAssetDecimals: getAssetDecimals,
|
|
4751
|
+
getAssetId: getAssetId,
|
|
4752
|
+
getAssetsObject: getAssetsObject,
|
|
4753
|
+
getNativeAssets: getNativeAssets,
|
|
4754
|
+
getOtherAssets: getOtherAssets,
|
|
4755
|
+
getParaId: getParaId,
|
|
4756
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
4757
|
+
getTNode: getTNode,
|
|
4758
|
+
hasSupportForAsset: hasSupportForAsset
|
|
4759
|
+
});
|
|
4760
|
+
|
|
4709
4761
|
function createAccID(api, account) {
|
|
4710
4762
|
console.log('Generating AccountId32 address');
|
|
4711
4763
|
return api.createType('AccountId32', account).toHex();
|
|
@@ -4806,17 +4858,34 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4806
4858
|
}
|
|
4807
4859
|
if (scenario === 'ParaToRelay' && pallet === 'polkadotXCM') {
|
|
4808
4860
|
console.log('AccountId32 transfer');
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4861
|
+
if (node === 'Statemine') {
|
|
4862
|
+
return {
|
|
4863
|
+
V3: {
|
|
4864
|
+
parents: 0,
|
|
4865
|
+
interior: {
|
|
4866
|
+
X1: {
|
|
4867
|
+
AccountId32: {
|
|
4868
|
+
id: createAccID(api, to)
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4816
4871
|
}
|
|
4817
4872
|
}
|
|
4818
|
-
}
|
|
4819
|
-
}
|
|
4873
|
+
};
|
|
4874
|
+
} else {
|
|
4875
|
+
return {
|
|
4876
|
+
V1: {
|
|
4877
|
+
parents: 0,
|
|
4878
|
+
interior: {
|
|
4879
|
+
X1: {
|
|
4880
|
+
AccountId32: {
|
|
4881
|
+
network: 'any',
|
|
4882
|
+
id: createAccID(api, to)
|
|
4883
|
+
}
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
};
|
|
4888
|
+
}
|
|
4820
4889
|
}
|
|
4821
4890
|
if (scenario === 'ParaToPara' && pallet === 'polkadotXCM') {
|
|
4822
4891
|
if (node === 'Quartz') {
|
|
@@ -4833,82 +4902,163 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4833
4902
|
}
|
|
4834
4903
|
if (ethers.utils.isAddress(to)) {
|
|
4835
4904
|
console.log('AccountKey20 transfer');
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4905
|
+
if (node === 'Statemine') {
|
|
4906
|
+
return {
|
|
4907
|
+
V3: {
|
|
4908
|
+
parents: 0,
|
|
4909
|
+
interior: {
|
|
4910
|
+
X1: {
|
|
4911
|
+
AccountKey20: {
|
|
4912
|
+
key: to
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4843
4915
|
}
|
|
4844
4916
|
}
|
|
4845
|
-
}
|
|
4846
|
-
}
|
|
4917
|
+
};
|
|
4918
|
+
} else {
|
|
4919
|
+
return {
|
|
4920
|
+
V1: {
|
|
4921
|
+
parents: 0,
|
|
4922
|
+
interior: {
|
|
4923
|
+
X1: {
|
|
4924
|
+
AccountKey20: {
|
|
4925
|
+
network: 'Any',
|
|
4926
|
+
key: to
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
};
|
|
4932
|
+
}
|
|
4847
4933
|
} else {
|
|
4848
4934
|
console.log('AccountId32 transfer');
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4935
|
+
if (node === 'Statemine') {
|
|
4936
|
+
return {
|
|
4937
|
+
V3: {
|
|
4938
|
+
parents: 0,
|
|
4939
|
+
interior: {
|
|
4940
|
+
X1: {
|
|
4941
|
+
AccountId32: {
|
|
4942
|
+
id: createAccID(api, to)
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4856
4945
|
}
|
|
4857
4946
|
}
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4947
|
+
};
|
|
4948
|
+
} else {
|
|
4949
|
+
return {
|
|
4950
|
+
V1: {
|
|
4951
|
+
parents: 0,
|
|
4952
|
+
interior: {
|
|
4953
|
+
X1: {
|
|
4954
|
+
AccountId32: {
|
|
4955
|
+
network: 'Any',
|
|
4956
|
+
id: createAccID(api, to)
|
|
4957
|
+
}
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
};
|
|
4962
|
+
}
|
|
4860
4963
|
}
|
|
4861
4964
|
}
|
|
4862
4965
|
if (scenario === 'RelayToPara') {
|
|
4966
|
+
var asset = getRelayChainSymbol(node);
|
|
4863
4967
|
if (ethers.utils.isAddress(to)) {
|
|
4864
4968
|
console.log('AccountKey20 transfer');
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4969
|
+
if (asset === 'KSM') {
|
|
4970
|
+
return {
|
|
4971
|
+
V3: {
|
|
4972
|
+
parents: 0,
|
|
4973
|
+
interior: {
|
|
4974
|
+
X1: {
|
|
4975
|
+
AccountKey20: {
|
|
4976
|
+
key: to
|
|
4977
|
+
}
|
|
4873
4978
|
}
|
|
4874
4979
|
}
|
|
4875
4980
|
}
|
|
4876
|
-
}
|
|
4877
|
-
}
|
|
4981
|
+
};
|
|
4982
|
+
} else {
|
|
4983
|
+
return {
|
|
4984
|
+
V1: {
|
|
4985
|
+
parents: 0,
|
|
4986
|
+
interior: {
|
|
4987
|
+
X1: {
|
|
4988
|
+
AccountKey20: {
|
|
4989
|
+
network: 'Any',
|
|
4990
|
+
key: to
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
}
|
|
4995
|
+
};
|
|
4996
|
+
}
|
|
4878
4997
|
} else {
|
|
4879
4998
|
console.log('AccountId32 transfer');
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4999
|
+
if (asset === 'KSM') {
|
|
5000
|
+
return {
|
|
5001
|
+
V3: {
|
|
5002
|
+
parents: 0,
|
|
5003
|
+
interior: {
|
|
5004
|
+
X1: {
|
|
5005
|
+
AccountId32: {
|
|
5006
|
+
id: createAccID(api, to)
|
|
5007
|
+
}
|
|
4888
5008
|
}
|
|
4889
5009
|
}
|
|
4890
5010
|
}
|
|
4891
|
-
}
|
|
4892
|
-
}
|
|
5011
|
+
};
|
|
5012
|
+
} else {
|
|
5013
|
+
return {
|
|
5014
|
+
V1: {
|
|
5015
|
+
parents: 0,
|
|
5016
|
+
interior: {
|
|
5017
|
+
X1: {
|
|
5018
|
+
AccountId32: {
|
|
5019
|
+
network: 'Any',
|
|
5020
|
+
id: createAccID(api, to)
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
};
|
|
5026
|
+
}
|
|
4893
5027
|
}
|
|
4894
5028
|
}
|
|
4895
5029
|
}
|
|
4896
5030
|
function createCurrencySpecification(amount, scenario, node, cur) {
|
|
4897
5031
|
if (scenario === 'ParaToRelay') {
|
|
4898
5032
|
console.log('polkadotXCM transfer in native currency to Relay chain');
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5033
|
+
if (node === 'Statemine') {
|
|
5034
|
+
return {
|
|
5035
|
+
V3: [{
|
|
5036
|
+
id: {
|
|
5037
|
+
Concrete: {
|
|
5038
|
+
parents: 1,
|
|
5039
|
+
interior: 'Here'
|
|
5040
|
+
}
|
|
5041
|
+
},
|
|
5042
|
+
fun: {
|
|
5043
|
+
Fungible: amount
|
|
4905
5044
|
}
|
|
4906
|
-
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
5045
|
+
}]
|
|
5046
|
+
};
|
|
5047
|
+
} else {
|
|
5048
|
+
return {
|
|
5049
|
+
V1: [{
|
|
5050
|
+
id: {
|
|
5051
|
+
Concrete: {
|
|
5052
|
+
parents: 1,
|
|
5053
|
+
interior: 'Here'
|
|
5054
|
+
}
|
|
5055
|
+
},
|
|
5056
|
+
fun: {
|
|
5057
|
+
Fungible: amount
|
|
5058
|
+
}
|
|
5059
|
+
}]
|
|
5060
|
+
};
|
|
5061
|
+
}
|
|
4912
5062
|
}
|
|
4913
5063
|
if (scenario === 'RelayToPara' || scenario === 'ParaToPara') {
|
|
4914
5064
|
console.log('polkadotXCM Native currency to sender chain transfer');
|
|
@@ -4943,18 +5093,57 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4943
5093
|
};
|
|
4944
5094
|
} else if ((node === 'Statemint' || node === 'Statemine') && scenario === 'ParaToPara') {
|
|
4945
5095
|
// Another specific case for Statemint & Statemine to send for example USDt
|
|
5096
|
+
if (node === 'Statemine') {
|
|
5097
|
+
return {
|
|
5098
|
+
V3: [{
|
|
5099
|
+
id: {
|
|
5100
|
+
Concrete: {
|
|
5101
|
+
parents: 0,
|
|
5102
|
+
interior: {
|
|
5103
|
+
X2: [{
|
|
5104
|
+
PalletInstance: 50
|
|
5105
|
+
}, {
|
|
5106
|
+
GeneralIndex: cur
|
|
5107
|
+
}]
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
},
|
|
5111
|
+
fun: {
|
|
5112
|
+
Fungible: amount
|
|
5113
|
+
}
|
|
5114
|
+
}]
|
|
5115
|
+
};
|
|
5116
|
+
} else {
|
|
5117
|
+
return {
|
|
5118
|
+
V1: [{
|
|
5119
|
+
id: {
|
|
5120
|
+
Concrete: {
|
|
5121
|
+
parents: 0,
|
|
5122
|
+
interior: {
|
|
5123
|
+
X2: [{
|
|
5124
|
+
PalletInstance: 50
|
|
5125
|
+
}, {
|
|
5126
|
+
GeneralIndex: cur
|
|
5127
|
+
}]
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
},
|
|
5131
|
+
fun: {
|
|
5132
|
+
Fungible: amount
|
|
5133
|
+
}
|
|
5134
|
+
}]
|
|
5135
|
+
};
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
// Otherwise
|
|
5139
|
+
var asset = getRelayChainSymbol(node);
|
|
5140
|
+
if (asset === 'KSM') {
|
|
4946
5141
|
return {
|
|
4947
|
-
|
|
5142
|
+
V3: [{
|
|
4948
5143
|
id: {
|
|
4949
5144
|
Concrete: {
|
|
4950
5145
|
parents: 0,
|
|
4951
|
-
interior:
|
|
4952
|
-
X2: [{
|
|
4953
|
-
PalletInstance: 50
|
|
4954
|
-
}, {
|
|
4955
|
-
GeneralIndex: cur
|
|
4956
|
-
}]
|
|
4957
|
-
}
|
|
5146
|
+
interior: 'Here'
|
|
4958
5147
|
}
|
|
4959
5148
|
},
|
|
4960
5149
|
fun: {
|
|
@@ -4963,7 +5152,6 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4963
5152
|
}]
|
|
4964
5153
|
};
|
|
4965
5154
|
}
|
|
4966
|
-
// Otherwise
|
|
4967
5155
|
return {
|
|
4968
5156
|
V1: [{
|
|
4969
5157
|
id: {
|
|
@@ -4982,12 +5170,21 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4982
5170
|
function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
4983
5171
|
console.log('Generating header for polkadotXCM transfer');
|
|
4984
5172
|
if (scenario === 'ParaToRelay') {
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
5173
|
+
if (node === 'Statemine') {
|
|
5174
|
+
return {
|
|
5175
|
+
V3: {
|
|
5176
|
+
parents: 1,
|
|
5177
|
+
interior: 'Here'
|
|
5178
|
+
}
|
|
5179
|
+
};
|
|
5180
|
+
} else {
|
|
5181
|
+
return {
|
|
5182
|
+
V1: {
|
|
5183
|
+
parents: 1,
|
|
5184
|
+
interior: 'Here'
|
|
5185
|
+
}
|
|
5186
|
+
};
|
|
5187
|
+
}
|
|
4991
5188
|
}
|
|
4992
5189
|
if (scenario === 'ParaToPara') {
|
|
4993
5190
|
if (node === 'Quartz') {
|
|
@@ -5011,16 +5208,31 @@ function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
|
5011
5208
|
};
|
|
5012
5209
|
}
|
|
5013
5210
|
if (scenario === 'RelayToPara') {
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5211
|
+
//We check nodeID currency (IF KSM then V3 IF DOT then V1)
|
|
5212
|
+
var asset = getRelayChainSymbol(node);
|
|
5213
|
+
if (asset === 'KSM') {
|
|
5214
|
+
return {
|
|
5215
|
+
V3: {
|
|
5216
|
+
parents: 0,
|
|
5217
|
+
interior: {
|
|
5218
|
+
X1: {
|
|
5219
|
+
Parachain: nodeId
|
|
5220
|
+
}
|
|
5020
5221
|
}
|
|
5021
5222
|
}
|
|
5022
|
-
}
|
|
5023
|
-
}
|
|
5223
|
+
};
|
|
5224
|
+
} else {
|
|
5225
|
+
return {
|
|
5226
|
+
V1: {
|
|
5227
|
+
parents: 0,
|
|
5228
|
+
interior: {
|
|
5229
|
+
X1: {
|
|
5230
|
+
Parachain: nodeId
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
}
|
|
5234
|
+
};
|
|
5235
|
+
}
|
|
5024
5236
|
}
|
|
5025
5237
|
}
|
|
5026
5238
|
function getNode(node) {
|
|
@@ -5083,9 +5295,9 @@ function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
|
5083
5295
|
}
|
|
5084
5296
|
function transferRelayToPara(api, destination, amount, to) {
|
|
5085
5297
|
var paraId = getParaId(destination);
|
|
5086
|
-
if (destination === 'Statemine' || destination === 'Encointer') {
|
|
5298
|
+
if (destination === 'Statemint' || destination === 'Statemine' || destination === 'Encointer') {
|
|
5087
5299
|
// Same for Statemint, Statemine and Encoiter
|
|
5088
|
-
return api.tx.xcmPallet.limitedTeleportAssets(createHeaderPolkadotXCM('RelayToPara', paraId), handleAddress('RelayToPara', '', api, to, paraId), createCurrencySpecification(amount, 'RelayToPara'), 0, 'Unlimited');
|
|
5300
|
+
return api.tx.xcmPallet.limitedTeleportAssets(createHeaderPolkadotXCM('RelayToPara', paraId, destination), handleAddress('RelayToPara', '', api, to, paraId, destination), createCurrencySpecification(amount, 'RelayToPara', destination), 0, 'Unlimited');
|
|
5089
5301
|
} else if (destination === 'Darwinia' || destination === 'Crab' || destination === 'Quartz') {
|
|
5090
5302
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered Quartz does not work with UMP & DMP too
|
|
5091
5303
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
@@ -6029,4 +6241,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6029
6241
|
return palletsMap[node].supportedPallets;
|
|
6030
6242
|
};
|
|
6031
6243
|
|
|
6032
|
-
export { Builder, NODE_NAMES, SUPPORTED_PALLETS, index$4 as assets, index as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };
|
|
6244
|
+
export { Builder, NODE_NAMES, SUPPORTED_PALLETS, index$4 as assets, index as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };
|