@paraspell/sdk-core 10.11.6 → 10.11.8

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isNodeEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, getNativeAssetSymbol, getOtherAssets, extractMultiAssetLoc, isAssetEqual, findAssetForNodeOrThrow, getExistentialDeposit, findAsset, isTMultiAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAssetOnDestOrThrow, hasSupportForAsset, getRelayChainSymbol, isSymbolSpecifier, normalizeMultiLocation, normalizeSymbol, Native, hasXcmPaymentApiSupport, getNativeAssets } from '@paraspell/assets';
2
+ import { isNodeEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, getNativeAssetSymbol, getOtherAssets, extractMultiAssetLoc, isAssetEqual, findAssetForNodeOrThrow, getExistentialDeposit, findAsset, isTMultiAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAssetOnDestOrThrow, hasSupportForAsset, getRelayChainSymbol, isSymbolSpecifier, normalizeMultiLocation, hasXcmPaymentApiSupport, normalizeSymbol, Native, getNativeAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, createPublicClient, http, getContract } from 'viem';
@@ -701,6 +701,7 @@ var convertSs58 = function convertSs58(api, address, node) {
701
701
  return encodeSs58(deriveAccountId(publicKey), ss58Prefix);
702
702
  };
703
703
 
704
+ var MIN_FEE = 1000n;
704
705
  var DEFAULT_FEE_ASSET = 0;
705
706
  var ETH_PARA_ID = 1;
706
707
  var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
@@ -716,6 +717,12 @@ var DOT_MULTILOCATION = {
716
717
  parents: Parents.ONE,
717
718
  interior: 'Here'
718
719
  };
720
+ var RELAY_LOCATION = {
721
+ parents: Parents.ONE,
722
+ interior: {
723
+ Here: null
724
+ }
725
+ };
719
726
  var CHAINS_DOT_RESERVE_AH = new Set(['Polimec', 'Moonbeam', 'AssetHubPolkadot', 'AssetHubKusama', 'AssetHubWestend', 'AssetHubPaseo', 'BifrostPolkadot', 'BifrostKusama', 'PeoplePolkadot', 'PeopleKusama', 'Ajuna']);
720
727
  var ASSET_HUB_EXECUTION_FEE = 2200000000n; // 0.22 DOT
721
728
  var TX_CLIENT_TIMEOUT_MS = 20 * 60 * 1000; // 20 minutes
@@ -739,7 +746,7 @@ var assertToIsString = function assertToIsString(to, overrideMsg) {
739
746
  };
740
747
  var assertAddressIsString = function assertAddressIsString(address) {
741
748
  if (isTMultiLocation(address)) {
742
- throw new InvalidParameterError('Multi-Location address is not supported for XCM fee calculation.');
749
+ throw new InvalidParameterError('Multi-Location address is not supported for this transfer type.');
743
750
  }
744
751
  };
745
752
  var assertHasLocation = function assertHasLocation(asset) {
@@ -6193,136 +6200,307 @@ var send = /*#__PURE__*/function () {
6193
6200
  };
6194
6201
  }();
6195
6202
 
