@paraspell/sdk-core 9.1.2 → 9.2.1

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
@@ -733,6 +733,18 @@ var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
733
733
  return _createClass(ScenarioNotSupportedError);
734
734
  }(/*#__PURE__*/_wrapNativeSuper(Error));
735
735
 
736
+ var TransferToAhNotSupported = /*#__PURE__*/function (_Error) {
737
+ function TransferToAhNotSupported(message) {
738
+ var _this;
739
+ _classCallCheck(this, TransferToAhNotSupported);
740
+ _this = _callSuper(this, TransferToAhNotSupported, [message]);
741
+ _this.name = 'TransferToAhNotSupported';
742
+ return _this;
743
+ }
744
+ _inherits(TransferToAhNotSupported, _Error);
745
+ return _createClass(TransferToAhNotSupported);
746
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
747
+
736
748
  // Inspired by Talisman Society’s SS58 encoder:
737
749
  // https://github.com/TalismanSociety/talisman/blob/dev/packages/crypto/src/address/encoding/ss58.ts
738
750
  var blake2b256 = function blake2b256(msg) {
@@ -3976,49 +3988,52 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
3976
3988
  while (1) switch (_context.prev = _context.next) {
3977
3989
  case 0:
3978
3990
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback;
3991
+ _context.next = 3;
3992
+ return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
3993
+ case 3:
3979
3994
  if (assets.hasDryRunSupport(origin)) {
3980
- _context.next = 6;
3995
+ _context.next = 8;
3981
3996
  break;
3982
3997
  }
3983
- _context.next = 4;
3998
+ _context.next = 6;
3984
3999
  return api.calculateTransactionFee(tx, senderAddress);
3985
- case 4:
4000
+ case 6:
3986
4001
  rawFee = _context.sent;
3987
4002
  return _context.abrupt("return", {
3988
4003
  fee: padFee(rawFee, origin, destination, 'origin'),
3989
4004
  feeType: 'paymentInfo'
3990
4005
  });
3991
- case 6:
3992
- _context.next = 8;
4006
+ case 8:
4007
+ _context.next = 10;
3993
4008
  return api.getDryRunCall({
3994
4009
  tx: tx,
3995
4010
  node: origin,
3996
4011
  address: senderAddress
3997
4012
  });
3998
- case 8:
4013
+ case 10:
3999
4014
  dryRunResult = _context.sent;
4000
4015
  if (dryRunResult.success) {
4001
- _context.next = 16;
4016
+ _context.next = 18;
4002
4017
  break;
4003
4018
  }
4004
4019
  if (!disableFallback) {
4005
- _context.next = 12;
4020
+ _context.next = 14;
4006
4021
  break;
4007
4022
  }
4008
4023
  return _context.abrupt("return", {
4009
4024
  dryRunError: dryRunResult.failureReason
4010
4025
  });
4011
- case 12:
4012
- _context.next = 14;
4013
- return api.calculateTransactionFee(tx, senderAddress);
4014
4026
  case 14:
4027
+ _context.next = 16;
4028
+ return api.calculateTransactionFee(tx, senderAddress);
4029
+ case 16:
4015
4030
  _rawFee = _context.sent;
4016
4031
  return _context.abrupt("return", {
4017
4032
  fee: padFee(_rawFee, origin, destination, 'origin'),
4018
4033
  feeType: 'paymentInfo',
4019
4034
  dryRunError: dryRunResult.failureReason
4020
4035
  });
4021
- case 16:
4036
+ case 18:
4022
4037
  fee = dryRunResult.fee, forwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
4023
4038
  return _context.abrupt("return", {
4024
4039
  fee: fee,
@@ -4026,7 +4041,7 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
4026
4041
  forwardedXcms: forwardedXcms,
4027
4042
  destParaId: destParaId
4028
4043
  });
4029
- case 18:
4044
+ case 20:
4030
4045
  case "end":
4031
4046
  return _context.stop();
4032
4047
  }
@@ -4040,7 +4055,7 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
4040
4055
  var getXcmFee = /*#__PURE__*/function () {
4041
4056
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4042
4057
  var _findAsset;
4043
- var api, tx, origin, destination, senderAddress, address, currency, disableFallback, asset, _yield$getFeeForOrigi, originFee, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFee, _destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4058
+ var api, tx, origin, destination, senderAddress, address, currency, disableFallback, asset, _yield$getFeeForOrigi, originFee, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4044
4059
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4045
4060
  while (1) switch (_context.prev = _context.next) {
4046
4061
  case 0:
@@ -4068,14 +4083,14 @@ var getXcmFee = /*#__PURE__*/function () {
4068
4083
  originDryRunError = _yield$getFeeForOrigi.dryRunError;
4069
4084
  initialForwardedXcm = _yield$getFeeForOrigi.forwardedXcms;
4070
4085
  initialDestParaId = _yield$getFeeForOrigi.destParaId;
4071
- if (!(origin === 'AssetHubKusama' && destination === 'Kusama')) {
4086
+ api.setDisconnectAllowed(true);
4087
+ _context.next = 15;
4088
+ return api.disconnect();
4089
+ case 15:
4090
+ if (!(originDryRunError || originFeeType === 'paymentInfo')) {
4072
4091
  _context.next = 30;
4073
4092
  break;
4074
4093
  }
4075
- api.setDisconnectAllowed(true);
4076
- _context.next = 16;
4077
- return api.disconnect();
4078
- case 16:
4079
4094
  destApi = api.clone();
4080
4095
  _context.prev = 17;
4081
4096
  _context.next = 20;
@@ -4086,6 +4101,7 @@ var getXcmFee = /*#__PURE__*/function () {
4086
4101
  return getFeeForDestNode({
4087
4102
  api: destApi,
4088
4103
  forwardedXcms: undefined,
4104
+ // force paymentInfo
4089
4105
  origin: origin,
4090
4106
  destination: destination,
4091
4107
  currency: currency,
@@ -4094,7 +4110,7 @@ var getXcmFee = /*#__PURE__*/function () {
4094
4110
  disableFallback: disableFallback
4095
4111
  });
4096
4112
  case 23:
4097
- destFee = _context.sent;
4113
+ destFeeRes = _context.sent;
4098
4114
  return _context.abrupt("return", {
4099
4115
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4100
4116
  fee: originFee
@@ -4105,10 +4121,10 @@ var getXcmFee = /*#__PURE__*/function () {
4105
4121
  }, originDryRunError && {
4106
4122
  dryRunError: originDryRunError
4107
4123
  }),
4108
- destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFee.fee && {
4109
- fee: destFee.fee
4110
- }), destFee.feeType && {
4111
- feeType: destFee.feeType
4124
+ destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFeeRes.fee && {
4125
+ fee: destFeeRes.fee
4126
+ }), destFeeRes.feeType && {
4127
+ feeType: destFeeRes.feeType
4112
4128
  }), {}, {
4113
4129
  currency: assets.getNativeAssetSymbol(destination)
4114
4130
  })
@@ -4121,83 +4137,30 @@ var getXcmFee = /*#__PURE__*/function () {
4121
4137
  case 29:
4122
4138
  return _context.finish(25);
4123
4139
  case 30:
4124
- api.setDisconnectAllowed(true);
4125
- _context.next = 33;
4126
- return api.disconnect();
4127
- case 33:
4128
- if (!originDryRunError) {
4129
- _context.next = 48;
4130
- break;
4131
- }
4132
- _destApi = api.clone();
4133
- _context.prev = 35;
4134
- _context.next = 38;
4135
- return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
4136
- case 38:
4137
- _destApi.setDisconnectAllowed(false);
4138
- _context.next = 41;
4139
- return getFeeForDestNode({
4140
- api: _destApi,
4141
- forwardedXcms: undefined,
4142
- // force paymentInfo
4143
- origin: origin,
4144
- destination: destination,
4145
- currency: currency,
4146
- address: address,
4147
- senderAddress: senderAddress,
4148
- disableFallback: disableFallback
4149
- });
4150
- case 41:
4151
- destFeeRes = _context.sent;
4152
- return _context.abrupt("return", {
4153
- origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4154
- fee: originFee
4155
- }), originFeeType && {
4156
- feeType: originFeeType
4157
- }), {}, {
4158
- currency: assets.getNativeAssetSymbol(origin),
4159
- dryRunError: originDryRunError
4160
- }),
4161
- destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFeeRes.fee && {
4162
- fee: destFeeRes.fee
4163
- }), destFeeRes.feeType && {
4164
- feeType: destFeeRes.feeType
4165
- }), {}, {
4166
- currency: assets.getNativeAssetSymbol(destination)
4167
- })
4168
- });
4169
- case 43:
4170
- _context.prev = 43;
4171
- _destApi.setDisconnectAllowed(true);
4172
- _context.next = 47;
4173
- return _destApi.disconnect();
4174
- case 47:
4175
- return _context.finish(43);
4176
- case 48:
4177
4140
  currentOrigin = origin;
