@paraspell/sdk 10.8.2 → 10.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -314,6 +314,39 @@ function _unsupportedIterableToArray(r, a) {
314
314
  }
315
315
  }
316
316
 
317
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
318
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
319
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
320
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
321
+ /* eslint-disable @typescript-eslint/no-explicit-any */
322
+ var processAssetsDepositedEvents = function processAssetsDepositedEvents(events, amount) {
323
+ var assetsDepositedEvents = events.filter(function (event) {
324
+ return event.type === 'Assets' && event.value.type === 'Deposited';
325
+ });
326
+ if (assetsDepositedEvents.length === 0) {
327
+ return undefined;
328
+ }
329
+ if (assetsDepositedEvents.length === 1) {
330
+ return BigInt(assetsDepositedEvents[0].value.value.amount);
331
+ }
332
+ var sortedEvents = _toConsumableArray(assetsDepositedEvents).sort(function (a, b) {
333
+ return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
334
+ });
335
+ // Remove the biggest value (first in sorted array)
336
+ var filteredEvents = sortedEvents.slice(1);
337
+ var sum = filteredEvents.reduce(function (total, event) {
338
+ return total + BigInt(event.value.value.amount);
339
+ }, BigInt(0));
340
+ // If sum is still bigger than amount, remove one more event (the next biggest)
341
+ while (sum > amount && filteredEvents.length > 0) {
342
+ filteredEvents = filteredEvents.slice(1);
343
+ sum = filteredEvents.reduce(function (total, event) {
344
+ return total + BigInt(event.value.value.amount);
345
+ }, BigInt(0));
346
+ }
347
+ return sum > 0 ? sum : undefined;
348
+ };
349
+
317
350
  var checkAndConvertToNumberOrBigInt = function checkAndConvertToNumberOrBigInt(input) {
318
351
  if (!/^-?\d+$/.test(input)) {
319
352
  throw new sdkCore.InvalidParameterError('Invalid integer string');
@@ -386,6 +419,14 @@ var _transform = function transform(obj) {
386
419
  type: key,
387
420
  value: polkadotApi.FixedSizeBinary.fromHex(value)
388
421
  };
422
+ } else if (key === 'SetFeesMode') {
423
+ var _value$jit_withdraw;
424
+ return {
425
+ type: key,
426
+ value: {
427
+ jit_withdraw: (_value$jit_withdraw = value.jit_withdraw) !== null && _value$jit_withdraw !== void 0 ? _value$jit_withdraw : false
428
+ }
429
+ };
389
430
  } else if (key === 'X1' && Array.isArray(value)) {
390
431
  return {
391
432
  type: key,
@@ -1238,11 +1279,11 @@ var PapiApi = /*#__PURE__*/function () {
1238
1279
  value: function () {
1239
1280
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
1240
1281
  var _this = this;
1241
- var tx, address, node, asset, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, hasMultiLocation, xcmFee, fee;
1282
+ var tx, address, node, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasMultiLocation, xcmFee, fee;
1242
1283
  return _regenerator().w(function (_context18) {
1243
1284
  while (1) switch (_context18.n) {
1244
1285
  case 0:
1245
- tx = _ref6.tx, address = _ref6.address, node = _ref6.node, asset = _ref6.asset, feeAsset = _ref6.feeAsset;
1286
+ tx = _ref6.tx, address = _ref6.address, node = _ref6.node, feeAsset = _ref6.feeAsset;
1246
1287
  supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
1247
1288
  if (supportsDryRunApi) {
1248
1289
  _context18.n = 1;
@@ -1342,13 +1383,16 @@ var PapiApi = /*#__PURE__*/function () {
1342
1383
  return this.calculateTransactionFee(tx, address);
1343
1384
  case 6:
1344
1385
  executionFee = _context18.v;
1345
- hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(asset === null || asset === void 0 ? void 0 : asset.multiLocation);
1346
- if (!(sdkCore.hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && node !== 'AssetHubPolkadot')) {
1386
+ nativeAsset = sdkCore.findAsset(node, {
1387
+ symbol: sdkCore.Native(sdkCore.getNativeAssetSymbol(node))
1388
+ }, null);
1389
+ hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.multiLocation);
1390
+ if (!(sdkCore.hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && nativeAsset && node !== 'AssetHubPolkadot')) {
1347
1391
  _context18.n = 8;
1348
1392
  break;
1349
1393
  }
1350
1394
  _context18.n = 7;
1351
- return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : asset);
1395
+ return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
1352
1396
  case 7:
1353
1397
  xcmFee = _context18.v;
1354
1398
  if (!(typeof xcmFee === 'bigint')) {
@@ -1444,8 +1488,8 @@ var PapiApi = /*#__PURE__*/function () {
1444
1488
  key: "getDryRunXcm",
1445
1489
  value: function () {
1446
1490
  var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_ref9) {
1447
- var _ref0, _ref1, _ref10, _ref11;
1448
- var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, feeEvent, fee;
1491
+ var _ref0, _ref1, _ref10, _ref11, _ref12, _ref13;
1492
+ var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee;
1449
1493
  return _regenerator().w(function (_context21) {
1450
1494
  while (1) switch (_context21.n) {
1451
1495
  case 0:
@@ -1509,16 +1553,33 @@ var PapiApi = /*#__PURE__*/function () {
1509
1553
  }) : undefined) !== null && _ref0 !== void 0 ? _ref0 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1510
1554
  return event.type === 'Tokens' && event.value.type === 'Deposited';
1511
1555
  }) : undefined;
1512
- feeEvent = (_ref1 = (_ref10 = (_ref11 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent : origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1556
+ processedAssetsAmount = node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount) : undefined;
1557
+ feeEvent = (_ref1 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
1558
+ //
1559
+ processedAssetsAmount !== undefined ? {
1560
+ type: 'Assets',
1561
+ value: {
1562
+ type: 'Deposited',
1563
+ value: {
1564
+ amount: processedAssetsAmount
1565
+ }
1566
+ }
1567
+ } : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1568
+ //
1569
+ node === 'Mythos' ? reversedEvents.find(function (event) {
1570
+ return event.type === 'Balances' && event.value.type === 'Issued';
1571
+ }) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
1572
+ //
1573
+ origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1513
1574
  return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
1514
1575
  }) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
1515
- // Prefer an Issued event
1576
+ // Prefer to Minted event
1516
1577
  reversedEvents.find(function (event) {
1517
- return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
1578
+ return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
1518
1579
  })) !== null && _ref10 !== void 0 ? _ref10 :
1519
- // Fallback to Minted event
1580
+ // Fallback an Issued event
1520
1581
  reversedEvents.find(function (event) {
1521
- return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
1582
+ return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
1522
1583
  })) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
1523
1584
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1524
1585
  });
@@ -1528,7 +1589,7 @@ var PapiApi = /*#__PURE__*/function () {
1528
1589
  }
1529
1590
  return _context21.a(2, Promise.resolve({
1530
1591
  success: false,
1531
- failureReason: 'Cannot determine destination fee. No Issued event found'
1592
+ failureReason: 'Cannot determine destination fee. No fee event found'
1532
1593
  }));
1533
1594
  case 6:
1534
1595
  fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
@@ -1884,6 +1945,8 @@ var getBridgeStatus = /*#__PURE__*/function () {
1884
1945
  };
1885
1946
  }();
1886
1947
  var getOriginXcmFee = createPapiApiCall(sdkCore.getOriginXcmFee);
1948
+ var getXcmFee = createPapiApiCall(sdkCore.getXcmFee);
1949
+ var handleSwapExecuteTransfer = createPapiApiCall(sdkCore.handleSwapExecuteTransfer);
1887
1950
 
1888
1951
  var transfer = /*#__PURE__*/Object.freeze({
1889
1952
  __proto__: null,
@@ -1892,6 +1955,8 @@ var transfer = /*#__PURE__*/Object.freeze({
1892
1955
  getBridgeStatus: getBridgeStatus,
1893
1956
  getOriginXcmFee: getOriginXcmFee,
1894
1957
  getParaEthTransferFees: getParaEthTransferFees,
1958
+ getXcmFee: getXcmFee,
1959
+ handleSwapExecuteTransfer: handleSwapExecuteTransfer,
1895
1960
  send: send
1896
1961
  });
1897
1962
 
@@ -1911,6 +1976,8 @@ exports.getBridgeStatus = getBridgeStatus;
1911
1976
  exports.getOriginFeeDetails = getOriginFeeDetails;
1912
1977
  exports.getOriginXcmFee = getOriginXcmFee;
1913
1978
  exports.getParaEthTransferFees = getParaEthTransferFees;
1979
+ exports.getXcmFee = getXcmFee;
1980
+ exports.handleSwapExecuteTransfer = handleSwapExecuteTransfer;
1914
1981
  exports.send = send;
1915
1982
  exports.transform = _transform;
1916
1983
  exports.xcmPallet = transfer;
package/dist/index.d.ts CHANGED
@@ -208,12 +208,20 @@ declare const getOriginXcmFee: (options: _paraspell_sdk_core.TGetOriginXcmFeeBas
208
208
  forwardedXcms?: any;
209
209
  destParaId?: number;
210
210
  }>;
211
+ declare const getXcmFee: (options: _paraspell_sdk_core.TGetXcmFeeBaseOptions<TPapiTransaction> & {
212
+ api?: TPapiApiOrUrl;
213
+ }) => Promise<_paraspell_sdk_core.TGetXcmFeeResult>;
214
+ declare const handleSwapExecuteTransfer: (options: _paraspell_sdk_core.TCreateBaseSwapXcmOptions & {
215
+ api?: TPapiApiOrUrl;
216
+ }) => Promise<TPapiTransaction>;
211
217
 
212
218
  declare const transfer_dryRun: typeof dryRun;
213
219
  declare const transfer_dryRunOrigin: typeof dryRunOrigin;
214
220
  declare const transfer_getBridgeStatus: typeof getBridgeStatus;
215
221
  declare const transfer_getOriginXcmFee: typeof getOriginXcmFee;
216
222
  declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
223
+ declare const transfer_getXcmFee: typeof getXcmFee;
224
+ declare const transfer_handleSwapExecuteTransfer: typeof handleSwapExecuteTransfer;
217
225
  declare const transfer_send: typeof send;
218
226
  declare namespace transfer {
219
227
  export {
@@ -222,6 +230,8 @@ declare namespace transfer {
222
230
  transfer_getBridgeStatus as getBridgeStatus,
223
231
  transfer_getOriginXcmFee as getOriginXcmFee,
224
232
  transfer_getParaEthTransferFees as getParaEthTransferFees,
233
+ transfer_getXcmFee as getXcmFee,
234
+ transfer_handleSwapExecuteTransfer as handleSwapExecuteTransfer,
225
235
  transfer_send as send,
226
236
  };
227
237
  }
@@ -231,5 +241,5 @@ declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Pr
231
241
  declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigint;
232
242
  declare const transform: (obj: any) => any;
233
243
 
234
- export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, send, transform, transfer as xcmPallet };
244
+ export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, send, transform, transfer as xcmPallet };
235
245
  export type { GeneralBuilder, TEvmNodeFromPapi, TPapiApi, TPapiApiOrUrl, TPapiTransaction };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, hasXcmPaymentApiSupport, getAssetsObject, localizeLocation, isRelayChain, InvalidCurrencyError, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
1
+ import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, findAsset, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, getAssetsObject, localizeLocation, isRelayChain, InvalidCurrencyError, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, getXcmFee as getXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { blake2b } from '@noble/hashes/blake2';
4
4
  import { bytesToHex } from '@noble/hashes/utils';
@@ -313,6 +313,39 @@ function _unsupportedIterableToArray(r, a) {
313
313
  }
314
314
  }
315
315
 
316
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
317
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
318
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
319
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
320
+ /* eslint-disable @typescript-eslint/no-explicit-any */
321
+ var processAssetsDepositedEvents = function processAssetsDepositedEvents(events, amount) {
322
+ var assetsDepositedEvents = events.filter(function (event) {
323
+ return event.type === 'Assets' && event.value.type === 'Deposited';
324
+ });
325
+ if (assetsDepositedEvents.length === 0) {
326
+ return undefined;
327
+ }
328
+ if (assetsDepositedEvents.length === 1) {
329
+ return BigInt(assetsDepositedEvents[0].value.value.amount);
330
+ }
331
+ var sortedEvents = _toConsumableArray(assetsDepositedEvents).sort(function (a, b) {
332
+ return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
333
+ });
334
+ // Remove the biggest value (first in sorted array)
335
+ var filteredEvents = sortedEvents.slice(1);
336
+ var sum = filteredEvents.reduce(function (total, event) {
337
+ return total + BigInt(event.value.value.amount);
338
+ }, BigInt(0));
339
+ // If sum is still bigger than amount, remove one more event (the next biggest)
340
+ while (sum > amount && filteredEvents.length > 0) {
341
+ filteredEvents = filteredEvents.slice(1);
342
+ sum = filteredEvents.reduce(function (total, event) {
343
+ return total + BigInt(event.value.value.amount);
344
+ }, BigInt(0));
345
+ }
346
+ return sum > 0 ? sum : undefined;
347
+ };
348
+
316
349
  var checkAndConvertToNumberOrBigInt = function checkAndConvertToNumberOrBigInt(input) {
317
350
  if (!/^-?\d+$/.test(input)) {
318
351
  throw new InvalidParameterError('Invalid integer string');
@@ -385,6 +418,14 @@ var _transform = function transform(obj) {
385
418
  type: key,
386
419
  value: FixedSizeBinary.fromHex(value)
387
420
  };
421
+ } else if (key === 'SetFeesMode') {
422
+ var _value$jit_withdraw;
423
+ return {
424
+ type: key,
425
+ value: {
426
+ jit_withdraw: (_value$jit_withdraw = value.jit_withdraw) !== null && _value$jit_withdraw !== void 0 ? _value$jit_withdraw : false
427
+ }
428
+ };
388
429
  } else if (key === 'X1' && Array.isArray(value)) {
389
430
  return {
390
431
  type: key,
@@ -1237,11 +1278,11 @@ var PapiApi = /*#__PURE__*/function () {
1237
1278
  value: function () {
1238
1279
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
1239
1280
  var _this = this;
1240
- var tx, address, node, asset, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, hasMultiLocation, xcmFee, fee;
1281
+ var tx, address, node, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasMultiLocation, xcmFee, fee;
1241
1282
  return _regenerator().w(function (_context18) {
1242
1283
  while (1) switch (_context18.n) {
1243
1284
  case 0:
1244
- tx = _ref6.tx, address = _ref6.address, node = _ref6.node, asset = _ref6.asset, feeAsset = _ref6.feeAsset;
1285
+ tx = _ref6.tx, address = _ref6.address, node = _ref6.node, feeAsset = _ref6.feeAsset;
1245
1286
  supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
1246
1287
  if (supportsDryRunApi) {
1247
1288
  _context18.n = 1;
@@ -1341,13 +1382,16 @@ var PapiApi = /*#__PURE__*/function () {
1341
1382
  return this.calculateTransactionFee(tx, address);
1342
1383
  case 6:
1343
1384
  executionFee = _context18.v;
1344
- hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(asset === null || asset === void 0 ? void 0 : asset.multiLocation);
1345
- if (!(hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && node !== 'AssetHubPolkadot')) {
1385
+ nativeAsset = findAsset(node, {
1386
+ symbol: Native(getNativeAssetSymbol(node))
1387
+ }, null);
1388
+ hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.multiLocation);
1389
+ if (!(hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && nativeAsset && node !== 'AssetHubPolkadot')) {
1346
1390
  _context18.n = 8;
1347
1391
  break;
1348
1392
  }
1349
1393
  _context18.n = 7;
1350
- return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : asset);
1394
+ return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
1351
1395
  case 7:
1352
1396
  xcmFee = _context18.v;
1353
1397
  if (!(typeof xcmFee === 'bigint')) {
@@ -1443,8 +1487,8 @@ var PapiApi = /*#__PURE__*/function () {
1443
1487
  key: "getDryRunXcm",
1444
1488
  value: function () {
1445
1489
  var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_ref9) {
1446
- var _ref0, _ref1, _ref10, _ref11;
1447
- var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, feeEvent, fee;
1490
+ var _ref0, _ref1, _ref10, _ref11, _ref12, _ref13;
1491
+ var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee;
1448
1492
  return _regenerator().w(function (_context21) {
1449
1493
  while (1) switch (_context21.n) {
1450
1494
  case 0:
@@ -1508,16 +1552,33 @@ var PapiApi = /*#__PURE__*/function () {
1508
1552
  }) : undefined) !== null && _ref0 !== void 0 ? _ref0 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1509
1553
  return event.type === 'Tokens' && event.value.type === 'Deposited';
1510
1554
  }) : undefined;
1511
- feeEvent = (_ref1 = (_ref10 = (_ref11 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent : origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1555
+ processedAssetsAmount = node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount) : undefined;
1556
+ feeEvent = (_ref1 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
1557
+ //
1558
+ processedAssetsAmount !== undefined ? {
1559
+ type: 'Assets',
1560
+ value: {
1561
+ type: 'Deposited',
1562
+ value: {
1563
+ amount: processedAssetsAmount
1564
+ }
1565
+ }
1566
+ } : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1567
+ //
1568
+ node === 'Mythos' ? reversedEvents.find(function (event) {
1569
+ return event.type === 'Balances' && event.value.type === 'Issued';
1570
+ }) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
1571
+ //
1572
+ origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1512
1573
  return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
1513
1574
  }) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
1514
- // Prefer an Issued event
1575
+ // Prefer to Minted event
1515
1576
  reversedEvents.find(function (event) {
1516
- return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
1577
+ return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
1517
1578
  })) !== null && _ref10 !== void 0 ? _ref10 :
1518
- // Fallback to Minted event
1579
+ // Fallback an Issued event
1519
1580
  reversedEvents.find(function (event) {
1520
- return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
1581
+ return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
1521
1582
  })) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
1522
1583
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1523
1584
  });
@@ -1527,7 +1588,7 @@ var PapiApi = /*#__PURE__*/function () {
1527
1588
  }
1528
1589
  return _context21.a(2, Promise.resolve({
1529
1590
  success: false,
1530
- failureReason: 'Cannot determine destination fee. No Issued event found'
1591
+ failureReason: 'Cannot determine destination fee. No fee event found'
1531
1592
  }));
1532
1593
  case 6:
1533
1594
  fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
@@ -1883,6 +1944,8 @@ var getBridgeStatus = /*#__PURE__*/function () {
1883
1944
  };
1884
1945
  }();
1885
1946
  var getOriginXcmFee = createPapiApiCall(getOriginXcmFee$1);
1947
+ var getXcmFee = createPapiApiCall(getXcmFee$1);
1948
+ var handleSwapExecuteTransfer = createPapiApiCall(handleSwapExecuteTransfer$1);
1886
1949
 
1887
1950
  var transfer = /*#__PURE__*/Object.freeze({
1888
1951
  __proto__: null,
@@ -1891,7 +1954,9 @@ var transfer = /*#__PURE__*/Object.freeze({
1891
1954
  getBridgeStatus: getBridgeStatus,
1892
1955
  getOriginXcmFee: getOriginXcmFee,
1893
1956
  getParaEthTransferFees: getParaEthTransferFees,
1957
+ getXcmFee: getXcmFee,
1958
+ handleSwapExecuteTransfer: handleSwapExecuteTransfer,
1894
1959
  send: send
1895
1960
  });
1896
1961
 
1897
- export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, send, _transform as transform, transfer as xcmPallet };
1962
+ export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, send, _transform as transform, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "10.8.2",
3
+ "version": "10.9.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "viem": "^2.31.6",
28
- "@paraspell/sdk-core": "10.8.2"
28
+ "@paraspell/sdk-core": "10.9.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "polkadot-api": ">= 1.14.1 < 2"