@paraspell/sdk 6.2.2 → 6.2.4

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
@@ -293,7 +293,7 @@ await getBalanceForeign(address, Parachain name, currency /*- {id: currencyID} |
293
293
  await getBalanceNative(address, Parachain name)
294
294
 
295
295
  //Get fee information regarding XCM call
296
- await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress)
296
+ await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress, api /* optional */, feeMargin /* 10% by default */)
297
297
 
298
298
  //Get all the information about XCM transfer
299
299
  await getTransferInfo(from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount)
package/dist/index.cjs CHANGED
@@ -589,6 +589,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
589
589
  };
590
590
 
591
591
  var Polkadot$1 = {
592
+ paraId: 0,
592
593
  relayChainAssetSymbol: "DOT",
593
594
  nativeAssetSymbol: "DOT",
594
595
  nativeAssets: [
@@ -601,6 +602,7 @@ var Polkadot$1 = {
601
602
  ]
602
603
  };
603
604
  var Kusama$1 = {
605
+ paraId: 0,
604
606
  relayChainAssetSymbol: "KSM",
605
607
  nativeAssetSymbol: "KSM",
606
608
  nativeAssets: [
@@ -7664,7 +7666,6 @@ var Phala$3 = {
7664
7666
  ]
7665
7667
  };
7666
7668
  var Ethereum$1 = {
7667
- paraId: 1,
7668
7669
  relayChainAssetSymbol: "DOT",
7669
7670
  nativeAssetSymbol: "ETH",
7670
7671
  nativeAssets: [
@@ -8240,11 +8241,14 @@ var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version,
8240
8241
  return _defineProperty({}, version, isMultiLocationDestination ? destination : multiLocation);
8241
8242
  };
8242
8243
  var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(multiLocation) {
8244
+ var _a;
8243
8245
  var parachainId = findParachainJunction(multiLocation);
8244
8246
  if (parachainId === null) {
8245
8247
  throw new Error('Parachain ID not found in destination multi location.');
8246
8248
  }
8247
- var node = getTNode(parachainId);
8249
+ var node = (_a = NODE_NAMES.find(function (nodeName) {
8250
+ return getParaId(nodeName) === parachainId;
8251
+ })) !== null && _a !== void 0 ? _a : null;
8248
8252
  if (node === null) {
8249
8253
  throw new Error('Node with specified paraId not found in destination multi location.');
8250
8254
  }
@@ -11082,10 +11086,13 @@ var getParaId = function getParaId(node) {
11082
11086
  * @param paraId - The parachain ID.
11083
11087
  * @returns The node name if found; otherwise, null.
11084
11088
  */
11085
- var getTNode = function getTNode(paraId) {
11089
+ var getTNode = function getTNode(paraId, ecosystem) {
11086
11090
  var _a;
11087
- return (_a = NODE_NAMES.find(function (node) {
11088
- return getParaId(node) === paraId;
11091
+ if (paraId === 0) {
11092
+ return ecosystem === 'polkadot' ? 'Polkadot' : 'Kusama';
11093
+ }
11094
+ return (_a = NODE_NAMES_DOT_KSM.find(function (nodeName) {
11095
+ return getNode(nodeName).type === ecosystem && getParaId(nodeName) === paraId;
11089
11096
  })) !== null && _a !== void 0 ? _a : null;
11090
11097
  };
11091
11098
 
@@ -12689,6 +12696,26 @@ var EvmBuilder = function EvmBuilder(provider) {
12689
12696
  return new EvmBuilderClass(provider);
12690
12697
  };
12691
12698
 
12699
+ var calculateTransactionFee = function calculateTransactionFee(tx, address) {
12700
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12701
+ var _yield$tx$paymentInfo, partialFee;
12702
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12703
+ while (1) switch (_context.prev = _context.next) {
12704
+ case 0:
12705
+ _context.next = 2;
12706
+ return tx.paymentInfo(address);
12707
+ case 2:
12708
+ _yield$tx$paymentInfo = _context.sent;
12709
+ partialFee = _yield$tx$paymentInfo.partialFee;
12710
+ return _context.abrupt("return", partialFee.toBn());
12711
+ case 5:
12712
+ case "end":
12713
+ return _context.stop();
12714
+ }
12715
+ }, _callee);
12716
+ }));
12717
+ };
12718
+
12692
12719
  var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
12693
12720
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12694
12721
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -12723,75 +12750,58 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
12723
12750
  }, _callee);
12724
12751
  }));
