@paraspell/sdk 10.4.0 → 10.4.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.
package/dist/index.cjs CHANGED
@@ -1359,38 +1359,96 @@ var PapiApi = /*#__PURE__*/function () {
1359
1359
  return getDryRunCall;
1360
1360
  }()
1361
1361
  }, {
1362
- key: "getDryRunXcm",
1362
+ key: "getXcmPaymentApiFee",
1363
1363
  value: function () {
1364
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref9) {
1365
- var _ref0, _ref1, _ref10, _ref11;
1366
- var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
1364
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(xcm, asset) {
1365
+ var weight, transformedMultiLocation, feeResult;
1367
1366
  return _regenerator().w(function (_context19) {
1368
1367
  while (1) switch (_context19.n) {
1368
+ case 0:
1369
+ _context19.n = 1;
1370
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(xcm);
1371
+ case 1:
1372
+ weight = _context19.v;
1373
+ if (asset !== null && asset !== void 0 && asset.multiLocation) {
1374
+ _context19.n = 2;
1375
+ break;
1376
+ }
1377
+ throw new sdkCore.InvalidCurrencyError('This asset does not have a multiLocation defined. Cannot determine destination fee.');
1378
+ case 2:
1379
+ transformedMultiLocation = _transform(sdkCore.normalizeMultiLocation(asset.multiLocation));
1380
+ _context19.n = 3;
1381
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
1382
+ type: 'V4',
1383
+ value: transformedMultiLocation
1384
+ });
1385
+ case 3:
1386
+ feeResult = _context19.v;
1387
+ return _context19.a(2, feeResult.value);
1388
+ }
1389
+ }, _callee19, this);
1390
+ }));
1391
+ function getXcmPaymentApiFee(_x33, _x34) {
1392
+ return _getXcmPaymentApiFee.apply(this, arguments);
1393
+ }
1394
+ return getXcmPaymentApiFee;
1395
+ }()
1396
+ }, {
1397
+ key: "getDryRunXcm",
1398
+ value: function () {
1399
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(_ref9) {
1400
+ var _ref0, _ref1, _ref10, _ref11;
1401
+ 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;
1402
+ return _regenerator().w(function (_context20) {
1403
+ while (1) switch (_context20.n) {
1369
1404
  case 0:
1370
1405
  originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
1371
1406
  supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
1372
1407
  if (supportsDryRunApi) {
1373
- _context19.n = 1;
1408
+ _context20.n = 1;
1374
1409
  break;
1375
1410
  }
1376
1411
  throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1377
1412
  case 1:
1378
1413
  transformedOriginLocation = _transform(originLocation);
1379
- _context19.n = 2;
1414
+ _context20.n = 2;
1380
1415
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1381
1416
  case 2:
1382
- result = _context19.v;
1417
+ result = _context20.v;
1383
1418
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1384
1419
  if (isSuccess) {
1385
- _context19.n = 3;
1420
+ _context20.n = 3;
1386
1421
  break;
1387
1422
  }
1388
1423
  failureReason = result.value.execution_result.value.error.type;
1389
- return _context19.a(2, Promise.resolve({
1424
+ return _context20.a(2, Promise.resolve({
1390
1425
  success: false,
1391
1426
  failureReason: failureReason
1392
1427
  }));
1393
1428
  case 3:
1429
+ actualWeight = result.value.execution_result.value.used;
1430
+ weight = actualWeight ? {
1431
+ refTime: actualWeight.ref_time,
1432
+ proofSize: actualWeight.proof_size
1433
+ } : undefined;
1434
+ forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1435
+ destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1436
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
1437
+ _context20.n = 5;
1438
+ break;
1439
+ }
1440
+ _context20.n = 4;
1441
+ return this.getXcmPaymentApiFee(xcm, asset);
1442
+ case 4:
1443
+ _fee = _context20.v;
1444
+ return _context20.a(2, {
1445
+ success: true,
1446
+ fee: _fee,
1447
+ weight: weight,
1448
+ forwardedXcms: forwardedXcms,
1449
+ destParaId: destParaId
1450
+ });
1451
+ case 5:
1394
1452
  emitted = result.value.emitted_events; // We want to look for the last event
1395
1453
  reversedEvents = _toConsumableArray(emitted).reverse();
1396
1454
  palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
@@ -1414,26 +1472,19 @@ var PapiApi = /*#__PURE__*/function () {
1414
1472
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1415
1473
  });
1416
1474
  if (feeEvent) {
1417
- _context19.n = 4;
1475
+ _context20.n = 6;
1418
1476
  break;
1419
1477
  }
1420
- return _context19.a(2, Promise.resolve({
1478
+ return _context20.a(2, Promise.resolve({
1421
1479
  success: false,
1422
1480
  failureReason: 'Cannot determine destination fee. No Issued event found'
1423
1481
  }));
1424
- case 4:
1482
+ case 6:
1425
1483
  fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
1426
1484
  if (feeAssetFeeEvent) {
1427
1485
  fee = amount - originFee - feeEvent.value.value.amount;
1428
1486
  }
1429
- actualWeight = result.value.execution_result.value.used;
1430
- weight = actualWeight ? {
1431
- refTime: actualWeight.ref_time,
1432
- proofSize: actualWeight.proof_size
1433
- } : undefined;
1434
- forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1435
- destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1436
- return _context19.a(2, Promise.resolve({
1487
+ return _context20.a(2, Promise.resolve({
1437
1488
  success: true,
1438
1489
  fee: fee,
1439
1490
  weight: weight,
@@ -1441,9 +1492,9 @@ var PapiApi = /*#__PURE__*/function () {
1441
1492
  destParaId: destParaId
1442
1493
  }));
1443
1494
  }
1444
- }, _callee19, this);
1495
+ }, _callee20, this);
1445
1496
  }));
1446
- function getDryRunXcm(_x33) {
1497
+ function getDryRunXcm(_x35) {
1447
1498
  return _getDryRunXcm.apply(this, arguments);
1448
1499
  }
1449
1500
  return getDryRunXcm;
@@ -1451,18 +1502,18 @@ var PapiApi = /*#__PURE__*/function () {
1451
1502
  }, {
1452
1503
  key: "getBridgeStatus",
1453
1504
  value: function () {
1454
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
1505
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
1455
1506
  var outboundOperatingMode;
1456
- return _regenerator().w(function (_context20) {
1457
- while (1) switch (_context20.n) {
1507
+ return _regenerator().w(function (_context21) {
1508
+ while (1) switch (_context21.n) {
1458
1509
  case 0:
1459
- _context20.n = 1;
1510
+ _context21.n = 1;
1460
1511
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1461
1512
  case 1:
1462
- outboundOperatingMode = _context20.v;
1463
- return _context20.a(2, outboundOperatingMode.type);
1513
+ outboundOperatingMode = _context21.v;
1514
+ return _context21.a(2, outboundOperatingMode.type);
1464
1515
  }
1465
- }, _callee20, this);
1516
+ }, _callee21, this);
1466
1517
  }));
1467
1518
  function getBridgeStatus() {
1468
1519
  return _getBridgeStatus.apply(this, arguments);
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, 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, getAssetsObject, normalizeMultiLocation, 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';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { blake2b } from '@noble/hashes/blake2';
4
4
  import { bytesToHex } from '@noble/hashes/utils';
@@ -1358,38 +1358,96 @@ var PapiApi = /*#__PURE__*/function () {
1358
1358
  return getDryRunCall;
1359
1359
  }()
1360
1360
  }, {
1361
- key: "getDryRunXcm",
1361
+ key: "getXcmPaymentApiFee",
1362
1362
  value: function () {
1363
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref9) {
1364
- var _ref0, _ref1, _ref10, _ref11;
1365
- var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
1363
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(xcm, asset) {
1364
+ var weight, transformedMultiLocation, feeResult;
1366
1365
  return _regenerator().w(function (_context19) {
1367
1366
  while (1) switch (_context19.n) {
1367
+ case 0:
1368
+ _context19.n = 1;
1369
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(xcm);
1370
+ case 1:
1371
+ weight = _context19.v;
1372
+ if (asset !== null && asset !== void 0 && asset.multiLocation) {
1373
+ _context19.n = 2;
1374
+ break;
1375
+ }
1376
+ throw new InvalidCurrencyError('This asset does not have a multiLocation defined. Cannot determine destination fee.');
1377
+ case 2:
1378
+ transformedMultiLocation = _transform(normalizeMultiLocation(asset.multiLocation));
1379
+ _context19.n = 3;
1380
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
1381
+ type: 'V4',
1382
+ value: transformedMultiLocation
1383
+ });
1384
+ case 3:
1385
+ feeResult = _context19.v;
1386
+ return _context19.a(2, feeResult.value);
1387
+ }
1388
+ }, _callee19, this);
1389
+ }));
1390
+ function getXcmPaymentApiFee(_x33, _x34) {
1391
+ return _getXcmPaymentApiFee.apply(this, arguments);
1392
+ }
1393
+ return getXcmPaymentApiFee;
1394
+ }()
1395
+ }, {
1396
+ key: "getDryRunXcm",
1397
+ value: function () {
1398
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(_ref9) {
1399
+ var _ref0, _ref1, _ref10, _ref11;
1400
+ 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;
1401
+ return _regenerator().w(function (_context20) {
1402
+ while (1) switch (_context20.n) {
1368
1403
  case 0:
1369
1404
  originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
1370
1405
  supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
1371
1406
  if (supportsDryRunApi) {
1372
- _context19.n = 1;
1407
+ _context20.n = 1;
1373
1408
  break;
1374
1409
  }
1375
1410
  throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1376
1411
  case 1:
1377
1412
  transformedOriginLocation = _transform(originLocation);
1378
- _context19.n = 2;
1413
+ _context20.n = 2;
1379
1414
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1380
1415
  case 2:
1381
- result = _context19.v;
1416
+ result = _context20.v;
1382
1417
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1383
1418
  if (isSuccess) {
1384
- _context19.n = 3;
1419
+ _context20.n = 3;
1385
1420
  break;
1386
1421
  }
1387
1422
  failureReason = result.value.execution_result.value.error.type;
1388
- return _context19.a(2, Promise.resolve({
1423
+ return _context20.a(2, Promise.resolve({
1389
1424
  success: false,
1390
1425
  failureReason: failureReason
1391
1426
  }));
1392
1427
  case 3:
1428
+ actualWeight = result.value.execution_result.value.used;
1429
+ weight = actualWeight ? {
1430
+ refTime: actualWeight.ref_time,
1431
+ proofSize: actualWeight.proof_size
1432
+ } : undefined;
1433
+ forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1434
+ destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1435
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
1436
+ _context20.n = 5;
1437
+ break;
1438
+ }
1439
+ _context20.n = 4;
1440
+ return this.getXcmPaymentApiFee(xcm, asset);
1441
+ case 4:
1442
+ _fee = _context20.v;
1443
+ return _context20.a(2, {
1444
+ success: true,
1445
+ fee: _fee,
1446
+ weight: weight,
1447
+ forwardedXcms: forwardedXcms,
1448
+ destParaId: destParaId
1449
+ });
1450
+ case 5:
1393
1451
  emitted = result.value.emitted_events; // We want to look for the last event
1394
1452
  reversedEvents = _toConsumableArray(emitted).reverse();
1395
1453
  palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
@@ -1413,26 +1471,19 @@ var PapiApi = /*#__PURE__*/function () {
1413
1471
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1414
1472
  });
1415
1473
  if (feeEvent) {
1416
- _context19.n = 4;
1474
+ _context20.n = 6;
1417
1475
  break;
1418
1476
  }
1419
- return _context19.a(2, Promise.resolve({
1477
+ return _context20.a(2, Promise.resolve({
1420
1478
  success: false,
1421
1479
  failureReason: 'Cannot determine destination fee. No Issued event found'
1422
1480
  }));
1423
- case 4:
1481
+ case 6:
1424
1482
  fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
1425
1483
  if (feeAssetFeeEvent) {
1426
1484
  fee = amount - originFee - feeEvent.value.value.amount;
1427
1485
  }
1428
- actualWeight = result.value.execution_result.value.used;
1429
- weight = actualWeight ? {
1430
- refTime: actualWeight.ref_time,
1431
- proofSize: actualWeight.proof_size
1432
- } : undefined;
1433
- forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1434
- destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1435
- return _context19.a(2, Promise.resolve({
1486
+ return _context20.a(2, Promise.resolve({
1436
1487
  success: true,
1437
1488
  fee: fee,
1438
1489
  weight: weight,
@@ -1440,9 +1491,9 @@ var PapiApi = /*#__PURE__*/function () {
1440
1491
  destParaId: destParaId
1441
1492
  }));
1442
1493
  }
1443
- }, _callee19, this);
1494
+ }, _callee20, this);
1444
1495
  }));
1445
- function getDryRunXcm(_x33) {
1496
+ function getDryRunXcm(_x35) {
1446
1497
  return _getDryRunXcm.apply(this, arguments);
1447
1498
  }
1448
1499
  return getDryRunXcm;
@@ -1450,18 +1501,18 @@ var PapiApi = /*#__PURE__*/function () {
1450
1501
  }, {
1451
1502
  key: "getBridgeStatus",
1452
1503
  value: function () {
1453
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
1504
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
1454
1505
  var outboundOperatingMode;
1455
- return _regenerator().w(function (_context20) {
1456
- while (1) switch (_context20.n) {
1506
+ return _regenerator().w(function (_context21) {
1507
+ while (1) switch (_context21.n) {
1457
1508
  case 0:
1458
- _context20.n = 1;
1509
+ _context21.n = 1;
1459
1510
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1460
1511
  case 1:
1461
- outboundOperatingMode = _context20.v;
1462
- return _context20.a(2, outboundOperatingMode.type);
1512
+ outboundOperatingMode = _context21.v;
1513
+ return _context21.a(2, outboundOperatingMode.type);
1463
1514
  }
1464
- }, _callee20, this);
1515
+ }, _callee21, this);
1465
1516
  }));
1466
1517
  function getBridgeStatus() {
1467
1518
  return _getBridgeStatus.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "10.4.0",
3
+ "version": "10.4.2",
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.30.5",
28
- "@paraspell/sdk-core": "10.4.0"
28
+ "@paraspell/sdk-core": "10.4.2"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "polkadot-api": ">= 1.13.0 < 2"