@paraspell/sdk 7.2.9 → 7.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16751,44 +16751,56 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
16751
16751
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16752
16752
  while (1) switch (_context.prev = _context.next) {
16753
16753
  case 0:
16754
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
16755
+ _context.next = 4;
16756
+ break;
16757
+ }
16758
+ if (!(!isForeignAsset(asset) || !asset.assetId)) {
16759
+ _context.next = 3;
16760
+ break;
16761
+ }
16762
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16763
+ case 3:
16764
+ return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
16765
+ case 4:
16754
16766
  if (!(node === 'Mythos')) {
16755
- _context.next = 2;
16767
+ _context.next = 6;
16756
16768
  break;
16757
16769
  }
16758
16770
  return _context.abrupt("return", api.getMythosForeignBalance(address));
16759
- case 2:
16771
+ case 6:
16760
16772
  if (isForeignAsset(asset)) {
16761
- _context.next = 4;
16773
+ _context.next = 8;
16762
16774
  break;
16763
16775
  }
16764
16776
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
16765
- case 4:
16777
+ case 8:
16766
16778
  if (!(node === 'Polimec')) {
16767
- _context.next = 8;
16779
+ _context.next = 12;
16768
16780
  break;
16769
16781
  }
16770
16782
  if (!(asset.assetId === undefined)) {
16771
- _context.next = 7;
16783
+ _context.next = 11;
16772
16784
  break;
16773
16785
  }
16774
16786
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16775
- case 7:
16787
+ case 11:
16776
16788
  return _context.abrupt("return", api.getForeignAssetsByIdBalance(address, asset.assetId));
16777
- case 8:
16789
+ case 12:
16778
16790
  if (!(node === 'AssetHubPolkadot')) {
16779
- _context.next = 14;
16791
+ _context.next = 18;
16780
16792
  break;
16781
16793
  }
16782
16794
  if (!asset.multiLocation) {
16783
- _context.next = 13;
16795
+ _context.next = 17;
16784
16796
  break;
16785
16797
  }
16786
16798
  return _context.abrupt("return", api.getAssetHubForeignBalance(address, asset.multiLocation));
16787
- case 13:
16799
+ case 17:
16788
16800
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, Number(asset.assetId)));
16789
- case 14:
16801
+ case 18:
16790
16802
  return _context.abrupt("return", api.getBalanceForeignPolkadotXcm(address, asset.assetId));
16791
- case 15:
16803
+ case 19:
16792
16804
  case "end":
16793
16805
  return _context.stop();
16794
16806
  }
