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