4178
4141
  forwardedXcms = initialForwardedXcm;
4179
4142
  nextParaId = initialDestParaId;
4180
4143
  intermediateFees = {};
4181
4144
  destinationFee = 0n;
4182
4145
  destinationFeeType = 'paymentInfo';
4183
- case 54:
4146
+ case 36:
4184
4147
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
4185
- _context.next = 86;
4148
+ _context.next = 68;
4186
4149
  break;
4187
4150
  }
4188
4151
  nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
4189
4152
  if (!(nextChain === null)) {
4190
- _context.next = 58;
4153
+ _context.next = 40;
4191
4154
  break;
4192
4155
  }
4193
4156
  throw new Error("Unable to find TNode for paraId ".concat(nextParaId));
4194
- case 58:
4157
+ case 40:
4195
4158
  hopApi = api.clone();
4196
- _context.prev = 59;
4197
- _context.next = 62;
4159
+ _context.prev = 41;
4160
+ _context.next = 44;
4198
4161
  return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
4199
- case 62:
4200
- _context.next = 64;
4162
+ case 44:
4163
+ _context.next = 46;
4201
4164
  return getFeeForDestNode({
4202
4165
  api: hopApi,
4203
4166
  forwardedXcms: forwardedXcms,
@@ -4208,10 +4171,10 @@ var getXcmFee = /*#__PURE__*/function () {
4208
4171
  senderAddress: senderAddress,
4209
4172
  disableFallback: disableFallback
4210
4173
  });
4211
- case 64:
4174
+ case 46:
4212
4175
  hopResult = _context.sent;
4213
4176
  if (!hopResult.dryRunError) {
4214
- _context.next = 76;
4177
+ _context.next = 58;
4215
4178
  break;
4216
4179
  }
4217
4180
  failingRecord = {
@@ -4232,10 +4195,10 @@ var getXcmFee = /*#__PURE__*/function () {
4232
4195
  }
4233
4196
  // We failed before the true destination, use fallback via paymentInfo.
4234
4197
  if (hopIsDestination) {
4235
- _context.next = 75;
4198
+ _context.next = 57;
4236
4199
  break;
4237
4200
  }
4238
- _context.next = 72;
4201
+ _context.next = 54;
4239
4202
  return getFeeForDestNode({
4240
4203
  api: hopApi,
4241
4204
  forwardedXcms: undefined,
@@ -4246,13 +4209,13 @@ var getXcmFee = /*#__PURE__*/function () {
4246
4209
  senderAddress: senderAddress,
4247
4210
  disableFallback: disableFallback
4248
4211
  });
4249
- case 72:
4212
+ case 54:
4250
4213
  destFallback = _context.sent;
4251
4214
  destinationFee = destFallback.fee;
4252
4215
  destinationFeeType = destFallback.feeType;
4253
- case 75:
4254
- return _context.abrupt("break", 86);
4255
- case 76:
4216
+ case 57:
4217
+ return _context.abrupt("break", 68);
4218
+ case 58:
4256
4219
  if (nextChain === destination || sdkCommon.isRelayChain(nextChain) && !sdkCommon.isRelayChain(destination)) {
4257
4220
  destinationFee = hopResult.fee;
4258
4221
  destinationFeeType = hopResult.feeType;
@@ -4272,16 +4235,16 @@ var getXcmFee = /*#__PURE__*/function () {
4272
4235
  forwardedXcms = hopResult.forwardedXcms;
4273
4236
  nextParaId = hopResult.destParaId;
4274
4237
  currentOrigin = nextChain;
4275
- case 80:
4276
- _context.prev = 80;
4277
- _context.next = 83;
4238
+ case 62:
4239
+ _context.prev = 62;
4240
+ _context.next = 65;
4278
4241
  return hopApi.disconnect();
4279
- case 83:
4280
- return _context.finish(80);
4281
- case 84:
4282
- _context.next = 54;
4242
+ case 65:
4243
+ return _context.finish(62);
4244
+ case 66:
4245
+ _context.next = 36;
4283
4246
  break;
4284
- case 86:
4247
+ case 68:
4285
4248
  return _context.abrupt("return", _objectSpread2(_objectSpread2({
4286
4249
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4287
4250
  fee: originFee
@@ -4303,11 +4266,11 @@ var getXcmFee = /*#__PURE__*/function () {
4303
4266
  dryRunError: destinationDryRunError
4304
4267
  })
4305
4268
  }));
4306
- case 87:
4269
+ case 69:
4307
4270
  case "end":
4308
4271
  return _context.stop();
4309
4272
  }
4310
- }, _callee, null, [[17,, 25, 30], [35,, 43, 48], [59,, 80, 84]]);
4273
+ }, _callee, null, [[17,, 25, 30], [41,, 62, 66]]);
4311
4274
  }));
