@paraspell/sdk 12.0.6 → 12.1.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.mjs +106 -44
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NumberFormatError, isConfig, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, getChainProviders, MissingChainApiError, Parents, Version, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, padValueBy, isRelayChain, isAssetEqual, 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, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { NumberFormatError, isConfig, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, getChainProviders, MissingChainApiError, Parents, Version, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, padValueBy, isRelayChain, isAssetEqual, 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, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$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.js';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
@@ -1435,13 +1435,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1435
1435
|
key: "getXcmPaymentApiFee",
|
|
1436
1436
|
value: function () {
|
|
1437
1437
|
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset) {
|
|
1438
|
-
var _deliveryFeeRes$value, _deliveryFeeRes$value2;
|
|
1438
|
+
var _execFeeRes$value, _deliveryFeeRes$value, _deliveryFeeRes$value2;
|
|
1439
1439
|
var transformXcm,
|
|
1440
1440
|
transformedXcm,
|
|
1441
1441
|
weight,
|
|
1442
1442
|
assetLocalizedLoc,
|
|
1443
1443
|
transformedAssetLoc,
|
|
1444
1444
|
execFeeRes,
|
|
1445
|
+
execFee,
|
|
1446
|
+
bridgeHubExecFee,
|
|
1445
1447
|
deliveryFeeRes,
|
|
1446
1448
|
deliveryFeeResolved,
|
|
1447
1449
|
nativeAsset,
|
|
@@ -1469,86 +1471,146 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1469
1471
|
});
|
|
1470
1472
|
case 2:
|
|
1471
1473
|
execFeeRes = _context11.v;
|
|
1472
|
-
|
|
1474
|
+
execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
|
|
1475
|
+
if (!(chain.startsWith('BridgeHub') && (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.success) === false && (execFeeRes === null || execFeeRes === void 0 || (_execFeeRes$value = execFeeRes.value) === null || _execFeeRes$value === void 0 ? void 0 : _execFeeRes$value.type) === 'AssetNotFound')) {
|
|
1473
1476
|
_context11.n = 4;
|
|
1474
1477
|
break;
|
|
1475
1478
|
}
|
|
1476
1479
|
_context11.n = 3;
|
|
1477
|
-
return this.
|
|
1480
|
+
return this.getBridgeHubFallbackExecFee(chain, weight.value, asset);
|
|
1478
1481
|
case 3:
|
|
1479
|
-
|
|
1482
|
+
bridgeHubExecFee = _context11.v;
|
|
1483
|
+
if (typeof bridgeHubExecFee === 'bigint') {
|
|
1484
|
+
execFee = bridgeHubExecFee;
|
|
1485
|
+
}
|
|
1486
|
+
case 4:
|
|
1487
|
+
if (!(forwardedXcm.length > 0)) {
|
|
1488
|
+
_context11.n = 6;
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1480
1491
|
_context11.n = 5;
|
|
1492
|
+
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
1493
|
+
case 5:
|
|
1494
|
+
_t3 = _context11.v;
|
|
1495
|
+
_context11.n = 7;
|
|
1481
1496
|
break;
|
|
1482
|
-
case
|
|
1497
|
+
case 6:
|
|
1483
1498
|
_t3 = undefined;
|
|
1484
|
-
case
|
|
1499
|
+
case 7:
|
|
1485
1500
|
deliveryFeeRes = _t3;
|
|
1486
1501
|
deliveryFeeResolved = (deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value = deliveryFeeRes.value) === null || _deliveryFeeRes$value === void 0 ? void 0 : _deliveryFeeRes$value.value.length) > 0 ? deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value2 = deliveryFeeRes.value) === null || _deliveryFeeRes$value2 === void 0 ? void 0 : _deliveryFeeRes$value2.value[0].fun.value : 0n;
|
|
1487
1502
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1488
1503
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
1489
|
-
_context11.n =
|
|
1504
|
+
_context11.n = 8;
|
|
1490
1505
|
break;
|
|
1491
1506
|
}
|
|
1492
1507
|
deliveryFee = deliveryFeeResolved;
|
|
1493
|
-
_context11.n =
|
|
1508
|
+
_context11.n = 11;
|
|
1494
1509
|
break;
|
|
1495
|
-
case
|
|
1496
|
-
_context11.p =
|
|
1510
|
+
case 8:
|
|
1511
|
+
_context11.p = 8;
|
|
1497
1512
|
assertHasLocation(nativeAsset);
|
|
1498
|
-
_context11.n =
|
|
1513
|
+
_context11.n = 9;
|
|
1499
1514
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1500
|
-
case
|
|
1515
|
+
case 9:
|
|
1501
1516
|
res = _context11.v;
|
|
1502
1517
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
1503
|
-
_context11.n =
|
|
1518
|
+
_context11.n = 11;
|
|
1504
1519
|
break;
|
|
1505
|
-
case
|
|
1506
|
-
_context11.p =
|
|
1520
|
+
case 10:
|
|
1521
|
+
_context11.p = 10;
|
|
1507
1522
|
_t4 = _context11.v;
|
|
1508
1523
|
if (_t4 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t4.message)) {
|
|
1509
1524
|
deliveryFee = 0n;
|
|
1510
1525
|
} else {
|
|
1511
1526
|
deliveryFee = 0n;
|
|
1512
1527
|
}
|
|
1513
|
-
case
|
|
1514
|
-
return _context11.a(2,
|
|
1528
|
+
case 11:
|
|
1529
|
+
return _context11.a(2, execFee + deliveryFee);
|
|
1515
1530
|
}
|
|
1516
|
-
}, _callee11, this, [[
|
|
1531
|
+
}, _callee11, this, [[8, 10]]);
|
|
1517
1532
|
}));
|
|
1518
1533
|
function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
|
|
1519
1534
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1520
1535
|
}
|
|
1521
1536
|
return getXcmPaymentApiFee;
|
|
1522
1537
|
}()
|
|
1538
|
+
}, {
|
|
1539
|
+
key: "getBridgeHubFallbackExecFee",
|
|
1540
|
+
value: function () {
|
|
1541
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset) {
|
|
1542
|
+
var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1543
|
+
return _regenerator().w(function (_context12) {
|
|
1544
|
+
while (1) switch (_context12.n) {
|
|
1545
|
+
case 0:
|
|
1546
|
+
_context12.n = 1;
|
|
1547
|
+
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1548
|
+
type: Version.V4,
|
|
1549
|
+
value: _transform(RELAY_LOCATION)
|
|
1550
|
+
});
|
|
1551
|
+
case 1:
|
|
1552
|
+
fallbackExecFeeRes = _context12.v;
|
|
1553
|
+
if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
|
|
1554
|
+
_context12.n = 2;
|
|
1555
|
+
break;
|
|
1556
|
+
}
|
|
1557
|
+
return _context12.a(2, undefined);
|
|
1558
|
+
case 2:
|
|
1559
|
+
ahApi = this.clone();
|
|
1560
|
+
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1561
|
+
_context12.n = 3;
|
|
1562
|
+
return ahApi.init(assetHubChain);
|
|
1563
|
+
case 3:
|
|
1564
|
+
assertHasLocation(asset);
|
|
1565
|
+
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1566
|
+
_context12.n = 4;
|
|
1567
|
+
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false);
|
|
1568
|
+
case 4:
|
|
1569
|
+
convertedExecFee = _context12.v;
|
|
1570
|
+
if (!(typeof convertedExecFee === 'bigint')) {
|
|
1571
|
+
_context12.n = 5;
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
return _context12.a(2, convertedExecFee);
|
|
1575
|
+
case 5:
|
|
1576
|
+
return _context12.a(2, undefined);
|
|
1577
|
+
}
|
|
1578
|
+
}, _callee12, this);
|
|
1579
|
+
}));
|
|
1580
|
+
function getBridgeHubFallbackExecFee(_x22, _x23, _x24) {
|
|
1581
|
+
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1582
|
+
}
|
|
1583
|
+
return getBridgeHubFallbackExecFee;
|
|
1584
|
+
}()
|
|
1523
1585
|
}, {
|
|
1524
1586
|
key: "getDryRunXcm",
|
|
1525
1587
|
value: function () {
|
|
1526
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1588
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
|
|
1527
1589
|
var _ref10, _processAssetsDeposit, _ref11, _ref12, _ref13, _ref14, _ref15;
|
|
1528
1590
|
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1529
|
-
return _regenerator().w(function (
|
|
1530
|
-
while (1) switch (
|
|
1591
|
+
return _regenerator().w(function (_context13) {
|
|
1592
|
+
while (1) switch (_context13.n) {
|
|
1531
1593
|
case 0:
|
|
1532
1594
|
originLocation = _ref1.originLocation, xcm = _ref1.xcm, chain = _ref1.chain, origin = _ref1.origin, asset = _ref1.asset, feeAsset = _ref1.feeAsset, originFee = _ref1.originFee, amount = _ref1.amount;
|
|
1533
1595
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1534
1596
|
if (supportsDryRunApi) {
|
|
1535
|
-
|
|
1597
|
+
_context13.n = 1;
|
|
1536
1598
|
break;
|
|
1537
1599
|
}
|
|
1538
1600
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1539
1601
|
case 1:
|
|
1540
1602
|
transformedOriginLocation = _transform(originLocation);
|
|
1541
|
-
|
|
1603
|
+
_context13.n = 2;
|
|
1542
1604
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1543
1605
|
case 2:
|
|
1544
|
-
result =
|
|
1606
|
+
result = _context13.v;
|
|
1545
1607
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1546
1608
|
if (isSuccess) {
|
|
1547
|
-
|
|
1609
|
+
_context13.n = 3;
|
|
1548
1610
|
break;
|
|
1549
1611
|
}
|
|
1550
1612
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1551
|
-
return
|
|
1613
|
+
return _context13.a(2, {
|
|
1552
1614
|
success: false,
|
|
1553
1615
|
failureReason: failureReason,
|
|
1554
1616
|
asset: asset
|
|
@@ -1562,18 +1624,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1562
1624
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1563
1625
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1564
1626
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1565
|
-
|
|
1627
|
+
_context13.n = 5;
|
|
1566
1628
|
break;
|
|
1567
1629
|
}
|
|
1568
|
-
|
|
1630
|
+
_context13.n = 4;
|
|
1569
1631
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1570
1632
|
case 4:
|
|
1571
|
-
_fee =
|
|
1633
|
+
_fee = _context13.v;
|
|
1572
1634
|
if (!(typeof _fee === 'bigint')) {
|
|
1573
|
-
|
|
1635
|
+
_context13.n = 5;
|
|
1574
1636
|
break;
|
|
1575
1637
|
}
|
|
1576
|
-
return
|
|
1638
|
+
return _context13.a(2, {
|
|
1577
1639
|
success: true,
|
|
1578
1640
|
fee: _fee,
|
|
1579
1641
|
asset: asset,
|
|
@@ -1622,10 +1684,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1622
1684
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1623
1685
|
});
|
|
1624
1686
|
if (feeEvent) {
|
|
1625
|
-
|
|
1687
|
+
_context13.n = 6;
|
|
1626
1688
|
break;
|
|
1627
1689
|
}
|
|
1628
|
-
return
|
|
1690
|
+
return _context13.a(2, Promise.resolve({
|
|
1629
1691
|
success: false,
|
|
1630
1692
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1631
1693
|
asset: asset
|
|
@@ -1636,7 +1698,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1636
1698
|
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1637
1699
|
}
|
|
1638
1700
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1639
|
-
return
|
|
1701
|
+
return _context13.a(2, Promise.resolve({
|
|
1640
1702
|
success: true,
|
|
1641
1703
|
fee: processedFee,
|
|
1642
1704
|
asset: asset,
|
|
@@ -1645,9 +1707,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1645
1707
|
destParaId: destParaId
|
|
1646
1708
|
}));
|
|
1647
1709
|
}
|
|
1648
|
-
},
|
|
1710
|
+
}, _callee13, this);
|
|
1649
1711
|
}));
|
|
1650
|
-
function getDryRunXcm(
|
|
1712
|
+
function getDryRunXcm(_x25) {
|
|
1651
1713
|
return _getDryRunXcm.apply(this, arguments);
|
|
1652
1714
|
}
|
|
1653
1715
|
return getDryRunXcm;
|
|
@@ -1655,18 +1717,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1655
1717
|
}, {
|
|
1656
1718
|
key: "getBridgeStatus",
|
|
1657
1719
|
value: function () {
|
|
1658
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1720
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1659
1721
|
var outboundOperatingMode;
|
|
1660
|
-
return _regenerator().w(function (
|
|
1661
|
-
while (1) switch (
|
|
1722
|
+
return _regenerator().w(function (_context14) {
|
|
1723
|
+
while (1) switch (_context14.n) {
|
|
1662
1724
|
case 0:
|
|
1663
|
-
|
|
1725
|
+
_context14.n = 1;
|
|
1664
1726
|
return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1665
1727
|
case 1:
|
|
1666
|
-
outboundOperatingMode =
|
|
1667
|
-
return
|
|
1728
|
+
outboundOperatingMode = _context14.v;
|
|
1729
|
+
return _context14.a(2, outboundOperatingMode.type);
|
|
1668
1730
|
}
|
|
1669
|
-
},
|
|
1731
|
+
}, _callee14, this);
|
|
1670
1732
|
}));
|
|
1671
1733
|
function getBridgeStatus() {
|
|
1672
1734
|
return _getBridgeStatus.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@noble/hashes": "^2.0.1",
|
|
27
27
|
"@polkadot-api/legacy-provider": "^0.3.6",
|
|
28
28
|
"viem": "^2.40.3",
|
|
29
|
-
"@paraspell/sdk-core": "12.0
|
|
29
|
+
"@paraspell/sdk-core": "12.1.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"polkadot-api": ">= 1.22.0 < 2"
|