@paraspell/sdk-core 10.10.9 → 10.10.11

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
@@ -723,7 +723,18 @@ var assertAddressIsString = function assertAddressIsString(address) {
723
723
  };
724
724
  var assertHasLocation = function assertHasLocation(asset) {
725
725
  if (!asset.multiLocation) {
726
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is missing multi-location"));
726
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " is missing multi-location"));
727
+ }
728
+ };
729
+ var assertHasId = function assertHasId(asset) {
730
+ assertIsForeign(asset);
731
+ if (asset.assetId === undefined) {
732
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " has no assetId"));
733
+ }
734
+ };
735
+ var assertIsForeign = function assertIsForeign(asset) {
736
+ if (!assets.isForeignAsset(asset)) {
737
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " is not a foreign asset"));
727
738
  }
728
739
  };
729
740
 
@@ -3503,55 +3514,40 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
3503
3514
  while (1) switch (_context.n) {
3504
3515
  case 0:
3505
3516
  if (!(node === 'Moonbeam' || node === 'Moonriver')) {
3506
- _context.n = 2;
3507
- break;
3508
- }
3509
- if (!(!assets.isForeignAsset(asset) || !asset.assetId || !asset.multiLocation)) {
3510
3517
  _context.n = 1;
3511
3518
  break;
3512
3519
  }
3513
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location or assetId"));
3514
- case 1:
3520
+ assertHasId(asset);
3515
3521
  return _context.a(2, getMoonbeamErc20Balance(node, asset.assetId, address));
3516
- case 2:
3522
+ case 1:
3517
3523
  if (!(node === 'Mythos')) {
3518
- _context.n = 3;
3524
+ _context.n = 2;
3519
3525
  break;
3520
3526
  }
3521
3527
  return _context.a(2, api.getMythosForeignBalance(address));
3522
- case 3:
3523
- if (assets.isForeignAsset(asset)) {
3524
- _context.n = 4;
3525
- break;
3526
- }
3527
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
3528
- case 4:
3528
+ case 2:
3529
+ assertIsForeign(asset);
3529
3530
  if (!(node === 'Polimec')) {
3530
- _context.n = 6;
3531
- break;
3532
- }
3533
- if (!(asset.multiLocation === undefined)) {
3534
- _context.n = 5;
3531
+ _context.n = 3;
3535
3532
  break;
3536
3533
  }
3537
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
3538
- case 5:
3534
+ assertHasLocation(asset);
3539
3535
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
3540
- case 6:
3536
+ case 3:
3541
3537
  if (!(node === 'AssetHubPolkadot')) {
3542
- _context.n = 8;
3538
+ _context.n = 5;
3543
3539
  break;
3544
3540
  }
3545
3541
  ASSETS_PALLET_ID = 50;
3546
3542
  hasRequiredJunctions = asset.multiLocation && sdkCommon.hasJunction(asset.multiLocation, 'PalletInstance', ASSETS_PALLET_ID) && sdkCommon.hasJunction(asset.multiLocation, 'GeneralIndex');
3547
3543
  if (!(!asset.multiLocation || hasRequiredJunctions)) {
3548
- _context.n = 7;
3544
+ _context.n = 4;
3549
3545
  break;
3550
3546
  }
3551
3547
  return _context.a(2, api.getBalanceAssetsPallet(address, Number(asset.assetId)));
3552
- case 7:
3548
+ case 4:
3553
3549
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
3554
- case 8:
3550
+ case 5:
3555
3551
  return _context.a(2, api.getBalanceForeignPolkadotXcm(address, asset.assetId));
3556
3552
  }
3557
3553
  }, _callee);
@@ -3567,23 +3563,18 @@ var getBalanceForeignXTokens = /*#__PURE__*/function () {
3567
3563
  while (1) switch (_context.n) {
3568
3564
  case 0:
3569
3565
  if (!(node === 'Astar' || node === 'Shiden')) {
3570
- _context.n = 2;
3571
- break;
3572
- }
3573
- if (!(!assets.isForeignAsset(asset) || !asset.assetId)) {
3574
3566
  _context.n = 1;
3575
3567
  break;
3576
3568
  }
3577
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
3578
- case 1:
3569
+ assertHasId(asset);
3579
3570
  return _context.a(2, api.getBalanceAssetsPallet(address, BigInt(asset.assetId)));
3580
- case 2:
3571
+ case 1:
3581
3572
  if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
3582
- _context.n = 3;
3573
+ _context.n = 2;
3583
3574
  break;
3584
3575
  }
3585
3576
  return _context.a(2, api.getBalanceForeignBifrost(address, asset));
3586
- case 3:
3577
+ case 2:
3587
3578
  return _context.a(2, api.getBalanceForeignXTokens(node, address, asset));
3588
3579
  }
