@paraspell/sdk 7.2.3 → 7.2.4

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.
@@ -586,180 +586,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
586
586
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
587
587
  };
588
588
 
589
- /**
590
- * Used to inform user, that currency they wish to use is not registered on either origin or destination Parachain
591
- */
592
- var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
593
- /**
594
- * Constructs a new InvalidCurrencyError.
595
- *
596
- * @param message - The error message.
597
- */
598
- function InvalidCurrencyError(message) {
599
- var _this;
600
- _classCallCheck(this, InvalidCurrencyError);
601
- _this = _callSuper(this, InvalidCurrencyError, [message]);
602
- _this.name = 'InvalidCurrencyError';
603
- return _this;
604
- }
605
- _inherits(InvalidCurrencyError, _Error);
606
- return _createClass(InvalidCurrencyError);
607
- }(/*#__PURE__*/_wrapNativeSuper(Error));
608
-
609
- /**
610
- * Used to inform user, that Parachain they wish to use is not supported yet
611
- */
612
- var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
613
- /**
614
- * Constructs a new NodeNotSupportedError.
615
- *
616
- * @param message - Optional custom error message.
617
- */
618
- function NodeNotSupportedError(message) {
619
- var _this;
620
- _classCallCheck(this, NodeNotSupportedError);
621
- _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
622
- _this.name = 'NodeNotSupported';
623
- return _this;
624
- }
625
- _inherits(NodeNotSupportedError, _Error);
626
- return _createClass(NodeNotSupportedError);
627
- }(/*#__PURE__*/_wrapNativeSuper(Error));
628
-
629
- /**
630
- * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
631
- */
632
- var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
633
- /**
634
- * Constructs a new NoXCMSupportImplementedError.
635
- *
636
- * @param node - The node for which XCM support is not implemented.
637
- */
638
- function NoXCMSupportImplementedError(node) {
639
- var _this;
640
- _classCallCheck(this, NoXCMSupportImplementedError);
641
- _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
642
- _this.name = 'NoXCMSupportImplemented';
643
- return _this;
644
- }
645
- _inherits(NoXCMSupportImplementedError, _Error);
646
- return _createClass(NoXCMSupportImplementedError);
647
- }(/*#__PURE__*/_wrapNativeSuper(Error));
648
-
649
- /**
650
- * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
651
- */
652
- var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
653
- /**
654
- * Constructs a new ScenarioNotSupportedError.
655
- *
656
- * @param node - The node where the scenario is not supported.
657
- * @param scenario - The scenario that is not supported.
658
- * @param message - Optional custom error message.
659
- */
660
- function ScenarioNotSupportedError(node, scenario, message) {
661
- var _this;
662
- _classCallCheck(this, ScenarioNotSupportedError);
663
- _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
664
- _this.name = 'ScenarioNotSupported';
665
- return _this;
666
- }
667
- _inherits(ScenarioNotSupportedError, _Error);
668
- return _createClass(ScenarioNotSupportedError);
669
- }(/*#__PURE__*/_wrapNativeSuper(Error));
670
-
671
- /**
672
- * Error thrown when nodes from different relay chains are incompatible.
673
- */
674
- var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
675
- /**
676
- * Constructs a new IncompatibleNodesError.
677
- *
678
- * @param message - Optional custom error message.
679
- */
680
- function IncompatibleNodesError(message) {
681
- var _this;
682
- _classCallCheck(this, IncompatibleNodesError);
683
- _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
684
- _this.name = 'IncompatibleNodes';
685
- return _this;
686
- }
687
- _inherits(IncompatibleNodesError, _Error);
688
- return _createClass(IncompatibleNodesError);
689
- }(/*#__PURE__*/_wrapNativeSuper(Error));
690
-
691
- /**
692
- * Error thrown when multiple assets with the same symbol are found.
693
- */
694
- var DuplicateAssetError = /*#__PURE__*/function (_Error) {
695
- /**
696
- * Constructs a new DuplicateAssetError.
697
- *
698
- * @param symbol - The symbol of the asset causing the duplication error.
699
- */
700
- function DuplicateAssetError(msg) {
701
- var _this;
702
- _classCallCheck(this, DuplicateAssetError);
703
- _this = _callSuper(this, DuplicateAssetError, [msg]);
704
- _this.name = 'DuplicateAsset';
705
- return _this;
706
- }
707
- _inherits(DuplicateAssetError, _Error);
708
- return _createClass(DuplicateAssetError);
709
- }(/*#__PURE__*/_wrapNativeSuper(Error));
710
-
711
- /**
712
- * Error thrown when multiple assets with the same symbol are found.
713
- */
714
- var DuplicateAssetIdError = /*#__PURE__*/function (_Error) {
715
- /**
716
- * Constructs a new DuplicateAssetError.
717
- *
718
- * @param symbol - The symbol of the asset causing the duplication error.
719
- */
720
- function DuplicateAssetIdError(id) {
721
- var _this;
722
- _classCallCheck(this, DuplicateAssetIdError);
723
- _this = _callSuper(this, DuplicateAssetIdError, ["Multiple assets found with the same ID: ".concat(id, ". Please specify asset directly by symbol using .currency({symbol: <ASSET_SYMBOL>})")]);
724
- _this.name = 'DuplicateAssetId';
725
- return _this;
726
- }
727
- _inherits(DuplicateAssetIdError, _Error);
728
- return _createClass(DuplicateAssetIdError);
729
- }(/*#__PURE__*/_wrapNativeSuper(Error));
730
-
731
- /**
732
- * Error thrown when an invalid address is provided.
733
- */
734
- var InvalidAddressError = /*#__PURE__*/function (_Error) {
735
- /**
736
- * Constructs a new InvalidAddressError.
737
- *
738
- * @param message - The error message.
739
- */
740
- function InvalidAddressError(message) {
741
- var _this;
742
- _classCallCheck(this, InvalidAddressError);
743
- _this = _callSuper(this, InvalidAddressError, [message]);
744
- _this.name = 'InvalidAddressError';
745
- return _this;
746
- }
747
- _inherits(InvalidAddressError, _Error);
748
- return _createClass(InvalidAddressError);
749
- }(/*#__PURE__*/_wrapNativeSuper(Error));
750
-
751
- var KeepAliveError = /*#__PURE__*/function (_Error) {
752
- function KeepAliveError(message) {
753
- var _this;
754
- _classCallCheck(this, KeepAliveError);
755
- _this = _callSuper(this, KeepAliveError, [message]);
756
- _this.name = 'KeepAliveError';
757
- return _this;
758
- }
759
- _inherits(KeepAliveError, _Error);
760
- return _createClass(KeepAliveError);
761
- }(/*#__PURE__*/_wrapNativeSuper(Error));
762
-
763
589
  var Polkadot$2 = {
764
590
  relayChainAssetSymbol: "DOT",
765
591
  nativeAssetSymbol: "DOT",
@@ -12165,6 +11991,77 @@ var getNodeProviders = function getNodeProviders(node) {
12165
11991
  });
12166
11992
  };
12167
11993
 
