@paraspell/sdk-pjs 12.2.0 → 12.2.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +151 -153
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getEvmPrivateKeyHex, isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, RELAY_LOCATION, getRelayChainOf, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getEvmPrivateKeyHex, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, RELAY_LOCATION, getRelayChainOf, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
4
4
  import { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
@@ -14,6 +14,15 @@ var createKeyringPair = function createKeyringPair(path) {
14
14
  return evmPrivateKey ? keyring.createFromUri(evmPrivateKey, undefined, 'ethereum') : keyring.addFromUri(path);
15
15
  };
16
16
 
17
+ var lowercaseFirstLetter = function lowercaseFirstLetter(value) {
18
+ return value.charAt(0).toLowerCase() + value.slice(1);
19
+ };
20
+ var snakeToCamel = function snakeToCamel(str) {
21
+ return str.toLowerCase().replace(/([-_][a-z])/g, function (group) {
22
+ return group.toUpperCase().replace('-', '').replace('_', '');
23
+ });
24
+ };
25
+
17
26
  function _arrayLikeToArray(r, a) {
18
27
  (null == a || a > r.length) && (a = r.length);
19
28
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -238,17 +247,53 @@ function _unsupportedIterableToArray(r, a) {
238
247
  }
239
248
  }
240
249
 
241
- var lowercaseFirstLetter = function lowercaseFirstLetter(value) {
242
- return value.charAt(0).toLowerCase() + value.slice(1);
243
- };
244
- var snakeToCamel = function snakeToCamel(str) {
245
- return str.toLowerCase().replace(/([-_][a-z])/g, function (group) {
246
- return group.toUpperCase().replace('-', '').replace('_', '');
247
- });
248
- };
250
+ // Cache settings
251
+ var DEFAULT_TTL_MS = 60000; // 1 minute
252
+ var MAX_CLIENTS = 100;
253
+ var EXTENSION_MS = 5 * 60000; // 5 minutes
254
+
255
+ var clientPool = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
256
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(client) {
257
+ return _regenerator().w(function (_context) {
258
+ while (1) switch (_context.n) {
259
+ case 0:
260
+ _context.n = 1;
261
+ return client.rpc.system.properties();
262
+ case 1:
263
+ return _context.a(2);
264
+ }
265
+ }, _callee);
266
+ }));
267
+ return function (_x) {
268
+ return _ref.apply(this, arguments);
269
+ };
270
+ }(), function (_key, entry) {
271
+ void entry.client.disconnect();
272
+ }, EXTENSION_MS);
273
+ var createPolkadotJsClient = /*#__PURE__*/function () {
274
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(ws) {
275
+ var wsProvider;
276
+ return _regenerator().w(function (_context2) {
277
+ while (1) switch (_context2.n) {
278
+ case 0:
279
+ wsProvider = new WsProvider(ws);
280
+ return _context2.a(2, ApiPromise.create({
281
+ provider: wsProvider
282
+ }));
283
+ }
284
+ }, _callee2);
285
+ }));
286
+ return function createPolkadotJsClient(_x2) {
287
+ return _ref2.apply(this, arguments);
288
+ };
289
+ }();
290
+ var _createClientPoolHelp = createClientPoolHelpers(clientPool, createPolkadotJsClient),
291
+ leaseClient = _createClientPoolHelp.leaseClient,
292
+ releaseClient = _createClientPoolHelp.releaseClient;
249
293
  var PolkadotJsApi = /*#__PURE__*/function () {
250
294
  function PolkadotJsApi(config) {
251
295
  _classCallCheck(this, PolkadotJsApi);
296
+ this._ttlMs = DEFAULT_TTL_MS;
252
297
  this.initialized = false;
253
298
  this.disconnectAllowed = true;
254
299
  this._config = config;
@@ -266,36 +311,40 @@ var PolkadotJsApi = /*#__PURE__*/function () {
266
311
  }, {
267
312
  key: "init",
268
313
  value: function () {
269
- var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, _clientTtlMs) {
270
- var apiConfig;
271
- return _regenerator().w(function (_context) {
272
- while (1) switch (_context.n) {
314
+ var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
315
+ var clientTtlMs,
316
+ apiConfig,
317
+ _args = arguments;
318
+ return _regenerator().w(function (_context3) {
319
+ while (1) switch (_context3.n) {
273
320
  case 0:
321
+ clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
274
322
  if (!(this.initialized || chain === 'Ethereum')) {
275
- _context.n = 1;
323
+ _context3.n = 1;
276
324
  break;
277
325
  }
278
- return _context.a(2);
326
+ return _context3.a(2);
279
327
  case 1:
328
+ this._ttlMs = clientTtlMs;
280
329
  this._chain = chain;
281
330
  apiConfig = this.getApiConfigForChain(chain);
282
331
  if (!(isConfig(this._config) && this._config.development && !apiConfig)) {
283
- _context.n = 2;
332
+ _context3.n = 2;
284
333
  break;
285
334
  }
286
335
  throw new MissingChainApiError(chain);
287
336
  case 2:
288
- _context.n = 3;
337
+ _context3.n = 3;
289
338
  return this.resolveApi(apiConfig, chain);
290
339
  case 3:
291
- this.api = _context.v;
340
+ this.api = _context3.v;
292
341
  this.initialized = true;
293
342
  case 4:
294
- return _context.a(2);
343
+ return _context3.a(2);
295
344
  }
296
- }, _callee, this);
345
+ }, _callee3, this);
297
346
  }));
298
- function init(_x, _x2) {
347
+ function init(_x3) {
299
348
  return _init.apply(this, arguments);
300
349
  }
301
350
  return init;
@@ -311,54 +360,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
311
360
  }
312
361
  }, {
313
362
  key: "resolveApi",
314
- value: function () {
315
- var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(apiConfig, chain) {
316
- var wsUrl;
317
- return _regenerator().w(function (_context2) {
318
- while (1) switch (_context2.n) {
319
- case 0:
320
- if (apiConfig) {
321
- _context2.n = 1;
322
- break;
323
- }
324
- wsUrl = getChainProviders(chain);
325
- return _context2.a(2, this.createApiInstance(wsUrl, chain));
326
- case 1:
327
- if (!(typeof apiConfig === 'string' || apiConfig instanceof Array)) {
328
- _context2.n = 2;
329
- break;
330
- }
331
- return _context2.a(2, this.createApiInstance(apiConfig, chain));
332
- case 2:
333
- return _context2.a(2, apiConfig);
334
- }
335
- }, _callee2, this);
336
- }));
337
- function resolveApi(_x3, _x4) {
338
- return _resolveApi.apply(this, arguments);
363
+ value: function resolveApi(apiConfig, chain) {
364
+ if (!apiConfig) {
365
+ var wsUrl = getChainProviders(chain);
366
+ return this.createApiInstance(wsUrl, chain);
339
367
  }
340
- return resolveApi;
341
- }()
368
+ if (typeof apiConfig === 'string' || apiConfig instanceof Array) {
369
+ return this.createApiInstance(apiConfig, chain);
370
+ }
371
+ return Promise.resolve(apiConfig);
372
+ }
342
373
  }, {
343
374
  key: "createApiInstance",
344
- value: function () {
345
- var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(wsUrl, _chain) {
346
- var wsProvider;
347
- return _regenerator().w(function (_context3) {
348
- while (1) switch (_context3.n) {
349
- case 0:
350
- wsProvider = new WsProvider(wsUrl);
351
- return _context3.a(2, ApiPromise.create({
352
- provider: wsProvider
353
- }));
354
- }
355
- }, _callee3);
356
- }));
357
- function createApiInstance(_x5, _x6) {
358
- return _createApiInstance.apply(this, arguments);
359
- }
360
- return createApiInstance;
361
- }()
375
+ value: function createApiInstance(wsUrl, _chain) {
376
+ return leaseClient(wsUrl, this._ttlMs, false);
377
+ }
362
378
  }, {
363
379
  key: "accountToHex",
364
380
  value: function accountToHex(address) {
@@ -374,9 +390,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
374
390
  }
375
391
  }, {
376
392
  key: "convertToPjsCall",
377
- value: function convertToPjsCall(_ref) {
378
- var module = _ref.module,
379
- method = _ref.method;
393
+ value: function convertToPjsCall(_ref3) {
394
+ var module = _ref3.module,
395
+ method = _ref3.method;
380
396
  return {
381
397
  module: lowercaseFirstLetter(module),
382
398
  method: snakeToCamel(method)
@@ -412,7 +428,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
412
428
  }
413
429
  }, _callee4, this);
414
430
  }));
