@paraspell/sdk-core 14.1.0 → 14.2.0

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
@@ -153,11 +153,13 @@ declare abstract class SubstrateChain<TApi, TRes, TSigner, TCustomChain extends
153
153
  canReceiveFrom<TCustomChain extends string = never>(_origin: TChain | TCustomChain): boolean;
154
154
  shouldUseNativeAssetTeleport({ api, assetInfo: asset, to }: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): boolean;
155
155
  shouldUseExecuteTransfer(_options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): boolean;
156
+ protected shouldUseReserveTransfer(): boolean;
156
157
  createAsset(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: WithAmount<TAssetInfo>, version: Version): TAsset;
157
158
  getNativeAssetSymbol(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>): string;
158
159
  transferLocal(options: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
159
160
  transferLocalNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
160
161
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
162
+ protected getLocalCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): unknown;
161
163
  getBalanceNative(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
162
164
  getCustomCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, _asset: TAssetInfo): unknown;
163
165
  getBalanceForeign(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
@@ -211,6 +213,8 @@ declare class AssetHubWestend<TApi, TRes, TSigner, TCustomChain extends string =
211
213
  declare class Astar<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
212
214
  constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
213
215
  protected getMintConfig(): TMintConfig;
216
+ protected shouldUseReserveTransfer(): boolean;
217
+ isSendingTempDisabled({ assetInfo }: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): boolean;
214
218
  transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
215
219
  isRelayToParaEnabled(): boolean;
216
220
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
@@ -352,6 +356,14 @@ declare class CrustShadow<TApi, TRes, TSigner, TCustomChain extends string = nev
352
356
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
353
357
  }
354
358
 
359
+ declare class Curio<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
360
+ constructor();
361
+ getCustomCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): TForeignOrTokenAsset;
362
+ protected getLocalCurrencyId(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): TForeignOrTokenAsset;
363
+ protected getMintConfig(): TMintConfig;
364
+ transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
365
+ }
366
+
355
367
  declare class Darwinia<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
356
368
  constructor();
357
369
  protected getMintConfig(): TMintConfig;
@@ -368,6 +380,7 @@ declare class EnergyWebX<TApi, TRes, TSigner, TCustomChain extends string = neve
368
380
  constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
369
381
  transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
370
382
  isRelayToParaEnabled(): boolean;
383
+ protected shouldUseReserveTransfer(): boolean;
371
384
  protected getMintConfig(): TMintConfig;
372
385
  getBalanceForeign(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
373
386
  }
@@ -407,6 +420,14 @@ declare class Jamton<TApi, TRes, TSigner, TCustomChain extends string = never> e
407
420
  ForeignAsset: number;
408
421
  Native?: undefined;
409
422
  };
423
+ protected getLocalCurrencyId(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): {
424
+ Native: number;
425
+ ForeignAsset?: undefined;
426
+ } | {
427
+ ForeignAsset: number;
428
+ Native?: undefined;
429
+ };
430
+ protected getMintConfig(): TMintConfig;
410
431
  transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
411
432
  }
412
433
 