11994
+ var getNodeProvider = function getNodeProvider(node) {
11995
+ if (isRelayChain(node)) {
11996
+ var _getNodeConfig = getNodeConfig(node),
11997
+ providers = _getNodeConfig.providers;
11998
+ if (providers.length === 0) {
11999
+ throw new Error("No providers found for node ".concat(node));
12000
+ }
12001
+ return providers[0].endpoint;
12002
+ }
12003
+ return getNode(node).getProvider();
12004
+ };
12005
+
12006
+ /**
12007
+ * Retrieves the parachain ID for a specified node.
12008
+ *
12009
+ * @param node - The node for which to get the paraId.
12010
+ * @returns The parachain ID of the node.
12011
+ */
12012
+ var getParaId = function getParaId(node) {
12013
+ return getNodeConfig(node).paraId;
12014
+ };
12015
+
12016
+ /**
12017
+ * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
12018
+ */
12019
+ var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
12020
+ /**
12021
+ * Constructs a new NoXCMSupportImplementedError.
12022
+ *
12023
+ * @param node - The node for which XCM support is not implemented.
12024
+ */
12025
+ function NoXCMSupportImplementedError(node) {
12026
+ var _this;
12027
+ _classCallCheck(this, NoXCMSupportImplementedError);
12028
+ _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
12029
+ _this.name = 'NoXCMSupportImplemented';
12030
+ return _this;
12031
+ }
12032
+ _inherits(NoXCMSupportImplementedError, _Error);
12033
+ return _createClass(NoXCMSupportImplementedError);
12034
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12035
+
12036
+ var findParachainJunction = function findParachainJunction(multilocation) {
12037
+ var interior = multilocation.interior;
12038
+ if (interior === 'Here') {
12039
+ return null;
12040
+ }
12041
+ for (var key in interior) {
12042
+ var junctions = interior[key];
12043
+ if (Array.isArray(junctions)) {
12044
+ var _iterator = _createForOfIteratorHelper(junctions),
12045
+ _step;
12046
+ try {
12047
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12048
+ var junction = _step.value;
12049
+ if ('Parachain' in junction) {
12050
+ return Number(junction.Parachain);
12051
+ }
12052
+ }
12053
+ } catch (err) {
12054
+ _iterator.e(err);
12055
+ } finally {
12056
+ _iterator.f();
12057
+ }
12058
+ } else if (_typeof(junctions) === 'object' && junctions !== null && 'Parachain' in junctions) {
12059
+ return Number(junctions.Parachain);
12060
+ }
12061
+ }
12062
+ return null;
12063
+ };
12064
+
12168
12065
  var createX1Payload = function createX1Payload(version, junction) {
12169
12066
  return version === exports.Version.V4 ? {
12170
12067
  X1: [junction]
@@ -12173,276 +12070,147 @@ var createX1Payload = function createX1Payload(version, junction) {
12173
12070
  };
12174
12071
  };
12175
12072
 
12176
- var isPrimitive = function isPrimitive(obj) {
12177
- return obj !== Object(obj);
12178
- };
12179
- var _deepEqual = function deepEqual(obj1, obj2) {
12180
- if (obj1 === obj2) return true;
12181
- if (isPrimitive(obj1) && isPrimitive(obj2)) return obj1 === obj2;
12182
- if (_typeof(obj1) !== 'object' || obj1 === null || _typeof(obj2) !== 'object' || obj2 === null) {
12183
- return false;
12184
- }
12185
- if (Array.isArray(obj1) !== Array.isArray(obj2)) {
12186
- return false;
12187
- }
12188
- var obj1Keys = Object.keys(obj1).map(function (key) {
12189
- return key.toLowerCase();
12190
- });
12191
- var obj2Keys = Object.keys(obj2).map(function (key) {
12192
- return key.toLowerCase();
12193
- });
12194
- if (obj1Keys.length !== obj2Keys.length) return false;
12195
- var _iterator = _createForOfIteratorHelper(obj1Keys),
12196
- _step;
12197
- try {
12198
- var _loop = function _loop() {
12199
- var key = _step.value;
12200
- var keyInObj2 = obj2Keys.find(function (k) {
12201
- return k === key;
12202
- });
12203
- if (!keyInObj2) return {
12204
- v: false
12205
- };
12206
- var obj1Value = obj1[Object.keys(obj1).find(function (k) {
12207
- return k.toLowerCase() === key;
12208
- })];
12209
- var obj2Value = obj2[Object.keys(obj2).find(function (k) {
12210
- return k.toLowerCase() === key;
12211
- })];
12212
- if (!_deepEqual(obj1Value, obj2Value)) return {
12213
- v: false
12214
- };
12215
- },
12216
- _ret;
12217
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
12218
- _ret = _loop();
12219
- if (_ret) return _ret.v;
12220
- }
12221
- } catch (err) {
12222
- _iterator.e(err);
12223
- } finally {
12224
- _iterator.f();
12225
- }
12226
- return true;
12227
- };
12228
-
12229
- var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api, address) {
12230
- var isMultiLocation = _typeof(address) === 'object';
12231
- if (isMultiLocation) {
12232
- return _defineProperty({}, exports.Version.V4, address);
12073
+ /**
12074
+ * Used to inform user, that currency they wish to use is not registered on either origin or destination Parachain
12075
+ */
12076
+ var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
12077
+ /**
12078
+ * Constructs a new InvalidCurrencyError.
12079
+ *
12080
+ * @param message - The error message.
12081
+ */
12082
+ function InvalidCurrencyError(message) {
12083
+ var _this;
12084
+ _classCallCheck(this, InvalidCurrencyError);
12085
+ _this = _callSuper(this, InvalidCurrencyError, [message]);
12086
+ _this.name = 'InvalidCurrencyError';
12087
+ return _this;
12233
12088
  }
12234
- var isEthAddress = ethers.ethers.isAddress(address);
12235
- return _defineProperty({}, exports.Version.V4, {
12236
- parents: exports.Parents.ZERO,
12237
- interior: {
12238
- X1: [isEthAddress ? {
12239
- AccountKey20: {
12240
- key: address
12241
- }
12242
- } : {
12243
- AccountId32: {
12244
- id: api.createAccountId(address),
12245
- network: null
12246
- }
12247
- }]
12248
- }
12249
- });
12250
- };
12089
+ _inherits(InvalidCurrencyError, _Error);
12090
+ return _createClass(InvalidCurrencyError);
12091
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12251
12092
 
12252
- var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
12253
- var isMultiLocation = _typeof(recipientAddress) === 'object';
12254
- if (isMultiLocation) {
12255
- return _defineProperty({}, version, recipientAddress);
12256
- }
12257
- var isEthAddress = ethers.ethers.isAddress(recipientAddress);
12258
- if (scenario === 'ParaToRelay') {
12259
- return _defineProperty({}, version, {
12260
- parents: pallet === 'XTokens' ? exports.Parents.ONE : exports.Parents.ZERO,
12261
- interior: createX1Payload(version, {
12262
- AccountId32: Object.assign(Object.assign({}, version === exports.Version.V1 && {
12263
- network: 'any'
12264
- }), {
12265
- id: api.createAccountId(recipientAddress)
12266
- })
12267
- })
12268
- });
12269
- }
12270
- if (scenario === 'ParaToPara' && pallet === 'XTokens') {
12271
- return _defineProperty({}, version, {
12272
- parents: exports.Parents.ONE,
12273
- interior: {
12274
- X2: [{
12275
- Parachain: nodeId
12276
- }, isEthAddress ? {
12277
- AccountKey20: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
12278
- network: 'any'
12279
- }), {
12280
- key: recipientAddress
12281
- })
12282
- } : {
12283
- AccountId32: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
12284
- network: 'any'
12285
- }), {
12286
- id: api.createAccountId(recipientAddress)
12287
- })
12288
- }]
12289
- }
12290
- });
12291
- }
12292
- if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
12293
- return _defineProperty({}, version, {
12294
- parents: exports.Parents.ZERO,
12295
- interior: createX1Payload(version, isEthAddress ? {
12296
- AccountKey20: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
12297
- network: 'any'
12298
- }), {
12299
- key: recipientAddress
12300
- })
12301
- } : {
12302
- AccountId32: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
12303
- network: 'any'
12304
- }), {
12305
- id: api.createAccountId(recipientAddress)
12306
- })
12307
- })
12308
- });
12093
+ /**
12094
+ * Used to inform user, that Parachain they wish to use is not supported yet
12095
+ */
12096
+ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
12097
+ /**
12098
+ * Constructs a new NodeNotSupportedError.
12099
+ *
12100
+ * @param message - Optional custom error message.
12101
+ */
12102
+ function NodeNotSupportedError(message) {
12103
+ var _this;
12104
+ _classCallCheck(this, NodeNotSupportedError);
12105
+ _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
12106
+ _this.name = 'NodeNotSupported';
12107
+ return _this;
12309
12108
  }
12310
- return _defineProperty({}, version, {
12311
- parents: exports.Parents.ZERO,
12312
- interior: createX1Payload(version, isEthAddress ? {
12313
- AccountKey20: {
12314
- key: recipientAddress
12315
- }
12316
- } : {
12317
- AccountId32: {
12318
- id: api.createAccountId(recipientAddress)
12319
- }
12320
- })
12321
- });
12322
- };
12109
+ _inherits(NodeNotSupportedError, _Error);
12110
+ return _createClass(NodeNotSupportedError);
12111
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12323
12112
 
12324
- var getFees = function getFees(scenario) {
12325
- if (scenario === 'ParaToRelay') {
12326
- return 4600000000;
12327
- } else if (scenario === 'ParaToPara') {
12328
- return 399600000000;
12113
+ /**
12114
+ * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
12115
+ */
12116
+ var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
12117
+ /**
12118
+ * Constructs a new ScenarioNotSupportedError.
12119
+ *
12120
+ * @param node - The node where the scenario is not supported.
12121
+ * @param scenario - The scenario that is not supported.
12122
+ * @param message - Optional custom error message.
12123
+ */
12124
+ function ScenarioNotSupportedError(node, scenario, message) {
12125
+ var _this;
12126
+ _classCallCheck(this, ScenarioNotSupportedError);
12127
+ _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
12128
+ _this.name = 'ScenarioNotSupported';
12129
+ return _this;
12329
12130
  }
12330
- throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
12331
- };
12131
+ _inherits(ScenarioNotSupportedError, _Error);
12132
+ return _createClass(ScenarioNotSupportedError);
12133
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12332
12134
 
12333
12135
  /**
12334
- * Retrieves the node instance for a given node.
12335
- *
12336
- * @param node - The node identifier.
12337
- * @returns The node instance
12136
+ * Error thrown when nodes from different relay chains are incompatible.
12338
12137
  */
12339
- var getNode = function getNode(node) {
12340
- var nodeMap = nodes();
12341
- return nodeMap[node];
12342
- };
12343
-
12344
- var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
12345
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12346
- var wsUrl;
12347
- return _regeneratorRuntime().wrap(function _callee$(_context) {
12348
- while (1) switch (_context.prev = _context.next) {
12349
- case 0:
12350
- if (!(node === 'Polkadot' || node === 'Kusama')) {
12351
- _context.next = 3;
12352
- break;
12353
- }
12354
- wsUrl = getNodeProvider(node);
12355
- return _context.abrupt("return", api.createApiInstance(wsUrl));
12356
- case 3:
12357
- return _context.abrupt("return", getNode(node).createApiInstance(api));
12358
- case 4:
12359
- case "end":
12360
- return _context.stop();
12361
- }
12362
- }, _callee);
12363
- }));
12364
- };
12365
-
12366
- var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
12367
- if (node === 'Polkadot') {
12368
- return 'DOT';
12369
- } else if (node === 'Kusama') {
12370
- return 'KSM';
12371
- } else {
12372
- return getRelayChainSymbol(node);
12138
+ var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
12139
+ /**
12140
+ * Constructs a new IncompatibleNodesError.
12141
+ *
12142
+ * @param message - Optional custom error message.
12143
+ */
12144
+ function IncompatibleNodesError(message) {
12145
+ var _this;
12146
+ _classCallCheck(this, IncompatibleNodesError);
12147
+ _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
12148
+ _this.name = 'IncompatibleNodes';
12149
+ return _this;
12373
12150
  }
12374
- };
12151
+ _inherits(IncompatibleNodesError, _Error);
12152
+ return _createClass(IncompatibleNodesError);
12153
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12375
12154
 