6196
- var createTypeAndThenCall = function createTypeAndThenCall(chain, destChain, reserveChain, input, reserveFee) {
6197
- var api = input.api,
6198
- destination = input.destination,
6199
- asset = input.asset,
6200
- version = input.version,
6201
- address = input.address,
6202
- paraIdTo = input.paraIdTo;
6203
- assertHasLocation(asset);
6203
+ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, customXcm, assets) {
6204
+ var origin = _ref.origin,
6205
+ reserve = _ref.reserve,
6206
+ dest = _ref.dest,
6207
+ asset = _ref.asset,
6208
+ version = _ref.options.version;
6209
+ var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : asset.multiLocation;
6210
+ var finalDest = origin.chain === reserve.chain ? dest.chain : reserve.chain;
6211
+ var destLocation = createDestination(version, origin.chain, finalDest, getParaId(finalDest));
6212
+ var reserveType = origin.chain === reserve.chain ? 'LocalReserve' : 'DestinationReserve';
6213
+ var feeMultiAsset = createMultiAsset(version, asset.amount, feeAssetLocation);
6214
+ return {
6215
+ module: 'PolkadotXcm',
6216
+ method: 'transfer_assets_using_type_and_then',
6217
+ parameters: {
6218
+ dest: addXcmVersionHeader(destLocation, version),
6219
+ assets: addXcmVersionHeader(assets, version),
6220
+ assets_transfer_type: reserveType,
6221
+ remote_fees_id: addXcmVersionHeader(feeMultiAsset.id, version),
6222
+ fees_transfer_type: reserveType,
6223
+ custom_xcm_on_dest: addXcmVersionHeader(customXcm, version),
6224
+ weight_limit: 'Unlimited'
6225
+ }
6226
+ };
6227
+ };
6228
+
6229
+ var FEE_PADDING_PERCENTAGE$2 = 20;
6230
+ var FEE_PADDING_HYDRATION = 150;
6231
+ var computeInstructionFee = /*#__PURE__*/function () {
6232
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, version, xcm) {
6233
+ var chain, api, _t, _t2, _t3;
6234
+ return _regenerator().w(function (_context) {
6235
+ while (1) switch (_context.n) {
6236
+ case 0:
6237
+ chain = _ref.chain, api = _ref.api;
6238
+ _t = padFeeBy;
6239
+ _context.n = 1;
6240
+ return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), {
6241
+ multiLocation: DOT_MULTILOCATION
6242
+ }, true);
6243
+ case 1:
6244
+ _t2 = _context.v;
6245
+ _t3 = chain === 'Hydration' ? FEE_PADDING_HYDRATION : FEE_PADDING_PERCENTAGE$2;
6246
+ return _context.a(2, _t(_t2, _t3));
6247
+ }
6248
+ }, _callee);
6249
+ }));
6250
+ return function computeInstructionFee(_x, _x2, _x3) {
6251
+ return _ref2.apply(this, arguments);
6252
+ };
6253
+ }();
6254
+ var computeAllFees = /*#__PURE__*/function () {
6255
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3, customXcm, isDotAsset, refundInstruction) {
6256
+ var reserve, dest, version, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
6257
+ return _regenerator().w(function (_context2) {
6258
+ while (1) switch (_context2.n) {
6259
+ case 0:
6260
+ reserve = _ref3.reserve, dest = _ref3.dest, version = _ref3.options.version;
6261
+ if (!('DepositReserveAsset' in customXcm)) {
6262
+ _context2.n = 6;
6263
+ break;
6264
+ }
6265
+ _context2.n = 1;
6266
+ return computeInstructionFee(reserve, version, [customXcm]);
6267
+ case 1:
6268
+ _t5 = _context2.v;
6269
+ if (!refundInstruction) {
6270
+ _context2.n = 3;
6271
+ break;
6272
+ }
6273
+ _context2.n = 2;
6274
+ return computeInstructionFee(reserve, version, [refundInstruction]);
6275
+ case 2:
6276
+ _t6 = _context2.v;
6277
+ _context2.n = 4;
6278
+ break;
6279
+ case 3:
6280
+ _t6 = 0n;
6281
+ case 4:
6282
+ _t7 = _t6;
6283
+ _context2.n = 5;
6284
+ return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm.DepositReserveAsset.xcm);
6285
+ case 5:
6286
+ _t8 = _context2.v;
6287
+ _t4 = {
6288
+ reserveFee: _t5,
6289
+ refundFee: _t7,
6290
+ destFee: _t8
6291
+ };
6292
+ _context2.n = 13;
6293
+ break;
6294
+ case 6:
6295
+ if (isDotAsset) {
6296
+ _context2.n = 8;
6297
+ break;
6298
+ }
6299
+ _context2.n = 7;
6300
+ return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, [customXcm]);
6301
+ case 7:
6302
+ _t9 = _context2.v;
6303
+ _context2.n = 9;
6304
+ break;
6305
+ case 8:
6306
+ _t9 = 0n;
6307
+ case 9:
6308
+ _t0 = _t9;
6309
+ if (isDotAsset) {
6310
+ _context2.n = 11;
6311
+ break;
6312
+ }
6313
+ _context2.n = 10;
6314
+ return computeInstructionFee(hasXcmPaymentApiSupport(reserve.chain) ? reserve : dest, version, [refundInstruction]);
6315
+ case 10:
6316
+ _t1 = _context2.v;
6317
+ _context2.n = 12;
6318
+ break;
6319
+ case 11:
6320
+ _t1 = 0n;
6321
+ case 12:
6322
+ _t10 = _t1;
6323
+ _t4 = {
6324
+ reserveFee: 0n,
6325
+ destFee: _t0,
6326
+ refundFee: _t10
6327
+ };
6328
+ case 13:
6329
+ return _context2.a(2, _t4);
6330
+ }
6331
+ }, _callee2);
6332
+ }));
6333
+ return function computeAllFees(_x4, _x5, _x6, _x7) {
6334
+ return _ref4.apply(this, arguments);
6335
+ };
6336
+ }();
6337
+
6338
+ var createTypeAndThenCallContext = /*#__PURE__*/function () {
6339
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
6340
+ var api, paraIdTo, asset, destChain, reserveChain, destApi, reserveApi;
6341
+ return _regenerator().w(function (_context) {
6342
+ while (1) switch (_context.n) {
6343
+ case 0:
6344
+ api = options.api, paraIdTo = options.paraIdTo, asset = options.asset;
6345
+ assertHasLocation(asset);
6346
+ destChain = getTNode(paraIdTo, getRelayChainOf(chain).toLowerCase());
6347
+ reserveChain = isRelayChain(destChain) ? destChain : getAssetReserveChain(chain, chain, asset.multiLocation);
6348
+ destApi = api.clone();
6349
+ _context.n = 1;
6350
+ return destApi.init(destChain);
6351
+ case 1:
6352
+ reserveApi = reserveChain !== chain ? api.clone() : destApi;
6353
+ _context.n = 2;
6354
+ return reserveApi.init(reserveChain);
6355
+ case 2:
6356
+ return _context.a(2, {
6357
+ origin: {
6358
+ api: api,
6359
+ chain: chain
6360
+ },
6361
+ dest: {
6362
+ api: destApi,
6363
+ chain: destChain
6364
+ },
6365
+ reserve: {
6366
+ api: reserveApi,
6367
+ chain: reserveChain
6368
+ },
6369
+ asset: asset,
6370
+ options: options
6371
+ });
6372
+ }
6373
+ }, _callee);
6374
+ }));
6375
+ return function createTypeAndThenCallContext(_x, _x2) {
6376
+ return _ref.apply(this, arguments);
6377
+ };
6378
+ }();
6379
+
6380
+ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
6381
+ var origin = _ref.origin,
6382
+ dest = _ref.dest,
6383
+ reserve = _ref.reserve,
6384
+ asset = _ref.asset,
6385
+ options = _ref.options;
6386
+ var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
6387
+ reserveFee: MIN_FEE,
6388
+ refundFee: 0n,
6389
+ destFee: MIN_FEE
6390
+ };
6391
+ var destination = options.destination,
6392
+ version = options.version,
6393
+ address = options.address,
6394
+ paraIdTo = options.paraIdTo;
6395
+ var reserveFee = fees.reserveFee,
6396
+ refundFee = fees.refundFee,
6397
+ destFee = fees.destFee;
6398
+ var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : asset.multiLocation;
6399
+ var multiAsset = createMultiAsset(version, asset.amount, localizeLocation(dest.chain, asset.multiLocation));
6204
6400
  var depositInstruction = {
6205
6401
  DepositAsset: {
6206
6402
  assets: {
6207
- Wild: 'All'
6403
+ Wild: {
6404
+ AllOf: {
6405
+ id: multiAsset.id,
6406
+ fun: 'Fungible'
6407
+ }
6408
+ }
6208
6409
  },
6209
6410
  beneficiary: createBeneficiaryLocation({
6210
- api: api,
6411
+ api: origin.api,
6211
6412
  address: address,
6212
6413
  version: version
6213
6414
  })
6214
6415
  }
6215
6416
  };