4312
4275
  return function getXcmFee(_x) {
4313
4276
  return _ref2.apply(this, arguments);
@@ -4475,70 +4438,17 @@ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, cu
4475
4438
  return asset !== null && asset !== void 0 ? asset : undefined;
4476
4439
  };
4477
4440
 
4478
- var validateCurrency = function validateCurrency(currency, feeAsset) {
4479
- if ('multiasset' in currency) {
4480
- if (currency.multiasset.length === 0) {
4481
- throw new assets.InvalidCurrencyError('Overridden multi assets cannot be empty');
4482
- }
4483
- if (currency.multiasset.length === 1) {
4484
- throw new assets.InvalidCurrencyError('Please provide more than one multi asset');
4485
- }
4486
- if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
4487
- return assets.isTMultiAsset(asset);
4488
- }) && !feeAsset) {
4489
- throw new assets.InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
4490
- }
4491
- }
4492
- };
4493
- var validateDestination = function validateDestination(origin, destination) {
4494
- if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
4495
- throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4496
- }
4497
- if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration' && origin !== 'BifrostPolkadot' && origin !== 'Moonbeam') {
4498
- throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
4499
- }
4500
- var isMultiLocationDestination = _typeof(destination) === 'object';
4501
- var isBridge = isBridgeTransfer(origin, destination);
4502
- var isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
4503
- if (!isRelayDestination && !isMultiLocationDestination) {
4504
- var originRelayChainSymbol = assets.getRelayChainSymbol(origin);
4505
- var destinationRelayChainSymbol = assets.getRelayChainSymbol(destination);
4506
- if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
4507
- throw new IncompatibleNodesError();
4508
- }
4509
- }
4510
- };
4511
- var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4512
- if (!assetCheckEnabled && 'symbol' in currency && assets.isSymbolSpecifier(currency.symbol)) {
4513
- throw new assets.InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4514
- }
4515
- if (!assetCheckEnabled && 'id' in currency) {
4516
- throw new assets.InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4517
- }
4518
- };
4519
4441
  var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
4520
4442
  var origin = _ref.from,
4521
4443
  destination = _ref.to,
4522
4444
  currency = _ref.currency;
4523
- var isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
4524
- var isMultiLocationDestination = _typeof(destination) === 'object';
4525
4445
  var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