12376
- // Contains important call creation utils (Selection of fees,formating of header and more.. )
12377
12155
  /**
12378
- * Determines the relay chain for a given node.
12379
- *
12380
- * @param node - The node for which to determine the relay chain.
12381
- * @returns 'Kusama' if the node's relay chain symbol is 'KSM'; otherwise, 'Polkadot'.
12156
+ * Error thrown when multiple assets with the same symbol are found.
12382
12157
  */
12383
- var determineRelayChain = function determineRelayChain(node) {
12384
- return getRelayChainSymbol(node) === 'KSM' ? 'Kusama' : 'Polkadot';
12385
- };
12158
+ var DuplicateAssetError = /*#__PURE__*/function (_Error) {
12159
+ /**
12160
+ * Constructs a new DuplicateAssetError.
12161
+ *
12162
+ * @param symbol - The symbol of the asset causing the duplication error.
12163
+ */
12164
+ function DuplicateAssetError(msg) {
12165
+ var _this;
12166
+ _classCallCheck(this, DuplicateAssetError);
12167
+ _this = _callSuper(this, DuplicateAssetError, [msg]);
12168
+ _this.name = 'DuplicateAsset';
12169
+ return _this;
12170
+ }
12171
+ _inherits(DuplicateAssetError, _Error);
12172
+ return _createClass(DuplicateAssetError);
12173
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12174
+
12386
12175
  /**
12387
- * Determines whether a given node is a relay chain (Polkadot or Kusama).
12388
- *
12389
- * @param node - The node to check.
12390
- * @returns True if the node is 'Polkadot' or 'Kusama'; otherwise, false.
12176
+ * Error thrown when multiple assets with the same symbol are found.
12391
12177
  */
12392
- var isRelayChain = function isRelayChain(node) {
12393
- return node === 'Polkadot' || node === 'Kusama';
12394
- };
12395
-
12396
- var getNodeProvider = function getNodeProvider(node) {
12397
- if (isRelayChain(node)) {
12398
- var _getNodeConfig = getNodeConfig(node),
12399
- providers = _getNodeConfig.providers;
12400
- if (providers.length === 0) {
12401
- throw new Error("No providers found for node ".concat(node));
12402
- }
12403
- return providers[0].endpoint;
12178
+ var DuplicateAssetIdError = /*#__PURE__*/function (_Error) {
12179
+ /**
12180
+ * Constructs a new DuplicateAssetError.
12181
+ *
12182
+ * @param symbol - The symbol of the asset causing the duplication error.
12183
+ */
12184
+ function DuplicateAssetIdError(id) {
12185
+ var _this;
12186
+ _classCallCheck(this, DuplicateAssetIdError);
12187
+ _this = _callSuper(this, DuplicateAssetIdError, ["Multiple assets found with the same ID: ".concat(id, ". Please specify asset directly by symbol using .currency({symbol: <ASSET_SYMBOL>})")]);
12188
+ _this.name = 'DuplicateAssetId';
12189
+ return _this;
12404
12190
  }
12405
- return getNode(node).getProvider();
12406
- };
12191
+ _inherits(DuplicateAssetIdError, _Error);
12192
+ return _createClass(DuplicateAssetIdError);
12193
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12407
12194
 
12408
12195
  /**
12409
- * Retrieves the parachain ID for a specified node.
12410
- *
12411
- * @param node - The node for which to get the paraId.
12412
- * @returns The parachain ID of the node.
12196
+ * Error thrown when an invalid address is provided.
12413
12197
  */
12414
- var getParaId = function getParaId(node) {
12415
- return getNodeConfig(node).paraId;
12416
- };
12417
-
12418
- var findParachainJunction = function findParachainJunction(multilocation) {
12419
- var interior = multilocation.interior;
12420
- if (interior === 'Here') {
12421
- return null;
12422
- }
12423
- for (var key in interior) {
12424
- var junctions = interior[key];
12425
- if (Array.isArray(junctions)) {
12426
- var _iterator = _createForOfIteratorHelper(junctions),
12427
- _step;
12428
- try {
12429
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
12430
- var junction = _step.value;
12431
- if ('Parachain' in junction) {
12432
- return Number(junction.Parachain);
12433
- }
12434
- }
12435
- } catch (err) {
12436
- _iterator.e(err);
12437
- } finally {
12438
- _iterator.f();
12439
- }
12440
- } else if (_typeof(junctions) === 'object' && junctions !== null && 'Parachain' in junctions) {
12441
- return Number(junctions.Parachain);
12442
- }
12198
+ var InvalidAddressError = /*#__PURE__*/function (_Error) {
12199
+ /**
12200
+ * Constructs a new InvalidAddressError.
12201
+ *
12202
+ * @param message - The error message.
12203
+ */
12204
+ function InvalidAddressError(message) {
12205
+ var _this;
12206
+ _classCallCheck(this, InvalidAddressError);
12207
+ _this = _callSuper(this, InvalidAddressError, [message]);
12208
+ _this.name = 'InvalidAddressError';
12209
+ return _this;
12443
12210
  }
12444
- return null;
12445
- };
12211
+ _inherits(InvalidAddressError, _Error);
12212
+ return _createClass(InvalidAddressError);
12213
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
12446
12214
 
12447
12215
  var DEFAULT_FEE_ASSET = 0;
12448
12216
  var ETH_CHAIN_ID = BigInt(1);
@@ -12464,7 +12232,10 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
12464
12232
  address = _ref.address,
12465
12233
  amount = _ref.amount,
12466
12234
  paraIdTo = _ref.paraIdTo;
12467
- var includeFee = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
12235
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
12236
+ includeFee: false
12237
+ },
12238
+ includeFee = _ref2.includeFee;
12468
12239
  // Handle the case when a destination is a multi-location
12469
12240
  var paraId = destination !== undefined && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
12470
12241
  return Object.assign({
@@ -12845,15 +12616,28 @@ var ParachainNode = /*#__PURE__*/function () {
12845
12616
  }, _callee, this);
12846
12617
  }));
12847
12618
  }
12619
+ }, {
12620
+ key: "getRelayToParaOverrides",
12621
+ value: function getRelayToParaOverrides() {
12622
+ return {
12623
+ section: 'reserve_transfer_assets',
12624
+ includeFee: false
12625
+ };
12626
+ }
12848
12627
  }, {
12849
12628
  key: "transferRelayToPara",
12850
12629
  value: function transferRelayToPara(options) {
12851
12630
  var _options$version = options.version,
12852
12631
  version = _options$version === void 0 ? exports.Version.V3 : _options$version;
12632
+ var _this$getRelayToParaO = this.getRelayToParaOverrides(),
12633
+ section = _this$getRelayToParaO.section,
12634
+ includeFee = _this$getRelayToParaO.includeFee;
12853
12635
  return {
12854
12636
  module: 'XcmPallet',
12855
- section: 'reserve_transfer_assets',
12856
- parameters: constructRelayToParaParameters(options, version)
12637
+ section: section,
12638
+ parameters: constructRelayToParaParameters(options, version, {
12639
+ includeFee: includeFee
12640
+ })
12857
12641
  };
12858
12642
  }
12859
12643
  }, {
@@ -13415,7 +13199,7 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
13415
13199
  key: "getProvider",
13416
13200
  value: function getProvider() {
13417
13201
  // Return the second WebSocket URL because the first one is sometimes unreliable.
13418
- return getNodeProviders(this.node)[2];
13202
+ return getNodeProviders(this.node)[3];
13419
13203
  }
13420
13204
  }]);
13421
13205
  }(ParachainNode);
@@ -13494,14 +13278,11 @@ var Moonbeam$2 = /*#__PURE__*/function (_ParachainNode) {
13494
13278
  }), 'transfer_assets', 'Unlimited'));
13495
13279
  }
13496
13280
  }, {
13497
- key: "transferRelayToPara",
13498
- value: function transferRelayToPara(options) {
13499
- var _options$version = options.version,
13500
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
13281
+ key: "getRelayToParaOverrides",
13282
+ value: function getRelayToParaOverrides() {
13501
13283
  return {
13502
- module: 'XcmPallet',
13503
13284
  section: 'limited_reserve_transfer_assets',
13504
- parameters: constructRelayToParaParameters(options, version, true)
13285
+ includeFee: true
13505
13286
  };
13506
13287
  }
13507
13288
  }, {
@@ -13755,14 +13536,11 @@ var Moonriver$2 = /*#__PURE__*/function (_ParachainNode) {
13755
13536
  }), 'transfer_assets', 'Unlimited'));
13756
13537
  }