6216
- var customXcm = chain === reserveChain || destChain === reserveChain ? [depositInstruction] : [{
6417
+ var assetsFilter = [];
6418
+ if (!isDotAsset) assetsFilter.push(createMultiAsset(version, reserveFee + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
6419
+ assetsFilter.push(createMultiAsset(version, asset.amount, localizeLocation(reserve.chain, asset.multiLocation)));
6420
+ return origin.chain !== reserve.chain && dest.chain !== reserve.chain ? {
6217
6421
  DepositReserveAsset: {
6218
- assets: {
6422
+ assets: fees.destFee === MIN_FEE ? {
6219
6423
  Wild: 'All'
6424
+ } : {
6425
+ Definite: assetsFilter
6220
6426
  },
6221
- dest: createDestination(version, chain, destination, paraIdTo),
6427
+ dest: createDestination(version, origin.chain, destination, paraIdTo),
6222
6428
  xcm: [{
6223
6429
  BuyExecution: {
6224
- fees: createMultiAsset(version, reserveFee, asset.multiLocation),
6430
+ fees: createMultiAsset(version, !isDotAsset ? destFee : asset.amount - reserveFee - refundFee, feeAssetLocation),
6225
6431
  weight_limit: 'Unlimited'
6226
6432
  }
6227
6433
  }, depositInstruction]
6228
6434
  }
6229
- }];
6230
- var finalDest = chain === reserveChain ? destChain : reserveChain;
6231
- var dest = createVersionedDestination(version, chain, finalDest, getParaId(finalDest));
6232
- var multiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
6233
- var assets = addXcmVersionHeader([multiAsset], version);
6234
- var customXcmVersioned = addXcmVersionHeader(customXcm, version);
6235
- var feesLocation = addXcmVersionHeader(multiAsset.id, version);
6236
- var reserve = chain === reserveChain ? 'LocalReserve' : 'DestinationReserve';
6237
- return {
6238
- module: 'PolkadotXcm',
6239
- method: 'transfer_assets_using_type_and_then',
6240
- parameters: {
6241
- dest: dest,
6242
- assets: assets,
6243
- assets_transfer_type: reserve,
6244
- remote_fees_id: feesLocation,
6245
- fees_transfer_type: reserve,
6246
- custom_xcm_on_dest: customXcmVersioned,
6247
- weight_limit: 'Unlimited'
6248
- }
6249
- };
6435
+ } : depositInstruction;
6250
6436
  };
6251
6437
 
6252
- var validateHops$1 = function validateHops(hops) {
6253
- var _iterator = _createForOfIteratorHelper(hops),
6254
- _step;
6255
- try {
6256
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
6257
- var hop = _step.value;
6258
- if (!hop.result.success) {
6259
- throw new DryRunFailedError("Dry run failed on an intermediate hop (".concat(hop.chain, "). Reason: ").concat(hop.result.failureReason || 'Unknown'));
6438
+ var createRefundInstruction = function createRefundInstruction(api, senderAddress, version) {
6439
+ return {
6440
+ SetAppendix: [{
6441
+ DepositAsset: {
6442
+ assets: {
6443
+ Wild: 'All'
6444
+ },
6445
+ beneficiary: createBeneficiaryLocation({
6446
+ api: api,
6447
+ address: senderAddress,
6448
+ version: version
6449
+ })
6260
6450
  }
6261
- }
6262
- } catch (err) {
6263
- _iterator.e(err);
6264
- } finally {
6265
- _iterator.f();
6266
- }
6451
+ }]
6452
+ };
6267
6453
  };
6268
- var getReserveFeeFromHops$1 = function getReserveFeeFromHops(hops) {
6269
- if (!hops || hops.length === 0 || !hops[0].result.success) {
6270
- return MIN_FEE$2;
6454
+
6455
+ var buildAssets = function buildAssets(asset, feeAmount, isDotAsset, version) {
6456
+ var assets = [];
6457
+ if (!isDotAsset) {
6458
+ assets.push(createMultiAsset(version, feeAmount, RELAY_LOCATION));
6271
6459
  }
6272
- return hops[0].result.fee;
6460
+ assets.push(createMultiAsset(version, asset.amount, asset.multiLocation));
6461
+ return assets;
6273
6462
  };
6274
- var MIN_FEE$2 = 1000n;
6275
- var FEE_PADDING_PERCENTAGE$2 = 40;
6276
- var createTypeAndThenTransfer$2 = /*#__PURE__*/function () {
6277
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, input) {
6278
- var api, address, paraIdTo, senderAddress, currency, asset, destChain, reserveChain, call, dryRunResult, reserveFeeEstimate, reserveFee;
6463
+ /**
6464
+ * Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
6465
+ */
6466
+ var createTypeAndThenCall = /*#__PURE__*/function () {
6467
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
6468
+ var api, senderAddress, version, context, asset, isDotAsset, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
6279
6469
  return _regenerator().w(function (_context) {
6280
6470
  while (1) switch (_context.n) {
6281
6471
  case 0:
6282
- api = input.api, address = input.address, paraIdTo = input.paraIdTo, senderAddress = input.senderAddress, currency = input.currency, asset = input.asset;
6283
- if (senderAddress) {
6284
- _context.n = 1;
6285
- break;
6286
- }
6287
- throw new InvalidParameterError('Please provide senderAddress');
6472
+ api = options.api, senderAddress = options.senderAddress, version = options.version;
6473
+ _context.n = 1;
6474
+ return createTypeAndThenCallContext(chain, options);
6288
6475
  case 1:
6289
- assertHasLocation(asset);
6290
- assertAddressIsString(address);
6291
- destChain = getTNode(paraIdTo, getRelayChainOf(chain).toLowerCase());
6292
- reserveChain = isRelayChain(destChain) ? destChain : getAssetReserveChain(chain, chain, asset.multiLocation);
6293
- call = createTypeAndThenCall(chain, destChain, reserveChain, input, MIN_FEE$2);
6294
- if (!(chain === reserveChain || destChain === reserveChain)) {
6295
- _context.n = 2;
6296
- break;
6297
- }
6298
- return _context.a(2, call);
6299
- case 2:
6300
- _context.n = 3;
6301
- return dryRunInternal({
6302
- api: api,
6303
- tx: api.callTxMethod(call),
6304
- origin: chain,
6305
- destination: destChain,
6306
- senderAddress: senderAddress,
6307
- address: address,
6308
- currency: currency
6476
+ context = _context.v;
6477
+ asset = context.asset;
6478
+ isDotAsset = deepEqual(asset.multiLocation, RELAY_LOCATION) || deepEqual(asset.multiLocation, {
6479
+ parents: 2,
6480
+ interior: {
6481
+ X1: [{
6482
+ GlobalConsensus: {
6483
+ Kusama: null
6484
+ }
6485
+ }]
6486
+ }
6309
6487
  });
6310
- case 3:
6311
- dryRunResult = _context.v;
6312
- if (dryRunResult.origin.success) {
6313
- _context.n = 4;
6314
- break;
6315
- }
6316
- throw new DryRunFailedError(dryRunResult.failureReason);
6317
- case 4:
6318
- validateHops$1(dryRunResult.hops);
6319
- reserveFeeEstimate = getReserveFeeFromHops$1(dryRunResult.hops);
6320
- reserveFee = padFeeBy(reserveFeeEstimate, FEE_PADDING_PERCENTAGE$2);
6321
- return _context.a(2, createTypeAndThenCall(chain, destChain, reserveChain, input, reserveFee));
6488
+ customXcm = createCustomXcm(context, isDotAsset);
6489
+ refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version) : null;
6490
+ _context.n = 2;
6491
+ return computeAllFees(context, customXcm, isDotAsset, refundInstruction);
6492
+ case 2:
6493
+ fees = _context.v;
6494
+ finalCustomXcm = [];
6495
+ if (refundInstruction) finalCustomXcm.push(refundInstruction);
6496
+ finalCustomXcm.push(createCustomXcm(context, isDotAsset, fees));
6497
+ totalFee = fees.reserveFee + fees.destFee + fees.refundFee;
6498
+ assets = buildAssets(asset, totalFee, isDotAsset, version);
6499
+ return _context.a(2, buildTypeAndThenCall(context, isDotAsset, finalCustomXcm, assets));
6322
6500
  }
6323
6501
  }, _callee);
6324
6502
  }));
6325
- return function createTypeAndThenTransfer(_x, _x2) {
6503
+ return function createTypeAndThenCall(_x, _x2) {
6326
6504
  return _ref.apply(this, arguments);
6327
6505
  };
6328
6506
  }();
@@ -7052,11 +7230,10 @@ var validateHops = function validateHops(hops) {
7052
7230
  };
7053
7231
  var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
7054
7232
  if (!hops || hops.length === 0 || !hops[0].result.success) {
7055
- return MIN_FEE$1;
7233
+ return MIN_FEE;
7056
7234
  }
7057
7235
  return hops[0].result.fee;
7058
7236
  };
7059
- var MIN_FEE$1 = 1000n;
7060
7237
  var FEE_PADDING_PERCENTAGE$1 = 40;
7061
7238
  var handleExecuteTransfer = /*#__PURE__*/function () {
7062
7239
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
@@ -7096,7 +7273,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7096
7273
  throw new InvalidParameterError("Asset amount is too low, please increase the amount or use a different fee asset.");
7097
7274
  }
7098
7275
  };
7099
- checkAmount(MIN_FEE$1);
7276
+ checkAmount(MIN_FEE);
7100
7277
  destChain = getTNode(paraIdTo, getRelayChainOf(chain).toLowerCase());
7101
7278
  internalOptions = {
7102
7279
  api: api,
@@ -7114,8 +7291,8 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7114
7291
  };
7115
7292
  call = createExecuteCall(chain, createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
7116
7293
  fees: {
7117
- originFee: feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE$1,
7118
- reserveFee: MIN_FEE$1
7294
+ originFee: feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE,
7295
+ reserveFee: MIN_FEE
7119
7296
  }
7120
7297
  })), MAX_WEIGHT);