415
- function queryState(_x7) {
431
+ function queryState(_x4) {
416
432
  return _queryState.apply(this, arguments);
417
433
  }
418
434
  return queryState;
@@ -475,7 +491,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
475
491
  }
476
492
  }, _callee5);
477
493
  }));
478
- function calculateTransactionFee(_x8, _x9) {
494
+ function calculateTransactionFee(_x5, _x6) {
479
495
  return _calculateTransactionFee.apply(this, arguments);
480
496
  }
481
497
  return calculateTransactionFee;
@@ -486,11 +502,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
486
502
  var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(fromMl, toMl, amountIn) {
487
503
  var includeFee,
488
504
  quoted,
489
- _args6 = arguments;
505
+ _args4 = arguments;
490
506
  return _regenerator().w(function (_context6) {
491
507
  while (1) switch (_context6.n) {
492
508
  case 0:
493
- includeFee = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : true;
509
+ includeFee = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
494
510
  _context6.n = 1;
495
511
  return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn.toString(), includeFee);
496
512
  case 1:
@@ -499,7 +515,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
499
515
  }
500
516
  }, _callee6, this);
501
517
  }));
502
- function quoteAhPrice(_x0, _x1, _x10) {
518
+ function quoteAhPrice(_x7, _x8, _x9) {
503
519
  return _quoteAhPrice.apply(this, arguments);
504
520
  }
505
521
  return quoteAhPrice;
@@ -552,7 +568,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
552
568
  }