13757
13538
  }, {
13758
- key: "transferRelayToPara",
13759
- value: function transferRelayToPara(options) {
13760
- var _options$version = options.version,
13761
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
13539
+ key: "getRelayToParaOverrides",
13540
+ value: function getRelayToParaOverrides() {
13762
13541
  return {
13763
- module: 'XcmPallet',
13764
13542
  section: 'limited_reserve_transfer_assets',
13765
- parameters: constructRelayToParaParameters(options, version, true)
13543
+ includeFee: true
13766
13544
  };
13767
13545
  }
13768
13546
  }, {
@@ -13886,38 +13664,133 @@ var InvArchTinker$2 = /*#__PURE__*/function (_ParachainNode) {
13886
13664
  _classCallCheck(this, InvArchTinker);
13887
13665
  return _callSuper(this, InvArchTinker, ['InvArchTinker', 'tinker', 'kusama', exports.Version.V3]);
13888
13666
  }
13889
- _inherits(InvArchTinker, _ParachainNode);
13890
- return _createClass(InvArchTinker, [{
13891
- key: "transferXTokens",
13892
- value: function transferXTokens(input) {
13893
- var asset = input.asset;
13894
- if (!isForeignAsset(asset) || !asset.assetId) {
13895
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
13667
+ _inherits(InvArchTinker, _ParachainNode);
13668
+ return _createClass(InvArchTinker, [{
13669
+ key: "transferXTokens",
13670
+ value: function transferXTokens(input) {
13671
+ var asset = input.asset;
13672
+ if (!isForeignAsset(asset) || !asset.assetId) {
13673
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
13674
+ }
13675
+ return XTokensTransferImpl.transferXTokens(input, BigInt(asset.assetId));
13676
+ }
13677
+ }]);
13678
+ }(ParachainNode);
13679
+
13680
+ var Karura$2 = /*#__PURE__*/function (_ParachainNode) {
13681
+ function Karura() {
13682
+ _classCallCheck(this, Karura);
13683
+ return _callSuper(this, Karura, ['Karura', 'karura', 'kusama', exports.Version.V3]);
13684
+ }
13685
+ _inherits(Karura, _ParachainNode);
13686
+ return _createClass(Karura, [{
13687
+ key: "transferXTokens",
13688
+ value: function transferXTokens(input) {
13689
+ return getNode('Acala').transferXTokens(input);
13690
+ }
13691
+ }, {
13692
+ key: "getProvider",
13693
+ value: function getProvider() {
13694
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
13695
+ return getNodeProviders(this.node)[4];
13696
+ }
13697
+ }]);
13698
+ }(ParachainNode);
13699
+
13700
+ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api, address) {
13701
+ var isMultiLocation = _typeof(address) === 'object';
13702
+ if (isMultiLocation) {
13703
+ return _defineProperty({}, exports.Version.V4, address);
13704
+ }
13705
+ var isEthAddress = ethers.ethers.isAddress(address);
13706
+ return _defineProperty({}, exports.Version.V4, {
13707
+ parents: exports.Parents.ZERO,
13708
+ interior: {
13709
+ X1: [isEthAddress ? {
13710
+ AccountKey20: {
13711
+ key: address
13712
+ }
13713
+ } : {
13714
+ AccountId32: {
13715
+ id: api.createAccountId(address),
13716
+ network: null
13717
+ }
13718
+ }]
13719
+ }
13720
+ });
13721
+ };
13722
+
13723
+ var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
13724
+ var isMultiLocation = _typeof(recipientAddress) === 'object';
13725
+ if (isMultiLocation) {
13726
+ return _defineProperty({}, version, recipientAddress);
13727
+ }
13728
+ var isEthAddress = ethers.ethers.isAddress(recipientAddress);
13729
+ if (scenario === 'ParaToRelay') {
13730
+ return _defineProperty({}, version, {
13731
+ parents: pallet === 'XTokens' ? exports.Parents.ONE : exports.Parents.ZERO,
13732
+ interior: createX1Payload(version, {
13733
+ AccountId32: Object.assign(Object.assign({}, version === exports.Version.V1 && {
13734
+ network: 'any'
13735
+ }), {
13736
+ id: api.createAccountId(recipientAddress)
13737
+ })
13738
+ })
13739
+ });
13740
+ }
13741
+ if (scenario === 'ParaToPara' && pallet === 'XTokens') {
13742
+ return _defineProperty({}, version, {
13743
+ parents: exports.Parents.ONE,
13744
+ interior: {
13745
+ X2: [{
13746
+ Parachain: nodeId
13747
+ }, isEthAddress ? {
13748
+ AccountKey20: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13749
+ network: 'any'
13750
+ }), {
13751
+ key: recipientAddress
13752
+ })
13753
+ } : {
13754
+ AccountId32: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13755
+ network: 'any'
13756
+ }), {
13757
+ id: api.createAccountId(recipientAddress)
13758
+ })
13759
+ }]
13760
+ }
13761
+ });
13762
+ }
13763
+ if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
13764
+ return _defineProperty({}, version, {
13765
+ parents: exports.Parents.ZERO,
13766
+ interior: createX1Payload(version, isEthAddress ? {
13767
+ AccountKey20: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13768
+ network: 'any'
13769
+ }), {
13770
+ key: recipientAddress
13771
+ })
13772
+ } : {
13773
+ AccountId32: Object.assign(Object.assign({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13774
+ network: 'any'
13775
+ }), {
13776
+ id: api.createAccountId(recipientAddress)
13777
+ })
13778
+ })
13779
+ });
13780
+ }
13781
+ return _defineProperty({}, version, {
13782
+ parents: exports.Parents.ZERO,
13783
+ interior: createX1Payload(version, isEthAddress ? {
13784
+ AccountKey20: {
13785
+ key: recipientAddress
13896
13786
  }
13897
- return XTokensTransferImpl.transferXTokens(input, BigInt(asset.assetId));
13898
- }
13899
- }]);
13900
- }(ParachainNode);
13901
-
13902
- var Karura$2 = /*#__PURE__*/function (_ParachainNode) {
13903
- function Karura() {
13904
- _classCallCheck(this, Karura);
13905
- return _callSuper(this, Karura, ['Karura', 'karura', 'kusama', exports.Version.V3]);
13906
- }
13907
- _inherits(Karura, _ParachainNode);
13908
- return _createClass(Karura, [{
13909
- key: "transferXTokens",
13910
- value: function transferXTokens(input) {
13911
- return getNode('Acala').transferXTokens(input);
13912
- }
13913
- }, {
13914
- key: "getProvider",
13915
- value: function getProvider() {
13916
- // Return the second WebSocket URL because the first one is sometimes unreliable.
13917
- return getNodeProviders(this.node)[4];
13918
- }
13919
- }]);
13920
- }(ParachainNode);
13787
+ } : {
13788
+ AccountId32: {
13789
+ id: api.createAccountId(recipientAddress)
13790
+ }
13791
+ })
13792
+ });
13793
+ };
13921
13794
 
13922
13795
  var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
13923
13796
  var api = _ref.api,
@@ -14124,14 +13997,11 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
14124
13997
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
14125
13998
  }
14126
13999
  }, {
14127
- key: "transferRelayToPara",
14128
- value: function transferRelayToPara(options) {
14129
- var _options$version = options.version,
14130
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14000
+ key: "getRelayToParaOverrides",
14001
+ value: function getRelayToParaOverrides() {
14131
14002
  return {
14132
- module: 'XcmPallet',
14133
14003
  section: 'limited_teleport_assets',
14134
- parameters: constructRelayToParaParameters(options, version, true)
14004
+ includeFee: true
14135
14005
  };
14136
14006
  }
14137
14007
  }, {
@@ -14152,6 +14022,12 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
14152
14022
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
14153
14023
  }
14154
14024
  }
14025
+ }, {
14026
+ key: "getProvider",
14027
+ value: function getProvider() {
14028
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
14029
+ return getNodeProviders(this.node)[1];
14030
+ }
14155
14031
  }]);
14156
14032
  }(ParachainNode);
14157
14033
 
@@ -14182,14 +14058,11 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
14182
14058
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14183
14059
  }
14184
14060
  }, {
14185
- key: "transferRelayToPara",
14186
- value: function transferRelayToPara(options) {
14187
- var _options$version = options.version,
14188
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14061
+ key: "getRelayToParaOverrides",
14062
+ value: function getRelayToParaOverrides() {
14189
14063
  return {
14190
- module: 'XcmPallet',
14191
14064
  section: 'limited_teleport_assets',
14192
- parameters: constructRelayToParaParameters(options, version, true)
14065
+ includeFee: true
14193
14066
  };
14194
14067
  }
14195
14068
  }, {
@@ -14218,16 +14091,11 @@ var CoretimeKusama$2 = /*#__PURE__*/function (_ParachainNode) {
14218
14091
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14219
14092
  }
14220
14093
  }, {
14221
- key: "transferRelayToPara",
14222
- value: function transferRelayToPara(options) {
14223
- // TESTED block hash on Rococo: 0x28929f7b2aeadbf3333f05d35bed18214a4b23dd270bd072f99e8a0131d22456
14224
- // https://rococo.subscan.io/extrinsic/0x469eec7dccb22696b0c95cf4f5eec4b367ad3dc23243a346cc2aad3cc9522800
14225
- var _options$version = options.version,
14226
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14094
+ key: "getRelayToParaOverrides",
14095
+ value: function getRelayToParaOverrides() {
14227
14096
  return {
14228
- module: 'XcmPallet',
14229
14097
  section: 'limited_teleport_assets',
14230
- parameters: constructRelayToParaParameters(options, version, true)
14098
+ includeFee: true
14231
14099
  };
14232
14100
  }
14233
14101
  }]);
