@paraspell/sdk-core 10.10.10 → 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);
@@ -5435,6 +5421,9 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
5435
5421
  return currency.multiasset.map(function (multiAsset) {
5436
5422
  var ml = assets.extractMultiAssetLoc(multiAsset);
5437
5423
  return _objectSpread2(_objectSpread2({}, multiAsset), {}, {
5424
+ fun: {
5425
+ Fungible: BigInt(multiAsset.fun.Fungible)
5426
+ },
5438
5427
  isFeeAsset: sdkCommon.deepEqual(ml, feeAsset.multilocation)
5439
5428
  });
5440
5429
  });
@@ -5456,7 +5445,7 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
5456
5445
  var originNode = getNode(originTyped);
5457
5446
  return _objectSpread2({
5458
5447
  isFeeAsset: assets.isAssetEqual(resolvedFeeAsset, asset)
5459
- }, createMultiAsset(originNode.version, currency.amount, asset.multiLocation));
5448
+ }, createMultiAsset(originNode.version, BigInt(currency.amount), asset.multiLocation));
5460
5449
  });
5461
5450
  if (assets$1.filter(function (asset) {
5462
5451
  return asset.isFeeAsset;
@@ -6116,7 +6105,7 @@ var send = /*#__PURE__*/function () {
6116
6105
  destination: destination,
6117
6106
  address: address,
6118
6107
  asset: _objectSpread2(_objectSpread2({}, asset), {}, {
6119
- amount: 'multiasset' in currency ? 0 : currency.amount
6108
+ amount: 'multiasset' in currency ? 0n : BigInt(currency.amount)
6120
6109
  }),
6121
6110
  paraIdTo: paraIdTo,
6122
6111
  version: resolvedVersion,
@@ -6133,11 +6122,11 @@ var send = /*#__PURE__*/function () {
6133
6122
  symbol: 'symbol' in currency ? currency.symbol : undefined
6134
6123
  };
6135
6124
  finalAsset = 'multiasset' in currency ? _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
6136
- amount: 0,
6125
+ amount: 0n,
6137
6126
  assetId: '1'
6138
6127
  }) : // Ensure amount is at least 2 to avoid Rust panic
6139
6128
  _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
6140
- amount: BigInt(currency.amount) < 2n ? 2n : currency.amount
6129
+ amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
6141
6130
  });
6142
6131
  finalVersion = selectXcmVersion(version, originVersion, destVersion);
6143
6132
  normalizedAsset = finalAsset.multiLocation ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
@@ -7379,7 +7368,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
7379
7368
  case 7:
7380
7369
  recalculatedMinAmountOut = _context3.v;
7381
7370
  updatedAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
7382
- amount: recalculatedMinAmountOut.toString()
7371
+ amount: recalculatedMinAmountOut
7383
7372
  });
7384
7373
  case 8:
7385
7374
  _context3.n = 9;
@@ -7418,7 +7407,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
7418
7407
  case 11:
7419
7408
  finalMinAmountOut = _context3.v;
7420
7409
  finalAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
7421
- amount: finalMinAmountOut.toString()
7410
+ amount: finalMinAmountOut
7422
7411
  });
7423
7412
  _context3.n = 12;
7424
7413
  return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
@@ -7906,12 +7895,7 @@ var ParachainNode = /*#__PURE__*/function () {
7906
7895
  var api = options.api,
7907
7896
  asset = options.asset,
7908
7897
  address = options.address;
7909
- if (!assets.isForeignAsset(asset)) {
7910
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
7911
- }
7912
- if (asset.assetId === undefined) {
7913
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
7914
- }
7898
+ assertHasId(asset);
7915
7899
  return api.callTxMethod({
7916
7900
  module: 'Tokens',
7917
7901
  method: 'transfer',
@@ -8098,14 +8082,14 @@ var ParachainNode = /*#__PURE__*/function () {
8098
8082
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
8099
8083
  bridgeFee = _yield$getParaEthTran2[0];
8100
8084
  executionFee = _yield$getParaEthTran2[1];
8101
- PARA_TO_PARA_FEE_DOT = 500000000; // 0.5 DOT
8102
- 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;
8103
8087
  ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
8104
8088
  if (ethAsset) {
8105
8089
  _context3.n = 7;
8106
8090
  break;
8107
8091
  }
8108
- 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)));
8109
8093
  case 7:
8110
8094
  if (!useOnlyDepositInstruction) {
8111
8095
  _context3.n = 8;
@@ -8125,21 +8109,16 @@ var ParachainNode = /*#__PURE__*/function () {
8125
8109
  })
8126
8110
  }