4526
- var pallet = pallets.getDefaultPallet(origin);
4527
- var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
4528
- if (!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost) {
4529
- var nativeAssets = assets.getNativeAssets(destination);
4530
- if (origin === 'Hydration') {
4531
- nativeAssets = nativeAssets.filter(function (nativeAsset) {
4532
- return nativeAsset.symbol !== 'DOT';
4533
- });
4534
- }
4535
- if ('symbol' in currency && nativeAssets.some(function (nativeAsset) {
4536
- var _asset$symbol;
4537
- return nativeAsset.symbol.toLowerCase() === (asset === null || asset === void 0 || (_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase());
4538
- })) {
4539
- throw new assets.InvalidCurrencyError("".concat(JSON.stringify(asset === null || asset === void 0 ? void 0 : asset.symbol), " is not supported for transfers to ").concat(destination, "."));
4540
- }
4446
+ var allowedChainsToAh = ['BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec'];
4447
+ if (!sdkCommon.isRelayChain(origin) && !isBridge && isDestAssetHub && !allowedChainsToAh.includes(origin) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
4448
+ throw new TransferToAhNotSupported("Node ".concat(origin, " does not support DOT transfer to AssetHub"));
4541
4449
  }
4450
+ var isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
4451
+ var isMultiLocationDestination = _typeof(destination) === 'object';
4542
4452
  if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !assets.hasSupportForAsset(destination, asset.symbol)) {
4543
4453
  throw new assets.InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
4544
4454
  }
@@ -4618,6 +4528,49 @@ var validateDestinationAddress = function validateDestinationAddress(address, de
4618
4528
  }
4619
4529
  };
4620
4530
 
4531
+ var validateCurrency = function validateCurrency(currency, feeAsset) {
4532
+ if ('multiasset' in currency) {
4533
+ if (currency.multiasset.length === 0) {
4534
+ throw new assets.InvalidCurrencyError('Overridden multi assets cannot be empty');
4535
+ }
4536
+ if (currency.multiasset.length === 1) {
4537
+ throw new assets.InvalidCurrencyError('Please provide more than one multi asset');
4538
+ }
4539
+ if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
4540
+ return assets.isTMultiAsset(asset);
4541
+ }) && !feeAsset) {
4542
+ throw new assets.InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
4543
+ }
4544
+ }
4545
+ };
4546
+ var validateDestination = function validateDestination(origin, destination) {
4547
+ if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
4548
+ throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4549
+ }
4550
+ var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
4551
+ if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
4552
+ throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
4553
+ }
4554
+ var isMultiLocationDestination = _typeof(destination) === 'object';
4555
+ var isBridge = isBridgeTransfer(origin, destination);
4556
+ var isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
4557
+ if (!isRelayDestination && !isMultiLocationDestination) {
4558
+ var originRelayChainSymbol = assets.getRelayChainSymbol(origin);
4559
+ var destinationRelayChainSymbol = assets.getRelayChainSymbol(destination);
4560
+ if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
4561
+ throw new IncompatibleNodesError();
4562
+ }
4563
+ }
4564
+ };
4565
+ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4566
+ if (!assetCheckEnabled && 'symbol' in currency && assets.isSymbolSpecifier(currency.symbol)) {
4567
+ throw new assets.InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4568
+ }
4569
+ if (!assetCheckEnabled && 'id' in currency) {
4570
+ throw new assets.InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4571
+ }
4572
+ };
4573
+
4621
4574
  var send = /*#__PURE__*/function () {
4622
4575
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
4623
4576
  var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, isLocalTransfer, overriddenAsset, resolvedAsset, originNode;
@@ -9730,6 +9683,7 @@ exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
9730
9683
  exports.NodeNotSupportedError = NodeNotSupportedError;
9731
9684
  exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
9732
9685
  exports.TX_CLIENT_TIMEOUT_MS = TX_CLIENT_TIMEOUT_MS;
9686
+ exports.TransferToAhNotSupported = TransferToAhNotSupported;
9733
9687
  exports.blake2b256 = blake2b256;
9734
9688
  exports.blake2b512 = blake2b512;
9735
9689
  exports.claimAssets = claimAssets;
@@ -9753,6 +9707,7 @@ exports.getBalanceForeignInternal = getBalanceForeignInternal;
9753
9707
  exports.getBalanceNative = getBalanceNative;
9754
9708
  exports.getBalanceNativeInternal = getBalanceNativeInternal;
9755
9709
  exports.getBridgeStatus = getBridgeStatus;
9710
+ exports.getFeeForOriginNode = getFeeForOriginNode;
9756
9711
  exports.getFees = getFees;
9757
9712
  exports.getMaxForeignTransferableAmount = getMaxForeignTransferableAmount;
9758
9713
  exports.getMaxForeignTransferableAmountInternal = getMaxForeignTransferableAmountInternal;
package/dist/index.d.ts CHANGED
@@ -1639,6 +1639,10 @@ declare class ScenarioNotSupportedError extends Error {
1639
1639
  constructor(node: TNode, scenario: TScenario, message?: string);
1640
1640
  }
1641
1641
 
1642
+ declare class TransferToAhNotSupported extends Error {
1643
+ constructor(message?: string);
1644
+ }
1645
+
1642
1646
  declare const getNodeConfig: (node: TNodeDotKsmWithRelayChains) => TNodeConfig;
1643
1647
 
1644
1648
  declare const getNodeProviders: (node: TNodeDotKsmWithRelayChains) => string[];
@@ -1697,6 +1701,14 @@ declare const transferMoonbeamToEth: <TApi, TRes>({ api, from, to, signer, addre
1697
1701
  declare const isEthersSigner: (signer: Signer | WalletClient) => signer is Signer;
1698
1702
  declare const isEthersContract: (contract: Contract | GetContractReturnType<Abi | readonly unknown[]>) => contract is Contract;
1699
1703
 
1704
+ declare const getFeeForOriginNode: <TApi, TRes>({ api, tx, origin, destination, senderAddress, disableFallback }: TGetFeeForOriginNodeOptions<TApi, TRes>) => Promise<{
1705
+ fee?: bigint;
1706
+ feeType?: TFeeType;
1707
+ dryRunError?: string;
1708
+ forwardedXcms?: any;
1709
+ destParaId?: number;
1710
+ }>;
1711
+
1700
1712
  declare const getXcmFee: <TApi, TRes>({ api, tx, origin, destination, senderAddress, address, currency, disableFallback }: TGetXcmFeeOptions<TApi, TRes>) => Promise<TGetXcmFeeResult>;
1701
1713
 
1702
1714
  declare const getXcmFeeEstimate: <TApi, TRes>({ api, tx, origin, destination, address, senderAddress, currency }: TGetXcmFeeEstimateOptions<TApi, TRes>) => Promise<TGetXcmFeeEstimateResult>;
@@ -1756,5 +1768,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
1756
1768
  */
1757
1769
  declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
1758
1770
 
1759
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1771
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFeeForOriginNode, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1760
1772
  export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetFeeForOriginNodeBaseOptions, TGetFeeForOriginNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmSection, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TVersionClaimAssets, TWeight, TXTokensCurrencySelection, TXTokensSection, TXTokensTransferOptions, TXTransferSection, TXTransferTransferOptions, TXcmAsset, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletSection, TXcmVersioned, TZeitgeistAsset, WithApi };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, hasDryRunSupport, findAsset, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, isSymbolSpecifier, getNativeAssets, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, getAssetId, getExistentialDeposit } from '@paraspell/assets';
2
+ import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, hasDryRunSupport, findAsset, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, isSymbolSpecifier, getAssetId, getExistentialDeposit } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { ethers, Contract } from 'ethers';
@@ -734,6 +734,18 @@ var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
734
734
  return _createClass(ScenarioNotSupportedError);