@@ -546,6 +567,7 @@ declare const chains: <TApi, TRes, TSigner>() => {
546
567
  Encointer: Encointer<TApi, TRes, TSigner, never>;
547
568
  Basilisk: Basilisk<TApi, TRes, TSigner, never>;
548
569
  BifrostKusama: BifrostKusama<TApi, TRes, TSigner, never>;
570
+ Curio: Curio<TApi, TRes, TSigner, never>;
549
571
  CrustShadow: CrustShadow<TApi, TRes, TSigner, never>;
550
572
  Crab: Crab<TApi, TRes, TSigner, never>;
551
573
  Karura: Karura<TApi, TRes, TSigner, never>;
@@ -1016,6 +1038,7 @@ type TDryRunBaseOptions<TRes, TCustomChain extends string = never> = {
1016
1038
  swapConfig?: TSwapConfig;
1017
1039
  useRootOrigin?: boolean;
1018
1040
  bypassOptions?: TBypassOptions;
1041
+ keepAlive?: boolean;
1019
1042
  };
1020
1043
  type TDryRunOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TDryRunBaseOptions<TRes, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
1021
1044
  type TDryRunCallBaseOptions<TRes, TCustomChain extends string = never> = {
@@ -1047,6 +1070,7 @@ type TDryRunCallBaseOptions<TRes, TCustomChain extends string = never> = {
1047
1070
  assets?: WithAmount<TAssetInfo>[];
1048
1071
  bypassOptions?: TBypassOptions;
1049
1072
  feeAsset?: TAssetInfo;
1073
+ keepAlive?: boolean;
1050
1074
  };
1051
1075
  type TDryRunBypassOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<Omit<TDryRunCallBaseOptions<TRes, TCustomChain>, 'useRootOrigin' | 'destination'>, TApi, TRes, TSigner, TCustomChain>;
1052
1076
  type TDryRunCallOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TDryRunCallBaseOptions<TRes, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
@@ -2035,7 +2059,7 @@ type TDestWeight = {
2035
2059
  proof_size: bigint;
2036
2060
  };
2037
2061
  type TXTokensMethod = 'transfer' | 'transfer_multiasset' | 'transfer_multiassets';
2038
- type TPolkadotXcmMethod = 'limited_teleport_assets' | 'transfer_assets_using_type_and_then';
2062
+ type TPolkadotXcmMethod = 'limited_teleport_assets' | 'limited_reserve_transfer_assets' | 'reserve_transfer_assets' | 'transfer_assets_using_type_and_then';
2039
2063
  type TWeight<TWeightType = bigint> = {
2040
2064
  refTime: TWeightType;
2041
2065
  proofSize: TWeightType;
@@ -2502,7 +2526,7 @@ declare const reverseTransformLocation: (location: TLocation) => TLocation;
2502
2526
 
2503
2527
  declare const normalizeAmount: (amount: bigint) => bigint;
2504
2528
 
2505
- declare const resolveDestChain: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, originChain: TSubstrateChain | TCustomChain, paraId: number | undefined) => "AssetHubPolkadot" | "Acala" | "Ajuna" | "Astar" | "BifrostPolkadot" | "BridgeHubPolkadot" | "Centrifuge" | "Darwinia" | "EnergyWebX" | "Hydration" | "Heima" | "Jamton" | "CoretimePolkadot" | "Collectives" | "Crust" | "NeuroWeb" | "Pendulum" | "Mythos" | "Peaq" | "PeoplePolkadot" | "Unique" | "Xode" | "AssetHubKusama" | "BridgeHubKusama" | "Karura" | "CoretimeKusama" | "Encointer" | "Basilisk" | "BifrostKusama" | "CrustShadow" | "Crab" | "RobonomicsPolkadot" | "PeopleKusama" | "Shiden" | "AssetHubWestend" | "BridgeHubWestend" | "CollectivesWestend" | "CoretimeWestend" | "Penpal" | "PeopleWestend" | "AssetHubPaseo" | "EnergyWebXPaseo" | "HeimaPaseo" | "HydrationPaseo" | "NeuroWebPaseo" | "PeoplePaseo" | undefined;
2529
+ declare const resolveDestChain: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, originChain: TSubstrateChain | TCustomChain, paraId: number | undefined) => "AssetHubPolkadot" | "Acala" | "Ajuna" | "Astar" | "BifrostPolkadot" | "BridgeHubPolkadot" | "Centrifuge" | "Darwinia" | "EnergyWebX" | "Hydration" | "Heima" | "Jamton" | "CoretimePolkadot" | "Collectives" | "Crust" | "NeuroWeb" | "Pendulum" | "Mythos" | "Peaq" | "PeoplePolkadot" | "Unique" | "Xode" | "AssetHubKusama" | "BridgeHubKusama" | "Karura" | "CoretimeKusama" | "Encointer" | "Basilisk" | "BifrostKusama" | "Curio" | "CrustShadow" | "Crab" | "RobonomicsPolkadot" | "PeopleKusama" | "Shiden" | "AssetHubWestend" | "BridgeHubWestend" | "CollectivesWestend" | "CoretimeWestend" | "Penpal" | "PeopleWestend" | "AssetHubPaseo" | "EnergyWebXPaseo" | "HeimaPaseo" | "HydrationPaseo" | "NeuroWebPaseo" | "PeoplePaseo" | undefined;
2506
2530
 
2507
2531
  declare const resolveParaId: <TApi, TRes, TSigner, TCustomChain extends string = never>(paraId: number | undefined, destination: TDestination, api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>) => number | undefined;
2508
2532
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositOrThrowImpl, normalizeCustomAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAssetEqual, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositOrThrowImpl, normalizeCustomAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, pad, toHex, getAddress, concat, keccak256, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
@@ -819,18 +819,13 @@ var keyFromWs = function keyFromWs(ws) {
819
819
  return Array.isArray(ws) ? JSON.stringify(ws) : ws;
820
820
  };
821
821
  var createClientPoolHelpers = function createClientPoolHelpers(clientPool, createClient) {
822
- var leaseClient = /*#__PURE__*/function () {
823
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ws, ttlMs) {
824
- var key, entry, client;
822
+ var pendingClients = new Map();
823
+ var createEntry = /*#__PURE__*/function () {
824
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(key, ws, ttlMs) {
825
+ var client, entry;
825
826
  return _regenerator().w(function (_context) {
826
827
  while (1) switch (_context.n) {
827
828
  case 0:
828
- key = keyFromWs(ws);
829
- entry = clientPool.peek(key);
830
- if (entry) {
831
- _context.n = 2;
832
- break;
833
- }
834
829
  _context.n = 1;
835
830
  return createClient(ws);
836
831
  case 1:
@@ -841,16 +836,51 @@ var createClientPoolHelpers = function createClientPoolHelpers(clientPool, creat
841
836
  destroyWanted: false
842
837
  };
843
838
  clientPool.set(key, entry, ttlMs);
839
+ return _context.a(2, entry);
840
+ }
841
+ }, _callee);
842
+ }));
843
+ return function createEntry(_x, _x2, _x3) {
844
+ return _ref.apply(this, arguments);
845
+ };
846
+ }();
847
+ var getOrCreateEntry = function getOrCreateEntry(key, ws, ttlMs) {
848
+ var pending = pendingClients.get(key);
849
+ if (pending) return pending;
850
+ var creation = Promise.resolve().then(function () {
851
+ return createEntry(key, ws, ttlMs);
852
+ })["finally"](function () {
853
+ pendingClients["delete"](key);
854
+ });
855
+ pendingClients.set(key, creation);
856
+ return creation;
857
+ };
858
+ var leaseClient = /*#__PURE__*/function () {
859
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(ws, ttlMs) {
860
+ var key, entry;
861
+ return _regenerator().w(function (_context2) {
862
+ while (1) switch (_context2.n) {
863
+ case 0:
864
+ key = keyFromWs(ws);
865
+ entry = clientPool.peek(key);
866
+ if (entry) {
867
+ _context2.n = 2;
868
+ break;
869
+ }
870
+ _context2.n = 1;
871
+ return getOrCreateEntry(key, ws, ttlMs);
872
+ case 1:
873
+ entry = _context2.v;
844
874
  case 2:
845
875
  entry.refs += 1;
846
- clientPool.revive(key, ttlMs);
847
876
  entry.destroyWanted = false;
848
- return _context.a(2, entry.client);
877
+ clientPool.revive(key, ttlMs);
878
+ return _context2.a(2, entry.client);
849
879
  }
850
- }, _callee);
880
+ }, _callee2);
851
881
  }));