@@ -14250,14 +14118,11 @@ var CoretimePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
14250
14118
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14251
14119
  }
14252
14120
  }, {
14253
- key: "transferRelayToPara",
14254
- value: function transferRelayToPara(options) {
14255
- var _options$version = options.version,
14256
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14121
+ key: "getRelayToParaOverrides",
14122
+ value: function getRelayToParaOverrides() {
14257
14123
  return {
14258
- module: 'XcmPallet',
14259
14124
  section: 'limited_teleport_assets',
14260
- parameters: constructRelayToParaParameters(options, version, true)
14125
+ includeFee: true
14261
14126
  };
14262
14127
  }
14263
14128
  }]);
@@ -14280,14 +14145,11 @@ var Encointer$2 = /*#__PURE__*/function (_ParachainNode) {
14280
14145
  throw new ScenarioNotSupportedError(this.node, input.scenario);
14281
14146
  }
14282
14147
  }, {
14283
- key: "transferRelayToPara",
14284
- value: function transferRelayToPara(options) {
14285
- var _options$version = options.version,
14286
- version = _options$version === void 0 ? exports.Version.V1 : _options$version;
14148
+ key: "getRelayToParaOverrides",
14149
+ value: function getRelayToParaOverrides() {
14287
14150
  return {
14288
- module: 'XcmPallet',
14289
14151
  section: 'limited_teleport_assets',
14290
- parameters: constructRelayToParaParameters(options, version, true)
14152
+ includeFee: true
14291
14153
  };
14292
14154
  }
14293
14155
  }]);
@@ -14338,14 +14200,11 @@ var PeoplePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
14338
14200
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14339
14201
  }
14340
14202
  }, {
14341
- key: "transferRelayToPara",
14342
- value: function transferRelayToPara(options) {
14343
- var _options$version = options.version,
14344
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14203
+ key: "getRelayToParaOverrides",
14204
+ value: function getRelayToParaOverrides() {
14345
14205
  return {
14346
- module: 'XcmPallet',
14347
14206
  section: 'limited_teleport_assets',
14348
- parameters: constructRelayToParaParameters(options, version, true)
14207
+ includeFee: true
14349
14208
  };
14350
14209
  }
14351
14210
  }]);
@@ -14368,14 +14227,11 @@ var PeopleKusama$2 = /*#__PURE__*/function (_ParachainNode) {
14368
14227
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14369
14228
  }
14370
14229
  }, {
14371
- key: "transferRelayToPara",
14372
- value: function transferRelayToPara(options) {
14373
- var _options$version = options.version,
14374
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14230
+ key: "getRelayToParaOverrides",
14231
+ value: function getRelayToParaOverrides() {
14375
14232
  return {
14376
- module: 'XcmPallet',
14377
14233
  section: 'limited_teleport_assets',
14378
- parameters: constructRelayToParaParameters(options, version, true)
14234
+ includeFee: true
14379
14235
  };
14380
14236
  }
14381
14237
  }]);
@@ -14698,14 +14554,11 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
14698
14554
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
14699
14555
  }
14700
14556
  }, {
14701
- key: "transferRelayToPara",
14702
- value: function transferRelayToPara(options) {
14703
- var _options$version = options.version,
14704
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14557
+ key: "getRelayToParaOverrides",
14558
+ value: function getRelayToParaOverrides() {
14705
14559
  return {
14706
- module: 'XcmPallet',
14707
14560
  section: 'limited_teleport_assets',
14708
- parameters: constructRelayToParaParameters(options, version, true)
14561
+ includeFee: true
14709
14562
  };
14710
14563
  }
14711
14564
  }, {
@@ -14924,14 +14777,11 @@ var BridgeHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
14924
14777
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14925
14778
  }
14926
14779
  }, {
14927
- key: "transferRelayToPara",
14928
- value: function transferRelayToPara(options) {
14929
- var _options$version = options.version,
14930
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14780
+ key: "getRelayToParaOverrides",
14781
+ value: function getRelayToParaOverrides() {
14931
14782
  return {
14932
- module: 'XcmPallet',
14933
14783
  section: 'limited_teleport_assets',
14934
- parameters: constructRelayToParaParameters(options, version, true)
14784
+ includeFee: true
14935
14785
  };
14936
14786
  }
14937
14787
  }]);
@@ -14957,14 +14807,11 @@ var BridgeHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
14957
14807
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
14958
14808
  }
14959
14809
  }, {
14960
- key: "transferRelayToPara",
14961
- value: function transferRelayToPara(options) {
14962
- var _options$version = options.version,
14963
- version = _options$version === void 0 ? exports.Version.V3 : _options$version;
14810
+ key: "getRelayToParaOverrides",
14811
+ value: function getRelayToParaOverrides() {
14964
14812
  return {
14965
- module: 'XcmPallet',
14966
14813
  section: 'limited_teleport_assets',
14967
- parameters: constructRelayToParaParameters(options, version, true)
14814
+ includeFee: true
14968
14815
  };
14969
14816
  }
14970
14817
  }]);
@@ -15076,7 +14923,7 @@ var Polimec$2 = /*#__PURE__*/function (_ParachainNode) {
15076
14923
  _classCallCheck(this, Polimec);
15077
14924
  _this = _callSuper(this, Polimec, ['Polimec', 'polimec', 'polkadot', exports.Version.V3]);
15078
14925
  _this.getAssetMultiLocation = function (asset) {
15079
- if (!isForeignAsset(asset) && asset.symbol === 'DOT') {
14926
+ if (asset.symbol === 'DOT') {
15080
14927
  return DOT_MULTILOCATION;
15081
14928
  }
15082
14929
  if (isForeignAsset(asset) && asset.multiLocation !== undefined) {
@@ -18029,51 +17876,213 @@ var Override = function Override(multiLocation) {
18029
17876
  * @param symbol - The symbol to normalize.
18030
17877
  * @returns The normalized symbol.
18031
17878
  */
18032
- var normalizeSymbol = function normalizeSymbol(symbol) {
18033
- if (!symbol) return '';
18034
- var lowerSymbol = symbol.toLowerCase();
18035
- return lowerSymbol.startsWith('xc') ? lowerSymbol.substring(2) : lowerSymbol;
17879
+ var normalizeSymbol = function normalizeSymbol(symbol) {
17880
+ if (!symbol) return '';
17881
+ var lowerSymbol = symbol.toLowerCase();
17882
+ return lowerSymbol.startsWith('xc') ? lowerSymbol.substring(2) : lowerSymbol;
17883
+ };
17884
+ /**
17885
+ * Retrieves the list of assets that are supported for transfers between two specified nodes.
17886
+ *
17887
+ * @param origin - The origin node.
17888
+ * @param destination - The destination node.
17889
+ * @returns An array of assets supported between the origin and destination nodes.
17890
+ */
17891
+ var getSupportedAssets = function getSupportedAssets(origin, destination) {
17892
+ var originAssets = getAssets(origin);
17893
+ var destinationAssets = getAssets(destination);
17894
+ if (destination === 'Ethereum' || origin === 'Ethereum') {
17895
+ return getOtherAssets('Ethereum');
17896
+ }
17897
+ if (origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot') {
17898
+ var polkadotAsset = getAssetBySymbolOrId('Polkadot', {
17899
+ symbol: 'DOT'
17900
+ }, null);
17901
+ var kusamaAsset = getAssetBySymbolOrId('Kusama', {
17902
+ symbol: 'KSM'
17903
+ }, null);
17904
+ return [].concat(_toConsumableArray(polkadotAsset ? [polkadotAsset] : []), _toConsumableArray(kusamaAsset ? [kusamaAsset] : []));
17905
+ }
17906
+ var supportedAssets = originAssets.filter(function (asset) {
17907
+ return destinationAssets.some(function (a) {
17908
+ return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
17909
+ });
17910
+ });
17911
+ if (origin === 'AssetHubPolkadot' && destination === 'BifrostPolkadot') {
17912
+ var wethAsset = getOtherAssets('Ethereum').find(function (_ref) {
17913
+ var symbol = _ref.symbol;
17914
+ return symbol === 'WETH';
17915
+ });
17916
+ if (wethAsset) supportedAssets.push({
17917
+ assetId: wethAsset.assetId,
17918
+ symbol: "".concat(wethAsset.symbol, ".e")
17919
+ });
17920
+ }
17921
+ return supportedAssets;
17922
+ };
17923
+
17924
+ var isPrimitive = function isPrimitive(obj) {
17925
+ return obj !== Object(obj);
17926
+ };
17927
+ var _deepEqual = function deepEqual(obj1, obj2) {
17928
+ if (obj1 === obj2) return true;
17929
+ if (isPrimitive(obj1) && isPrimitive(obj2)) return obj1 === obj2;
17930
+ if (_typeof(obj1) !== 'object' || obj1 === null || _typeof(obj2) !== 'object' || obj2 === null) {
17931
+ return false;
17932
+ }
17933
+ if (Array.isArray(obj1) !== Array.isArray(obj2)) {
17934
+ return false;
17935
+ }
17936
+ var obj1Keys = Object.keys(obj1).map(function (key) {
17937
+ return key.toLowerCase();
17938
+ });
17939
+ var obj2Keys = Object.keys(obj2).map(function (key) {
17940
+ return key.toLowerCase();
17941
+ });
17942
+ if (obj1Keys.length !== obj2Keys.length) return false;
17943
+ var _iterator = _createForOfIteratorHelper(obj1Keys),
17944
+ _step;
17945
+ try {
17946
+ var _loop = function _loop() {
17947
+ var key = _step.value;
17948
+ var keyInObj2 = obj2Keys.find(function (k) {
17949
+ return k === key;
17950
+ });
17951
+ if (!keyInObj2) return {
17952
+ v: false
17953
+ };
17954
+ var obj1Value = obj1[Object.keys(obj1).find(function (k) {
17955
+ return k.toLowerCase() === key;
17956
+ })];
17957
+ var obj2Value = obj2[Object.keys(obj2).find(function (k) {
17958
+ return k.toLowerCase() === key;
17959
+ })];
17960
+ if (!_deepEqual(obj1Value, obj2Value)) return {
17961
+ v: false
17962
+ };
17963
+ },
17964
+ _ret;
17965
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
17966
+ _ret = _loop();
17967
+ if (_ret) return _ret.v;
17968
+ }
17969
+ } catch (err) {
17970
+ _iterator.e(err);
17971
+ } finally {
17972
+ _iterator.f();
17973
+ }
17974
+ return true;
17975
+ };
17976
+
17977
+ var getFees = function getFees(scenario) {
17978
+ if (scenario === 'ParaToRelay') {
17979
+ return 4600000000;
17980
+ } else if (scenario === 'ParaToPara') {
17981
+ return 399600000000;
17982
+ }
17983
+ throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
17984
+ };
17985
+
17986
+ /**
17987
+ * Retrieves the node instance for a given node.
17988
+ *
17989
+ * @param node - The node identifier.
17990
+ * @returns The node instance
17991
+ */
17992
+ var getNode = function getNode(node) {
17993
+ var nodeMap = nodes();
17994
+ return nodeMap[node];
17995
+ };
17996
+
17997
+ var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
17998
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17999
+ var wsUrl;
18000
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18001
+ while (1) switch (_context.prev = _context.next) {
18002
+ case 0:
18003
+ if (!(node === 'Polkadot' || node === 'Kusama')) {
18004
+ _context.next = 3;
18005
+ break;
18006
+ }
18007
+ wsUrl = getNodeProvider(node);
18008
+ return _context.abrupt("return", api.createApiInstance(wsUrl));
18009
+ case 3:
18010
+ return _context.abrupt("return", getNode(node).createApiInstance(api));
18011
+ case 4:
18012
+ case "end":
18013
+ return _context.stop();
18014
+ }
18015
+ }, _callee);
18016
+ }));
18017
+ };
18018
+
18019
+ var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
18020
+ if (node === 'Polkadot') {
18021
+ return 'DOT';
18022
+ } else if (node === 'Kusama') {
18023
+ return 'KSM';
18024
+ } else {
18025
+ return getRelayChainSymbol(node);
18026
+ }
18027
+ };
18028
+
18029
+ // Contains important call creation utils (Selection of fees,formating of header and more.. )
18030
+ /**
18031
+ * Determines the relay chain for a given node.
18032
+ *
18033
+ * @param node - The node for which to determine the relay chain.
18034
+ * @returns 'Kusama' if the node's relay chain symbol is 'KSM'; otherwise, 'Polkadot'.
18035
+ */
18036
+ var determineRelayChain = function determineRelayChain(node) {
18037
+ return getRelayChainSymbol(node) === 'KSM' ? 'Kusama' : 'Polkadot';
18036
18038
  };