3589
3580
  }, _callee);
@@ -3617,31 +3608,26 @@ var getEthErc20Balance = /*#__PURE__*/function () {
3617
3608
  transport: viem.http('https://ethereum.publicnode.com/')
3618
3609
  });
3619
3610
  asset = assets.findAssetForNodeOrThrow('Ethereum', currency, null);
3620
- if (!(!assets.isForeignAsset(asset) || !asset.assetId)) {
3621
- _context.n = 1;
3622
- break;
3623
- }
3624
- throw new InvalidParameterError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset."));
3625
- case 1:
3611
+ assertHasId(asset);
3626
3612
  if (!(asset.symbol === 'ETH')) {
3627
- _context.n = 3;
3613
+ _context.n = 2;
3628
3614
  break;
3629
3615
  }
3630
- _context.n = 2;
3616
+ _context.n = 1;
3631
3617
  return client.getBalance({
3632
3618
  address: address
3633
3619
  });
3634
- case 2:
3620
+ case 1:
3635
3621
  return _context.a(2, _context.v);
3636
- case 3:
3637
- _context.n = 4;
3622
+ case 2:
3623
+ _context.n = 3;
3638
3624
  return client.readContract({
3639
3625
  address: asset.assetId,
3640
3626
  abi: ERC20_ABI,
3641
3627
  functionName: 'balanceOf',
3642
3628
  args: [address]
3643
3629
  });
3644
- case 4:
3630
+ case 3:
3645
3631
  return _context.a(2, _context.v);
3646
3632
  }
3647
3633
  }, _callee);
@@ -4536,7 +4522,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
4536
4522
  ahAddress = _ref.ahAddress,
4537
4523
  version = _ref.version;
4538
4524
  if (!assets.isForeignAsset(asset)) {
4539
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
4525
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " is not a foreign asset"));
4540
4526
  }
4541
4527
  assertHasLocation(asset);
4542
4528
  if (!senderAddress) {
@@ -4547,7 +4533,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
4547
4533
  }
4548
4534
  var ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
4549
4535
  if (!ethAsset) {
4550
- throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
4536
+ throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt)));
4551
4537
  }
4552
4538
  var interiorSb = ethAsset.symbol === 'ETH' ? {
4553
4539
  Here: null
@@ -4829,7 +4815,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
4829
4815
  senderAddress: senderAddress,
4830
4816
  ahAddress: ahAddress,
4831
4817
  asset: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
4832
- amount: currency.amount
4818
+ amount: BigInt(currency.amount)
4833
4819
  }),
4834
4820
  version: sdkCommon.Version.V4
4835
4821
  }, from, messageId);
@@ -5117,7 +5103,9 @@ var dryRunInternal = /*#__PURE__*/function () {
5117
5103
  _context.n = 3;
5118
5104
  break;
5119
5105
  }
5120
- if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
5106
+ if (destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub'))) {
5107
+ hopCurrency = assets.getNativeAssetSymbol(currentChain);
5108
+ } else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
5121
5109
  hopCurrency = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
5122
5110
  } else if (isDestination) {
5123
5111
  hopCurrency = assets.findAssetOnDestOrThrow(origin, currentChain, currency).symbol;
@@ -5433,6 +5421,9 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
5433
5421
  return currency.multiasset.map(function (multiAsset) {
5434
5422
  var ml = assets.extractMultiAssetLoc(multiAsset);
5435
5423
  return _objectSpread2(_objectSpread2({}, multiAsset), {}, {
5424
+ fun: {
5425
+ Fungible: BigInt(multiAsset.fun.Fungible)
5426
+ },
5436
5427
  isFeeAsset: sdkCommon.deepEqual(ml, feeAsset.multilocation)
5437
5428
  });
5438
5429
  });
@@ -5454,7 +5445,7 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
5454
5445
  var originNode = getNode(originTyped);
5455
5446
  return _objectSpread2({
5456
5447
  isFeeAsset: assets.isAssetEqual(resolvedFeeAsset, asset)
5457
- }, createMultiAsset(originNode.version, currency.amount, asset.multiLocation));
5448
+ }, createMultiAsset(originNode.version, BigInt(currency.amount), asset.multiLocation));
5458
5449
  });