852
- return function leaseClient(_x, _x2) {
853
- return _ref.apply(this, arguments);
882
+ return function leaseClient(_x4, _x5) {
883
+ return _ref2.apply(this, arguments);
854
884
  };
855
885
  }();
856
886
  var releaseClient = function releaseClient(ws) {
@@ -1449,6 +1479,17 @@ var BifrostKusama$1 = {
1449
1479
  }
1450
1480
  ]
1451
1481
  };
1482
+ var Curio$1 = {
1483
+ name: "Curio",
1484
+ info: "curio",
1485
+ paraId: 3339,
1486
+ providers: [
1487
+ {
1488
+ name: "Curio",
1489
+ endpoint: "wss://parachain.curioinvest.com/"
1490
+ }
1491
+ ]
1492
+ };
1452
1493
  var CrustShadow$1 = {
1453
1494
  name: "Crust Shadow",
1454
1495
  info: "shadow",
@@ -1854,6 +1895,7 @@ var configs = {
1854
1895
  Encointer: Encointer$1,
1855
1896
  Basilisk: Basilisk$1,
1856
1897
  BifrostKusama: BifrostKusama$1,
1898
+ Curio: Curio$1,
1857
1899
  CrustShadow: CrustShadow$1,
1858
1900
  Crab: Crab$1,
1859
1901
  RobonomicsPolkadot: RobonomicsPolkadot$1,
@@ -2766,7 +2808,7 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
2766
2808
  key: "transfer",
2767
2809
  value: function () {
2768
2810
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(transferOptions) {
2769
- var api, asset, currency, feeAsset, feeCurrency, recipient, destination, paraIdTo, overriddenAsset, version, sender, ahAddress, pallet, method, keepAlive, transactOptions, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, mythAsset, isMythAsset, assetNeedsTypeThen, supportsTypeThen, isSubBridge, useTypeAndThen, options, promise, isAHOrigin, isAHDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call, input, _t;
2811
+ var api, asset, currency, feeAsset, feeCurrency, recipient, destination, paraIdTo, overriddenAsset, version, sender, ahAddress, pallet, method, keepAlive, transactOptions, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, mythAsset, isMythAsset, assetNeedsTypeThen, shouldUseReserveTransfer, supportsTypeThen, isSubBridge, useTypeAndThen, options, promise, isAHOrigin, isAHDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call, input, _t;
2770
2812
  return _regenerator().w(function (_context) {
2771
2813
  while (1) switch (_context.n) {
2772
2814
  case 0:
@@ -2795,18 +2837,19 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
2795
2837
  mythAsset = api.findNativeAssetInfoOrThrow('Mythos');
2796
2838
  isMythAsset = isAssetEqual(mythAsset, asset);
2797
2839
  assetNeedsTypeThen = isRelayAsset || isMythAsset;
2840
+ shouldUseReserveTransfer = isRelayAsset && this.shouldUseReserveTransfer();
2798
2841
  _context.n = 3;
2799
2842
  return api.hasMethod(api.hasPallet(this.chain, 'XcmPallet') ? 'XcmPallet' : 'PolkadotXcm', 'transfer_assets_using_type_and_then');
2800
2843
  case 3:
2801
2844
  supportsTypeThen = _context.v;
2802
- if (!(assetNeedsTypeThen && !supportsTypeThen)) {
2845
+ isSubBridge = !isTLocation(destination) && isSubstrateBridge(this.chain, destination);
2846
+ if (!(assetNeedsTypeThen && !supportsTypeThen && (!shouldUseReserveTransfer || isSubBridge))) {
2803
2847
  _context.n = 4;
2804
2848
  break;
2805
2849
  }
2806
2850
  throw new TypeAndThenUnavailableError('Relaychain assets require the type-and-then method which is not supported by this chain.');
2807
2851
  case 4:
2808
- isSubBridge = !isTLocation(destination) && isSubstrateBridge(this.chain, destination);
2809
- useTypeAndThen = assetNeedsTypeThen && supportsTypeThen && destChain && !isExternalChain(destChain) && !feeAsset && (!isTrustedChain(this.chain) || !isTrustedChain(destChain)) || isSubBridge;
2852
+ useTypeAndThen = !shouldUseReserveTransfer && assetNeedsTypeThen && supportsTypeThen && destChain && !isExternalChain(destChain) && !feeAsset && (!isTrustedChain(this.chain) || !isTrustedChain(destChain)) || isSubBridge;
2810
2853
  if (!(supportsPolkadotXCM(this) || useTypeAndThen)) {
2811
2854
  _context.n = 13;
2812
2855
  break;
@@ -2943,7 +2986,7 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
2943
2986
  value: function throwIfTempDisabled(options, destChain) {
2944
2987
  var isSendingDisabled = this.isSendingTempDisabled(options);
2945
2988
  if (isSendingDisabled) {
2946
- throw new FeatureTemporarilyDisabledError("Sending from ".concat(this.chain, " is temporarily disabled"));
2989
+ throw new FeatureTemporarilyDisabledError("Sending ".concat(options.assetInfo.symbol, " from ").concat(this.chain, " is temporarily disabled"));
2947
2990
  }
2948
2991
  var scenario = resolveScenario(this.chain, options.to);
2949
2992
  var isReceivingDisabled = destChain && !isExternalChain(destChain) && getChain(destChain).isReceivingTempDisabled(scenario);
@@ -2981,6 +3024,11 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
2981
3024
  value: function shouldUseExecuteTransfer(_options) {
2982
3025
  return false;
2983
3026
  }
3027
+ }, {
3028
+ key: "shouldUseReserveTransfer",
3029
+ value: function shouldUseReserveTransfer() {
3030
+ return false;
3031
+ }
2984
3032
  }, {
2985
3033
  key: "createAsset",
2986
3034
  value: function createAsset$1(api, asset, version) {
@@ -3090,11 +3138,10 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
3090
3138
  recipient = options.recipient,
3091
3139
  isAmountAll = options.isAmountAll,
3092
3140
  keepAlive = options.keepAlive;
3093
- assertHasId(asset);
3094
3141
  var dest = {
3095
3142
  Id: recipient
3096
3143
  };
3097
- var currencyId = BigInt(asset.assetId);
3144
+ var currencyId = this.getLocalCurrencyId(api, asset);
3098
3145
  if (isAmountAll) {
3099
3146
  return api.deserializeExtrinsics({
3100
3147
  module: 'Tokens',
@@ -3116,6 +3163,12 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
3116
3163
  }
3117
3164
  });
3118
3165
  }
3166
+ }, {
3167
+ key: "getLocalCurrencyId",
3168
+ value: function getLocalCurrencyId(_api, asset) {
3169
+ assertHasId(asset);
3170
+ return BigInt(asset.assetId);
3171
+ }
3119
3172
  }, {
3120
3173
  key: "getBalanceNative",
3121
3174
  value: function getBalanceNative(api, address, asset) {
@@ -3370,7 +3423,8 @@ var validateBridgeAsset = function validateBridgeAsset(origin, destination, asse
3370
3423
  var nativeAsset = api.findNativeAssetInfoOrThrow(origin);
3371
3424
  var isNativeAsset = isAssetEqual(asset, nativeAsset);
3372
3425
  var isBridgedStablecoin = isStableCoinAsset(asset);
3373
- if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
3426
+ var isAdditionalBridgedAsset = isAdditionalSubstrateBridgeAsset(asset);
3427
+ if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin || isAdditionalBridgedAsset)) {
3374
3428
  throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
3375
3429
  }
3376
3430
  };
@@ -4021,7 +4075,8 @@ var buildDryRun = function buildDryRun(api, tx, options, bypassOptions) {
4021
4075
  feeAsset = options.feeAsset,
4022
4076
  from = options.from,
4023
4077
  currency = options.currency,
4024
- version = options.version;
4078
+ version = options.version,
4079
+ keepAlive = options.keepAlive;
4025
4080
  if (isTLocation(to)) {
4026
4081
  throw new InvalidAddressError('Location destination is not supported for XCM fee calculation.');
4027
4082
  }
@@ -4034,7 +4089,8 @@ var buildDryRun = function buildDryRun(api, tx, options, bypassOptions) {
4034
4089
  currency: currency,
4035
4090
  feeAsset: feeAsset,
4036
4091
  version: version,
4037
- bypassOptions: bypassOptions
4092
+ bypassOptions: bypassOptions,
4093
+ keepAlive: from === to ? keepAlive !== null && keepAlive !== void 0 ? keepAlive : true : false
4038
4094
  });
4039
4095
  };
4040
4096
 
@@ -5813,11 +5869,11 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
5813
5869
 
5814
5870
  var dryRunInternal = /*#__PURE__*/function () {
5815
5871
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5816
- var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, dryRunError, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
5872
+ var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, keepAlive, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, dryRunError, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
5817
5873
  return _regenerator().w(function (_context2) {
5818
5874
  while (1) switch (_context2.n) {
5819
5875
  case 0:
5820
- api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
5876
+ api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, keepAlive = options.keepAlive, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
5821
5877
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
5822
5878
  _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
5823
5879
  amount = asset.amount;
@@ -5835,6 +5891,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5835
5891
  feeAsset: resolvedFeeAsset,
5836
5892
  version: resolvedVersion,
5837
5893
  bypassOptions: bypassOptions,
5894
+ keepAlive: keepAlive,
5838
5895
  useRootOrigin: useRootOrigin || !!bypassOptions
5839
5896
  });
5840
5897
  case 1:
@@ -6170,6 +6227,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
6170
6227
  mintFeeAssetRes,
6171
6228
  amount,
6172
6229
  mintSentAsset,
6230
+ sentAssets,
6173
6231
  mintAssetResults,
6174
6232
  _args2 = arguments,
6175
6233
  _t,
@@ -6237,7 +6295,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
6237
6295
  case 8:
6238
6296
  mintSentAsset = /*#__PURE__*/function () {
6239
6297
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
6240
- var balance, bonus, mintAmount, _calcPreviewMintAmoun, missing, total;
6298
+ var balance, bonus, mintAmount, _calcPreviewMintAmoun, keepAliveBuffer, desiredBalance, missing, total;
6241
6299
  return _regenerator().w(function (_context) {
6242
6300
  while (1) switch (_context.n) {
6243
6301
  case 0:
@@ -6254,7 +6312,9 @@ var wrapTxBypass = /*#__PURE__*/function () {
6254
6312
  if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
6255
6313
  mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
6256
6314
  } else {
6257
- missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, sentAsset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
6315
+ keepAliveBuffer = dryRunOptions.keepAlive ? getEdFromAssetOrThrow(sentAsset) : 0n;
6316
+ desiredBalance = sentAsset.amount + keepAliveBuffer;
6317
+ missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, desiredBalance)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
6258
6318
  total = missing + bonus;
6259
6319
  mintAmount = total > 0n ? total : null;
6260
6320
  }
@@ -6268,8 +6328,9 @@ var wrapTxBypass = /*#__PURE__*/function () {
6268
6328
  return _ref3.apply(this, arguments);
6269
6329
  };
6270
6330
  }(); // mint assets that are being sent
6331
+ sentAssets = (_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset];
6271
6332
  _context2.n = 9;
6272
- return Promise.all(((_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset]).map(mintSentAsset));
6333
+ return Promise.all(sentAssets.map(mintSentAsset));
6273
6334
  case 9:
6274
6335
  mintAssetResults = _context2.v;
6275
6336
  return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
@@ -8038,8 +8099,8 @@ var createDestination = function createDestination(api, version, origin, destina
8038
8099
  }
8039
8100
  };
8040
8101
  }
8041
- var isSb = !isLocDestination && isSnowbridge(origin, destination);
8042
- if (isSb) {
8102
+ var isExternalDestination = !isLocDestination && isExternalChain(destination);
8103
+ if (isExternalDestination) {
8043
8104
  return {
8044
8105
  parents: Parents.TWO,
8045
8106
  interior: {
@@ -8265,6 +8326,26 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8265
8326
  };
8266
8327
  };
8267
8328
 
8329
+ var PINK_LOCATION = {
8330
+ parents: 1,
8331
+ interior: {
8332
+ X3: [{
8333
+ Parachain: 1000
8334
+ }, {
8335
+ PalletInstance: 50
8336
+ }, {
8337
+ GeneralIndex: 23
8338
+ }]
8339
+ }
8340
+ };
8341
+ var requiresSystemAssetByLocation = function requiresSystemAssetByLocation(api, assetLocation) {
8342
+ var wudLocation = api.findAssetInfoOrThrow('Jamton', {
8343
+ symbol: 'WUD'
8344
+ }).location;
8345
+ return [wudLocation, PINK_LOCATION].some(function (location) {
8346
+ return deepEqual(assetLocation, location);
8347
+ });
8348
+ };
8268
8349
  var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
8269
8350
  var expectedConsensus = isExternalChain(destination) ? getEthereumJunction(api, chain, false).GlobalConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
8270
8351
  var isDestReserve = deepEqual(getJunctionValue(location, 'GlobalConsensus'), expectedConsensus);
@@ -8277,12 +8358,12 @@ var resolveReserveChain = function resolveReserveChain(api, chain, destination,
8277
8358
  if (overrideReserve !== undefined) {
8278
8359
  return overrideReserve;
8279
8360
  }
8280
- return api.getAssetReserveChain(chain, assetLocation, true);
8361
+ return api.getAssetReserveChain(chain, assetLocation, isExternalChain(destination));
8281
8362
  };
8282
8363
  var createTypeAndThenCallContext = /*#__PURE__*/function () {
8283
8364
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, overrides) {
8284
8365
  var _overrides$noFeeAsset;
8285
- var api, chain, destination, assetInfo, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, bridgeHopChain, destApi, reserveApi;
8366
+ var api, chain, destination, assetInfo, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isExternalDestination, isSnowbridgeAsset, requiresSystemAsset, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, assetHubChain, bridgeHopChain, destApi, reserveApi;
8286
8367
  return _regenerator().w(function (_context) {
8287
8368
  while (1) switch (_context.n) {
8288
8369
  case 0:
@@ -8320,14 +8401,18 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
8320
8401
  systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(chain));
8321
8402
  assetGlobalConsensus = getJunctionValue(assetInfo.location, 'GlobalConsensus');
8322
8403
  originRelayChain = api.getRelayChainOf(chain);
8323
- isAssetHubToExternal = chain.startsWith('AssetHub') && isExternalChain(destination);
8324
- isForeignRelayToExternal = isExternalChain(destination) && !chain.startsWith('AssetHub') && assetInfo.location.parents === 2 && RELAYCHAINS.some(function (relay) {
8404
+ isExternalDestination = isExternalChain(destination);
8405
+ isSnowbridgeAsset = deepEqual(assetGlobalConsensus, getEthereumJunction(api, chain, false).GlobalConsensus);
8406
+ requiresSystemAsset = !isExternalDestination && (isSnowbridgeAsset || !isRelayChain(destination) && requiresSystemAssetByLocation(api, assetInfo.location));
8407
+ isAssetHubToExternal = chain.startsWith('AssetHub') && isExternalDestination;
8408
+ isForeignRelayToExternal = isExternalDestination && !chain.startsWith('AssetHub') && assetInfo.location.parents === 2 && RELAYCHAINS.some(function (relay) {
8325
8409
  return relay !== originRelayChain && deepEqual(assetGlobalConsensus, _defineProperty({}, relay.toLowerCase(), null));
8326
8410
  });
8327
- isRelayAsset = !isForeignRelayToExternal && (isAssetHubToExternal || NO_FEE_ASSET_LOCS.some(function (loc) {
8411
+ isRelayAsset = !requiresSystemAsset && !isForeignRelayToExternal && (isAssetHubToExternal || NO_FEE_ASSET_LOCS.some(function (loc) {
8328
8412
  return deepEqual(assetInfo.location, loc);
8329
8413
  }) || isSubBridge || ((_overrides$noFeeAsset = overrides.noFeeAsset) !== null && _overrides$noFeeAsset !== void 0 ? _overrides$noFeeAsset : false));
8330
- bridgeHopChain = !chain.startsWith('AssetHub') && assetGlobalConsensus !== undefined ? "AssetHub".concat(originRelayChain) : undefined;
8414
+ assetHubChain = "AssetHub".concat(originRelayChain);
8415
+ bridgeHopChain = !chain.startsWith('AssetHub') && destination !== assetHubChain && assetGlobalConsensus !== undefined ? assetHubChain : undefined;
8331
8416
  destApi = api.clone();
8332
8417
  _context.n = 1;
8333
8418
  return destApi.init(destination);
@@ -9159,7 +9244,9 @@ var isNativeAssetTeleport = function isNativeAssetTeleport(api, origin, dest, as
9159
9244
  var isOriginAh = origin.includes('AssetHub');
9160
9245
  var isDestAh = dest.includes('AssetHub');
9161
9246
  if (isOriginAh === isDestAh) return false;
9247
+ if (api.getRelayChainOf(origin) !== api.getRelayChainOf(dest)) return false;
9162
9248
  var para = isDestAh ? origin : dest;
9249
+ if (para === 'Curio') return false;
9163
9250
  return isAssetEqual(api.findNativeAssetInfoOrThrow(para), asset);
9164
9251
  };
9165
9252
 
@@ -10724,10 +10811,21 @@ var Astar = /*#__PURE__*/function (_SubstrateChain) {
10724
10811
  useBigIntId: true
10725
10812
  };
10726
10813
  }
10814
+ }, {
10815
+ key: "shouldUseReserveTransfer",
10816
+ value: function shouldUseReserveTransfer() {
10817
+ return true;
10818
+ }
10819
+ }, {
10820
+ key: "isSendingTempDisabled",
10821
+ value: function isSendingTempDisabled(_ref) {
10822
+ var assetInfo = _ref.assetInfo;
10823
+ return deepEqual(assetInfo.location, RELAY_LOCATION);
10824
+ }
10727
10825
  }, {
10728
10826
  key: "transferPolkadotXCM",
10729
10827
  value: function transferPolkadotXCM(input) {
10730
- return transferPolkadotXcm(input, 'transfer_assets_using_type_and_then');
10828
+ return transferPolkadotXcm(input, 'reserve_transfer_assets');
10731
10829
  }
10732
10830
  }, {
10733
10831
  key: "isRelayToParaEnabled",
@@ -11428,6 +11526,43 @@ var CrustShadow = /*#__PURE__*/function (_SubstrateChain) {
11428
11526
  }]);
11429
11527
  }(SubstrateChain);
11430
11528
 
11529
+ var Curio = /*#__PURE__*/function (_SubstrateChain) {
11530
+ function Curio() {
11531
+ _classCallCheck(this, Curio);
11532
+ return _callSuper(this, Curio, ['Curio', 'curio', 'Kusama', Version.V4]);
11533
+ }
11534
+ _inherits(Curio, _SubstrateChain);
11535
+ return _createClass(Curio, [{
11536
+ key: "getCustomCurrencyId",
11537
+ value: function getCustomCurrencyId(_api, asset) {
11538
+ if (asset.isNative) return {
11539
+ Token: asset.symbol
11540
+ };
11541
+ assertHasId(asset);
11542
+ return {
11543
+ ForeignAsset: Number(asset.assetId)
11544
+ };
11545
+ }
11546
+ }, {
11547
+ key: "getLocalCurrencyId",
11548
+ value: function getLocalCurrencyId(api, asset) {
11549
+ return this.getCustomCurrencyId(api, asset);
11550
+ }
11551
+ }, {
11552
+ key: "getMintConfig",
11553
+ value: function getMintConfig() {
11554
+ return {
11555
+ useCustomCurrencyId: true
11556
+ };
11557
+ }
11558
+ }, {
11559
+ key: "transferPolkadotXCM",
11560
+ value: function transferPolkadotXCM(input) {
11561
+ return transferPolkadotXcm(input);
11562
+ }
11563
+ }]);
11564
+ }(SubstrateChain);
11565
+
11431
11566
  var Darwinia = /*#__PURE__*/function (_SubstrateChain) {
11432
11567
  function Darwinia() {
11433
11568
  _classCallCheck(this, Darwinia);
@@ -11530,13 +11665,18 @@ var EnergyWebX = /*#__PURE__*/function (_SubstrateChain) {
11530
11665
  scenario: scenario
11531
11666
  });
11532
11667
  }
11533
- return transferPolkadotXcm(input);
11668
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
11534
11669
  }
11535
11670
  }, {
11536
11671
  key: "isRelayToParaEnabled",
11537
11672
  value: function isRelayToParaEnabled() {
11538
11673
  return false;
11539
11674
  }
11675
+ }, {
11676
+ key: "shouldUseReserveTransfer",
11677
+ value: function shouldUseReserveTransfer() {
11678
+ return true;
11679
+ }
11540
11680
  }, {
11541
11681
  key: "getMintConfig",
11542
11682
  value: function getMintConfig() {
@@ -11672,29 +11812,28 @@ var Jamton = /*#__PURE__*/function (_SubstrateChain) {
11672
11812
  ForeignAsset: assetId
11673
11813
  };
11674
11814
  }
11815
+ }, {
11816
+ key: "getLocalCurrencyId",
11817
+ value: function getLocalCurrencyId(api, asset) {
11818
+ return this.getCustomCurrencyId(api, asset);
11819
+ }
11820
+ }, {
11821
+ key: "getMintConfig",
11822
+ value: function getMintConfig() {
11823
+ return {
11824
+ useCustomCurrencyId: true
11825
+ };
11826
+ }
11675
11827
  }, {
11676
11828
  key: "transferPolkadotXCM",
11677
11829
  value: function transferPolkadotXCM(input) {
11678
- var api = input.api,
11679
- assetInfo = input.assetInfo,
11830
+ var assetInfo = input.assetInfo,
11680
11831
  scenario = input.scenario,
11681
- destination = input.destination,
11682
- version = input.version;
11832
+ destination = input.destination;
11683
11833
  if (assetInfo.isNative) return transferPolkadotXcm(input);
11684
11834
  if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot') {
11685
11835
  throw new ScenarioNotSupportedError("Transfer from ".concat(this.chain, " to ").concat(JSON.stringify(destination), " is not yet supported"));
11686
11836
  }
11687
- if (isSymbolMatch(assetInfo.symbol, 'WUD')) {
11688
- var usdt = api.findAssetInfoOrThrow(this.chain, {
11689
- symbol: 'USDt'
11690
- });
11691
- var MIN_USDT_AMOUNT = 180000n; // 0.18 USDt
11692
- return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
11693
- overriddenAsset: [_objectSpread2(_objectSpread2({}, createAsset(version, MIN_USDT_AMOUNT, usdt.location)), {}, {
11694
- isFeeAsset: true
11695
- }), createAsset(version, assetInfo.amount, assetInfo.location)]
11696
- }));
11697
- }
11698
11837
  return transferPolkadotXcm(input);
11699
11838
  }
11700
11839
  }]);
@@ -12334,6 +12473,7 @@ var chains = function chains() {
12334
12473
  Encointer: new Encointer(),
12335
12474
  Basilisk: new Basilisk(),
12336
12475
  BifrostKusama: new BifrostKusama(),
12476
+ Curio: new Curio(),
12337
12477
  CrustShadow: new CrustShadow(),
12338
12478
  Crab: new Crab(),
12339
12479
  Karura: new Karura(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "14.1.0",
3
+ "version": "14.2.0",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,9 +25,9 @@
25
25
  "@noble/hashes": "^2.2.0",
26
26
  "@scure/base": "^2.2.0",
27
27
  "viem": "^2.55.10",
28
- "@paraspell/assets": "14.1.0",
29
- "@paraspell/sdk-common": "14.1.0",
30
- "@paraspell/pallets": "14.1.0"
28
+ "@paraspell/pallets": "14.2.0",
29
+ "@paraspell/sdk-common": "14.2.0",
30
+ "@paraspell/assets": "14.2.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/plugin-syntax-import-attributes": "^7.29.7",