18037
18039
  /**
18038
- * Retrieves the list of assets that are supported for transfers between two specified nodes.
18040
+ * Determines whether a given node is a relay chain (Polkadot or Kusama).
18039
18041
  *
18040
- * @param origin - The origin node.
18041
- * @param destination - The destination node.
18042
- * @returns An array of assets supported between the origin and destination nodes.
18042
+ * @param node - The node to check.
18043
+ * @returns True if the node is 'Polkadot' or 'Kusama'; otherwise, false.
18043
18044
  */
18044
- var getSupportedAssets = function getSupportedAssets(origin, destination) {
18045
- var originAssets = getAssets(origin);
18046
- var destinationAssets = getAssets(destination);
18047
- if (destination === 'Ethereum' || origin === 'Ethereum') {
18048
- return getOtherAssets('Ethereum');
18049
- }
18050
- if (origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot') {
18051
- var polkadotAsset = getAssetBySymbolOrId('Polkadot', {
18052
- symbol: 'DOT'
18053
- }, null);
18054
- var kusamaAsset = getAssetBySymbolOrId('Kusama', {
18055
- symbol: 'KSM'
18056
- }, null);
18057
- return [].concat(_toConsumableArray(polkadotAsset ? [polkadotAsset] : []), _toConsumableArray(kusamaAsset ? [kusamaAsset] : []));
18058
- }
18059
- var supportedAssets = originAssets.filter(function (asset) {
18060
- return destinationAssets.some(function (a) {
18061
- return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
18062
- });
18063
- });
18064
- if (origin === 'AssetHubPolkadot' && destination === 'BifrostPolkadot') {
18065
- var wethAsset = getOtherAssets('Ethereum').find(function (_ref) {
18066
- var symbol = _ref.symbol;
18067
- return symbol === 'WETH';
18068
- });
18069
- if (wethAsset) supportedAssets.push({
18070
- assetId: wethAsset.assetId,
18071
- symbol: "".concat(wethAsset.symbol, ".e")
18072
- });
18045
+ var isRelayChain = function isRelayChain(node) {
18046
+ return node === 'Polkadot' || node === 'Kusama';
18047
+ };
18048
+
18049
+ var validateDestinationAddress = function validateDestinationAddress(address, destination) {
18050
+ if (typeof address === 'string' && destination && !isTMultiLocation(destination)) {
18051
+ var isDestinationEvm = isNodeEvm(destination);
18052
+ var isEthereumAddress = ethers.ethers.isAddress(address);
18053
+ if (isDestinationEvm) {
18054
+ if (!isEthereumAddress) {
18055
+ throw new InvalidAddressError('Destination node is an EVM chain, but the address provided is not a valid Ethereum address.');
18056
+ }
18057
+ } else {
18058
+ if (isEthereumAddress) {
18059
+ throw new InvalidAddressError('EVM address provided but destination is not an EVM chain.');
18060
+ }
18061
+ }
18073
18062
  }
18074
- return supportedAssets;
18075
18063
  };
18076
18064
 
18065
+ var determineAssetCheckEnabled = function determineAssetCheckEnabled(origin, currency, isBridge) {
18066
+ var originNode = getNode(origin);
18067
+ return 'multiasset' in currency || 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) || isBridge ? false : originNode.assetCheckEnabled;
18068
+ };
18069
+
18070
+ var isBridgeTransfer = function isBridgeTransfer(origin, destination) {
18071
+ return origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
18072
+ };
18073
+
18074
+ var KeepAliveError = /*#__PURE__*/function (_Error) {
18075
+ function KeepAliveError(message) {
18076
+ var _this;
18077
+ _classCallCheck(this, KeepAliveError);
18078
+ _this = _callSuper(this, KeepAliveError, [message]);
18079
+ _this.name = 'KeepAliveError';
18080
+ return _this;
18081
+ }
18082
+ _inherits(KeepAliveError, _Error);
18083
+ return _createClass(KeepAliveError);
18084
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
18085
+
18077
18086
  var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
18078
18087
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18079
18088
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -18203,205 +18212,193 @@ var checkKeepAlive = function checkKeepAlive(_a) {
18203
18212
  });
18204
18213
  };
18205
18214
 
