@paraspell/sdk 12.2.2 → 12.4.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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +21 -89
  3. package/dist/index.mjs +164 -129
  4. package/package.json +5 -3
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ParaSpell
3
+ Copyright (c) 2026 ParaSpell
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div align="center">
4
4
  <h1 align="center">@paraspell/sdk</h1>
5
- <h4 align="center"> SDK for handling XCM asset transfers across Polkadot and Kusama ecosystems. </h4>
5
+ <h4 align="center"> SDK for handling XCM asset transfers across Polkadot, Kusama, Paseo and Westend ecosystems. </h4>
6
6
  <p align="center">
7
7
  <a href="https://npmjs.com/package/@paraspell/sdk">
8
8
  <img alt="version" src="https://img.shields.io/npm/v/@paraspell/sdk?style=flat-square" />
@@ -65,23 +65,20 @@ import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk'; //Only needed
65
65
  ```
66
66
  ## Implementation
67
67
 
68
- ```
69
- NOTES:
70
- - You can now query Ethereum asset balances on Ethereum via balance query
71
- - The Builder() now accepts an optional configuration object (To enhance localhost experience and testing). This object can contain apiOverrides and a development flag. More information in the "Localhost test setup" section.
72
- - V10 > V11 Migration guide https://paraspell.github.io/docs/migration/v10-to-v11.html
73
- - Brand new asset decimal abstraction introduced. It can be turned on in Builder config. Will be turned on by default in next major release.
74
- ```
75
-
76
- ```
77
- Latest news:
78
- - V11 > V12 Migration guide https://paraspell.github.io/docs/migration/v11-to-v12.html
79
- ```
68
+ > [!NOTE]
69
+ > - Local transfers are now available for every currency and every chain. To try them, simply use the same origin and destination parameters.
70
+ > - Transfer info queries are now all in the Builder pattern and don't require any imports other than the builder.
71
+ > - You can now query Ethereum asset balances on Ethereum via balance query
72
+ > - The Builder() now accepts an optional configuration object (To enhance localhost experience and testing). This object can contain apiOverrides and a development flag. More information in the "Localhost test setup" section.
73
+ > - Brand new asset decimal abstraction introduced. It can be turned on in Builder config. Will be turned on by default in next major release.
74
+ >
75
+ > **Latest news:**
76
+ > - V11 > V12 Migration guide https://paraspell.github.io/docs/migration/v11-to-v12.html
80
77
 
81
78
  ### Sending XCM
82
79
  For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html).
83
80
 
84
- #### Transfer assets from Parachain to Parachain
81
+ #### Transfer assets from Substrate to Substrate
85
82
 
86
83
  ```ts
87
84
  const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