735
735
  }(/*#__PURE__*/_wrapNativeSuper(Error));
736
736
 
737
+ var TransferToAhNotSupported = /*#__PURE__*/function (_Error) {
738
+ function TransferToAhNotSupported(message) {
739
+ var _this;
740
+ _classCallCheck(this, TransferToAhNotSupported);
741
+ _this = _callSuper(this, TransferToAhNotSupported, [message]);
742
+ _this.name = 'TransferToAhNotSupported';
743
+ return _this;
744
+ }
745
+ _inherits(TransferToAhNotSupported, _Error);
746
+ return _createClass(TransferToAhNotSupported);
747
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
748
+
737
749
  // Inspired by Talisman Society’s SS58 encoder:
738
750
  // https://github.com/TalismanSociety/talisman/blob/dev/packages/crypto/src/address/encoding/ss58.ts
739
751
  var blake2b256 = function blake2b256(msg) {
@@ -3977,49 +3989,52 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
3977
3989
  while (1) switch (_context.prev = _context.next) {
3978
3990
  case 0:
3979
3991
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback;
3992
+ _context.next = 3;
3993
+ return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
3994
+ case 3:
3980
3995
  if (hasDryRunSupport(origin)) {
3981
- _context.next = 6;
3996
+ _context.next = 8;
3982
3997
  break;
3983
3998
  }
3984
- _context.next = 4;
3999
+ _context.next = 6;
3985
4000
  return api.calculateTransactionFee(tx, senderAddress);
3986
- case 4:
4001
+ case 6:
3987
4002
  rawFee = _context.sent;
3988
4003
  return _context.abrupt("return", {
3989
4004
  fee: padFee(rawFee, origin, destination, 'origin'),
3990
4005
  feeType: 'paymentInfo'
3991
4006
  });
3992
- case 6:
3993
- _context.next = 8;
4007
+ case 8:
4008
+ _context.next = 10;
3994
4009
  return api.getDryRunCall({
3995
4010
  tx: tx,
3996
4011
  node: origin,
3997
4012
  address: senderAddress
3998
4013
  });
3999
- case 8:
4014
+ case 10:
4000
4015
  dryRunResult = _context.sent;
4001
4016
  if (dryRunResult.success) {
4002
- _context.next = 16;
4017
+ _context.next = 18;
4003
4018
  break;
4004
4019
  }
4005
4020
  if (!disableFallback) {
4006
- _context.next = 12;
4021
+ _context.next = 14;
4007
4022
  break;
4008
4023
  }
4009
4024
  return _context.abrupt("return", {
4010
4025
  dryRunError: dryRunResult.failureReason
4011
4026
  });
4012
- case 12:
4013
- _context.next = 14;
4014
- return api.calculateTransactionFee(tx, senderAddress);
4015
4027
  case 14:
4028
+ _context.next = 16;
4029
+ return api.calculateTransactionFee(tx, senderAddress);
4030
+ case 16:
4016
4031
  _rawFee = _context.sent;
4017
4032
  return _context.abrupt("return", {
4018
4033
  fee: padFee(_rawFee, origin, destination, 'origin'),
4019
4034
  feeType: 'paymentInfo',
4020
4035
  dryRunError: dryRunResult.failureReason
4021
4036
  });
4022
- case 16:
4037
+ case 18:
4023
4038
  fee = dryRunResult.fee, forwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
4024
4039
  return _context.abrupt("return", {
4025
4040
  fee: fee,
@@ -4027,7 +4042,7 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
4027
4042
  forwardedXcms: forwardedXcms,
4028
4043
  destParaId: destParaId
4029
4044
  });
4030
- case 18:
4045
+ case 20:
4031
4046
  case "end":
4032
4047
  return _context.stop();
4033
4048
  }
@@ -4041,7 +4056,7 @@ var getFeeForOriginNode = /*#__PURE__*/function () {
4041
4056
  var getXcmFee = /*#__PURE__*/function () {
4042
4057
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4043
4058
  var _findAsset;
4044
- var api, tx, origin, destination, senderAddress, address, currency, disableFallback, asset, _yield$getFeeForOrigi, originFee, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFee, _destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4059
+ var api, tx, origin, destination, senderAddress, address, currency, disableFallback, asset, _yield$getFeeForOrigi, originFee, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4045
4060
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4046
4061
  while (1) switch (_context.prev = _context.next) {
4047
4062
  case 0:
@@ -4069,14 +4084,14 @@ var getXcmFee = /*#__PURE__*/function () {
4069
4084
  originDryRunError = _yield$getFeeForOrigi.dryRunError;
4070
4085
  initialForwardedXcm = _yield$getFeeForOrigi.forwardedXcms;
4071
4086
  initialDestParaId = _yield$getFeeForOrigi.destParaId;
4072
- if (!(origin === 'AssetHubKusama' && destination === 'Kusama')) {
4087
+ api.setDisconnectAllowed(true);
4088
+ _context.next = 15;
4089
+ return api.disconnect();
4090
+ case 15:
4091
+ if (!(originDryRunError || originFeeType === 'paymentInfo')) {
4073
4092
  _context.next = 30;
4074
4093
  break;
4075
4094
  }
4076
- api.setDisconnectAllowed(true);
4077
- _context.next = 16;
4078
- return api.disconnect();
4079
- case 16:
4080
4095
  destApi = api.clone();
4081
4096
  _context.prev = 17;
4082
4097
  _context.next = 20;
@@ -4087,6 +4102,7 @@ var getXcmFee = /*#__PURE__*/function () {
4087
4102
  return getFeeForDestNode({
4088
4103
  api: destApi,
4089
4104
  forwardedXcms: undefined,
4105
+ // force paymentInfo
4090
4106
  origin: origin,
4091
4107
  destination: destination,
4092
4108
  currency: currency,
@@ -4095,7 +4111,7 @@ var getXcmFee = /*#__PURE__*/function () {
4095
4111
  disableFallback: disableFallback
4096
4112
  });
4097
4113
  case 23:
4098
- destFee = _context.sent;
4114
+ destFeeRes = _context.sent;
4099
4115
  return _context.abrupt("return", {
4100
4116
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4101
4117
  fee: originFee
@@ -4106,10 +4122,10 @@ var getXcmFee = /*#__PURE__*/function () {
4106
4122
  }, originDryRunError && {
4107
4123
  dryRunError: originDryRunError
4108
4124
  }),
4109
- destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFee.fee && {
4110
- fee: destFee.fee
4111
- }), destFee.feeType && {
4112
- feeType: destFee.feeType
4125
+ destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFeeRes.fee && {
4126
+ fee: destFeeRes.fee
4127
+ }), destFeeRes.feeType && {
4128
+ feeType: destFeeRes.feeType
4113
4129
  }), {}, {
4114
4130
  currency: getNativeAssetSymbol(destination)
4115
4131
  })
@@ -4122,83 +4138,30 @@ var getXcmFee = /*#__PURE__*/function () {
4122
4138
  case 29:
4123
4139
  return _context.finish(25);
4124
4140
  case 30:
4125
- api.setDisconnectAllowed(true);
4126
- _context.next = 33;
4127
- return api.disconnect();
4128
- case 33:
4129
- if (!originDryRunError) {
4130
- _context.next = 48;
4131
- break;
4132
- }
4133
- _destApi = api.clone();
4134
- _context.prev = 35;
4135
- _context.next = 38;
4136
- return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
4137
- case 38:
4138
- _destApi.setDisconnectAllowed(false);
4139
- _context.next = 41;
4140
- return getFeeForDestNode({
4141
- api: _destApi,
4142
- forwardedXcms: undefined,
4143
- // force paymentInfo
4144
- origin: origin,
4145
- destination: destination,
4146
- currency: currency,
4147
- address: address,
4148
- senderAddress: senderAddress,
4149
- disableFallback: disableFallback
4150
- });
4151
- case 41:
4152
- destFeeRes = _context.sent;
4153
- return _context.abrupt("return", {
4154
- origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4155
- fee: originFee
4156
- }), originFeeType && {
4157
- feeType: originFeeType
4158
- }), {}, {
4159
- currency: getNativeAssetSymbol(origin),
4160
- dryRunError: originDryRunError
4161
- }),
4162
- destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFeeRes.fee && {
4163
- fee: destFeeRes.fee
4164
- }), destFeeRes.feeType && {
4165
- feeType: destFeeRes.feeType
4166
- }), {}, {
4167
- currency: getNativeAssetSymbol(destination)
4168
- })
4169
- });
4170
- case 43:
4171
- _context.prev = 43;
4172
- _destApi.setDisconnectAllowed(true);
4173
- _context.next = 47;
4174
- return _destApi.disconnect();
4175
- case 47:
4176
- return _context.finish(43);
4177
- case 48:
4178
4141
  currentOrigin = origin;
4179
4142
  forwardedXcms = initialForwardedXcm;
4180
4143
  nextParaId = initialDestParaId;
4181
4144
  intermediateFees = {};
4182
4145
  destinationFee = 0n;
4183
4146
  destinationFeeType = 'paymentInfo';
4184
- case 54:
4147
+ case 36:
4185
4148
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
4186
- _context.next = 86;
4149
+ _context.next = 68;
4187
4150
  break;
4188
4151
  }
