@paraspell/sdk-pjs 8.4.2 → 8.5.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 CHANGED
@@ -11,7 +11,7 @@
11
11
  <img alt="downloads" src="https://img.shields.io/npm/dm/@paraspell/sdk-pjs?style=flat-square" />
12
12
  </a>
13
13
  <a href="https://github.com/paraspell/xcm-sdk/actions">
14
- <img alt="build" src="https://github.com/paraspell/xcm-sdk/actions/workflows/release.yml/badge.svg" />
14
+ <img alt="build" src="https://github.com/paraspell/xcm-tools/actions/workflows/ci.yml/badge.svg" />
15
15
  </a>
16
16
  <a href="https://snyk.io/test/github/paraspell/sdk">
17
17
  <img alt="snyk" src="https://snyk.io/test/github/paraspell/sdk/badge.svg" />
@@ -19,7 +19,6 @@
19
19
  </p>
20
20
  <p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported.html"\>[list]</p>
21
21
  <p>SDK documentation <a href = "https://paraspell.github.io/docs/" \>[here]</p>
22
- <p>SDK starter template project <a href = "https://github.com/paraspell/xcm-sdk-template" \>[here]</p>
23
22
  </div>
24
23
 
25
24
  <br /><br />
@@ -223,7 +222,7 @@ const result = await Builder(API /*optional*/)
223
222
  .dryRun(SENDER_ADDRESS)
224
223
 
225
224
  //Function pattern
226
- getDryRun({api /*optional*/, node, address /*sender address*/, tx /* Extrinsic object */})
225
+ await getDryRun({api /*optional*/, node, address /*sender address*/, tx /* Extrinsic object */})
227
226
  ```
228
227
 
229
228
  ### Asset claim:
@@ -331,6 +330,9 @@ await getTransferableAmount({address, node, currency /*- {id: currencyID} | {sym
331
330
 
332
331
  //Get all the information about XCM transfer
333
332
  await getTransferInfo({from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, api /* api/ws_url_string optional */})
333
+
334
+ //Get bridge and execution fee for transfer from Parachain to Ethereum. Returns as an object of 2 values - [bridgeFee, executionFee]
335
+ await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
334
336
  ```
335
337
 
336
338
  ## 💻 Tests
package/dist/index.cjs CHANGED
@@ -1395,12 +1395,35 @@ var transferEthToPolkadot = function transferEthToPolkadot(options) {
1395
1395
  api: new PolkadotJsApi()
1396
1396
  }));
1397
1397
  };
1398
+ var getParaEthTransferFees = /*#__PURE__*/function () {
1399
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
1400
+ var pjsApi;
1401
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1402
+ while (1) switch (_context.prev = _context.next) {
1403
+ case 0:
1404
+ pjsApi = new PolkadotJsApi();
1405
+ pjsApi.setApi(api);
1406
+ _context.next = 4;
1407
+ return pjsApi.init('AssetHubPolkadot');
1408
+ case 4:
1409
+ return _context.abrupt("return", sdkCore.getParaEthTransferFees(pjsApi));
1410
+ case 5:
1411
+ case "end":
1412
+ return _context.stop();
1413
+ }
1414
+ }, _callee);
1415
+ }));
1416
+ return function getParaEthTransferFees(_x) {
1417
+ return _ref.apply(this, arguments);
1418
+ };
1419
+ }();
1398
1420
 