@@ -16801,7 +16813,7 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
16801
16813
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16802
16814
  while (1) switch (_context.prev = _context.next) {
16803
16815
  case 0:
16804
- if (!(node === 'Moonbeam' || node === 'Moonriver' || node === 'Astar' || node === 'Shiden')) {
16816
+ if (!(node === 'Astar' || node === 'Shiden')) {
16805
16817
  _context.next = 4;
16806
16818
  break;
16807
16819
  }
@@ -18307,7 +18319,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18307
18319
  amount = _ref.amount,
18308
18320
  api = _ref.api;
18309
18321
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18310
- var _b, _c, _d, _e, _f, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18322
+ var _b, _c, _d, _e, _f, destApi, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18311
18323
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18312
18324
  while (1) switch (_context.prev = _context.next) {
18313
18325
  case 0:
@@ -18315,16 +18327,21 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18315
18327
  return api.init(origin);
18316
18328
  case 2:
18317
18329
  api.setDisconnectAllowed(false);
18318
- _context.prev = 3;
18330
+ destApi = api.clone();
18319
18331
  _context.next = 6;
18332
+ return destApi.init(destination);
18333
+ case 6:
18334
+ destApi.setDisconnectAllowed(false);
18335
+ _context.prev = 7;
18336
+ _context.next = 10;
18320
18337
  return getBalanceNativeInternal({
18321
18338
  address: accountOrigin,
18322
18339
  node: origin,
18323
18340
  api: api
18324
18341
  });
18325
- case 6:
18342
+ case 10:
18326
18343
  originBalance = _context.sent;
18327
- _context.next = 9;
18344
+ _context.next = 13;
18328
18345
  return getOriginFeeDetailsInternal({
18329
18346
  origin: origin,
18330
18347
  destination: destination,
@@ -18334,29 +18351,29 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18334
18351
  accountDestination: accountDestination,
18335
18352
  api: api
18336
18353
  });
18337
- case 9:
18354
+ case 13:
18338
18355
  xcmFeeDetails = _context.sent;
18339
18356
  expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
18340
18357
  asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
18341
18358
  if (asset) {
18342
- _context.next = 14;
18359
+ _context.next = 18;
18343
18360
  break;
18344
18361
  }
18345
18362
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
18346
- case 14:
18363
+ case 18:
18347
18364
  _context.t0 = {
18348
18365
  origin: origin,
18349
18366
  destination: destination,
18350
- ecosystem: determineRelayChainSymbol(origin)
18367
+ ecosystem: getRelayChainSymbol(origin)
18351
18368
  };
18352
- _context.next = 17;
18369
+ _context.next = 21;
18353
18370
  return getAssetBalanceInternal({
18354
18371
  api: api,
18355
18372
  address: accountOrigin,
18356
18373
  node: origin,
18357
18374
  currency: currency
18358
18375
  });
18359
- case 17:
18376
+ case 21:
18360
18377
  _context.t1 = _context.sent;
18361
18378
  _context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
18362
18379
  _context.t3 = {
@@ -18369,13 +18386,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18369
18386
  _context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
18370
18387
  _context.t8 = getNativeAssetSymbol(origin);
18371
18388
  _context.t9 = BigInt((_e = getExistentialDeposit(origin)) !== null && _e !== void 0 ? _e : '0');
18372
- _context.next = 28;
18389
+ _context.next = 32;
18373
18390
  return getMaxNativeTransferableAmount$1({
18374
18391
  api: api,
18375
18392
  address: accountOrigin,
18376
18393
  node: origin
18377
18394
  });
18378
- case 28:
18395
+ case 32:
18379
18396
  _context.t10 = _context.sent;
18380
18397
  _context.t11 = {
18381
18398
  balance: _context.t4,
@@ -18386,13 +18403,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18386
18403
  minNativeTransferableAmount: _context.t9,
18387
18404
  maxNativeTransferableAmount: _context.t10
18388
18405
  };
18389
- _context.next = 32;
18406
+ _context.next = 36;
18390
18407
  return getBalanceNativeInternal({
18391
18408
  address: accountDestination,
18392
18409
  node: destination,
18393
- api: api
18410
+ api: destApi
18394
18411
  });
18395
- case 32:
18412
+ case 36:
18396
18413
  _context.t12 = _context.sent;
18397
18414
  _context.t13 = getNativeAssetSymbol(destination);
18398
18415
  _context.t14 = BigInt((_f = getExistentialDeposit(destination)) !== null && _f !== void 0 ? _f : '0');
@@ -18407,18 +18424,22 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18407
18424
  originFeeBalance: _context.t11,
18408
18425
  destinationFeeBalance: _context.t15
18409
18426
  });
18410
- case 37:
18411
- _context.prev = 37;
18427
+ case 41:
18428
+ _context.prev = 41;
18429
+ api.setDisconnectAllowed(true);
18412
18430
  api.setDisconnectAllowed(true);
18413
- _context.next = 41;
18431
+ _context.next = 46;
18414
18432
  return api.disconnect();
18415
- case 41:
18416
- return _context.finish(37);
18417
- case 42:
18433
+ case 46:
18434
+ _context.next = 48;
18435
+ return destApi.disconnect();
18436
+ case 48:
18437
+ return _context.finish(41);
18438
+ case 49:
18418
18439
  case "end":
18419
18440
  return _context.stop();
18420
18441
  }
18421
- }, _callee, null, [[3,, 37, 42]]);
18442
+ }, _callee, null, [[7,, 41, 49]]);
18422
18443
  })();
18423
18444
  });
18424
18445
  };
@@ -18595,16 +18616,6 @@ var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
18595
18616
  }));
18596
18617
  };
18597
18618
 
18598
- var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
18599
- if (node === 'Polkadot') {
18600
- return 'DOT';
18601
- } else if (node === 'Kusama') {
18602
- return 'KSM';
18603
- } else {
18604
- return getRelayChainSymbol(node);
18605
- }
18606
- };
18607
-
18608
18619
  // Contains important call creation utils (Selection of fees,formating of header and more.. )