12725
12752
  };
12726
- var calculateTransactionFee$1 = function calculateTransactionFee(tx, address) {
12727
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
12728
- var _yield$tx$paymentInfo, partialFee;
12729
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12730
- while (1) switch (_context2.prev = _context2.next) {
12731
- case 0:
12732
- _context2.next = 2;
12733
- return tx.paymentInfo(address);
12734
- case 2:
12735
- _yield$tx$paymentInfo = _context2.sent;
12736
- partialFee = _yield$tx$paymentInfo.partialFee;
12737
- return _context2.abrupt("return", partialFee.toBn());
12738
- case 5:
12739
- case "end":
12740
- return _context2.stop();
12741
- }
12742
- }, _callee2);
12743
- }));
12744
- };
12745
- var getOriginFeeDetails = function getOriginFeeDetails(origin, destination, currency, amount, account, api) {
12746
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
12747
- var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
12748
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
12749
- while (1) switch (_context3.prev = _context3.next) {
12750
- case 0:
12751
- _context3.next = 2;
12752
- return getBalanceNative(account, origin);
12753
- case 2:
12754
- nativeBalance = _context3.sent;
12755
- minTransferableAmount = getMinNativeTransferableAmount(origin);
12756
- if (!(api !== null && api !== void 0)) {
12757
- _context3.next = 8;
12753
+ var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
12754
+ for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
12755
+ args_1[_key - 6] = arguments[_key];
12756
+ }
12757
+ return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
12758
+ var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
12759
+ return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
12760
+ var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
12761
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12762
+ while (1) switch (_context2.prev = _context2.next) {
12763
+ case 0:
12764
+ _context2.next = 2;
12765
+ return getBalanceNative(account, origin);
12766
+ case 2:
12767
+ nativeBalance = _context2.sent;
12768
+ minTransferableAmount = getMinNativeTransferableAmount(origin);
12769
+ if (!(api !== null && api !== void 0)) {
12770
+ _context2.next = 8;
12771
+ break;
12772
+ }
12773
+ _context2.t0 = api;
12774
+ _context2.next = 11;
12758
12775
  break;
12759
- }
12760
- _context3.t0 = api;
12761
- _context3.next = 11;
12762
- break;
12763
- case 8:
12764
- _context3.next = 10;
12765
- return createApiInstanceForNode(origin);
12766
- case 10:
12767
- _context3.t0 = _context3.sent;
12768
- case 11:
12769
- apiWithFallback = _context3.t0;
12770
- _context3.next = 14;
12771
- return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
12772
- case 14:
12773
- tx = _context3.sent;
12774
- _context3.next = 17;
12775
- return calculateTransactionFee$1(tx, account);
12776
- case 17:
12777
- xcmFee = _context3.sent;
12778
- xcmFeeBigInt = BigInt(xcmFee.toString());
12779
- xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(10);
12780
- console.log('nativeBalance', nativeBalance);
12781
- console.log('minTransferableAmount', minTransferableAmount);
12782
- console.log('xcmFeeBigInt', xcmFeeBigInt);
12783
- console.log('xcmFeeWithMargin', xcmFeeWithMargin);
12784
- sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
12785
- return _context3.abrupt("return", {
12786
- sufficientForXCM: sufficientForXCM,
12787
- xcmFee: xcmFeeBigInt
12788
- });
12789
- case 26:
12790
- case "end":
12791
- return _context3.stop();
12792
- }
12793
- }, _callee3);
12794
- }));
12776
+ case 8:
12777
+ _context2.next = 10;
12778
+ return createApiInstanceForNode(origin);
12779
+ case 10:
12780
+ _context2.t0 = _context2.sent;
12781
+ case 11:
12782
+ apiWithFallback = _context2.t0;
12783
+ _context2.next = 14;
12784
+ return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
12785
+ case 14:
12786
+ tx = _context2.sent;
12787
+ _context2.next = 17;
12788
+ return calculateTransactionFee(tx, account);
12789
+ case 17:
12790
+ xcmFee = _context2.sent;
12791
+ xcmFeeBigInt = BigInt(xcmFee.toString());
12792
+ xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
12793
+ sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
12794
+ return _context2.abrupt("return", {
12795
+ sufficientForXCM: sufficientForXCM,
12796
+ xcmFee: xcmFeeBigInt
12797
+ });
12798
+ case 22:
12799
+ case "end":
12800
+ return _context2.stop();
12801
+ }
12802
+ }, _callee2);
12803
+ })();
12804
+ });
12795
12805
  };
