@paraspell/sdk-pjs 14.3.4 → 14.3.6

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 +66 -5
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, isCustomChain, isSenderSigner, PolkadotApi, buildDryRunError, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetEqual, RELAY_LOCATION, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, Version, RoutingResolutionError, addXcmVersionHeader, createBridgedXcmPrefix, isCustomChain, isSenderSigner, PolkadotApi, buildDryRunError, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, isAssetEqual, RELAY_LOCATION, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, 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 { snakeToCamel, lowercaseFirstLetter } from '@paraspell/sdk-common';
@@ -10,6 +10,9 @@ function _arrayLikeToArray(r, a) {
10
10
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
11
11
  return n;
12
12
  }
13
+ function _arrayWithHoles(r) {
14
+ if (Array.isArray(r)) return r;
15
+ }
13
16
  function _arrayWithoutHoles(r) {
14
17
  if (Array.isArray(r)) return _arrayLikeToArray(r);
15
18
  }
@@ -143,6 +146,33 @@ function _isNativeReflectConstruct() {
143
146
  function _iterableToArray(r) {
144
147
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
145
148
  }
149
+ function _iterableToArrayLimit(r, l) {
150
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
151
+ if (null != t) {
152
+ var e,
153
+ n,
154
+ i,
155
+ u,
156
+ a = [],
157
+ f = true,
158
+ o = false;
159
+ try {
160
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
161
+ } catch (r) {
162
+ o = true, n = r;
163
+ } finally {
164
+ try {
165
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
166
+ } finally {
167
+ if (o) throw n;
168
+ }
169
+ }
170
+ return a;
171
+ }
172
+ }
173
+ function _nonIterableRest() {
174
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
175
+ }
146
176
  function _nonIterableSpread() {
147
177
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
148
178
  }
@@ -285,6 +315,9 @@ function _setPrototypeOf(t, e) {
285
315
  return t.__proto__ = e, t;
286
316
  }, _setPrototypeOf(t, e);
287
317
  }
318
+ function _slicedToArray(r, e) {
319
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
320
+ }
288
321
  function _toConsumableArray(r) {
289
322
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
290
323
  }
@@ -827,11 +860,11 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
827
860
  value: function () {
828
861
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
829
862
  var _this3 = this;
830
- var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _resultJson, _msg, _resultJson2, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
863
+ var tx, address, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, feeAsset, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _resultJson, _msg, _resultJson2, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
831
864
  return _regenerator().w(function (_context0) {
832
865
  while (1) switch (_context0.p = _context0.n) {
833
866
  case 0:
834
- tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
867
+ tx = options.tx, address = options.address, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
835
868
  supportsDryRunApi = this.hasDryRunSupport(chain);
836
869
  if (supportsDryRunApi) {
837
870
  _context0.n = 1;
@@ -839,6 +872,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
839
872
  }
840
873
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
841
874
  case 1:
875
+ feeAsset = this.getMethod(tx) === 'execute' ? options.feeAsset : undefined;
842
876
  basePayload = useRootOrigin ? {
843
877
  system: {
844
878
  Root: null
@@ -865,7 +899,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
865
899
  case 4:
866
900
  resolvedTx = _t;
867
901
  _context0.n = 5;
868
- return this.resolveFeeAsset(options);
902
+ return this.resolveFeeAsset(_objectSpread2(_objectSpread2({}, options), {}, {
903
+ feeAsset: feeAsset
904
+ }));
869
905
  case 5:
870
906
  resolvedFeeAsset = _context0.v;
871
907
  performDryRunCall = /*#__PURE__*/function () {
@@ -1067,7 +1103,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1067
1103
  case 20:
1068
1104
  resolvedFeeAsset = {
1069
1105
  isCustomAsset: false,
1070
- asset: this.resolveDefaultFeeAsset(options)
1106
+ asset: this.resolveDefaultFeeAsset(_objectSpread2(_objectSpread2({}, options), {}, {
1107
+ feeAsset: feeAsset
1108
+ }))
1071
1109
  };
1072
1110
  case 21:
1073
1111
  _context0.n = 22;
@@ -1416,6 +1454,26 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1416
1454
  }
1417
1455
  return getDryRunXcm;
1418
1456
  }()
1457
+ }, {
1458
+ key: "createBridgedForwardedXcms",
1459
+ value: function createBridgedForwardedXcms(forwardedXcm, params) {
1460
+ var _Object$keys = Object.keys(forwardedXcm),
1461
+ _Object$keys2 = _slicedToArray(_Object$keys, 1),
1462
+ versionKey = _Object$keys2[0];
1463
+ var version = Object.values(Version).find(function (v) {
1464
+ return v.toLowerCase() === versionKey.toLowerCase();
1465
+ });
1466
+ if (!version) {
1467
+ throw new RoutingResolutionError("Unsupported XCM version ".concat(versionKey, " in the forwarded XCM"));
1468
+ }
1469
+ var exportMessage = forwardedXcm[versionKey].find(function (instruction) {
1470
+ return 'exportMessage' in instruction;
1471
+ });
1472
+ if (!exportMessage) {
1473
+ throw new RoutingResolutionError('ExportMessage instruction not found in the forwarded XCM');
1474
+ }
1475
+ return [addXcmVersionHeader(params.destination, version), [addXcmVersionHeader([].concat(_toConsumableArray(createBridgedXcmPrefix(version, params)), _toConsumableArray(exportMessage.exportMessage.xcm)), version)]];
1476
+ }
1419
1477
  }, {
1420
1478
  key: "getBridgeStatus",
1421
1479
  value: function () {
@@ -1492,6 +1550,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1492
1550
  releaseClient(key);
1493
1551
  }
1494
1552
  }
1553
+ if (force || _typeof(api) !== 'object' || Array.isArray(api)) {
1554
+ this.resetChain();
1555
+ }
1495
1556
  return Promise.resolve();
1496
1557
  }
1497
1558
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "14.3.4",
3
+ "version": "14.3.6",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@paraspell/sdk-common": "14.3.4",
26
- "@paraspell/sdk-core": "14.3.4"
25
+ "@paraspell/sdk-common": "14.3.6",
26
+ "@paraspell/sdk-core": "14.3.6"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@polkadot/api": ">= 16.0 < 17",