@paraspell/sdk-core 12.0.3 → 12.0.5

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.d.ts CHANGED
@@ -292,7 +292,7 @@ declare abstract class BaseAssetsPallet {
292
292
  protected palletName: TAssetsPallet;
293
293
  constructor(palletName: TAssetsPallet);
294
294
  abstract mint<TApi, TRes>(address: string, assetInfo: WithAmount<TAssetInfo>, balance: bigint, chain: TSubstrateChain, api: IPolkadotApi<TApi, TRes>): Promise<TSetBalanceRes>;
295
- abstract getBalance<TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, asset: TAssetInfo, customCurrencyId?: unknown, chain?: TSubstrateChain): Promise<bigint>;
295
+ abstract getBalance<TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, asset: TAssetInfo, customCurrencyId?: unknown): Promise<bigint>;
296
296
  }
297
297
 
298
298
  /**
@@ -608,7 +608,7 @@ type TDryRunCallBaseOptions<TRes> = {
608
608
  */
609
609
  destination: TDestination;
610
610
  /**
611
- * The address to dry-run with
611
+ * The address to dry-run with (senderAddress)
612
612
  */
613
613
  address: string;
614
614
  /**
package/dist/index.mjs CHANGED
@@ -3017,6 +3017,9 @@ var getMythosOriginFee = /*#__PURE__*/function () {
3017
3017
  }();
3018
3018
 
3019
3019
  var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
3020
+ if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
3021
+ throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
3022
+ }
3020
3023
  var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
3021
3024
  var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
3022
3025
  if (!asset && !usesRawOverriddenMultiAssets) {
@@ -6485,7 +6488,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
6485
6488
  sufficient = _context.v;
6486
6489
  return _context.a(2, {
6487
6490
  fee: paddedFee,
6488
- asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : asset,
6491
+ asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : findNativeAssetInfoOrThrow(origin),
6489
6492
  feeType: 'paymentInfo',
6490
6493
  sufficient: sufficient
6491
6494
  });
@@ -6765,7 +6768,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
6765
6768
  feeType: originFeeType
6766
6769
  }), {}, {
6767
6770
  sufficient: sufficientOriginFee,
6768
- asset: originFeeType === 'paymentInfo' ? findNativeAssetInfoOrThrow(origin) : originAsset
6771
+ asset: originAsset
6769
6772
  }, originDryRunError && {
6770
6773
  dryRunError: originDryRunError
6771
6774
  }), originDryRunSubError && {
@@ -8171,8 +8174,8 @@ var resolveBuyExecutionAmount = function resolveBuyExecutionAmount(_ref, isForFe
8171
8174
  // We have actual fees, calculate exact buy execution amount
8172
8175
  return isRelayAsset ? assetInfo.amount - hopFees : destFee;
8173
8176
  };
8174
- var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount) {
8175
- var fees = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
8177
+ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction) {
8178
+ var fees = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
8176
8179
  hopFees: 0n,
8177
8180
  destFee: 0n
8178
8181
  };
@@ -8236,21 +8239,21 @@ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc
8236
8239
  var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
8237
8240
  // If destination is a system chain, use teleport instead of reserve deposit
8238
8241
  if (isSystemChain(dest.chain)) {
8239
- return [{
8242
+ return [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
8240
8243
  InitiateTeleport: {
8241
8244
  assets: filter,
8242
8245
  dest: destLoc,
8243
8246
  xcm: [buyExecution, depositInstruction]
8244
8247
  }
8245
- }];
8248
+ }]);
8246
8249
  }
8247
- return [{
8250
+ return [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
8248
8251
  DepositReserveAsset: {
8249
8252
  assets: filter,
8250
8253
  dest: destLoc,
8251
8254
  xcm: [buyExecution, depositInstruction]
8252
8255
  }
8253
- }];
8256
+ }]);
8254
8257
  }
8255
8258
  return [depositInstruction];
8256
8259
  };
@@ -8301,18 +8304,16 @@ var constructTypeAndThenCall = function constructTypeAndThenCall(context) {
8301
8304
  senderAddress = _context$options.senderAddress,
8302
8305
  version = _context$options.version;
8303
8306
  var assetCount = isRelayAsset ? 1 : 2;
8304
- var refundInstruction = senderAddress ? createRefundInstruction(origin.api, senderAddress, version, assetCount) : null;
8305
- var finalCustomXcm = [];
8306
- if (refundInstruction && !isSubBridge) finalCustomXcm.push(refundInstruction);
8307
+ var refundInstruction = senderAddress && !isSubBridge ? createRefundInstruction(origin.api, senderAddress, version, assetCount) : null;
8307
8308
  var resolvedFees = fees !== null && fees !== void 0 ? fees : {
8308
8309
  hopFees: 0n,
8309
8310
  destFee: 0n
8310
8311
  };
8311
8312
  var isForFeeCalc = fees === null;
8312
8313
  var systemAssetAmount = resolveSystemAssetAmount(context, isForFeeCalc, resolvedFees);
8313
- finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, resolvedFees)));
8314
+ var customXcm = createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction, resolvedFees);
8314
8315
  var assets = buildAssets(origin.chain, assetInfo, systemAssetAmount, isRelayAsset, version);