7121
7298
  _context.n = 5;
@@ -7286,7 +7463,6 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
7286
7463
  };
7287
7464
  }();
7288
7465
 
7289
- var MIN_FEE = 1000n;
7290
7466
  var FEE_PADDING_PERCENTAGE = 20;
7291
7467
  var validateAmount = function validateAmount(amount, requiredFee) {
7292
7468
  if (amount <= requiredFee) {
@@ -7865,7 +8041,7 @@ var ParachainNode = /*#__PURE__*/function () {
7865
8041
  key: "transfer",
7866
8042
  value: function () {
7867
8043
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
7868
- var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, shouldUseMultiasset, input, _options, isEthAsset, isAHPOrigin, isAHPDest, isEthDest;
8044
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, shouldUseMultiasset, input, _options, isEthAsset, isAHPOrigin, isAHPDest, isEthDest, isEthAssetViaAh, isEthAssetToAh, call;
7869
8045
  return _regenerator().w(function (_context) {
7870
8046
  while (1) switch (_context.n) {
7871
8047
  case 0:
@@ -7962,17 +8138,17 @@ var ParachainNode = /*#__PURE__*/function () {
7962
8138
  isAHPOrigin = this.node === 'AssetHubPolkadot' || this.node === 'AssetHubKusama';
7963
8139
  isAHPDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
7964
8140
  isEthDest = destination === 'Ethereum'; // Eth asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
7965
- if (!(isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset)) {
7966
- _context.n = 6;
7967
- break;
7968
- }
7969
- return _context.a(2, this.transferEthAssetViaAH(_options));
7970
- case 6:
7971
- if (!(isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset)) {
8141
+ isEthAssetViaAh = isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // Eth asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
8142
+ isEthAssetToAh = isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
8143
+ if (!(isEthAssetViaAh || isEthAssetToAh)) {
7972
8144
  _context.n = 7;
7973
8145
  break;
7974
8146
  }
7975
- return _context.a(2, this.transferToEthereum(_options, true));
8147
+ _context.n = 6;
8148
+ return createTypeAndThenCall(this.node, _options);
8149
+ case 6:
8150
+ call = _context.v;
8151
+ return _context.a(2, api.callTxMethod(call));
7976
8152
  case 7:
7977
8153
  return _context.a(2, this.transferPolkadotXCM(_options));
7978
8154
  case 8:
@@ -8079,118 +8255,11 @@ var ParachainNode = /*#__PURE__*/function () {
8079
8255
  }
8080
8256
  });
8081
8257
  }
8082
- }, {
8083
- key: "transferEthAssetViaAH",
8084
- value: function () {
8085
- var _transferEthAssetViaAH = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
8086
- var _feeAsset$multiLocati;
8087
- var api, asset, version, destination, address, senderAddress, feeAsset, paraIdTo, ethMultiAsset, PARA_TO_PARA_FEE_DOT, AH_EXECUTION_FEE_PADDED, dryRunResult, dryRunFeePadded, dest, call;
8088
- return _regenerator().w(function (_context2) {
8089
- while (1) switch (_context2.n) {
8090
- case 0:
8091
- api = input.api, asset = input.asset, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset, paraIdTo = input.paraIdTo;
8092
- assertHasLocation(asset);
8093
- if (!(senderAddress === undefined)) {
8094
- _context2.n = 1;
8095
- break;
8096
- }
8097
- throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
8098
- case 1:
8099
- if (!isTMultiLocation(address)) {
8100
- _context2.n = 2;
8101
- break;
8102
- }
8103
- throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
8104
- case 2:
8105
- ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
8106
- PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
8107
- // Pad by 25%
8108
- AH_EXECUTION_FEE_PADDED = ASSET_HUB_EXECUTION_FEE * 125n / 100n; // Perform a dry run AH -> dest to calculate the BuyExecution amount
8109
- _context2.n = 3;
8110
- return Builder(api.clone()).from('AssetHubPolkadot').to(destination).currency({
8111
- symbol: Native('DOT'),
8112
- amount: AH_EXECUTION_FEE_PADDED
8113
- }).address(address).senderAddress(senderAddress).dryRun();
8114
- case 3:
8115
- dryRunResult = _context2.v;
8116
- if (dryRunResult.origin.success) {
8117
- _context2.n = 4;
8118
- break;
8119
- }
8120
- throw new DryRunFailedError(dryRunResult.origin.failureReason);
8121
- case 4:
8122
- // Pad fee by 50%
8123
- dryRunFeePadded = BigInt(dryRunResult.origin.fee) * 3n / 2n;
8124
- dest = createDestination(version, this.node, destination, paraIdTo);
8125
- call = {
8126
- module: 'PolkadotXcm',
8127
- method: 'transfer_assets_using_type_and_then',
8128
- parameters: {
8129
- dest: createVersionedDestination(version, this.node, destination, getParaId('AssetHubPolkadot')),
8130
- assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
8131
- assets_transfer_type: 'DestinationReserve',
8132
- remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : DOT_MULTILOCATION, version),
8133
- fees_transfer_type: 'DestinationReserve',
8134
- custom_xcm_on_dest: addXcmVersionHeader([{
8135
- SetAppendix: [{
8136
- DepositAsset: {
8137
- assets: {
8138
- Wild: 'All'
8139
- },
8140
- beneficiary: createBeneficiaryLocation({
8141
- api: api,
8142
- address: senderAddress,
8143
- version: version
8144
- })
8145
- }
8146
- }]
8147
- }, {
8148
- DepositReserveAsset: {
8149
- assets: {
8150
- Wild: 'All'
8151
- },
8152
- dest: dest,
8153
- xcm: [{
8154
- BuyExecution: {
8155
- fees: {
8156
- id: DOT_MULTILOCATION,
8157
- fun: {
8158
- Fungible: dryRunFeePadded
8159
- }
8160
- },
8161
- weight_limit: 'Unlimited'
8162
- }
8163
- }, {
8164
- DepositAsset: {
8165
- assets: {
8166
- Wild: 'All'
8167
- },
8168
- beneficiary: createBeneficiaryLocation({
8169
- api: api,
8170
- address: address,
8171
- version: version
8172
- })
8173
- }
8174
- }]
8175
- }
8176
- }], version),
8177
- weight_limit: 'Unlimited'
8178
- }
8179
- };
8180
- return _context2.a(2, api.callTxMethod(call));
8181
- }
8182
- }, _callee2, this);
8183
- }));
8184
- function transferEthAssetViaAH(_x2) {
8185
- return _transferEthAssetViaAH.apply(this, arguments);
8186
- }
8187
- return transferEthAssetViaAH;
8188
- }()
8189
8258
  }, {
8190
8259
  key: "transferToEthereum",
8191
8260
  value: function () {
8192
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
8193
- var _feeAsset$multiLocati2;
8261
+ var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
8262
+ var _feeAsset$multiLocati;
8194
8263
  var useOnlyDepositInstruction,
8195
8264
  api,
8196
8265
  asset,
@@ -8212,44 +8281,39 @@ var ParachainNode = /*#__PURE__*/function () {
8212
8281
  customXcmOnDest,
8213
8282
  messageId,
8214
8283
  call,
8215
- _args3 = arguments;
8216
- return _regenerator().w(function (_context3) {
8217
- while (1) switch (_context3.n) {
8284
+ _args2 = arguments;
8285
+ return _regenerator().w(function (_context2) {
8286
+ while (1) switch (_context2.n) {
8218
8287
  case 0:
8219
- useOnlyDepositInstruction = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
8288
+ useOnlyDepositInstruction = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;
8220
8289
  api = input.api, asset = input.asset, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset;
8221
- _context3.n = 1;
8290
+ _context2.n = 1;
8222
8291
  return getBridgeStatus(api.clone());
8223
8292
  case 1:
8224
- bridgeStatus = _context3.v;
8293
+ bridgeStatus = _context2.v;
8225
8294
  if (!(bridgeStatus !== 'Normal')) {
8226
- _context3.n = 2;
8295
+ _context2.n = 2;
8227
8296
  break;
8228
8297
  }
8229
8298
  throw new BridgeHaltedError();
8230
8299
  case 2:
8231
8300
  assertHasLocation(asset);
8301
+ assertAddressIsString(address);
8232
8302
  if (!(senderAddress === undefined)) {
8233
- _context3.n = 3;
8303
+ _context2.n = 3;
8234
8304
  break;
8235
8305
  }
8236
8306
  throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
8237
8307
  case 3:
8238
- if (!isTMultiLocation(address)) {
8239
- _context3.n = 4;
8240
- break;
8241
- }
8242
- throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
8243
- case 4:
8244
8308
  ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
8245
- _context3.n = 5;
8309
+ _context2.n = 4;
8246
8310
  return api.createApiForNode('AssetHubPolkadot');
8247
- case 5:
8248
- ahApi = _context3.v;
8249
- _context3.n = 6;
8311
+ case 4:
8312
+ ahApi = _context2.v;
8313
+ _context2.n = 5;
8250
8314
  return getParaEthTransferFees(ahApi);
8251
- case 6:
8252
- _yield$getParaEthTran = _context3.v;
8315
+ case 5:
8316
+ _yield$getParaEthTran = _context2.v;
8253
8317
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
8254
8318
  bridgeFee = _yield$getParaEthTran2[0];
8255
8319
  executionFee = _yield$getParaEthTran2[1];
@@ -8257,13 +8321,13 @@ var ParachainNode = /*#__PURE__*/function () {
8257
8321
  fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : bridgeFee + executionFee;
8258
8322
  ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
8259
8323
  if (ethAsset) {
8260
- _context3.n = 7;
8324
+ _context2.n = 6;
8261
8325
  break;
8262
8326
  }
8263
8327
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset, replaceBigInt)));
8264
- case 7:
8328
+ case 6:
8265
8329
  if (!useOnlyDepositInstruction) {
8266
- _context3.n = 8;
8330
+ _context2.n = 7;
8267
8331
  break;
8268
8332
  }
8269
8333
  customXcmOnDest = addXcmVersionHeader([{
@@ -8280,16 +8344,16 @@ var ParachainNode = /*#__PURE__*/function () {
8280
8344
  })
8281
8345
  }
8282
8346
  }], version);
8283
- _context3.n = 10;
8347
+ _context2.n = 9;
8284
8348
  break;
8285
- case 8:
8349
+ case 7:
8286
8350
  assertHasId(ethAsset);
8287
- _context3.n = 9;
8351
+ _context2.n = 8;
8288
8352
  return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
8289
- case 9:
8290
- messageId = _context3.v;
8353
+ case 8:
8354
+ messageId = _context2.v;
8291
8355
  customXcmOnDest = createCustomXcmOnDest(input, this.node, messageId);
8292
- case 10:
8356
+ case 9:
8293
8357
  call = {
8294
8358
  module: 'PolkadotXcm',
8295
8359
  method: 'transfer_assets_using_type_and_then',
@@ -8297,17 +8361,17 @@ var ParachainNode = /*#__PURE__*/function () {
8297
8361
  dest: createVersionedDestination(version, this.node, destination, getParaId('AssetHubPolkadot')),
8298
8362
  assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, fee, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
8299
8363
  assets_transfer_type: 'DestinationReserve',
8300
- remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati2 = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati2 !== void 0 ? _feeAsset$multiLocati2 : DOT_MULTILOCATION, version),
8364
+ remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : DOT_MULTILOCATION, version),
8301
8365
  fees_transfer_type: 'DestinationReserve',
8302
8366
  custom_xcm_on_dest: customXcmOnDest,
8303
8367
  weight_limit: 'Unlimited'
8304
8368
  }
8305
8369
  };
8306
- return _context3.a(2, api.callTxMethod(call));
8370
+ return _context2.a(2, api.callTxMethod(call));
8307
8371
  }
8308
- }, _callee3, this);
8372
+ }, _callee2, this);
8309
8373
  }));