1399
1421
  var transfer = /*#__PURE__*/Object.freeze({
1400
1422
  __proto__: null,
1401
1423
  approveToken: approveToken,
1402
1424
  depositToken: depositToken,
1403
1425
  getDryRun: getDryRun,
1426
+ getParaEthTransferFees: getParaEthTransferFees,
1404
1427
  getTokenBalance: getTokenBalance,
1405
1428
  send: send,
1406
1429
  transferEthToPolkadot: transferEthToPolkadot
@@ -1545,7 +1568,7 @@ var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
1545
1568
  var transferMoonbeamToEth = /*#__PURE__*/function () {
1546
1569
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
1547
1570
  var _signer$account;
1548
- var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, BRIDGE_LOCATION, ERC20_TOKEN_LOCATION, ERC20_TOKEN_LOCATION_REANCHORED, customXcm, apiPjs, assetHubApi, assetHubApiPjs, xcmHash, sender, _yield$Promise$all, _yield$Promise$all2, parachainId, accountNextId, entropy, messageId, xcmOnDest, customXcmOnDest, transferFee, createTx, tx;
1571
+ var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, BRIDGE_LOCATION, ERC20_TOKEN_LOCATION, ERC20_TOKEN_LOCATION_REANCHORED, customXcm, apiPjs, assetHubApi, assetHubApiPjs, xcmHash, sender, _yield$Promise$all, _yield$Promise$all2, parachainId, accountNextId, entropy, messageId, xcmOnDest, customXcmOnDest, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, createTx, tx;
1549
1572
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1550
1573
  while (1) switch (_context.prev = _context.next) {
1551
1574
  case 0:
@@ -1748,10 +1771,13 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1748
1771
  });
1749
1772
  customXcmOnDest = xcmOnDest.toHex();
1750
1773
  _context.next = 57;
1751
- return sdkCore.calculateFee(assetHubApi);
1774
+ return sdkCore.getParaEthTransferFees(assetHubApi);
1752
1775
  case 57:
1753
- transferFee = _context.sent;
1754
- // Partially inspired by Moonbeam XCM-SDK
1776
+ _yield$getParaEthTran = _context.sent;
1777
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
1778
+ bridgeFee = _yield$getParaEthTran2[0];
1779
+ executionFee = _yield$getParaEthTran2[1];
1780
+ transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
1755
1781
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
1756
1782
  createTx = function createTx(func, args) {
1757
1783
  if (isEthersContract(contract)) {
@@ -1759,7 +1785,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1759
1785
  }
1760
1786
  return contract.write[func](args);
1761
1787
  }; // Execute the custom XCM message with the precompile
1762
- _context.next = 61;
1788
+ _context.next = 65;
1763
1789
  return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
1764
1790
  // This represents (1,X1(Parachain(1000)))
1765
1791
  [1, ['0x00' + util.numberToHex(sdkCore.getParaId('AssetHubPolkadot'), 32).slice(2)]],
@@ -1771,10 +1797,10 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1771
1797
  0,
1772
1798
  // The TransferType corresponding to fee asset
1773
1799
  2, customXcmOnDest]);
1774
- case 61:
1800
+ case 65:
1775
1801
  tx = _context.sent;
1776
1802
  return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
1777
- case 63:
1803
+ case 67:
1778
1804
  case "end":
1779
1805
  return _context.stop();
1780
1806
  }
@@ -1964,6 +1990,7 @@ exports.getDryRun = getDryRun;
1964
1990
  exports.getMaxForeignTransferableAmount = getMaxForeignTransferableAmount;
1965
1991
  exports.getMaxNativeTransferableAmount = getMaxNativeTransferableAmount;
1966
1992
  exports.getOriginFeeDetails = getOriginFeeDetails;
1993
+ exports.getParaEthTransferFees = getParaEthTransferFees;
1967
1994
  exports.getTokenBalance = getTokenBalance;
1968
1995
  exports.getTransferInfo = getTransferInfo;
1969
1996
  exports.getTransferableAmount = getTransferableAmount;
package/dist/index.d.ts CHANGED
@@ -43,15 +43,17 @@ declare const transferEthToPolkadot: (options: Omit<TEvmBuilderOptions<TPjsApi,
43
43
  response: ethers.TransactionResponse;
44
44
  messageReceipt: _snowbridge_api_dist_toPolkadot_v2.MessageReceipt;
45
45
  }>;