12796
12806
 
12797
12807
  /**
@@ -12937,6 +12947,7 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
12937
12947
  var index$1 = /*#__PURE__*/Object.freeze({
12938
12948
  __proto__: null,
12939
12949
  getAllAssetsSymbols: getAllAssetsSymbols,
12950
+ getAssetBalance: getAssetBalance,
12940
12951
  getAssetDecimals: getAssetDecimals,
12941
12952
  getAssetId: getAssetId,
12942
12953
  getAssets: getAssets,
@@ -12946,6 +12957,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
12946
12957
  getExistentialDeposit: getExistentialDeposit$1,
12947
12958
  getNativeAssetSymbol: getNativeAssetSymbol,
12948
12959
  getNativeAssets: getNativeAssets,
12960
+ getOriginFeeDetails: getOriginFeeDetails,
12949
12961
  getOtherAssets: getOtherAssets,
12950
12962
  getParaId: getParaId,
12951
12963
  getRelayChainSymbol: getRelayChainSymbol,
@@ -13042,10 +13054,8 @@ var getAllNodeProviders = function getAllNodeProviders(node) {
13042
13054
 
13043
13055
  var getFees = function getFees(scenario) {
13044
13056
  if (scenario === 'ParaToRelay') {
13045
- console.log('Asigning fees for transfer to Relay chain');
13046
13057
  return 4600000000;
13047
13058
  } else if (scenario === 'ParaToPara') {
13048
- console.log('Asigning fees for transfer to another Parachain chain');
13049
13059
  return 399600000000;
13050
13060
  }
13051
13061
  throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
@@ -13222,26 +13232,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
13222
13232
  return _createClass(KeepAliveError);
13223
13233
  }(/*#__PURE__*/_wrapNativeSuper(Error));
13224
13234
 
13225
- var calculateTransactionFee = function calculateTransactionFee(tx, address) {
13226
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13227
- var _yield$tx$paymentInfo, partialFee;
13228
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13229
- while (1) switch (_context.prev = _context.next) {
13230
- case 0:
13231
- _context.next = 2;
13232
- return tx.paymentInfo(address);
13233
- case 2:
13234
- _yield$tx$paymentInfo = _context.sent;
13235
- partialFee = _yield$tx$paymentInfo.partialFee;
13236
- return _context.abrupt("return", partialFee.toBn());
13237
- case 5:
13238
- case "end":
13239
- return _context.stop();
13240
- }
13241
- }, _callee);
13242
- }));
13243
- };
13244
-
13245
13235
  var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
13246
13236
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13247
13237
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -13833,6 +13823,7 @@ exports.createApiInstanceForNode = createApiInstanceForNode;
13833
13823
  exports.determineRelayChain = determineRelayChain;
13834
13824
  exports.getAllAssetsSymbols = getAllAssetsSymbols;
13835
13825
  exports.getAllNodeProviders = getAllNodeProviders;
13826
+ exports.getAssetBalance = getAssetBalance;
13836
13827
  exports.getAssetDecimals = getAssetDecimals;
13837
13828
  exports.getAssetId = getAssetId;
13838
13829
  exports.getAssets = getAssets;
@@ -13846,6 +13837,7 @@ exports.getNativeAssets = getNativeAssets;
13846
13837
  exports.getNode = getNode;