8315
- return buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets);
8316
+ return buildTypeAndThenCall(context, isRelayAsset, customXcm, assets);
8316
8317
  };
8317
8318
  /**
8318
8319
  * Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
@@ -9222,7 +9223,7 @@ var Parachain = /*#__PURE__*/function () {
9222
9223
  instance = getPalletInstance(pallet);
9223
9224
  _context5.p = 4;
9224
9225
  _context5.n = 5;
9225
- return instance.getBalance(api, address, asset, customCurrencyId, this.chain);
9226
+ return instance.getBalance(api, address, asset, customCurrencyId);
9226
9227
  case 5:
9227
9228
  return _context5.a(2, _context5.v);
9228
9229
  case 6:
@@ -11647,9 +11648,31 @@ var EnergyWebX = /*#__PURE__*/function (_Parachain) {
11647
11648
  }
11648
11649
  }, {
11649
11650
  key: "getBalanceForeign",
11650
- value: function getBalanceForeign(api, address, asset) {
11651
- return getPalletInstance('Assets').getBalance(api, address, asset, this.chain);
11652
- }
11651
+ value: function () {
11652
+ var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
11653
+ var _balance$balance;
11654
+ var balance;
11655
+ return _regenerator().w(function (_context) {
11656
+ while (1) switch (_context.n) {
11657
+ case 0:
11658
+ assertHasLocation(asset);
11659
+ _context.n = 1;
11660
+ return api.queryState({
11661
+ module: 'Assets',
11662
+ method: 'Account',
11663
+ params: [asset.location, address]
11664
+ });
11665
+ case 1:
11666
+ balance = _context.v;
11667
+ return _context.a(2, (_balance$balance = balance === null || balance === void 0 ? void 0 : balance.balance) !== null && _balance$balance !== void 0 ? _balance$balance : 0n);
11668
+ }
11669
+ }, _callee);
11670
+ }));
11671
+ function getBalanceForeign(_x, _x2, _x3) {
11672
+ return _getBalanceForeign.apply(this, arguments);
11673
+ }
11674
+ return getBalanceForeign;
11675
+ }()
11653
11676
  }]);
11654
11677
  }(Parachain);
11655
11678
 
@@ -13539,22 +13562,21 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
13539
13562
  }, {
13540
13563
  key: "getBalance",
13541
13564
  value: function () {
13542
- var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset, chain) {
13565
+ var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
13543
13566
  var _this = this,
13544
13567
  _balance$balance,
13545
13568
  _balance2;
13546
- var isEnergyWebX, fetchBalance, balance, _t;
13569
+ var fetchBalance, balance, _t;
13547
13570
  return _regenerator().w(function (_context) {
13548
13571
  while (1) switch (_context.p = _context.n) {
13549
13572
  case 0:
13550
13573
  assertHasId(asset);
13551
- isEnergyWebX = chain === 'EnergyWebX';
13552
13574
  fetchBalance = function fetchBalance() {
13553
13575
  var useBigInt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13554
13576
  return api.queryState({
13555
13577
  module: _this.palletName,
13556
13578
  method: 'Account',
13557
- params: [isEnergyWebX ? asset.location : useBigInt ? BigInt(asset.assetId) : Number(asset.assetId), address]
13579
+ params: [useBigInt ? BigInt(asset.assetId) : Number(asset.assetId), address]
13558
13580
  });
13559
13581
  }; // Try with number ID first, if it fails, try with bigint ID
13560
13582
  _context.p = 1;
@@ -13584,7 +13606,7 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
13584
13606
  }
13585
13607
  }, _callee, null, [[1, 3]]);
13586
13608
  }));
13587
- function getBalance(_x, _x2, _x3, _x4) {
13609
+ function getBalance(_x, _x2, _x3) {
13588
13610
  return _getBalance.apply(this, arguments);
13589
13611
  }
13590
13612
  return getBalance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "12.0.3",
3
+ "version": "12.0.5",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^2.0.1",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "^2.40.3",
29
- "@paraspell/assets": "12.0.3",
30
- "@paraspell/pallets": "12.0.3",
31
- "@paraspell/sdk-common": "12.0.3"
29
+ "@paraspell/pallets": "12.0.5",
30
+ "@paraspell/sdk-common": "12.0.5",
31
+ "@paraspell/assets": "12.0.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",