8310
- function transferToEthereum(_x3) {
8374
+ function transferToEthereum(_x2) {
8311
8375
  return _transferToEthereum.apply(this, arguments);
8312
8376
  }
8313
8377
  return transferToEthereum;
@@ -8413,7 +8477,7 @@ var Ajuna = /*#__PURE__*/function (_ParachainNode) {
8413
8477
  api = input.api;
8414
8478
  _t = api;
8415
8479
  _context.n = 1;
8416
- return createTypeAndThenTransfer$2(this.node, input);
8480
+ return createTypeAndThenCall(this.node, input);
8417
8481
  case 1:
8418
8482
  _t2 = _context.v;
8419
8483
  return _context.a(2, _t.callTxMethod.call(_t, _t2));
@@ -8609,57 +8673,14 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
8609
8673
  }]);
8610
8674
  }(ParachainNode);
8611
8675
 
8612
- var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
8613
- var api = _ref.api,
8614
- address = _ref.address;
8615
- return _defineProperty({}, version, [{
8616
- DepositAsset: {
8617
- assets: {
8618
- Wild: 'All'
8619
- },
8620
- beneficiary: createBeneficiaryLocation({
8621
- api: api,
8622
- address: address,
8623
- version: version
8624
- })
8625
- }
8626
- }]);
8627
- };
8628
8676
  var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8629
