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