18206
- var validateDestinationAddress = function validateDestinationAddress(address, destination) {
18207
- if (typeof address === 'string' && destination && !isTMultiLocation(destination)) {
18208
- var isDestinationEvm = isNodeEvm(destination);
18209
- var isEthereumAddress = ethers.ethers.isAddress(address);
18210
- if (isDestinationEvm) {
18211
- if (!isEthereumAddress) {
18212
- throw new InvalidAddressError('Destination node is an EVM chain, but the address provided is not a valid Ethereum address.');
18213
- }
18214
- } else {
18215
- if (isEthereumAddress) {
18216
- throw new InvalidAddressError('EVM address provided but destination is not an EVM chain.');
18217
- }
18215
+ var performKeepAliveCheck = function performKeepAliveCheck(_a, asset_1) {
18216
+ return __awaiter(void 0, [_a, asset_1], void 0, function (_ref, asset) {
18217
+ var api = _ref.api,
18218
+ origin = _ref.origin,
18219
+ destApiForKeepAlive = _ref.destApiForKeepAlive,
18220
+ amount = _ref.amount,
18221
+ currency = _ref.currency,
18222
+ address = _ref.address,
18223
+ destination = _ref.destination;
18224
+ return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18225
+ var amountStr;
18226
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18227
+ while (1) switch (_context.prev = _context.next) {
18228
+ case 0:
18229
+ amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
18230
+ if (!('multilocation' in currency || 'multiasset' in currency)) {
18231
+ _context.next = 5;
18232
+ break;
18233
+ }
18234
+ console.warn('Keep alive check is not supported when using MultiLocation as currency.');
18235
+ _context.next = 23;
18236
+ break;
18237
+ case 5:
18238
+ if (!(_typeof(address) === 'object')) {
18239
+ _context.next = 9;
18240
+ break;
18241
+ }
18242
+ console.warn('Keep alive check is not supported when using MultiLocation as address.');
18243
+ _context.next = 23;
18244
+ break;
18245
+ case 9:
18246
+ if (!(_typeof(destination) === 'object')) {
18247
+ _context.next = 13;
18248
+ break;
18249
+ }
18250
+ console.warn('Keep alive check is not supported when using MultiLocation as destination.');
18251
+ _context.next = 23;
18252
+ break;
18253
+ case 13:
18254
+ if (!(destination === 'Ethereum')) {
18255
+ _context.next = 17;
18256
+ break;
18257
+ }
18258
+ console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
18259
+ _context.next = 23;
18260
+ break;
18261
+ case 17:
18262
+ if (asset) {
18263
+ _context.next = 21;
18264
+ break;
18265
+ }
18266
+ console.warn('Keep alive check is not supported when asset check is disabled.');
18267
+ _context.next = 23;
18268
+ break;
18269
+ case 21:
18270
+ _context.next = 23;
18271
+ return checkKeepAlive({
18272
+ originApi: api,
18273
+ address: address,
18274
+ amount: amountStr !== null && amountStr !== void 0 ? amountStr : '',
18275
+ originNode: origin,
18276
+ destApi: destApiForKeepAlive,
18277
+ asset: asset,
18278
+ destNode: destination
18279
+ });
18280
+ case 23:
18281
+ case "end":
18282
+ return _context.stop();
18283
+ }
18284
+ }, _callee);
18285
+ })();
18286
+ });
18287
+ };
18288
+
18289
+ var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
18290
+ var isRelayDestination = destination === undefined;
18291
+ return assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination ? determineRelayChain(origin) : !isTMultiLocation(destination) ? destination : null) : null;
18292
+ };
18293
+
18294
+ var validateCurrency = function validateCurrency(currency, amount, feeAsset) {
18295
+ if ((!('multiasset' in currency) || 'multilocation' in currency) && amount === null) {
18296
+ throw new Error('Amount is required');
18297
+ }
18298
+ if ('multiasset' in currency) {
18299
+ if (amount !== null) {
18300
+ console.warn('Amount is ignored when using overriding currency using multiple multi locations. Please set it to null.');
18301
+ }
18302
+ if (currency.multiasset.length === 0) {
18303
+ throw new InvalidCurrencyError('Overrided multi assets cannot be empty');
18304
+ }
18305
+ if (currency.multiasset.length === 1 && (feeAsset === 0 || feeAsset !== undefined)) {
18306
+ throw new InvalidCurrencyError('Overrided single multi asset cannot be used with fee asset');
18307
+ }
18308
+ if (currency.multiasset.length > 1 && feeAsset === undefined) {
18309
+ throw new InvalidCurrencyError('Overrided multi assets cannot be used without specifying fee asset');
18310
+ }
18311
+ if (currency.multiasset.length > 1 && feeAsset !== undefined && (feeAsset < 0 || feeAsset >= currency.multiasset.length)) {
18312
+ throw new InvalidCurrencyError('Fee asset index is out of bounds. Please provide a valid index.');
18313
+ }
18314
+ }
18315
+ };
18316
+ var validateDestination = function validateDestination(origin, destination) {
18317
+ if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration') {
18318
+ throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
18319
+ }
18320
+ var isMultiLocationDestination = _typeof(destination) === 'object';
18321
+ var isBridge = isBridgeTransfer(origin, destination);
18322
+ var isRelayDestination = destination === undefined;
18323
+ if (!isRelayDestination && !isMultiLocationDestination) {
18324
+ var originRelayChainSymbol = getRelayChainSymbol(origin);
18325
+ var destinationRelayChainSymbol = getRelayChainSymbol(destination);
18326
+ if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
18327
+ throw new IncompatibleNodesError();
18328
+ }
18329
+ }
18330
+ };
18331
+ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
18332
+ if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
18333
+ throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
18334
+ }
18335
+ if (!assetCheckEnabled && 'id' in currency) {
18336
+ throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
18337
+ }
18338
+ };
18339
+ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
18340
+ var origin = _ref.origin,
18341
+ destination = _ref.destination,
18342
+ currency = _ref.currency;
18343
+ var isRelayDestination = destination === undefined;
18344
+ var isMultiLocationDestination = _typeof(destination) === 'object';
18345
+ var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
18346
+ var pallet = getDefaultPallet(origin);
18347
+ var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
18348
+ if (!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost) {
18349
+ var nativeAssets = getNativeAssets(destination);
18350
+ if (origin === 'Hydration') {
18351
+ nativeAssets = nativeAssets.filter(function (nativeAsset) {
18352
+ return nativeAsset.symbol !== 'DOT';
18353
+ });
18354
+ }
18355
+ if ('symbol' in currency && nativeAssets.some(function (nativeAsset) {
18356
+ var _a;
18357
+ return nativeAsset.symbol.toLowerCase() === ((_a = asset === null || asset === void 0 ? void 0 : asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase());
18358
+ })) {
18359
+ throw new InvalidCurrencyError("".concat(JSON.stringify(asset === null || asset === void 0 ? void 0 : asset.symbol), " is not supported for transfers to ").concat(destination, "."));
18218
18360
  }
18219
18361
  }
18362
+ if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
18363
+ throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
18364
+ }
18365
+ if (!isBridge && asset === null && assetCheckEnabled) {
18366
+ throwUnsupportedCurrency(currency, origin);
18367
+ }
18220
18368
  };
18221
18369
 
18222
18370
  var send = function send(options) {
18223
18371
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18224
- var api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, isBifrost, asset, nativeAssets, amountStr, resolvedAsset;
18372
+ var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, originNode, isBridge, assetCheckEnabled, asset, resolvedAsset;
18225
18373
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18226
18374
  while (1) switch (_context.prev = _context.next) {
18227
18375
  case 0:
18228
18376
  api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, feeAsset = options.feeAsset, version = options.version, ahAddress = options.ahAddress;
18229
- if (!((!('multiasset' in currency) || 'multilocation' in currency) && amount === null)) {
18230
- _context.next = 3;
18231
- break;
18232
- }
18233
- throw new Error('Amount is required');
18234
- case 3:
18235
- if (!('multilocation' in currency && (feeAsset === 0 || feeAsset !== undefined))) {
18236
- _context.next = 5;
18237
- break;
18238
- }
18239
- throw new InvalidCurrencyError('Overrided single multi asset cannot be used with fee asset');
18240
- case 5:
18241
- if (!('multiasset' in currency)) {
18242
- _context.next = 15;
18243
- break;
18244
- }
18245
- if (amount !== null) {
18246
- console.warn('Amount is ignored when using overriding currency using multiple multi locations. Please set it to null.');
18247
- }
18248
- if (!(currency.multiasset.length === 0)) {
18249
- _context.next = 9;
18250
- break;
18251
- }
18252
- throw new InvalidCurrencyError('Overrided multi assets cannot be empty');
18253
- case 9:
18254
- if (!(currency.multiasset.length === 1 && (feeAsset === 0 || feeAsset !== undefined))) {
18255
- _context.next = 11;
18256
- break;
18257
- }
18258
- throw new InvalidCurrencyError('Overrided single multi asset cannot be used with fee asset');
18259
- case 11:
18260
- if (!(currency.multiasset.length > 1 && feeAsset === undefined)) {
18261
- _context.next = 13;
18262
- break;
18263
- }
18264
- throw new InvalidCurrencyError('Overrided multi assets cannot be used without specifying fee asset');
18265
- case 13:
18266
- if (!(currency.multiasset.length > 1 && feeAsset !== undefined && (feeAsset < 0 || feeAsset >= currency.multiasset.length))) {
18267
- _context.next = 15;
18268
- break;
18269
- }
18270
- throw new InvalidCurrencyError('Fee asset index is out of bounds. Please provide a valid index.');
18271
- case 15:
18272
- if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration')) {
18273
- _context.next = 17;
18274
- break;
18275
- }
18276
- throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
18277
- case 17:
18278
- isMultiLocationDestination = _typeof(destination) === 'object';
18279
- isBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
18280
- isRelayDestination = destination === undefined;
18281
- if (!(!isRelayDestination && !isMultiLocationDestination)) {
18282
- _context.next = 25;
18283
- break;
18284
- }
18285
- originRelayChainSymbol = getRelayChainSymbol(origin);
18286
- destinationRelayChainSymbol = getRelayChainSymbol(destination);
18287
- if (!(!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol)) {
18288
- _context.next = 25;
18289
- break;
18290
- }
18291
- throw new IncompatibleNodesError();
18292
- case 25:
18293
- originNode = getNode(origin);
18294
- assetCheckEnabled = 'multiasset' in currency || 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) || isBridge ? false : originNode.assetCheckEnabled;
18377
+ validateCurrency(currency, amount, feeAsset);
18378
+ validateDestination(origin, destination);
18295
18379
  validateDestinationAddress(address, destination);
