@paraspell/sdk 10.0.0 → 10.0.1
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/README.md +6 -0
- package/dist/index.cjs +16 -10
- package/dist/index.mjs +17 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -259,6 +259,7 @@ const result = await Builder(API /*optional*/)
|
|
|
259
259
|
.from(NODE)
|
|
260
260
|
.to(NODE_2)
|
|
261
261
|
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
|
|
262
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
262
263
|
.address(ADDRESS)
|
|
263
264
|
.senderAddress(SENDER_ADDRESS)
|
|
264
265
|
.dryRun()
|
|
@@ -279,6 +280,7 @@ const info = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
279
280
|
.from(ORIGIN_CHAIN)
|
|
280
281
|
.to(DESTINATION_CHAIN)
|
|
281
282
|
.currency(CURRENCY)
|
|
283
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
282
284
|
.address(RECIPIENT_ADDRESS)
|
|
283
285
|
.senderAddress(SENDER_ADDRESS)
|
|
284
286
|
.getTransferInfo()
|
|
@@ -290,6 +292,7 @@ const transferable = await Builder(/*node api/ws_url_string/ws_url_array - optio
|
|
|
290
292
|
.from(ORIGIN_CHAIN)
|
|
291
293
|
.to(DESTINATION_CHAIN)
|
|
292
294
|
.currency(CURRENCY)
|
|
295
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
293
296
|
.address(RECIPIENT_ADDRESS)
|
|
294
297
|
.senderAddress(SENDER_ADDRESS)
|
|
295
298
|
.getTransferableAmount()
|
|
@@ -301,6 +304,7 @@ const ed = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
301
304
|
.from(ORIGIN_CHAIN)
|
|
302
305
|
.to(DESTINATION_CHAIN)
|
|
303
306
|
.currency(CURRENCY)
|
|
307
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
304
308
|
.address(RECIPIENT_ADDRESS)
|
|
305
309
|
.senderAddress(SENDER_ADDRESS)
|
|
306
310
|
.verifyEdOnDestination()
|
|
@@ -314,6 +318,7 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
314
318
|
.from(ORIGIN_CHAIN)
|
|
315
319
|
.to(DESTINATION_CHAIN)
|
|
316
320
|
.currency(CURRENCY)
|
|
321
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
317
322
|
.address(RECIPIENT_ADDRESS)
|
|
318
323
|
.senderAddress(SENDER_ADDRESS)
|
|
319
324
|
.getXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin or Destination chain do not support DryRun out of the box.
|
|
@@ -338,6 +343,7 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
338
343
|
.from(ORIGIN_CHAIN)
|
|
339
344
|
.to(DESTINATION_CHAIN)
|
|
340
345
|
.currency(CURRENCY)
|
|
346
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
341
347
|
.address(RECIPIENT_ADDRESS)
|
|
342
348
|
.senderAddress(SENDER_ADDRESS)
|
|
343
349
|
.getOriginXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin do not support DryRun out of the box.
|
package/dist/index.cjs
CHANGED
|
@@ -1437,11 +1437,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1437
1437
|
value: function () {
|
|
1438
1438
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
1439
1439
|
var _this$api$getUnsafeAp;
|
|
1440
|
-
var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1440
|
+
var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1441
1441
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1442
1442
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1443
1443
|
case 0:
|
|
1444
|
-
tx = _ref6.tx, address = _ref6.address, node = _ref6.node;
|
|
1444
|
+
tx = _ref6.tx, address = _ref6.address, node = _ref6.node, isFeeAsset = _ref6.isFeeAsset;
|
|
1445
1445
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1446
1446
|
if (supportsDryRunApi) {
|
|
1447
1447
|
_context17.next = 4;
|
|
@@ -1477,7 +1477,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1477
1477
|
return this.calculateTransactionFee(tx, address);
|
|
1478
1478
|
case 16:
|
|
1479
1479
|
executionFee = _context17.sent;
|
|
1480
|
-
fee = sdkCore.computeFeeFromDryRun(result, node, executionFee);
|
|
1480
|
+
fee = sdkCore.computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
|
|
1481
1481
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1482
1482
|
weight = actualWeight ? {
|
|
1483
1483
|
refTime: actualWeight.ref_time,
|
|
@@ -1507,12 +1507,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1507
1507
|
key: "getDryRunXcm",
|
|
1508
1508
|
value: function () {
|
|
1509
1509
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref9) {
|
|
1510
|
-
var _ref0, _ref1, _ref10;
|
|
1511
|
-
var originLocation, xcm, node, origin, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1510
|
+
var _ref0, _ref1, _ref10, _ref11;
|
|
1511
|
+
var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1512
1512
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1513
1513
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1514
1514
|
case 0:
|
|
1515
|
-
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin;
|
|
1515
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1516
1516
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1517
1517
|
if (supportsDryRunApi) {
|
|
1518
1518
|
_context18.next = 4;
|
|
@@ -1539,7 +1539,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1539
1539
|
emitted = result.value.emitted_events; // We want to look for the last event
|
|
1540
1540
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1541
1541
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1542
|
-
|
|
1542
|
+
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && sdkCore.isAssetEqual(feeAsset, asset);
|
|
1543
|
+
feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1544
|
+
return event.type === 'ForeignAssets' && event.value.type === 'Issued';
|
|
1545
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1543
1546
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1544
1547
|
}) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1545
1548
|
// Prefer an Issued event
|
|
@@ -1553,15 +1556,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1553
1556
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1554
1557
|
});
|
|
1555
1558
|
if (feeEvent) {
|
|
1556
|
-
_context18.next =
|
|
1559
|
+
_context18.next = 19;
|
|
1557
1560
|
break;
|
|
1558
1561
|
}
|
|
1559
1562
|
return _context18.abrupt("return", Promise.resolve({
|
|
1560
1563
|
success: false,
|
|
1561
1564
|
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
1562
1565
|
}));
|
|
1563
|
-
case
|
|
1566
|
+
case 19:
|
|
1564
1567
|
fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
|
|
1568
|
+
if (isFeeAsset && feeEvent.type === 'ForeignAssets' && feeEvent.value.type === 'Issued') {
|
|
1569
|
+
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1570
|
+
}
|
|
1565
1571
|
actualWeight = result.value.execution_result.value.used;
|
|
1566
1572
|
weight = actualWeight ? {
|
|
1567
1573
|
refTime: actualWeight.ref_time,
|
|
@@ -1576,7 +1582,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1576
1582
|
forwardedXcms: forwardedXcms,
|
|
1577
1583
|
destParaId: destParaId
|
|
1578
1584
|
}));
|
|
1579
|
-
case
|
|
1585
|
+
case 26:
|
|
1580
1586
|
case "end":
|
|
1581
1587
|
return _context18.stop();
|
|
1582
1588
|
}
|
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, 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, 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';
|
|
@@ -1436,11 +1436,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1436
1436
|
value: function () {
|
|
1437
1437
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
1438
1438
|
var _this$api$getUnsafeAp;
|
|
1439
|
-
var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1439
|
+
var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1440
1440
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1441
1441
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1442
1442
|
case 0:
|
|
1443
|
-
tx = _ref6.tx, address = _ref6.address, node = _ref6.node;
|
|
1443
|
+
tx = _ref6.tx, address = _ref6.address, node = _ref6.node, isFeeAsset = _ref6.isFeeAsset;
|
|
1444
1444
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1445
1445
|
if (supportsDryRunApi) {
|
|
1446
1446
|
_context17.next = 4;
|
|
@@ -1476,7 +1476,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1476
1476
|
return this.calculateTransactionFee(tx, address);
|
|
1477
1477
|
case 16:
|
|
1478
1478
|
executionFee = _context17.sent;
|
|
1479
|
-
fee = computeFeeFromDryRun(result, node, executionFee);
|
|
1479
|
+
fee = computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
|
|
1480
1480
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1481
1481
|
weight = actualWeight ? {
|
|
1482
1482
|
refTime: actualWeight.ref_time,
|
|
@@ -1506,12 +1506,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1506
1506
|
key: "getDryRunXcm",
|
|
1507
1507
|
value: function () {
|
|
1508
1508
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref9) {
|
|
1509
|
-
var _ref0, _ref1, _ref10;
|
|
1510
|
-
var originLocation, xcm, node, origin, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1509
|
+
var _ref0, _ref1, _ref10, _ref11;
|
|
1510
|
+
var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1511
1511
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1512
1512
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1513
1513
|
case 0:
|
|
1514
|
-
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin;
|
|
1514
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1515
1515
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1516
1516
|
if (supportsDryRunApi) {
|
|
1517
1517
|
_context18.next = 4;
|
|
@@ -1538,7 +1538,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1538
1538
|
emitted = result.value.emitted_events; // We want to look for the last event
|
|
1539
1539
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1540
1540
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1541
|
-
|
|
1541
|
+
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && isAssetEqual(feeAsset, asset);
|
|
1542
|
+
feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1543
|
+
return event.type === 'ForeignAssets' && event.value.type === 'Issued';
|
|
1544
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1542
1545
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1543
1546
|
}) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1544
1547
|
// Prefer an Issued event
|
|
@@ -1552,15 +1555,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1552
1555
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1553
1556
|
});
|
|
1554
1557
|
if (feeEvent) {
|
|
1555
|
-
_context18.next =
|
|
1558
|
+
_context18.next = 19;
|
|
1556
1559
|
break;
|
|
1557
1560
|
}
|
|
1558
1561
|
return _context18.abrupt("return", Promise.resolve({
|
|
1559
1562
|
success: false,
|
|
1560
1563
|
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
1561
1564
|
}));
|
|
1562
|
-
case
|
|
1565
|
+
case 19:
|
|
1563
1566
|
fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
|
|
1567
|
+
if (isFeeAsset && feeEvent.type === 'ForeignAssets' && feeEvent.value.type === 'Issued') {
|
|
1568
|
+
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1569
|
+
}
|
|
1564
1570
|
actualWeight = result.value.execution_result.value.used;
|
|
1565
1571
|
weight = actualWeight ? {
|
|
1566
1572
|
refTime: actualWeight.ref_time,
|
|
@@ -1575,7 +1581,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1575
1581
|
forwardedXcms: forwardedXcms,
|
|
1576
1582
|
destParaId: destParaId
|
|
1577
1583
|
}));
|
|
1578
|
-
case
|
|
1584
|
+
case 26:
|
|
1579
1585
|
case "end":
|
|
1580
1586
|
return _context18.stop();
|
|
1581
1587
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"ethers": "^6.13.7",
|
|
28
28
|
"quick-lru": "^7.0.1",
|
|
29
29
|
"viem": "^2.28.1",
|
|
30
|
-
"@paraspell/sdk-core": "10.0.
|
|
30
|
+
"@paraspell/sdk-core": "10.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"polkadot-api": ">= 1.10.2 < 2"
|