4189
4152
  nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
4190
4153
  if (!(nextChain === null)) {
4191
- _context.next = 58;
4154
+ _context.next = 40;
4192
4155
  break;
4193
4156
  }
4194
4157
  throw new Error("Unable to find TNode for paraId ".concat(nextParaId));
4195
- case 58:
4158
+ case 40:
4196
4159
  hopApi = api.clone();
4197
- _context.prev = 59;
4198
- _context.next = 62;
4160
+ _context.prev = 41;
4161
+ _context.next = 44;
4199
4162
  return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
4200
- case 62:
4201
- _context.next = 64;
4163
+ case 44:
4164
+ _context.next = 46;
4202
4165
  return getFeeForDestNode({
4203
4166
  api: hopApi,
4204
4167
  forwardedXcms: forwardedXcms,
@@ -4209,10 +4172,10 @@ var getXcmFee = /*#__PURE__*/function () {
4209
4172
  senderAddress: senderAddress,
4210
4173
  disableFallback: disableFallback
4211
4174
  });
4212
- case 64:
4175
+ case 46:
4213
4176
  hopResult = _context.sent;
4214
4177
  if (!hopResult.dryRunError) {
4215
- _context.next = 76;
4178
+ _context.next = 58;
4216
4179
  break;
4217
4180
  }
4218
4181
  failingRecord = {
@@ -4233,10 +4196,10 @@ var getXcmFee = /*#__PURE__*/function () {
4233
4196
  }
4234
4197
  // We failed before the true destination, use fallback via paymentInfo.
4235
4198
  if (hopIsDestination) {
4236
- _context.next = 75;
4199
+ _context.next = 57;
4237
4200
  break;
4238
4201
  }
4239
- _context.next = 72;
4202
+ _context.next = 54;
4240
4203
  return getFeeForDestNode({
4241
4204
  api: hopApi,
4242
4205
  forwardedXcms: undefined,
@@ -4247,13 +4210,13 @@ var getXcmFee = /*#__PURE__*/function () {
4247
4210
  senderAddress: senderAddress,
4248
4211
  disableFallback: disableFallback
4249
4212
  });
4250
- case 72:
4213
+ case 54:
4251
4214
  destFallback = _context.sent;
4252
4215
  destinationFee = destFallback.fee;
4253
4216
  destinationFeeType = destFallback.feeType;
4254
- case 75:
4255
- return _context.abrupt("break", 86);
4256
- case 76:
4217
+ case 57:
4218
+ return _context.abrupt("break", 68);
4219
+ case 58:
4257
4220
  if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
4258
4221
  destinationFee = hopResult.fee;
4259
4222
  destinationFeeType = hopResult.feeType;
@@ -4273,16 +4236,16 @@ var getXcmFee = /*#__PURE__*/function () {
4273
4236
  forwardedXcms = hopResult.forwardedXcms;
4274
4237
  nextParaId = hopResult.destParaId;
4275
4238
  currentOrigin = nextChain;
4276
- case 80:
4277
- _context.prev = 80;
4278
- _context.next = 83;
4239
+ case 62:
4240
+ _context.prev = 62;
4241
+ _context.next = 65;
4279
4242
  return hopApi.disconnect();
4280
- case 83:
4281
- return _context.finish(80);
4282
- case 84:
4283
- _context.next = 54;
4243
+ case 65:
4244
+ return _context.finish(62);
4245
+ case 66:
4246
+ _context.next = 36;
4284
4247
  break;
4285
- case 86:
4248
+ case 68:
4286
4249
  return _context.abrupt("return", _objectSpread2(_objectSpread2({
4287
4250
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
4288
4251
  fee: originFee
@@ -4304,11 +4267,11 @@ var getXcmFee = /*#__PURE__*/function () {
4304
4267
  dryRunError: destinationDryRunError
4305
4268
  })
4306
4269
  }));
4307
- case 87:
4270
+ case 69:
4308
4271
  case "end":
4309
4272
  return _context.stop();
4310
4273
  }
4311
- }, _callee, null, [[17,, 25, 30], [35,, 43, 48], [59,, 80, 84]]);
4274
+ }, _callee, null, [[17,, 25, 30], [41,, 62, 66]]);
4312
4275
  }));
