@paraspell/sdk-core 11.8.6 → 11.9.0

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
@@ -860,35 +860,54 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
860
860
  return viem.parseUnits(increaseAmount, asset.decimals) + BigInt(amount);
861
861
  }
862
862
  };
863
- var overrideTxAmount = function overrideTxAmount(options, builder, amount) {
864
- var modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
865
- amount: computeOverridenAmount(options, amount)
866
- }));
867
- return modifiedBuilder['buildInternal']();
868
- };
869
- var createTx = /*#__PURE__*/function () {
863
+ var overrideTxAmount = /*#__PURE__*/function () {
870
864
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount) {
865
+ var modifiedBuilder, _yield$modifiedBuilde, tx;
871
866
  return _regenerator().w(function (_context) {
872
867
  while (1) switch (_context.n) {
868
+ case 0:
869
+ modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
870
+ amount: computeOverridenAmount(options, amount)
871
+ }));
872
+ _context.n = 1;
873
+ return modifiedBuilder['buildInternal']();
874
+ case 1:
875
+ _yield$modifiedBuilde = _context.v;
876
+ tx = _yield$modifiedBuilde.tx;
877
+ return _context.a(2, tx);
878
+ }
879
+ }, _callee);
880
+ }));
881
+ return function overrideTxAmount(_x, _x2, _x3) {
882
+ return _ref.apply(this, arguments);
883
+ };
884
+ }();
885
+ var createTx = /*#__PURE__*/function () {
886
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, builder, amount) {
887
+ var _yield$builder$buildI, tx;
888
+ return _regenerator().w(function (_context2) {
889
+ while (1) switch (_context2.n) {
873
890
  case 0:
874
891
  if (!(amount === undefined)) {
875
- _context.n = 2;
892
+ _context2.n = 2;
876
893
  break;
877
894
  }
878
- _context.n = 1;
895
+ _context2.n = 1;
879
896
  return builder['buildInternal']();
880
897
  case 1:
881
- return _context.a(2, _context.v);
898
+ _yield$builder$buildI = _context2.v;
899
+ tx = _yield$builder$buildI.tx;
900
+ return _context2.a(2, tx);
882
901
  case 2:
883
- _context.n = 3;
902
+ _context2.n = 3;
884
903
  return overrideTxAmount(options, builder, amount);
885
904
  case 3:
886
- return _context.a(2, _context.v);
905
+ return _context2.a(2, _context2.v);
887
906
  }
888
- }, _callee);
907
+ }, _callee2);
889
908
  }));
890
- return function createTx(_x, _x2, _x3) {
891
- return _ref.apply(this, arguments);
909
+ return function createTx(_x4, _x5, _x6) {
910
+ return _ref2.apply(this, arguments);
892
911
  };
893
912
  }();
894
913
 
@@ -3753,7 +3772,7 @@ var determineAddress = function determineAddress(chain, address, senderAddress)
3753
3772
  };
3754
3773
  var getReverseTxFee = /*#__PURE__*/function () {
3755
3774
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
3756
- var api, origin, destination, senderAddress, address, toAddress, fromAddress, tx, rawFee;
3775
+ var api, origin, destination, senderAddress, address, toAddress, fromAddress, _yield$Builder$from$t, tx, rawFee;
3757
3776
  return _regenerator().w(function (_context) {
3758
3777
  while (1) switch (_context.n) {
3759
3778
  case 0:
@@ -3763,7 +3782,8 @@ var getReverseTxFee = /*#__PURE__*/function () {
3763
3782
  _context.n = 1;
3764
3783
  return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
3765
3784
  case 1:
3766
- tx = _context.v;
3785
+ _yield$Builder$from$t = _context.v;
3786
+ tx = _yield$Builder$from$t.tx;
3767
3787
  _context.n = 2;
3768
3788
  return api.calculateTransactionFee(tx, fromAddress);
3769
3789
  case 2:
@@ -3984,7 +4004,7 @@ var getBalanceForeignInternal = /*#__PURE__*/function () {
3984
4004
  }
3985
4005
  return _context.a(2, getBalanceForeignXTokens(api, chain, address, asset));
3986
4006
  case 3:
3987
- if (!(defaultPallet === 'PolkadotXcm')) {
4007
+ if (!(defaultPallet === 'PolkadotXcm' || defaultPallet === 'XTransfer')) {
3988
4008
  _context.n = 4;
3989
4009
  break;
3990
4010
  }
@@ -4429,7 +4449,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4429
4449
  asset: asset,
4430
4450
  originFee: originFee,
4431
4451
  feeAsset: resolvedFeeAsset,
4432
- amount: currency.amount < 2n ? 2n : currency.amount
4452
+ amount: currency.amount < MIN_AMOUNT ? MIN_AMOUNT : currency.amount
4433
4453
  });
4434
4454
  case 4:
4435
4455
  dryRunResult = _context3.v;
@@ -6038,6 +6058,128 @@ var transferXTokens = function transferXTokens(input, currencySelection) {
6038
6058
  return api.callTxMethod(call);
6039
6059
  };
6040
6060
 
6061
+ var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
6062
+ _classCallCheck(this, BaseAssetsPallet);
6063
+ this.palletName = palletName;
6064
+ });
6065
+
6066
+ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
6067
+ function AssetsPallet() {
6068
+ _classCallCheck(this, AssetsPallet);
6069
+ return _callSuper(this, AssetsPallet, arguments);
6070
+ }
6071
+ _inherits(AssetsPallet, _BaseAssetsPallet);
6072
+ return _createClass(AssetsPallet, [{
6073
+ key: "mint",
6074
+ value: function mint(address, asset, _balance, chain) {
6075
+ assertHasId(asset);
6076
+ var assetId = asset.assetId,
6077
+ amount = asset.amount;
6078
+ var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
6079
+ var addr = assets.isChainEvm(chain) ? address : {
6080
+ Id: address
6081
+ };
6082
+ return Promise.resolve({
6083
+ assetStatusTx: {
6084
+ module: this.palletName,
6085
+ method: 'force_asset_status',
6086
+ parameters: {
6087
+ id: id,
6088
+ owner: addr,
6089
+ issuer: addr,
6090
+ admin: addr,
6091
+ freezer: addr,
6092
+ min_balance: 0n,
6093
+ is_sufficient: true,
6094
+ is_frozen: false
6095
+ }
6096
+ },
6097
+ balanceTx: {
6098
+ module: this.palletName,
6099
+ method: 'mint',
6100
+ parameters: {
6101
+ id: id,
6102
+ beneficiary: addr,
6103
+ amount: amount
6104
+ }
6105
+ }
6106
+ });
6107
+ }
6108
+ }]);
6109
+ }(BaseAssetsPallet);
6110
+
6111
+ var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
6112
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
6113
+ var _getExistentialDeposi;
6114
+ var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, _yield$Builder$from$t, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
6115
+ return _regenerator().w(function (_context) {
6116
+ while (1) switch (_context.n) {
6117
+ case 0:
6118
+ api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
6119
+ _context.n = 1;
6120
+ return api.init(origin);
6121
+ case 1:
6122
+ _context.n = 2;
6123
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
6124
+ case 2:
6125
+ _yield$Builder$from$t = _context.v;
6126
+ tx = _yield$Builder$from$t.tx;
6127
+ _context.n = 3;
6128
+ return api.calculateTransactionFee(tx, account);
6129
+ case 3:
6130
+ xcmFee = _context.v;
6131
+ xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
6132
+ _context.n = 4;
6133
+ return getBalanceNativeInternal({
6134
+ address: account,
6135
+ chain: origin,
6136
+ api: api
6137
+ });
6138
+ case 4:
6139
+ nativeBalance = _context.v;
6140
+ existentialDeposit = BigInt((_getExistentialDeposi = assets.getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
6141
+ sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
6142
+ return _context.a(2, {
6143
+ sufficientForXCM: sufficientForXCM,
6144
+ xcmFee: xcmFee
6145
+ });
6146
+ }
6147
+ }, _callee);
6148
+ }));
6149
+ return function getOriginFeeDetailsInternal(_x) {
6150
+ return _ref2.apply(this, arguments);
6151
+ };
6152
+ }();
6153
+ var getOriginFeeDetails = /*#__PURE__*/function () {
6154
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6155
+ var api;
6156
+ return _regenerator().w(function (_context2) {
6157
+ while (1) switch (_context2.p = _context2.n) {
6158
+ case 0:
6159
+ api = options.api;
6160
+ api.setDisconnectAllowed(false);
6161
+ _context2.p = 1;
6162
+ _context2.n = 2;
6163
+ return getOriginFeeDetailsInternal(options);
6164
+ case 2:
6165
+ return _context2.a(2, _context2.v);
6166
+ case 3:
6167
+ _context2.p = 3;
6168
+ api.setDisconnectAllowed(true);
6169
+ _context2.n = 4;
6170
+ return api.disconnect();
6171
+ case 4:
6172
+ return _context2.f(3);
6173
+ case 5:
6174
+ return _context2.a(2);
6175
+ }
6176
+ }, _callee2, null, [[1,, 3, 5]]);
6177
+ }));
6178
+ return function getOriginFeeDetails(_x2) {
6179
+ return _ref3.apply(this, arguments);
6180
+ };
6181
+ }();
6182
+
6041
6183
  var supportsXTokens = function supportsXTokens(obj) {
6042
6184
  return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
6043
6185
  };
@@ -6404,54 +6546,120 @@ var Parachain = /*#__PURE__*/function () {
6404
6546
  }