553
569
  }, _callee7, this);
554
570
  }));
555
- function getFromRpc(_x11, _x12, _x13) {
571
+ function getFromRpc(_x0, _x1, _x10) {
556
572
  return _getFromRpc.apply(this, arguments);
557
573
  }
558
574
  return getFromRpc;
@@ -583,16 +599,16 @@ var PolkadotJsApi = /*#__PURE__*/function () {
583
599
  }
584
600
  }, _callee8);
585
601
  }));
586
- function createApiForChain(_x14) {
602
+ function createApiForChain(_x11) {
587
603
  return _createApiForChain.apply(this, arguments);
588
604
  }
589
605
  return createApiForChain;
590
606
  }()
591
607
  }, {
592
608
  key: "resolveDefaultFeeAsset",
593
- value: function resolveDefaultFeeAsset(_ref2) {
594
- var chain = _ref2.chain,
595
- feeAsset = _ref2.feeAsset;
609
+ value: function resolveDefaultFeeAsset(_ref4) {
610
+ var chain = _ref4.chain,
611
+ feeAsset = _ref4.feeAsset;
596
612
  return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
597
613
  }
598
614
  }, {
@@ -636,7 +652,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
636
652
  }
637
653
  }, _callee9, this);
638
654
  }));
639
- function resolveFeeAsset(_x15) {
655
+ function resolveFeeAsset(_x12) {
640
656
  return _resolveFeeAsset.apply(this, arguments);
641
657
  }
642
658
  return resolveFeeAsset;
@@ -689,7 +705,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
689
705
  case 5:
690
706
  resolvedFeeAsset = _context10.v;
691
707
  performDryRunCall = /*#__PURE__*/function () {
692
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
708
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
693
709
  var _this$api$call$dryRun;
694
710
  return _regenerator().w(function (_context0) {
695
711
  while (1) switch (_context0.n) {
@@ -698,8 +714,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
698
714
  }
699
715
  }, _callee0);
700
716
  }));
701
- return function performDryRunCall(_x17) {
702
- return _ref3.apply(this, arguments);
717
+ return function performDryRunCall(_x14) {
718
+ return _ref5.apply(this, arguments);
703
719
  };
704
720
  }();
705
721
  getExecutionSuccessFromResult = function getExecutionSuccessFromResult(resultHuman) {
@@ -707,7 +723,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
707
723
  return Boolean((resultHuman === null || resultHuman === void 0 ? void 0 : resultHuman.Ok) && ((_resultHuman$Ok$execu = resultHuman.Ok.executionResult) === null || _resultHuman$Ok$execu === void 0 ? void 0 : _resultHuman$Ok$execu.Ok));
708
724
  };