4313
4276
  return function getXcmFee(_x) {
4314
4277
  return _ref2.apply(this, arguments);
@@ -4476,70 +4439,17 @@ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, cu
4476
4439
  return asset !== null && asset !== void 0 ? asset : undefined;
4477
4440
  };
4478
4441
 
4479
- var validateCurrency = function validateCurrency(currency, feeAsset) {
4480
- if ('multiasset' in currency) {
4481
- if (currency.multiasset.length === 0) {
4482
- throw new InvalidCurrencyError('Overridden multi assets cannot be empty');
4483
- }
4484
- if (currency.multiasset.length === 1) {
4485
- throw new InvalidCurrencyError('Please provide more than one multi asset');
4486
- }
4487
- if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
4488
- return isTMultiAsset(asset);
4489
- }) && !feeAsset) {
4490
- throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
4491
- }
4492
- }
4493
- };
4494
- var validateDestination = function validateDestination(origin, destination) {
4495
- if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination) && origin !== destination) {
4496
- throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4497
- }
4498
- if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration' && origin !== 'BifrostPolkadot' && origin !== 'Moonbeam') {
4499
- throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
4500
- }
4501
- var isMultiLocationDestination = _typeof(destination) === 'object';
4502
- var isBridge = isBridgeTransfer(origin, destination);
4503
- var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
4504
- if (!isRelayDestination && !isMultiLocationDestination) {
4505
- var originRelayChainSymbol = getRelayChainSymbol(origin);
4506
- var destinationRelayChainSymbol = getRelayChainSymbol(destination);
4507
- if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
4508
- throw new IncompatibleNodesError();
4509
- }
4510
- }
4511
- };
4512
- var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4513
- if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
4514
- throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4515
- }
4516
- if (!assetCheckEnabled && 'id' in currency) {
4517
- throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4518
- }
4519
- };
4520
4442
  var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