46
+ declare const getParaEthTransferFees: (api?: TPjsApiOrUrl) => Promise<[bigint, bigint]>;
46
47
 
47
48
  declare const transfer_approveToken: typeof approveToken;
48
49
  declare const transfer_depositToken: typeof depositToken;
49
50
  declare const transfer_getDryRun: typeof getDryRun;
51
+ declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
50
52
  declare const transfer_getTokenBalance: typeof getTokenBalance;
51
53
  declare const transfer_send: typeof send;
52
54
  declare const transfer_transferEthToPolkadot: typeof transferEthToPolkadot;
53
55
  declare namespace transfer {
54
- export { transfer_approveToken as approveToken, transfer_depositToken as depositToken, transfer_getDryRun as getDryRun, transfer_getTokenBalance as getTokenBalance, transfer_send as send, transfer_transferEthToPolkadot as transferEthToPolkadot };
56
+ export { transfer_approveToken as approveToken, transfer_depositToken as depositToken, transfer_getDryRun as getDryRun, transfer_getParaEthTransferFees as getParaEthTransferFees, transfer_getTokenBalance as getTokenBalance, transfer_send as send, transfer_transferEthToPolkadot as transferEthToPolkadot };
55
57
  }
56
58
 
57
59
  /**
@@ -208,4 +210,4 @@ type IFinalBuilderWithOptions = IFinalBuilderWithOptions$1<TPjsApi, Extrinsic>;
208
210
 
209
211
  declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<_polkadot_api.ApiPromise>;
210
212
 
211
- export { Builder, EvmBuilder, type Extrinsic, GeneralBuilder, type IFinalBuilderWithOptions, type TPjsApi, type TPjsApiOrUrl, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
213
+ export { Builder, EvmBuilder, type Extrinsic, GeneralBuilder, type IFinalBuilderWithOptions, type TPjsApi, type TPjsApiOrUrl, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getParaId, isForeignAsset, InvalidCurrencyError, getAssetBySymbolOrId, isOverrideMultiLocationSpecifier, BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, calculateFee, ETH_CHAIN_ID, findAssetByMultiLocation, ETHEREUM_JUNCTION, transferMoonbeamEvm, validateAddress, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
1
+ import { getParaId, isForeignAsset, InvalidCurrencyError, getAssetBySymbolOrId, isOverrideMultiLocationSpecifier, BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getParaEthTransferFees as getParaEthTransferFees$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, ETH_CHAIN_ID, findAssetByMultiLocation, ETHEREUM_JUNCTION, transferMoonbeamEvm, validateAddress, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { Context, toPolkadotV2, assetsV2, environment } from '@snowbridge/api';
4
4
  import { WETH9__factory } from '@snowbridge/contract-types';
@@ -1394,12 +1394,35 @@ var transferEthToPolkadot = function transferEthToPolkadot(options) {
1394
1394
  api: new PolkadotJsApi()
1395
1395
  }));
1396
1396
  };
1397
+ var getParaEthTransferFees = /*#__PURE__*/function () {
1398
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
1399
+ var pjsApi;
1400
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1401
+ while (1) switch (_context.prev = _context.next) {
1402
+ case 0:
1403
+ pjsApi = new PolkadotJsApi();
1404
+ pjsApi.setApi(api);
1405
+ _context.next = 4;
1406
+ return pjsApi.init('AssetHubPolkadot');
1407
+ case 4:
1408
+ return _context.abrupt("return", getParaEthTransferFees$1(pjsApi));
1409
+ case 5:
1410
+ case "end":
1411
+ return _context.stop();
1412
+ }
1413
+ }, _callee);
1414
+ }));
1415
+ return function getParaEthTransferFees(_x) {
1416
+ return _ref.apply(this, arguments);
1417
+ };
1418
+ }();
1397
1419
 