709
725
  extractFailureReasonFromResult = function extractFailureReasonFromResult(resultHuman, resultJson) {
710
- var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok, _ref4;
726
+ var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok, _ref6;
711
727
  var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok = resultHuman.Ok) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.executionResult) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.Err) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.error) === null || _resultHuman$Ok === void 0 ? void 0 : _resultHuman$Ok.Module;
712
728
  if (modErrHuman) {
713
729
  return resolveModuleError(chain, modErrHuman);
@@ -728,7 +744,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
728
744
  };
729
745
  }
730
746
  return {
731
- failureReason: JSON.stringify((_ref4 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref4 !== void 0 ? _ref4 : 'Unknown error')
747
+ failureReason: JSON.stringify((_ref6 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref6 !== void 0 ? _ref6 : 'Unknown error')
732
748
  };
733
749
  }; // Attempt 1: WITHOUT version
734
750
  isSuccess = false;
@@ -818,15 +834,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
818
834
  } : undefined;
819
835
  nativeAsset = findNativeAssetInfoOrThrow(chain);
820
836
  hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
821
- destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref5) {
822
- return i.here === null ? 0 : (_ref5 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref5 === void 0 ? void 0 : _ref5.parachain;
837
+ destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref7) {
838
+ return i.here === null ? 0 : (_ref7 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref7 === void 0 ? void 0 : _ref7.parachain;
823
839
  }(Object.values(forwardedXcms[0])[0].interior);
824
840
  if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
825
841
  _context10.n = 21;
826
842
  break;
827
843
  }
828
844
  getPaymentInfoWeight = /*#__PURE__*/function () {
829
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
845
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
830
846
  var _yield$tx$paymentInfo2, weight;
831
847
  return _regenerator().w(function (_context1) {
832
848
  while (1) switch (_context1.n) {
@@ -841,7 +857,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
841
857
  }, _callee1);
842
858
  }));
843
859
  return function getPaymentInfoWeight() {
844
- return _ref6.apply(this, arguments);
860
+ return _ref8.apply(this, arguments);
845
861
  };
846
862
  }();
847
863
  if (resultJson.ok.local_xcm) {
@@ -896,7 +912,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
896
912
  }
897
913
  }, _callee10, this, [[11, 13], [6, 8]]);
898
914
  }));
899
- function getDryRunCall(_x16) {
915
+ function getDryRunCall(_x13) {
900
916
  return _getDryRunCall.apply(this, arguments);
901
917
  }
902
918
  return getDryRunCall;
@@ -905,7 +921,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
905
921
  key: "getXcmPaymentApiFee",
906
922
  value: function () {
907
923
  var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset) {
908
- var _ref7, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref8, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
924
+ var _ref9, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref0, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
909
925
  var overridenWeight,
910
926
  weight,
911
927
  assetLocalizedLoc,
@@ -921,13 +937,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
921
937
  nativeAsset,
922
938
  deliveryFee,
923
939
  res,
924
- _args11 = arguments,
940
+ _args1 = arguments,
925
941
  _t5,
926
942
  _t6;
927
943
  return _regenerator().w(function (_context11) {
928
944
  while (1) switch (_context11.p = _context11.n) {
929
945
  case 0:
930
- overridenWeight = _args11.length > 5 ? _args11[5] : undefined;
946
+ overridenWeight = _args1.length > 5 ? _args1[5] : undefined;
931
947
  if (!(overridenWeight !== null && overridenWeight !== void 0)) {
932
948
  _context11.n = 1;
933
949
  break;
@@ -979,7 +995,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
979
995
  case 9:
980
996
  deliveryFeeRes = _t6;
981
997
  deliveryFeeResJson = deliveryFeeRes === null || deliveryFeeRes === void 0 ? void 0 : deliveryFeeRes.toJSON();
982
- deliveryFeeResolved = deliveryFeeRes && ((_ref7 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref7 === void 0 ? void 0 : _ref7.length) > 0 ? BigInt((_ref8 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref8 === void 0 || (_ref8 = _ref8[0]) === null || _ref8 === void 0 || (_ref8 = _ref8.fun) === null || _ref8 === void 0 ? void 0 : _ref8.fungible) : 0n;
998
+ deliveryFeeResolved = deliveryFeeRes && ((_ref9 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref9 === void 0 ? void 0 : _ref9.length) > 0 ? BigInt((_ref0 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref0 === void 0 || (_ref0 = _ref0[0]) === null || _ref0 === void 0 || (_ref0 = _ref0.fun) === null || _ref0 === void 0 ? void 0 : _ref0.fungible) : 0n;
983
999
  nativeAsset = findNativeAssetInfoOrThrow(chain);
984
1000
  if (!isAssetXcEqual(asset, nativeAsset)) {
985
1001
  _context11.n = 10;
@@ -1007,7 +1023,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1007
1023
  }
1008
1024
  }, _callee11, this, [[10, 12]]);
1009
1025
  }));
1010
- function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
1026
+ function getXcmPaymentApiFee(_x15, _x16, _x17, _x18) {
1011
1027
  return _getXcmPaymentApiFee.apply(this, arguments);
1012
1028
  }
1013
1029
  return getXcmPaymentApiFee;
@@ -1054,7 +1070,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1054
1070
  }
1055
1071
  }, _callee12, this);
1056
1072
  }));