@@ -103,75 +100,7 @@ await builder.disconnect()
103
100
  /*
104
101
  EXAMPLE:
105
102
  const builder = Builder()
106
- .from('Acala')
107
- .to('Astar')
108
- .currency({
109
- symbol: 'ACA',
110
- amount: '1000000000'
111
- })
112
- .address(address)
113
-
114
- const tx = await builder.build()
115
-
116
- //Disconnect API after TX
117
- await builder.disconnect()
118
- */
119
- ```
120
-
121
- #### Transfer assets from the Relay chain to the Parachain
122
-
123
- ```ts
124
- const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
125
- .from(TRelaychain) // Kusama | Polkadot | Westend | Paseo
126
- .to(TChain/*,customParaId - optional*/ | Location object)
127
- .currency({symbol: 'DOT', amount: amount /*Use "ALL" to transfer everything*/})
128
- .address(address | Location object)
129
- /*.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
130
- .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
131
-
132
- const tx = await builder.build()
133
-
134
- //Make sure to disconnect the API after it is no longer used (eg, after a transaction)
135
- await builder.disconnect()
136
-
137
- /*
138
- EXAMPLE:
139
- const builder = await Builder()
140
- .from('Polkadot')
141
- .to('Astar')
142
- .currency({
143
- symbol: 'DOT',
144
- amount: '1000000000'
145
- })
146
- .address(address)
147
-
148
- const tx = await builder.build()
149
-
150
- //Disconnect API after TX
151
- await builder.disconnect()
152
- */
153
- ```
154
-
155
- #### Transfer assets from Parachain to Relay chain
156
-
157
- ```ts
158
- const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
159
- .from(TSubstrateChain)
160
- .to(TRelaychain) // Kusama | Polkadot | Westend | Paseo
161
- .currency({symbol: 'DOT', amount: amount /*Use "ALL" to transfer everything*/})
162
- .address(address | Location object)
163
- /*.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
164
- .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
165
-
166
- const tx = await builder.build()
167
-
168
- //Make sure to disconnect the API after it is no longer used (eg, after a transaction)
169
- await builder.disconnect()
170
-
171
- /*
172
- EXAMPLE:
173
- const builder = await Builder()
174
- .from('Astar')
103
+ .from('AssetHubPolkadot')
175
104
  .to('Polkadot')
176
105
  .currency({
177
106
  symbol: 'DOT',
@@ -531,7 +460,8 @@ console.log(SUPPORTED_PALLETS)
531
460
 
532
461
  - Run all core tests and checks using `pnpm runAll`
533
462
 
534
- XCM SDK can be tested in [Playground](https://playground.paraspell.xyz/xcm-sdk/xcm-transfer).
463
+ > [!NOTE]
464
+ > XCM SDK can be tested in [Playground](https://playground.paraspell.xyz/xcm-sdk/xcm-transfer).
535
465
 
536
466
  ## Contribute to XCM Tools and earn rewards 💰
537
467
 
@@ -551,8 +481,10 @@ Published under [MIT License](https://github.com/paraspell/xcm-tools/blob/main/p
551
481
 
552
482
  ## Supported by
553
483
 
554
- <div>
555
- <div align="center" style="margin-top: 20px;">
556
- <img width="750" alt="version" src="https://github.com/user-attachments/assets/29e4b099-d90c-46d6-a3ce-94edfbda003c" />
557
- </div>
558
- </div>
484
+ <p align="center">
485
+ <picture>
486
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_transparent.png">
487
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_w3f_standard.png">
488
+ <img width="750" alt="Shows a black logo in light color mode and a white one in dark color mode." src="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_w3f_standard.png">
489
+ </picture>
490
+ </p>
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getEvmPrivateKeyHex, NumberFormatError, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, 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';
1
+ import { getEvmPrivateKeyHex, NumberFormatError, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, isExternalChain, Parents, Version, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, 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 { secp256k1 } from '@noble/curves/secp256k1.js';
4
4
  import { keccak_256 } from '@noble/hashes/sha3.js';
@@ -638,7 +638,7 @@ var PapiApi = /*#__PURE__*/function () {
638
638
  while (1) switch (_context2.n) {
639
639
  case 0:
640
640
  clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
641
- if (!(this.initialized || chain === 'Ethereum')) {
641
+ if (!(this.initialized || isExternalChain(chain))) {
642
642
  _context2.n = 1;
643
643
  break;
644
644
  }
@@ -1082,7 +1082,7 @@ var PapiApi = /*#__PURE__*/function () {
1082
1082
  return (result === null || result === void 0 ? void 0 : result.success) && ((_result$value3 = result.value) === null || _result$value3 === void 0 || (_result$value3 = _result$value3.execution_result) === null || _result$value3 === void 0 ? void 0 : _result$value3.success) && !errorInEvents;
1083
1083
  };
1084
1084
  findFailureObjectFromResult = function findFailureObjectFromResult(result) {
1085
- var _result$value4, _executionResultValue, _executionResultValue2, _result$value5;
1085
+ var _result$value4, _executionResultValue, _executionResultValue2, _executionResultValue3, _result$value5;
1086
1086
  var executionResultValue = result === null || result === void 0 || (_result$value4 = result.value) === null || _result$value4 === void 0 || (_result$value4 = _result$value4.execution_result) === null || _result$value4 === void 0 ? void 0 : _result$value4.value;
1087
1087
  if (executionResultValue !== null && executionResultValue !== void 0 && (_executionResultValue = executionResultValue.error) !== null && _executionResultValue !== void 0 && (_executionResultValue = _executionResultValue.value) !== null && _executionResultValue !== void 0 && (_executionResultValue = _executionResultValue.value) !== null && _executionResultValue !== void 0 && _executionResultValue.type) {
1088
1088
  return executionResultValue.error.value.value;
@@ -1090,6 +1090,9 @@ var PapiApi = /*#__PURE__*/function () {
1090
1090
  if (executionResultValue !== null && executionResultValue !== void 0 && (_executionResultValue2 = executionResultValue.error) !== null && _executionResultValue2 !== void 0 && (_executionResultValue2 = _executionResultValue2.value) !== null && _executionResultValue2 !== void 0 && _executionResultValue2.type) {
1091
1091
  return executionResultValue.error.value;
1092
1092
  }
1093
+ if (executionResultValue !== null && executionResultValue !== void 0 && (_executionResultValue3 = executionResultValue.error) !== null && _executionResultValue3 !== void 0 && _executionResultValue3.type) {
1094
+ return executionResultValue.error;
1095
+ }
1093
1096
  if (result !== null && result !== void 0 && (_result$value5 = result.value) !== null && _result$value5 !== void 0 && _result$value5.type) {
1094
1097
  return result.value;
1095
1098
  }
@@ -1279,14 +1282,90 @@ var PapiApi = /*#__PURE__*/function () {
1279
1282
  }
1280
1283
  return getXcmWeight;
1281
1284
  }()
1285
+ }, {
1286
+ key: "getDeliveryFee",
1287
+ value: function () {
1288
+ var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, forwardedXcm, asset, assetLocalizedLoc) {
1289
+ var _deliveryFeeRes, _deliveryFeeRes2;
1290
+ var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res, _t4, _t5;
1291
+ return _regenerator().w(function (_context12) {
1292
+ while (1) switch (_context12.p = _context12.n) {
1293
+ case 0:
1294
+ xcmPaymentApi = this.api.getUnsafeApi().apis.XcmPaymentApi;
1295
+ usedThirdParam = false;
1296
+ if (!(forwardedXcm.length > 0)) {
1297
+ _context12.n = 6;
1298
+ break;
1299
+ }
1300
+ baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
1301
+ _context12.p = 1;
1302
+ _context12.n = 2;
1303
+ return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs);
1304
+ case 2:
1305
+ deliveryFeeRes = _context12.v;
1306
+ _context12.n = 6;
1307
+ break;
1308
+ case 3:
1309
+ _context12.p = 3;
1310
+ _t4 = _context12.v;
1311
+ message = _t4 instanceof Error ? _t4.message : String(_t4); // Some runtimes require the 3rd arg; without it the runtime-api call can throw
1312
+ // with a generic "Cannot read properties of undefined".
1313
+ if (!message.includes('Cannot read properties of undefined')) {
1314
+ _context12.n = 5;
1315
+ break;
1316
+ }
1317
+ usedThirdParam = true;
1318
+ transformedAssetLoc = _transform(addXcmVersionHeader(assetLocalizedLoc, Version.V4));
1319
+ _context12.n = 4;
1320
+ return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs.concat([transformedAssetLoc]));
1321
+ case 4:
1322
+ deliveryFeeRes = _context12.v;
1323
+ _context12.n = 6;
1324
+ break;
1325
+ case 5:
1326
+ throw _t4;
1327
+ case 6:
1328
+ deliveryFeeResolved = ((_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 || (_deliveryFeeRes = _deliveryFeeRes.value) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.value.length) > 0 ? (_deliveryFeeRes2 = deliveryFeeRes) === null || _deliveryFeeRes2 === void 0 || (_deliveryFeeRes2 = _deliveryFeeRes2.value) === null || _deliveryFeeRes2 === void 0 ? void 0 : _deliveryFeeRes2.value[0].fun.value : 0n;
1329
+ nativeAsset = findNativeAssetInfoOrThrow(chain);
1330
+ if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
1331
+ _context12.n = 7;
1332
+ break;
1333
+ }
1334
+ return _context12.a(2, deliveryFeeResolved);
1335
+ case 7:
1336
+ _context12.p = 7;
1337
+ assertHasLocation(nativeAsset);
1338
+ _context12.n = 8;
1339
+ return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
1340
+ case 8:
1341
+ res = _context12.v;
1342
+ return _context12.a(2, res !== null && res !== void 0 ? res : 0n);
1343
+ case 9:
1344
+ _context12.p = 9;
1345
+ _t5 = _context12.v;
1346
+ if (!(_t5 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t5.message))) {
1347
+ _context12.n = 10;
1348
+ break;
1349
+ }
1350
+ return _context12.a(2, 0n);
1351
+ case 10:
1352
+ return _context12.a(2, 0n);
1353
+ case 11:
1354
+ return _context12.a(2);
1355
+ }
1356
+ }, _callee12, this, [[7, 9], [1, 3]]);
1357
+ }));
1358
+ function getDeliveryFee(_x17, _x18, _x19, _x20) {
1359
+ return _getDeliveryFee.apply(this, arguments);
1360
+ }
1361
+ return getDeliveryFee;
1362
+ }()
1282
1363
  }, {
1283
1364
  key: "getXcmPaymentApiFee",
1284
1365
  value: function () {
1285
- var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(chain, localXcm, forwardedXcm, asset) {
1366
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset) {
1286
1367
  var _this2 = this,
1287
- _execFeeRes$value,
1288
- _deliveryFeeRes$value,
1289
- _deliveryFeeRes$value2;
1368
+ _execFeeRes$value;
1290
1369
  var transformXcm,
1291
1370
  overridenWeight,
1292
1371
  transformedXcm,
@@ -1297,123 +1376,79 @@ var PapiApi = /*#__PURE__*/function () {
1297
1376
  execFeeRes,
1298
1377
  execFee,
1299
1378
  bridgeHubExecFee,
1300
- deliveryFeeRes,
1301
- deliveryFeeResolved,
1302
- nativeAsset,
1303
1379
  deliveryFee,
1304
- res,
1305
- _args12 = arguments,
1306
- _t4,
1307
- _t5,
1380
+ _args13 = arguments,
1308
1381
  _t6;
1309
- return _regenerator().w(function (_context13) {
1310
- while (1) switch (_context13.p = _context13.n) {
1382
+ return _regenerator().w(function (_context14) {
1383
+ while (1) switch (_context14.n) {
1311
1384
  case 0:
1312
- transformXcm = _args12.length > 4 && _args12[4] !== undefined ? _args12[4] : false;
1313
- overridenWeight = _args12.length > 5 ? _args12[5] : undefined;
1385
+ transformXcm = _args13.length > 4 && _args13[4] !== undefined ? _args13[4] : false;
1386
+ overridenWeight = _args13.length > 5 ? _args13[5] : undefined;
1314
1387
  transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
1315
1388
  queryWeight = /*#__PURE__*/function () {
1316
- var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
1389
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1317
1390
  var weightRes;
1318
- return _regenerator().w(function (_context12) {
1319
- while (1) switch (_context12.n) {
1391
+ return _regenerator().w(function (_context13) {
1392
+ while (1) switch (_context13.n) {
1320
1393
  case 0:
1321
- _context12.n = 1;
1394
+ _context13.n = 1;
1322
1395
  return _this2.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
1323
1396
  case 1:
1324
- weightRes = _context12.v;
1325
- return _context12.a(2, weightRes.value);
1397
+ weightRes = _context13.v;
1398
+ return _context13.a(2, weightRes.value);
1326
1399
  }
1327
- }, _callee12);
1400
+ }, _callee13);
1328
1401
  }));
1329
1402
  return function queryWeight() {
1330
1403
  return _ref11.apply(this, arguments);
1331
1404
  };
1332
1405
  }();
1333
1406
  if (!(overridenWeight !== null && overridenWeight !== void 0)) {
1334
- _context13.n = 1;
1407
+ _context14.n = 1;
1335
1408
  break;
1336
1409
  }
1337
- _t4 = overridenWeight;
1338
- _context13.n = 3;
1410
+ _t6 = overridenWeight;
1411
+ _context14.n = 3;
1339
1412
  break;
1340
1413
  case 1:
1341
- _context13.n = 2;
1414
+ _context14.n = 2;
1342
1415
  return queryWeight();
1343
1416
  case 2:
1344
- _t4 = _context13.v;
1417
+ _t6 = _context14.v;
1345
1418
  case 3:
1346
- weight = _t4;
1419
+ weight = _t6;
1347
1420
  assertHasLocation(asset);
1348
1421
  assetLocalizedLoc = localizeLocation(chain, asset.location);
1349
1422
  transformedAssetLoc = _transform(assetLocalizedLoc);
1350
- _context13.n = 4;
1423
+ _context14.n = 4;
1351
1424
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight, {
1352
1425
  type: Version.V4,
1353
1426
  value: transformedAssetLoc
1354
1427
  });
1355
1428
  case 4:
1356
- execFeeRes = _context13.v;
1429
+ execFeeRes = _context14.v;
1357
1430
  execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
1358
1431
  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')) {
1359
- _context13.n = 6;
1432
+ _context14.n = 6;
1360
1433
  break;
1361
1434
  }
1362
- _context13.n = 5;
1435
+ _context14.n = 5;
1363
1436
  return this.getBridgeHubFallbackExecFee(chain, weight, asset);
1364
1437
  case 5:
1365
- bridgeHubExecFee = _context13.v;
1438
+ bridgeHubExecFee = _context14.v;
1366
1439
  if (typeof bridgeHubExecFee === 'bigint') {
1367
1440
  execFee = bridgeHubExecFee;
1368
1441
  }
1369
1442
  case 6:
1370
- if (!(forwardedXcm.length > 0)) {
1371
- _context13.n = 8;
1372
- break;
1373
- }
1374
- _context13.n = 7;
1375
- return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
1443
+ _context14.n = 7;
1444
+ return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc);
1376
1445
  case 7:
1377
- _t5 = _context13.v;
1378
- _context13.n = 9;
1379
- break;
1380
- case 8:
1381
- _t5 = undefined;
1382
- case 9:
1383
- deliveryFeeRes = _t5;
1384
- 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;
1385
- nativeAsset = findNativeAssetInfoOrThrow(chain);
1386
- if (!isAssetXcEqual(asset, nativeAsset)) {
1387
- _context13.n = 10;
1388
- break;
1389
- }
1390
- deliveryFee = deliveryFeeResolved;
1391
- _context13.n = 13;
1392
- break;
1393
- case 10:
1394
- _context13.p = 10;
1395
- assertHasLocation(nativeAsset);
1396
- _context13.n = 11;
1397
- return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
1398
- case 11:
1399
- res = _context13.v;
1400
- deliveryFee = res !== null && res !== void 0 ? res : 0n;
1401
- _context13.n = 13;
1402
- break;
1403
- case 12:
1404
- _context13.p = 12;
1405
- _t6 = _context13.v;
1406
- if (_t6 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t6.message)) {
1407
- deliveryFee = 0n;
1408
- } else {
1409
- deliveryFee = 0n;
1410
- }
1411
- case 13:
1412
- return _context13.a(2, execFee + deliveryFee);
1446
+ deliveryFee = _context14.v;
1447
+ return _context14.a(2, execFee + deliveryFee);
1413
1448
  }
1414
- }, _callee13, this, [[10, 12]]);
1449
+ }, _callee14, this);
1415
1450
  }));