18296
- isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
18297
- pallet = getDefaultPallet(origin);
18298
- isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
18299
- if (!(!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol))) {
18300
- _context.next = 33;
18301
- break;
18302
- }
18303
- throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
18304
- case 33:
18305
- if (!(!assetCheckEnabled && 'id' in currency)) {
18306
- _context.next = 35;
18307
- break;
18308
- }
18309
- throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
18310
- case 35:
18311
- asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination ? determineRelayChain(origin) : !isTMultiLocation(destination) ? destination : null) : null;
18312
- if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
18313
- _context.next = 41;
18314
- break;
18315
- }
18316
- nativeAssets = getNativeAssets(destination);
18317
- if (origin === 'Hydration') {
18318
- nativeAssets = nativeAssets.filter(function (nativeAsset) {
18319
- return nativeAsset.symbol !== 'DOT';
18320
- });
18321
- }
18322
- if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
18323
- var _a;
18324
- return nativeAsset.symbol.toLowerCase() === ((_a = asset === null || asset === void 0 ? void 0 : asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase());
18325
- }))) {
18326
- _context.next = 41;
18327
- break;
18328
- }
18329
- throw new InvalidCurrencyError("".concat(JSON.stringify(asset === null || asset === void 0 ? void 0 : asset.symbol), " is not supported for transfers to ").concat(destination, "."));
18330
- case 41:
18331
- if (!isBridge && asset === null && assetCheckEnabled) {
18332
- throwUnsupportedCurrency(currency, origin);
18333
- }
18334
- if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
18335
- _context.next = 44;
18336
- break;
18337
- }
18338
- throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
18339
- case 44:
18340
- _context.next = 46;
18380
+ originNode = getNode(origin);
18381
+ isBridge = isBridgeTransfer(origin, destination);
18382
+ assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
18383
+ validateAssetSpecifiers(assetCheckEnabled, currency);
18384
+ asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
18385
+ validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
18386
+ _context.next = 12;
18341
18387
  return api.init(origin);
18342
- case 46:
18343
- _context.prev = 46;
18344
- amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
18345
- if (!('multilocation' in currency || 'multiasset' in currency)) {
18346
- _context.next = 52;
18347
- break;
18348
- }
18349
- console.warn('Keep alive check is not supported when using MultiLocation as currency.');
18350
- _context.next = 70;
18351
- break;
18352
- case 52:
18353
- if (!(_typeof(address) === 'object')) {
18354
- _context.next = 56;
18355
- break;
18356
- }
18357
- console.warn('Keep alive check is not supported when using MultiLocation as address.');
18358
- _context.next = 70;
18359
- break;
18360
- case 56:
18361
- if (!(_typeof(destination) === 'object')) {
18362
- _context.next = 60;
18363
- break;
18364
- }
18365
- console.warn('Keep alive check is not supported when using MultiLocation as destination.');
18366
- _context.next = 70;
18367
- break;
18368
- case 60:
18369
- if (!(destination === 'Ethereum')) {
18370
- _context.next = 64;
18371
- break;
18372
- }
18373
- console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
18374
- _context.next = 70;
18375
- break;
18376
- case 64:
18377
- if (asset) {
18378
- _context.next = 68;
18379
- break;
18380
- }
18381
- console.warn('Keep alive check is not supported when asset check is disabled.');
18382
- _context.next = 70;
18383
- break;
18384
- case 68:
18385
- _context.next = 70;
18386
- return checkKeepAlive({
18387
- originApi: api,
18388
- address: address,
18389
- amount: amountStr !== null && amountStr !== void 0 ? amountStr : '',
18390
- originNode: origin,
18391
- destApi: destApiForKeepAlive,
18392
- asset: asset,
18393
- destNode: destination
18394
- });
18395
- case 70:
18388
+ case 12:
18389
+ _context.prev = 12;
18390
+ _context.next = 15;
18391
+ return performKeepAliveCheck(options, asset);
18392
+ case 15:
18396
18393
  // In case asset check is disabled, we create asset object from currency symbol
18397
18394
  resolvedAsset = asset !== null && asset !== void 0 ? asset : {
18398
18395
  symbol: 'symbol' in currency ? currency.symbol : undefined
18399
18396
  };
18400
- _context.next = 73;
18397
+ _context.next = 18;
18401
18398
  return originNode.transfer({
18402
18399
  api: api,
18403
18400
  asset: resolvedAsset,
18404
- amount: amountStr !== null && amountStr !== void 0 ? amountStr : '',
18401
+ amount: (_a = amount === null || amount === void 0 ? void 0 : amount.toString()) !== null && _a !== void 0 ? _a : '',
18405
18402
  address: address,
18406
18403
  destination: destination,
18407
18404
  paraIdTo: paraIdTo,
@@ -18411,62 +18408,63 @@ var send = function send(options) {
18411
18408
  destApiForKeepAlive: destApiForKeepAlive,
18412
18409
  ahAddress: ahAddress
18413
18410
  });
18414
- case 73:
18411
+ case 18:
18415
18412
  return _context.abrupt("return", _context.sent);
18416
- case 74:
18417
- _context.prev = 74;
18413
+ case 19:
18414
+ _context.prev = 19;
18418
18415
  if (!isPjsClient(api)) {
18419
- _context.next = 78;
18416
+ _context.next = 23;
18420
18417
  break;
18421
18418
  }
18422
- _context.next = 78;
18419
+ _context.next = 23;
18423
18420
  return api.disconnect();
18424
- case 78:
18425
- return _context.finish(74);
18426
- case 79:
18421
+ case 23:
18422
+ return _context.finish(19);
18423
+ case 24:
18427
18424
  case "end":
18428
18425
  return _context.stop();
18429
18426
  }
18430
- }, _callee, null, [[46,, 74, 79]]);
18427
+ }, _callee, null, [[12,, 19, 24]]);
18431
18428
  }));
18432
18429
  };
18430
+
18433
18431
  var transferRelayToPara = function transferRelayToPara(options) {
18434
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
18432
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18435
18433
  var api, destination, amount, address, paraIdTo, destApiForKeepAlive, version, isMultiLocationDestination, isAddressMultiLocation, amountStr, serializedApiCall;
18436
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
18437
- while (1) switch (_context2.prev = _context2.next) {
18434
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18435
+ while (1) switch (_context.prev = _context.next) {
18438
18436
  case 0:
18439
18437
  api = options.api, destination = options.destination, amount = options.amount, address = options.address, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, version = options.version;
18440
18438
  isMultiLocationDestination = _typeof(destination) === 'object';
18441
18439
  isAddressMultiLocation = _typeof(address) === 'object';
18442
- if (!(api === undefined && isMultiLocationDestination)) {
18443
- _context2.next = 5;
18440
+ if (!(api.getApiOrUrl() === undefined && isMultiLocationDestination)) {
18441
+ _context.next = 5;
18444
18442
  break;
18445
18443
  }
18446
18444
  throw new Error('API is required when using MultiLocation as destination.');
18447
18445
  case 5:
18448
- _context2.next = 7;
18446
+ _context.next = 7;
18449
18447
  return api.init(determineRelayChain(destination));
18450
18448
  case 7:
18451
- _context2.prev = 7;
18449
+ _context.prev = 7;
18452
18450
  amountStr = amount.toString();
18453
18451
  if (!isMultiLocationDestination) {
18454
- _context2.next = 13;
18452
+ _context.next = 13;
18455
18453
  break;
18456
18454
  }
18457
18455
  console.warn('Keep alive check is not supported when using MultiLocation as destination.');
18458
- _context2.next = 19;
18456
+ _context.next = 19;
18459
18457
  break;
18460
18458
  case 13:
18461
18459
  if (!isAddressMultiLocation) {
18462
- _context2.next = 17;
18460
+ _context.next = 17;
18463
18461
  break;
18464
18462
  }
18465
18463
  console.warn('Keep alive check is not supported when using MultiLocation as address.');
18466
- _context2.next = 19;
18464
+ _context.next = 19;
18467
18465
  break;
18468
18466
  case 17:
18469
- _context2.next = 19;
18467
+ _context.next = 19;
18470
18468
  return checkKeepAlive({
18471
18469
  originApi: api,
18472
18470
  address: address,
@@ -18487,22 +18485,22 @@ var transferRelayToPara = function transferRelayToPara(options) {
18487
18485
  destApiForKeepAlive: destApiForKeepAlive,
18488
18486
  version: version
18489
18487
  });
18490
- return _context2.abrupt("return", api.callTxMethod(serializedApiCall));
18488
+ return _context.abrupt("return", api.callTxMethod(serializedApiCall));
18491
18489
  case 21:
18492
- _context2.prev = 21;
18490
+ _context.prev = 21;
18493
18491
  if (!isPjsClient(api)) {
18494
- _context2.next = 25;
18492
+ _context.next = 25;
18495
18493
  break;
18496
18494
  }
18497
- _context2.next = 25;
18495
+ _context.next = 25;
18498
18496
  return api.disconnect();
18499
18497
  case 25:
18500
- return _context2.finish(21);
18498
+ return _context.finish(21);
18501
18499
  case 26:
18502
18500
  case "end":
18503
- return _context2.stop();
18501
+ return _context.stop();
18504
18502
  }
18505
- }, _callee2, null, [[7,, 21, 26]]);
18503
+ }, _callee, null, [[7,, 21, 26]]);
18506
18504
  }));
18507
18505
  };
18508
18506
 
@@ -18715,6 +18713,11 @@ var PapiApi = /*#__PURE__*/function () {
18715
18713
  value: function setApi(api) {
18716
18714
  this._api = api;
18717
18715
  }
18716
+ }, {
18717
+ key: "getApiOrUrl",
18718
+ value: function getApiOrUrl() {
18719
+ return this._api;
18720
+ }
18718
18721
  }, {
18719
18722
  key: "getApi",
18720
18723
  value: function getApi() {