1057
- function getBridgeHubFallbackExecFee(_x22, _x23, _x24) {
1073
+ function getBridgeHubFallbackExecFee(_x19, _x20, _x21) {
1058
1074
  return _getBridgeHubFallbackExecFee.apply(this, arguments);
1059
1075
  }
1060
1076
  return getBridgeHubFallbackExecFee;
@@ -1076,7 +1092,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1076
1092
  }
1077
1093
  }, _callee13, this);
1078
1094
  }));
1079
- function getXcmWeight(_x25) {
1095
+ function getXcmWeight(_x22) {
1080
1096
  return _getXcmWeight.apply(this, arguments);
1081
1097
  }
1082
1098
  return getXcmWeight;
@@ -1084,13 +1100,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1084
1100
  }, {
1085
1101
  key: "getDryRunXcm",
1086
1102
  value: function () {
1087
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref9) {
1088
- var _ref1, _ref10, _ref11;
1103
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref1) {
1104
+ var _ref11, _ref12, _ref13;
1089
1105
  var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
1090
1106
  return _regenerator().w(function (_context14) {
1091
1107
  while (1) switch (_context14.n) {
1092
1108
  case 0:
1093
- originLocation = _ref9.originLocation, xcm = _ref9.xcm, asset = _ref9.asset, chain = _ref9.chain, origin = _ref9.origin;
1109
+ originLocation = _ref1.originLocation, xcm = _ref1.xcm, asset = _ref1.asset, chain = _ref1.chain, origin = _ref1.origin;
1094
1110
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1095
1111
  if (supportsDryRunApi) {
1096
1112
  _context14.n = 1;
@@ -1123,8 +1139,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1123
1139
  refTime: BigInt(actualWeight.refTime),
1124
1140
  proofSize: BigInt(actualWeight.proofSize)
1125
1141
  } : undefined;
1126
- destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref0) {
1127
- return i.Here ? 0 : (_ref0 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref0 === void 0 ? void 0 : _ref0.parachain;
1142
+ destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
1143
+ return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
1128
1144
  }(Object.values(forwardedXcms[0])[0].interior);
1129
1145
  if (!(hasXcmPaymentApiSupport(chain) && asset)) {
1130
1146
  _context14.n = 5;
@@ -1150,17 +1166,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1150
1166
  emitted = result.Ok.emittedEvents; // We want to look for the last event
1151
1167
  reversedEvents = _toConsumableArray(emitted).reverse();
1152
1168
  palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
1153
- feeEvent = (_ref1 = (_ref10 = (_ref11 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1169
+ feeEvent = (_ref11 = (_ref12 = (_ref13 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1154
1170
  return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
1155
- }) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
1171
+ }) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1156
1172
  // Prefer an Issued event
1157
1173
  reversedEvents.find(function (event) {
1158
1174
  return palletsWithIssued.includes(event.section) && event.method === 'Issued';
1159
- })) !== null && _ref10 !== void 0 ? _ref10 :
1175
+ })) !== null && _ref12 !== void 0 ? _ref12 :
1160
1176
  // Fallback to Minted event
1161
1177
  reversedEvents.find(function (event) {
1162
1178
  return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
1163
- })) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
1179
+ })) !== null && _ref11 !== void 0 ? _ref11 : reversedEvents.find(function (event) {
1164
1180
  return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
1165
1181
  });
1166
1182
  if (feeEvent) {
@@ -1186,7 +1202,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1186
1202
  }