13847
13838
  exports.getNodeEndpointOption = getNodeEndpointOption;
13848
13839
  exports.getNodeProvider = getNodeProvider;
13840
+ exports.getOriginFeeDetails = getOriginFeeDetails;
13849
13841
  exports.getOtherAssets = getOtherAssets;
13850
13842
  exports.getParaId = getParaId;
13851
13843
  exports.getRelayChainSymbol = getRelayChainSymbol;
package/dist/index.d.ts CHANGED
@@ -1082,14 +1082,14 @@ declare const getAssetDecimals: (node: TNodeWithRelayChains, symbol: string) =>
1082
1082
  * @param node - The node for which to get the paraId.
1083
1083
  * @returns The parachain ID of the node.
1084
1084
  */
1085
- declare const getParaId: (node: TNode) => number;
1085
+ declare const getParaId: (node: TNodeWithRelayChains) => number;
1086
1086
  /**
1087
1087
  * Retrieves the node name corresponding to a specified parachain ID.
1088
1088
  *
1089
1089
  * @param paraId - The parachain ID.
1090
1090
  * @returns The node name if found; otherwise, null.
1091
1091
  */
1092
- declare const getTNode: (paraId: number) => TNode | null;
1092
+ declare const getTNode: (paraId: number, ecosystem: TRelayChainType) => TNodeDotKsmWithRelayChains | null;
1093
1093
 
1094
1094
  /**
1095
1095
  * Retrieves the existential deposit value for a given node.
@@ -1099,6 +1099,8 @@ declare const getTNode: (paraId: number) => TNode | null;
1099
1099
  */
1100
1100
  declare const getExistentialDeposit: (node: TNodeDotKsmWithRelayChains) => string | null;
1101
1101
 
1102
+ declare const getAssetBalance: (account: string, node: TNodeDotKsmWithRelayChains, currency: TCurrencyCore) => Promise<bigint>;
1103
+
1102
1104
  /**
1103
1105
  * Retrieves the native balance for a given account on a specified node.
1104
1106
  *
@@ -1121,6 +1123,8 @@ declare const getBalanceNative: (address: string, node: TNodeWithRelayChains, ap
1121
1123
  */
1122
1124
  declare const getBalanceForeign: (address: string, node: TNodePolkadotKusama, symbolOrId: TCurrencyCore, api?: ApiPromise) => Promise<bigint | null>;
1123
1125
 