6405
6547
  }, {
6406
6548
  key: "transferLocal",
6407
- value: function transferLocal(options) {
6408
- var asset = options.assetInfo,
6409
- address = options.address;
6410
- if (sdkCommon.isTLocation(address)) {
6411
- throw new InvalidAddressError('Location address is not supported for local transfers');
6412
- }
6413
- var validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
6414
- address: address
6415
- });
6416
- var isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(asset);
6417
- if (isNativeAsset) {
6418
- return this.transferLocalNativeAsset(validatedOptions);
6419
- } else {
6420
- return this.transferLocalNonNativeAsset(validatedOptions);
6549
+ value: function () {
6550
+ var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
6551
+ var api, asset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
6552
+ return _regenerator().w(function (_context3) {
6553
+ while (1) switch (_context3.n) {
6554
+ case 0:
6555
+ api = options.api, asset = options.assetInfo, address = options.address, senderAddress = options.senderAddress, currency = options.currency, isAmountAll = options.isAmountAll;
6556
+ if (!sdkCommon.isTLocation(address)) {
6557
+ _context3.n = 1;
6558
+ break;
6559
+ }
6560
+ throw new InvalidAddressError('Location address is not supported for local transfers');
6561
+ case 1:
6562
+ validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
6563
+ address: address
6564
+ });
6565
+ isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(asset);
6566
+ if (!isAmountAll) {
6567
+ _context3.n = 3;
6568
+ break;
6569
+ }
6570
+ assertSenderAddress(senderAddress);
6571
+ _context3.n = 2;
6572
+ return getAssetBalanceInternal({
6573
+ api: api,
6574
+ chain: this.chain,
6575
+ address: senderAddress,
6576
+ currency: currency
6577
+ });
6578
+ case 2:
6579
+ balance = _context3.v;
6580
+ _context3.n = 4;
6581
+ break;
6582
+ case 3:
6583
+ balance = MIN_AMOUNT;
6584
+ case 4:
6585
+ localOptions = _objectSpread2(_objectSpread2({}, validatedOptions), {}, {
6586
+ balance: balance
6587
+ });
6588
+ if (!isNativeAsset) {
6589
+ _context3.n = 5;
6590
+ break;
6591
+ }
6592
+ return _context3.a(2, this.transferLocalNativeAsset(localOptions));
6593
+ case 5:
6594
+ return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
6595
+ case 6:
6596
+ return _context3.a(2);
6597
+ }
6598
+ }, _callee3, this);
6599
+ }));
6600
+ function transferLocal(_x3) {
6601
+ return _transferLocal.apply(this, arguments);
6421
6602
  }
6422
- }
6603
+ return transferLocal;
6604
+ }()
6423
6605
  }, {
6424
6606
  key: "transferLocalNativeAsset",
6425
6607
  value: function transferLocalNativeAsset(options) {
6426
6608
  var api = options.api,
6427
6609
  asset = options.assetInfo,
6428
- address = options.address;
6429
- return api.callTxMethod({
6610
+ address = options.address,
6611
+ isAmountAll = options.isAmountAll;
6612
+ var dest = assets.isChainEvm(this.chain) ? address : {
6613
+ Id: address
6614
+ };
6615
+ if (isAmountAll) {
6616
+ return Promise.resolve(api.callTxMethod({
6617
+ module: 'Balances',
6618
+ method: 'transfer_all',
6619
+ parameters: {
6620
+ dest: dest,
6621
+ keep_alive: false
6622
+ }
6623
+ }));
6624
+ }
6625
+ return Promise.resolve(api.callTxMethod({
6430
6626
  module: 'Balances',
6431
6627
  method: 'transfer_keep_alive',
6432
6628
  parameters: {
6433
- dest: assets.isChainEvm(this.chain) ? address : {
6434
- Id: address
6435
- },
6629
+ dest: dest,
6436
6630
  value: asset.amount
6437
6631
  }
6438
- });
6632
+ }));
6439
6633
  }
6440
6634
  }, {
6441
6635
  key: "transferLocalNonNativeAsset",
6442
6636
  value: function transferLocalNonNativeAsset(options) {
6443
6637
  var api = options.api,
6444
6638
  asset = options.assetInfo,
6445
- address = options.address;
6639
+ address = options.address,
6640
+ isAmountAll = options.isAmountAll;
6446
6641
  assertHasId(asset);
6642
+ var dest = {
6643
+ Id: address
6644
+ };
6645
+ var currencyId = BigInt(asset.assetId);
6646
+ if (isAmountAll) {
6647
+ return api.callTxMethod({
6648
+ module: 'Tokens',
6649
+ method: 'transfer_all',
6650
+ parameters: {
6651
+ dest: dest,
6652
+ currency_id: currencyId,
6653
+ keep_alive: false
6654
+ }
6655
+ });
6656
+ }
6447
6657
  return api.callTxMethod({
6448
6658
  module: 'Tokens',
6449
6659
  method: 'transfer',
6450
6660
  parameters: {
6451
- dest: {
6452
- Id: address
6453
- },
6454
- currency_id: BigInt(asset.assetId),
6661
+ dest: dest,
6662
+ currency_id: currencyId,
6455
6663
  amount: asset.amount
6456
6664
  }
6457
6665
  });
@@ -6459,7 +6667,7 @@ var Parachain = /*#__PURE__*/function () {
6459
6667
  }, {
6460
6668
  key: "transferToEthereum",
6461
6669
  value: function () {
6462
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
6670
+ var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
6463
6671
  var _feeAsset$location;
6464
6672
  var useOnlyDepositInstruction,
6465
6673
  api,
@@ -6482,18 +6690,18 @@ var Parachain = /*#__PURE__*/function () {
6482
6690
  customXcmOnDest,
6483
6691
  messageId,
6484
6692
  call,
6485
- _args3 = arguments;
6486
- return _regenerator().w(function (_context3) {
6487
- while (1) switch (_context3.n) {
6693
+ _args4 = arguments;
6694
+ return _regenerator().w(function (_context4) {
6695
+ while (1) switch (_context4.n) {
6488
6696
  case 0:
6489
- useOnlyDepositInstruction = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
6697
+ useOnlyDepositInstruction = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;
6490
6698
  api = input.api, asset = input.assetInfo, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAssetInfo;
6491
- _context3.n = 1;
6699
+ _context4.n = 1;
6492
6700
  return getBridgeStatus(api.clone());
6493
6701
  case 1:
6494
- bridgeStatus = _context3.v;
6702
+ bridgeStatus = _context4.v;
6495
6703
  if (!(bridgeStatus !== 'Normal')) {
6496
- _context3.n = 2;
6704
+ _context4.n = 2;
6497
6705
  break;
6498
6706
  }
6499
6707
  throw new BridgeHaltedError();
@@ -6502,14 +6710,14 @@ var Parachain = /*#__PURE__*/function () {
6502
6710
  assertAddressIsString(address);
6503
6711
  assertSenderAddress(senderAddress);
6504
6712
  ethAsset = createAsset(version, asset.amount, asset.location);
6505
- _context3.n = 3;
6713
+ _context4.n = 3;
6506
6714
  return api.createApiForChain('AssetHubPolkadot');
6507
6715
  case 3:
6508
- ahApi = _context3.v;
6509
- _context3.n = 4;
6716
+ ahApi = _context4.v;
6717
+ _context4.n = 4;
6510
6718
  return getParaEthTransferFees(ahApi);
6511
6719
  case 4:
6512
- _yield$getParaEthTran = _context3.v;
6720
+ _yield$getParaEthTran = _context4.v;
6513
6721
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
6514
6722
  bridgeFee = _yield$getParaEthTran2[0];
6515
6723
  executionFee = _yield$getParaEthTran2[1];
@@ -6517,13 +6725,13 @@ var Parachain = /*#__PURE__*/function () {
6517
6725
  fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : bridgeFee + executionFee;
6518
6726
  ethAssetInfo = assets.findAssetInfoByLoc(assets.getOtherAssets('Ethereum'), asset.location);
6519
6727
  if (ethAssetInfo) {
6520
- _context3.n = 5;
6728
+ _context4.n = 5;
6521
6729
  break;
6522
6730
  }
6523
6731
  throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt)));
6524
6732
  case 5:
6525
6733
  if (!useOnlyDepositInstruction) {
6526
- _context3.n = 6;
6734
+ _context4.n = 6;
6527
6735
  break;
6528
6736
  }
6529
6737
  customXcmOnDest = addXcmVersionHeader([{
@@ -6540,14 +6748,14 @@ var Parachain = /*#__PURE__*/function () {
6540
6748
  })
6541
6749
  }
6542
6750
  }], version);
6543
- _context3.n = 8;
6751
+ _context4.n = 8;
6544
6752
  break;
6545
6753
  case 6:
6546
6754
  assertHasId(ethAssetInfo);
6547
- _context3.n = 7;
6755
+ _context4.n = 7;
6548
6756
  return generateMessageId(api, senderAddress, getParaId(this.chain), ethAssetInfo.assetId, address, asset.amount);
6549
6757
  case 7:
6550
- messageId = _context3.v;
6758
+ messageId = _context4.v;
6551
6759
  customXcmOnDest = createCustomXcmOnDest(input, this.chain, messageId);
6552
6760
  case 8:
6553
6761
  call = {
@@ -6563,11 +6771,11 @@ var Parachain = /*#__PURE__*/function () {
6563
6771
  weight_limit: 'Unlimited'
6564
6772
  }
6565
6773
  };
6566
- return _context3.a(2, api.callTxMethod(call));
6774
+ return _context4.a(2, api.callTxMethod(call));
6567
6775
  }
6568
- }, _callee3, this);
6776
+ }, _callee4, this);
6569
6777
  }));