4521
4443
  var origin = _ref.from,
4522
4444
  destination = _ref.to,
4523
4445
  currency = _ref.currency;
4524
- var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
4525
- var isMultiLocationDestination = _typeof(destination) === 'object';
4526
4446
  var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
4527
- var pallet = getDefaultPallet(origin);
4528
- var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
4529
- if (!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost) {
4530
- var nativeAssets = getNativeAssets(destination);
4531
- if (origin === 'Hydration') {
4532
- nativeAssets = nativeAssets.filter(function (nativeAsset) {
4533
- return nativeAsset.symbol !== 'DOT';
4534
- });
4535
- }
4536
- if ('symbol' in currency && nativeAssets.some(function (nativeAsset) {
4537
- var _asset$symbol;
4538
- return nativeAsset.symbol.toLowerCase() === (asset === null || asset === void 0 || (_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase());
4539
- })) {
4540
- throw new InvalidCurrencyError("".concat(JSON.stringify(asset === null || asset === void 0 ? void 0 : asset.symbol), " is not supported for transfers to ").concat(destination, "."));
4541
- }
4447
+ var allowedChainsToAh = ['BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec'];
4448
+ if (!isRelayChain(origin) && !isBridge && isDestAssetHub && !allowedChainsToAh.includes(origin) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
4449
+ throw new TransferToAhNotSupported("Node ".concat(origin, " does not support DOT transfer to AssetHub"));
4542
4450
  }
4451
+ var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
4452
+ var isMultiLocationDestination = _typeof(destination) === 'object';
4543
4453
  if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
4544
4454
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
4545
4455
  }
@@ -4619,6 +4529,49 @@ var validateDestinationAddress = function validateDestinationAddress(address, de
4619
4529
  }
4620
4530
  };
4621
4531
 
4532
+ var validateCurrency = function validateCurrency(currency, feeAsset) {
4533
+ if ('multiasset' in currency) {
4534
+ if (currency.multiasset.length === 0) {
4535
+ throw new InvalidCurrencyError('Overridden multi assets cannot be empty');
4536
+ }
4537
+ if (currency.multiasset.length === 1) {
4538
+ throw new InvalidCurrencyError('Please provide more than one multi asset');
4539
+ }
4540
+ if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
4541
+ return isTMultiAsset(asset);
4542
+ }) && !feeAsset) {
4543
+ throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
4544
+ }
4545
+ }
4546
+ };
4547
+ var validateDestination = function validateDestination(origin, destination) {
4548
+ if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination) && origin !== destination) {
4549
+ throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4550
+ }
4551
+ var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
4552
+ if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
4553
+ throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
4554
+ }
4555
+ var isMultiLocationDestination = _typeof(destination) === 'object';
4556
+ var isBridge = isBridgeTransfer(origin, destination);
4557
+ var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
4558
+ if (!isRelayDestination && !isMultiLocationDestination) {
4559
+ var originRelayChainSymbol = getRelayChainSymbol(origin);
4560
+ var destinationRelayChainSymbol = getRelayChainSymbol(destination);
4561
+ if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
4562
+ throw new IncompatibleNodesError();
4563
+ }
4564
+ }
4565
+ };
4566
+ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4567
+ if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
4568
+ throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4569
+ }
4570
+ if (!assetCheckEnabled && 'id' in currency) {
4571
+ throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4572
+ }
4573
+ };
4574
+
4622
4575
  var send = /*#__PURE__*/function () {
4623
4576
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
4624
4577
  var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, isLocalTransfer, overriddenAsset, resolvedAsset, originNode;
@@ -9716,4 +9669,4 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
9716
9669
  };
9717
9670
  }();
9718
9671
 
9719
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
9672
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFeeForOriginNode, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "9.1.2",
3
+ "version": "9.2.1",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "@scure/base": "^1.2.5",
28
28
  "ethers": "^6.13.7",
29
29
  "viem": "^2.28.1",
30
- "@paraspell/assets": "9.1.2",
31
- "@paraspell/pallets": "9.1.2",
32
- "@paraspell/sdk-common": "9.1.2"
30
+ "@paraspell/assets": "9.2.1",
31
+ "@paraspell/sdk-common": "9.2.1",
32
+ "@paraspell/pallets": "9.2.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/plugin-syntax-import-attributes": "^7.27.1",