1126
+ declare const getOriginFeeDetails: (origin: TNodeDotKsmWithRelayChains, destination: TNodeDotKsmWithRelayChains, currency: TCurrencyCore, amount: string, account: string, api?: ApiPromise, feeMarginPercentage?: number) => Promise<TOriginFeeDetails>;
1127
+
1124
1128
  /**
1125
1129
  * Retrieves detailed transfer information for a cross-chain transfer.
1126
1130
  *
@@ -1144,6 +1148,7 @@ declare const getTransferInfo: (origin: TNodeDotKsmWithRelayChains, destination:
1144
1148
  declare const getSupportedAssets: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains) => TAsset[];
1145
1149
 
1146
1150
  declare const index_getAllAssetsSymbols: typeof getAllAssetsSymbols;
1151
+ declare const index_getAssetBalance: typeof getAssetBalance;
1147
1152
  declare const index_getAssetDecimals: typeof getAssetDecimals;
1148
1153
  declare const index_getAssetId: typeof getAssetId;
1149
1154
  declare const index_getAssets: typeof getAssets;
@@ -1153,6 +1158,7 @@ declare const index_getBalanceNative: typeof getBalanceNative;
1153
1158
  declare const index_getExistentialDeposit: typeof getExistentialDeposit;
1154
1159
  declare const index_getNativeAssetSymbol: typeof getNativeAssetSymbol;
1155
1160
  declare const index_getNativeAssets: typeof getNativeAssets;
1161
+ declare const index_getOriginFeeDetails: typeof getOriginFeeDetails;
1156
1162
  declare const index_getOtherAssets: typeof getOtherAssets;
1157
1163
  declare const index_getParaId: typeof getParaId;
1158
1164
  declare const index_getRelayChainSymbol: typeof getRelayChainSymbol;
@@ -1161,7 +1167,7 @@ declare const index_getTNode: typeof getTNode;
1161
1167
  declare const index_getTransferInfo: typeof getTransferInfo;
1162
1168
  declare const index_hasSupportForAsset: typeof hasSupportForAsset;
1163
1169
  declare namespace index {
1164
- export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
1170
+ export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetBalance as getAssetBalance, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOriginFeeDetails as getOriginFeeDetails, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
1165
1171
  }
1166
1172
 
1167
1173
  /**
@@ -1514,4 +1520,4 @@ declare class DuplicateAssetIdError extends Error {
1514
1520
  constructor(id: string);
1515
1521
  }
1516
1522
 
1517
- export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
1523
+ export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetBalance, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
package/dist/index.mjs CHANGED
@@ -587,6 +587,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
587
587
  };
588
588
 
589
589
  var Polkadot$1 = {
590
+ paraId: 0,
590
591
  relayChainAssetSymbol: "DOT",
591
592
  nativeAssetSymbol: "DOT",
592
593
  nativeAssets: [
@@ -599,6 +600,7 @@ var Polkadot$1 = {
599
600
  ]
600
601
  };
601
602
  var Kusama$1 = {
603
+ paraId: 0,
602
604
  relayChainAssetSymbol: "KSM",
603
605
  nativeAssetSymbol: "KSM",
604
606
  nativeAssets: [
@@ -7662,7 +7664,6 @@ var Phala$3 = {
7662
7664
  ]
7663
7665
  };
7664
7666
  var Ethereum$1 = {
7665
- paraId: 1,
7666
7667
  relayChainAssetSymbol: "DOT",
7667
7668
  nativeAssetSymbol: "ETH",
7668
7669
  nativeAssets: [
@@ -8238,11 +8239,14 @@ var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version,
8238
8239
  return _defineProperty({}, version, isMultiLocationDestination ? destination : multiLocation);
8239
8240
  };
8240
8241
  var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(multiLocation) {
8242
+ var _a;
8241
8243
  var parachainId = findParachainJunction(multiLocation);
8242
8244
  if (parachainId === null) {
8243
8245
  throw new Error('Parachain ID not found in destination multi location.');
8244
8246
  }
8245
- var node = getTNode(parachainId);
8247
+ var node = (_a = NODE_NAMES.find(function (nodeName) {
8248
+ return getParaId(nodeName) === parachainId;
8249
+ })) !== null && _a !== void 0 ? _a : null;
8246
8250
  if (node === null) {
8247
8251
  throw new Error('Node with specified paraId not found in destination multi location.');
8248
8252
  }
@@ -11080,10 +11084,13 @@ var getParaId = function getParaId(node) {
11080
11084
  * @param paraId - The parachain ID.
11081
11085
  * @returns The node name if found; otherwise, null.
11082
11086
  */
11083
- var getTNode = function getTNode(paraId) {
11087
+ var getTNode = function getTNode(paraId, ecosystem) {
11084
11088
  var _a;
11085
- return (_a = NODE_NAMES.find(function (node) {
11086
- return getParaId(node) === paraId;
11089
+ if (paraId === 0) {
11090
+ return ecosystem === 'polkadot' ? 'Polkadot' : 'Kusama';
11091
+ }
11092
+ return (_a = NODE_NAMES_DOT_KSM.find(function (nodeName) {
11093
+ return getNode(nodeName).type === ecosystem && getParaId(nodeName) === paraId;
11087
11094
  })) !== null && _a !== void 0 ? _a : null;
11088
11095
  };
11089
11096
 
@@ -12687,6 +12694,26 @@ var EvmBuilder = function EvmBuilder(provider) {
12687
12694
  return new EvmBuilderClass(provider);
12688
12695
  };
12689
12696
 
12697
+ var calculateTransactionFee = function calculateTransactionFee(tx, address) {
12698
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12699
+ var _yield$tx$paymentInfo, partialFee;
12700
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12701
+ while (1) switch (_context.prev = _context.next) {
12702
+ case 0:
12703
+ _context.next = 2;
12704
+ return tx.paymentInfo(address);
12705
+ case 2:
12706
+ _yield$tx$paymentInfo = _context.sent;
12707
+ partialFee = _yield$tx$paymentInfo.partialFee;
12708
+ return _context.abrupt("return", partialFee.toBn());
12709
+ case 5:
12710
+ case "end":
12711
+ return _context.stop();
12712
+ }
12713
+ }, _callee);
12714
+ }));
12715
+ };
12716
+
12690
12717
  var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