1398
1420
  var transfer = /*#__PURE__*/Object.freeze({
1399
1421
  __proto__: null,
1400
1422
  approveToken: approveToken,
1401
1423
  depositToken: depositToken,
1402
1424
  getDryRun: getDryRun,
1425
+ getParaEthTransferFees: getParaEthTransferFees,
1403
1426
  getTokenBalance: getTokenBalance,
1404
1427
  send: send,
1405
1428
  transferEthToPolkadot: transferEthToPolkadot
@@ -1544,7 +1567,7 @@ var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
1544
1567
  var transferMoonbeamToEth = /*#__PURE__*/function () {
1545
1568
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
1546
1569
  var _signer$account;
1547
- var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, BRIDGE_LOCATION, ERC20_TOKEN_LOCATION, ERC20_TOKEN_LOCATION_REANCHORED, customXcm, apiPjs, assetHubApi, assetHubApiPjs, xcmHash, sender, _yield$Promise$all, _yield$Promise$all2, parachainId, accountNextId, entropy, messageId, xcmOnDest, customXcmOnDest, transferFee, createTx, tx;
1570
+ var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, BRIDGE_LOCATION, ERC20_TOKEN_LOCATION, ERC20_TOKEN_LOCATION_REANCHORED, customXcm, apiPjs, assetHubApi, assetHubApiPjs, xcmHash, sender, _yield$Promise$all, _yield$Promise$all2, parachainId, accountNextId, entropy, messageId, xcmOnDest, customXcmOnDest, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, createTx, tx;
1548
1571
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1549
1572
  while (1) switch (_context.prev = _context.next) {
1550
1573
  case 0:
@@ -1747,10 +1770,13 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1747
1770
  });
1748
1771
  customXcmOnDest = xcmOnDest.toHex();
1749
1772
  _context.next = 57;
1750
- return calculateFee(assetHubApi);
1773
+ return getParaEthTransferFees$1(assetHubApi);
1751
1774
  case 57:
1752
- transferFee = _context.sent;
1753
- // Partially inspired by Moonbeam XCM-SDK
1775
+ _yield$getParaEthTran = _context.sent;
1776
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
1777
+ bridgeFee = _yield$getParaEthTran2[0];
1778
+ executionFee = _yield$getParaEthTran2[1];
1779
+ transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
1754
1780
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
1755
1781
  createTx = function createTx(func, args) {
1756
1782
  if (isEthersContract(contract)) {
@@ -1758,7 +1784,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1758
1784
  }
1759
1785
  return contract.write[func](args);
1760
1786
  }; // Execute the custom XCM message with the precompile
1761
- _context.next = 61;
1787
+ _context.next = 65;
1762
1788
  return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
1763
1789
  // This represents (1,X1(Parachain(1000)))
1764
1790
  [1, ['0x00' + numberToHex(getParaId('AssetHubPolkadot'), 32).slice(2)]],
@@ -1770,10 +1796,10 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
1770
1796
  0,
1771
1797
  // The TransferType corresponding to fee asset
1772
1798
  2, customXcmOnDest]);
1773
- case 61:
1799
+ case 65:
1774
1800
  tx = _context.sent;
1775
1801
  return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
1776
- case 63:
1802
+ case 67:
1777
1803
  case "end":
1778
1804
  return _context.stop();
1779
1805
  }
@@ -1948,4 +1974,4 @@ var EvmBuilder = function EvmBuilder(provider) {
1948
1974
  return EvmBuilder$1(pjsApi, provider);
1949
1975
  };
1950
1976
 
1951
- export { Builder, EvmBuilder, GeneralBuilder, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
1977
+ export { Builder, EvmBuilder, GeneralBuilder, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "8.4.2",
3
+ "version": "8.5.1",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "@snowbridge/contract-types": "^0.1.32",
28
28
  "ethers": "^6.13.5",
29
29
  "viem": "^2.22.22",
30
- "@paraspell/sdk-core": "8.4.2"
30
+ "@paraspell/sdk-core": "8.5.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@polkadot/api": ">= 15.0 < 16",