@paraspell/sdk 1.1.4 → 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 +396 -172
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +396 -173
- package/package.json +2 -2
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,19 +227,6 @@ function _toPropertyKey(arg) {
|
|
|
190
227
|
return typeof key === "symbol" ? key : String(key);
|
|
191
228
|
}
|
|
192
229
|
|
|
193
|
-
var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
|
|
194
|
-
_inherits(NoXCMSupportImplementedError, _Error);
|
|
195
|
-
var _super = _createSuper(NoXCMSupportImplementedError);
|
|
196
|
-
function NoXCMSupportImplementedError(node) {
|
|
197
|
-
var _this;
|
|
198
|
-
_classCallCheck(this, NoXCMSupportImplementedError);
|
|
199
|
-
_this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
|
|
200
|
-
_this.name = 'NoXCMSupportImplemented';
|
|
201
|
-
return _this;
|
|
202
|
-
}
|
|
203
|
-
return _createClass(NoXCMSupportImplementedError);
|
|
204
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
205
|
-
|
|
206
230
|
var Acala$2 = {
|
|
207
231
|
paraId: 2000,
|
|
208
232
|
relayChainAssetSymbol: "DOT",
|
|
@@ -3536,67 +3560,19 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
|
|
|
3536
3560
|
default: assets
|
|
3537
3561
|
});
|
|
3538
3562
|
|
|
3539
|
-
|
|
3540
|
-
function
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
function
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
return
|
|
3551
|
-
}
|
|
3552
|
-
function getNativeAssets(node) {
|
|
3553
|
-
var info = getAssetsObject(node).nativeAssets;
|
|
3554
|
-
return info || [];
|
|
3555
|
-
}
|
|
3556
|
-
function getOtherAssets(node) {
|
|
3557
|
-
return getAssetsObject(node).otherAssets;
|
|
3558
|
-
}
|
|
3559
|
-
function getAllAssetsSymbols(node) {
|
|
3560
|
-
var _getAssetsObject = getAssetsObject(node),
|
|
3561
|
-
relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
|
|
3562
|
-
nativeAssets = _getAssetsObject.nativeAssets,
|
|
3563
|
-
otherAssets = _getAssetsObject.otherAssets;
|
|
3564
|
-
return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
|
|
3565
|
-
var symbol = _ref.symbol;
|
|
3566
|
-
return symbol;
|
|
3567
|
-
})), _toConsumableArray(otherAssets.map(function (_ref2) {
|
|
3568
|
-
var symbol = _ref2.symbol;
|
|
3569
|
-
return symbol;
|
|
3570
|
-
})));
|
|
3571
|
-
}
|
|
3572
|
-
function hasSupportForAsset(node, symbol) {
|
|
3573
|
-
return getAllAssetsSymbols(node).includes(symbol);
|
|
3574
|
-
}
|
|
3575
|
-
function getAssetDecimals(node, symbol) {
|
|
3576
|
-
var _getAssetsObject2 = getAssetsObject(node),
|
|
3577
|
-
otherAssets = _getAssetsObject2.otherAssets,
|
|
3578
|
-
nativeAssets = _getAssetsObject2.nativeAssets;
|
|
3579
|
-
var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
|
|
3580
|
-
return o.symbol === symbol;
|
|
3581
|
-
});
|
|
3582
|
-
return asset ? asset.decimals : null;
|
|
3583
|
-
}
|
|
3584
|
-
function getParaId(node) {
|
|
3585
|
-
return getAssetsObject(node).paraId;
|
|
3586
|
-
}
|
|
3587
|
-
|
|
3588
|
-
var index$4 = /*#__PURE__*/Object.freeze({
|
|
3589
|
-
__proto__: null,
|
|
3590
|
-
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
3591
|
-
getAssetDecimals: getAssetDecimals,
|
|
3592
|
-
getAssetId: getAssetId,
|
|
3593
|
-
getAssetsObject: getAssetsObject,
|
|
3594
|
-
getNativeAssets: getNativeAssets,
|
|
3595
|
-
getOtherAssets: getOtherAssets,
|
|
3596
|
-
getParaId: getParaId,
|
|
3597
|
-
getRelayChainSymbol: getRelayChainSymbol,
|
|
3598
|
-
hasSupportForAsset: hasSupportForAsset
|
|
3599
|
-
});
|
|
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));
|
|
3600
3576
|
|
|
3601
3577
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
3602
3578
|
return 'transferXTokens' in obj;
|
|
@@ -3715,6 +3691,7 @@ var Unique$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
3715
3691
|
return Unique;
|
|
3716
3692
|
}(ParachainNode);
|
|
3717
3693
|
|
|
3694
|
+
// Used to inform user, that currency they wish to use is not registered on either origin or destination Parachain
|
|
3718
3695
|
var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
|
|
3719
3696
|
_inherits(InvalidCurrencyError, _Error);
|
|
3720
3697
|
var _super = _createSuper(InvalidCurrencyError);
|
|
@@ -4400,6 +4377,7 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
4400
4377
|
return Karura;
|
|
4401
4378
|
}(ParachainNode);
|
|
4402
4379
|
|
|
4380
|
+
// Contains basic structure of polkadotXCM call
|
|
4403
4381
|
var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
4404
4382
|
function PolkadotXCMTransferImpl() {
|
|
4405
4383
|
_classCallCheck(this, PolkadotXCMTransferImpl);
|
|
@@ -4456,6 +4434,7 @@ var Statemine$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
4456
4434
|
return Statemine;
|
|
4457
4435
|
}(ParachainNode);
|
|
4458
4436
|
|
|
4437
|
+
// Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
|
|
4459
4438
|
var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
4460
4439
|
_inherits(ScenarioNotSupportedError, _Error);
|
|
4461
4440
|
var _super = _createSuper(ScenarioNotSupportedError);
|
|
@@ -4648,6 +4627,7 @@ var Shiden$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
4648
4627
|
return Shiden;
|
|
4649
4628
|
}(ParachainNode);
|
|
4650
4629
|
|
|
4630
|
+
// Contains supported Parachains and exports supported XCM Pallets
|
|
4651
4631
|
var NODE_NAMES = ['Statemint', 'Acala', 'Astar', 'BifrostPolkadot', 'Bitgreen', 'Centrifuge', 'Clover', 'ComposableFinance', 'Darwinia', 'HydraDX', 'Interlay', 'Kylin', 'Litentry', 'Moonbeam', 'Parallel', 'Statemine', 'Encointer', 'Altair', 'Amplitude', 'Bajun', 'Basilisk', 'BifrostKusama', 'Pioneer', 'Calamari', 'CrustShadow', 'Crab', 'Dorafactory', 'Imbue', 'Integritee', 'InvArchTinker', 'Karura', 'Kico', 'Kintsugi', 'Litmus', 'Mangata', 'Moonriver', 'ParallelHeiko', 'Picasso', 'Pichiu', 'Quartz', 'Robonomics', 'Shiden', 'Turing', 'Equilibrium', 'Unique', 'Crust', 'Efinity', 'Ipci'];
|
|
4652
4632
|
var nodes = {
|
|
4653
4633
|
Statemint: new Statemint$1(),
|
|
@@ -4701,6 +4681,83 @@ var nodes = {
|
|
|
4701
4681
|
};
|
|
4702
4682
|
var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm'];
|
|
4703
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
|
+
|
|
4704
4761
|
function createAccID(api, account) {
|
|
4705
4762
|
console.log('Generating AccountId32 address');
|
|
4706
4763
|
return api.createType('AccountId32', account).toHex();
|
|
@@ -4801,17 +4858,34 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4801
4858
|
}
|
|
4802
4859
|
if (scenario === 'ParaToRelay' && pallet === 'polkadotXCM') {
|
|
4803
4860
|
console.log('AccountId32 transfer');
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4861
|
+
if (node === 'Statemine') {
|
|
4862
|
+
return {
|
|
4863
|
+
V3: {
|
|
4864
|
+
parents: 0,
|
|
4865
|
+
interior: {
|
|
4866
|
+
X1: {
|
|
4867
|
+
AccountId32: {
|
|
4868
|
+
id: createAccID(api, to)
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4811
4871
|
}
|
|
4812
4872
|
}
|
|
4813
|
-
}
|
|
4814
|
-
}
|
|
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
|
+
}
|
|
4815
4889
|
}
|
|
4816
4890
|
if (scenario === 'ParaToPara' && pallet === 'polkadotXCM') {
|
|
4817
4891
|
if (node === 'Quartz') {
|
|
@@ -4828,82 +4902,163 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
|
|
|
4828
4902
|
}
|
|
4829
4903
|
if (ethers.utils.isAddress(to)) {
|
|
4830
4904
|
console.log('AccountKey20 transfer');
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4905
|
+
if (node === 'Statemine') {
|
|
4906
|
+
return {
|
|
4907
|
+
V3: {
|
|
4908
|
+
parents: 0,
|
|
4909
|
+
interior: {
|
|
4910
|
+
X1: {
|
|
4911
|
+
AccountKey20: {
|
|
4912
|
+
key: to
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4838
4915
|
}
|
|
4839
4916
|
}
|
|
4840
|
-
}
|
|
4841
|
-
}
|
|
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
|
+
}
|
|
4842
4933
|
} else {
|
|
4843
4934
|
console.log('AccountId32 transfer');
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4935
|
+
if (node === 'Statemine') {
|
|
4936
|
+
return {
|
|
4937
|
+
V3: {
|
|
4938
|
+
parents: 0,
|
|
4939
|
+
interior: {
|
|
4940
|
+
X1: {
|
|
4941
|
+
AccountId32: {
|
|
4942
|
+
id: createAccID(api, to)
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4851
4945
|
}
|
|
4852
4946
|
}
|
|
4853
|
-
}
|
|
4854
|
-
}
|
|
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
|
+
}
|
|
4855
4963
|
}
|
|
4856
4964
|
}
|
|
4857
4965
|
if (scenario === 'RelayToPara') {
|
|
4966
|
+
var asset = getRelayChainSymbol(node);
|
|
4858
4967
|
if (ethers.utils.isAddress(to)) {
|
|
4859
4968
|
console.log('AccountKey20 transfer');
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4969
|
+
if (asset === 'KSM') {
|
|
4970
|
+
return {
|
|
4971
|
+
V3: {
|
|
4972
|
+
parents: 0,
|
|
4973
|
+
interior: {
|
|
4974
|
+
X1: {
|
|
4975
|
+
AccountKey20: {
|
|
4976
|
+
key: to
|
|
4977
|
+
}
|
|
4868
4978
|
}
|
|
4869
4979
|
}
|
|
4870
4980
|
}
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
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
|
+
}
|
|
4873
4997
|
} else {
|
|
4874
4998
|
console.log('AccountId32 transfer');
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4999
|
+
if (asset === 'KSM') {
|
|
5000
|
+
return {
|
|
5001
|
+
V3: {
|
|
5002
|
+
parents: 0,
|
|
5003
|
+
interior: {
|
|
5004
|
+
X1: {
|
|
5005
|
+
AccountId32: {
|
|
5006
|
+
id: createAccID(api, to)
|
|
5007
|
+
}
|
|
4883
5008
|
}
|
|
4884
5009
|
}
|
|
4885
5010
|
}
|
|
4886
|
-
}
|
|
4887
|
-
}
|
|
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
|
+
}
|
|
4888
5027
|
}
|
|
4889
5028
|
}
|
|
4890
5029
|
}
|
|
4891
5030
|
function createCurrencySpecification(amount, scenario, node, cur) {
|
|
4892
5031
|
if (scenario === 'ParaToRelay') {
|
|
4893
5032
|
console.log('polkadotXCM transfer in native currency to Relay chain');
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
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
|
|
4900
5044
|
}
|
|
4901
|
-
}
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
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
|
+
}
|
|
4907
5062
|
}
|
|
4908
5063
|
if (scenario === 'RelayToPara' || scenario === 'ParaToPara') {
|
|
4909
5064
|
console.log('polkadotXCM Native currency to sender chain transfer');
|
|
@@ -4938,18 +5093,57 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4938
5093
|
};
|
|
4939
5094
|
} else if ((node === 'Statemint' || node === 'Statemine') && scenario === 'ParaToPara') {
|
|
4940
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') {
|
|
4941
5141
|
return {
|
|
4942
|
-
|
|
5142
|
+
V3: [{
|
|
4943
5143
|
id: {
|
|
4944
5144
|
Concrete: {
|
|
4945
5145
|
parents: 0,
|
|
4946
|
-
interior:
|
|
4947
|
-
X2: [{
|
|
4948
|
-
PalletInstance: 50
|
|
4949
|
-
}, {
|
|
4950
|
-
GeneralIndex: cur
|
|
4951
|
-
}]
|
|
4952
|
-
}
|
|
5146
|
+
interior: 'Here'
|
|
4953
5147
|
}
|
|
4954
5148
|
},
|
|
4955
5149
|
fun: {
|
|
@@ -4958,7 +5152,6 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4958
5152
|
}]
|
|
4959
5153
|
};
|
|
4960
5154
|
}
|
|
4961
|
-
// Otherwise
|
|
4962
5155
|
return {
|
|
4963
5156
|
V1: [{
|
|
4964
5157
|
id: {
|
|
@@ -4977,12 +5170,21 @@ function createCurrencySpecification(amount, scenario, node, cur) {
|
|
|
4977
5170
|
function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
4978
5171
|
console.log('Generating header for polkadotXCM transfer');
|
|
4979
5172
|
if (scenario === 'ParaToRelay') {
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
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
|
+
}
|
|
4986
5188
|
}
|
|
4987
5189
|
if (scenario === 'ParaToPara') {
|
|
4988
5190
|
if (node === 'Quartz') {
|
|
@@ -5006,16 +5208,31 @@ function createHeaderPolkadotXCM(scenario, nodeId, node) {
|
|
|
5006
5208
|
};
|
|
5007
5209
|
}
|
|
5008
5210
|
if (scenario === 'RelayToPara') {
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
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
|
+
}
|
|
5015
5221
|
}
|
|
5016
5222
|
}
|
|
5017
|
-
}
|
|
5018
|
-
}
|
|
5223
|
+
};
|
|
5224
|
+
} else {
|
|
5225
|
+
return {
|
|
5226
|
+
V1: {
|
|
5227
|
+
parents: 0,
|
|
5228
|
+
interior: {
|
|
5229
|
+
X1: {
|
|
5230
|
+
Parachain: nodeId
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
}
|
|
5234
|
+
};
|
|
5235
|
+
}
|
|
5019
5236
|
}
|
|
5020
5237
|
}
|
|
5021
5238
|
function getNode(node) {
|
|
@@ -5049,6 +5266,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
|
5049
5266
|
return null;
|
|
5050
5267
|
};
|
|
5051
5268
|
|
|
5269
|
+
// Used to inform user, that Parachain they wish to use is not supported yet
|
|
5052
5270
|
var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
5053
5271
|
_inherits(NodeNotSupportedError, _Error);
|
|
5054
5272
|
var _super = _createSuper(NodeNotSupportedError);
|
|
@@ -5062,6 +5280,7 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
|
5062
5280
|
return _createClass(NodeNotSupportedError);
|
|
5063
5281
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5064
5282
|
|
|
5283
|
+
//Contains basic call formatting for different XCM Palletss
|
|
5065
5284
|
function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5066
5285
|
var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
|
|
5067
5286
|
if (!asset) {
|
|
@@ -5076,9 +5295,9 @@ function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
|
5076
5295
|
}
|
|
5077
5296
|
function transferRelayToPara(api, destination, amount, to) {
|
|
5078
5297
|
var paraId = getParaId(destination);
|
|
5079
|
-
if (destination === 'Statemine' || destination === 'Encointer') {
|
|
5298
|
+
if (destination === 'Statemint' || destination === 'Statemine' || destination === 'Encointer') {
|
|
5080
5299
|
// Same for Statemint, Statemine and Encoiter
|
|
5081
|
-
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');
|
|
5082
5301
|
} else if (destination === 'Darwinia' || destination === 'Crab' || destination === 'Quartz') {
|
|
5083
5302
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered Quartz does not work with UMP & DMP too
|
|
5084
5303
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
@@ -5092,6 +5311,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
5092
5311
|
transferRelayToPara: transferRelayToPara
|
|
5093
5312
|
});
|
|
5094
5313
|
|
|
5314
|
+
//Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
|
|
5095
5315
|
function addLiquidity(api, assetA, assetB, amountA, amountBMaxLimit) {
|
|
5096
5316
|
return api.tx.xyk.addLiquidity(assetA, assetB, amountA, amountBMaxLimit);
|
|
5097
5317
|
}
|
|
@@ -5117,6 +5337,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
5117
5337
|
sell: sell
|
|
5118
5338
|
});
|
|
5119
5339
|
|
|
5340
|
+
//Contains call formatting for opening HRMP channels functionality
|
|
5120
5341
|
function openChannel(api, origin, destination, maxSize, maxMessageSize) {
|
|
5121
5342
|
return api.tx.sudo.sudo(api.tx.parasSudoWrapper.sudoEstablishHrmpChannel(getParaId(origin), getParaId(destination), maxSize, maxMessageSize));
|
|
5122
5343
|
}
|
|
@@ -5126,6 +5347,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
5126
5347
|
openChannel: openChannel
|
|
5127
5348
|
});
|
|
5128
5349
|
|
|
5350
|
+
//Contains call formatting for closing HRMP channels functionality
|
|
5129
5351
|
function closeChannel(api, origin, inbound, outbound) {
|
|
5130
5352
|
return api.tx.sudo.sudo(api.tx.hrmp.forceCleanHrmp(getParaId(origin), inbound, outbound));
|
|
5131
5353
|
}
|
|
@@ -6010,6 +6232,7 @@ var palletsMapJson = /*#__PURE__*/Object.freeze({
|
|
|
6010
6232
|
default: pallets
|
|
6011
6233
|
});
|
|
6012
6234
|
|
|
6235
|
+
// Script that pulls XCM Pallets for selected Parachain
|
|
6013
6236
|
var palletsMap = palletsMapJson;
|
|
6014
6237
|
var getDefaultPallet = function getDefaultPallet(node) {
|
|
6015
6238
|
return palletsMap[node].defaultPallet;
|
|
@@ -6018,4 +6241,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6018
6241
|
return palletsMap[node].supportedPallets;
|
|
6019
6242
|
};
|
|
6020
6243
|
|
|
6021
|
-
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 };
|