1416
- function getXcmPaymentApiFee(_x17, _x18, _x19, _x20) {
1451
+ function getXcmPaymentApiFee(_x21, _x22, _x23, _x24) {
1417
1452
  return _getXcmPaymentApiFee.apply(this, arguments);
1418
1453
  }
1419
1454
  return getXcmPaymentApiFee;
@@ -1421,46 +1456,46 @@ var PapiApi = /*#__PURE__*/function () {
1421
1456
  }, {
1422
1457
  key: "getBridgeHubFallbackExecFee",
1423
1458
  value: function () {
1424
- var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, weightValue, asset) {
1459
+ var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(chain, weightValue, asset) {
1425
1460
  var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
1426
- return _regenerator().w(function (_context14) {
1427
- while (1) switch (_context14.n) {
1461
+ return _regenerator().w(function (_context15) {
1462
+ while (1) switch (_context15.n) {
1428
1463
  case 0:
1429
- _context14.n = 1;
1464
+ _context15.n = 1;
1430
1465
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
1431
1466
  type: Version.V4,
1432
1467
  value: _transform(RELAY_LOCATION)
1433
1468
  });
1434
1469
  case 1:
1435
- fallbackExecFeeRes = _context14.v;
1470
+ fallbackExecFeeRes = _context15.v;
1436
1471
  if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
1437
- _context14.n = 2;
1472
+ _context15.n = 2;
1438
1473
  break;
1439
1474
  }
1440
- return _context14.a(2, undefined);
1475
+ return _context15.a(2, undefined);
1441
1476
  case 2:
1442
1477
  ahApi = this.clone();
1443
1478
  assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
1444
- _context14.n = 3;
1479
+ _context15.n = 3;
1445
1480
  return ahApi.init(assetHubChain);
1446
1481
  case 3:
1447
1482
  assertHasLocation(asset);
1448
1483
  ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
1449
- _context14.n = 4;
1484
+ _context15.n = 4;
1450
1485
  return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false);
1451
1486
  case 4:
1452
- convertedExecFee = _context14.v;
1487
+ convertedExecFee = _context15.v;
1453
1488
  if (!(typeof convertedExecFee === 'bigint')) {
1454
- _context14.n = 5;
1489
+ _context15.n = 5;
1455
1490
  break;
1456
1491
  }
1457
- return _context14.a(2, convertedExecFee);
1492
+ return _context15.a(2, convertedExecFee);
1458
1493
  case 5:
1459
- return _context14.a(2, undefined);
1494
+ return _context15.a(2, undefined);
1460
1495
  }
1461
- }, _callee14, this);
1496
+ }, _callee15, this);
1462
1497
  }));