8127
8111
  }], version);
8128
- _context3.n = 11;
8112
+ _context3.n = 10;
8129
8113
  break;
8130
8114
  case 8:
8131
- if (ethAsset.assetId) {
8132
- _context3.n = 9;
8133
- break;
8134
- }
8135
- throw new assets.InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
8136
- case 9:
8137
- _context3.n = 10;
8115
+ assertHasId(ethAsset);
8116
+ _context3.n = 9;
8138
8117
  return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
8139
- case 10:
8118
+ case 9:
8140
8119
  messageId = _context3.v;
8141
8120
  customXcmOnDest = createCustomXcmOnDest(input, this.node, messageId);
8142
- case 11:
8121
+ case 10:
8143
8122
  call = {
8144
8123
  module: 'PolkadotXcm',
8145
8124
  method: 'transfer_assets_using_type_and_then',
@@ -8305,12 +8284,7 @@ var Ajuna = /*#__PURE__*/function (_ParachainNode) {
8305
8284
  var api = options.api,
8306
8285
  asset = options.asset,
8307
8286
  address = options.address;
8308
- if (!assets.isForeignAsset(asset)) {
8309
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8310
- }
8311
- if (asset.assetId === undefined) {
8312
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8313
- }
8287
+ assertHasId(asset);
8314
8288
  return api.callTxMethod({
8315
8289
  module: 'Assets',
8316
8290
  method: 'transfer',
@@ -8345,9 +8319,7 @@ var Altair = /*#__PURE__*/function (_ParachainNode) {
8345
8319
  key: "getCurrencySelection",
8346
8320
  value: function getCurrencySelection(asset) {
8347
8321
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Native';
8348
- if (!assets.isForeignAsset(asset)) {
8349
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8350
- }
8322
+ assertHasId(asset);
8351
8323
  return {
8352
8324
  ForeignAsset: Number(asset.assetId)
8353
8325
  };
@@ -8365,12 +8337,7 @@ var Altair = /*#__PURE__*/function (_ParachainNode) {
8365
8337
  var api = options.api,
8366
8338
  asset = options.asset,
8367
8339
  address = options.address;
8368
- if (!assets.isForeignAsset(asset)) {
8369
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8370
- }
8371
- if (asset.assetId === undefined) {
8372
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8373
- }
8340
+ assertHasId(asset);
8374
8341
  return api.callTxMethod({
8375
8342
  module: 'Tokens',
8376
8343
  method: 'transfer',
@@ -8396,9 +8363,7 @@ var Amplitude = /*#__PURE__*/function (_ParachainNode) {
8396
8363
  key: "transferXTokens",
8397
8364
  value: function transferXTokens$1(input) {
8398
8365
  var asset = input.asset;
8399
- if (!assets.isForeignAsset(asset)) {
8400
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8401
- }
8366
+ assertHasId(asset);
8402
8367
  var currencySelection = {
8403
8368
  XCM: Number(asset.assetId)
8404
8369
  };
@@ -8487,9 +8452,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8487
8452
  destination = input.destination,
8488
8453
  asset = input.asset,
8489
8454
  paraIdTo = input.paraIdTo;
8490
- if (!assets.isForeignAsset(asset)) {
8491
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8492
- }
8455
+ assertIsForeign(asset);
8493
8456
  assertHasLocation(asset);
8494
8457
  var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
8495
8458
  var call = {
@@ -8571,16 +8534,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8571
8534
  }
8572
8535
  throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
8573
8536
  case 4:
8574
- if (assets.isForeignAsset(asset)) {
8575
- _context.n = 5;
8576
- break;
8577
- }
8578
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8579
- case 5:
8537
+ assertIsForeign(asset);
8580
8538
  assertHasLocation(asset);
8581
- _context.n = 6;
8539
+ _context.n = 5;
8582
8540
  return generateMessageId(api, senderAddress, getParaId(this.node), JSON.stringify(asset.multiLocation), address, asset.amount);
8583
- case 6:
8541
+ case 5:
8584
8542
  messageId = _context.v;
8585
8543
  multiLocation = asset.symbol === this.getNativeAssetSymbol() ? DOT_MULTILOCATION : asset.multiLocation;
8586
8544
  call = {
@@ -8639,19 +8597,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8639
8597
  }
8640
8598
  throw new BridgeHaltedError();
8641
8599
  case 2:
8642
- if (assets.isForeignAsset(asset)) {
8643
- _context2.n = 3;
8644
- break;
8645
- }
8646
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8647
- case 3:
8600
+ assertIsForeign(asset);
8648
8601
  assertHasLocation(asset);
8649
8602
  if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === assets.getNativeAssetSymbol('Kusama'))) {
8650
- _context2.n = 4;
8603
+ _context2.n = 3;
8651
8604
  break;
8652
8605
  }
8653
8606
  return _context2.a(2, this.handleEthBridgeNativeTransfer(input));
8654
- case 4:
8607
+ case 3:
8655
8608
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
8656
8609
  destLocation: createDestination(this.version, this.node, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
8657
8610
  beneficiaryLocation: createBeneficiaryLocation({
@@ -8848,9 +8801,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
8848
8801
  var api = options.api,
8849
8802
  asset = options.asset,
8850
8803
  address = options.address;
8851
- if (!assets.isForeignAsset(asset)) {
8852
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8853
- }
8804
+ assertIsForeign(asset);
8854
8805
  if (asset.assetId !== undefined) {
8855
8806
  return api.callTxMethod({
8856
8807
  module: 'Assets',
@@ -8929,12 +8880,7 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
8929
8880
  var api = options.api,
8930
8881
  asset = options.asset,
8931
8882
  address = options.address;
8932
- if (!assets.isForeignAsset(asset)) {
8933
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
8934
- }
8935
- if (asset.assetId === undefined) {
8936
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8937
- }
8883
+ assertHasId(asset);
8938
8884
  return api.callTxMethod({
8939
8885
  module: 'Assets',
8940
8886
  method: 'transfer',
@@ -8960,9 +8906,7 @@ var Basilisk = /*#__PURE__*/function (_ParachainNode) {
8960
8906
  key: "transferXTokens",
8961
8907
  value: function transferXTokens$1(input) {
8962
8908
  var asset = input.asset;
8963
- if (!assets.isForeignAsset(asset)) {
8964
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
8965
- }
8909
+ assertHasId(asset);
8966
8910
  return transferXTokens(input, Number(asset.assetId));
8967
8911
  }
8968
8912
  }, {
@@ -9198,9 +9142,7 @@ var Centrifuge = /*#__PURE__*/function (_ParachainNode) {
9198
9142
  key: "getCurrencySelection",
9199
9143
  value: function getCurrencySelection(asset) {
9200
9144
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Native';
9201
- if (!assets.isForeignAsset(asset)) {
9202
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9203
- }
9145
+ assertHasId(asset);
9204
9146
  return {
9205
9147
  ForeignAsset: Number(asset.assetId)
9206
9148
  };
@@ -9218,12 +9160,7 @@ var Centrifuge = /*#__PURE__*/function (_ParachainNode) {
9218
9160
  var api = options.api,
9219
9161
  asset = options.asset,
9220
9162
  address = options.address;
9221
- if (!assets.isForeignAsset(asset)) {
9222
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9223
- }
9224
- if (asset.assetId === undefined) {
9225
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9226
- }
9163
+ assertHasId(asset);
9227
9164
  return api.callTxMethod({
9228
9165
  module: 'Tokens',
9229
9166
  method: 'transfer',
@@ -9288,9 +9225,7 @@ var ComposableFinance = /*#__PURE__*/function (_ParachainNode) {
9288
9225
  key: "transferXTokens",
9289
9226
  value: function transferXTokens$1(input) {
9290
9227
  var asset = input.asset;
9291
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
9292
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9293
- }
9228
+ assertHasId(asset);
9294
9229
  return transferXTokens(input, BigInt(asset.assetId));
9295
9230
  }
9296
9231
  }]);
@@ -9424,7 +9359,7 @@ var Crust = /*#__PURE__*/function (_ParachainNode) {
9424
9359
  return 'SelfReserve';
9425
9360
  }
9426
9361
  if (!assets.isForeignAsset(asset) || !asset.assetId) {
9427
- 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"));
9428
9363
  }
9429
9364
  return {
9430
9365
  OtherReserve: BigInt(asset.assetId)
@@ -9443,12 +9378,7 @@ var Crust = /*#__PURE__*/function (_ParachainNode) {
9443
9378
  var api = options.api,
9444
9379
  asset = options.asset,
9445
9380
  address = options.address;
9446
- if (!assets.isForeignAsset(asset)) {
9447
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9448
- }
9449
- if (asset.assetId === undefined) {
9450
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9451
- }
9381
+ assertHasId(asset);
9452
9382
  return api.callTxMethod({
9453
9383
  module: 'Assets',
9454
9384
  method: 'transfer',
@@ -9476,9 +9406,7 @@ var CrustShadow = /*#__PURE__*/function (_ParachainNode) {
9476
9406
  if (asset.symbol === this.getNativeAssetSymbol()) {
9477
9407
  return 'SelfReserve';
9478
9408
  }
9479
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
9480
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9481
- }
9409
+ assertHasId(asset);
9482
9410
  return {
9483
9411
  OtherReserve: BigInt(asset.assetId)
9484
9412
  };
@@ -9556,12 +9484,7 @@ var Darwinia = /*#__PURE__*/function (_ParachainNode) {
9556
9484
  var api = options.api,
9557
9485
  asset = options.asset,
9558
9486
  address = options.address;
9559
- if (!assets.isForeignAsset(asset)) {
9560
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9561
- }
9562
- if (asset.assetId === undefined) {
9563
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9564
- }
9487
+ assertHasId(asset);
9565
9488
  return api.callTxMethod({
9566
9489
  module: 'Assets',
9567
9490
  method: 'transfer',
@@ -9648,7 +9571,7 @@ var getAssetMultiLocation = function getAssetMultiLocation(asset) {
9648
9571
  if (assets.isForeignAsset(asset) && asset.multiLocation !== undefined) {
9649
9572
  return asset.multiLocation;
9650
9573
  }
9651
- 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"));
9652
9575
  };
9653
9576
  var createTransferAssetsTransfer = function createTransferAssetsTransfer(options, version) {
9654
9577
  var asset = options.asset;
@@ -9793,12 +9716,8 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
9793
9716
  var api = options.api,
9794
9717
  asset = options.asset,
9795
9718
  address = options.address;
9796
- if (!assets.isForeignAsset(asset)) {
9797
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9798
- }
9799
- if (asset.multiLocation === undefined) {
9800
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
9801
- }
9719
+ assertIsForeign(asset);
9720
+ assertHasLocation(asset);
9802
9721
  return api.callTxMethod({
9803
9722
  module: 'ForeignAssets',
9804
9723
  method: 'transfer',
@@ -9944,9 +9863,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
9944
9863
  if (asset.symbol === this.getNativeAssetSymbol()) {
9945
9864
  return transferXTokens(input, Hydration.NATIVE_ASSET_ID);
9946
9865
  }
9947
- if (!assets.isForeignAsset(asset)) {
9948
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9949
- }
9866
+ assertHasId(asset);
9950
9867
  return transferXTokens(input, Number(asset.assetId));
9951
9868
  }
9952
9869
  }, {
@@ -9979,12 +9896,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
9979
9896
  var api = options.api,
9980
9897
  asset = options.asset,
9981
9898
  address = options.address;
9982
- if (!assets.isForeignAsset(asset)) {
9983
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
9984
- }
9985
- if (asset.assetId === undefined) {
9986
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
9987
- }
9899
+ assertHasId(asset);
9988
9900
  return api.callTxMethod({
9989
9901
  module: 'Tokens',
9990
9902
  method: 'transfer',
@@ -10072,9 +9984,7 @@ var Jamton = /*#__PURE__*/function (_ParachainNode) {
10072
9984
  Native: Jamton.NATIVE_ASSET_IDS[asset.symbol]
10073
9985
  });
10074
9986
  }
10075
- if (!assets.isForeignAsset(asset) || asset.assetId === undefined) {
10076
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10077
- }
9987
+ assertHasId(asset);
10078
9988
  if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot') {
10079
9989
  throw new ScenarioNotSupportedError(this.node, scenario, "Transfer from ".concat(this.node, " to ").concat(JSON.stringify(destination), " is not yet supported"));
10080
9990
  }
@@ -10084,7 +9994,7 @@ var Jamton = /*#__PURE__*/function (_ParachainNode) {
10084
9994
  }, null);
10085
9995
  assertHasLocation(asset);
10086
9996
  assertHasLocation(usdt);
10087
- var MIN_USDT_AMOUNT = 180000; // 0.18 USDt
9997
+ var MIN_USDT_AMOUNT = 180000n; // 0.18 USDt
10088
9998
  return transferXTokens(_objectSpread2(_objectSpread2({}, input), {}, {
10089
9999
  overriddenAsset: [_objectSpread2(_objectSpread2({}, createMultiAsset(version, MIN_USDT_AMOUNT, usdt.multiLocation)), {}, {
10090
10000
  isFeeAsset: true
@@ -10264,9 +10174,7 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
10264
10174
  key: "getAssetId",
10265
10175
  value: function getAssetId(asset) {
10266
10176
  if (asset.symbol === this.getNativeAssetSymbol()) return Manta.NATIVE_ASSET_ID;
10267
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10268
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10269
- }
10177
+ assertHasId(asset);
10270
10178
  return BigInt(asset.assetId);
10271
10179
  }
10272
10180
  }, {
@@ -10284,12 +10192,7 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
10284
10192
  var api = options.api,
10285
10193
  asset = options.asset,
10286
10194
  address = options.address;
10287
- if (!assets.isForeignAsset(asset)) {
10288
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10289
- }
10290
- if (asset.assetId === undefined) {
10291
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10292
- }
10195
+ assertHasId(asset);
10293
10196
  return api.callTxMethod({
10294
10197
  module: 'Assets',
10295
10198
  method: 'transfer',
@@ -10361,12 +10264,7 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
10361
10264
  var api = options.api,
10362
10265
  asset = options.asset,
10363
10266
  address = options.address;
10364
- if (!assets.isForeignAsset(asset)) {
10365
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10366
- }
10367
- if (asset.assetId === undefined) {
10368
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10369
- }
10267
+ assertHasId(asset);
10370
10268
  return api.callTxMethod({
10371
10269
  module: 'Assets',
10372
10270
  method: 'transfer',
@@ -10690,9 +10588,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
10690
10588
  if (scenario !== 'ParaToPara') {
10691
10589
  throw new ScenarioNotSupportedError(this.node, scenario);
10692
10590
  }
10693
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10694
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10695
- }
10591
+ assertHasId(asset);
10696
10592
  return transferXTokens(input, BigInt(asset.assetId));
10697
10593
  }
10698
10594
  }, {
@@ -10706,12 +10602,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
10706
10602
  var api = options.api,
10707
10603
  asset = options.asset,
10708
10604
  address = options.address;
10709
- if (!assets.isForeignAsset(asset)) {
10710
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10711
- }
10712
- if (asset.assetId === undefined) {
10713
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10714
- }
10605
+ assertHasId(asset);
10715
10606
  return api.callTxMethod({
10716
10607
  module: 'Assets',
10717
10608
  method: 'transfer',
@@ -10746,7 +10637,7 @@ var Pendulum = /*#__PURE__*/function (_ParachainNode) {
10746
10637
  XCM: Number(asset.assetId)
10747
10638
  };
10748
10639
  }
10749
- 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"));
10750
10641
  }
10751
10642
  }, {
10752
10643
  key: "transferXTokens",
@@ -10892,12 +10783,7 @@ var Phala = /*#__PURE__*/function (_ParachainNode) {
10892
10783
  var api = options.api,
10893
10784
  asset = options.asset,
10894
10785
  address = options.address;
10895
- if (!assets.isForeignAsset(asset)) {
10896
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10897
- }
10898
- if (asset.assetId === undefined) {
10899
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10900
- }
10786
+ assertHasId(asset);
10901
10787
  return api.callTxMethod({
10902
10788
  module: 'Assets',
10903
10789
  method: 'transfer',
@@ -10926,9 +10812,7 @@ var Quartz = /*#__PURE__*/function (_ParachainNode) {
10926
10812
  if (asset.symbol === this.getNativeAssetSymbol()) {
10927
10813
  return transferXTokens(input, Quartz.NATIVE_ASSET_ID);
10928
10814
  }
10929
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
10930
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10931
- }
10815
+ assertHasId(asset);
10932
10816
  return transferXTokens(input, Number(asset.assetId));
10933
10817
  }
10934
10818
  }]);
@@ -10971,12 +10855,7 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_ParachainNode) {
10971
10855
  var api = options.api,
10972
10856
  asset = options.asset,
10973
10857
  address = options.address;
10974
- if (!assets.isForeignAsset(asset)) {
10975
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
10976
- }
10977
- if (asset.assetId === undefined) {
10978
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
10979
- }
10858
+ assertHasId(asset);
10980
10859
  return api.callTxMethod({
10981
10860
  module: 'Assets',
10982
10861
  method: 'transfer',
@@ -11059,9 +10938,7 @@ var Unique = /*#__PURE__*/function (_ParachainNode) {
11059
10938
  if (asset.symbol === this.getNativeAssetSymbol()) {
11060
10939
  return transferXTokens(input, Unique.NATIVE_ASSET_ID);
11061
10940
  }
11062
- if (!assets.isForeignAsset(asset) || !asset.assetId) {
11063
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11064
- }
10941
+ assertHasId(asset);
11065
10942
  return transferXTokens(input, Number(asset.assetId));
11066
10943
  }
11067
10944
  }, {
@@ -11087,9 +10964,7 @@ var Zeitgeist = /*#__PURE__*/function (_ParachainNode) {
11087
10964
  key: "getCurrencySelection",
11088
10965
  value: function getCurrencySelection(asset) {
11089
10966
  if (asset.symbol === this.getNativeAssetSymbol()) return 'Ztg';
11090
- if (!assets.isForeignAsset(asset)) {
11091
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11092
- }
10967
+ assertHasId(asset);
11093
10968
  return {
11094
10969
  ForeignAsset: Number(asset.assetId)
11095
10970
  };
@@ -11107,12 +10982,7 @@ var Zeitgeist = /*#__PURE__*/function (_ParachainNode) {
11107
10982
  var api = options.api,
11108
10983
  asset = options.asset,
11109
10984
  address = options.address;
11110
- if (!assets.isForeignAsset(asset)) {
11111
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
11112
- }
11113
- if (asset.assetId === undefined) {
11114
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
11115
- }
10985
+ assertHasId(asset);
11116
10986
  return api.callTxMethod({
11117
10987
  module: 'AssetManager',
11118
10988
  method: 'transfer',
@@ -12071,7 +11941,9 @@ exports.UnableToComputeError = UnableToComputeError;
12071
11941
  exports.addEthereumBridgeFees = addEthereumBridgeFees;
12072
11942
  exports.addXcmVersionHeader = addXcmVersionHeader;
12073
11943
  exports.assertAddressIsString = assertAddressIsString;
11944
+ exports.assertHasId = assertHasId;
12074
11945
  exports.assertHasLocation = assertHasLocation;
11946
+ exports.assertIsForeign = assertIsForeign;
12075
11947
  exports.assertToIsString = assertToIsString;
12076
11948
  exports.blake2b256 = blake2b256;
12077
11949
  exports.blake2b512 = blake2b512;