12691
12718
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12692
12719
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -12721,75 +12748,58 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
12721
12748
  }, _callee);
12722
12749
  }));
12723
12750
  };
12724
- var calculateTransactionFee$1 = function calculateTransactionFee(tx, address) {
12725
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
12726
- var _yield$tx$paymentInfo, partialFee;
12727
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12728
- while (1) switch (_context2.prev = _context2.next) {
12729
- case 0:
12730
- _context2.next = 2;
12731
- return tx.paymentInfo(address);
12732
- case 2:
12733
- _yield$tx$paymentInfo = _context2.sent;
12734
- partialFee = _yield$tx$paymentInfo.partialFee;
12735
- return _context2.abrupt("return", partialFee.toBn());
12736
- case 5:
12737
- case "end":
12738
- return _context2.stop();
12739
- }
12740
- }, _callee2);
12741
- }));
12742
- };
12743
- var getOriginFeeDetails = function getOriginFeeDetails(origin, destination, currency, amount, account, api) {
12744
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
12745
- var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
12746
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
12747
- while (1) switch (_context3.prev = _context3.next) {
12748
- case 0:
12749
- _context3.next = 2;
12750
- return getBalanceNative(account, origin);
12751
- case 2:
12752
- nativeBalance = _context3.sent;
12753
- minTransferableAmount = getMinNativeTransferableAmount(origin);
12754
- if (!(api !== null && api !== void 0)) {
12755
- _context3.next = 8;
12751
+ var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
12752
+ for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
12753
+ args_1[_key - 6] = arguments[_key];
12754
+ }
12755
+ return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
12756
+ var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
12757
+ return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
12758
+ var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
12759
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12760
+ while (1) switch (_context2.prev = _context2.next) {
12761
+ case 0:
12762
+ _context2.next = 2;
12763
+ return getBalanceNative(account, origin);
12764
+ case 2:
12765
+ nativeBalance = _context2.sent;
12766
+ minTransferableAmount = getMinNativeTransferableAmount(origin);
12767
+ if (!(api !== null && api !== void 0)) {
12768
+ _context2.next = 8;
12769
+ break;
12770
+ }
12771
+ _context2.t0 = api;
12772
+ _context2.next = 11;
12756
12773
  break;
12757
- }
12758
- _context3.t0 = api;
12759
- _context3.next = 11;
12760
- break;
12761
- case 8:
12762
- _context3.next = 10;
12763
- return createApiInstanceForNode(origin);
12764
- case 10:
12765
- _context3.t0 = _context3.sent;
12766
- case 11:
12767
- apiWithFallback = _context3.t0;
12768
- _context3.next = 14;
12769
- return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
12770
- case 14:
12771
- tx = _context3.sent;
12772
- _context3.next = 17;
12773
- return calculateTransactionFee$1(tx, account);
12774
- case 17:
12775
- xcmFee = _context3.sent;
12776
- xcmFeeBigInt = BigInt(xcmFee.toString());
12777
- xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(10);
12778
- console.log('nativeBalance', nativeBalance);
12779
- console.log('minTransferableAmount', minTransferableAmount);
12780
- console.log('xcmFeeBigInt', xcmFeeBigInt);
12781
- console.log('xcmFeeWithMargin', xcmFeeWithMargin);
12782
- sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
12783
- return _context3.abrupt("return", {
12784
- sufficientForXCM: sufficientForXCM,
12785
- xcmFee: xcmFeeBigInt
12786
- });
12787
- case 26:
12788
- case "end":
12789
- return _context3.stop();
12790
- }
12791
- }, _callee3);
12792
- }));
12774
+ case 8:
12775
+ _context2.next = 10;
12776
+ return createApiInstanceForNode(origin);
12777
+ case 10:
12778
+ _context2.t0 = _context2.sent;
12779
+ case 11:
12780
+ apiWithFallback = _context2.t0;
12781
+ _context2.next = 14;
12782
+ return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
12783
+ case 14:
12784
+ tx = _context2.sent;
12785
+ _context2.next = 17;
12786
+ return calculateTransactionFee(tx, account);
12787
+ case 17:
12788
+ xcmFee = _context2.sent;
12789
+ xcmFeeBigInt = BigInt(xcmFee.toString());
12790
+ xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
12791
+ sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
12792
+ return _context2.abrupt("return", {
12793
+ sufficientForXCM: sufficientForXCM,
12794
+ xcmFee: xcmFeeBigInt
12795
+ });
12796
+ case 22:
12797
+ case "end":
12798
+ return _context2.stop();
12799
+ }
12800
+ }, _callee2);
12801
+ })();
12802
+ });
12793
12803
  };
