@paraspell/sdk-core 11.14.3 → 11.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4647,11 +4647,12 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
4647
4647
  return !(isMultipleAssets || hasOverriddenLocation);
4648
4648
  };
4649
4649
 
4650
- var validateAddress = function validateAddress(address, chain) {
4651
- var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4650
+ var validateAddress = function validateAddress(api, address, chain) {
4651
+ var isDestination = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
4652
4652
  if (sdkCommon.isTLocation(address)) return;
4653
4653
  var isEvm = assets.isChainEvm(chain);
4654
4654
  var isEthereumAddress = viem.isAddress(address);
4655
+ var isPublicKeyFormat = typeof address === 'string' && address.startsWith('0x') && !isEthereumAddress;
4655
4656
  if (isEvm) {
4656
4657
  if (!isEthereumAddress) {
4657
4658
  throw new InvalidAddressError("".concat(isDestination ? 'Destination chain' : 'Chain', " is an EVM chain, but the address provided is not a valid Ethereum address."));
@@ -4660,12 +4661,21 @@ var validateAddress = function validateAddress(address, chain) {
4660
4661
  if (isEthereumAddress) {
4661
4662
  throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "chain is not an EVM chain."));
4662
4663
  }
4664
+ if (isPublicKeyFormat) {
4665
+ return;
4666
+ }
4667
+ if (typeof address === 'string') {
4668
+ var isValid = api.validateSubstrateAddress(address);
4669
+ if (!isValid) {
4670
+ throw new InvalidAddressError("Invalid address: ".concat(address));
4671
+ }
4672
+ }
4663
4673
  }
4664
4674
  };
4665
4675
 
4666
- var validateDestinationAddress = function validateDestinationAddress(address, destination) {
4676
+ var validateDestinationAddress = function validateDestinationAddress(address, destination, api) {
4667
4677
  if (typeof address === 'string' && !sdkCommon.isTLocation(destination)) {
4668
- validateAddress(address, destination);
4678
+ validateAddress(api, address, destination, true);
4669
4679
  }
4670
4680
  };
4671
4681
 
@@ -7508,7 +7518,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7508
7518
  key: "transferPolkadotXCM",
7509
7519
  value: function () {
7510
7520
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
7511
- var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call, method, modifiedInput, _t, _t2;
7521
+ var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, requiresTypeThen, _call, method, modifiedInput, _t, _t2;
7512
7522
  return _regenerator().w(function (_context3) {
7513
7523
  while (1) switch (_context3.n) {
7514
7524
  case 0:
@@ -7558,7 +7568,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7558
7568
  return _context3.a(2, this.handleMythosTransfer(options));
7559
7569
  case 7:
7560
7570
  isExternalAsset = assetInfo.location && assetInfo.location.parents === sdkCommon.Parents.TWO;
7561
- if (!isExternalAsset) {
7571
+ requiresTypeThen = AH_REQUIRES_FEE_ASSET_LOCS.some(function (loc) {
7572
+ return sdkCommon.deepEqual(loc, assetInfo.location);
7573
+ });
7574
+ if (!(isExternalAsset || requiresTypeThen)) {
7562
7575
  _context3.n = 9;
7563
7576
  break;
7564
7577
  }
@@ -8433,24 +8446,6 @@ var HeimaPaseo = /*#__PURE__*/function (_Heima) {
8433
8446
  return _createClass(HeimaPaseo);
8434
8447
  }(Heima);
8435
8448
 
8436
- var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
8437
- var api = _ref.api,
8438
- address = _ref.address;
8439
- return _defineProperty({}, version, [{
8440
- DepositAsset: {
8441
- assets: {
8442
- Wild: {
8443
- AllCounted: 2
8444
- }
8445
- },
8446
- beneficiary: createBeneficiaryLocation({
8447
- api: api,
8448
- address: address,
8449
- version: version
8450
- })
8451
- }
8452
- }]);
8453
- };
8454
8449
  var Hydration = /*#__PURE__*/function (_Parachain) {
8455
8450
  function Hydration() {
8456
8451
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Hydration';
@@ -8462,35 +8457,10 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8462
8457
  }
8463
8458
  _inherits(Hydration, _Parachain);
8464
8459
  return _createClass(Hydration, [{
8465
- key: "transferToAssetHub",
8466
- value: function transferToAssetHub(input) {
8467
- var api = input.api,
8468
- asset = input.assetInfo,
8469
- version = input.version,
8470
- destination = input.destination;
8471
- var call = {
8472
- module: 'PolkadotXcm',
8473
- method: 'transfer_assets_using_type_and_then',
8474
- parameters: {
8475
- dest: createVersionedDestination(version, this.chain, destination, getParaId('AssetHubPolkadot')),
8476
- assets: _defineProperty({}, version, [createAsset(version, asset.amount, DOT_LOCATION)]),
8477
- assets_transfer_type: 'DestinationReserve',
8478
- remote_fees_id: _defineProperty({}, version, {
8479
- parents: sdkCommon.Parents.ONE,
8480
- interior: 'Here'
8481
- }),
8482
- fees_transfer_type: 'DestinationReserve',
8483
- custom_xcm_on_dest: createCustomXcmAh(input, version),
8484
- weight_limit: 'Unlimited'
8485
- }
8486
- };
8487
- return api.callTxMethod(call);
8488
- }
8489
- }, {
8490
8460
  key: "transferPolkadotXCM",
8491
8461
  value: function () {
8492
8462
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
8493
- var api, destination, feeAsset, asset, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t;
8463
+ var api, destination, feeAsset, asset, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t, _t2;
8494
8464
  return _regenerator().w(function (_context) {
8495
8465
  while (1) switch (_context.n) {
8496
8466
  case 0:
@@ -8523,7 +8493,11 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8523
8493
  case 3:
8524
8494
  return _context.a(2, _t.callTxMethod.call(_t, _context.v));
8525
8495
  case 4:
8526
- return _context.a(2, this.transferToAssetHub(input));
8496
+ _t2 = api;
8497
+ _context.n = 5;
8498
+ return createTypeAndThenCall(this.chain, input);
8499
+ case 5:
8500
+ return _context.a(2, _t2.callTxMethod.call(_t2, _context.v));
8527
8501
  }
8528
8502
  }, _callee, this);
8529
8503
  }));
@@ -8571,7 +8545,10 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8571
8545
  assetInfo = options.assetInfo,
8572
8546
  feeAsset = options.feeAsset;
8573
8547
  var baseCanUseXTokens = _superPropGet(Hydration, "canUseXTokens", this, 3)([options]);
8574
- return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && assetInfo.symbol === 'DOT') && baseCanUseXTokens && !feeAsset;
8548
+ var requiresTypeThen = AH_REQUIRES_FEE_ASSET_LOCS.some(function (loc) {
8549
+ return sdkCommon.deepEqual(loc, assetInfo.location);
8550
+ });
8551
+ return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && assetInfo.symbol === 'DOT') && baseCanUseXTokens && !feeAsset && !requiresTypeThen;
8575
8552
  }
8576
8553
  }, {
8577
8554
  key: "transferLocalNativeAsset",
@@ -9989,6 +9966,18 @@ var RELAY_LOCATION = {
9989
9966
  Here: null
9990
9967
  }
9991
9968
  };
9969
+ var AH_REQUIRES_FEE_ASSET_LOCS = [{
9970
+ parents: sdkCommon.Parents.ONE,
9971
+ interior: {
9972
+ X3: [{
9973
+ Parachain: 1000
9974
+ }, {
9975
+ PalletInstance: 50
9976
+ }, {
9977
+ GeneralIndex: 50000075
9978
+ }]
9979
+ }
9980
+ }];
9992
9981
  var ASSET_HUB_EXECUTION_FEE = 2200000000n; // 0.22 DOT
9993
9982
  var TX_CLIENT_TIMEOUT_MS = 20 * 60 * 1000; // 20 minutes
9994
9983
  var DRY_RUN_CLIENT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
@@ -10048,7 +10037,7 @@ var claimAssets = /*#__PURE__*/function () {
10048
10037
  while (1) switch (_context.n) {
10049
10038
  case 0:
10050
10039
  api = options.api, chain = options.chain, address = options.address;
10051
- validateAddress(address, chain);
10040
+ validateAddress(api, address, chain, true);
10052
10041
  _context.n = 1;
10053
10042
  return api.init(chain, TX_CLIENT_TIMEOUT_MS);
10054
10043
  case 1:
@@ -10089,7 +10078,7 @@ var dryRun = /*#__PURE__*/function () {
10089
10078
  while (1) switch (_context.p = _context.n) {
10090
10079
  case 0:
10091
10080
  api = options.api, senderAddress = options.senderAddress, origin = options.origin;
10092
- validateAddress(senderAddress, origin, false);
10081
+ validateAddress(api, senderAddress, origin, false);
10093
10082
  _context.n = 1;
10094
10083
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
10095
10084
  case 1:
@@ -10121,7 +10110,7 @@ var dryRunOrigin = /*#__PURE__*/function () {
10121
10110
  while (1) switch (_context.p = _context.n) {
10122
10111
  case 0:
10123
10112
  api = options.api, chain = options.chain, address = options.address;
10124
- validateAddress(address, chain, false);
10113
+ validateAddress(api, address, chain, false);
10125
10114
  _context.n = 1;
10126
10115
  return api.init(chain, DRY_RUN_CLIENT_TIMEOUT_MS);
10127
10116
  case 1:
@@ -11683,8 +11672,8 @@ var send = /*#__PURE__*/function () {
11683
11672
  api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, isAmountAll = options.isAmountAll;
11684
11673
  validateCurrency(currency, feeAsset);
11685
11674
  validateDestination(origin, destination);
11686
- validateDestinationAddress(address, destination);
11687
- if (senderAddress) validateAddress(senderAddress, origin, false);
11675
+ validateDestinationAddress(address, destination, api);
11676
+ if (senderAddress) validateAddress(api, senderAddress, origin, false);
11688
11677
  isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(origin, destination);
11689
11678
  assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
11690
11679
  validateAssetSpecifiers(assetCheckEnabled, currency);
@@ -12258,7 +12247,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12258
12247
  while (1) switch (_context2.p = _context2.n) {
12259
12248
  case 0:
12260
12249
  api = _ref.api, origin = _ref.origin, senderAddress = _ref.senderAddress, address = _ref.address, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder;
12261
- validateAddress(senderAddress, chain, false);
12250
+ validateAddress(api, senderAddress, chain, false);
12262
12251
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
12263
12252
  asset = assets.findAssetInfoOrThrow(chain, currency, null);
12264
12253
  destAsset = assets.findAssetOnDestOrThrow(origin, destination, currency);
@@ -12427,7 +12416,7 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
12427
12416
  while (1) switch (_context.n) {
12428
12417
  case 0:
12429
12418
  api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, buildTx = _ref.buildTx, feeAsset = _ref.feeAsset;
12430
- validateAddress(senderAddress, chain, false);
12419
+ validateAddress(api, senderAddress, chain, false);
12431
12420
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
12432
12421
  asset = assets.findAssetInfoOrThrow(chain, currency, null);
12433
12422
  amount = abstractDecimals(currency.amount, asset.decimals, api);
@@ -12737,11 +12726,12 @@ var createRefundInstruction = function createRefundInstruction(api, senderAddres
12737
12726
 
12738
12727
  var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, version) {
12739
12728
  var assets = [];
12729
+ var shouldLocalizeAndSort = sdkCommon.isRelayChain(chain) || chain.startsWith('AssetHub');
12740
12730
  if (!isDotAsset) {
12741
12731
  assets.push(createAsset(version, feeAmount, RELAY_LOCATION));
12742
12732
  }
12743
- assets.push(createAsset(version, asset.amount, sdkCommon.isRelayChain(chain) ? localizeLocation(chain, asset.location) : asset.location));
12744
- return assets;
12733
+ assets.push(createAsset(version, asset.amount, shouldLocalizeAndSort ? localizeLocation(chain, asset.location) : asset.location));
12734
+ return shouldLocalizeAndSort ? sortAssets(assets) : assets;
12745
12735
  };
12746
12736
  var DEFAULT_SYSTEM_ASSET_AMOUNT = '1';
12747
12737
  var resolveSystemAssetAmount = function resolveSystemAssetAmount(_ref, isForFeeCalc, fees) {
@@ -12928,7 +12918,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12928
12918
  }
12929
12919
  return _context.a(2, true);
12930
12920
  case 1:
12931
- validateAddress(address, destination);
12921
+ validateAddress(api, address, destination, true);
12932
12922
  if (!(origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama')) {
12933
12923
  _context.n = 2;
12934
12924
  break;
package/dist/index.d.ts CHANGED
@@ -1538,6 +1538,7 @@ interface IPolkadotApi<TApi, TRes> {
1538
1538
  * Convert a location to a chain account address using the runtime LocationToAccount API, if available.
1539
1539
  */
1540
1540
  convertLocationToAccount(location: TLocation): Promise<string | undefined>;
1541
+ validateSubstrateAddress(address: string): boolean;
1541
1542
  }
1542
1543
 
1543
1544
  declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
@@ -1851,7 +1852,6 @@ declare class HeimaPaseo<TApi, TRes> extends Heima<TApi, TRes> {
1851
1852
  declare class Hydration<TApi, TRes> extends Parachain<TApi, TRes> implements IXTokensTransfer, IPolkadotXCMTransfer {
1852
1853
  private static NATIVE_ASSET_ID;
1853
1854
  constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
1854
- transferToAssetHub<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): TRes;
1855
1855
  transferPolkadotXCM<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): Promise<TRes>;
1856
1856
  transferMoonbeamWhAsset<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
1857
1857
  transferXTokens<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
@@ -2377,7 +2377,7 @@ declare const handleToAhTeleport: <TApi, TRes>(origin: TParachain, input: TPolka
2377
2377
  declare const parseUnits: typeof parseUnits$1;
2378
2378
  declare const formatUnits: typeof formatUnits$1;
2379
2379
 
2380
- declare const validateAddress: (address: TAddress, chain: TChain, isDestination?: boolean) => void;
2380
+ declare const validateAddress: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: TAddress, chain: TChain, isDestination?: boolean) => void;
2381
2381
 
2382
2382
  export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatUnits, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
2383
2383
  export type { BuildHopInfoOptions, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderOptions, TBypassOptions, TChainConfig, TChainConfigMap, TChainWithApi, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignByAssetOptions, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TSwapConfig, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -4648,11 +4648,12 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
4648
4648
  return !(isMultipleAssets || hasOverriddenLocation);
4649
4649
  };
4650
4650
 
4651
- var validateAddress = function validateAddress(address, chain) {
4652
- var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4651
+ var validateAddress = function validateAddress(api, address, chain) {
4652
+ var isDestination = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
4653
4653
  if (isTLocation(address)) return;
4654
4654
  var isEvm = isChainEvm(chain);
4655
4655
  var isEthereumAddress = isAddress(address);
4656
+ var isPublicKeyFormat = typeof address === 'string' && address.startsWith('0x') && !isEthereumAddress;
4656
4657
  if (isEvm) {
4657
4658
  if (!isEthereumAddress) {
4658
4659
  throw new InvalidAddressError("".concat(isDestination ? 'Destination chain' : 'Chain', " is an EVM chain, but the address provided is not a valid Ethereum address."));
@@ -4661,12 +4662,21 @@ var validateAddress = function validateAddress(address, chain) {
4661
4662
  if (isEthereumAddress) {
4662
4663
  throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "chain is not an EVM chain."));
4663
4664
  }
4665
+ if (isPublicKeyFormat) {
4666
+ return;
4667
+ }
4668
+ if (typeof address === 'string') {
4669
+ var isValid = api.validateSubstrateAddress(address);
4670
+ if (!isValid) {
4671
+ throw new InvalidAddressError("Invalid address: ".concat(address));
4672
+ }
4673
+ }
4664
4674
  }
4665
4675
  };
4666
4676
 
4667
- var validateDestinationAddress = function validateDestinationAddress(address, destination) {
4677
+ var validateDestinationAddress = function validateDestinationAddress(address, destination, api) {
4668
4678
  if (typeof address === 'string' && !isTLocation(destination)) {
4669
- validateAddress(address, destination);
4679
+ validateAddress(api, address, destination, true);
4670
4680
  }
4671
4681
  };
4672
4682
 
@@ -7509,7 +7519,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7509
7519
  key: "transferPolkadotXCM",
7510
7520
  value: function () {
7511
7521
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
7512
- var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call, method, modifiedInput, _t, _t2;
7522
+ var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, requiresTypeThen, _call, method, modifiedInput, _t, _t2;
7513
7523
  return _regenerator().w(function (_context3) {
7514
7524
  while (1) switch (_context3.n) {
7515
7525
  case 0:
@@ -7559,7 +7569,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7559
7569
  return _context3.a(2, this.handleMythosTransfer(options));
7560
7570
  case 7:
7561
7571
  isExternalAsset = assetInfo.location && assetInfo.location.parents === Parents.TWO;
7562
- if (!isExternalAsset) {
7572
+ requiresTypeThen = AH_REQUIRES_FEE_ASSET_LOCS.some(function (loc) {
7573
+ return deepEqual(loc, assetInfo.location);
7574
+ });
7575
+ if (!(isExternalAsset || requiresTypeThen)) {
7563
7576
  _context3.n = 9;
7564
7577
  break;
7565
7578
  }
@@ -8434,24 +8447,6 @@ var HeimaPaseo = /*#__PURE__*/function (_Heima) {
8434
8447
  return _createClass(HeimaPaseo);
8435
8448
  }(Heima);
8436
8449
 
8437
- var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
8438
- var api = _ref.api,
8439
- address = _ref.address;
8440
- return _defineProperty({}, version, [{
8441
- DepositAsset: {
8442
- assets: {
8443
- Wild: {
8444
- AllCounted: 2
8445
- }
8446
- },
8447
- beneficiary: createBeneficiaryLocation({
8448
- api: api,
8449
- address: address,
8450
- version: version
8451
- })
8452
- }
8453
- }]);
8454
- };
8455
8450
  var Hydration = /*#__PURE__*/function (_Parachain) {
8456
8451
  function Hydration() {
8457
8452
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Hydration';
@@ -8463,35 +8458,10 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8463
8458
  }
8464
8459
  _inherits(Hydration, _Parachain);
8465
8460
  return _createClass(Hydration, [{
8466
- key: "transferToAssetHub",
8467
- value: function transferToAssetHub(input) {
8468
- var api = input.api,
8469
- asset = input.assetInfo,
8470
- version = input.version,
8471
- destination = input.destination;
8472
- var call = {
8473
- module: 'PolkadotXcm',
8474
- method: 'transfer_assets_using_type_and_then',
8475
- parameters: {
8476
- dest: createVersionedDestination(version, this.chain, destination, getParaId('AssetHubPolkadot')),
8477
- assets: _defineProperty({}, version, [createAsset(version, asset.amount, DOT_LOCATION)]),
8478
- assets_transfer_type: 'DestinationReserve',
8479
- remote_fees_id: _defineProperty({}, version, {
8480
- parents: Parents.ONE,
8481
- interior: 'Here'
8482
- }),
8483
- fees_transfer_type: 'DestinationReserve',
8484
- custom_xcm_on_dest: createCustomXcmAh(input, version),
8485
- weight_limit: 'Unlimited'
8486
- }
8487
- };
8488
- return api.callTxMethod(call);
8489
- }
8490
- }, {
8491
8461
  key: "transferPolkadotXCM",
8492
8462
  value: function () {
8493
8463
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
8494
- var api, destination, feeAsset, asset, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t;
8464
+ var api, destination, feeAsset, asset, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t, _t2;
8495
8465
  return _regenerator().w(function (_context) {
8496
8466
  while (1) switch (_context.n) {
8497
8467
  case 0:
@@ -8524,7 +8494,11 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8524
8494
  case 3:
8525
8495
  return _context.a(2, _t.callTxMethod.call(_t, _context.v));
8526
8496
  case 4:
8527
- return _context.a(2, this.transferToAssetHub(input));
8497
+ _t2 = api;
8498
+ _context.n = 5;
8499
+ return createTypeAndThenCall(this.chain, input);
8500
+ case 5:
8501
+ return _context.a(2, _t2.callTxMethod.call(_t2, _context.v));
8528
8502
  }
8529
8503
  }, _callee, this);
8530
8504
  }));
@@ -8572,7 +8546,10 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8572
8546
  assetInfo = options.assetInfo,
8573
8547
  feeAsset = options.feeAsset;
8574
8548
  var baseCanUseXTokens = _superPropGet(Hydration, "canUseXTokens", this, 3)([options]);
8575
- return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && assetInfo.symbol === 'DOT') && baseCanUseXTokens && !feeAsset;
8549
+ var requiresTypeThen = AH_REQUIRES_FEE_ASSET_LOCS.some(function (loc) {
8550
+ return deepEqual(loc, assetInfo.location);
8551
+ });
8552
+ return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && assetInfo.symbol === 'DOT') && baseCanUseXTokens && !feeAsset && !requiresTypeThen;
8576
8553
  }
8577
8554
  }, {
8578
8555
  key: "transferLocalNativeAsset",
@@ -9990,6 +9967,18 @@ var RELAY_LOCATION = {
9990
9967
  Here: null
9991
9968
  }
9992
9969
  };
9970
+ var AH_REQUIRES_FEE_ASSET_LOCS = [{
9971
+ parents: Parents.ONE,
9972
+ interior: {
9973
+ X3: [{
9974
+ Parachain: 1000
9975
+ }, {
9976
+ PalletInstance: 50
9977
+ }, {
9978
+ GeneralIndex: 50000075
9979
+ }]
9980
+ }
9981
+ }];
9993
9982
  var ASSET_HUB_EXECUTION_FEE = 2200000000n; // 0.22 DOT
9994
9983
  var TX_CLIENT_TIMEOUT_MS = 20 * 60 * 1000; // 20 minutes
9995
9984
  var DRY_RUN_CLIENT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
@@ -10049,7 +10038,7 @@ var claimAssets = /*#__PURE__*/function () {
10049
10038
  while (1) switch (_context.n) {
10050
10039
  case 0:
10051
10040
  api = options.api, chain = options.chain, address = options.address;
10052
- validateAddress(address, chain);
10041
+ validateAddress(api, address, chain, true);
10053
10042
  _context.n = 1;
10054
10043
  return api.init(chain, TX_CLIENT_TIMEOUT_MS);
10055
10044
  case 1:
@@ -10090,7 +10079,7 @@ var dryRun = /*#__PURE__*/function () {
10090
10079
  while (1) switch (_context.p = _context.n) {
10091
10080
  case 0:
10092
10081
  api = options.api, senderAddress = options.senderAddress, origin = options.origin;
10093
- validateAddress(senderAddress, origin, false);
10082
+ validateAddress(api, senderAddress, origin, false);
10094
10083
  _context.n = 1;
10095
10084
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
10096
10085
  case 1:
@@ -10122,7 +10111,7 @@ var dryRunOrigin = /*#__PURE__*/function () {
10122
10111
  while (1) switch (_context.p = _context.n) {
10123
10112
  case 0:
10124
10113
  api = options.api, chain = options.chain, address = options.address;
10125
- validateAddress(address, chain, false);
10114
+ validateAddress(api, address, chain, false);
10126
10115
  _context.n = 1;
10127
10116
  return api.init(chain, DRY_RUN_CLIENT_TIMEOUT_MS);
10128
10117
  case 1:
@@ -11684,8 +11673,8 @@ var send = /*#__PURE__*/function () {
11684
11673
  api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, isAmountAll = options.isAmountAll;
11685
11674
  validateCurrency(currency, feeAsset);
11686
11675
  validateDestination(origin, destination);
11687
- validateDestinationAddress(address, destination);
11688
- if (senderAddress) validateAddress(senderAddress, origin, false);
11676
+ validateDestinationAddress(address, destination, api);
11677
+ if (senderAddress) validateAddress(api, senderAddress, origin, false);
11689
11678
  isBridge = !isTLocation(destination) && isSubstrateBridge(origin, destination);
11690
11679
  assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
11691
11680
  validateAssetSpecifiers(assetCheckEnabled, currency);
@@ -12259,7 +12248,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12259
12248
  while (1) switch (_context2.p = _context2.n) {
12260
12249
  case 0:
12261
12250
  api = _ref.api, origin = _ref.origin, senderAddress = _ref.senderAddress, address = _ref.address, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder;
12262
- validateAddress(senderAddress, chain, false);
12251
+ validateAddress(api, senderAddress, chain, false);
12263
12252
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
12264
12253
  asset = findAssetInfoOrThrow(chain, currency, null);
12265
12254
  destAsset = findAssetOnDestOrThrow(origin, destination, currency);
@@ -12428,7 +12417,7 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
12428
12417
  while (1) switch (_context.n) {
12429
12418
  case 0:
12430
12419
  api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, buildTx = _ref.buildTx, feeAsset = _ref.feeAsset;
12431
- validateAddress(senderAddress, chain, false);
12420
+ validateAddress(api, senderAddress, chain, false);
12432
12421
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
12433
12422
  asset = findAssetInfoOrThrow(chain, currency, null);
12434
12423
  amount = abstractDecimals(currency.amount, asset.decimals, api);
@@ -12738,11 +12727,12 @@ var createRefundInstruction = function createRefundInstruction(api, senderAddres
12738
12727
 
12739
12728
  var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, version) {
12740
12729
  var assets = [];
12730
+ var shouldLocalizeAndSort = isRelayChain(chain) || chain.startsWith('AssetHub');
12741
12731
  if (!isDotAsset) {
12742
12732
  assets.push(createAsset(version, feeAmount, RELAY_LOCATION));
12743
12733
  }
12744
- assets.push(createAsset(version, asset.amount, isRelayChain(chain) ? localizeLocation(chain, asset.location) : asset.location));
12745
- return assets;
12734
+ assets.push(createAsset(version, asset.amount, shouldLocalizeAndSort ? localizeLocation(chain, asset.location) : asset.location));
12735
+ return shouldLocalizeAndSort ? sortAssets(assets) : assets;
12746
12736
  };
12747
12737
  var DEFAULT_SYSTEM_ASSET_AMOUNT = '1';
12748
12738
  var resolveSystemAssetAmount = function resolveSystemAssetAmount(_ref, isForFeeCalc, fees) {
@@ -12929,7 +12919,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12929
12919
  }
12930
12920
  return _context.a(2, true);
12931
12921
  case 1:
12932
- validateAddress(address, destination);
12922
+ validateAddress(api, address, destination, true);
12933
12923
  if (!(origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama')) {
12934
12924
  _context.n = 2;
12935
12925
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "11.14.3",
3
+ "version": "11.14.4",
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": "^1.8.0",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "^2.38.5",
29
- "@paraspell/assets": "11.14.3",
30
- "@paraspell/sdk-common": "11.14.3",
31
- "@paraspell/pallets": "11.14.3"
29
+ "@paraspell/assets": "11.14.4",
30
+ "@paraspell/sdk-common": "11.14.4",
31
+ "@paraspell/pallets": "11.14.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",