6570
- function transferToEthereum(_x3) {
6778
+ function transferToEthereum(_x4) {
6571
6779
  return _transferToEthereum.apply(this, arguments);
6572
6780
  }
6573
6781
  return transferToEthereum;
@@ -6577,8 +6785,12 @@ var Parachain = /*#__PURE__*/function () {
6577
6785
 
6578
6786
  var Acala = /*#__PURE__*/function (_Parachain) {
6579
6787
  function Acala() {
6788
+ var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Acala';
6789
+ var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'acala';
6790
+ var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
6791
+ var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : sdkCommon.Version.V4;
6580
6792
  _classCallCheck(this, Acala);
6581
- return _callSuper(this, Acala, ['Acala', 'acala', 'Polkadot', sdkCommon.Version.V4]);
6793
+ return _callSuper(this, Acala, [chain, info, ecosystem, version]);
6582
6794
  }
6583
6795
  _inherits(Acala, _Parachain);
6584
6796
  return _createClass(Acala, [{
@@ -6600,39 +6812,70 @@ var Acala = /*#__PURE__*/function (_Parachain) {
6600
6812
  }
6601
6813
  }, {
6602
6814
  key: "transferLocalNativeAsset",
6603
- value: function transferLocalNativeAsset(options) {
6815
+ value: function () {
6816
+ var _transferLocalNativeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
6817
+ var api, asset, address, balance, senderAddress, isAmountAll, createTx, amount, fee;
6818
+ return _regenerator().w(function (_context) {
6819
+ while (1) switch (_context.n) {
6820
+ case 0:
6821
+ api = options.api, asset = options.assetInfo, address = options.address, balance = options.balance, senderAddress = options.senderAddress, isAmountAll = options.isAmountAll;
6822
+ createTx = function createTx(amount) {
6823
+ return api.callTxMethod({
6824
+ module: 'Currencies',
6825
+ method: 'transfer_native_currency',
6826
+ parameters: {
6827
+ dest: {
6828
+ Id: address
6829
+ },
6830
+ amount: amount
6831
+ }
6832
+ });
6833
+ };
6834
+ if (!isAmountAll) {
6835
+ _context.n = 2;
6836
+ break;
6837
+ }
6838
+ assertSenderAddress(senderAddress);
6839
+ _context.n = 1;
6840
+ return api.calculateTransactionFee(createTx(MIN_AMOUNT), senderAddress);
6841
+ case 1:
6842
+ fee = _context.v;
6843
+ amount = balance - fee;
6844
+ _context.n = 3;
6845
+ break;
6846
+ case 2:
6847
+ amount = asset.amount;
6848
+ case 3:
6849
+ return _context.a(2, createTx(amount));
6850
+ }
6851
+ }, _callee);
6852
+ }));
6853
+ function transferLocalNativeAsset(_x) {
6854
+ return _transferLocalNativeAsset.apply(this, arguments);
6855
+ }
6856
+ return transferLocalNativeAsset;
6857
+ }()
6858
+ }, {
6859
+ key: "transferLocalNonNativeAsset",
6860
+ value: function transferLocalNonNativeAsset(options) {
6604
6861
  var api = options.api,
6605
6862
  asset = options.assetInfo,
6606
- address = options.address;
6863
+ address = options.address,
6864
+ balance = options.balance,
6865
+ isAmountAll = options.isAmountAll;
6866
+ if (asset.symbol.toLowerCase() === 'lcdot') {
6867
+ throw new assets.InvalidCurrencyError('LcDOT local transfers are not supported');
6868
+ }
6869
+ var amount = isAmountAll ? balance : asset.amount;
6607
6870
  return api.callTxMethod({
6608
6871
  module: 'Currencies',
6609
- method: 'transfer_native_currency',
6610
- parameters: {
6611
- dest: {
6612
- Id: address
6613
- },
6614
- amount: asset.amount
6615
- }
6616
- });
6617
- }
6618
- }, {
6619
- key: "transferLocalNonNativeAsset",
6620
- value: function transferLocalNonNativeAsset(options) {
6621
- var api = options.api,
6622
- asset = options.assetInfo,
6623
- address = options.address;
6624
- if (asset.symbol.toLowerCase() === 'lcdot') {
6625
- throw new assets.InvalidCurrencyError('LcDOT local transfers are not supported');
6626
- }
6627
- return api.callTxMethod({
6628
- module: 'Currencies',
6629
- method: 'transfer',
6872
+ method: 'transfer',
6630
6873
  parameters: {
6631
6874
  dest: {
6632
6875
  Id: address
6633
6876
  },
6634
6877
  currency_id: this.getCurrencySelection(asset),
6635
- amount: asset.amount
6878
+ amount: amount
6636
6879
  }
6637
6880
  });
6638
6881
  }
@@ -6672,16 +6915,30 @@ var Ajuna = /*#__PURE__*/function (_Parachain) {
6672
6915
  value: function transferLocalNonNativeAsset(options) {
6673
6916
  var api = options.api,
6674
6917
  asset = options.assetInfo,
6675
- address = options.address;
6918
+ address = options.address,
6919
+ isAmountAll = options.isAmountAll;
6676
6920
  assertHasId(asset);
6921
+ var assetId = Number(asset.assetId);
6922
+ var dest = {
6923
+ Id: address
6924
+ };
6925
+ if (isAmountAll) {
6926
+ return api.callTxMethod({
6927
+ module: 'Assets',
6928
+ method: 'transfer_all',
6929
+ parameters: {
6930
+ id: assetId,
6931
+ dest: dest,
6932
+ keep_alive: false
6933
+ }
6934
+ });
6935
+ }
6677
6936
  return api.callTxMethod({
6678
6937
  module: 'Assets',
6679
6938
  method: 'transfer',
6680
6939
  parameters: {
6681
- id: Number(asset.assetId),
6682
- target: {
6683
- Id: address
6684
- },
6940
+ id: assetId,
6941
+ target: dest,
6685
6942
  amount: asset.amount
6686
6943
  }
6687
6944
  });
@@ -6773,16 +7030,29 @@ var Altair = /*#__PURE__*/function (_Parachain) {
6773
7030
  value: function transferLocalNonNativeAsset(options) {
6774
7031
  var api = options.api,
6775
7032
  asset = options.assetInfo,
6776
- address = options.address;
6777
- assertHasId(asset);
7033
+ address = options.address,
7034
+ isAmountAll = options.isAmountAll;
7035
+ var dest = {
7036
+ Id: address
7037
+ };
7038
+ var currencyId = this.getCurrencySelection(asset);
7039
+ if (isAmountAll) {
7040
+ return api.callTxMethod({
7041
+ module: 'Tokens',
7042
+ method: 'transfer_all',
7043
+ parameters: {
7044
+ dest: dest,
7045
+ currency_id: currencyId,
7046
+ keep_alive: false
7047
+ }
7048
+ });
7049
+ }
6778
7050
  return api.callTxMethod({
6779
7051
  module: 'Tokens',
6780
7052
  method: 'transfer',
6781
7053
  parameters: {
6782
- dest: {
6783
- Id: address
6784
- },
6785
- currency_id: this.getCurrencySelection(asset),
7054
+ dest: dest,
7055
+ currency_id: currencyId,
6786
7056
  amount: asset.amount
6787
7057
  }
6788
7058
  });
@@ -7193,18 +7463,45 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7193
7463
  value: function transferLocalNonNativeAsset(options) {
7194
7464
  var api = options.api,
7195
7465
  asset = options.assetInfo,
7196
- address = options.address;
7466
+ address = options.address,
7467
+ isAmountAll = options.isAmountAll;
7197
7468
  assertIsForeign(asset);
7198
7469
  if (asset.assetId !== undefined) {
7470
+ var assetId = Number(asset.assetId);
7471
+ var dest = {
7472
+ Id: address
7473
+ };
7474
+ if (isAmountAll) {
7475
+ return api.callTxMethod({
7476
+ module: 'Assets',
7477
+ method: 'transfer_all',
7478
+ parameters: {
7479
+ id: assetId,
7480
+ dest: dest,
7481
+ keep_alive: false
7482
+ }
7483
+ });
7484
+ }
7199
7485
  return api.callTxMethod({
7200
7486
  module: 'Assets',
7201
7487
  method: 'transfer',
7202
7488
  parameters: {
7203
- id: Number(asset.assetId),
7204
- target: {
7489
+ id: assetId,
7490
+ target: dest,
7491
+ amount: asset.amount
7492
+ }
7493
+ });
7494
+ }
7495
+ if (isAmountAll) {
7496
+ return api.callTxMethod({
7497
+ module: 'ForeignAssets',
7498
+ method: 'transfer_all',
7499
+ parameters: {
7500
+ id: asset.location,
7501
+ dest: {
7205
7502
  Id: address
7206
7503
  },
7207
- amount: asset.amount
7504
+ keep_alive: false
7208
7505
  }
7209
7506
  });
7210
7507
  }
@@ -7272,16 +7569,30 @@ var Astar = /*#__PURE__*/function (_Parachain) {
7272
7569
  value: function transferLocalNonNativeAsset(options) {
7273
7570
  var api = options.api,
7274
7571
  asset = options.assetInfo,
7275
- address = options.address;
7572
+ address = options.address,
7573
+ isAmountAll = options.isAmountAll;
7276
7574
  assertHasId(asset);
7575
+ var assetId = Number(asset.assetId);
7576
+ var dest = {
7577
+ Id: address
7578
+ };
7579
+ if (isAmountAll) {
7580
+ return api.callTxMethod({
7581
+ module: 'Assets',
7582
+ method: 'transfer_all',
7583
+ parameters: {
7584
+ id: assetId,
7585
+ dest: dest,
7586
+ keep_alive: false
7587
+ }
7588
+ });
7589
+ }
7277
7590
  return api.callTxMethod({
7278
7591
  module: 'Assets',
7279
7592
  method: 'transfer',
7280
7593
  parameters: {
7281
- id: Number(asset.assetId),
7282
- target: {
7283
- Id: address
7284
- },
7594
+ id: assetId,
7595
+ target: dest,
7285
7596
  amount: asset.amount
7286
7597
  }
7287
7598
  });
@@ -7437,15 +7748,29 @@ var BifrostPolkadot = /*#__PURE__*/function (_Parachain) {
7437
7748
  value: function transferLocalNonNativeAsset(options) {
7438
7749
  var api = options.api,
7439
7750
  asset = options.assetInfo,
7440
- address = options.address;
7751
+ address = options.address,
7752
+ isAmountAll = options.isAmountAll;
7753
+ var dest = {
7754
+ Id: address
7755
+ };
7756
+ var currencyId = this.getCurrencySelection(asset);
7757
+ if (isAmountAll) {
7758
+ return api.callTxMethod({
7759
+ module: 'Tokens',
7760
+ method: 'transfer_all',
7761
+ parameters: {
7762
+ dest: dest,
7763
+ currency_id: currencyId,
7764
+ keep_alive: false
7765
+ }
7766
+ });
7767
+ }
7441
7768
  return api.callTxMethod({
7442
7769
  module: 'Tokens',
7443
7770
  method: 'transfer',
7444
7771
  parameters: {
7445
- dest: {
7446
- Id: address
7447
- },
7448
- currency_id: this.getCurrencySelection(asset),
7772
+ dest: dest,
7773
+ currency_id: currencyId,
7449
7774
  amount: asset.amount
7450
7775
  }
7451
7776
  });
@@ -7565,16 +7890,29 @@ var Centrifuge = /*#__PURE__*/function (_Parachain) {
7565
7890
  value: function transferLocalNonNativeAsset(options) {
7566
7891
  var api = options.api,
7567
7892
  asset = options.assetInfo,
7568
- address = options.address;
7569
- assertHasId(asset);
7893
+ address = options.address,
7894
+ isAmountAll = options.isAmountAll;
7895
+ var dest = {
7896
+ Id: address
7897
+ };
7898
+ var currencyId = this.getCurrencySelection(asset);
7899
+ if (isAmountAll) {
7900
+ return api.callTxMethod({
7901
+ module: 'Tokens',
7902
+ method: 'transfer_all',
7903
+ parameters: {
7904
+ dest: dest,
7905
+ currency_id: currencyId,
7906
+ keep_alive: false
7907
+ }
7908
+ });
7909
+ }
7570
7910
  return api.callTxMethod({
7571
7911
  module: 'Tokens',
7572
7912
  method: 'transfer',
7573
7913
  parameters: {
7574
- dest: {
7575
- Id: address
7576
- },
7577
- currency_id: this.getCurrencySelection(asset),
7914
+ dest: dest,
7915
+ currency_id: currencyId,
7578
7916
  amount: asset.amount
7579
7917
  }
7580
7918
  });
@@ -7799,16 +8137,30 @@ var Crust = /*#__PURE__*/function (_Parachain) {
7799
8137
  value: function transferLocalNonNativeAsset(options) {
7800
8138
  var api = options.api,
7801
8139
  asset = options.assetInfo,
7802
- address = options.address;
8140
+ address = options.address,
8141
+ isAmountAll = options.isAmountAll;
7803
8142
  assertHasId(asset);
8143
+ var assetId = BigInt(asset.assetId);
8144
+ var dest = {
8145
+ Id: address
8146
+ };
8147
+ if (isAmountAll) {
8148
+ return api.callTxMethod({
8149
+ module: 'Assets',
8150
+ method: 'transfer_all',
8151
+ parameters: {
8152
+ id: assetId,
8153
+ dest: dest,
8154
+ keep_alive: false
8155
+ }
8156
+ });
8157
+ }
7804
8158
  return api.callTxMethod({
7805
8159
  module: 'Assets',
7806
8160
  method: 'transfer',
7807
8161
  parameters: {
7808
- id: BigInt(asset.assetId),
7809
- target: {
7810
- Id: address
7811
- },
8162
+ id: assetId,
8163
+ target: dest,
7812
8164
  amount: asset.amount
7813
8165
  }
7814
8166
  });
@@ -7915,13 +8267,26 @@ var Darwinia = /*#__PURE__*/function (_Parachain) {
7915
8267
  value: function transferLocalNonNativeAsset(options) {
7916
8268
  var api = options.api,
7917
8269
  asset = options.assetInfo,
7918
- address = options.address;
8270
+ address = options.address,
8271
+ isAmountAll = options.isAmountAll;
7919
8272
  assertHasId(asset);
8273
+ var assetId = BigInt(asset.assetId);
8274
+ if (isAmountAll) {
8275
+ return api.callTxMethod({
8276
+ module: 'Assets',
8277
+ method: 'transfer_all',
8278
+ parameters: {
8279
+ id: assetId,
8280
+ dest: address,
8281
+ keep_alive: false
8282
+ }
8283
+ });
8284
+ }
7920
8285
  return api.callTxMethod({
7921
8286
  module: 'Assets',
7922
8287
  method: 'transfer',
7923
8288
  parameters: {
7924
- id: BigInt(asset.assetId),
8289
+ id: assetId,
7925
8290
  target: address,
7926
8291
  amount: asset.amount
7927
8292
  }
@@ -8189,9 +8554,23 @@ var Polimec = /*#__PURE__*/function (_Parachain) {
8189
8554
  value: function transferLocalNonNativeAsset(options) {
8190
8555
  var api = options.api,
8191
8556
  asset = options.assetInfo,
8192
- address = options.address;
8557
+ address = options.address,
8558
+ isAmountAll = options.isAmountAll;
8193
8559
  assertIsForeign(asset);
8194
8560
  assertHasLocation(asset);
8561
+ if (isAmountAll) {
8562
+ return api.callTxMethod({
8563
+ module: 'ForeignAssets',
8564
+ method: 'transfer_all',
8565
+ parameters: {
8566
+ id: asset.location,
8567
+ target: {
8568
+ Id: address
8569
+ },
8570
+ keep_alive: false
8571
+ }
8572
+ });
8573
+ }
8195
8574
  return api.callTxMethod({
8196
8575
  module: 'ForeignAssets',
8197
8576
  method: 'transfer',
@@ -8375,29 +8754,53 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8375
8754
  value: function transferLocalNativeAsset(options) {
8376
8755
  var api = options.api,
8377
8756
  asset = options.assetInfo,
8378
- address = options.address;
8379
- return api.callTxMethod({
8757
+ address = options.address,
8758
+ isAmountAll = options.isAmountAll;
8759
+ if (isAmountAll) {
8760
+ return Promise.resolve(api.callTxMethod({
8761
+ module: 'Balances',
8762
+ method: 'transfer_all',
8763
+ parameters: {
8764
+ dest: address,
8765
+ keep_alive: false
8766
+ }
8767
+ }));
8768
+ }
8769
+ return Promise.resolve(api.callTxMethod({
8380
8770
  module: 'Balances',
8381
8771
  method: 'transfer_keep_alive',
8382
8772
  parameters: {
8383
8773
  dest: address,
8384
8774
  value: asset.amount
8385
8775
  }
8386
- });
8776
+ }));
8387
8777
  }
8388
8778
  }, {
8389
8779
  key: "transferLocalNonNativeAsset",
8390
8780
  value: function transferLocalNonNativeAsset(options) {
8391
8781
  var api = options.api,
8392
8782
  asset = options.assetInfo,
8393
- address = options.address;
8783
+ address = options.address,
8784
+ isAmountAll = options.isAmountAll;
8394
8785
  assertHasId(asset);
8786
+ var currencyId = Number(asset.assetId);
8787
+ if (isAmountAll) {
8788
+ return api.callTxMethod({
8789
+ module: 'Tokens',
8790
+ method: 'transfer_all',
8791
+ parameters: {
8792
+ dest: address,
8793
+ currency_id: currencyId,
8794
+ keep_alive: false
8795
+ }
8796
+ });
8797
+ }
8395
8798
  return api.callTxMethod({
8396
8799
  module: 'Tokens',
8397
8800
  method: 'transfer',
8398
8801
  parameters: {
8399
8802
  dest: address,
8400
- currency_id: Number(asset.assetId),
8803
+ currency_id: currencyId,
8401
8804
  amount: asset.amount
8402
8805
  }
8403
8806
  });
@@ -8440,16 +8843,30 @@ var IntegriteePolkadot = /*#__PURE__*/function (_Parachain) {
8440
8843
  value: function transferLocalNonNativeAsset(options) {
8441
8844
  var api = options.api,
8442
8845
  asset = options.assetInfo,
8443
- address = options.address;
8846
+ address = options.address,
8847
+ isAmountAll = options.isAmountAll;
8444
8848
  assertHasId(asset);
8849
+ var assetId = Number(asset.assetId);
8850
+ var dest = {
8851
+ Id: address
8852
+ };
8853
+ if (isAmountAll) {
8854
+ return api.callTxMethod({
8855
+ module: 'Assets',
8856
+ method: 'transfer_all',
8857
+ parameters: {
8858
+ id: assetId,
8859
+ dest: dest,
8860
+ keep_alive: false
8861
+ }
8862
+ });
8863
+ }
8445
8864
  return api.callTxMethod({
8446
8865
  module: 'Assets',
8447
8866
  method: 'transfer',
8448
8867
  parameters: {
8449
- id: Number(asset.assetId),
8450
- target: {
8451
- Id: address
8452
- },
8868
+ id: assetId,
8869
+ target: dest,
8453
8870
  amount: asset.amount
8454
8871
  }
8455
8872
  });
@@ -8504,20 +8921,33 @@ var Interlay = /*#__PURE__*/function (_Parachain) {
8504
8921
  }, {
8505
8922
  key: "transferLocalNativeAsset",
8506
8923
  value: function transferLocalNativeAsset(options) {
8507
- return this.transferLocalNonNativeAsset(options);
8924
+ return Promise.resolve(this.transferLocalNonNativeAsset(options));
8508
8925
  }
8509
8926
  }, {
8510
8927
  key: "transferLocalNonNativeAsset",
8511
8928
  value: function transferLocalNonNativeAsset(options) {
8512
8929
  var api = options.api,
8513
8930
  asset = options.assetInfo,
8514
- address = options.address;
8931
+ address = options.address,
8932
+ isAmountAll = options.isAmountAll;
8933
+ var currencyId = this.getCurrencySelection(asset);
8934
+ if (isAmountAll) {
8935
+ return api.callTxMethod({
8936
+ module: 'Tokens',
8937
+ method: 'transfer_all',
8938
+ parameters: {
8939
+ dest: address,
8940
+ currency_id: currencyId,
8941
+ keep_alive: false
8942
+ }
8943
+ });
8944
+ }
8515
8945
  return api.callTxMethod({
8516
8946
  module: 'Tokens',
8517
8947
  method: 'transfer',
8518
8948
  parameters: {
8519
8949
  dest: address,
8520
- currency_id: this.getCurrencySelection(asset),
8950
+ currency_id: currencyId,
8521
8951
  value: asset.amount
8522
8952
  }
8523
8953
  });
@@ -8572,29 +9002,14 @@ Jamton.NATIVE_ASSET_IDS = {
8572
9002
  jamTON: 2
8573
9003
  };
8574
9004
 
8575
- var Karura = /*#__PURE__*/function (_Parachain) {
9005
+ var Karura = /*#__PURE__*/function (_Acala) {
8576
9006
  function Karura() {
8577
9007
  _classCallCheck(this, Karura);
8578
9008
  return _callSuper(this, Karura, ['Karura', 'karura', 'Kusama', sdkCommon.Version.V4]);
8579
9009
  }
8580
- _inherits(Karura, _Parachain);
8581
- return _createClass(Karura, [{
8582
- key: "transferXTokens",
8583
- value: function transferXTokens(input) {
8584
- return getChain('Acala').transferXTokens(input);
8585
- }
8586
- }, {
8587
- key: "transferLocalNativeAsset",
8588
- value: function transferLocalNativeAsset(options) {
8589
- return getChain('Acala').transferLocalNativeAsset(options);
8590
- }
8591
- }, {
8592
- key: "transferLocalNonNativeAsset",
8593
- value: function transferLocalNonNativeAsset(options) {
8594
- return getChain('Acala').transferLocalNonNativeAsset(options);
8595
- }
8596
- }]);
8597
- }(Parachain);
9010
+ _inherits(Karura, _Acala);
9011
+ return _createClass(Karura);
9012
+ }(Acala);
8598
9013
 
8599
9014
  var KiltSpiritnet = /*#__PURE__*/function (_Parachain) {
8600
9015
  function KiltSpiritnet() {
@@ -8658,20 +9073,33 @@ var Kintsugi = /*#__PURE__*/function (_Parachain) {
8658
9073
  }, {
8659
9074
  key: "transferLocalNativeAsset",
8660
9075
  value: function transferLocalNativeAsset(options) {
8661
- return this.transferLocalNonNativeAsset(options);
9076
+ return Promise.resolve(this.transferLocalNonNativeAsset(options));
8662
9077
  }
8663
9078
  }, {
8664
9079
  key: "transferLocalNonNativeAsset",
8665
9080
  value: function transferLocalNonNativeAsset(options) {
8666
9081
  var api = options.api,
8667
9082
  asset = options.assetInfo,
8668
- address = options.address;
9083
+ address = options.address,
9084
+ isAmountAll = options.isAmountAll;
9085
+ var currencyId = this.getCurrencySelection(asset);
9086
+ if (isAmountAll) {
9087
+ return api.callTxMethod({
9088
+ module: 'Tokens',
9089
+ method: 'transfer_all',
9090
+ parameters: {
9091
+ dest: address,
9092
+ currency_id: currencyId,
9093
+ keep_alive: false
9094
+ }
9095
+ });
9096
+ }
8669
9097
  return api.callTxMethod({
8670
9098
  module: 'Tokens',
8671
9099
  method: 'transfer',
8672
9100
  parameters: {
8673
9101
  dest: address,
8674
- currency_id: this.getCurrencySelection(asset),
9102
+ currency_id: currencyId,
8675
9103
  value: asset.amount
8676
9104
  }
8677
9105
  });
@@ -8750,17 +9178,21 @@ var Manta = /*#__PURE__*/function (_Parachain) {
8750
9178
  value: function transferLocalNonNativeAsset(options) {
8751
9179
  var api = options.api,
8752
9180
  asset = options.assetInfo,
8753
- address = options.address;
9181
+ address = options.address,
9182
+ balance = options.balance,
9183
+ isAmountAll = options.isAmountAll;
8754
9184
  assertHasId(asset);
9185
+ var assetId = BigInt(asset.assetId);
9186
+ var amount = isAmountAll ? balance : asset.amount;
8755
9187
  return api.callTxMethod({
8756
9188
  module: 'Assets',
8757
9189
  method: 'transfer',
8758
9190
  parameters: {
8759
- id: BigInt(asset.assetId),
9191
+ id: assetId,
8760
9192
  target: {
8761
9193
  Id: address
8762
9194
  },
8763
- amount: asset.amount
9195
+ amount: amount
8764
9196
  }
8765
9197
  });
8766
9198
  }
@@ -8832,20 +9264,8 @@ var Moonbeam = /*#__PURE__*/function (_Parachain) {
8832
9264
  }()
8833
9265
  }, {
8834
9266
  key: "transferLocalNonNativeAsset",
8835
- value: function transferLocalNonNativeAsset(options) {
8836
- var api = options.api,
8837
- assetInfo = options.assetInfo,
8838
- address = options.address;
8839
- assertHasId(assetInfo);
8840
- return api.callTxMethod({
8841
- module: 'Assets',
8842
- method: 'transfer',
8843
- parameters: {
8844
- id: BigInt(assetInfo.assetId),
8845
- target: address,
8846
- amount: assetInfo.amount
8847
- }
8848
- });
9267
+ value: function transferLocalNonNativeAsset(_options) {
9268
+ throw new ScenarioNotSupportedError(this.chain, 'ParaToPara', "".concat(this.chain, " local transfers are temporarily disabled"));
8849
9269
  }
8850
9270
  }]);
8851
9271
  }(Parachain);
@@ -9022,6 +9442,53 @@ var NeuroWeb = /*#__PURE__*/function (_Parachain) {
9022
9442
  value: function transferPolkadotXCM(input) {
9023
9443
  return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9024
9444
  }
9445
+ }, {
9446
+ key: "transferLocalNativeAsset",
9447
+ value: function transferLocalNativeAsset(options) {
9448
+ var api = options.api,
9449
+ asset = options.assetInfo,
9450
+ address = options.address,
9451
+ isAmountAll = options.isAmountAll;
9452
+ if (isAmountAll) {
9453
+ return Promise.resolve(api.callTxMethod({
9454
+ module: 'Balances',
9455
+ method: 'transfer_all',
9456
+ parameters: {
9457
+ dest: address,
9458
+ keep_alive: false
9459
+ }
9460
+ }));
9461
+ }
9462
+ return Promise.resolve(api.callTxMethod({
9463
+ module: 'Balances',
9464
+ method: 'transfer_keep_alive',
9465
+ parameters: {
9466
+ dest: address,
9467
+ value: asset.amount
9468
+ }
9469
+ }));
9470
+ }
9471
+ }, {
9472
+ key: "transferLocalNonNativeAsset",
9473
+ value: function transferLocalNonNativeAsset(options) {
9474
+ var api = options.api,
9475
+ asset = options.assetInfo,
9476
+ address = options.address,
9477
+ balance = options.balance,
9478
+ isAmountAll = options.isAmountAll;
9479
+ assertHasId(asset);
9480
+ var assetId = BigInt(asset.assetId);
9481
+ var amount = isAmountAll ? balance : asset.amount;
9482
+ return api.callTxMethod({
9483
+ module: 'Assets',
9484
+ method: 'transfer',
9485
+ parameters: {
9486
+ id: assetId,
9487
+ target: address,
9488
+ amount: amount
9489
+ }
9490
+ });
9491
+ }
9025
9492
  }]);
9026
9493
  }(Parachain);
9027
9494
 
@@ -9161,16 +9628,30 @@ var Peaq = /*#__PURE__*/function (_Parachain) {
9161
9628
  value: function transferLocalNonNativeAsset(options) {
9162
9629
  var api = options.api,
9163
9630
  asset = options.assetInfo,
9164
- address = options.address;
9631
+ address = options.address,
9632
+ isAmountAll = options.isAmountAll;
9165
9633
  assertHasId(asset);
9634
+ var assetId = BigInt(asset.assetId);
9635
+ var dest = {
9636
+ Id: address
9637
+ };
9638
+ if (isAmountAll) {
9639
+ return api.callTxMethod({
9640
+ module: 'Assets',
9641
+ method: 'transfer_all',
9642
+ parameters: {
9643
+ id: assetId,
9644
+ dest: dest,
9645
+ keep_alive: false
9646
+ }
9647
+ });
9648
+ }
9166
9649
  return api.callTxMethod({
9167
9650
  module: 'Assets',
9168
9651
  method: 'transfer',
9169
9652
  parameters: {
9170
- id: BigInt(asset.assetId),
9171
- target: {
9172
- Id: address
9173
- },
9653
+ id: assetId,
9654
+ target: dest,
9174
9655
  amount: asset.amount
9175
9656
  }
9176
9657
  });
@@ -9342,17 +9823,21 @@ var Phala = /*#__PURE__*/function (_Parachain) {
9342
9823
  value: function transferLocalNonNativeAsset(options) {
9343
9824
  var api = options.api,
9344
9825
  asset = options.assetInfo,
9345
- address = options.address;
9826
+ address = options.address,
9827
+ isAmountAll = options.isAmountAll;
9346
9828
  assertHasId(asset);
9829
+ var assetId = BigInt(asset.assetId);
9830
+ var dest = {
9831
+ Id: address
9832
+ };
9833
+ var amount = isAmountAll ? options.balance : asset.amount;
9347
9834
  return api.callTxMethod({
9348
9835
  module: 'Assets',
9349
9836
  method: 'transfer',
9350
9837
  parameters: {
9351
- id: BigInt(asset.assetId),
9352
- target: {
9353
- Id: address
9354
- },
9355
- amount: asset.amount
9838
+ id: assetId,
9839
+ target: dest,
9840
+ amount: amount
9356
9841
  }
9357
9842
  });
9358
9843
  }
@@ -9423,16 +9908,30 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_Parachain) {
9423
9908
  value: function transferLocalNonNativeAsset(options) {
9424
9909
  var api = options.api,
9425
9910
  asset = options.assetInfo,
9426
- address = options.address;
9911
+ address = options.address,
9912
+ isAmountAll = options.isAmountAll;
9427
9913
  assertHasId(asset);
9914
+ var assetId = BigInt(asset.assetId);
9915
+ var dest = {
9916
+ Id: address
9917
+ };
9918
+ if (isAmountAll) {
9919
+ return api.callTxMethod({
9920
+ module: 'Assets',
9921
+ method: 'transfer_all',
9922
+ parameters: {
9923
+ id: assetId,
9924
+ dest: dest,
9925
+ keep_alive: false
9926
+ }
9927
+ });
9928
+ }
9428
9929
  return api.callTxMethod({
9429
9930
  module: 'Assets',
9430
9931
  method: 'transfer',
9431
9932
  parameters: {
9432
- id: BigInt(asset.assetId),
9433
- target: {
9434
- Id: address
9435
- },
9933
+ id: assetId,
9934
+ target: dest,
9436
9935
  amount: asset.amount
9437
9936
  }
9438
9937
  });
@@ -9593,8 +10092,11 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
9593
10092
  value: function transferLocalNonNativeAsset(options) {
9594
10093
  var api = options.api,
9595
10094
  asset = options.assetInfo,
9596
- address = options.address;
10095
+ address = options.address,
10096
+ balance = options.balance,
10097
+ isAmountAll = options.isAmountAll;
9597
10098
  assertHasId(asset);
10099
+ var amount = isAmountAll ? balance : asset.amount;
9598
10100
  return api.callTxMethod({
9599
10101
  module: 'AssetManager',
9600
10102
  method: 'transfer',
@@ -9603,7 +10105,7 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
9603
10105
  Id: address
9604
10106
  },
9605
10107
  currency_id: this.getCurrencySelection(asset),
9606
- amount: asset.amount
10108
+ amount: amount
9607
10109
  }
9608
10110
  });
9609
10111
  }
@@ -9736,6 +10238,8 @@ var MAX_WEIGHT = {
9736
10238
  refTime: MAX_U64
9737
10239
  };
9738
10240
  var BYPASS_MINT_AMOUNT = '1000';
10241
+ var MIN_AMOUNT = 2n;
10242
+ var AMOUNT_ALL = 'ALL';
9739
10243
 
9740
10244
  var buildClaimAssetsParams = function buildClaimAssetsParams(options) {
9741
10245
  var assets = options.assets,
@@ -9891,11 +10395,6 @@ var dryRunOrigin = /*#__PURE__*/function () {
9891
10395
  };
9892
10396
  }();
9893
10397
 
9894
- var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
9895
- _classCallCheck(this, BaseAssetsPallet);
9896
- this.palletName = palletName;
9897
- });
9898
-
9899
10398
  var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9900
10399
  function AssetManagerPallet() {
9901
10400
  _classCallCheck(this, AssetManagerPallet);
@@ -9927,51 +10426,6 @@ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9927
10426
  }]);
9928
10427
  }(BaseAssetsPallet);
9929
10428
 
9930
- var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9931
- function AssetsPallet() {
9932
- _classCallCheck(this, AssetsPallet);
9933
- return _callSuper(this, AssetsPallet, arguments);
9934
- }
9935
- _inherits(AssetsPallet, _BaseAssetsPallet);
9936
- return _createClass(AssetsPallet, [{
9937
- key: "mint",
9938
- value: function mint(address, asset, _balance, chain) {
9939
- assertHasId(asset);
9940
- var assetId = asset.assetId,
9941
- amount = asset.amount;
9942
- var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
9943
- var addr = assets.isChainEvm(chain) ? address : {
9944
- Id: address
9945
- };
9946
- return Promise.resolve({
9947
- assetStatusTx: {
9948
- module: this.palletName,
9949
- method: 'force_asset_status',
9950
- parameters: {
9951
- id: id,
9952
- owner: addr,
9953
- issuer: addr,
9954
- admin: addr,
9955
- freezer: addr,
9956
- min_balance: 0n,
9957
- is_sufficient: true,
9958
- is_frozen: false
9959
- }
9960
- },
9961
- balanceTx: {
9962
- module: this.palletName,
9963
- method: 'mint',
9964
- parameters: {
9965
- id: id,
9966
- beneficiary: addr,
9967
- amount: amount
9968
- }
9969
- }
9970
- });
9971
- }
9972
- }]);
9973
- }(BaseAssetsPallet);
9974
-
9975
10429
  var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9976
10430
  function BalancesPallet() {
9977
10431
  _classCallCheck(this, BalancesPallet);
@@ -10007,17 +10461,19 @@ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
10007
10461
  _inherits(CurrenciesPallet, _BaseAssetsPallet);
10008
10462
  return _createClass(CurrenciesPallet, [{
10009
10463
  key: "mint",
10010
- value: function mint(address, assetInfo, balance) {
10011
- assertHasId(assetInfo);
10012
- var assetId = assetInfo.assetId,
10013
- amount = assetInfo.amount;
10464
+ value: function mint(address, asset, balance, chain) {
10465
+ var isKarura = chain.startsWith('Karura');
10466
+ var id = isKarura ? getChain('Karura').getCurrencySelection(asset) : (assertHasId(asset), Number(asset.assetId));
10467
+ var amount = asset.amount;
10014
10468
  return Promise.resolve({
10015
10469
  balanceTx: {
10016
10470
  module: this.palletName,
10017
10471
  method: 'update_balance',
10018
10472
  parameters: {
10019
- who: address,
10020
- currency_id: Number(assetId),
10473
+ who: isKarura ? {
10474
+ Id: address
10475
+ } : address,
10476
+ currency_id: id,
10021
10477
  amount: balance + amount
10022
10478
  }
10023
10479
  }
@@ -10179,77 +10635,6 @@ var getPalletInstance = function getPalletInstance(type) {
10179
10635
  return palletRegistry[type];
10180
10636
  };
10181
10637
 
10182
- var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
10183
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
10184
- var _getExistentialDeposi;
10185
- var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
10186
- return _regenerator().w(function (_context) {
10187
- while (1) switch (_context.n) {
10188
- case 0:
10189
- api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
10190
- _context.n = 1;
10191
- return api.init(origin);
10192
- case 1:
10193
- _context.n = 2;
10194
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
10195
- case 2:
10196
- tx = _context.v;
10197
- _context.n = 3;
10198
- return api.calculateTransactionFee(tx, account);
10199
- case 3:
10200
- xcmFee = _context.v;
10201
- xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
10202
- _context.n = 4;
10203
- return getBalanceNativeInternal({
10204
- address: account,
10205
- chain: origin,
10206
- api: api
10207
- });
10208
- case 4:
10209
- nativeBalance = _context.v;
10210
- existentialDeposit = BigInt((_getExistentialDeposi = assets.getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
10211
- sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
10212
- return _context.a(2, {
10213
- sufficientForXCM: sufficientForXCM,
10214
- xcmFee: xcmFee
10215
- });
10216
- }
10217
- }, _callee);
10218
- }));
10219
- return function getOriginFeeDetailsInternal(_x) {
10220
- return _ref2.apply(this, arguments);
10221
- };
10222
- }();
10223
- var getOriginFeeDetails = /*#__PURE__*/function () {
10224
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
10225
- var api;
10226
- return _regenerator().w(function (_context2) {
10227
- while (1) switch (_context2.p = _context2.n) {
10228
- case 0:
10229
- api = options.api;
10230
- api.setDisconnectAllowed(false);
10231
- _context2.p = 1;
10232
- _context2.n = 2;
10233
- return getOriginFeeDetailsInternal(options);
10234
- case 2:
10235
- return _context2.a(2, _context2.v);
10236
- case 3:
10237
- _context2.p = 3;
10238
- api.setDisconnectAllowed(true);
10239
- _context2.n = 4;
10240
- return api.disconnect();
10241
- case 4:
10242
- return _context2.f(3);
10243
- case 5:
10244
- return _context2.a(2);
10245
- }
10246
- }, _callee2, null, [[1,, 3, 5]]);
10247
- }));
10248
- return function getOriginFeeDetails(_x2) {
10249
- return _ref3.apply(this, arguments);
10250
- };
10251
- }();
10252
-
10253
10638
  var pickOtherPallet = function pickOtherPallet(asset, pallets) {
10254
10639
  if (assets.isForeignAsset(asset) && (!asset.assetId || asset.assetId.startsWith('0x'))) {
10255
10640
  var _pallets$find;
@@ -10788,6 +11173,9 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
10788
11173
  }
10789
11174
  // MultiAsset is an array of TCurrencyCore, search for assets
10790
11175
  var assets$1 = currency.map(function (currency) {
11176
+ if (currency.amount === AMOUNT_ALL) {
11177
+ throw new assets.InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
11178
+ }
10791
11179
  var asset = assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null);
10792
11180
  if (!asset) {
10793
11181
  throw new assets.InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
@@ -11539,11 +11927,11 @@ var transferRelayToPara = /*#__PURE__*/function () {
11539
11927
 
11540
11928
  var send = /*#__PURE__*/function () {
11541
11929
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
11542
- var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, amount, finalAmount, originVersion, destVersion, resolvedVersion, isLocalTransfer, overriddenAsset, resolvedAsset, finalAsset, finalVersion, normalizedAsset;
11930
+ var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, ahAddress, pallet, method, isAmountAll, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, amount, finalAmount, originVersion, destVersion, resolvedVersion, isLocalTransfer, overriddenAsset, resolvedAsset, finalAsset, finalVersion, normalizedAsset;
11543
11931
  return _regenerator().w(function (_context) {
11544
11932
  while (1) switch (_context.n) {
11545
11933
  case 0:
11546
- api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
11934
+ api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, isAmountAll = options.isAmountAll;
11547
11935
  validateCurrency(currency, feeAsset);
11548
11936
  validateDestination(origin, destination);
11549
11937
  validateDestinationAddress(address, destination);
@@ -11555,7 +11943,7 @@ var send = /*#__PURE__*/function () {
11555
11943
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
11556
11944
  validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
11557
11945
  amount = Array.isArray(currency) ? 0n : abstractDecimals(currency.amount, asset === null || asset === void 0 ? void 0 : asset.decimals, api); // Ensure amount is at least 2 to avoid Rust panic (only for non-array currencies)
11558
- finalAmount = !Array.isArray(currency) && amount < 2n ? 2n : amount;
11946
+ finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
11559
11947
  originVersion = getChainVersion(origin);
11560
11948
  destVersion = !sdkCommon.isTLocation(destination) ? getChainVersion(destination) : undefined;
11561
11949
  resolvedVersion = selectXcmVersion(version, originVersion, destVersion);
@@ -11589,7 +11977,16 @@ var send = /*#__PURE__*/function () {
11589
11977
  _context.n = 4;
11590
11978
  return api.init(origin, TX_CLIENT_TIMEOUT_MS);
11591
11979
  case 4:
11592
- return _context.a(2, api.callTxMethod({
11980
+ return _context.a(2, api.callTxMethod(isAmountAll ? {
11981
+ module: 'Balances',
11982
+ method: 'transfer_all',
11983
+ parameters: {
11984
+ dest: {
11985
+ Id: address
11986
+ },
11987
+ keepAlive: true
11988
+ }
11989
+ } : {
11593
11990
  module: 'Balances',
11594
11991
  method: 'transfer_keep_alive',
11595
11992
  parameters: {
@@ -11648,7 +12045,8 @@ var send = /*#__PURE__*/function () {
11648
12045
  senderAddress: senderAddress,
11649
12046
  ahAddress: ahAddress,
11650
12047
  pallet: pallet,
11651
- method: method
12048
+ method: method,
12049
+ isAmountAll: isAmountAll
11652
12050
  }));
11653
12051
  }
11654
12052
  }, _callee);
@@ -12073,7 +12471,7 @@ var getTransferInfo = /*#__PURE__*/function () {
12073
12471
 
12074
12472
  var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12075
12473
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
12076
- var api, origin, senderAddress, address, chain, destination, currency, feeAsset, buildTx, builder, resolvedFeeAsset, asset, destAsset, destCurrency, destApi, destBalance, destEd, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, amount, result, originFee, hopFeeTotal, destinationFee, edComponent, minAmount, modifiedBuilder, dryRunResult, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
12474
+ var api, origin, senderAddress, address, chain, destination, currency, feeAsset, buildTx, builder, resolvedFeeAsset, asset, destAsset, destCurrency, destApi, destBalance, destEd, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, amount, result, originFee, hopFeeTotal, destinationFee, edComponent, minAmount, modifiedBuilder, _yield$modifiedBuilde, tx, dryRunResult;
12077
12475
  return _regenerator().w(function (_context) {
12078
12476
  while (1) switch (_context.n) {
12079
12477
  case 0:
@@ -12132,30 +12530,23 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12132
12530
  modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12133
12531
  amount: minAmount
12134
12532
  }));
12135
- _t = dryRunInternal;
12136
- _t2 = api;
12137
12533
  _context.n = 4;
12138
12534
  return modifiedBuilder['buildInternal']();
12139
12535
  case 4:
12140
- _t3 = _context.v;
12141
- _t4 = chain;
12142
- _t5 = destination;
12143
- _t6 = senderAddress;
12144
- _t7 = address;
12145
- _t8 = _objectSpread2(_objectSpread2({}, currency), {}, {
12146
- amount: minAmount
12147
- });
12148
- _t9 = feeAsset;
12536
+ _yield$modifiedBuilde = _context.v;
12537
+ tx = _yield$modifiedBuilde.tx;
12149
12538
  _context.n = 5;
12150
- return _t({
12151
- api: _t2,
12152
- tx: _t3,
12153
- origin: _t4,
12154
- destination: _t5,
12155
- senderAddress: _t6,
12156
- address: _t7,
12157
- currency: _t8,
12158
- feeAsset: _t9
12539
+ return dryRunInternal({
12540
+ api: api,
12541
+ tx: tx,
12542
+ origin: chain,
12543
+ destination: destination,
12544
+ senderAddress: senderAddress,
12545
+ address: address,
12546
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
12547
+ amount: minAmount
12548
+ }),
12549
+ feeAsset: feeAsset
12159
12550
  });
12160
12551
  case 5:
12161
12552
  dryRunResult = _context.v;
@@ -13031,6 +13422,54 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
13031
13422
  }]);
13032
13423
  }();
13033
13424
 
13425
+ var normalizeAmountAll = /*#__PURE__*/function () {
13426
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, buildTx, options) {
13427
+ var currency, isAmountAll, transferable;
13428
+ return _regenerator().w(function (_context) {
13429
+ while (1) switch (_context.n) {
13430
+ case 0:
13431
+ currency = options.currency;
13432
+ isAmountAll = !Array.isArray(currency) && currency.amount === AMOUNT_ALL;
13433
+ if (isAmountAll) {
13434
+ _context.n = 1;
13435
+ break;
13436
+ }
13437
+ return _context.a(2, _objectSpread2({
13438
+ api: api,
13439
+ isAmountAll: isAmountAll
13440
+ }, options));
13441
+ case 1:
13442
+ assertToIsString(options.to);
13443
+ assertSenderAddress(options.senderAddress);
13444
+ _context.n = 2;
13445
+ return getTransferableAmountInternal({
13446
+ api: api,
13447
+ buildTx: buildTx,
13448
+ origin: options.from,
13449
+ destination: options.to,
13450
+ senderAddress: options.senderAddress,
13451
+ feeAsset: options.feeAsset,
13452
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
13453
+ amount: MIN_AMOUNT
13454
+ })
13455
+ });
13456
+ case 2:
13457
+ transferable = _context.v;
13458
+ return _context.a(2, _objectSpread2(_objectSpread2({}, options), {}, {
13459
+ api: api,
13460
+ isAmountAll: isAmountAll,
13461
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
13462
+ amount: transferable
13463
+ })
13464
+ }));
13465
+ }
13466
+ }, _callee);
13467
+ }));
13468
+ return function normalizeAmountAll(_x, _x2, _x3) {
13469
+ return _ref.apply(this, arguments);
13470
+ };
13471
+ }();
13472
+
13034
13473
  var BatchTransactionManager = /*#__PURE__*/function () {
13035
13474
  function BatchTransactionManager() {
13036
13475
  _classCallCheck(this, BatchTransactionManager);
@@ -13049,25 +13488,25 @@ var BatchTransactionManager = /*#__PURE__*/function () {
13049
13488
  }, {
13050
13489
  key: "buildBatch",
13051
13490
  value: function () {
13052
- var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, from) {
13491
+ var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, from) {
13053
13492
  var options,
13054
13493
  mode,
13055
13494
  sameFrom,
13056
- results,
13495
+ normalized,
13057
13496
  txs,
13058
- _args = arguments;
13059
- return _regenerator().w(function (_context) {
13060
- while (1) switch (_context.n) {
13497
+ _args2 = arguments;
13498
+ return _regenerator().w(function (_context2) {
13499
+ while (1) switch (_context2.n) {
13061
13500
  case 0:
13062
- options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {
13501
+ options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {
13063
13502
  mode: exports.BatchMode.BATCH_ALL
13064
13503
  };
13065
- _context.n = 1;
13504
+ _context2.n = 1;
13066
13505
  return api.init(from, TX_CLIENT_TIMEOUT_MS);
13067
13506
  case 1:
13068
13507
  mode = options.mode;
13069
13508
  if (!(this.transactionOptions.length === 0)) {
13070
- _context.n = 2;
13509
+ _context2.n = 2;
13071
13510
  break;
13072
13511
  }
13073
13512
  throw new InvalidParameterError('No transactions to batch.');
@@ -13076,21 +13515,38 @@ var BatchTransactionManager = /*#__PURE__*/function () {
13076
13515
  return tx.from === from;
13077
13516
  });
13078
13517
  if (sameFrom) {
13079
- _context.n = 3;
13518
+ _context2.n = 3;
13080
13519
  break;
13081
13520
  }
13082
13521
  throw new InvalidParameterError('All transactions must have the same origin.');
13083
13522
  case 3:
13084
- results = this.transactionOptions.map(function (options) {
13085
- return send(options);
13086
- });
13087
- _context.n = 4;
13088
- return Promise.all(results);
13523
+ _context2.n = 4;
13524
+ return Promise.all(this.transactionOptions.map(/*#__PURE__*/function () {
13525
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(opts) {
13526
+ var buildTx;
13527
+ return _regenerator().w(function (_context) {
13528
+ while (1) switch (_context.n) {
13529
+ case 0:
13530
+ buildTx = opts.buildTx;
13531
+ return _context.a(2, normalizeAmountAll(api, buildTx, opts));
13532
+ }
13533
+ }, _callee);
13534
+ }));
13535
+ return function (_x3) {
13536
+ return _ref.apply(this, arguments);
13537
+ };
13538
+ }()));
13089
13539
  case 4:
13090
- txs = _context.v;
13091
- return _context.a(2, api.callBatchMethod(txs, mode));
13540
+ normalized = _context2.v;
13541
+ _context2.n = 5;
13542
+ return Promise.all(normalized.map(function (o) {
13543
+ return send(o);
13544
+ }));
13545
+ case 5:
13546
+ txs = _context2.v;
13547
+ return _context2.a(2, api.callBatchMethod(txs, mode));
13092
13548
  }
13093
- }, _callee, this);
13549
+ }, _callee2, this);
13094
13550
  }));
13095
13551
  function buildBatch(_x, _x2) {
13096
13552
  return _buildBatch.apply(this, arguments);
@@ -13283,9 +13739,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
13283
13739
  }, {
13284
13740
  key: "addToBatch",
13285
13741
  value: function addToBatch() {
13286
- this.batchManager.addTransaction(_objectSpread2({
13742
+ var buildTx = this.createTxFactory();
13743
+ this.batchManager.addTransaction(_objectSpread2(_objectSpread2({
13287
13744
  api: this.api
13288
- }, this._options));
13745
+ }, this._options), {}, {
13746
+ buildTx: buildTx
13747
+ }));
13289
13748
  return new GeneralBuilder(this.api, this.batchManager, {
13290
13749
  from: this._options.from
13291
13750
  });
@@ -13326,10 +13785,16 @@ var GeneralBuilder = /*#__PURE__*/function () {
13326
13785
  key: "build",
13327
13786
  value: (function () {
13328
13787
  var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
13788
+ var _yield$this$buildComm, tx;
13329
13789
  return _regenerator().w(function (_context2) {
13330
13790
  while (1) switch (_context2.n) {
13331
13791
  case 0:
13332
- return _context2.a(2, this.buildCommon());
13792
+ _context2.n = 1;
13793
+ return this.buildCommon();
13794
+ case 1:
13795
+ _yield$this$buildComm = _context2.v;
13796
+ tx = _yield$this$buildComm.tx;
13797
+ return _context2.a(2, tx);
13333
13798
  }
13334
13799
  }, _callee2, this);
13335
13800
  }));
@@ -13346,13 +13811,16 @@ var GeneralBuilder = /*#__PURE__*/function () {
13346
13811
  _this$_options,
13347
13812
  from,
13348
13813
  to,
13814
+ builder,
13815
+ createTx,
13816
+ normalizedOptions,
13349
13817
  tx,
13350
13818
  _args3 = arguments;
13351
13819
  return _regenerator().w(function (_context3) {
13352
13820
  while (1) switch (_context3.n) {
13353
13821
  case 0:
13354
13822
  isCalledInternally = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
13355
- if (this.batchManager.isEmpty()) {
13823
+ if (!(!this.batchManager.isEmpty() && !isCalledInternally)) {
13356
13824
  _context3.n = 1;
13357
13825
  break;
13358
13826
  }
@@ -13365,16 +13833,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
13365
13833
  }
13366
13834
  throw new InvalidParameterError('Transfers between relay chains are not yet supported.');
13367
13835
  case 2:
13836
+ builder = this.currency(_objectSpread2(_objectSpread2({}, this._options.currency), {}, {
13837
+ amount: MIN_AMOUNT.toString()
13838
+ }));
13839
+ createTx = builder.createTxFactory();
13368
13840
  _context3.n = 3;
13369
- return send(_objectSpread2({
13370
- api: this.api
13371
- }, this._options));
13841
+ return normalizeAmountAll(this.api, createTx, this._options);
13372
13842
  case 3:
13373
- tx = _context3.v;
13843
+ normalizedOptions = _context3.v;
13374
13844
  _context3.n = 4;
13375
- return this.maybePerformXcmFormatCheck(tx, this._options, isCalledInternally);
13845
+ return send(normalizedOptions);
13376
13846
  case 4:
13377
- return _context3.a(2, tx);
13847
+ tx = _context3.v;
13848
+ _context3.n = 5;
13849
+ return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
13850
+ case 5:
13851
+ return _context3.a(2, {
13852
+ tx: tx,
13853
+ options: normalizedOptions
13854
+ });
13378
13855
  }
13379
13856
  }, _callee3, this);
13380
13857
  }));
@@ -13425,15 +13902,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
13425
13902
  key: "dryRun",
13426
13903
  value: function () {
13427
13904
  var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
13428
- var tx;
13905
+ var _yield$this$buildInte, tx, options;
13429
13906
  return _regenerator().w(function (_context5) {
13430
13907
  while (1) switch (_context5.n) {
13431
13908
  case 0:
13432
13909
  _context5.n = 1;
13433
13910
  return this.buildInternal();
13434
13911
  case 1:
13435
- tx = _context5.v;
13436
- return _context5.a(2, buildDryRun(this.api, tx, this._options));
13912
+ _yield$this$buildInte = _context5.v;
13913
+ tx = _yield$this$buildInte.tx;
13914
+ options = _yield$this$buildInte.options;
13915
+ return _context5.a(2, buildDryRun(this.api, tx, options));
13437
13916
  }
13438
13917
  }, _callee5, this);
13439
13918
  }));
@@ -13445,18 +13924,20 @@ var GeneralBuilder = /*#__PURE__*/function () {
13445
13924
  }, {
13446
13925
  key: "dryRunPreview",
13447
13926
  value: function () {
13448
- var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
13449
- var tx;
13927
+ var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(dryRunOptions) {
13928
+ var _yield$this$buildInte2, tx, options;
13450
13929
  return _regenerator().w(function (_context6) {
13451
13930
  while (1) switch (_context6.n) {
13452
13931
  case 0:
13453
13932
  _context6.n = 1;
13454
13933
  return this.buildInternal();
13455
13934
  case 1:
13456
- tx = _context6.v;
13457
- return _context6.a(2, buildDryRun(this.api, tx, this._options, {
13935
+ _yield$this$buildInte2 = _context6.v;
13936
+ tx = _yield$this$buildInte2.tx;
13937
+ options = _yield$this$buildInte2.options;
13938
+ return _context6.a(2, buildDryRun(this.api, tx, options, {
13458
13939
  sentAssetMintMode: 'preview',
13459
- mintFeeAssets: options === null || options === void 0 ? void 0 : options.mintFeeAssets
13940
+ mintFeeAssets: dryRunOptions === null || dryRunOptions === void 0 ? void 0 : dryRunOptions.mintFeeAssets
13460
13941
  }));
13461
13942
  }
13462
13943
  }, _callee6, this);
@@ -13594,7 +14075,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13594
14075
  key: "getXcmFeeEstimate",
13595
14076
  value: (function () {
13596
14077
  var _getXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
13597
- var _this$_options4, from, to, address, senderAddress, currency, tx;
14078
+ var _this$_options4, from, to, address, senderAddress, currency, _yield$this$buildInte3, tx;
13598
14079
  return _regenerator().w(function (_context9) {
13599
14080
  while (1) switch (_context9.p = _context9.n) {
13600
14081
  case 0:
@@ -13604,7 +14085,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
13604
14085
  _context9.n = 1;
13605
14086
  return this.buildInternal();
13606
14087
  case 1:
13607
- tx = _context9.v;
14088
+ _yield$this$buildInte3 = _context9.v;
14089
+ tx = _yield$this$buildInte3.tx;
13608
14090
  _context9.p = 2;
13609
14091
  _context9.n = 3;
13610
14092
  return getXcmFeeEstimate({
@@ -13644,7 +14126,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13644
14126
  key: "getOriginXcmFeeEstimate",
13645
14127
  value: (function () {
13646
14128
  var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
13647
- var _this$_options5, from, to, senderAddress, currency, tx;
14129
+ var _this$_options5, from, to, senderAddress, currency, _yield$this$buildInte4, tx;
13648
14130
  return _regenerator().w(function (_context0) {
13649
14131
  while (1) switch (_context0.p = _context0.n) {
13650
14132
  case 0:
@@ -13653,7 +14135,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
13653
14135
  _context0.n = 1;
13654
14136
  return this.buildInternal();
13655
14137
  case 1:
13656
- tx = _context0.v;
14138
+ _yield$this$buildInte4 = _context0.v;
14139
+ tx = _yield$this$buildInte4.tx;
13657
14140
  _context0.p = 2;
13658
14141
  _context0.n = 3;
13659
14142
  return getOriginXcmFeeEstimate({