1187
1203
  }, _callee14, this);
1188
1204
  }));
1189
- function getDryRunXcm(_x26) {
1205
+ function getDryRunXcm(_x23) {
1190
1206
  return _getDryRunXcm.apply(this, arguments);
1191
1207
  }
1192
1208
  return getDryRunXcm;
@@ -1224,45 +1240,27 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1224
1240
  }
1225
1241
  }, {
1226
1242
  key: "disconnect",
1227
- value: function () {
1228
- var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1229
- var _this$_config$apiOver2;
1230
- var force,
1231
- api,
1232
- _args16 = arguments;
1233
- return _regenerator().w(function (_context16) {
1234
- while (1) switch (_context16.n) {
1235
- case 0:
1236
- force = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : false;
1237
- if (this.initialized) {
1238
- _context16.n = 1;
1239
- break;
1240
- }
1241
- return _context16.a(2, Promise.resolve());
1242
- case 1:
1243
- if (!(!force && !this.disconnectAllowed)) {
1244
- _context16.n = 2;
1245
- break;
1246
- }
1247
- return _context16.a(2);
1248
- case 2:
1249
- api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._chain] : this._config; // Disconnect api only if it was created automatically
1250
- if (!(force || typeof api === 'string' || api === undefined)) {
1251
- _context16.n = 3;
1252
- break;
1253
- }
1254
- _context16.n = 3;
1255
- return this.api.disconnect();
1256
- case 3:
1257
- return _context16.a(2);
1258
- }
1259
- }, _callee16, this);
1260
- }));
1261
- function disconnect() {
1262
- return _disconnect.apply(this, arguments);
1243
+ value: function disconnect() {
1244
+ var _this$_config$apiOver2;
1245
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1246
+ if (!this.initialized) return Promise.resolve();
1247
+ if (!force && !this.disconnectAllowed) return Promise.resolve();
1248
+ var api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._chain] : this._config;
1249
+ // Own client provided, destroy only if force true
1250
+ if (force && _typeof(api) === 'object') {
1251
+ void this.api.disconnect();
1263
1252
  }
1264
- return disconnect;
1265
- }()
1253
+ // Client created automatically
1254
+ if (typeof api === 'string' || Array.isArray(api) || api === undefined) {
1255
+ if (force) {
1256
+ void this.api.disconnect();
1257
+ } else {
1258
+ var key = api === undefined ? getChainProviders(this._chain) : api;
1259
+ releaseClient(key);
1260
+ }
1261
+ }
1262
+ return Promise.resolve();
1263
+ }
1266
1264
  }, {
1267
1265
  key: "validateSubstrateAddress",
1268
1266
  value: function validateSubstrateAddress(address) {
@@ -1283,21 +1281,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1283
1281
  }, {
1284
1282
  key: "signAndSubmit",
1285
1283
  value: function () {
1286
- var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, path) {
1284
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, path) {
1287
1285
  var pair, hash;
1288
- return _regenerator().w(function (_context17) {
1289
- while (1) switch (_context17.n) {
1286
+ return _regenerator().w(function (_context16) {
1287
+ while (1) switch (_context16.n) {
1290
1288
  case 0:
1291
1289
  pair = createKeyringPair(path);
1292
- _context17.n = 1;
1290
+ _context16.n = 1;
1293
1291
  return tx.signAndSend(pair);
1294
1292
  case 1:
1295
- hash = _context17.v;
1296
- return _context17.a(2, hash.toHex());
1293
+ hash = _context16.v;
1294
+ return _context16.a(2, hash.toHex());
1297
1295
  }
1298
- }, _callee17);
1296
+ }, _callee16);
1299
1297
  }));
1300
- function signAndSubmit(_x27, _x28) {
1298
+ function signAndSubmit(_x24, _x25) {
1301
1299
  return _signAndSubmit.apply(this, arguments);
1302
1300
  }
1303
1301
  return signAndSubmit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "12.2.0",
3
+ "version": "12.2.2",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "@snowbridge/contract-types": "0.2.20",
28
28
  "ethers": "6.15.0",
29
29
  "viem": "2.40.3",
30
- "@paraspell/sdk-core": "12.2.0"
30
+ "@paraspell/sdk-core": "12.2.2"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@polkadot/api": ">= 16.0 < 17",