12794
12804
 
12795
12805
  /**
@@ -12935,6 +12945,7 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
12935
12945
  var index$1 = /*#__PURE__*/Object.freeze({
12936
12946
  __proto__: null,
12937
12947
  getAllAssetsSymbols: getAllAssetsSymbols,
12948
+ getAssetBalance: getAssetBalance,
12938
12949
  getAssetDecimals: getAssetDecimals,
12939
12950
  getAssetId: getAssetId,
12940
12951
  getAssets: getAssets,
@@ -12944,6 +12955,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
12944
12955
  getExistentialDeposit: getExistentialDeposit$1,
12945
12956
  getNativeAssetSymbol: getNativeAssetSymbol,
12946
12957
  getNativeAssets: getNativeAssets,
12958
+ getOriginFeeDetails: getOriginFeeDetails,
12947
12959
  getOtherAssets: getOtherAssets,
12948
12960
  getParaId: getParaId,
12949
12961
  getRelayChainSymbol: getRelayChainSymbol,
@@ -13040,10 +13052,8 @@ var getAllNodeProviders = function getAllNodeProviders(node) {
13040
13052
 
13041
13053
  var getFees = function getFees(scenario) {
13042
13054
  if (scenario === 'ParaToRelay') {
13043
- console.log('Asigning fees for transfer to Relay chain');
13044
13055
  return 4600000000;
13045
13056
  } else if (scenario === 'ParaToPara') {
13046
- console.log('Asigning fees for transfer to another Parachain chain');
13047
13057
  return 399600000000;
13048
13058
  }
13049
13059
  throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
@@ -13220,26 +13230,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
13220
13230
  return _createClass(KeepAliveError);
13221
13231
  }(/*#__PURE__*/_wrapNativeSuper(Error));
13222
13232
 
13223
- var calculateTransactionFee = function calculateTransactionFee(tx, address) {
13224
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13225
- var _yield$tx$paymentInfo, partialFee;
13226
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13227
- while (1) switch (_context.prev = _context.next) {
13228
- case 0:
13229
- _context.next = 2;
13230
- return tx.paymentInfo(address);
13231
- case 2:
13232
- _yield$tx$paymentInfo = _context.sent;
13233
- partialFee = _yield$tx$paymentInfo.partialFee;
13234
- return _context.abrupt("return", partialFee.toBn());
13235
- case 5:
13236
- case "end":
13237
- return _context.stop();
13238
- }
13239
- }, _callee);
13240
- }));
13241
- };
13242
-
13243
13233
  var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
13244
13234
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13245
13235
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -13810,4 +13800,4 @@ var index = /*#__PURE__*/Object.freeze({
13810
13800
  transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
13811
13801
  });
13812
13802
 
13813
- export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
13803
+ export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetBalance, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "6.2.2",
3
+ "version": "6.2.4",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",