@paraspell/sdk 1.1.9 → 1.1.10
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 +144 -186
- package/dist/index.mjs +144 -186
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -229,6 +229,42 @@ function _toPropertyKey(arg) {
|
|
|
229
229
|
return typeof key === "symbol" ? key : String(key);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/******************************************************************************
|
|
233
|
+
Copyright (c) Microsoft Corporation.
|
|
234
|
+
|
|
235
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
236
|
+
purpose with or without fee is hereby granted.
|
|
237
|
+
|
|
238
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
239
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
240
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
241
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
242
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
243
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
244
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
245
|
+
***************************************************************************** */
|
|
246
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
250
|
+
var e = new Error(message);
|
|
251
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
|
|
255
|
+
var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
|
|
256
|
+
_inherits(NoXCMSupportImplementedError, _Error);
|
|
257
|
+
var _super = _createSuper(NoXCMSupportImplementedError);
|
|
258
|
+
function NoXCMSupportImplementedError(node) {
|
|
259
|
+
var _this;
|
|
260
|
+
_classCallCheck(this, NoXCMSupportImplementedError);
|
|
261
|
+
_this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
|
|
262
|
+
_this.name = 'NoXCMSupportImplemented';
|
|
263
|
+
return _this;
|
|
264
|
+
}
|
|
265
|
+
return _createClass(NoXCMSupportImplementedError);
|
|
266
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
267
|
+
|
|
232
268
|
var Acala$2 = {
|
|
233
269
|
paraId: 2000,
|
|
234
270
|
relayChainAssetSymbol: "DOT",
|
|
@@ -3562,19 +3598,82 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
|
3562
3598
|
default: assets
|
|
3563
3599
|
});
|
|
3564
3600
|
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3601
|
+
var assetsMap = assetsMapJson;
|
|
3602
|
+
function getAssetsObject(node) {
|
|
3603
|
+
return assetsMap[node];
|
|
3604
|
+
}
|
|
3605
|
+
function getAssetId(node, symbol) {
|
|
3606
|
+
var info = getAssetsObject(node).otherAssets.find(function (o) {
|
|
3607
|
+
return o.symbol === symbol;
|
|
3608
|
+
});
|
|
3609
|
+
return info ? info.assetId : null;
|
|
3610
|
+
}
|
|
3611
|
+
function getRelayChainSymbol(node) {
|
|
3612
|
+
return getAssetsObject(node).relayChainAssetSymbol;
|
|
3613
|
+
}
|
|
3614
|
+
function getNativeAssets(node) {
|
|
3615
|
+
var info = getAssetsObject(node).nativeAssets;
|
|
3616
|
+
return info || [];
|
|
3617
|
+
}
|
|
3618
|
+
function getOtherAssets(node) {
|
|
3619
|
+
return getAssetsObject(node).otherAssets;
|
|
3620
|
+
}
|
|
3621
|
+
function getAllAssetsSymbols(node) {
|
|
3622
|
+
var _getAssetsObject = getAssetsObject(node),
|
|
3623
|
+
relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
|
|
3624
|
+
nativeAssets = _getAssetsObject.nativeAssets,
|
|
3625
|
+
otherAssets = _getAssetsObject.otherAssets;
|
|
3626
|
+
return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
|
|
3627
|
+
var symbol = _ref.symbol;
|
|
3628
|
+
return symbol;
|
|
3629
|
+
})), _toConsumableArray(otherAssets.map(function (_ref2) {
|
|
3630
|
+
var symbol = _ref2.symbol;
|
|
3631
|
+
return symbol;
|
|
3632
|
+
})));
|
|
3633
|
+
}
|
|
3634
|
+
function hasSupportForAsset(node, symbol) {
|
|
3635
|
+
return getAllAssetsSymbols(node).includes(symbol);
|
|
3636
|
+
}
|
|
3637
|
+
function getAssetDecimals(node, symbol) {
|
|
3638
|
+
var _getAssetsObject2 = getAssetsObject(node),
|
|
3639
|
+
otherAssets = _getAssetsObject2.otherAssets,
|
|
3640
|
+
nativeAssets = _getAssetsObject2.nativeAssets;
|
|
3641
|
+
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
|
|
3642
|
+
return o.symbol === symbol;
|
|
3643
|
+
});
|
|
3644
|
+
return asset ? asset.decimals : null;
|
|
3645
|
+
}
|
|
3646
|
+
function getParaId(node) {
|
|
3647
|
+
return getAssetsObject(node).paraId;
|
|
3648
|
+
}
|
|
3649
|
+
function getTNode(nodeID) {
|
|
3650
|
+
var _iterator = _createForOfIteratorHelper(NODE_NAMES),
|
|
3651
|
+
_step;
|
|
3652
|
+
try {
|
|
3653
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3654
|
+
var node = _step.value;
|
|
3655
|
+
if (getParaId(node) === nodeID) return node;
|
|
3656
|
+
}
|
|
3657
|
+
} catch (err) {
|
|
3658
|
+
_iterator.e(err);
|
|
3659
|
+
} finally {
|
|
3660
|
+
_iterator.f();
|
|
3575
3661
|
}
|
|
3576
|
-
|
|
3577
|
-
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
3665
|
+
__proto__: null,
|
|
3666
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
3667
|
+
getAssetDecimals: getAssetDecimals,
|
|
3668
|
+
getAssetId: getAssetId,
|
|
3669
|
+
getAssetsObject: getAssetsObject,
|
|
3670
|
+
getNativeAssets: getNativeAssets,
|
|
3671
|
+
getOtherAssets: getOtherAssets,
|
|
3672
|
+
getParaId: getParaId,
|
|
3673
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
3674
|
+
getTNode: getTNode,
|
|
3675
|
+
hasSupportForAsset: hasSupportForAsset
|
|
3676
|
+
});
|
|
3578
3677
|
|
|
3579
3678
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
3580
3679
|
return 'transferXTokens' in obj;
|
|
@@ -4683,83 +4782,6 @@ var nodes = {
|
|
|
4683
4782
|
};
|
|
4684
4783
|
var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm'];
|
|
4685
4784
|
|
|
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
|
-
|
|
4763
4785
|
function createAccID(api, account) {
|
|
4764
4786
|
console.log('Generating AccountId32 address');
|
|
4765
4787
|
return api.createType('AccountId32', account).toHex();
|
|
@@ -4860,7 +4882,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4860
4882
|
}
|
|
4861
4883
|
if (scenario === 'ParaToRelay' && pallet === 'polkadotXCM') {
|
|
4862
4884
|
console.log('AccountId32 transfer');
|
|
4863
|
-
if (node === 'Statemine') {
|
|
4885
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4864
4886
|
return {
|
|
4865
4887
|
V3: {
|
|
4866
4888
|
parents: 0,
|
|
@@ -4904,7 +4926,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4904
4926
|
}
|
|
4905
4927
|
if (ethers.ethers.utils.isAddress(to)) {
|
|
4906
4928
|
console.log('AccountKey20 transfer');
|
|
4907
|
-
if (node === 'Statemine') {
|
|
4929
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4908
4930
|
return {
|
|
4909
4931
|
V3: {
|
|
4910
4932
|
parents: 0,
|
|
@@ -4934,7 +4956,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4934
4956
|
}
|
|
4935
4957
|
} else {
|
|
4936
4958
|
console.log('AccountId32 transfer');
|
|
4937
|
-
if (node === 'Statemine') {
|
|
4959
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4938
4960
|
return {
|
|
4939
4961
|
V3: {
|
|
4940
4962
|
parents: 0,
|
|
@@ -4965,74 +4987,41 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4965
4987
|
}
|
|
4966
4988
|
}
|
|
4967
4989
|
if (scenario === 'RelayToPara') {
|
|
4968
|
-
var asset = getRelayChainSymbol(node);
|
|
4969
4990
|
if (ethers.ethers.utils.isAddress(to)) {
|
|
4970
4991
|
console.log('AccountKey20 transfer');
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
key: to
|
|
4979
|
-
}
|
|
4980
|
-
}
|
|
4981
|
-
}
|
|
4982
|
-
}
|
|
4983
|
-
};
|
|
4984
|
-
} else {
|
|
4985
|
-
return {
|
|
4986
|
-
V1: {
|
|
4987
|
-
parents: 0,
|
|
4988
|
-
interior: {
|
|
4989
|
-
X1: {
|
|
4990
|
-
AccountKey20: {
|
|
4991
|
-
network: 'Any',
|
|
4992
|
-
key: to
|
|
4993
|
-
}
|
|
4992
|
+
return {
|
|
4993
|
+
V3: {
|
|
4994
|
+
parents: 0,
|
|
4995
|
+
interior: {
|
|
4996
|
+
X1: {
|
|
4997
|
+
AccountKey20: {
|
|
4998
|
+
key: to
|
|
4994
4999
|
}
|
|
4995
5000
|
}
|
|
4996
5001
|
}
|
|
4997
|
-
}
|
|
4998
|
-
}
|
|
5002
|
+
}
|
|
5003
|
+
};
|
|
4999
5004
|
} else {
|
|
5000
5005
|
console.log('AccountId32 transfer');
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
id: createAccID(api, to)
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
5011
|
-
}
|
|
5012
|
-
}
|
|
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
|
-
}
|
|
5006
|
+
return {
|
|
5007
|
+
V3: {
|
|
5008
|
+
parents: 0,
|
|
5009
|
+
interior: {
|
|
5010
|
+
X1: {
|
|
5011
|
+
AccountId32: {
|
|
5012
|
+
id: createAccID(api, to)
|
|
5024
5013
|
}
|
|
5025
5014
|
}
|
|
5026
5015
|
}
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5016
|
+
}
|
|
5017
|
+
};
|
|
5029
5018
|
}
|
|
5030
5019
|
}
|
|
5031
5020
|
}
|
|
5032
5021
|
function createCurrencySpecification(amount, scenario, node, cur) {
|
|
5033
5022
|
if (scenario === 'ParaToRelay') {
|
|
5034
5023
|
console.log('polkadotXCM transfer in native currency to Relay chain');
|
|
5035
|
-
if (node === 'Statemine') {
|
|
5024
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5036
5025
|
return {
|
|
5037
5026
|
V3: [{
|
|
5038
5027
|
id: {
|
|
@@ -5095,7 +5084,7 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5095
5084
|
};
|
|
5096
5085
|
} else if ((node === 'Statemint' || node === 'Statemine') && scenario === 'ParaToPara') {
|
|
5097
5086
|
// Another specific case for Statemint & Statemine to send for example USDt
|
|
5098
|
-
if (node === 'Statemine') {
|
|
5087
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5099
5088
|
return {
|
|
5100
5089
|
V3: [{
|
|
5101
5090
|
id: {
|
|
@@ -5138,24 +5127,8 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5138
5127
|
}
|
|
5139
5128
|
}
|
|
5140
5129
|
// Otherwise
|
|
5141
|
-
var asset = getRelayChainSymbol(node);
|
|
5142
|
-
if (asset === 'KSM') {
|
|
5143
|
-
return {
|
|
5144
|
-
V3: [{
|
|
5145
|
-
id: {
|
|
5146
|
-
Concrete: {
|
|
5147
|
-
parents: 0,
|
|
5148
|
-
interior: 'Here'
|
|
5149
|
-
}
|
|
5150
|
-
},
|
|
5151
|
-
fun: {
|
|
5152
|
-
Fungible: amount
|
|
5153
|
-
}
|
|
5154
|
-
}]
|
|
5155
|
-
};
|
|
5156
|
-
}
|
|
5157
5130
|
return {
|
|
5158
|
-
|
|
5131
|
+
V3: [{
|
|
5159
5132
|
id: {
|
|
5160
5133
|
Concrete: {
|
|
5161
5134
|
parents: 0,
|
|
@@ -5172,7 +5145,7 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5172
5145
|
function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
5173
5146
|
console.log('Generating header for polkadotXCM transfer');
|
|
5174
5147
|
if (scenario === 'ParaToRelay') {
|
|
5175
|
-
if (node === 'Statemine') {
|
|
5148
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5176
5149
|
return {
|
|
5177
5150
|
V3: {
|
|
5178
5151
|
parents: 1,
|
|
@@ -5210,31 +5183,16 @@ function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
|
5210
5183
|
};
|
|
5211
5184
|
}
|
|
5212
5185
|
if (scenario === 'RelayToPara') {
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
interior: {
|
|
5220
|
-
X1: {
|
|
5221
|
-
Parachain: nodeId
|
|
5222
|
-
}
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5225
|
-
};
|
|
5226
|
-
} else {
|
|
5227
|
-
return {
|
|
5228
|
-
V1: {
|
|
5229
|
-
parents: 0,
|
|
5230
|
-
interior: {
|
|
5231
|
-
X1: {
|
|
5232
|
-
Parachain: nodeId
|
|
5233
|
-
}
|
|
5186
|
+
return {
|
|
5187
|
+
V3: {
|
|
5188
|
+
parents: 0,
|
|
5189
|
+
interior: {
|
|
5190
|
+
X1: {
|
|
5191
|
+
Parachain: nodeId
|
|
5234
5192
|
}
|
|
5235
5193
|
}
|
|
5236
|
-
}
|
|
5237
|
-
}
|
|
5194
|
+
}
|
|
5195
|
+
};
|
|
5238
5196
|
}
|
|
5239
5197
|
}
|
|
5240
5198
|
function getNode(node) {
|
package/dist/index.mjs
CHANGED
|
@@ -227,6 +227,42 @@ function _toPropertyKey(arg) {
|
|
|
227
227
|
return typeof key === "symbol" ? key : String(key);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
/******************************************************************************
|
|
231
|
+
Copyright (c) Microsoft Corporation.
|
|
232
|
+
|
|
233
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
234
|
+
purpose with or without fee is hereby granted.
|
|
235
|
+
|
|
236
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
237
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
238
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
239
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
240
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
241
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
242
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
243
|
+
***************************************************************************** */
|
|
244
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
248
|
+
var e = new Error(message);
|
|
249
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
|
|
253
|
+
var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
|
|
254
|
+
_inherits(NoXCMSupportImplementedError, _Error);
|
|
255
|
+
var _super = _createSuper(NoXCMSupportImplementedError);
|
|
256
|
+
function NoXCMSupportImplementedError(node) {
|
|
257
|
+
var _this;
|
|
258
|
+
_classCallCheck(this, NoXCMSupportImplementedError);
|
|
259
|
+
_this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
|
|
260
|
+
_this.name = 'NoXCMSupportImplemented';
|
|
261
|
+
return _this;
|
|
262
|
+
}
|
|
263
|
+
return _createClass(NoXCMSupportImplementedError);
|
|
264
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
265
|
+
|
|
230
266
|
var Acala$2 = {
|
|
231
267
|
paraId: 2000,
|
|
232
268
|
relayChainAssetSymbol: "DOT",
|
|
@@ -3560,19 +3596,82 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
|
3560
3596
|
default: assets
|
|
3561
3597
|
});
|
|
3562
3598
|
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3599
|
+
var assetsMap = assetsMapJson;
|
|
3600
|
+
function getAssetsObject(node) {
|
|
3601
|
+
return assetsMap[node];
|
|
3602
|
+
}
|
|
3603
|
+
function getAssetId(node, symbol) {
|
|
3604
|
+
var info = getAssetsObject(node).otherAssets.find(function (o) {
|
|
3605
|
+
return o.symbol === symbol;
|
|
3606
|
+
});
|
|
3607
|
+
return info ? info.assetId : null;
|
|
3608
|
+
}
|
|
3609
|
+
function getRelayChainSymbol(node) {
|
|
3610
|
+
return getAssetsObject(node).relayChainAssetSymbol;
|
|
3611
|
+
}
|
|
3612
|
+
function getNativeAssets(node) {
|
|
3613
|
+
var info = getAssetsObject(node).nativeAssets;
|
|
3614
|
+
return info || [];
|
|
3615
|
+
}
|
|
3616
|
+
function getOtherAssets(node) {
|
|
3617
|
+
return getAssetsObject(node).otherAssets;
|
|
3618
|
+
}
|
|
3619
|
+
function getAllAssetsSymbols(node) {
|
|
3620
|
+
var _getAssetsObject = getAssetsObject(node),
|
|
3621
|
+
relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
|
|
3622
|
+
nativeAssets = _getAssetsObject.nativeAssets,
|
|
3623
|
+
otherAssets = _getAssetsObject.otherAssets;
|
|
3624
|
+
return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
|
|
3625
|
+
var symbol = _ref.symbol;
|
|
3626
|
+
return symbol;
|
|
3627
|
+
})), _toConsumableArray(otherAssets.map(function (_ref2) {
|
|
3628
|
+
var symbol = _ref2.symbol;
|
|
3629
|
+
return symbol;
|
|
3630
|
+
})));
|
|
3631
|
+
}
|
|
3632
|
+
function hasSupportForAsset(node, symbol) {
|
|
3633
|
+
return getAllAssetsSymbols(node).includes(symbol);
|
|
3634
|
+
}
|
|
3635
|
+
function getAssetDecimals(node, symbol) {
|
|
3636
|
+
var _getAssetsObject2 = getAssetsObject(node),
|
|
3637
|
+
otherAssets = _getAssetsObject2.otherAssets,
|
|
3638
|
+
nativeAssets = _getAssetsObject2.nativeAssets;
|
|
3639
|
+
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
|
|
3640
|
+
return o.symbol === symbol;
|
|
3641
|
+
});
|
|
3642
|
+
return asset ? asset.decimals : null;
|
|
3643
|
+
}
|
|
3644
|
+
function getParaId(node) {
|
|
3645
|
+
return getAssetsObject(node).paraId;
|
|
3646
|
+
}
|
|
3647
|
+
function getTNode(nodeID) {
|
|
3648
|
+
var _iterator = _createForOfIteratorHelper(NODE_NAMES),
|
|
3649
|
+
_step;
|
|
3650
|
+
try {
|
|
3651
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3652
|
+
var node = _step.value;
|
|
3653
|
+
if (getParaId(node) === nodeID) return node;
|
|
3654
|
+
}
|
|
3655
|
+
} catch (err) {
|
|
3656
|
+
_iterator.e(err);
|
|
3657
|
+
} finally {
|
|
3658
|
+
_iterator.f();
|
|
3573
3659
|
}
|
|
3574
|
-
|
|
3575
|
-
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
3663
|
+
__proto__: null,
|
|
3664
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
3665
|
+
getAssetDecimals: getAssetDecimals,
|
|
3666
|
+
getAssetId: getAssetId,
|
|
3667
|
+
getAssetsObject: getAssetsObject,
|
|
3668
|
+
getNativeAssets: getNativeAssets,
|
|
3669
|
+
getOtherAssets: getOtherAssets,
|
|
3670
|
+
getParaId: getParaId,
|
|
3671
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
3672
|
+
getTNode: getTNode,
|
|
3673
|
+
hasSupportForAsset: hasSupportForAsset
|
|
3674
|
+
});
|
|
3576
3675
|
|
|
3577
3676
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
3578
3677
|
return 'transferXTokens' in obj;
|
|
@@ -4681,83 +4780,6 @@ var nodes = {
|
|
|
4681
4780
|
};
|
|
4682
4781
|
var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm'];
|
|
4683
4782
|
|
|
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
|
-
|
|
4761
4783
|
function createAccID(api, account) {
|
|
4762
4784
|
console.log('Generating AccountId32 address');
|
|
4763
4785
|
return api.createType('AccountId32', account).toHex();
|
|
@@ -4858,7 +4880,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4858
4880
|
}
|
|
4859
4881
|
if (scenario === 'ParaToRelay' && pallet === 'polkadotXCM') {
|
|
4860
4882
|
console.log('AccountId32 transfer');
|
|
4861
|
-
if (node === 'Statemine') {
|
|
4883
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4862
4884
|
return {
|
|
4863
4885
|
V3: {
|
|
4864
4886
|
parents: 0,
|
|
@@ -4902,7 +4924,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4902
4924
|
}
|
|
4903
4925
|
if (ethers.utils.isAddress(to)) {
|
|
4904
4926
|
console.log('AccountKey20 transfer');
|
|
4905
|
-
if (node === 'Statemine') {
|
|
4927
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4906
4928
|
return {
|
|
4907
4929
|
V3: {
|
|
4908
4930
|
parents: 0,
|
|
@@ -4932,7 +4954,7 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4932
4954
|
}
|
|
4933
4955
|
} else {
|
|
4934
4956
|
console.log('AccountId32 transfer');
|
|
4935
|
-
if (node === 'Statemine') {
|
|
4957
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
4936
4958
|
return {
|
|
4937
4959
|
V3: {
|
|
4938
4960
|
parents: 0,
|
|
@@ -4963,74 +4985,41 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4963
4985
|
}
|
|
4964
4986
|
}
|
|
4965
4987
|
if (scenario === 'RelayToPara') {
|
|
4966
|
-
var asset = getRelayChainSymbol(node);
|
|
4967
4988
|
if (ethers.utils.isAddress(to)) {
|
|
4968
4989
|
console.log('AccountKey20 transfer');
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
key: to
|
|
4977
|
-
}
|
|
4978
|
-
}
|
|
4979
|
-
}
|
|
4980
|
-
}
|
|
4981
|
-
};
|
|
4982
|
-
} else {
|
|
4983
|
-
return {
|
|
4984
|
-
V1: {
|
|
4985
|
-
parents: 0,
|
|
4986
|
-
interior: {
|
|
4987
|
-
X1: {
|
|
4988
|
-
AccountKey20: {
|
|
4989
|
-
network: 'Any',
|
|
4990
|
-
key: to
|
|
4991
|
-
}
|
|
4990
|
+
return {
|
|
4991
|
+
V3: {
|
|
4992
|
+
parents: 0,
|
|
4993
|
+
interior: {
|
|
4994
|
+
X1: {
|
|
4995
|
+
AccountKey20: {
|
|
4996
|
+
key: to
|
|
4992
4997
|
}
|
|
4993
4998
|
}
|
|
4994
4999
|
}
|
|
4995
|
-
}
|
|
4996
|
-
}
|
|
5000
|
+
}
|
|
5001
|
+
};
|
|
4997
5002
|
} else {
|
|
4998
5003
|
console.log('AccountId32 transfer');
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
id: createAccID(api, to)
|
|
5007
|
-
}
|
|
5008
|
-
}
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
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
|
-
}
|
|
5004
|
+
return {
|
|
5005
|
+
V3: {
|
|
5006
|
+
parents: 0,
|
|
5007
|
+
interior: {
|
|
5008
|
+
X1: {
|
|
5009
|
+
AccountId32: {
|
|
5010
|
+
id: createAccID(api, to)
|
|
5022
5011
|
}
|
|
5023
5012
|
}
|
|
5024
5013
|
}
|
|
5025
|
-
}
|
|
5026
|
-
}
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
5027
5016
|
}
|
|
5028
5017
|
}
|
|
5029
5018
|
}
|
|
5030
5019
|
function createCurrencySpecification(amount, scenario, node, cur) {
|
|
5031
5020
|
if (scenario === 'ParaToRelay') {
|
|
5032
5021
|
console.log('polkadotXCM transfer in native currency to Relay chain');
|
|
5033
|
-
if (node === 'Statemine') {
|
|
5022
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5034
5023
|
return {
|
|
5035
5024
|
V3: [{
|
|
5036
5025
|
id: {
|
|
@@ -5093,7 +5082,7 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5093
5082
|
};
|
|
5094
5083
|
} else if ((node === 'Statemint' || node === 'Statemine') && scenario === 'ParaToPara') {
|
|
5095
5084
|
// Another specific case for Statemint & Statemine to send for example USDt
|
|
5096
|
-
if (node === 'Statemine') {
|
|
5085
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5097
5086
|
return {
|
|
5098
5087
|
V3: [{
|
|
5099
5088
|
id: {
|
|
@@ -5136,24 +5125,8 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5136
5125
|
}
|
|
5137
5126
|
}
|
|
5138
5127
|
// Otherwise
|
|
5139
|
-
var asset = getRelayChainSymbol(node);
|
|
5140
|
-
if (asset === 'KSM') {
|
|
5141
|
-
return {
|
|
5142
|
-
V3: [{
|
|
5143
|
-
id: {
|
|
5144
|
-
Concrete: {
|
|
5145
|
-
parents: 0,
|
|
5146
|
-
interior: 'Here'
|
|
5147
|
-
}
|
|
5148
|
-
},
|
|
5149
|
-
fun: {
|
|
5150
|
-
Fungible: amount
|
|
5151
|
-
}
|
|
5152
|
-
}]
|
|
5153
|
-
};
|
|
5154
|
-
}
|
|
5155
5128
|
return {
|
|
5156
|
-
|
|
5129
|
+
V3: [{
|
|
5157
5130
|
id: {
|
|
5158
5131
|
Concrete: {
|
|
5159
5132
|
parents: 0,
|
|
@@ -5170,7 +5143,7 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
5170
5143
|
function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
5171
5144
|
console.log('Generating header for polkadotXCM transfer');
|
|
5172
5145
|
if (scenario === 'ParaToRelay') {
|
|
5173
|
-
if (node === 'Statemine') {
|
|
5146
|
+
if (node === 'Statemine' || node === 'Statemint') {
|
|
5174
5147
|
return {
|
|
5175
5148
|
V3: {
|
|
5176
5149
|
parents: 1,
|
|
@@ -5208,31 +5181,16 @@ function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
|
5208
5181
|
};
|
|
5209
5182
|
}
|
|
5210
5183
|
if (scenario === 'RelayToPara') {
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
interior: {
|
|
5218
|
-
X1: {
|
|
5219
|
-
Parachain: nodeId
|
|
5220
|
-
}
|
|
5221
|
-
}
|
|
5222
|
-
}
|
|
5223
|
-
};
|
|
5224
|
-
} else {
|
|
5225
|
-
return {
|
|
5226
|
-
V1: {
|
|
5227
|
-
parents: 0,
|
|
5228
|
-
interior: {
|
|
5229
|
-
X1: {
|
|
5230
|
-
Parachain: nodeId
|
|
5231
|
-
}
|
|
5184
|
+
return {
|
|
5185
|
+
V3: {
|
|
5186
|
+
parents: 0,
|
|
5187
|
+
interior: {
|
|
5188
|
+
X1: {
|
|
5189
|
+
Parachain: nodeId
|
|
5232
5190
|
}
|
|
5233
5191
|
}
|
|
5234
|
-
}
|
|
5235
|
-
}
|
|
5192
|
+
}
|
|
5193
|
+
};
|
|
5236
5194
|
}
|
|
5237
5195
|
}
|
|
5238
5196
|
function getNode(node) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": "@paraspell/sdk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@polkadot/api": "^10.6.1",
|
|
26
|
-
"@polkadot/types": "^10.6.1",
|
|
27
26
|
"@polkadot/api-base": "^10.6.1",
|
|
28
|
-
"@polkadot/apps-config": "^0.124.1"
|
|
27
|
+
"@polkadot/apps-config": "^0.124.1",
|
|
28
|
+
"@polkadot/types": "^10.6.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/plugin-syntax-import-assertions": "^7.20.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@rollup/plugin-babel": "^6.0.3",
|
|
35
35
|
"@rollup/plugin-json": "^6.0.0",
|
|
36
36
|
"@types/node": "^18.11.9",
|
|
37
|
-
"@vitest/coverage-
|
|
37
|
+
"@vitest/coverage-v8": "^0.32.2",
|
|
38
38
|
"eslint": "latest",
|
|
39
39
|
"eslint-config-prettier": "^8.6.0",
|
|
40
40
|
"eslint-plugin-prettier": "^4.2.1",
|