18609
18620
  /**
18610
18621
  * Determines the relay chain for a given node.
package/dist/index.mjs CHANGED
@@ -16749,44 +16749,56 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
16749
16749
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16750
16750
  while (1) switch (_context.prev = _context.next) {
16751
16751
  case 0:
16752
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
16753
+ _context.next = 4;
16754
+ break;
16755
+ }
16756
+ if (!(!isForeignAsset(asset) || !asset.assetId)) {
16757
+ _context.next = 3;
16758
+ break;
16759
+ }
16760
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16761
+ case 3:
16762
+ return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
16763
+ case 4:
16752
16764
  if (!(node === 'Mythos')) {
16753
- _context.next = 2;
16765
+ _context.next = 6;
16754
16766
  break;
16755
16767
  }
16756
16768
  return _context.abrupt("return", api.getMythosForeignBalance(address));
16757
- case 2:
16769
+ case 6:
16758
16770
  if (isForeignAsset(asset)) {
16759
- _context.next = 4;
16771
+ _context.next = 8;
16760
16772
  break;
16761
16773
  }
16762
16774
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
16763
- case 4:
16775
+ case 8:
16764
16776
  if (!(node === 'Polimec')) {
16765
- _context.next = 8;
16777
+ _context.next = 12;
16766
16778
  break;
16767
16779
  }
16768
16780
  if (!(asset.assetId === undefined)) {
16769
- _context.next = 7;
16781
+ _context.next = 11;
16770
16782
  break;
16771
16783
  }
16772
16784
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16773
- case 7:
16785
+ case 11:
16774
16786
  return _context.abrupt("return", api.getForeignAssetsByIdBalance(address, asset.assetId));
16775
- case 8:
16787
+ case 12:
16776
16788
  if (!(node === 'AssetHubPolkadot')) {
16777
- _context.next = 14;
16789
+ _context.next = 18;
16778
16790
  break;
16779
16791
  }
16780
16792
  if (!asset.multiLocation) {
16781
- _context.next = 13;
16793
+ _context.next = 17;
16782
16794
  break;
16783
16795
  }
16784
16796
  return _context.abrupt("return", api.getAssetHubForeignBalance(address, asset.multiLocation));
16785
- case 13:
16797
+ case 17:
16786
16798
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, Number(asset.assetId)));
16787
- case 14:
16799
+ case 18:
16788
16800
  return _context.abrupt("return", api.getBalanceForeignPolkadotXcm(address, asset.assetId));
16789
- case 15:
16801
+ case 19:
16790
16802
  case "end":
16791
16803
  return _context.stop();
16792
16804
  }
@@ -16799,7 +16811,7 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
16799
16811
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16800
16812
  while (1) switch (_context.prev = _context.next) {
16801
16813
  case 0:
16802
- if (!(node === 'Moonbeam' || node === 'Moonriver' || node === 'Astar' || node === 'Shiden')) {
16814
+ if (!(node === 'Astar' || node === 'Shiden')) {
16803
16815
  _context.next = 4;
16804
16816
  break;
16805
16817
  }
@@ -18305,7 +18317,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18305
18317
  amount = _ref.amount,
18306
18318
  api = _ref.api;
18307
18319
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18308
- var _b, _c, _d, _e, _f, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18320
+ var _b, _c, _d, _e, _f, destApi, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18309
18321
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18310
18322
  while (1) switch (_context.prev = _context.next) {
18311
18323
  case 0:
@@ -18313,16 +18325,21 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18313
18325
  return api.init(origin);
18314
18326
  case 2:
18315
18327
  api.setDisconnectAllowed(false);
18316
- _context.prev = 3;
18328
+ destApi = api.clone();
18317
18329
  _context.next = 6;
18330
+ return destApi.init(destination);
18331
+ case 6:
18332
+ destApi.setDisconnectAllowed(false);
18333
+ _context.prev = 7;
18334
+ _context.next = 10;
18318
18335
  return getBalanceNativeInternal({
18319
18336
  address: accountOrigin,
18320
18337
  node: origin,
18321
18338
  api: api
18322
18339
  });
18323
- case 6:
18340
+ case 10:
18324
18341
  originBalance = _context.sent;
18325
- _context.next = 9;
18342
+ _context.next = 13;
18326
18343
  return getOriginFeeDetailsInternal({
18327
18344
  origin: origin,
18328
18345
  destination: destination,
@@ -18332,29 +18349,29 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18332
18349
  accountDestination: accountDestination,
18333
18350
  api: api
18334
18351
  });
18335
- case 9:
18352
+ case 13:
18336
18353
  xcmFeeDetails = _context.sent;
18337
18354
  expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
18338
18355
  asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
18339
18356
  if (asset) {
18340
- _context.next = 14;
18357
+ _context.next = 18;
18341
18358
  break;
18342
18359
  }
18343
18360
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
18344
- case 14:
18361
+ case 18:
18345
18362
  _context.t0 = {
18346
18363
  origin: origin,
18347
18364
  destination: destination,
18348
- ecosystem: determineRelayChainSymbol(origin)
18365
+ ecosystem: getRelayChainSymbol(origin)
18349
18366
  };
18350
- _context.next = 17;
18367
+ _context.next = 21;
18351
18368
  return getAssetBalanceInternal({
18352
18369
  api: api,
18353
18370
  address: accountOrigin,
18354
18371
  node: origin,
18355
18372
  currency: currency
18356
18373
  });
18357
- case 17:
18374
+ case 21:
18358
18375
  _context.t1 = _context.sent;
18359
18376
  _context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
18360
18377
  _context.t3 = {
@@ -18367,13 +18384,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18367
18384
  _context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
18368
18385
  _context.t8 = getNativeAssetSymbol(origin);
18369
18386
  _context.t9 = BigInt((_e = getExistentialDeposit(origin)) !== null && _e !== void 0 ? _e : '0');
18370
- _context.next = 28;
18387
+ _context.next = 32;
18371
18388
  return getMaxNativeTransferableAmount$1({
18372
18389
  api: api,
18373
18390
  address: accountOrigin,
18374
18391
  node: origin
18375
18392
  });
18376
- case 28:
18393
+ case 32:
18377
18394
  _context.t10 = _context.sent;
18378
18395
  _context.t11 = {
18379
18396
  balance: _context.t4,
@@ -18384,13 +18401,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18384
18401
  minNativeTransferableAmount: _context.t9,
18385
18402
  maxNativeTransferableAmount: _context.t10
18386
18403
  };
18387
- _context.next = 32;
18404
+ _context.next = 36;
18388
18405
  return getBalanceNativeInternal({
18389
18406
  address: accountDestination,
18390
18407
  node: destination,
18391
- api: api
18408
+ api: destApi
18392
18409
  });
18393
- case 32:
18410
+ case 36:
18394
18411
  _context.t12 = _context.sent;
18395
18412
  _context.t13 = getNativeAssetSymbol(destination);
18396
18413
  _context.t14 = BigInt((_f = getExistentialDeposit(destination)) !== null && _f !== void 0 ? _f : '0');
@@ -18405,18 +18422,22 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18405
18422
  originFeeBalance: _context.t11,
18406
18423
  destinationFeeBalance: _context.t15
18407
18424
  });
18408
- case 37:
18409
- _context.prev = 37;
18425
+ case 41:
18426
+ _context.prev = 41;
18427
+ api.setDisconnectAllowed(true);
18410
18428
  api.setDisconnectAllowed(true);
18411
- _context.next = 41;
18429
+ _context.next = 46;
18412
18430
  return api.disconnect();
18413
- case 41:
18414
- return _context.finish(37);
18415
- case 42:
18431
+ case 46:
18432
+ _context.next = 48;
18433
+ return destApi.disconnect();
18434
+ case 48:
18435
+ return _context.finish(41);
18436
+ case 49:
18416
18437
  case "end":
18417
18438
  return _context.stop();
18418
18439
  }
18419
- }, _callee, null, [[3,, 37, 42]]);
18440
+ }, _callee, null, [[7,, 41, 49]]);
18420
18441
  })();
18421
18442
  });
18422
18443
  };
@@ -18593,16 +18614,6 @@ var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
18593
18614
  }));
18594
18615
  };
18595
18616
 
18596
- var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
18597
- if (node === 'Polkadot') {
18598
- return 'DOT';
18599
- } else if (node === 'Kusama') {
18600
- return 'KSM';
18601
- } else {
18602
- return getRelayChainSymbol(node);
18603
- }
18604
- };
18605
-
18606
18617
  // Contains important call creation utils (Selection of fees,formating of header and more.. )
18607
18618
  /**
18608
18619
  * Determines the relay chain for a given node.
@@ -16751,44 +16751,56 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
16751
16751
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16752
16752
  while (1) switch (_context.prev = _context.next) {
16753
16753
  case 0:
16754
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
16755
+ _context.next = 4;
16756
+ break;
16757
+ }
16758
+ if (!(!isForeignAsset(asset) || !asset.assetId)) {
16759
+ _context.next = 3;
16760
+ break;
16761
+ }
16762
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16763
+ case 3:
16764
+ return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
16765
+ case 4:
16754
16766
  if (!(node === 'Mythos')) {
16755
- _context.next = 2;
16767
+ _context.next = 6;
16756
16768
  break;
16757
16769
  }
16758
16770
  return _context.abrupt("return", api.getMythosForeignBalance(address));
16759
- case 2:
16771
+ case 6:
16760
16772
  if (isForeignAsset(asset)) {
16761
- _context.next = 4;
16773
+ _context.next = 8;
16762
16774
  break;
16763
16775
  }
16764
16776
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
16765
- case 4:
16777
+ case 8:
16766
16778
  if (!(node === 'Polimec')) {
16767
- _context.next = 8;
16779
+ _context.next = 12;
16768
16780
  break;
16769
16781
  }
16770
16782
  if (!(asset.assetId === undefined)) {
16771
- _context.next = 7;
16783
+ _context.next = 11;
16772
16784
  break;
16773
16785
  }
16774
16786
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16775
- case 7:
16787
+ case 11:
16776
16788
  return _context.abrupt("return", api.getForeignAssetsByIdBalance(address, asset.assetId));
16777
- case 8:
16789
+ case 12:
16778
16790
  if (!(node === 'AssetHubPolkadot')) {
16779
- _context.next = 14;
16791
+ _context.next = 18;
16780
16792
  break;
16781
16793
  }
16782
16794
  if (!asset.multiLocation) {
16783
- _context.next = 13;
16795
+ _context.next = 17;
16784
16796
  break;
16785
16797
  }
16786
16798
  return _context.abrupt("return", api.getAssetHubForeignBalance(address, asset.multiLocation));
16787
- case 13:
16799
+ case 17:
16788
16800
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, Number(asset.assetId)));
16789
- case 14:
16801
+ case 18:
16790
16802
  return _context.abrupt("return", api.getBalanceForeignPolkadotXcm(address, asset.assetId));
16791
- case 15:
16803
+ case 19:
16792
16804
  case "end":
16793
16805
  return _context.stop();
16794
16806
  }
@@ -16801,7 +16813,7 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
16801
16813
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16802
16814
  while (1) switch (_context.prev = _context.next) {
16803
16815
  case 0:
16804
- if (!(node === 'Moonbeam' || node === 'Moonriver' || node === 'Astar' || node === 'Shiden')) {
16816
+ if (!(node === 'Astar' || node === 'Shiden')) {
16805
16817
  _context.next = 4;
16806
16818
  break;
16807
16819
  }
@@ -18307,7 +18319,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18307
18319
  amount = _ref.amount,
18308
18320
  api = _ref.api;
18309
18321
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18310
- var _b, _c, _d, _e, _f, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18322
+ var _b, _c, _d, _e, _f, destApi, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18311
18323
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18312
18324
  while (1) switch (_context.prev = _context.next) {
18313
18325
  case 0:
@@ -18315,16 +18327,21 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18315
18327
  return api.init(origin);
18316
18328
  case 2:
18317
18329
  api.setDisconnectAllowed(false);
18318
- _context.prev = 3;
18330
+ destApi = api.clone();
18319
18331
  _context.next = 6;
18332
+ return destApi.init(destination);
18333
+ case 6:
18334
+ destApi.setDisconnectAllowed(false);
18335
+ _context.prev = 7;
18336
+ _context.next = 10;
18320
18337
  return getBalanceNativeInternal({
18321
18338
  address: accountOrigin,
18322
18339
  node: origin,
18323
18340
  api: api
18324
18341
  });
18325
- case 6:
18342
+ case 10:
18326
18343
  originBalance = _context.sent;
18327
- _context.next = 9;
18344
+ _context.next = 13;
18328
18345
  return getOriginFeeDetailsInternal({
18329
18346
  origin: origin,
18330
18347
  destination: destination,
@@ -18334,29 +18351,29 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18334
18351
  accountDestination: accountDestination,
18335
18352
  api: api
18336
18353
  });
18337
- case 9:
18354
+ case 13:
18338
18355
  xcmFeeDetails = _context.sent;
18339
18356
  expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
18340
18357
  asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
18341
18358
  if (asset) {
18342
- _context.next = 14;
18359
+ _context.next = 18;
18343
18360
  break;
18344
18361
  }
18345
18362
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
18346
- case 14:
18363
+ case 18:
18347
18364
  _context.t0 = {
18348
18365
  origin: origin,
18349
18366
  destination: destination,
18350
- ecosystem: determineRelayChainSymbol(origin)
18367
+ ecosystem: getRelayChainSymbol(origin)
18351
18368
  };
18352
- _context.next = 17;
18369
+ _context.next = 21;
18353
18370
  return getAssetBalanceInternal({
18354
18371
  api: api,
18355
18372
  address: accountOrigin,
18356
18373
  node: origin,
18357
18374
  currency: currency
18358
18375
  });
18359
- case 17:
18376
+ case 21:
18360
18377
  _context.t1 = _context.sent;
18361
18378
  _context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
18362
18379
  _context.t3 = {
@@ -18369,13 +18386,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18369
18386
  _context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
18370
18387
  _context.t8 = getNativeAssetSymbol(origin);
18371
18388
  _context.t9 = BigInt((_e = getExistentialDeposit(origin)) !== null && _e !== void 0 ? _e : '0');
18372
- _context.next = 28;
18389
+ _context.next = 32;
18373
18390
  return getMaxNativeTransferableAmount$1({
18374
18391
  api: api,
18375
18392
  address: accountOrigin,
18376
18393
  node: origin
18377
18394
  });
18378
- case 28:
18395
+ case 32:
18379
18396
  _context.t10 = _context.sent;
18380
18397
  _context.t11 = {
18381
18398
  balance: _context.t4,
@@ -18386,13 +18403,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18386
18403
  minNativeTransferableAmount: _context.t9,
18387
18404
  maxNativeTransferableAmount: _context.t10
18388
18405
  };
18389
- _context.next = 32;
18406
+ _context.next = 36;
18390
18407
  return getBalanceNativeInternal({
18391
18408
  address: accountDestination,
18392
18409
  node: destination,
18393
- api: api
18410
+ api: destApi
18394
18411
  });
18395
- case 32:
18412
+ case 36:
18396
18413
  _context.t12 = _context.sent;
18397
18414
  _context.t13 = getNativeAssetSymbol(destination);
18398
18415
  _context.t14 = BigInt((_f = getExistentialDeposit(destination)) !== null && _f !== void 0 ? _f : '0');
@@ -18407,18 +18424,22 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18407
18424
  originFeeBalance: _context.t11,
18408
18425
  destinationFeeBalance: _context.t15
18409
18426
  });
18410
- case 37:
18411
- _context.prev = 37;
18427
+ case 41:
18428
+ _context.prev = 41;
18429
+ api.setDisconnectAllowed(true);
18412
18430
  api.setDisconnectAllowed(true);
18413
- _context.next = 41;
18431
+ _context.next = 46;
18414
18432
  return api.disconnect();
18415
- case 41:
18416
- return _context.finish(37);
18417
- case 42:
18433
+ case 46:
18434
+ _context.next = 48;
18435
+ return destApi.disconnect();
18436
+ case 48:
18437
+ return _context.finish(41);
18438
+ case 49:
18418
18439
  case "end":
18419
18440
  return _context.stop();
18420
18441
  }
18421
- }, _callee, null, [[3,, 37, 42]]);
18442
+ }, _callee, null, [[7,, 41, 49]]);
18422
18443
  })();
18423
18444
  });
18424
18445
  };
@@ -18595,16 +18616,6 @@ var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
18595
18616
  }));
18596
18617
  };
18597
18618
 
18598
- var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
18599
- if (node === 'Polkadot') {
18600
- return 'DOT';
18601
- } else if (node === 'Kusama') {
18602
- return 'KSM';
18603
- } else {
18604
- return getRelayChainSymbol(node);
18605
- }
18606
- };
18607
-
18608
18619
  // Contains important call creation utils (Selection of fees,formating of header and more.. )
18609
18620
  /**
18610
18621
  * Determines the relay chain for a given node.
@@ -16749,44 +16749,56 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
16749
16749
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16750
16750
  while (1) switch (_context.prev = _context.next) {
16751
16751
  case 0:
16752
+ if (!(node === 'Moonbeam' || node === 'Moonriver')) {
16753
+ _context.next = 4;
16754
+ break;
16755
+ }
16756
+ if (!(!isForeignAsset(asset) || !asset.assetId)) {
16757
+ _context.next = 3;
16758
+ break;
16759
+ }
16760
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16761
+ case 3:
16762
+ return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
16763
+ case 4:
16752
16764
  if (!(node === 'Mythos')) {
16753
- _context.next = 2;
16765
+ _context.next = 6;
16754
16766
  break;
16755
16767
  }
16756
16768
  return _context.abrupt("return", api.getMythosForeignBalance(address));
16757
- case 2:
16769
+ case 6:
16758
16770
  if (isForeignAsset(asset)) {
16759
- _context.next = 4;
16771
+ _context.next = 8;
16760
16772
  break;
16761
16773
  }
16762
16774
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
16763
- case 4:
16775
+ case 8:
16764
16776
  if (!(node === 'Polimec')) {
16765
- _context.next = 8;
16777
+ _context.next = 12;
16766
16778
  break;
16767
16779
  }
16768
16780
  if (!(asset.assetId === undefined)) {
16769
- _context.next = 7;
16781
+ _context.next = 11;
16770
16782
  break;
16771
16783
  }
16772
16784
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
16773
- case 7:
16785
+ case 11:
16774
16786
  return _context.abrupt("return", api.getForeignAssetsByIdBalance(address, asset.assetId));
16775
- case 8:
16787
+ case 12:
16776
16788
  if (!(node === 'AssetHubPolkadot')) {
16777
- _context.next = 14;
16789
+ _context.next = 18;
16778
16790
  break;
16779
16791
  }
16780
16792
  if (!asset.multiLocation) {
16781
- _context.next = 13;
16793
+ _context.next = 17;
16782
16794
  break;
16783
16795
  }
16784
16796
  return _context.abrupt("return", api.getAssetHubForeignBalance(address, asset.multiLocation));
16785
- case 13:
16797
+ case 17:
16786
16798
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, Number(asset.assetId)));
16787
- case 14:
16799
+ case 18:
16788
16800
  return _context.abrupt("return", api.getBalanceForeignPolkadotXcm(address, asset.assetId));
16789
- case 15:
16801
+ case 19:
16790
16802
  case "end":
16791
16803
  return _context.stop();
16792
16804
  }
@@ -16799,7 +16811,7 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
16799
16811
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16800
16812
  while (1) switch (_context.prev = _context.next) {
16801
16813
  case 0:
16802
- if (!(node === 'Moonbeam' || node === 'Moonriver' || node === 'Astar' || node === 'Shiden')) {
16814
+ if (!(node === 'Astar' || node === 'Shiden')) {
16803
16815
  _context.next = 4;
16804
16816
  break;
16805
16817
  }
@@ -18305,7 +18317,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18305
18317
  amount = _ref.amount,
18306
18318
  api = _ref.api;
18307
18319
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18308
- var _b, _c, _d, _e, _f, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18320
+ var _b, _c, _d, _e, _f, destApi, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
18309
18321
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18310
18322
  while (1) switch (_context.prev = _context.next) {
18311
18323
  case 0:
@@ -18313,16 +18325,21 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18313
18325
  return api.init(origin);
18314
18326
  case 2:
18315
18327
  api.setDisconnectAllowed(false);
18316
- _context.prev = 3;
18328
+ destApi = api.clone();
18317
18329
  _context.next = 6;
18330
+ return destApi.init(destination);
18331
+ case 6:
18332
+ destApi.setDisconnectAllowed(false);
18333
+ _context.prev = 7;
18334
+ _context.next = 10;
18318
18335
  return getBalanceNativeInternal({
18319
18336
  address: accountOrigin,
18320
18337
  node: origin,
18321
18338
  api: api
18322
18339
  });
18323
- case 6:
18340
+ case 10:
18324
18341
  originBalance = _context.sent;
18325
- _context.next = 9;
18342
+ _context.next = 13;
18326
18343
  return getOriginFeeDetailsInternal({
18327
18344
  origin: origin,
18328
18345
  destination: destination,
@@ -18332,29 +18349,29 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18332
18349
  accountDestination: accountDestination,
18333
18350
  api: api
18334
18351
  });
18335
- case 9:
18352
+ case 13:
18336
18353
  xcmFeeDetails = _context.sent;
18337
18354
  expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
18338
18355
  asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
18339
18356
  if (asset) {
18340
- _context.next = 14;
18357
+ _context.next = 18;
18341
18358
  break;
18342
18359
  }
18343
18360
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
18344
- case 14:
18361
+ case 18:
18345
18362
  _context.t0 = {
18346
18363
  origin: origin,
18347
18364
  destination: destination,
18348
- ecosystem: determineRelayChainSymbol(origin)
18365
+ ecosystem: getRelayChainSymbol(origin)
18349
18366
  };
18350
- _context.next = 17;
18367
+ _context.next = 21;
18351
18368
  return getAssetBalanceInternal({
18352
18369
  api: api,
18353
18370
  address: accountOrigin,
18354
18371
  node: origin,
18355
18372
  currency: currency
18356
18373
  });
18357
- case 17:
18374
+ case 21:
18358
18375
  _context.t1 = _context.sent;
18359
18376
  _context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
18360
18377
  _context.t3 = {
@@ -18367,13 +18384,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18367
18384
  _context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
18368
18385
  _context.t8 = getNativeAssetSymbol(origin);
18369
18386
  _context.t9 = BigInt((_e = getExistentialDeposit(origin)) !== null && _e !== void 0 ? _e : '0');
18370
- _context.next = 28;
18387
+ _context.next = 32;
18371
18388
  return getMaxNativeTransferableAmount$1({
18372
18389
  api: api,
18373
18390
  address: accountOrigin,
18374
18391
  node: origin
18375
18392
  });
18376
- case 28:
18393
+ case 32:
18377
18394
  _context.t10 = _context.sent;
18378
18395
  _context.t11 = {
18379
18396
  balance: _context.t4,
@@ -18384,13 +18401,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18384
18401
  minNativeTransferableAmount: _context.t9,
18385
18402
  maxNativeTransferableAmount: _context.t10
18386
18403
  };
18387
- _context.next = 32;
18404
+ _context.next = 36;
18388
18405
  return getBalanceNativeInternal({
18389
18406
  address: accountDestination,
18390
18407
  node: destination,
18391
- api: api
18408
+ api: destApi
18392
18409
  });
18393
- case 32:
18410
+ case 36:
18394
18411
  _context.t12 = _context.sent;
18395
18412
  _context.t13 = getNativeAssetSymbol(destination);
18396
18413
  _context.t14 = BigInt((_f = getExistentialDeposit(destination)) !== null && _f !== void 0 ? _f : '0');
@@ -18405,18 +18422,22 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
18405
18422
  originFeeBalance: _context.t11,
18406
18423
  destinationFeeBalance: _context.t15
18407
18424
  });
18408
- case 37:
18409
- _context.prev = 37;
18425
+ case 41:
18426
+ _context.prev = 41;
18427
+ api.setDisconnectAllowed(true);
18410
18428
  api.setDisconnectAllowed(true);
18411
- _context.next = 41;
18429
+ _context.next = 46;
18412
18430
  return api.disconnect();
18413
- case 41:
18414
- return _context.finish(37);
18415
- case 42:
18431
+ case 46:
18432
+ _context.next = 48;
18433
+ return destApi.disconnect();
18434
+ case 48:
18435
+ return _context.finish(41);
18436
+ case 49:
18416
18437
  case "end":
18417
18438
  return _context.stop();
18418
18439
  }
18419
- }, _callee, null, [[3,, 37, 42]]);
18440
+ }, _callee, null, [[7,, 41, 49]]);
18420
18441
  })();
18421
18442
  });
18422
18443
  };
@@ -18593,16 +18614,6 @@ var createApiInstanceForNode$1 = function createApiInstanceForNode(api, node) {
18593
18614
  }));
18594
18615
  };
18595
18616
 
18596
- var determineRelayChainSymbol = function determineRelayChainSymbol(node) {
18597
- if (node === 'Polkadot') {
18598
- return 'DOT';
18599
- } else if (node === 'Kusama') {
18600
- return 'KSM';
18601
- } else {
18602
- return getRelayChainSymbol(node);
18603
- }
18604
- };
18605
-
18606
18617
  // Contains important call creation utils (Selection of fees,formating of header and more.. )
18607
18618
  /**
18608
18619
  * Determines the relay chain for a given node.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "7.2.9",
3
+ "version": "7.2.10",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",