@paraspell/sdk-core 10.10.7 → 10.10.9

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
@@ -3970,6 +3970,22 @@ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, cu
3970
3970
  return asset !== null && asset !== void 0 ? asset : undefined;
3971
3971
  };
3972
3972
 
3973
+ var validateAddress = function validateAddress(address, node) {
3974
+ var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3975
+ if (sdkCommon.isTMultiLocation(address)) return;
3976
+ var isEvm = assets.isNodeEvm(node);
3977
+ var isEthereumAddress = viem.isAddress(address);
3978
+ if (isEvm) {
3979
+ if (!isEthereumAddress) {
3980
+ throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
3981
+ }
3982
+ } else {
3983
+ if (isEthereumAddress) {
3984
+ throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "node is not an EVM chain."));
3985
+ }
3986
+ }
3987
+ };
3988
+
3973
3989
  var isAssetHub = function isAssetHub(chain) {
3974
3990
  return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
3975
3991
  };
@@ -5473,22 +5489,6 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
5473
5489
  return !(hasMultiAsset || hasOverriddenMultilocation);
5474
5490
  };
5475
5491
 
5476
- var validateAddress = function validateAddress(address, node) {
5477
- var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
5478
- if (sdkCommon.isTMultiLocation(address)) return;
5479
- var isEvm = assets.isNodeEvm(node);
5480
- var isEthereumAddress = viem.isAddress(address);
5481
- if (isEvm) {
5482
- if (!isEthereumAddress) {
5483
- throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
5484
- }
5485
- } else {
5486
- if (isEthereumAddress) {
5487
- throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "node is not an EVM chain."));
5488
- }
5489
- }
5490
- };
5491
-
5492
5492
  var validateDestinationAddress = function validateDestinationAddress(address, destination) {
5493
5493
  if (typeof address === 'string' && !sdkCommon.isTMultiLocation(destination)) {
5494
5494
  validateAddress(address, destination);
@@ -6165,13 +6165,68 @@ var send = /*#__PURE__*/function () {
6165
6165
  };
6166
6166
  }();
6167
6167
 
6168
+ var attemptDryRunFee = /*#__PURE__*/function () {
6169
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
6170
+ var currency, builder, reductionPcts, lastReduction, result, _i, _reductionPcts, percentage, modifiedBuilder, _t, _t2, _t3, _t4, _t5, _t6, _t7;
6171
+ return _regenerator().w(function (_context) {
6172
+ while (1) switch (_context.n) {
6173
+ case 0:
6174
+ currency = options.currency, builder = options.builder;
6175
+ reductionPcts = [0, 10, 20, 30, 40, 50];
6176
+ lastReduction = reductionPcts[reductionPcts.length - 1];
6177
+ result = null;
6178
+ _i = 0, _reductionPcts = reductionPcts;
6179
+ case 1:
6180
+ if (!(_i < _reductionPcts.length)) {
6181
+ _context.n = 5;
6182
+ break;
6183
+ }
6184
+ percentage = _reductionPcts[_i];
6185
+ modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
6186
+ amount: padFeeBy(BigInt(currency.amount), -percentage)
6187
+ }));
6188
+ _t = getOriginXcmFee;
6189
+ _t2 = _objectSpread2;
6190
+ _t3 = _objectSpread2({}, options);
6191
+ _t4 = {};
6192
+ _context.n = 2;
6193
+ return modifiedBuilder.build();
6194
+ case 2:
6195
+ _t5 = _context.v;
6196
+ _t6 = {
6197
+ tx: _t5
6198
+ };
6199
+ _t7 = _t2(_t3, _t4, _t6);
6200
+ _context.n = 3;
6201
+ return _t(_t7);
6202
+ case 3:
6203
+ result = _context.v;
6204
+ if (!(result.feeType === 'dryRun' || percentage === lastReduction)) {
6205
+ _context.n = 4;
6206
+ break;
6207
+ }
6208
+ return _context.a(2, result);
6209
+ case 4:
6210
+ _i++;
6211
+ _context.n = 1;
6212
+ break;
6213
+ case 5:
6214
+ return _context.a(2, result);
6215
+ }
6216
+ }, _callee);
6217
+ }));
6218
+ return function attemptDryRunFee(_x) {
6219
+ return _ref.apply(this, arguments);
6220
+ };
6221
+ }();
6222
+
6168
6223
  var getTransferableAmountInternal = /*#__PURE__*/function () {
6169
6224
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
6170
- var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
6225
+ var api, senderAddress, node, destination, currency, builder, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$attemptDryRunF, fee, transferable;
6171
6226
  return _regenerator().w(function (_context) {
6172
6227
  while (1) switch (_context.n) {
6173
6228
  case 0:
6174
- api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.origin, destination = _ref.destination, currency = _ref.currency, tx = _ref.tx, feeAsset = _ref.feeAsset;
6229
+ api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.origin, destination = _ref.destination, currency = _ref.currency, builder = _ref.builder, feeAsset = _ref.feeAsset;
6175
6230
  validateAddress(senderAddress, node, false);
6176
6231
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, node, destination, currency) : undefined;
6177
6232
  asset = assets.findAssetForNodeOrThrow(node, currency, null);
@@ -6193,9 +6248,9 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
6193
6248
  break;
6194
6249
  }
6195
6250
  _context.n = 2;
6196
- return getOriginXcmFee({
6251
+ return attemptDryRunFee({
6197
6252
  api: api,
6198
- tx: tx,
6253
+ builder: builder,
6199
6254
  origin: node,
6200
6255
  destination: node,
6201
6256
  senderAddress: senderAddress,
@@ -6204,8 +6259,8 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
6204
6259
  disableFallback: false
6205
6260
  });
6206
6261
  case 2:
6207
- _yield$getOriginXcmFe = _context.v;
6208
- fee = _yield$getOriginXcmFe.fee;
6262
+ _yield$attemptDryRunF = _context.v;
6263
+ fee = _yield$attemptDryRunF.fee;
6209
6264
  if (!(fee === undefined)) {
6210
6265
  _context.n = 3;
6211
6266
  break;
@@ -11856,27 +11911,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
11856
11911
  key: "getTransferableAmount",
11857
11912
  value: (function () {
11858
11913
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
11859
- var _this$_options7, from, to, senderAddress, currency, feeAsset, tx;
11914
+ var _this$_options7, from, to, senderAddress, currency, feeAsset;
11860
11915
  return _regenerator().w(function (_context8) {
11861
11916
  while (1) switch (_context8.n) {
11862
11917
  case 0:
11863
11918
  _this$_options7 = this._options, from = _this$_options7.from, to = _this$_options7.to, senderAddress = _this$_options7.senderAddress, currency = _this$_options7.currency, feeAsset = _this$_options7.feeAsset;
11864
11919
  assertToIsString(to);
11865
11920
  _context8.n = 1;
11866
- return this.build();
11867
- case 1:
11868
- tx = _context8.v;
11869
- _context8.n = 2;
11870
11921
  return getTransferableAmount({
11871
11922
  api: this.api,
11872
- tx: tx,
11923
+ builder: this,
11873
11924
  origin: from,
11874
11925
  destination: to,
11875
11926
  senderAddress: senderAddress,
11876
11927
  feeAsset: feeAsset,
11877
11928
  currency: currency
11878
11929
  });
11879
- case 2:
11930
+ case 1:
11880
11931
  return _context8.a(2, _context8.v);
11881
11932
  }
11882
11933
  }, _callee8, this);
package/dist/index.d.ts CHANGED
@@ -258,6 +258,257 @@ type TAssetClaimOptionsBase = {
258
258
  };
259
259
  type TAssetClaimOptions<TApi, TRes> = WithApi<TAssetClaimOptionsBase, TApi, TRes>;
260
260
 
261
+ /**
262
+ * Builder class for constructing asset claim transactions.
263
+ */
264
+ declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptionsBase> = object> {
265
+ readonly api: IPolkadotApi<TApi, TRes>;
266
+ readonly _options: T;
267
+ constructor(api: IPolkadotApi<TApi, TRes>, options?: T);
268
+ /**
269
+ * Specifies the assets to be claimed.
270
+ *
271
+ * @param multiAssets - An array of assets to claim in a multi-asset format.
272
+ * @returns An instance of Builder
273
+ */
274
+ fungible(multiAssets: TMultiAsset[]): AssetClaimBuilder<TApi, TRes, T & {
275
+ multiAssets: TMultiAsset[];
276
+ }>;
277
+ /**
278
+ * Specifies the account address on which the assets will be claimed.
279
+ *
280
+ * @param address - The destination account address.
281
+ * @returns An instance of Builder
282
+ */
283
+ account(address: TAddress): AssetClaimBuilder<TApi, TRes, T & {
284
+ address: TAddress;
285
+ }>;
286
+ /**
287
+ * Sets the XCM version to be used for the asset claim.
288
+ *
289
+ * @param version - The XCM version.
290
+ * @returns An instance of Builder
291
+ */
292
+ xcmVersion(version: Version): AssetClaimBuilder<TApi, TRes, T & {
293
+ version: Version;
294
+ }>;
295
+ /**
296
+ * Builds and returns the asset claim extrinsic.
297
+ *
298
+ * @returns A Promise that resolves to the asset claim extrinsic.
299
+ */
300
+ build(this: AssetClaimBuilder<TApi, TRes, TAssetClaimOptionsBase>): Promise<TRes>;
301
+ /**
302
+ * Returns the API instance used by the builder.
303
+ *
304
+ * @returns The API instance.
305
+ */
306
+ getApi(): TApi;
307
+ /**
308
+ * Disconnects the API.
309
+ *
310
+ * @returns A Promise that resolves when the API is disconnected.
311
+ */
312
+ disconnect(): Promise<void>;
313
+ }
314
+
315
+ declare class BatchTransactionManager<TApi, TRes> {
316
+ transactionOptions: TSendOptions<TApi, TRes>[];
317
+ addTransaction(options: TSendOptions<TApi, TRes>): void;
318
+ isEmpty(): boolean;
319
+ buildBatch(api: IPolkadotApi<TApi, TRes>, from: TNodeDotKsmWithRelayChains, options?: TBatchOptions): Promise<TRes>;
320
+ }
321
+
322
+ /**
323
+ * A builder class for constructing Para-to-Para, Para-to-Relay, Relay-to-Para transactions and asset claims.
324
+ */
325
+ declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = object> {
326
+ readonly batchManager: BatchTransactionManager<TApi, TRes>;
327
+ readonly api: IPolkadotApi<TApi, TRes>;
328
+ readonly _options: T;
329
+ constructor(api: IPolkadotApi<TApi, TRes>, batchManager: BatchTransactionManager<TApi, TRes>, options?: T);
330
+ /**
331
+ * Specifies the origin node for the transaction.
332
+ *
333
+ * @param node - The node from which the transaction originates.
334
+ * @returns An instance of Builder
335
+ */
336
+ from(node: TNodeDotKsmWithRelayChains): GeneralBuilder<TApi, TRes, T & {
337
+ from: TNodeDotKsmWithRelayChains;
338
+ }>;
339
+ /**
340
+ * Specifies the destination node for the transaction.
341
+ *
342
+ * @param node - The node to which the transaction is sent.
343
+ * @param paraIdTo - (Optional) The parachain ID of the destination node.
344
+ * @returns An instance of Builder
345
+ */
346
+ to(node: TDestination, paraIdTo?: number): GeneralBuilder<TApi, TRes, T & {
347
+ to: TDestination;
348
+ }>;
349
+ /**
350
+ * Initiates the process to claim assets from a specified node.
351
+ *
352
+ * @param node - The node from which to claim assets.
353
+ * @returns An instance of Builder
354
+ */
355
+ claimFrom(node: TNodeWithRelayChains): AssetClaimBuilder<TApi, TRes, {
356
+ node: TNodeWithRelayChains;
357
+ }>;
358
+ /**
359
+ * Specifies the currency to be used in the transaction. Symbol, ID, multi-location or multi-asset.
360
+ *
361
+ * @param currency - The currency to be transferred.
362
+ * @returns An instance of Builder
363
+ */
364
+ currency(currency: TCurrencyInputWithAmount): GeneralBuilder<TApi, TRes, T & {
365
+ currency: TCurrencyInputWithAmount;
366
+ }>;
367
+ /**
368
+ * Sets the recipient address.
369
+ *
370
+ * @param address - The destination address.
371
+ * @returns An instance of Builder
372
+ */
373
+ address(address: TAddress): GeneralBuilder<TApi, TRes, T & {
374
+ address: TAddress;
375
+ }>;
376
+ /**
377
+ * Sets the sender address.
378
+ *
379
+ * @param address - The sender address.
380
+ * @returns
381
+ */
382
+ senderAddress(address: string): GeneralBuilder<TApi, TRes, T & {
383
+ senderAddress: string;
384
+ }>;
385
+ /**
386
+ * Sets the asset hub address. This is used for transfers that go through the Asset Hub and originate from an EVM chain.
387
+ *
388
+ * @param address - The address to be used.
389
+ * @returns An instance of Builder
390
+ */
391
+ ahAddress(address: string | undefined): GeneralBuilder<TApi, TRes, T & {
392
+ ahAddress: string | undefined;
393
+ }>;
394
+ /**
395
+ * Sets the XCM version to be used for the transfer.
396
+ *
397
+ * @param version - The XCM version.
398
+ * @returns An instance of Builder
399
+ */
400
+ xcmVersion(version: Version): GeneralBuilder<TApi, TRes, T & {
401
+ version: Version;
402
+ }>;
403
+ /**
404
+ * Sets a custom pallet for the transaction.
405
+ *
406
+ * @param palletName - The name of the custom pallet to be used.
407
+ * @returns An instance of the Builder.
408
+ */
409
+ customPallet(pallet: string, method: string): GeneralBuilder<TApi, TRes, T & {
410
+ pallet: string;
411
+ method: string;
412
+ }>;
413
+ /**
414
+ * Optional fee asset for the transaction.
415
+ *
416
+ * @param currency - The currency to be used for the fee.
417
+ * @returns An instance of the Builder
418
+ */
419
+ feeAsset(currency: TCurrencyInput | undefined): GeneralBuilder<TApi, TRes, T & {
420
+ feeAsset: TCurrencyInput | undefined;
421
+ }>;
422
+ /**
423
+ * Adds the transfer transaction to the batch.
424
+ *
425
+ * @returns An instance of Builder
426
+ */
427
+ addToBatch(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>): GeneralBuilder<TApi, TRes, T & {
428
+ from: TNodeDotKsmWithRelayChains;
429
+ }>;
430
+ /**
431
+ * Builds and returns the batched transaction based on the configured parameters.
432
+ *
433
+ * @param options - (Optional) Options to customize the batch transaction.
434
+ * @returns A Extrinsic representing the batched transactions.
435
+ */
436
+ buildBatch(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>, options?: TBatchOptions): Promise<TRes>;
437
+ /**
438
+ * Builds and returns the transfer extrinsic.
439
+ *
440
+ * @returns A Promise that resolves to the transfer extrinsic.
441
+ */
442
+ build(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>): Promise<TRes>;
443
+ dryRun(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TDryRunResult>;
444
+ /**
445
+ * Returns the XCM fee for the transfer using dryRun or paymentInfo function.
446
+ *
447
+ * @returns An origin and destination fee.
448
+ */
449
+ getXcmFee<TDisableFallback extends boolean = false>(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, options?: TGetXcmFeeBuilderOptions & {
450
+ disableFallback: TDisableFallback;
451
+ }): Promise<TGetXcmFeeResult<TDisableFallback>>;
452
+ /**
453
+ * Returns the origin XCM fee for the transfer using dryRun or paymentInfo function.
454
+ *
455
+ * @returns An origin fee.
456
+ */
457
+ getOriginXcmFee(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, { disableFallback }?: TGetXcmFeeBuilderOptions): Promise<TXcmFeeDetail & {
458
+ forwardedXcms?: any;
459
+ destParaId?: number;
460
+ }>;
461
+ /**
462
+ * Estimates the origin and destination XCM fee using paymentInfo function.
463
+ *
464
+ * @returns An origin and destination fee estimate.
465
+ */
466
+ getXcmFeeEstimate(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TGetXcmFeeEstimateResult>;
467
+ /**
468
+ * Estimates the origin XCM fee using paymentInfo function.
469
+ *
470
+ * @returns An origin fee estimate.
471
+ */
472
+ getOriginXcmFeeEstimate(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TGetXcmFeeEstimateDetail>;
473
+ /**
474
+ * Returns the max transferable amount for the transfer
475
+ *
476
+ * @returns The max transferable amount.
477
+ */
478
+ getTransferableAmount(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<bigint>;
479
+ /**
480
+ * Returns the max transferable amount for the transfer
481
+ *
482
+ * @returns The max transferable amount.
483
+ */
484
+ verifyEdOnDestination(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<boolean>;
485
+ /**
486
+ * Returns the transfer info for the transfer
487
+ *
488
+ * @returns The transfer info.
489
+ */
490
+ getTransferInfo(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TTransferInfo>;
491
+ /**
492
+ * Returns the API instance used by the builder.
493
+ *
494
+ * @returns The API instance.
495
+ */
496
+ getApi(): TApi;
497
+ /**
498
+ * Disconnects the API.
499
+ *
500
+ * @returns A Promise that resolves when the API is disconnected.
501
+ */
502
+ disconnect(): Promise<void>;
503
+ }
504
+ /**
505
+ * Creates a new Builder instance.
506
+ *
507
+ * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
508
+ * @returns A new Builder instance.
509
+ */
510
+ declare const Builder: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>) => GeneralBuilder<TApi, TRes, object>;
511
+
261
512
  type TBalanceResponse = {
262
513
  free?: string;
263
514
  balance?: string;
@@ -378,7 +629,7 @@ type TGetMaxForeignTransferableAmountOptionsBase = {
378
629
  currency: TCurrencyCore;
379
630
  };
380
631
  type TGetMaxForeignTransferableAmountOptions<TApi, TRes> = WithApi<TGetMaxForeignTransferableAmountOptionsBase, TApi, TRes>;
381
- type TGetTransferableAmountOptionsBase<TRes> = {
632
+ type TGetTransferableAmountOptionsBase<TApi, TRes> = {
382
633
  /**
383
634
  * The sender address of the account.
384
635
  */
@@ -396,12 +647,12 @@ type TGetTransferableAmountOptionsBase<TRes> = {
396
647
  */
397
648
  currency: WithAmount<TCurrencyCore>;
398
649
  /**
399
- * The transaction to calculate the fee for
650
+ * The transaction builder
400
651
  */
401
- tx: TRes;
652
+ builder: GeneralBuilder<TApi, TRes, TSendBaseOptions>;
402
653
  feeAsset?: TCurrencyInput;
403
654
  };
404
- type TGetTransferableAmountOptions<TApi, TRes> = WithApi<TGetTransferableAmountOptionsBase<TRes>, TApi, TRes>;
655
+ type TGetTransferableAmountOptions<TApi, TRes> = WithApi<TGetTransferableAmountOptionsBase<TApi, TRes>, TApi, TRes>;
405
656
  type TVerifyEdOnDestinationOptionsBase<TRes> = {
406
657
  /**
407
658
  * The origin node.
@@ -965,6 +1216,9 @@ type TGetOriginXcmFeeBaseOptions<TRes> = {
965
1216
  disableFallback: boolean;
966
1217
  };
967
1218
  type TGetOriginXcmFeeOptions<TApi, TRes> = WithApi<TGetOriginXcmFeeBaseOptions<TRes>, TApi, TRes>;
1219
+ type TAttemptDryRunFeeOptions<TApi, TRes> = Omit<TGetOriginXcmFeeOptions<TApi, TRes>, 'tx'> & {
1220
+ builder: GeneralBuilder<TApi, TRes, TSendBaseOptions>;
1221
+ };
968
1222
  type TGetFeeForDestNodeBaseOptions = {
969
1223
  prevNode: TNodeDotKsmWithRelayChains;
970
1224
  origin: TNodeDotKsmWithRelayChains;
@@ -1084,257 +1338,6 @@ declare const deriveAccountId: (raw: Uint8Array) => Uint8Array;
1084
1338
  declare const encodeSs58: (payload: Uint8Array, network: number) => string;
1085
1339
  declare const convertSs58: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, node: TNodeDotKsmWithRelayChains) => string;
1086
1340
 
1087
- /**
1088
- * Builder class for constructing asset claim transactions.
1089
- */
1090
- declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptionsBase> = object> {
1091
- readonly api: IPolkadotApi<TApi, TRes>;
1092
- readonly _options: T;
1093
- constructor(api: IPolkadotApi<TApi, TRes>, options?: T);
1094
- /**
1095
- * Specifies the assets to be claimed.
1096
- *
1097
- * @param multiAssets - An array of assets to claim in a multi-asset format.
1098
- * @returns An instance of Builder
1099
- */
1100
- fungible(multiAssets: TMultiAsset[]): AssetClaimBuilder<TApi, TRes, T & {
1101
- multiAssets: TMultiAsset[];
1102
- }>;
1103
- /**
1104
- * Specifies the account address on which the assets will be claimed.
1105
- *
1106
- * @param address - The destination account address.
1107
- * @returns An instance of Builder
1108
- */
1109
- account(address: TAddress): AssetClaimBuilder<TApi, TRes, T & {
1110
- address: TAddress;
1111
- }>;
1112
- /**
1113
- * Sets the XCM version to be used for the asset claim.
1114
- *
1115
- * @param version - The XCM version.
1116
- * @returns An instance of Builder
1117
- */
1118
- xcmVersion(version: Version): AssetClaimBuilder<TApi, TRes, T & {
1119
- version: Version;
1120
- }>;
1121
- /**
1122
- * Builds and returns the asset claim extrinsic.
1123
- *
1124
- * @returns A Promise that resolves to the asset claim extrinsic.
1125
- */
1126
- build(this: AssetClaimBuilder<TApi, TRes, TAssetClaimOptionsBase>): Promise<TRes>;
1127
- /**
1128
- * Returns the API instance used by the builder.
1129
- *
1130
- * @returns The API instance.
1131
- */
1132
- getApi(): TApi;
1133
- /**
1134
- * Disconnects the API.
1135
- *
1136
- * @returns A Promise that resolves when the API is disconnected.
1137
- */
1138
- disconnect(): Promise<void>;
1139
- }
1140
-
1141
- declare class BatchTransactionManager<TApi, TRes> {
1142
- transactionOptions: TSendOptions<TApi, TRes>[];
1143
- addTransaction(options: TSendOptions<TApi, TRes>): void;
1144
- isEmpty(): boolean;
1145
- buildBatch(api: IPolkadotApi<TApi, TRes>, from: TNodeDotKsmWithRelayChains, options?: TBatchOptions): Promise<TRes>;
1146
- }
1147
-
1148
- /**
1149
- * A builder class for constructing Para-to-Para, Para-to-Relay, Relay-to-Para transactions and asset claims.
1150
- */
1151
- declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = object> {
1152
- readonly batchManager: BatchTransactionManager<TApi, TRes>;
1153
- readonly api: IPolkadotApi<TApi, TRes>;
1154
- readonly _options: T;
1155
- constructor(api: IPolkadotApi<TApi, TRes>, batchManager: BatchTransactionManager<TApi, TRes>, options?: T);
1156
- /**
1157
- * Specifies the origin node for the transaction.
1158
- *
1159
- * @param node - The node from which the transaction originates.
1160
- * @returns An instance of Builder
1161
- */
1162
- from(node: TNodeDotKsmWithRelayChains): GeneralBuilder<TApi, TRes, T & {
1163
- from: TNodeDotKsmWithRelayChains;
1164
- }>;
1165
- /**
1166
- * Specifies the destination node for the transaction.
1167
- *
1168
- * @param node - The node to which the transaction is sent.
1169
- * @param paraIdTo - (Optional) The parachain ID of the destination node.
1170
- * @returns An instance of Builder
1171
- */
1172
- to(node: TDestination, paraIdTo?: number): GeneralBuilder<TApi, TRes, T & {
1173
- to: TDestination;
1174
- }>;
1175
- /**
1176
- * Initiates the process to claim assets from a specified node.
1177
- *
1178
- * @param node - The node from which to claim assets.
1179
- * @returns An instance of Builder
1180
- */
1181
- claimFrom(node: TNodeWithRelayChains): AssetClaimBuilder<TApi, TRes, {
1182
- node: TNodeWithRelayChains;
1183
- }>;
1184
- /**
1185
- * Specifies the currency to be used in the transaction. Symbol, ID, multi-location or multi-asset.
1186
- *
1187
- * @param currency - The currency to be transferred.
1188
- * @returns An instance of Builder
1189
- */
1190
- currency(currency: TCurrencyInputWithAmount): GeneralBuilder<TApi, TRes, T & {
1191
- currency: TCurrencyInputWithAmount;
1192
- }>;
1193
- /**
1194
- * Sets the recipient address.
1195
- *
1196
- * @param address - The destination address.
1197
- * @returns An instance of Builder
1198
- */
1199
- address(address: TAddress): GeneralBuilder<TApi, TRes, T & {
1200
- address: TAddress;
1201
- }>;
1202
- /**
1203
- * Sets the sender address.
1204
- *
1205
- * @param address - The sender address.
1206
- * @returns
1207
- */
1208
- senderAddress(address: string): GeneralBuilder<TApi, TRes, T & {
1209
- senderAddress: string;
1210
- }>;
1211
- /**
1212
- * Sets the asset hub address. This is used for transfers that go through the Asset Hub and originate from an EVM chain.
1213
- *
1214
- * @param address - The address to be used.
1215
- * @returns An instance of Builder
1216
- */
1217
- ahAddress(address: string | undefined): GeneralBuilder<TApi, TRes, T & {
1218
- ahAddress: string | undefined;
1219
- }>;
1220
- /**
1221
- * Sets the XCM version to be used for the transfer.
1222
- *
1223
- * @param version - The XCM version.
1224
- * @returns An instance of Builder
1225
- */
1226
- xcmVersion(version: Version): GeneralBuilder<TApi, TRes, T & {
1227
- version: Version;
1228
- }>;
1229
- /**
1230
- * Sets a custom pallet for the transaction.
1231
- *
1232
- * @param palletName - The name of the custom pallet to be used.
1233
- * @returns An instance of the Builder.
1234
- */
1235
- customPallet(pallet: string, method: string): GeneralBuilder<TApi, TRes, T & {
1236
- pallet: string;
1237
- method: string;
1238
- }>;
1239
- /**
1240
- * Optional fee asset for the transaction.
1241
- *
1242
- * @param currency - The currency to be used for the fee.
1243
- * @returns An instance of the Builder
1244
- */
1245
- feeAsset(currency: TCurrencyInput | undefined): GeneralBuilder<TApi, TRes, T & {
1246
- feeAsset: TCurrencyInput | undefined;
1247
- }>;
1248
- /**
1249
- * Adds the transfer transaction to the batch.
1250
- *
1251
- * @returns An instance of Builder
1252
- */
1253
- addToBatch(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>): GeneralBuilder<TApi, TRes, T & {
1254
- from: TNodeDotKsmWithRelayChains;
1255
- }>;
1256
- /**
1257
- * Builds and returns the batched transaction based on the configured parameters.
1258
- *
1259
- * @param options - (Optional) Options to customize the batch transaction.
1260
- * @returns A Extrinsic representing the batched transactions.
1261
- */
1262
- buildBatch(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>, options?: TBatchOptions): Promise<TRes>;
1263
- /**
1264
- * Builds and returns the transfer extrinsic.
1265
- *
1266
- * @returns A Promise that resolves to the transfer extrinsic.
1267
- */
1268
- build(this: GeneralBuilder<TApi, TRes, TSendBaseOptions>): Promise<TRes>;
1269
- dryRun(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TDryRunResult>;
1270
- /**
1271
- * Returns the XCM fee for the transfer using dryRun or paymentInfo function.
1272
- *
1273
- * @returns An origin and destination fee.
1274
- */
1275
- getXcmFee<TDisableFallback extends boolean = false>(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, options?: TGetXcmFeeBuilderOptions & {
1276
- disableFallback: TDisableFallback;
1277
- }): Promise<TGetXcmFeeResult<TDisableFallback>>;
1278
- /**
1279
- * Returns the origin XCM fee for the transfer using dryRun or paymentInfo function.
1280
- *
1281
- * @returns An origin fee.
1282
- */
1283
- getOriginXcmFee(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, { disableFallback }?: TGetXcmFeeBuilderOptions): Promise<TXcmFeeDetail & {
1284
- forwardedXcms?: any;
1285
- destParaId?: number;
1286
- }>;
1287
- /**
1288
- * Estimates the origin and destination XCM fee using paymentInfo function.
1289
- *
1290
- * @returns An origin and destination fee estimate.
1291
- */
1292
- getXcmFeeEstimate(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TGetXcmFeeEstimateResult>;
1293
- /**
1294
- * Estimates the origin XCM fee using paymentInfo function.
1295
- *
1296
- * @returns An origin fee estimate.
1297
- */
1298
- getOriginXcmFeeEstimate(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TGetXcmFeeEstimateDetail>;
1299
- /**
1300
- * Returns the max transferable amount for the transfer
1301
- *
1302
- * @returns The max transferable amount.
1303
- */
1304
- getTransferableAmount(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<bigint>;
1305
- /**
1306
- * Returns the max transferable amount for the transfer
1307
- *
1308
- * @returns The max transferable amount.
1309
- */
1310
- verifyEdOnDestination(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<boolean>;
1311
- /**
1312
- * Returns the transfer info for the transfer
1313
- *
1314
- * @returns The transfer info.
1315
- */
1316
- getTransferInfo(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TTransferInfo>;
1317
- /**
1318
- * Returns the API instance used by the builder.
1319
- *
1320
- * @returns The API instance.
1321
- */
1322
- getApi(): TApi;
1323
- /**
1324
- * Disconnects the API.
1325
- *
1326
- * @returns A Promise that resolves when the API is disconnected.
1327
- */
1328
- disconnect(): Promise<void>;
1329
- }
1330
- /**
1331
- * Creates a new Builder instance.
1332
- *
1333
- * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
1334
- * @returns A new Builder instance.
1335
- */
1336
- declare const Builder: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>) => GeneralBuilder<TApi, TRes, object>;
1337
-
1338
1341
  declare const ETH_CHAIN_ID: bigint;
1339
1342
  declare const ETHEREUM_JUNCTION: TJunction;
1340
1343
  declare const TX_CLIENT_TIMEOUT_MS: number;
@@ -1940,7 +1943,7 @@ declare const getBalanceNative: <TApi, TRes>(options: TGetBalanceNativeOptions<T
1940
1943
  declare const getOriginFeeDetailsInternal: <TApi, TRes>({ api, account, accountDestination, ahAddress, currency, origin, destination, feeMarginPercentage }: TGetOriginFeeDetailsOptions<TApi, TRes>) => Promise<TOriginFeeDetails>;
1941
1944
  declare const getOriginFeeDetails: <TApi, TRes>(options: TGetOriginFeeDetailsOptions<TApi, TRes>) => Promise<TOriginFeeDetails>;
1942
1945
 
1943
- declare const getTransferableAmountInternal: <TApi, TRes>({ api, senderAddress, origin: node, destination, currency, tx, feeAsset }: TGetTransferableAmountOptions<TApi, TRes>) => Promise<bigint>;
1946
+ declare const getTransferableAmountInternal: <TApi, TRes>({ api, senderAddress, origin: node, destination, currency, builder, feeAsset }: TGetTransferableAmountOptions<TApi, TRes>) => Promise<bigint>;
1944
1947
  declare const getTransferableAmount: <TApi, TRes>(options: TGetTransferableAmountOptions<TApi, TRes>) => Promise<bigint>;
1945
1948
 
1946
1949
  declare const getTransferInfo: <TApi, TRes>({ api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset }: TGetTransferInfoOptions<TApi, TRes>) => Promise<TTransferInfo>;
@@ -2081,4 +2084,4 @@ declare const handleToAhTeleport: <TApi, TRes>(origin: TNodePolkadotKusama, inpu
2081
2084
  declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, isDestination?: boolean) => void;
2082
2085
 
2083
2086
  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, UnableToComputeError, XTokensError, addEthereumBridgeFees, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createMultiAsset, createVersionedMultiAssets, createX1Payload, deriveAccountId, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChainLocation, getChainVersion, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getRelayChainOf, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, localizeLocation, maybeOverrideMultiAsset, maybeOverrideMultiAssets, padFee, padFeeBy, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, sortMultiAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination };
2084
- export type { HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress, XcmFeeHopResult };
2087
+ export type { HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TAttemptDryRunFeeOptions, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress, XcmFeeHopResult };
package/dist/index.mjs CHANGED
@@ -3971,6 +3971,22 @@ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, cu
3971
3971
  return asset !== null && asset !== void 0 ? asset : undefined;
3972
3972
  };
3973
3973
 
3974
+ var validateAddress = function validateAddress(address, node) {
3975
+ var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3976
+ if (isTMultiLocation(address)) return;
3977
+ var isEvm = isNodeEvm(node);
3978
+ var isEthereumAddress = isAddress(address);
3979
+ if (isEvm) {
3980
+ if (!isEthereumAddress) {
3981
+ throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
3982
+ }
3983
+ } else {
3984
+ if (isEthereumAddress) {
3985
+ throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "node is not an EVM chain."));
3986
+ }
3987
+ }
3988
+ };
3989
+
3974
3990
  var isAssetHub = function isAssetHub(chain) {
3975
3991
  return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
3976
3992
  };
@@ -5474,22 +5490,6 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
5474
5490
  return !(hasMultiAsset || hasOverriddenMultilocation);
5475
5491
  };
5476
5492
 
5477
- var validateAddress = function validateAddress(address, node) {
5478
- var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
5479
- if (isTMultiLocation(address)) return;
5480
- var isEvm = isNodeEvm(node);
5481
- var isEthereumAddress = isAddress(address);
5482
- if (isEvm) {
5483
- if (!isEthereumAddress) {
5484
- throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
5485
- }
5486
- } else {
5487
- if (isEthereumAddress) {
5488
- throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "node is not an EVM chain."));
5489
- }
5490
- }
5491
- };
5492
-
5493
5493
  var validateDestinationAddress = function validateDestinationAddress(address, destination) {
5494
5494
  if (typeof address === 'string' && !isTMultiLocation(destination)) {
5495
5495
  validateAddress(address, destination);
@@ -6166,13 +6166,68 @@ var send = /*#__PURE__*/function () {
6166
6166
  };
6167
6167
  }();
6168
6168
 
6169
+ var attemptDryRunFee = /*#__PURE__*/function () {
6170
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
6171
+ var currency, builder, reductionPcts, lastReduction, result, _i, _reductionPcts, percentage, modifiedBuilder, _t, _t2, _t3, _t4, _t5, _t6, _t7;
6172
+ return _regenerator().w(function (_context) {
6173
+ while (1) switch (_context.n) {
6174
+ case 0:
6175
+ currency = options.currency, builder = options.builder;
6176
+ reductionPcts = [0, 10, 20, 30, 40, 50];
6177
+ lastReduction = reductionPcts[reductionPcts.length - 1];
6178
+ result = null;
6179
+ _i = 0, _reductionPcts = reductionPcts;
6180
+ case 1:
6181
+ if (!(_i < _reductionPcts.length)) {
6182
+ _context.n = 5;
6183
+ break;
6184
+ }
6185
+ percentage = _reductionPcts[_i];
6186
+ modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
6187
+ amount: padFeeBy(BigInt(currency.amount), -percentage)
6188
+ }));
6189
+ _t = getOriginXcmFee;
6190
+ _t2 = _objectSpread2;
6191
+ _t3 = _objectSpread2({}, options);
6192
+ _t4 = {};
6193
+ _context.n = 2;
6194
+ return modifiedBuilder.build();
6195
+ case 2:
6196
+ _t5 = _context.v;
6197
+ _t6 = {
6198
+ tx: _t5
6199
+ };
6200
+ _t7 = _t2(_t3, _t4, _t6);
6201
+ _context.n = 3;
6202
+ return _t(_t7);
6203
+ case 3:
6204
+ result = _context.v;
6205
+ if (!(result.feeType === 'dryRun' || percentage === lastReduction)) {
6206
+ _context.n = 4;
6207
+ break;
6208
+ }
6209
+ return _context.a(2, result);
6210
+ case 4:
6211
+ _i++;
6212
+ _context.n = 1;
6213
+ break;
6214
+ case 5:
6215
+ return _context.a(2, result);
6216
+ }
6217
+ }, _callee);
6218
+ }));
6219
+ return function attemptDryRunFee(_x) {
6220
+ return _ref.apply(this, arguments);
6221
+ };
6222
+ }();
6223
+
6169
6224
  var getTransferableAmountInternal = /*#__PURE__*/function () {
6170
6225
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
6171
- var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
6226
+ var api, senderAddress, node, destination, currency, builder, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$attemptDryRunF, fee, transferable;
6172
6227
  return _regenerator().w(function (_context) {
6173
6228
  while (1) switch (_context.n) {
6174
6229
  case 0:
6175
- api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.origin, destination = _ref.destination, currency = _ref.currency, tx = _ref.tx, feeAsset = _ref.feeAsset;
6230
+ api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.origin, destination = _ref.destination, currency = _ref.currency, builder = _ref.builder, feeAsset = _ref.feeAsset;
6176
6231
  validateAddress(senderAddress, node, false);
6177
6232
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, node, destination, currency) : undefined;
6178
6233
  asset = findAssetForNodeOrThrow(node, currency, null);
@@ -6194,9 +6249,9 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
6194
6249
  break;
6195
6250
  }
6196
6251
  _context.n = 2;
6197
- return getOriginXcmFee({
6252
+ return attemptDryRunFee({
6198
6253
  api: api,
6199
- tx: tx,
6254
+ builder: builder,
6200
6255
  origin: node,
6201
6256
  destination: node,
6202
6257
  senderAddress: senderAddress,
@@ -6205,8 +6260,8 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
6205
6260
  disableFallback: false
6206
6261
  });
6207
6262
  case 2:
6208
- _yield$getOriginXcmFe = _context.v;
6209
- fee = _yield$getOriginXcmFe.fee;
6263
+ _yield$attemptDryRunF = _context.v;
6264
+ fee = _yield$attemptDryRunF.fee;
6210
6265
  if (!(fee === undefined)) {
6211
6266
  _context.n = 3;
6212
6267
  break;
@@ -11857,27 +11912,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
11857
11912
  key: "getTransferableAmount",
11858
11913
  value: (function () {
11859
11914
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
11860
- var _this$_options7, from, to, senderAddress, currency, feeAsset, tx;
11915
+ var _this$_options7, from, to, senderAddress, currency, feeAsset;
11861
11916
  return _regenerator().w(function (_context8) {
11862
11917
  while (1) switch (_context8.n) {
11863
11918
  case 0:
11864
11919
  _this$_options7 = this._options, from = _this$_options7.from, to = _this$_options7.to, senderAddress = _this$_options7.senderAddress, currency = _this$_options7.currency, feeAsset = _this$_options7.feeAsset;
11865
11920
  assertToIsString(to);
11866
11921
  _context8.n = 1;
11867
- return this.build();
11868
- case 1:
11869
- tx = _context8.v;
11870
- _context8.n = 2;
11871
11922
  return getTransferableAmount({
11872
11923
  api: this.api,
11873
- tx: tx,
11924
+ builder: this,
11874
11925
  origin: from,
11875
11926
  destination: to,
11876
11927
  senderAddress: senderAddress,
11877
11928
  feeAsset: feeAsset,
11878
11929
  currency: currency
11879
11930
  });
11880
- case 2:
11931
+ case 1:
11881
11932
  return _context8.a(2, _context8.v);
11882
11933
  }
11883
11934
  }, _callee8, this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "10.10.7",
3
+ "version": "10.10.9",
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": "^1.2.6",
28
28
  "viem": "^2.31.6",
29
- "@paraspell/pallets": "10.10.7",
30
- "@paraspell/assets": "10.10.7",
31
- "@paraspell/sdk-common": "10.10.7"
29
+ "@paraspell/assets": "10.10.9",
30
+ "@paraspell/sdk-common": "10.10.9",
31
+ "@paraspell/pallets": "10.10.9"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",