8677
  function AssetHubPolkadot() {
8630
- var _this;
8631
8678
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'AssetHubPolkadot';
8632
8679
  var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'PolkadotAssetHub';
8633
8680
  var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'polkadot';
8634
8681
  var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.V5;
8635
8682
  _classCallCheck(this, AssetHubPolkadot);
8636
- _this = _callSuper(this, AssetHubPolkadot, [chain, info, type, version]);
8637
- _this.handleLocalReserveTransfer = function (input) {
8638
- var useDOTAsFeeAsset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
8639
- var api = input.api,
8640
- version = input.version,
8641
- destination = input.destination,
8642
- asset = input.asset,
8643
- paraIdTo = input.paraIdTo;
8644
- assertIsForeign(asset);
8645
- assertHasLocation(asset);
8646
- var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
8647
- var call = {
8648
- module: 'PolkadotXcm',
8649
- method: 'transfer_assets_using_type_and_then',
8650
- parameters: {
8651
- dest: createVersionedDestination(version, _this.node, destination, paraIdTo),
8652
- assets: addXcmVersionHeader([].concat(_toConsumableArray(useDOTAsFeeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [createMultiAsset(version, asset.amount, asset.multiLocation)]), version),
8653
- assets_transfer_type: 'LocalReserve',
8654
- remote_fees_id: addXcmVersionHeader(useDOTAsFeeAsset ? DOT_MULTILOCATION : asset.multiLocation, version),
8655
- fees_transfer_type: 'LocalReserve',
8656
- custom_xcm_on_dest: createCustomXcmToBifrost(input, version),
8657
- weight_limit: 'Unlimited'
8658
- }
8659
- };
8660
- return api.callTxMethod(call);
8661
- };
8662
- return _this;
8683
+ return _callSuper(this, AssetHubPolkadot, [chain, info, type, version]);
8663
8684
  }
8664
8685
  _inherits(AssetHubPolkadot, _ParachainNode);
8665
8686
  return _createClass(AssetHubPolkadot, [{
@@ -8864,14 +8885,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8864
8885
  }, {
8865
8886
  key: "transferPolkadotXCM",
8866
8887
  value: function () {
8867
- var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
8868
- var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isNativeFeeAsset, isEthereumAsset, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2, _t3, _t4;
8888
+ var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
8889
+ var api, scenario, asset, destination, feeAsset, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isEthereumAsset, _call, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2, _t3, _t4;
8869
8890
  return _regenerator().w(function (_context3) {
8870
8891
  while (1) switch (_context3.n) {
8871
8892
  case 0:
8872
- api = input.api, scenario = input.scenario, asset = input.asset, destination = input.destination, feeAsset = input.feeAsset, overriddenAsset = input.overriddenAsset;
8893
+ api = options.api, scenario = options.scenario, asset = options.asset, destination = options.destination, feeAsset = options.feeAsset, overriddenAsset = options.overriddenAsset;
8873
8894
  if (!feeAsset) {
8874
- _context3.n = 4;
8895
+ _context3.n = 5;
8875
8896
  break;
8876
8897
  }
8877
8898
  if (!overriddenAsset) {
@@ -8881,83 +8902,85 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8881
8902
  throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
8882
8903
  case 1:
8883
8904
  if (!isSymbolMatch(asset.symbol, 'KSM')) {
8884
- _context3.n = 2;
8905
+ _context3.n = 3;
8885
8906
  break;
8886
8907
  }
8887
- return _context3.a(2, this.handleLocalReserveTransfer(input));
8908
+ _context3.n = 2;
8909
+ return createTypeAndThenCall(this.node, options);
8888
8910
  case 2:
8911
+ call = _context3.v;
8912
+ return _context3.a(2, api.callTxMethod(call));
8913
+ case 3:
8889
8914
  isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
8890
8915
  isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol());
8891
8916
  if (!(!isNativeAsset || !isNativeFeeAsset)) {
8892
- _context3.n = 4;
8917
+ _context3.n = 5;
8893
8918
  break;
8894
8919
  }
8895
8920
  _t = api;
8896
- _context3.n = 3;
8897
- return handleExecuteTransfer(this.node, input);
8898
- case 3:
8921
+ _context3.n = 4;
8922
+ return handleExecuteTransfer(this.node, options);
8923
+ case 4:
8899
8924
  _t2 = _context3.v;
8900
8925
  return _context3.a(2, _t.callTxMethod.call(_t, _t2));
8901
- case 4:
8902
- if (!(destination === 'AssetHubKusama')) {
8903
- _context3.n = 5;
8904
- break;
8905
- }
8906
- return _context3.a(2, this.handleBridgeTransfer(input, 'Kusama'));
8907
8926
  case 5:
8908
- if (!(destination === 'Ethereum')) {
8927
+ if (!(destination === 'AssetHubKusama')) {
8909
8928
  _context3.n = 6;
8910
8929
  break;
8911
8930
  }
8912
- return _context3.a(2, this.handleEthBridgeTransfer(input));
8931
+ return _context3.a(2, this.handleBridgeTransfer(options, 'Kusama'));
8913
8932
  case 6:
8914
- if (!(destination === 'Mythos')) {
8933
+ if (!(destination === 'Ethereum')) {
8915
8934
  _context3.n = 7;
8916
8935
  break;
8917
8936
  }
8918
- return _context3.a(2, this.handleMythosTransfer(input));
8937
+ return _context3.a(2, this.handleEthBridgeTransfer(options));
8919
8938
  case 7:
8920
- isEthereumAsset = asset.multiLocation && findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
8921
- if (!(destination === 'BifrostPolkadot' && isEthereumAsset)) {
8939
+ if (!(destination === 'Mythos')) {
8922
8940
  _context3.n = 8;
8923
8941
  break;
8924
8942
  }
8925
- return _context3.a(2, this.handleLocalReserveTransfer(input));
8943
+ return _context3.a(2, this.handleMythosTransfer(options));
8926
8944
  case 8:
8945
+ isEthereumAsset = asset.multiLocation && findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
8927
8946
  if (!isEthereumAsset) {
8928
- _context3.n = 9;
8947
+ _context3.n = 10;
8929
8948
  break;
8930
8949
  }
8931
- return _context3.a(2, this.handleLocalReserveTransfer(input, true));
8950
+ _context3.n = 9;
8951
+ return createTypeAndThenCall(this.node, options);
8932
8952
  case 9:
8953
+ _call = _context3.v;
8954
+ return _context3.a(2, api.callTxMethod(_call));
8955
+ case 10:
8933
8956
  CHAINS_SUPPORT_DOT_TRANSFER = new Set(['Hydration', 'Polimec', 'Moonbeam', 'BifrostPolkadot', 'PeoplePolkadot', 'Ajuna']);
8934
8957
  isTrusted = !isTMultiLocation(destination) && isSystemChain(destination);
8935
8958
  isDotReserveAh = !isTMultiLocation(destination) && CHAINS_SUPPORT_DOT_TRANSFER.has(destination);
8936
8959
  if (!(scenario === 'ParaToPara' && asset.symbol === this.getNativeAssetSymbol() && !isForeignAsset(asset) && !isDotReserveAh && !isTrusted)) {
8937
- _context3.n = 10;
8960
+ _context3.n = 11;
8938
8961
  break;
8939
8962
  }
8940
8963
  throw new ScenarioNotSupportedError(this.node, scenario, 'Some Parachains do not have a reserve for DOT on AssetHub. This can also include multihop transfers that have AssetHub as a hop chain and the call contains DOT. Chains that do not have a DOT reserve on AssetHub are not allowed to transfer DOT to it or through it because this transfer will result in asset loss.');
8941
- case 10:
8964
+ case 11:
8942
8965
  if (!(scenario === 'ParaToPara' && asset.symbol === 'KSM' && !isForeignAsset(asset))) {
8943
- _context3.n = 11;
8966
+ _context3.n = 12;
8944
8967
  break;
8945
8968
  }
8946
8969
  throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
8947
- case 11:
8970
+ case 12:
8948
8971
  method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
8949
8972
  if (!(method === 'transfer_assets' && isSymbolMatch(asset.symbol, getRelayChainSymbol(this.node)))) {
8950
- _context3.n = 13;
8973
+ _context3.n = 14;
8951
8974
  break;
8952
8975
  }
8953
8976
  _t3 = api;
8954
- _context3.n = 12;
8955
- return createTypeAndThenTransfer$2(this.node, input);
8956
- case 12:
8977
+ _context3.n = 13;
8978
+ return createTypeAndThenCall(this.node, options);
8979
+ case 13:
8957
8980
  _t4 = _context3.v;
8958
8981
  return _context3.a(2, _t3.callTxMethod.call(_t3, _t4));
8959
- case 13:
8960
- modifiedInput = this.patchInput(input);
8982
+ case 14:
8983
+ modifiedInput = this.patchInput(options);
8961
8984
  return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
8962
8985
  }
8963
8986
  }, _callee3, this);
@@ -9203,7 +9226,7 @@ var BifrostPolkadot = /*#__PURE__*/function (_ParachainNode) {
9203
9226
  }
9204
9227
  _t = api;
9205
9228
  _context.n = 1;
9206
- return createTypeAndThenTransfer$2(this.node, input);
9229
+ return createTypeAndThenCall(this.node, input);
9207
9230
  case 1:
9208
9231
  _t2 = _context.v;
9209
9232
  return _context.a(2, _t.callTxMethod.call(_t, _t2));
@@ -10558,7 +10581,7 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
10558
10581
  }
10559
10582
  _t = api;
10560
10583
  _context.n = 2;
10561
- return createTypeAndThenTransfer$2(this.node, input);
10584
+ return createTypeAndThenCall(this.node, input);
10562
10585
  case 2:
10563
10586
  _t2 = _context.v;
10564
10587
  return _context.a(2, _t.callTxMethod.call(_t, _t2));
@@ -12249,4 +12272,4 @@ var Builder = function Builder(api) {
12249
12272
  return new GeneralBuilder(api, new BatchTransactionManager());
12250
12273
  };
12251
12274
 
12252
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addEthereumBridgeFees, addXcmVersionHeader, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createMultiAsset, createTypeAndThenTransfer$2 as createTypeAndThenTransfer, 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, isConfig, localizeLocation, maybeOverrideMultiAsset, maybeOverrideMultiAssets, padFee, padFeeBy, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, sortMultiAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination };
12275
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addEthereumBridgeFees, addXcmVersionHeader, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createMultiAsset, createTypeAndThenCall, createVersionedMultiAssets, createX1Payload, deriveAccountId, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, 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, isConfig, localizeLocation, maybeOverrideMultiAsset, maybeOverrideMultiAssets, padFee, padFeeBy, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, sortMultiAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination };