@paraspell/sdk-core 12.0.4 → 12.0.6

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
  /**
@@ -1811,7 +1811,6 @@ declare class HeimaPaseo<TApi, TRes> extends Heima<TApi, TRes> {
1811
1811
  }
1812
1812
 
1813
1813
  declare class Hydration<TApi, TRes> extends Parachain<TApi, TRes> implements IXTokensTransfer, IPolkadotXCMTransfer {
1814
- private static NATIVE_ASSET_ID;
1815
1814
  constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
1816
1815
  transferPolkadotXCM<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): Promise<TRes>;
1817
1816
  transferMoonbeamWhAsset<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
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,25 +8239,44 @@ 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
  };
8257
8260
 
8261
+ var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
8262
+ return {
8263
+ SetAppendix: [{
8264
+ DepositAsset: {
8265
+ assets: {
8266
+ Wild: {
8267
+ AllCounted: assetCount
8268
+ }
8269
+ },
8270
+ beneficiary: createBeneficiaryLocation({
8271
+ api: api,
8272
+ address: senderAddress,
8273
+ version: version
8274
+ })
8275
+ }
8276
+ }]
8277
+ };
8278
+ };
8279
+
8258
8280
  var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, version) {
8259
8281
  var assets = [];
8260
8282
  var shouldLocalizeAndSort = isRelayChain(chain) || chain.startsWith('AssetHub');
@@ -8276,19 +8298,22 @@ var constructTypeAndThenCall = function constructTypeAndThenCall(context) {
8276
8298
  var fees = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
8277
8299
  var origin = context.origin,
8278
8300
  assetInfo = context.assetInfo,
8301
+ isSubBridge = context.isSubBridge,
8279
8302
  isRelayAsset = context.isRelayAsset,
8280
- version = context.options.version;
8303
+ _context$options = context.options,
8304
+ senderAddress = _context$options.senderAddress,
8305
+ version = _context$options.version;
8281
8306
  var assetCount = isRelayAsset ? 1 : 2;
8282
- var finalCustomXcm = [];
8307
+ var refundInstruction = senderAddress && !isSubBridge ? createRefundInstruction(origin.api, senderAddress, version, assetCount) : null;
8283
8308
  var resolvedFees = fees !== null && fees !== void 0 ? fees : {
8284
8309
  hopFees: 0n,
8285
8310
  destFee: 0n
8286
8311
  };
8287
8312
  var isForFeeCalc = fees === null;
8288
8313
  var systemAssetAmount = resolveSystemAssetAmount(context, isForFeeCalc, resolvedFees);
8289
- finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, resolvedFees)));
8314
+ var customXcm = createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction, resolvedFees);
8290
8315
  var assets = buildAssets(origin.chain, assetInfo, systemAssetAmount, isRelayAsset, version);
8291
- return buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets);
8316
+ return buildTypeAndThenCall(context, isRelayAsset, customXcm, assets);
8292
8317
  };
8293
8318
  /**
8294
8319
  * Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
@@ -9198,7 +9223,7 @@ var Parachain = /*#__PURE__*/function () {
9198
9223
  instance = getPalletInstance(pallet);
9199
9224
  _context5.p = 4;
9200
9225
  _context5.n = 5;
9201
- return instance.getBalance(api, address, asset, customCurrencyId, this.chain);
9226
+ return instance.getBalance(api, address, asset, customCurrencyId);
9202
9227
  case 5:
9203
9228
  return _context5.a(2, _context5.v);
9204
9229
  case 6:
@@ -11623,9 +11648,31 @@ var EnergyWebX = /*#__PURE__*/function (_Parachain) {
11623
11648
  }
11624
11649
  }, {
11625
11650
  key: "getBalanceForeign",
11626
- value: function getBalanceForeign(api, address, asset) {
11627
- return getPalletInstance('Assets').getBalance(api, address, asset, this.chain);
11628
- }
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
+ }()
11629
11676
  }]);
11630
11677
  }(Parachain);
11631
11678
 
@@ -11758,9 +11805,6 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
11758
11805
  value: function transferXTokens$1(input) {
11759
11806
  var asset = input.asset,
11760
11807
  destination = input.destination;
11761
- if (asset.symbol === this.getNativeAssetSymbol()) {
11762
- return transferXTokens(input, Hydration.NATIVE_ASSET_ID);
11763
- }
11764
11808
  var isMoonbeamWhAsset = asset.location && hasJunction(asset.location, 'Parachain', getParaId('Moonbeam')) && hasJunction(asset.location, 'PalletInstance', 110);
11765
11809
  if (isMoonbeamWhAsset && destination === 'Moonbeam') {
11766
11810
  return this.transferMoonbeamWhAsset(input);
@@ -11838,7 +11882,6 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
11838
11882
  }
11839
11883
  }]);
11840
11884
  }(Parachain);
11841
- Hydration.NATIVE_ASSET_ID = 0;
11842
11885
 
11843
11886
  var HydrationPaseo = /*#__PURE__*/function (_Hydration) {
11844
11887
  function HydrationPaseo() {
@@ -13515,22 +13558,21 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
13515
13558
  }, {
13516
13559
  key: "getBalance",
13517
13560
  value: function () {
13518
- var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset, chain) {
13561
+ var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
13519
13562
  var _this = this,
13520
13563
  _balance$balance,
13521
13564
  _balance2;
13522
- var isEnergyWebX, fetchBalance, balance, _t;
13565
+ var fetchBalance, balance, _t;
13523
13566
  return _regenerator().w(function (_context) {
13524
13567
  while (1) switch (_context.p = _context.n) {
13525
13568
  case 0:
13526
13569
  assertHasId(asset);
13527
- isEnergyWebX = chain === 'EnergyWebX';
13528
13570
  fetchBalance = function fetchBalance() {
13529
13571
  var useBigInt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13530
13572
  return api.queryState({
13531
13573
  module: _this.palletName,
13532
13574
  method: 'Account',
13533
- params: [isEnergyWebX ? asset.location : useBigInt ? BigInt(asset.assetId) : Number(asset.assetId), address]
13575
+ params: [useBigInt ? BigInt(asset.assetId) : Number(asset.assetId), address]
13534
13576
  });
13535
13577
  }; // Try with number ID first, if it fails, try with bigint ID
13536
13578
  _context.p = 1;
@@ -13560,7 +13602,7 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
13560
13602
  }
13561
13603
  }, _callee, null, [[1, 3]]);
13562
13604
  }));
13563
- function getBalance(_x, _x2, _x3, _x4) {
13605
+ function getBalance(_x, _x2, _x3) {
13564
13606
  return _getBalance.apply(this, arguments);
13565
13607
  }
13566
13608
  return getBalance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "12.0.4",
3
+ "version": "12.0.6",
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.4",
30
- "@paraspell/sdk-common": "12.0.4",
31
- "@paraspell/pallets": "12.0.4"
29
+ "@paraspell/pallets": "12.0.6",
30
+ "@paraspell/sdk-common": "12.0.6",
31
+ "@paraspell/assets": "12.0.6"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",