5459
5450
  if (assets$1.filter(function (asset) {
5460
5451
  return asset.isFeeAsset;
@@ -5733,7 +5724,7 @@ var getXcmFee = /*#__PURE__*/function () {
5733
5724
  });
5734
5725
  case 1:
5735
5726
  hopResult = _context.v;
5736
- if (hopResult.feeType === 'dryRun') {
5727
+ if (hopResult.feeType === 'dryRun' && !(destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub')))) {
5737
5728
  if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
5738
5729
  hopCurrency = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
5739
5730
  } else if (destination === currentChain) {
@@ -6114,7 +6105,7 @@ var send = /*#__PURE__*/function () {
6114
6105
  destination: destination,
6115
6106
  address: address,
6116
6107
  asset: _objectSpread2(_objectSpread2({}, asset), {}, {
6117
- amount: 'multiasset' in currency ? 0 : currency.amount
6108
+ amount: 'multiasset' in currency ? 0n : BigInt(currency.amount)
6118
6109
  }),
6119
6110
  paraIdTo: paraIdTo,
6120
6111
  version: resolvedVersion,
@@ -6131,11 +6122,11 @@ var send = /*#__PURE__*/function () {
6131
6122
  symbol: 'symbol' in currency ? currency.symbol : undefined
6132
6123
  };
6133
6124
  finalAsset = 'multiasset' in currency ? _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
6134
- amount: 0,
6125
+ amount: 0n,
6135
6126
  assetId: '1'
6136
6127
  }) : // Ensure amount is at least 2 to avoid Rust panic
6137
6128
  _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
6138
- amount: BigInt(currency.amount) < 2n ? 2n : currency.amount
6129
+ amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
6139
6130
  });
6140
6131
  finalVersion = selectXcmVersion(version, originVersion, destVersion);
6141
6132
  normalizedAsset = finalAsset.multiLocation ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
@@ -6167,11 +6158,11 @@ var send = /*#__PURE__*/function () {
6167
6158
 
6168
6159
  var attemptDryRunFee = /*#__PURE__*/function () {
6169
6160
  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;
6161
+ var origin, currency, builder, reductionPcts, lastReduction, result, _i, _reductionPcts, percentage, modifiedBuilder, _t, _t2, _t3, _t4, _t5, _t6, _t7;
6171
6162
  return _regenerator().w(function (_context) {
6172
6163
  while (1) switch (_context.n) {
6173
6164
  case 0:
6174
- currency = options.currency, builder = options.builder;
6165
+ origin = options.origin, currency = options.currency, builder = options.builder;
6175
6166
  reductionPcts = [0, 10, 20, 30, 40, 50];
6176
6167
  lastReduction = reductionPcts[reductionPcts.length - 1];
6177
6168
  result = null;
@@ -6201,7 +6192,7 @@ var attemptDryRunFee = /*#__PURE__*/function () {
6201
6192
  return _t(_t7);
6202
6193
  case 3:
6203
6194
  result = _context.v;
6204
- if (!(result.feeType === 'dryRun' || percentage === lastReduction)) {
6195
+ if (!(result.feeType === 'dryRun' || percentage === lastReduction || !assets.hasDryRunSupport(origin))) {
6205
6196
  _context.n = 4;
6206
6197
  break;
6207
6198
  }
@@ -7377,7 +7368,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
7377
7368
  case 7:
7378
7369
  recalculatedMinAmountOut = _context3.v;
7379
7370
  updatedAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
7380
- amount: recalculatedMinAmountOut.toString()
7371
+ amount: recalculatedMinAmountOut
7381
7372
  });
7382
7373
  case 8:
7383
7374
  _context3.n = 9;
@@ -7416,7 +7407,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
7416
7407
  case 11:
7417
7408
  finalMinAmountOut = _context3.v;
7418
7409
  finalAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
7419
- amount: finalMinAmountOut.toString()
7410
+ amount: finalMinAmountOut
7420
7411
  });
7421
7412
  _context3.n = 12;
7422
7413
  return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
@@ -7904,12 +7895,7 @@ var ParachainNode = /*#__PURE__*/function () {
7904
7895
  var api = options.api,
7905
7896
  asset = options.asset,
7906
7897
  address = options.address;
7907
- if (!assets.isForeignAsset(asset)) {
7908
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
7909
- }
7910
- if (asset.assetId === undefined) {
7911
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
7912
- }
7898
+ assertHasId(asset);
7913
7899
  return api.callTxMethod({
7914
7900
  module: 'Tokens',
7915
7901
  method: 'transfer',
@@ -8096,14 +8082,14 @@ var ParachainNode = /*#__PURE__*/function () {
8096
8082
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
8097
8083
  bridgeFee = _yield$getParaEthTran2[0];
8098
8084
  executionFee = _yield$getParaEthTran2[1];
8099
- PARA_TO_PARA_FEE_DOT = 500000000; // 0.5 DOT
8100
- fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
8085
+ PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
8086
+ fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : bridgeFee + executionFee;
8101
8087
  ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
8102
8088
  if (ethAsset) {
8103
8089
  _context3.n = 7;
8104
8090
  break;
8105
8091
  }
8106
- throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
8092
+ throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt)));
8107
8093
  case 7:
8108
8094
  if (!useOnlyDepositInstruction) {
8109
8095
  _context3.n = 8;
@@ -8123,21 +8109,16 @@ var ParachainNode = /*#__PURE__*/function () {
8123
8109
  })
8124
8110
  }
8125
8111
  }], version);
8126
- _context3.n = 11;
8112
+ _context3.n = 10;
8127
8113
  break;
8128
8114
  case 8:
8129
- if (ethAsset.assetId) {
8130
- _context3.n = 9;
8131
- break;
8132
- }
8133
- throw new assets.InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
8134
- case 9:
8135
- _context3.n = 10;
8115
+ assertHasId(ethAsset);
8116
+ _context3.n = 9;
8136
8117
  return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
8137
- case 10:
8118
+ case 9:
8138
8119
  messageId = _context3.v;
8139
8120
  customXcmOnDest = createCustomXcmOnDest(input, this.node, messageId);
8140
- case 11:
8121
+ case 10:
8141
8122
  call = {
8142
8123
  module: 'PolkadotXcm',
8143
8124
  method: 'transfer_assets_using_type_and_then',
@@ -8303,12 +8284,7 @@ var Ajuna = /*#__PURE__*/function (_ParachainNode) {
8303
8284
  var api = options.api,
8304
8285
  asset = options.asset,
8305
8286
  address = options.address;
8306
- if (!assets.isForeignAsset(asset)) {
8307
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8308
- }
8309
- if (asset.assetId === undefined) {
8310
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8311
- }
8287
+ assertHasId(asset);
8312
8288
  return api.callTxMethod({
8313
8289
  module: 'Assets',
8314
8290
  method: 'transfer',
@@ -8343,9 +8319,7 @@ var Altair = /*#__PURE__*/function (_ParachainNode) {
8343
8319
  key: "getCurrencySelection",
8344
8320
  value: function getCurrencySelection(asset) {
8345
8321
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Native';
8346
- if (!assets.isForeignAsset(asset)) {
8347
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8348
- }
8322
+ assertHasId(asset);
8349
8323
  return {
8350
8324
  ForeignAsset: Number(asset.assetId)
8351
8325
  };
@@ -8363,12 +8337,7 @@ var Altair = /*#__PURE__*/function (_ParachainNode) {
8363
8337
  var api = options.api,
8364
8338
  asset = options.asset,
8365
8339
  address = options.address;
8366
- if (!assets.isForeignAsset(asset)) {
8367
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8368
- }
8369
- if (asset.assetId === undefined) {
8370
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8371
- }
8340
+ assertHasId(asset);
8372
8341
  return api.callTxMethod({
8373
8342
  module: 'Tokens',
8374
8343
  method: 'transfer',
@@ -8394,9 +8363,7 @@ var Amplitude = /*#__PURE__*/function (_ParachainNode) {
8394
8363
  key: "transferXTokens",
8395
8364
  value: function transferXTokens$1(input) {
8396
8365
  var asset = input.asset;
8397
- if (!assets.isForeignAsset(asset)) {
8398
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8399
- }
8366
+ assertHasId(asset);
8400
8367
  var currencySelection = {
8401
8368
  XCM: Number(asset.assetId)
8402
8369
  };
@@ -8485,9 +8452,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8485
8452
  destination = input.destination,
8486
8453
  asset = input.asset,
8487
8454
  paraIdTo = input.paraIdTo;
8488
- if (!assets.isForeignAsset(asset)) {
8489
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8490
- }
8455
+ assertIsForeign(asset);
8491
8456
  assertHasLocation(asset);
8492
8457
  var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
8493
8458
  var call = {
@@ -8569,16 +8534,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8569
8534
  }
8570
8535
  throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
8571
8536
  case 4:
8572
- if (assets.isForeignAsset(asset)) {
8573
- _context.n = 5;
8574
- break;
8575
- }
8576
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8577
- case 5:
8537
+ assertIsForeign(asset);
8578
8538
  assertHasLocation(asset);
8579
- _context.n = 6;
8539
+ _context.n = 5;
8580
8540
  return generateMessageId(api, senderAddress, getParaId(this.node), JSON.stringify(asset.multiLocation), address, asset.amount);
8581
- case 6:
8541
+ case 5:
8582
8542
  messageId = _context.v;
8583
8543
  multiLocation = asset.symbol === this.getNativeAssetSymbol() ? DOT_MULTILOCATION : asset.multiLocation;
8584
8544
  call = {
@@ -8637,19 +8597,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8637
8597
  }
8638
8598
  throw new BridgeHaltedError();
8639
8599
  case 2:
8640
- if (assets.isForeignAsset(asset)) {
8641
- _context2.n = 3;
8642
- break;
8643
- }
8644
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8645
- case 3:
8600
+ assertIsForeign(asset);
8646
8601
  assertHasLocation(asset);
8647
8602
  if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === assets.getNativeAssetSymbol('Kusama'))) {
8648
- _context2.n = 4;
8603
+ _context2.n = 3;
8649
8604
  break;
8650
8605
  }
8651
8606
  return _context2.a(2, this.handleEthBridgeNativeTransfer(input));
8652
- case 4:
8607
+ case 3:
8653
8608
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
8654
8609
  destLocation: createDestination(this.version, this.node, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
8655
8610
  beneficiaryLocation: createBeneficiaryLocation({
@@ -8846,9 +8801,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8846
8801
  var api = options.api,
8847
8802
  asset = options.asset,
8848
8803
  address = options.address;
8849
- if (!assets.isForeignAsset(asset)) {
8850
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8851
- }
8804
+ assertIsForeign(asset);
8852
8805
  if (asset.assetId !== undefined) {
8853
8806
  return api.callTxMethod({
8854
8807
  module: 'Assets',
@@ -8927,12 +8880,7 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
8927
8880
  var api = options.api,
8928
8881
  asset = options.asset,
8929
8882
  address = options.address;
8930
- if (!assets.isForeignAsset(asset)) {
8931
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8932
- }
8933
- if (asset.assetId === undefined) {
8934
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8935
- }
8883
+ assertHasId(asset);
8936
8884
  return api.callTxMethod({
8937
8885
  module: 'Assets',
8938
8886
  method: 'transfer',
@@ -8958,9 +8906,7 @@ var Basilisk = /*#__PURE__*/function (_ParachainNode) {
8958
8906
  key: "transferXTokens",
8959
8907
  value: function transferXTokens$1(input) {
8960
8908
  var asset = input.asset;
8961
- if (!assets.isForeignAsset(asset)) {
8962
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8963
- }
8909
+ assertHasId(asset);
8964
8910
  return transferXTokens(input, Number(asset.assetId));
8965
8911
  }
8966
8912
  }, {
@@ -9196,9 +9142,7 @@ var Centrifuge = /*#__PURE__*/function (_ParachainNode) {
9196
9142
  key: "getCurrencySelection",
9197
9143
  value: function getCurrencySelection(asset) {
9198
9144
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Native';
9199
- if (!assets.isForeignAsset(asset)) {
9200
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9201
- }
9145
+ assertHasId(asset);
9202
9146
  return {
9203
9147
  ForeignAsset: Number(asset.assetId)
9204
9148
  };
@@ -9216,12 +9160,7 @@ var Centrifuge = /*#__PURE__*/function (_ParachainNode) {
9216
9160
  var api = options.api,
9217
9161
  asset = options.asset,
9218
9162
  address = options.address;
9219
- if (!assets.isForeignAsset(asset)) {
9220
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9221
- }
9222
- if (asset.assetId === undefined) {
9223
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9224
- }
9163
+ assertHasId(asset);
9225
9164
  return api.callTxMethod({
9226
9165
  module: 'Tokens',
9227
9166
  method: 'transfer',
@@ -9286,9 +9225,7 @@ var ComposableFinance = /*#__PURE__*/function (_ParachainNode) {
9286
9225
  key: "transferXTokens",
9287
9226
  value: function transferXTokens$1(input) {
9288
9227
  var asset = input.asset;
9289
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
9290
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9291
- }
9228
+ assertHasId(asset);
9292
9229
  return transferXTokens(input, BigInt(asset.assetId));
9293
9230
  }
9294
9231
  }]);
@@ -9422,7 +9359,7 @@ var Crust = /*#__PURE__*/function (_ParachainNode) {
9422
9359
  return 'SelfReserve';
9423
9360
  }
9424
9361
  if (!assets.isForeignAsset(asset) || !asset.assetId) {
9425
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9362
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " has no assetId"));
9426
9363
  }
9427
9364
  return {
9428
9365
  OtherReserve: BigInt(asset.assetId)
@@ -9441,12 +9378,7 @@ var Crust = /*#__PURE__*/function (_ParachainNode) {
9441
9378
  var api = options.api,
9442
9379
  asset = options.asset,
9443
9380
  address = options.address;
9444
- if (!assets.isForeignAsset(asset)) {
9445
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9446
- }
9447
- if (asset.assetId === undefined) {
9448
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9449
- }
9381
+ assertHasId(asset);
9450
9382
  return api.callTxMethod({
9451
9383
  module: 'Assets',
9452
9384
  method: 'transfer',
@@ -9474,9 +9406,7 @@ var CrustShadow = /*#__PURE__*/function (_ParachainNode) {
9474
9406
  if (asset.symbol === this.getNativeAssetSymbol()) {
9475
9407
  return 'SelfReserve';
9476
9408
  }
9477
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
9478
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9479
- }
9409
+ assertHasId(asset);
9480
9410
  return {
9481
9411
  OtherReserve: BigInt(asset.assetId)
9482
9412
  };
@@ -9554,12 +9484,7 @@ var Darwinia = /*#__PURE__*/function (_ParachainNode) {
9554
9484
  var api = options.api,
9555
9485
  asset = options.asset,
9556
9486
  address = options.address;
9557
- if (!assets.isForeignAsset(asset)) {
9558
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9559
- }
9560
- if (asset.assetId === undefined) {
9561
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9562
- }
9487
+ assertHasId(asset);
9563
9488
  return api.callTxMethod({
9564
9489
  module: 'Assets',
9565
9490
  method: 'transfer',
@@ -9646,7 +9571,7 @@ var getAssetMultiLocation = function getAssetMultiLocation(asset) {
9646
9571
  if (assets.isForeignAsset(asset) && asset.multiLocation !== undefined) {
9647
9572
  return asset.multiLocation;
9648
9573
  }
9649
- throw new assets.InvalidCurrencyError("Transfer of asset ".concat(JSON.stringify(asset), " is not supported yet"));
9574
+ throw new assets.InvalidCurrencyError("Transfer of asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " is not supported yet"));
9650
9575
  };
9651
9576
  var createTransferAssetsTransfer = function createTransferAssetsTransfer(options, version) {
9652
9577
  var asset = options.asset;
@@ -9791,12 +9716,8 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
9791
9716
  var api = options.api,
9792
9717
  asset = options.asset,
9793
9718
  address = options.address;
9794
- if (!assets.isForeignAsset(asset)) {
9795
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9796
- }
9797
- if (asset.multiLocation === undefined) {
9798
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
9799
- }
9719
+ assertIsForeign(asset);
9720
+ assertHasLocation(asset);
9800
9721
  return api.callTxMethod({
9801
9722
  module: 'ForeignAssets',
9802
9723
  method: 'transfer',
@@ -9942,9 +9863,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
9942
9863
  if (asset.symbol === this.getNativeAssetSymbol()) {
9943
9864
  return transferXTokens(input, Hydration.NATIVE_ASSET_ID);
9944
9865
  }
9945
- if (!assets.isForeignAsset(asset)) {
9946
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9947
- }
9866
+ assertHasId(asset);
9948
9867
  return transferXTokens(input, Number(asset.assetId));
9949
9868
  }
9950
9869
  }, {
@@ -9977,12 +9896,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
9977
9896
  var api = options.api,
9978
9897
  asset = options.asset,
9979
9898
  address = options.address;
9980
- if (!assets.isForeignAsset(asset)) {
9981
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9982
- }
9983
- if (asset.assetId === undefined) {
9984
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9985
- }
9899
+ assertHasId(asset);
9986
9900
  return api.callTxMethod({
9987
9901
  module: 'Tokens',
9988
9902
  method: 'transfer',
@@ -10070,9 +9984,7 @@ var Jamton = /*#__PURE__*/function (_ParachainNode) {
10070
9984
  Native: Jamton.NATIVE_ASSET_IDS[asset.symbol]
10071
9985
  });
10072
9986
  }
10073
- if (!assets.isForeignAsset(asset) || asset.assetId === undefined) {
10074
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10075
- }
9987
+ assertHasId(asset);
10076
9988
  if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot') {
10077
9989
  throw new ScenarioNotSupportedError(this.node, scenario, "Transfer from ".concat(this.node, " to ").concat(JSON.stringify(destination), " is not yet supported"));
10078
9990
  }
@@ -10082,7 +9994,7 @@ var Jamton = /*#__PURE__*/function (_ParachainNode) {
10082
9994
  }, null);
10083
9995
  assertHasLocation(asset);
10084
9996
  assertHasLocation(usdt);
10085
- var MIN_USDT_AMOUNT = 180000; // 0.18 USDt
9997
+ var MIN_USDT_AMOUNT = 180000n; // 0.18 USDt
10086
9998
  return transferXTokens(_objectSpread2(_objectSpread2({}, input), {}, {
10087
9999
  overriddenAsset: [_objectSpread2(_objectSpread2({}, createMultiAsset(version, MIN_USDT_AMOUNT, usdt.multiLocation)), {}, {
10088
10000
  isFeeAsset: true
@@ -10262,9 +10174,7 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
10262
10174
  key: "getAssetId",
10263
10175
  value: function getAssetId(asset) {
10264
10176
  if (asset.symbol === this.getNativeAssetSymbol()) return Manta.NATIVE_ASSET_ID;
10265
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10266
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10267
- }
10177
+ assertHasId(asset);
10268
10178
  return BigInt(asset.assetId);
10269
10179
  }
10270
10180
  }, {
@@ -10282,12 +10192,7 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
10282
10192
  var api = options.api,
10283
10193
  asset = options.asset,
10284
10194
  address = options.address;
10285
- if (!assets.isForeignAsset(asset)) {
10286
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10287
- }
10288
- if (asset.assetId === undefined) {
10289
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10290
- }
10195
+ assertHasId(asset);
10291
10196
  return api.callTxMethod({
10292
10197
  module: 'Assets',
10293
10198
  method: 'transfer',
@@ -10359,12 +10264,7 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
10359
10264
  var api = options.api,
10360
10265
  asset = options.asset,
10361
10266
  address = options.address;
10362
- if (!assets.isForeignAsset(asset)) {
10363
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10364
- }
10365
- if (asset.assetId === undefined) {
10366
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10367
- }
10267
+ assertHasId(asset);
10368
10268
  return api.callTxMethod({
10369
10269
  module: 'Assets',
10370
10270
  method: 'transfer',
@@ -10688,9 +10588,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
10688
10588
  if (scenario !== 'ParaToPara') {
10689
10589
  throw new ScenarioNotSupportedError(this.node, scenario);
10690
10590
  }
10691
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10692
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10693
- }
10591
+ assertHasId(asset);
10694
10592
  return transferXTokens(input, BigInt(asset.assetId));
10695
10593
  }
10696
10594
  }, {
@@ -10704,12 +10602,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
10704
10602
  var api = options.api,
10705
10603
  asset = options.asset,
10706
10604
  address = options.address;
10707
- if (!assets.isForeignAsset(asset)) {
10708
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10709
- }
10710
- if (asset.assetId === undefined) {
10711
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10712
- }
10605
+ assertHasId(asset);
10713
10606
  return api.callTxMethod({
10714
10607
  module: 'Assets',
10715
10608
  method: 'transfer',
@@ -10744,7 +10637,7 @@ var Pendulum = /*#__PURE__*/function (_ParachainNode) {
10744
10637
  XCM: Number(asset.assetId)
10745
10638
  };
10746
10639
  }
10747
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10640
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " has no assetId"));
10748
10641
  }
10749
10642
  }, {
10750
10643
  key: "transferXTokens",
@@ -10890,12 +10783,7 @@ var Phala = /*#__PURE__*/function (_ParachainNode) {
10890
10783
  var api = options.api,
10891
10784
  asset = options.asset,
10892
10785
  address = options.address;
10893
- if (!assets.isForeignAsset(asset)) {
10894
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10895
- }
10896
- if (asset.assetId === undefined) {
10897
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10898
- }
10786
+ assertHasId(asset);
10899
10787
  return api.callTxMethod({
10900
10788
  module: 'Assets',
10901
10789
  method: 'transfer',
@@ -10924,9 +10812,7 @@ var Quartz = /*#__PURE__*/function (_ParachainNode) {
10924
10812
  if (asset.symbol === this.getNativeAssetSymbol()) {
10925
10813
  return transferXTokens(input, Quartz.NATIVE_ASSET_ID);
10926
10814
  }
10927
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10928
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10929
- }
10815
+ assertHasId(asset);
10930
10816
  return transferXTokens(input, Number(asset.assetId));
10931
10817
  }
10932
10818
  }]);
@@ -10969,12 +10855,7 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_ParachainNode) {
10969
10855
  var api = options.api,
10970
10856
  asset = options.asset,
10971
10857
  address = options.address;
10972
- if (!assets.isForeignAsset(asset)) {
10973
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10974
- }
10975
- if (asset.assetId === undefined) {
10976
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10977
- }
10858
+ assertHasId(asset);
10978
10859
  return api.callTxMethod({
10979
10860
  module: 'Assets',
10980
10861
  method: 'transfer',
@@ -11057,9 +10938,7 @@ var Unique = /*#__PURE__*/function (_ParachainNode) {
11057
10938
  if (asset.symbol === this.getNativeAssetSymbol()) {
11058
10939
  return transferXTokens(input, Unique.NATIVE_ASSET_ID);
11059
10940
  }
11060
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
11061
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11062
- }
10941
+ assertHasId(asset);
11063
10942
  return transferXTokens(input, Number(asset.assetId));
11064
10943
  }
11065
10944
  }, {
@@ -11085,9 +10964,7 @@ var Zeitgeist = /*#__PURE__*/function (_ParachainNode) {
11085
10964
  key: "getCurrencySelection",
11086
10965
  value: function getCurrencySelection(asset) {
11087
10966
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Ztg';
11088
- if (!assets.isForeignAsset(asset)) {
11089
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11090
- }
10967
+ assertHasId(asset);
11091
10968
  return {
11092
10969
  ForeignAsset: Number(asset.assetId)
11093
10970
  };
@@ -11105,12 +10982,7 @@ var Zeitgeist = /*#__PURE__*/function (_ParachainNode) {
11105
10982
  var api = options.api,
11106
10983
  asset = options.asset,
11107
10984
  address = options.address;
11108
- if (!assets.isForeignAsset(asset)) {
11109
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
11110
- }
11111
- if (asset.assetId === undefined) {
11112
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11113
- }
10985
+ assertHasId(asset);
11114
10986
  return api.callTxMethod({
11115
10987
  module: 'AssetManager',
11116
10988
  method: 'transfer',
@@ -12069,7 +11941,9 @@ exports.UnableToComputeError = UnableToComputeError;
12069
11941
  exports.addEthereumBridgeFees = addEthereumBridgeFees;
12070
11942
  exports.addXcmVersionHeader = addXcmVersionHeader;
12071
11943
  exports.assertAddressIsString = assertAddressIsString;
11944
+ exports.assertHasId = assertHasId;
12072
11945
  exports.assertHasLocation = assertHasLocation;
11946
+ exports.assertIsForeign = assertIsForeign;
12073
11947
  exports.assertToIsString = assertToIsString;
12074
11948
  exports.blake2b256 = blake2b256;
12075
11949
  exports.blake2b512 = blake2b512;