1463
- function getBridgeHubFallbackExecFee(_x21, _x22, _x23) {
1498
+ function getBridgeHubFallbackExecFee(_x25, _x26, _x27) {
1464
1499
  return _getBridgeHubFallbackExecFee.apply(this, arguments);
1465
1500
  }
1466
1501
  return getBridgeHubFallbackExecFee;
@@ -1468,32 +1503,32 @@ var PapiApi = /*#__PURE__*/function () {
1468
1503
  }, {
1469
1504
  key: "getDryRunXcm",
1470
1505
  value: function () {
1471
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref12) {
1506
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref12) {
1472
1507
  var _ref13, _processAssetsDeposit, _ref14, _ref15, _ref16, _ref17, _ref18;
1473
1508
  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;
1474
- return _regenerator().w(function (_context15) {
1475
- while (1) switch (_context15.n) {
1509
+ return _regenerator().w(function (_context16) {
1510
+ while (1) switch (_context16.n) {
1476
1511
  case 0:
1477
1512
  originLocation = _ref12.originLocation, xcm = _ref12.xcm, chain = _ref12.chain, origin = _ref12.origin, asset = _ref12.asset, feeAsset = _ref12.feeAsset, originFee = _ref12.originFee, amount = _ref12.amount;
1478
1513
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1479
1514
  if (supportsDryRunApi) {
1480
- _context15.n = 1;
1515
+ _context16.n = 1;
1481
1516
  break;
1482
1517
  }
1483
1518
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
1484
1519
  case 1:
1485
1520
  transformedOriginLocation = _transform(originLocation);
1486
- _context15.n = 2;
1521
+ _context16.n = 2;
1487
1522
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1488
1523
  case 2:
1489
- result = _context15.v;
1524
+ result = _context16.v;
1490
1525
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1491
1526
  if (isSuccess) {
1492
- _context15.n = 3;
1527
+ _context16.n = 3;
1493
1528
  break;
1494
1529
  }
1495
1530
  failureReason = extractDryRunXcmFailureReason(result);
1496
- return _context15.a(2, {
1531
+ return _context16.a(2, {
1497
1532
  success: false,
1498
1533
  failureReason: failureReason,
1499
1534
  asset: asset
@@ -1507,18 +1542,18 @@ var PapiApi = /*#__PURE__*/function () {
1507
1542
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1508
1543
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1509
1544
  if (!(hasXcmPaymentApiSupport(chain) && asset)) {
1510
- _context15.n = 5;
1545
+ _context16.n = 5;
1511
1546
  break;
1512
1547
  }
1513
- _context15.n = 4;
1548
+ _context16.n = 4;
1514
1549
  return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
1515
1550
  case 4:
1516
- _fee = _context15.v;
1551
+ _fee = _context16.v;
1517
1552
  if (!(typeof _fee === 'bigint')) {
1518
- _context15.n = 5;
1553
+ _context16.n = 5;
1519
1554
  break;
1520
1555
  }
1521
- return _context15.a(2, {
1556
+ return _context16.a(2, {
1522
1557
  success: true,
1523
1558
  fee: _fee,
1524
1559
  asset: asset,
@@ -1561,10 +1596,10 @@ var PapiApi = /*#__PURE__*/function () {
1561
1596
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1562
1597
  });
1563
1598
  if (feeEvent) {
1564
- _context15.n = 6;
1599
+ _context16.n = 6;
1565
1600
  break;
1566
1601
  }
1567
- return _context15.a(2, Promise.resolve({
1602
+ return _context16.a(2, Promise.resolve({
1568
1603
  success: false,
1569
1604
  failureReason: 'Cannot determine destination fee. No fee event found',
1570
1605
  asset: asset
@@ -1575,7 +1610,7 @@ var PapiApi = /*#__PURE__*/function () {
1575
1610
  fee = amount - originFee - feeEvent.value.value.amount;
1576
1611
  }
1577
1612
  processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
1578
- return _context15.a(2, Promise.resolve({
1613
+ return _context16.a(2, Promise.resolve({
1579
1614
  success: true,
1580
1615
  fee: processedFee,
1581
1616
  asset: asset,
@@ -1584,9 +1619,9 @@ var PapiApi = /*#__PURE__*/function () {
1584
1619
  destParaId: destParaId
1585
1620
  }));
1586
1621
  }
1587
- }, _callee15, this);
1622
+ }, _callee16, this);
1588
1623
  }));
1589
- function getDryRunXcm(_x24) {
1624
+ function getDryRunXcm(_x28) {
1590
1625
  return _getDryRunXcm.apply(this, arguments);
1591
1626
  }
1592
1627
  return getDryRunXcm;
@@ -1594,18 +1629,18 @@ var PapiApi = /*#__PURE__*/function () {
1594
1629
  }, {
1595
1630
  key: "getBridgeStatus",
1596
1631
  value: function () {
1597
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1632
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
1598
1633
  var outboundOperatingMode;
1599
- return _regenerator().w(function (_context16) {
1600
- while (1) switch (_context16.n) {
1634
+ return _regenerator().w(function (_context17) {
1635
+ while (1) switch (_context17.n) {
1601
1636
  case 0:
1602
- _context16.n = 1;
1637
+ _context17.n = 1;
1603
1638
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1604
1639
  case 1:
1605
- outboundOperatingMode = _context16.v;
1606
- return _context16.a(2, outboundOperatingMode.type);
1640
+ outboundOperatingMode = _context17.v;
1641
+ return _context17.a(2, outboundOperatingMode.type);
1607
1642
  }
1608
- }, _callee16, this);
1643
+ }, _callee17, this);
1609
1644
  }));
1610
1645
  function getBridgeStatus() {
1611
1646
  return _getBridgeStatus.apply(this, arguments);
@@ -1653,22 +1688,22 @@ var PapiApi = /*#__PURE__*/function () {
1653
1688
  }, {
1654
1689
  key: "signAndSubmit",
1655
1690
  value: function () {
1656
- var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, path) {
1691
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(tx, path) {
1657
1692
  var signer, _yield$tx$signAndSubm, txHash;
1658
- return _regenerator().w(function (_context17) {
1659
- while (1) switch (_context17.n) {
1693
+ return _regenerator().w(function (_context18) {
1694
+ while (1) switch (_context18.n) {
1660
1695
  case 0:
1661
1696
  signer = createDevSigner(path);
1662
- _context17.n = 1;
1697
+ _context18.n = 1;
1663
1698
  return tx.signAndSubmit(signer);
1664
1699
  case 1:
1665
- _yield$tx$signAndSubm = _context17.v;
1700
+ _yield$tx$signAndSubm = _context18.v;
1666
1701
  txHash = _yield$tx$signAndSubm.txHash;
1667
- return _context17.a(2, txHash);
1702
+ return _context18.a(2, txHash);
1668
1703
  }
1669
- }, _callee17);
1704
+ }, _callee18);
1670
1705
  }));
1671
- function signAndSubmit(_x25, _x26) {
1706
+ function signAndSubmit(_x29, _x30) {
1672
1707
  return _signAndSubmit.apply(this, arguments);
1673
1708
  }
1674
1709
  return signAndSubmit;
@@ -1849,7 +1884,7 @@ var EvmBuilderCore = /*#__PURE__*/function () {
1849
1884
  _context.n = 1;
1850
1885
  break;
1851
1886
  }
1852
- return _context.a(2, transferMoonbeamToEth(this._options));
1887
+ return _context.a(2, transferMoonbeamToEth(from, this._options));
1853
1888
  case 1:
1854
1889
  return _context.a(2, transferMoonbeamEvm(this._options));
1855
1890
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "12.2.2",
3
+ "version": "12.4.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,12 +28,13 @@
28
28
  "@polkadot-labs/hdkd": "^0.0.26",
29
29
  "@polkadot-labs/hdkd-helpers": "^0.0.27",
30
30
  "viem": "2.40.3",
31
- "@paraspell/sdk-core": "12.2.2"
31
+ "@paraspell/sdk-core": "12.4.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "polkadot-api": ">= 1.23.1 < 2"
35
35
  },
36
36
  "devDependencies": {
37
+ "@acala-network/chopsticks": "^1.2.5",
37
38
  "@babel/plugin-syntax-import-attributes": "^7.27.1",
38
39
  "@babel/preset-env": "^7.28.5",
39
40
  "@codecov/rollup-plugin": "^1.9.1",
@@ -61,6 +62,7 @@
61
62
  "test:cov": "vitest run --coverage",
62
63
  "test:watch": "vitest",
63
64
  "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test",
64
- "test:e2e": "vitest run --config ./vitest.config.e2e.ts --sequence.concurrent"
65
+ "test:e2e": "vitest run --config ./vitest.config.e2e.ts --sequence.concurrent",
66
+ "test:e2e:chopsticks": "vitest run --config ./vitest.config.chopsticks.e2e.ts"
65
67
  }
66
68
  }