@paraspell/sdk-core 11.8.6 → 11.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, hasXcmPaymentApiSupport, getRelayChainSymbol, getExistentialDeposit, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, hasXcmPaymentApiSupport, getExistentialDeposit, getRelayChainSymbol, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, parseUnits, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
@@ -861,35 +861,54 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
861
861
  return parseUnits(increaseAmount, asset.decimals) + BigInt(amount);
862
862
  }
863
863
  };
864
- var overrideTxAmount = function overrideTxAmount(options, builder, amount) {
865
- var modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
866
- amount: computeOverridenAmount(options, amount)
867
- }));
868
- return modifiedBuilder['buildInternal']();
869
- };
870
- var createTx = /*#__PURE__*/function () {
864
+ var overrideTxAmount = /*#__PURE__*/function () {
871
865
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount) {
866
+ var modifiedBuilder, _yield$modifiedBuilde, tx;
872
867
  return _regenerator().w(function (_context) {
873
868
  while (1) switch (_context.n) {
869
+ case 0:
870
+ modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
871
+ amount: computeOverridenAmount(options, amount)
872
+ }));
873
+ _context.n = 1;
874
+ return modifiedBuilder['buildInternal']();
875
+ case 1:
876
+ _yield$modifiedBuilde = _context.v;
877
+ tx = _yield$modifiedBuilde.tx;
878
+ return _context.a(2, tx);
879
+ }
880
+ }, _callee);
881
+ }));
882
+ return function overrideTxAmount(_x, _x2, _x3) {
883
+ return _ref.apply(this, arguments);
884
+ };
885
+ }();
886
+ var createTx = /*#__PURE__*/function () {
887
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, builder, amount) {
888
+ var _yield$builder$buildI, tx;
889
+ return _regenerator().w(function (_context2) {
890
+ while (1) switch (_context2.n) {
874
891
  case 0:
875
892
  if (!(amount === undefined)) {
876
- _context.n = 2;
893
+ _context2.n = 2;
877
894
  break;
878
895
  }
879
- _context.n = 1;
896
+ _context2.n = 1;
880
897
  return builder['buildInternal']();
881
898
  case 1:
882
- return _context.a(2, _context.v);
899
+ _yield$builder$buildI = _context2.v;
900
+ tx = _yield$builder$buildI.tx;
901
+ return _context2.a(2, tx);
883
902
  case 2:
884
- _context.n = 3;
903
+ _context2.n = 3;
885
904
  return overrideTxAmount(options, builder, amount);
886
905
  case 3:
887
- return _context.a(2, _context.v);
906
+ return _context2.a(2, _context2.v);
888
907
  }
889
- }, _callee);
908
+ }, _callee2);
890
909
  }));
891
- return function createTx(_x, _x2, _x3) {
892
- return _ref.apply(this, arguments);
910
+ return function createTx(_x4, _x5, _x6) {
911
+ return _ref2.apply(this, arguments);
893
912
  };
894
913
  }();
895
914
 
@@ -3754,7 +3773,7 @@ var determineAddress = function determineAddress(chain, address, senderAddress)
3754
3773
  };
3755
3774
  var getReverseTxFee = /*#__PURE__*/function () {
3756
3775
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
3757
- var api, origin, destination, senderAddress, address, toAddress, fromAddress, tx, rawFee;
3776
+ var api, origin, destination, senderAddress, address, toAddress, fromAddress, _yield$Builder$from$t, tx, rawFee;
3758
3777
  return _regenerator().w(function (_context) {
3759
3778
  while (1) switch (_context.n) {
3760
3779
  case 0:
@@ -3764,7 +3783,8 @@ var getReverseTxFee = /*#__PURE__*/function () {
3764
3783
  _context.n = 1;
3765
3784
  return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
3766
3785
  case 1:
3767
- tx = _context.v;
3786
+ _yield$Builder$from$t = _context.v;
3787
+ tx = _yield$Builder$from$t.tx;
3768
3788
  _context.n = 2;
3769
3789
  return api.calculateTransactionFee(tx, fromAddress);
3770
3790
  case 2:
@@ -3985,7 +4005,7 @@ var getBalanceForeignInternal = /*#__PURE__*/function () {
3985
4005
  }
3986
4006
  return _context.a(2, getBalanceForeignXTokens(api, chain, address, asset));
3987
4007
  case 3:
3988
- if (!(defaultPallet === 'PolkadotXcm')) {
4008
+ if (!(defaultPallet === 'PolkadotXcm' || defaultPallet === 'XTransfer')) {
3989
4009
  _context.n = 4;
3990
4010
  break;
3991
4011
  }
@@ -4430,7 +4450,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4430
4450
  asset: asset,
4431
4451
  originFee: originFee,
4432
4452
  feeAsset: resolvedFeeAsset,
4433
- amount: currency.amount < 2n ? 2n : currency.amount
4453
+ amount: currency.amount < MIN_AMOUNT ? MIN_AMOUNT : currency.amount
4434
4454
  });
4435
4455
  case 4:
4436
4456
  dryRunResult = _context3.v;
@@ -6039,6 +6059,128 @@ var transferXTokens = function transferXTokens(input, currencySelection) {
6039
6059
  return api.callTxMethod(call);
6040
6060
  };
6041
6061
 
6062
+ var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
6063
+ _classCallCheck(this, BaseAssetsPallet);
6064
+ this.palletName = palletName;
6065
+ });
6066
+
6067
+ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
6068
+ function AssetsPallet() {
6069
+ _classCallCheck(this, AssetsPallet);
6070
+ return _callSuper(this, AssetsPallet, arguments);
6071
+ }
6072
+ _inherits(AssetsPallet, _BaseAssetsPallet);
6073
+ return _createClass(AssetsPallet, [{
6074
+ key: "mint",
6075
+ value: function mint(address, asset, _balance, chain) {
6076
+ assertHasId(asset);
6077
+ var assetId = asset.assetId,
6078
+ amount = asset.amount;
6079
+ var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
6080
+ var addr = isChainEvm(chain) ? address : {
6081
+ Id: address
6082
+ };
6083
+ return Promise.resolve({
6084
+ assetStatusTx: {
6085
+ module: this.palletName,
6086
+ method: 'force_asset_status',
6087
+ parameters: {
6088
+ id: id,
6089
+ owner: addr,
6090
+ issuer: addr,
6091
+ admin: addr,
6092
+ freezer: addr,
6093
+ min_balance: 0n,
6094
+ is_sufficient: true,
6095
+ is_frozen: false
6096
+ }
6097
+ },
6098
+ balanceTx: {
6099
+ module: this.palletName,
6100
+ method: 'mint',
6101
+ parameters: {
6102
+ id: id,
6103
+ beneficiary: addr,
6104
+ amount: amount
6105
+ }
6106
+ }
6107
+ });
6108
+ }
6109
+ }]);
6110
+ }(BaseAssetsPallet);
6111
+
6112
+ var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
6113
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
6114
+ var _getExistentialDeposi;
6115
+ var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, _yield$Builder$from$t, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
6116
+ return _regenerator().w(function (_context) {
6117
+ while (1) switch (_context.n) {
6118
+ case 0:
6119
+ 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;
6120
+ _context.n = 1;
6121
+ return api.init(origin);
6122
+ case 1:
6123
+ _context.n = 2;
6124
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
6125
+ case 2:
6126
+ _yield$Builder$from$t = _context.v;
6127
+ tx = _yield$Builder$from$t.tx;
6128
+ _context.n = 3;
6129
+ return api.calculateTransactionFee(tx, account);
6130
+ case 3:
6131
+ xcmFee = _context.v;
6132
+ xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
6133
+ _context.n = 4;
6134
+ return getBalanceNativeInternal({
6135
+ address: account,
6136
+ chain: origin,
6137
+ api: api
6138
+ });
6139
+ case 4:
6140
+ nativeBalance = _context.v;
6141
+ existentialDeposit = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
6142
+ sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
6143
+ return _context.a(2, {
6144
+ sufficientForXCM: sufficientForXCM,
6145
+ xcmFee: xcmFee
6146
+ });
6147
+ }
6148
+ }, _callee);
6149
+ }));
6150
+ return function getOriginFeeDetailsInternal(_x) {
6151
+ return _ref2.apply(this, arguments);
6152
+ };
6153
+ }();
6154
+ var getOriginFeeDetails = /*#__PURE__*/function () {
6155
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6156
+ var api;
6157
+ return _regenerator().w(function (_context2) {
6158
+ while (1) switch (_context2.p = _context2.n) {
6159
+ case 0:
6160
+ api = options.api;
6161
+ api.setDisconnectAllowed(false);
6162
+ _context2.p = 1;
6163
+ _context2.n = 2;
6164
+ return getOriginFeeDetailsInternal(options);
6165
+ case 2:
6166
+ return _context2.a(2, _context2.v);
6167
+ case 3:
6168
+ _context2.p = 3;
6169
+ api.setDisconnectAllowed(true);
6170
+ _context2.n = 4;
6171
+ return api.disconnect();
6172
+ case 4:
6173
+ return _context2.f(3);
6174
+ case 5:
6175
+ return _context2.a(2);
6176
+ }
6177
+ }, _callee2, null, [[1,, 3, 5]]);
6178
+ }));
6179
+ return function getOriginFeeDetails(_x2) {
6180
+ return _ref3.apply(this, arguments);
6181
+ };
6182
+ }();
6183
+
6042
6184
  var supportsXTokens = function supportsXTokens(obj) {
6043
6185
  return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
6044
6186
  };
@@ -6405,54 +6547,120 @@ var Parachain = /*#__PURE__*/function () {
6405
6547
  }
6406
6548
  }, {
6407
6549
  key: "transferLocal",
6408
- value: function transferLocal(options) {
6409
- var asset = options.assetInfo,
6410
- address = options.address;
6411
- if (isTLocation(address)) {
6412
- throw new InvalidAddressError('Location address is not supported for local transfers');
6413
- }
6414
- var validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
6415
- address: address
6416
- });
6417
- var isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !isForeignAsset(asset);
6418
- if (isNativeAsset) {
6419
- return this.transferLocalNativeAsset(validatedOptions);
6420
- } else {
6421
- return this.transferLocalNonNativeAsset(validatedOptions);
6550
+ value: function () {
6551
+ var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
6552
+ var api, asset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
6553
+ return _regenerator().w(function (_context3) {
6554
+ while (1) switch (_context3.n) {
6555
+ case 0:
6556
+ api = options.api, asset = options.assetInfo, address = options.address, senderAddress = options.senderAddress, currency = options.currency, isAmountAll = options.isAmountAll;
6557
+ if (!isTLocation(address)) {
6558
+ _context3.n = 1;
6559
+ break;
6560
+ }
6561
+ throw new InvalidAddressError('Location address is not supported for local transfers');
6562
+ case 1:
6563
+ validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
6564
+ address: address
6565
+ });
6566
+ isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !isForeignAsset(asset);
6567
+ if (!isAmountAll) {
6568
+ _context3.n = 3;
6569
+ break;
6570
+ }
6571
+ assertSenderAddress(senderAddress);
6572
+ _context3.n = 2;
6573
+ return getAssetBalanceInternal({
6574
+ api: api,
6575
+ chain: this.chain,
6576
+ address: senderAddress,
6577
+ currency: currency
6578
+ });
6579
+ case 2:
6580
+ balance = _context3.v;
6581
+ _context3.n = 4;
6582
+ break;
6583
+ case 3:
6584
+ balance = MIN_AMOUNT;
6585
+ case 4:
6586
+ localOptions = _objectSpread2(_objectSpread2({}, validatedOptions), {}, {
6587
+ balance: balance
6588
+ });
6589
+ if (!isNativeAsset) {
6590
+ _context3.n = 5;
6591
+ break;
6592
+ }
6593
+ return _context3.a(2, this.transferLocalNativeAsset(localOptions));
6594
+ case 5:
6595
+ return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
6596
+ case 6:
6597
+ return _context3.a(2);
6598
+ }
6599
+ }, _callee3, this);
6600
+ }));
6601
+ function transferLocal(_x3) {
6602
+ return _transferLocal.apply(this, arguments);
6422
6603
  }
6423
- }
6604
+ return transferLocal;
6605
+ }()
6424
6606
  }, {
6425
6607
  key: "transferLocalNativeAsset",
6426
6608
  value: function transferLocalNativeAsset(options) {
6427
6609
  var api = options.api,
6428
6610
  asset = options.assetInfo,
6429
- address = options.address;
6430
- return api.callTxMethod({
6611
+ address = options.address,
6612
+ isAmountAll = options.isAmountAll;
6613
+ var dest = isChainEvm(this.chain) ? address : {
6614
+ Id: address
6615
+ };
6616
+ if (isAmountAll) {
6617
+ return Promise.resolve(api.callTxMethod({
6618
+ module: 'Balances',
6619
+ method: 'transfer_all',
6620
+ parameters: {
6621
+ dest: dest,
6622
+ keep_alive: false
6623
+ }
6624
+ }));
6625
+ }
6626
+ return Promise.resolve(api.callTxMethod({
6431
6627
  module: 'Balances',
6432
6628
  method: 'transfer_keep_alive',
6433
6629
  parameters: {
6434
- dest: isChainEvm(this.chain) ? address : {
6435
- Id: address
6436
- },
6630
+ dest: dest,
6437
6631
  value: asset.amount
6438
6632
  }
6439
- });
6633
+ }));
6440
6634
  }
6441
6635
  }, {
6442
6636
  key: "transferLocalNonNativeAsset",
6443
6637
  value: function transferLocalNonNativeAsset(options) {
6444
6638
  var api = options.api,
6445
6639
  asset = options.assetInfo,
6446
- address = options.address;
6640
+ address = options.address,
6641
+ isAmountAll = options.isAmountAll;
6447
6642
  assertHasId(asset);
6643
+ var dest = {
6644
+ Id: address
6645
+ };
6646
+ var currencyId = BigInt(asset.assetId);
6647
+ if (isAmountAll) {
6648
+ return api.callTxMethod({
6649
+ module: 'Tokens',
6650
+ method: 'transfer_all',
6651
+ parameters: {
6652
+ dest: dest,
6653
+ currency_id: currencyId,
6654
+ keep_alive: false
6655
+ }
6656
+ });
6657
+ }
6448
6658
  return api.callTxMethod({
6449
6659
  module: 'Tokens',
6450
6660
  method: 'transfer',
6451
6661
  parameters: {
6452
- dest: {
6453
- Id: address
6454
- },
6455
- currency_id: BigInt(asset.assetId),
6662
+ dest: dest,
6663
+ currency_id: currencyId,
6456
6664
  amount: asset.amount
6457
6665
  }
6458
6666
  });
@@ -6460,7 +6668,7 @@ var Parachain = /*#__PURE__*/function () {
6460
6668
  }, {
6461
6669
  key: "transferToEthereum",
6462
6670
  value: function () {
6463
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
6671
+ var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
6464
6672
  var _feeAsset$location;
6465
6673
  var useOnlyDepositInstruction,
6466
6674
  api,
@@ -6483,18 +6691,18 @@ var Parachain = /*#__PURE__*/function () {
6483
6691
  customXcmOnDest,
6484
6692
  messageId,
6485
6693
  call,
6486
- _args3 = arguments;
6487
- return _regenerator().w(function (_context3) {
6488
- while (1) switch (_context3.n) {
6694
+ _args4 = arguments;
6695
+ return _regenerator().w(function (_context4) {
6696
+ while (1) switch (_context4.n) {
6489
6697
  case 0:
6490
- useOnlyDepositInstruction = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
6698
+ useOnlyDepositInstruction = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;
6491
6699
  api = input.api, asset = input.assetInfo, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAssetInfo;
6492
- _context3.n = 1;
6700
+ _context4.n = 1;
6493
6701
  return getBridgeStatus(api.clone());
6494
6702
  case 1:
6495
- bridgeStatus = _context3.v;
6703
+ bridgeStatus = _context4.v;
6496
6704
  if (!(bridgeStatus !== 'Normal')) {
6497
- _context3.n = 2;
6705
+ _context4.n = 2;
6498
6706
  break;
6499
6707
  }
6500
6708
  throw new BridgeHaltedError();
@@ -6503,14 +6711,14 @@ var Parachain = /*#__PURE__*/function () {
6503
6711
  assertAddressIsString(address);
6504
6712
  assertSenderAddress(senderAddress);
6505
6713
  ethAsset = createAsset(version, asset.amount, asset.location);
6506
- _context3.n = 3;
6714
+ _context4.n = 3;
6507
6715
  return api.createApiForChain('AssetHubPolkadot');
6508
6716
  case 3:
6509
- ahApi = _context3.v;
6510
- _context3.n = 4;
6717
+ ahApi = _context4.v;
6718
+ _context4.n = 4;
6511
6719
  return getParaEthTransferFees(ahApi);
6512
6720
  case 4:
6513
- _yield$getParaEthTran = _context3.v;
6721
+ _yield$getParaEthTran = _context4.v;
6514
6722
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
6515
6723
  bridgeFee = _yield$getParaEthTran2[0];
6516
6724
  executionFee = _yield$getParaEthTran2[1];
@@ -6518,13 +6726,13 @@ var Parachain = /*#__PURE__*/function () {
6518
6726
  fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : bridgeFee + executionFee;
6519
6727
  ethAssetInfo = findAssetInfoByLoc(getOtherAssets('Ethereum'), asset.location);
6520
6728
  if (ethAssetInfo) {
6521
- _context3.n = 5;
6729
+ _context4.n = 5;
6522
6730
  break;
6523
6731
  }
6524
6732
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset, replaceBigInt)));
6525
6733
  case 5:
6526
6734
  if (!useOnlyDepositInstruction) {
6527
- _context3.n = 6;
6735
+ _context4.n = 6;
6528
6736
  break;
6529
6737
  }
6530
6738
  customXcmOnDest = addXcmVersionHeader([{
@@ -6541,14 +6749,14 @@ var Parachain = /*#__PURE__*/function () {
6541
6749
  })
6542
6750
  }
6543
6751
  }], version);
6544
- _context3.n = 8;
6752
+ _context4.n = 8;
6545
6753
  break;
6546
6754
  case 6:
6547
6755
  assertHasId(ethAssetInfo);
6548
- _context3.n = 7;
6756
+ _context4.n = 7;
6549
6757
  return generateMessageId(api, senderAddress, getParaId(this.chain), ethAssetInfo.assetId, address, asset.amount);
6550
6758
  case 7:
6551
- messageId = _context3.v;
6759
+ messageId = _context4.v;
6552
6760
  customXcmOnDest = createCustomXcmOnDest(input, this.chain, messageId);
6553
6761
  case 8:
6554
6762
  call = {
@@ -6564,11 +6772,11 @@ var Parachain = /*#__PURE__*/function () {
6564
6772
  weight_limit: 'Unlimited'
6565
6773
  }
6566
6774
  };
6567
- return _context3.a(2, api.callTxMethod(call));
6775
+ return _context4.a(2, api.callTxMethod(call));
6568
6776
  }
6569
- }, _callee3, this);
6777
+ }, _callee4, this);
6570
6778
  }));
6571
- function transferToEthereum(_x3) {
6779
+ function transferToEthereum(_x4) {
6572
6780
  return _transferToEthereum.apply(this, arguments);
6573
6781
  }
6574
6782
  return transferToEthereum;
@@ -6578,8 +6786,12 @@ var Parachain = /*#__PURE__*/function () {
6578
6786
 
6579
6787
  var Acala = /*#__PURE__*/function (_Parachain) {
6580
6788
  function Acala() {
6789
+ var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Acala';
6790
+ var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'acala';
6791
+ var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
6792
+ var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.V4;
6581
6793
  _classCallCheck(this, Acala);
6582
- return _callSuper(this, Acala, ['Acala', 'acala', 'Polkadot', Version.V4]);
6794
+ return _callSuper(this, Acala, [chain, info, ecosystem, version]);
6583
6795
  }
6584
6796
  _inherits(Acala, _Parachain);
6585
6797
  return _createClass(Acala, [{
@@ -6601,39 +6813,70 @@ var Acala = /*#__PURE__*/function (_Parachain) {
6601
6813
  }
6602
6814
  }, {
6603
6815
  key: "transferLocalNativeAsset",
6604
- value: function transferLocalNativeAsset(options) {
6816
+ value: function () {
6817
+ var _transferLocalNativeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
6818
+ var api, asset, address, balance, senderAddress, isAmountAll, createTx, amount, fee;
6819
+ return _regenerator().w(function (_context) {
6820
+ while (1) switch (_context.n) {
6821
+ case 0:
6822
+ api = options.api, asset = options.assetInfo, address = options.address, balance = options.balance, senderAddress = options.senderAddress, isAmountAll = options.isAmountAll;
6823
+ createTx = function createTx(amount) {
6824
+ return api.callTxMethod({
6825
+ module: 'Currencies',
6826
+ method: 'transfer_native_currency',
6827
+ parameters: {
6828
+ dest: {
6829
+ Id: address
6830
+ },
6831
+ amount: amount
6832
+ }
6833
+ });
6834
+ };
6835
+ if (!isAmountAll) {
6836
+ _context.n = 2;
6837
+ break;
6838
+ }
6839
+ assertSenderAddress(senderAddress);
6840
+ _context.n = 1;
6841
+ return api.calculateTransactionFee(createTx(MIN_AMOUNT), senderAddress);
6842
+ case 1:
6843
+ fee = _context.v;
6844
+ amount = balance - fee;
6845
+ _context.n = 3;
6846
+ break;
6847
+ case 2:
6848
+ amount = asset.amount;
6849
+ case 3:
6850
+ return _context.a(2, createTx(amount));
6851
+ }
6852
+ }, _callee);
6853
+ }));
6854
+ function transferLocalNativeAsset(_x) {
6855
+ return _transferLocalNativeAsset.apply(this, arguments);
6856
+ }
6857
+ return transferLocalNativeAsset;
6858
+ }()
6859
+ }, {
6860
+ key: "transferLocalNonNativeAsset",
6861
+ value: function transferLocalNonNativeAsset(options) {
6605
6862
  var api = options.api,
6606
6863
  asset = options.assetInfo,
6607
- address = options.address;
6864
+ address = options.address,
6865
+ balance = options.balance,
6866
+ isAmountAll = options.isAmountAll;
6867
+ if (asset.symbol.toLowerCase() === 'lcdot') {
6868
+ throw new InvalidCurrencyError('LcDOT local transfers are not supported');
6869
+ }
6870
+ var amount = isAmountAll ? balance : asset.amount;
6608
6871
  return api.callTxMethod({
6609
6872
  module: 'Currencies',
6610
- method: 'transfer_native_currency',
6873
+ method: 'transfer',
6611
6874
  parameters: {
6612
6875
  dest: {
6613
6876
  Id: address
6614
6877
  },
6615
- amount: asset.amount
6616
- }
6617
- });
6618
- }
6619
- }, {
6620
- key: "transferLocalNonNativeAsset",
6621
- value: function transferLocalNonNativeAsset(options) {
6622
- var api = options.api,
6623
- asset = options.assetInfo,
6624
- address = options.address;
6625
- if (asset.symbol.toLowerCase() === 'lcdot') {
6626
- throw new InvalidCurrencyError('LcDOT local transfers are not supported');
6627
- }
6628
- return api.callTxMethod({
6629
- module: 'Currencies',
6630
- method: 'transfer',
6631
- parameters: {
6632
- dest: {
6633
- Id: address
6634
- },
6635
- currency_id: this.getCurrencySelection(asset),
6636
- amount: asset.amount
6878
+ currency_id: this.getCurrencySelection(asset),
6879
+ amount: amount
6637
6880
  }
6638
6881
  });
6639
6882
  }
@@ -6673,16 +6916,30 @@ var Ajuna = /*#__PURE__*/function (_Parachain) {
6673
6916
  value: function transferLocalNonNativeAsset(options) {
6674
6917
  var api = options.api,
6675
6918
  asset = options.assetInfo,
6676
- address = options.address;
6919
+ address = options.address,
6920
+ isAmountAll = options.isAmountAll;
6677
6921
  assertHasId(asset);
6922
+ var assetId = Number(asset.assetId);
6923
+ var dest = {
6924
+ Id: address
6925
+ };
6926
+ if (isAmountAll) {
6927
+ return api.callTxMethod({
6928
+ module: 'Assets',
6929
+ method: 'transfer_all',
6930
+ parameters: {
6931
+ id: assetId,
6932
+ dest: dest,
6933
+ keep_alive: false
6934
+ }
6935
+ });
6936
+ }
6678
6937
  return api.callTxMethod({
6679
6938
  module: 'Assets',
6680
6939
  method: 'transfer',
6681
6940
  parameters: {
6682
- id: Number(asset.assetId),
6683
- target: {
6684
- Id: address
6685
- },
6941
+ id: assetId,
6942
+ target: dest,
6686
6943
  amount: asset.amount
6687
6944
  }
6688
6945
  });
@@ -6774,16 +7031,29 @@ var Altair = /*#__PURE__*/function (_Parachain) {
6774
7031
  value: function transferLocalNonNativeAsset(options) {
6775
7032
  var api = options.api,
6776
7033
  asset = options.assetInfo,
6777
- address = options.address;
6778
- assertHasId(asset);
7034
+ address = options.address,
7035
+ isAmountAll = options.isAmountAll;
7036
+ var dest = {
7037
+ Id: address
7038
+ };
7039
+ var currencyId = this.getCurrencySelection(asset);
7040
+ if (isAmountAll) {
7041
+ return api.callTxMethod({
7042
+ module: 'Tokens',
7043
+ method: 'transfer_all',
7044
+ parameters: {
7045
+ dest: dest,
7046
+ currency_id: currencyId,
7047
+ keep_alive: false
7048
+ }
7049
+ });
7050
+ }
6779
7051
  return api.callTxMethod({
6780
7052
  module: 'Tokens',
6781
7053
  method: 'transfer',
6782
7054
  parameters: {
6783
- dest: {
6784
- Id: address
6785
- },
6786
- currency_id: this.getCurrencySelection(asset),
7055
+ dest: dest,
7056
+ currency_id: currencyId,
6787
7057
  amount: asset.amount
6788
7058
  }
6789
7059
  });
@@ -7194,18 +7464,45 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7194
7464
  value: function transferLocalNonNativeAsset(options) {
7195
7465
  var api = options.api,
7196
7466
  asset = options.assetInfo,
7197
- address = options.address;
7467
+ address = options.address,
7468
+ isAmountAll = options.isAmountAll;
7198
7469
  assertIsForeign(asset);
7199
7470
  if (asset.assetId !== undefined) {
7471
+ var assetId = Number(asset.assetId);
7472
+ var dest = {
7473
+ Id: address
7474
+ };
7475
+ if (isAmountAll) {
7476
+ return api.callTxMethod({
7477
+ module: 'Assets',
7478
+ method: 'transfer_all',
7479
+ parameters: {
7480
+ id: assetId,
7481
+ dest: dest,
7482
+ keep_alive: false
7483
+ }
7484
+ });
7485
+ }
7200
7486
  return api.callTxMethod({
7201
7487
  module: 'Assets',
7202
7488
  method: 'transfer',
7203
7489
  parameters: {
7204
- id: Number(asset.assetId),
7205
- target: {
7490
+ id: assetId,
7491
+ target: dest,
7492
+ amount: asset.amount
7493
+ }
7494
+ });
7495
+ }
7496
+ if (isAmountAll) {
7497
+ return api.callTxMethod({
7498
+ module: 'ForeignAssets',
7499
+ method: 'transfer_all',
7500
+ parameters: {
7501
+ id: asset.location,
7502
+ dest: {
7206
7503
  Id: address
7207
7504
  },
7208
- amount: asset.amount
7505
+ keep_alive: false
7209
7506
  }
7210
7507
  });
7211
7508
  }
@@ -7273,16 +7570,30 @@ var Astar = /*#__PURE__*/function (_Parachain) {
7273
7570
  value: function transferLocalNonNativeAsset(options) {
7274
7571
  var api = options.api,
7275
7572
  asset = options.assetInfo,
7276
- address = options.address;
7573
+ address = options.address,
7574
+ isAmountAll = options.isAmountAll;
7277
7575
  assertHasId(asset);
7576
+ var assetId = Number(asset.assetId);
7577
+ var dest = {
7578
+ Id: address
7579
+ };
7580
+ if (isAmountAll) {
7581
+ return api.callTxMethod({
7582
+ module: 'Assets',
7583
+ method: 'transfer_all',
7584
+ parameters: {
7585
+ id: assetId,
7586
+ dest: dest,
7587
+ keep_alive: false
7588
+ }
7589
+ });
7590
+ }
7278
7591
  return api.callTxMethod({
7279
7592
  module: 'Assets',
7280
7593
  method: 'transfer',
7281
7594
  parameters: {
7282
- id: Number(asset.assetId),
7283
- target: {
7284
- Id: address
7285
- },
7595
+ id: assetId,
7596
+ target: dest,
7286
7597
  amount: asset.amount
7287
7598
  }
7288
7599
  });
@@ -7438,15 +7749,29 @@ var BifrostPolkadot = /*#__PURE__*/function (_Parachain) {
7438
7749
  value: function transferLocalNonNativeAsset(options) {
7439
7750
  var api = options.api,
7440
7751
  asset = options.assetInfo,
7441
- address = options.address;
7752
+ address = options.address,
7753
+ isAmountAll = options.isAmountAll;
7754
+ var dest = {
7755
+ Id: address
7756
+ };
7757
+ var currencyId = this.getCurrencySelection(asset);
7758
+ if (isAmountAll) {
7759
+ return api.callTxMethod({
7760
+ module: 'Tokens',
7761
+ method: 'transfer_all',
7762
+ parameters: {
7763
+ dest: dest,
7764
+ currency_id: currencyId,
7765
+ keep_alive: false
7766
+ }
7767
+ });
7768
+ }
7442
7769
  return api.callTxMethod({
7443
7770
  module: 'Tokens',
7444
7771
  method: 'transfer',
7445
7772
  parameters: {
7446
- dest: {
7447
- Id: address
7448
- },
7449
- currency_id: this.getCurrencySelection(asset),
7773
+ dest: dest,
7774
+ currency_id: currencyId,
7450
7775
  amount: asset.amount
7451
7776
  }
7452
7777
  });
@@ -7566,16 +7891,29 @@ var Centrifuge = /*#__PURE__*/function (_Parachain) {
7566
7891
  value: function transferLocalNonNativeAsset(options) {
7567
7892
  var api = options.api,
7568
7893
  asset = options.assetInfo,
7569
- address = options.address;
7570
- assertHasId(asset);
7894
+ address = options.address,
7895
+ isAmountAll = options.isAmountAll;
7896
+ var dest = {
7897
+ Id: address
7898
+ };
7899
+ var currencyId = this.getCurrencySelection(asset);
7900
+ if (isAmountAll) {
7901
+ return api.callTxMethod({
7902
+ module: 'Tokens',
7903
+ method: 'transfer_all',
7904
+ parameters: {
7905
+ dest: dest,
7906
+ currency_id: currencyId,
7907
+ keep_alive: false
7908
+ }
7909
+ });
7910
+ }
7571
7911
  return api.callTxMethod({
7572
7912
  module: 'Tokens',
7573
7913
  method: 'transfer',
7574
7914
  parameters: {
7575
- dest: {
7576
- Id: address
7577
- },
7578
- currency_id: this.getCurrencySelection(asset),
7915
+ dest: dest,
7916
+ currency_id: currencyId,
7579
7917
  amount: asset.amount
7580
7918
  }
7581
7919
  });
@@ -7800,16 +8138,30 @@ var Crust = /*#__PURE__*/function (_Parachain) {
7800
8138
  value: function transferLocalNonNativeAsset(options) {
7801
8139
  var api = options.api,
7802
8140
  asset = options.assetInfo,
7803
- address = options.address;
8141
+ address = options.address,
8142
+ isAmountAll = options.isAmountAll;
7804
8143
  assertHasId(asset);
8144
+ var assetId = BigInt(asset.assetId);
8145
+ var dest = {
8146
+ Id: address
8147
+ };
8148
+ if (isAmountAll) {
8149
+ return api.callTxMethod({
8150
+ module: 'Assets',
8151
+ method: 'transfer_all',
8152
+ parameters: {
8153
+ id: assetId,
8154
+ dest: dest,
8155
+ keep_alive: false
8156
+ }
8157
+ });
8158
+ }
7805
8159
  return api.callTxMethod({
7806
8160
  module: 'Assets',
7807
8161
  method: 'transfer',
7808
8162
  parameters: {
7809
- id: BigInt(asset.assetId),
7810
- target: {
7811
- Id: address
7812
- },
8163
+ id: assetId,
8164
+ target: dest,
7813
8165
  amount: asset.amount
7814
8166
  }
7815
8167
  });
@@ -7916,13 +8268,26 @@ var Darwinia = /*#__PURE__*/function (_Parachain) {
7916
8268
  value: function transferLocalNonNativeAsset(options) {
7917
8269
  var api = options.api,
7918
8270
  asset = options.assetInfo,
7919
- address = options.address;
8271
+ address = options.address,
8272
+ isAmountAll = options.isAmountAll;
7920
8273
  assertHasId(asset);
8274
+ var assetId = BigInt(asset.assetId);
8275
+ if (isAmountAll) {
8276
+ return api.callTxMethod({
8277
+ module: 'Assets',
8278
+ method: 'transfer_all',
8279
+ parameters: {
8280
+ id: assetId,
8281
+ dest: address,
8282
+ keep_alive: false
8283
+ }
8284
+ });
8285
+ }
7921
8286
  return api.callTxMethod({
7922
8287
  module: 'Assets',
7923
8288
  method: 'transfer',
7924
8289
  parameters: {
7925
- id: BigInt(asset.assetId),
8290
+ id: assetId,
7926
8291
  target: address,
7927
8292
  amount: asset.amount
7928
8293
  }
@@ -8190,9 +8555,23 @@ var Polimec = /*#__PURE__*/function (_Parachain) {
8190
8555
  value: function transferLocalNonNativeAsset(options) {
8191
8556
  var api = options.api,
8192
8557
  asset = options.assetInfo,
8193
- address = options.address;
8558
+ address = options.address,
8559
+ isAmountAll = options.isAmountAll;
8194
8560
  assertIsForeign(asset);
8195
8561
  assertHasLocation(asset);
8562
+ if (isAmountAll) {
8563
+ return api.callTxMethod({
8564
+ module: 'ForeignAssets',
8565
+ method: 'transfer_all',
8566
+ parameters: {
8567
+ id: asset.location,
8568
+ target: {
8569
+ Id: address
8570
+ },
8571
+ keep_alive: false
8572
+ }
8573
+ });
8574
+ }
8196
8575
  return api.callTxMethod({
8197
8576
  module: 'ForeignAssets',
8198
8577
  method: 'transfer',
@@ -8376,29 +8755,53 @@ var Hydration = /*#__PURE__*/function (_Parachain) {
8376
8755
  value: function transferLocalNativeAsset(options) {
8377
8756
  var api = options.api,
8378
8757
  asset = options.assetInfo,
8379
- address = options.address;
8380
- return api.callTxMethod({
8758
+ address = options.address,
8759
+ isAmountAll = options.isAmountAll;
8760
+ if (isAmountAll) {
8761
+ return Promise.resolve(api.callTxMethod({
8762
+ module: 'Balances',
8763
+ method: 'transfer_all',
8764
+ parameters: {
8765
+ dest: address,
8766
+ keep_alive: false
8767
+ }
8768
+ }));
8769
+ }
8770
+ return Promise.resolve(api.callTxMethod({
8381
8771
  module: 'Balances',
8382
8772
  method: 'transfer_keep_alive',
8383
8773
  parameters: {
8384
8774
  dest: address,
8385
8775
  value: asset.amount
8386
8776
  }
8387
- });
8777
+ }));
8388
8778
  }
8389
8779
  }, {
8390
8780
  key: "transferLocalNonNativeAsset",
8391
8781
  value: function transferLocalNonNativeAsset(options) {
8392
8782
  var api = options.api,
8393
8783
  asset = options.assetInfo,
8394
- address = options.address;
8784
+ address = options.address,
8785
+ isAmountAll = options.isAmountAll;
8395
8786
  assertHasId(asset);
8787
+ var currencyId = Number(asset.assetId);
8788
+ if (isAmountAll) {
8789
+ return api.callTxMethod({
8790
+ module: 'Tokens',
8791
+ method: 'transfer_all',
8792
+ parameters: {
8793
+ dest: address,
8794
+ currency_id: currencyId,
8795
+ keep_alive: false
8796
+ }
8797
+ });
8798
+ }
8396
8799
  return api.callTxMethod({
8397
8800
  module: 'Tokens',
8398
8801
  method: 'transfer',
8399
8802
  parameters: {
8400
8803
  dest: address,
8401
- currency_id: Number(asset.assetId),
8804
+ currency_id: currencyId,
8402
8805
  amount: asset.amount
8403
8806
  }
8404
8807
  });
@@ -8441,16 +8844,30 @@ var IntegriteePolkadot = /*#__PURE__*/function (_Parachain) {
8441
8844
  value: function transferLocalNonNativeAsset(options) {
8442
8845
  var api = options.api,
8443
8846
  asset = options.assetInfo,
8444
- address = options.address;
8847
+ address = options.address,
8848
+ isAmountAll = options.isAmountAll;
8445
8849
  assertHasId(asset);
8850
+ var assetId = Number(asset.assetId);
8851
+ var dest = {
8852
+ Id: address
8853
+ };
8854
+ if (isAmountAll) {
8855
+ return api.callTxMethod({
8856
+ module: 'Assets',
8857
+ method: 'transfer_all',
8858
+ parameters: {
8859
+ id: assetId,
8860
+ dest: dest,
8861
+ keep_alive: false
8862
+ }
8863
+ });
8864
+ }
8446
8865
  return api.callTxMethod({
8447
8866
  module: 'Assets',
8448
8867
  method: 'transfer',
8449
8868
  parameters: {
8450
- id: Number(asset.assetId),
8451
- target: {
8452
- Id: address
8453
- },
8869
+ id: assetId,
8870
+ target: dest,
8454
8871
  amount: asset.amount
8455
8872
  }
8456
8873
  });
@@ -8505,20 +8922,33 @@ var Interlay = /*#__PURE__*/function (_Parachain) {
8505
8922
  }, {
8506
8923
  key: "transferLocalNativeAsset",
8507
8924
  value: function transferLocalNativeAsset(options) {
8508
- return this.transferLocalNonNativeAsset(options);
8925
+ return Promise.resolve(this.transferLocalNonNativeAsset(options));
8509
8926
  }
8510
8927
  }, {
8511
8928
  key: "transferLocalNonNativeAsset",
8512
8929
  value: function transferLocalNonNativeAsset(options) {
8513
8930
  var api = options.api,
8514
8931
  asset = options.assetInfo,
8515
- address = options.address;
8932
+ address = options.address,
8933
+ isAmountAll = options.isAmountAll;
8934
+ var currencyId = this.getCurrencySelection(asset);
8935
+ if (isAmountAll) {
8936
+ return api.callTxMethod({
8937
+ module: 'Tokens',
8938
+ method: 'transfer_all',
8939
+ parameters: {
8940
+ dest: address,
8941
+ currency_id: currencyId,
8942
+ keep_alive: false
8943
+ }
8944
+ });
8945
+ }
8516
8946
  return api.callTxMethod({
8517
8947
  module: 'Tokens',
8518
8948
  method: 'transfer',
8519
8949
  parameters: {
8520
8950
  dest: address,
8521
- currency_id: this.getCurrencySelection(asset),
8951
+ currency_id: currencyId,
8522
8952
  value: asset.amount
8523
8953
  }
8524
8954
  });
@@ -8573,29 +9003,14 @@ Jamton.NATIVE_ASSET_IDS = {
8573
9003
  jamTON: 2
8574
9004
  };
8575
9005
 
8576
- var Karura = /*#__PURE__*/function (_Parachain) {
9006
+ var Karura = /*#__PURE__*/function (_Acala) {
8577
9007
  function Karura() {
8578
9008
  _classCallCheck(this, Karura);
8579
9009
  return _callSuper(this, Karura, ['Karura', 'karura', 'Kusama', Version.V4]);
8580
9010
  }
8581
- _inherits(Karura, _Parachain);
8582
- return _createClass(Karura, [{
8583
- key: "transferXTokens",
8584
- value: function transferXTokens(input) {
8585
- return getChain('Acala').transferXTokens(input);
8586
- }
8587
- }, {
8588
- key: "transferLocalNativeAsset",
8589
- value: function transferLocalNativeAsset(options) {
8590
- return getChain('Acala').transferLocalNativeAsset(options);
8591
- }
8592
- }, {
8593
- key: "transferLocalNonNativeAsset",
8594
- value: function transferLocalNonNativeAsset(options) {
8595
- return getChain('Acala').transferLocalNonNativeAsset(options);
8596
- }
8597
- }]);
8598
- }(Parachain);
9011
+ _inherits(Karura, _Acala);
9012
+ return _createClass(Karura);
9013
+ }(Acala);
8599
9014
 
8600
9015
  var KiltSpiritnet = /*#__PURE__*/function (_Parachain) {
8601
9016
  function KiltSpiritnet() {
@@ -8659,20 +9074,33 @@ var Kintsugi = /*#__PURE__*/function (_Parachain) {
8659
9074
  }, {
8660
9075
  key: "transferLocalNativeAsset",
8661
9076
  value: function transferLocalNativeAsset(options) {
8662
- return this.transferLocalNonNativeAsset(options);
9077
+ return Promise.resolve(this.transferLocalNonNativeAsset(options));
8663
9078
  }
8664
9079
  }, {
8665
9080
  key: "transferLocalNonNativeAsset",
8666
9081
  value: function transferLocalNonNativeAsset(options) {
8667
9082
  var api = options.api,
8668
9083
  asset = options.assetInfo,
8669
- address = options.address;
9084
+ address = options.address,
9085
+ isAmountAll = options.isAmountAll;
9086
+ var currencyId = this.getCurrencySelection(asset);
9087
+ if (isAmountAll) {
9088
+ return api.callTxMethod({
9089
+ module: 'Tokens',
9090
+ method: 'transfer_all',
9091
+ parameters: {
9092
+ dest: address,
9093
+ currency_id: currencyId,
9094
+ keep_alive: false
9095
+ }
9096
+ });
9097
+ }
8670
9098
  return api.callTxMethod({
8671
9099
  module: 'Tokens',
8672
9100
  method: 'transfer',
8673
9101
  parameters: {
8674
9102
  dest: address,
8675
- currency_id: this.getCurrencySelection(asset),
9103
+ currency_id: currencyId,
8676
9104
  value: asset.amount
8677
9105
  }
8678
9106
  });
@@ -8751,17 +9179,21 @@ var Manta = /*#__PURE__*/function (_Parachain) {
8751
9179
  value: function transferLocalNonNativeAsset(options) {
8752
9180
  var api = options.api,
8753
9181
  asset = options.assetInfo,
8754
- address = options.address;
9182
+ address = options.address,
9183
+ balance = options.balance,
9184
+ isAmountAll = options.isAmountAll;
8755
9185
  assertHasId(asset);
9186
+ var assetId = BigInt(asset.assetId);
9187
+ var amount = isAmountAll ? balance : asset.amount;
8756
9188
  return api.callTxMethod({
8757
9189
  module: 'Assets',
8758
9190
  method: 'transfer',
8759
9191
  parameters: {
8760
- id: BigInt(asset.assetId),
9192
+ id: assetId,
8761
9193
  target: {
8762
9194
  Id: address
8763
9195
  },
8764
- amount: asset.amount
9196
+ amount: amount
8765
9197
  }
8766
9198
  });
8767
9199
  }
@@ -8833,20 +9265,8 @@ var Moonbeam = /*#__PURE__*/function (_Parachain) {
8833
9265
  }()
8834
9266
  }, {
8835
9267
  key: "transferLocalNonNativeAsset",
8836
- value: function transferLocalNonNativeAsset(options) {
8837
- var api = options.api,
8838
- assetInfo = options.assetInfo,
8839
- address = options.address;
8840
- assertHasId(assetInfo);
8841
- return api.callTxMethod({
8842
- module: 'Assets',
8843
- method: 'transfer',
8844
- parameters: {
8845
- id: BigInt(assetInfo.assetId),
8846
- target: address,
8847
- amount: assetInfo.amount
8848
- }
8849
- });
9268
+ value: function transferLocalNonNativeAsset(_options) {
9269
+ throw new ScenarioNotSupportedError(this.chain, 'ParaToPara', "".concat(this.chain, " local transfers are temporarily disabled"));
8850
9270
  }
8851
9271
  }]);
8852
9272
  }(Parachain);
@@ -9023,6 +9443,53 @@ var NeuroWeb = /*#__PURE__*/function (_Parachain) {
9023
9443
  value: function transferPolkadotXCM(input) {
9024
9444
  return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9025
9445
  }
9446
+ }, {
9447
+ key: "transferLocalNativeAsset",
9448
+ value: function transferLocalNativeAsset(options) {
9449
+ var api = options.api,
9450
+ asset = options.assetInfo,
9451
+ address = options.address,
9452
+ isAmountAll = options.isAmountAll;
9453
+ if (isAmountAll) {
9454
+ return Promise.resolve(api.callTxMethod({
9455
+ module: 'Balances',
9456
+ method: 'transfer_all',
9457
+ parameters: {
9458
+ dest: address,
9459
+ keep_alive: false
9460
+ }
9461
+ }));
9462
+ }
9463
+ return Promise.resolve(api.callTxMethod({
9464
+ module: 'Balances',
9465
+ method: 'transfer_keep_alive',
9466
+ parameters: {
9467
+ dest: address,
9468
+ value: asset.amount
9469
+ }
9470
+ }));
9471
+ }
9472
+ }, {
9473
+ key: "transferLocalNonNativeAsset",
9474
+ value: function transferLocalNonNativeAsset(options) {
9475
+ var api = options.api,
9476
+ asset = options.assetInfo,
9477
+ address = options.address,
9478
+ balance = options.balance,
9479
+ isAmountAll = options.isAmountAll;
9480
+ assertHasId(asset);
9481
+ var assetId = BigInt(asset.assetId);
9482
+ var amount = isAmountAll ? balance : asset.amount;
9483
+ return api.callTxMethod({
9484
+ module: 'Assets',
9485
+ method: 'transfer',
9486
+ parameters: {
9487
+ id: assetId,
9488
+ target: address,
9489
+ amount: amount
9490
+ }
9491
+ });
9492
+ }
9026
9493
  }]);
9027
9494
  }(Parachain);
9028
9495
 
@@ -9162,16 +9629,30 @@ var Peaq = /*#__PURE__*/function (_Parachain) {
9162
9629
  value: function transferLocalNonNativeAsset(options) {
9163
9630
  var api = options.api,
9164
9631
  asset = options.assetInfo,
9165
- address = options.address;
9632
+ address = options.address,
9633
+ isAmountAll = options.isAmountAll;
9166
9634
  assertHasId(asset);
9635
+ var assetId = BigInt(asset.assetId);
9636
+ var dest = {
9637
+ Id: address
9638
+ };
9639
+ if (isAmountAll) {
9640
+ return api.callTxMethod({
9641
+ module: 'Assets',
9642
+ method: 'transfer_all',
9643
+ parameters: {
9644
+ id: assetId,
9645
+ dest: dest,
9646
+ keep_alive: false
9647
+ }
9648
+ });
9649
+ }
9167
9650
  return api.callTxMethod({
9168
9651
  module: 'Assets',
9169
9652
  method: 'transfer',
9170
9653
  parameters: {
9171
- id: BigInt(asset.assetId),
9172
- target: {
9173
- Id: address
9174
- },
9654
+ id: assetId,
9655
+ target: dest,
9175
9656
  amount: asset.amount
9176
9657
  }
9177
9658
  });
@@ -9343,17 +9824,21 @@ var Phala = /*#__PURE__*/function (_Parachain) {
9343
9824
  value: function transferLocalNonNativeAsset(options) {
9344
9825
  var api = options.api,
9345
9826
  asset = options.assetInfo,
9346
- address = options.address;
9827
+ address = options.address,
9828
+ isAmountAll = options.isAmountAll;
9347
9829
  assertHasId(asset);
9830
+ var assetId = BigInt(asset.assetId);
9831
+ var dest = {
9832
+ Id: address
9833
+ };
9834
+ var amount = isAmountAll ? options.balance : asset.amount;
9348
9835
  return api.callTxMethod({
9349
9836
  module: 'Assets',
9350
9837
  method: 'transfer',
9351
9838
  parameters: {
9352
- id: BigInt(asset.assetId),
9353
- target: {
9354
- Id: address
9355
- },
9356
- amount: asset.amount
9839
+ id: assetId,
9840
+ target: dest,
9841
+ amount: amount
9357
9842
  }
9358
9843
  });
9359
9844
  }
@@ -9424,16 +9909,30 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_Parachain) {
9424
9909
  value: function transferLocalNonNativeAsset(options) {
9425
9910
  var api = options.api,
9426
9911
  asset = options.assetInfo,
9427
- address = options.address;
9912
+ address = options.address,
9913
+ isAmountAll = options.isAmountAll;
9428
9914
  assertHasId(asset);
9915
+ var assetId = BigInt(asset.assetId);
9916
+ var dest = {
9917
+ Id: address
9918
+ };
9919
+ if (isAmountAll) {
9920
+ return api.callTxMethod({
9921
+ module: 'Assets',
9922
+ method: 'transfer_all',
9923
+ parameters: {
9924
+ id: assetId,
9925
+ dest: dest,
9926
+ keep_alive: false
9927
+ }
9928
+ });
9929
+ }
9429
9930
  return api.callTxMethod({
9430
9931
  module: 'Assets',
9431
9932
  method: 'transfer',
9432
9933
  parameters: {
9433
- id: BigInt(asset.assetId),
9434
- target: {
9435
- Id: address
9436
- },
9934
+ id: assetId,
9935
+ target: dest,
9437
9936
  amount: asset.amount
9438
9937
  }
9439
9938
  });
@@ -9594,8 +10093,11 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
9594
10093
  value: function transferLocalNonNativeAsset(options) {
9595
10094
  var api = options.api,
9596
10095
  asset = options.assetInfo,
9597
- address = options.address;
10096
+ address = options.address,
10097
+ balance = options.balance,
10098
+ isAmountAll = options.isAmountAll;
9598
10099
  assertHasId(asset);
10100
+ var amount = isAmountAll ? balance : asset.amount;
9599
10101
  return api.callTxMethod({
9600
10102
  module: 'AssetManager',
9601
10103
  method: 'transfer',
@@ -9604,7 +10106,7 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
9604
10106
  Id: address
9605
10107
  },
9606
10108
  currency_id: this.getCurrencySelection(asset),
9607
- amount: asset.amount
10109
+ amount: amount
9608
10110
  }
9609
10111
  });
9610
10112
  }
@@ -9737,6 +10239,8 @@ var MAX_WEIGHT = {
9737
10239
  refTime: MAX_U64
9738
10240
  };
9739
10241
  var BYPASS_MINT_AMOUNT = '1000';
10242
+ var MIN_AMOUNT = 2n;
10243
+ var AMOUNT_ALL = 'ALL';
9740
10244
 
9741
10245
  var buildClaimAssetsParams = function buildClaimAssetsParams(options) {
9742
10246
  var assets = options.assets,
@@ -9892,11 +10396,6 @@ var dryRunOrigin = /*#__PURE__*/function () {
9892
10396
  };
9893
10397
  }();
9894
10398
 
9895
- var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
9896
- _classCallCheck(this, BaseAssetsPallet);
9897
- this.palletName = palletName;
9898
- });
9899
-
9900
10399
  var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9901
10400
  function AssetManagerPallet() {
9902
10401
  _classCallCheck(this, AssetManagerPallet);
@@ -9928,51 +10427,6 @@ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9928
10427
  }]);
9929
10428
  }(BaseAssetsPallet);
9930
10429
 
9931
- var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9932
- function AssetsPallet() {
9933
- _classCallCheck(this, AssetsPallet);
9934
- return _callSuper(this, AssetsPallet, arguments);
9935
- }
9936
- _inherits(AssetsPallet, _BaseAssetsPallet);
9937
- return _createClass(AssetsPallet, [{
9938
- key: "mint",
9939
- value: function mint(address, asset, _balance, chain) {
9940
- assertHasId(asset);
9941
- var assetId = asset.assetId,
9942
- amount = asset.amount;
9943
- var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
9944
- var addr = isChainEvm(chain) ? address : {
9945
- Id: address
9946
- };
9947
- return Promise.resolve({
9948
- assetStatusTx: {
9949
- module: this.palletName,
9950
- method: 'force_asset_status',
9951
- parameters: {
9952
- id: id,
9953
- owner: addr,
9954
- issuer: addr,
9955
- admin: addr,
9956
- freezer: addr,
9957
- min_balance: 0n,
9958
- is_sufficient: true,
9959
- is_frozen: false
9960
- }
9961
- },
9962
- balanceTx: {
9963
- module: this.palletName,
9964
- method: 'mint',
9965
- parameters: {
9966
- id: id,
9967
- beneficiary: addr,
9968
- amount: amount
9969
- }
9970
- }
9971
- });
9972
- }
9973
- }]);
9974
- }(BaseAssetsPallet);
9975
-
9976
10430
  var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9977
10431
  function BalancesPallet() {
9978
10432
  _classCallCheck(this, BalancesPallet);
@@ -10008,17 +10462,19 @@ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
10008
10462
  _inherits(CurrenciesPallet, _BaseAssetsPallet);
10009
10463
  return _createClass(CurrenciesPallet, [{
10010
10464
  key: "mint",
10011
- value: function mint(address, assetInfo, balance) {
10012
- assertHasId(assetInfo);
10013
- var assetId = assetInfo.assetId,
10014
- amount = assetInfo.amount;
10465
+ value: function mint(address, asset, balance, chain) {
10466
+ var isKarura = chain.startsWith('Karura');
10467
+ var id = isKarura ? getChain('Karura').getCurrencySelection(asset) : (assertHasId(asset), Number(asset.assetId));
10468
+ var amount = asset.amount;
10015
10469
  return Promise.resolve({
10016
10470
  balanceTx: {
10017
10471
  module: this.palletName,
10018
10472
  method: 'update_balance',
10019
10473
  parameters: {
10020
- who: address,
10021
- currency_id: Number(assetId),
10474
+ who: isKarura ? {
10475
+ Id: address
10476
+ } : address,
10477
+ currency_id: id,
10022
10478
  amount: balance + amount
10023
10479
  }
10024
10480
  }
@@ -10151,105 +10607,34 @@ var TokensPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
10151
10607
  return Promise.resolve({
10152
10608
  balanceTx: {
10153
10609
  module: this.palletName,
10154
- method: 'set_balance',
10155
- parameters: {
10156
- who: {
10157
- Id: address
10158
- },
10159
- currency_id: id,
10160
- new_free: balance + amount,
10161
- new_reserved: 0n
10162
- }
10163
- }
10164
- });
10165
- }
10166
- }]);
10167
- }(BaseAssetsPallet);
10168
-
10169
- var palletRegistry = {
10170
- Balances: new BalancesPallet('Balances'),
10171
- Tokens: new TokensPallet('Tokens'),
10172
- Currencies: new CurrenciesPallet('Currencies'),
10173
- Assets: new AssetsPallet('Assets'),
10174
- ForeignAssets: new ForeignAssetsPallet('ForeignAssets'),
10175
- AssetManager: new AssetManagerPallet('AssetManager'),
10176
- System: new SystemPallet('System'),
10177
- Fungibles: new AssetsPallet('Fungibles')
10178
- };
10179
- var getPalletInstance = function getPalletInstance(type) {
10180
- return palletRegistry[type];
10181
- };
10182
-
10183
- var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
10184
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
10185
- var _getExistentialDeposi;
10186
- var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
10187
- return _regenerator().w(function (_context) {
10188
- while (1) switch (_context.n) {
10189
- case 0:
10190
- 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;
10191
- _context.n = 1;
10192
- return api.init(origin);
10193
- case 1:
10194
- _context.n = 2;
10195
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
10196
- case 2:
10197
- tx = _context.v;
10198
- _context.n = 3;
10199
- return api.calculateTransactionFee(tx, account);
10200
- case 3:
10201
- xcmFee = _context.v;
10202
- xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
10203
- _context.n = 4;
10204
- return getBalanceNativeInternal({
10205
- address: account,
10206
- chain: origin,
10207
- api: api
10208
- });
10209
- case 4:
10210
- nativeBalance = _context.v;
10211
- existentialDeposit = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
10212
- sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
10213
- return _context.a(2, {
10214
- sufficientForXCM: sufficientForXCM,
10215
- xcmFee: xcmFee
10216
- });
10217
- }
10218
- }, _callee);
10219
- }));
10220
- return function getOriginFeeDetailsInternal(_x) {
10221
- return _ref2.apply(this, arguments);
10222
- };
10223
- }();
10224
- var getOriginFeeDetails = /*#__PURE__*/function () {
10225
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
10226
- var api;
10227
- return _regenerator().w(function (_context2) {
10228
- while (1) switch (_context2.p = _context2.n) {
10229
- case 0:
10230
- api = options.api;
10231
- api.setDisconnectAllowed(false);
10232
- _context2.p = 1;
10233
- _context2.n = 2;
10234
- return getOriginFeeDetailsInternal(options);
10235
- case 2:
10236
- return _context2.a(2, _context2.v);
10237
- case 3:
10238
- _context2.p = 3;
10239
- api.setDisconnectAllowed(true);
10240
- _context2.n = 4;
10241
- return api.disconnect();
10242
- case 4:
10243
- return _context2.f(3);
10244
- case 5:
10245
- return _context2.a(2);
10246
- }
10247
- }, _callee2, null, [[1,, 3, 5]]);
10248
- }));
10249
- return function getOriginFeeDetails(_x2) {
10250
- return _ref3.apply(this, arguments);
10251
- };
10252
- }();
10610
+ method: 'set_balance',
10611
+ parameters: {
10612
+ who: {
10613
+ Id: address
10614
+ },
10615
+ currency_id: id,
10616
+ new_free: balance + amount,
10617
+ new_reserved: 0n
10618
+ }
10619
+ }
10620
+ });
10621
+ }
10622
+ }]);
10623
+ }(BaseAssetsPallet);
10624
+
10625
+ var palletRegistry = {
10626
+ Balances: new BalancesPallet('Balances'),
10627
+ Tokens: new TokensPallet('Tokens'),
10628
+ Currencies: new CurrenciesPallet('Currencies'),
10629
+ Assets: new AssetsPallet('Assets'),
10630
+ ForeignAssets: new ForeignAssetsPallet('ForeignAssets'),
10631
+ AssetManager: new AssetManagerPallet('AssetManager'),
10632
+ System: new SystemPallet('System'),
10633
+ Fungibles: new AssetsPallet('Fungibles')
10634
+ };
10635
+ var getPalletInstance = function getPalletInstance(type) {
10636
+ return palletRegistry[type];
10637
+ };
10253
10638
 
10254
10639
  var pickOtherPallet = function pickOtherPallet(asset, pallets) {
10255
10640
  if (isForeignAsset(asset) && (!asset.assetId || asset.assetId.startsWith('0x'))) {
@@ -10789,6 +11174,9 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
10789
11174
  }
10790
11175
  // MultiAsset is an array of TCurrencyCore, search for assets
10791
11176
  var assets = currency.map(function (currency) {
11177
+ if (currency.amount === AMOUNT_ALL) {
11178
+ throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
11179
+ }
10792
11180
  var asset = findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
10793
11181
  if (!asset) {
10794
11182
  throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
@@ -11540,11 +11928,11 @@ var transferRelayToPara = /*#__PURE__*/function () {
11540
11928
 
11541
11929
  var send = /*#__PURE__*/function () {
11542
11930
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
11543
- 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;
11931
+ 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;
11544
11932
  return _regenerator().w(function (_context) {
11545
11933
  while (1) switch (_context.n) {
11546
11934
  case 0:
11547
- 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;
11935
+ 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;
11548
11936
  validateCurrency(currency, feeAsset);
11549
11937
  validateDestination(origin, destination);
11550
11938
  validateDestinationAddress(address, destination);
@@ -11556,7 +11944,7 @@ var send = /*#__PURE__*/function () {
11556
11944
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
11557
11945
  validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
11558
11946
  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)
11559
- finalAmount = !Array.isArray(currency) && amount < 2n ? 2n : amount;
11947
+ finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
11560
11948
  originVersion = getChainVersion(origin);
11561
11949
  destVersion = !isTLocation(destination) ? getChainVersion(destination) : undefined;
11562
11950
  resolvedVersion = selectXcmVersion(version, originVersion, destVersion);
@@ -11590,7 +11978,16 @@ var send = /*#__PURE__*/function () {
11590
11978
  _context.n = 4;
11591
11979
  return api.init(origin, TX_CLIENT_TIMEOUT_MS);
11592
11980
  case 4:
11593
- return _context.a(2, api.callTxMethod({
11981
+ return _context.a(2, api.callTxMethod(isAmountAll ? {
11982
+ module: 'Balances',
11983
+ method: 'transfer_all',
11984
+ parameters: {
11985
+ dest: {
11986
+ Id: address
11987
+ },
11988
+ keepAlive: true
11989
+ }
11990
+ } : {
11594
11991
  module: 'Balances',
11595
11992
  method: 'transfer_keep_alive',
11596
11993
  parameters: {
@@ -11649,7 +12046,8 @@ var send = /*#__PURE__*/function () {
11649
12046
  senderAddress: senderAddress,
11650
12047
  ahAddress: ahAddress,
11651
12048
  pallet: pallet,
11652
- method: method
12049
+ method: method,
12050
+ isAmountAll: isAmountAll
11653
12051
  }));
11654
12052
  }
11655
12053
  }, _callee);
@@ -12074,7 +12472,7 @@ var getTransferInfo = /*#__PURE__*/function () {
12074
12472
 
12075
12473
  var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12076
12474
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
12077
- 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;
12475
+ 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;
12078
12476
  return _regenerator().w(function (_context) {
12079
12477
  while (1) switch (_context.n) {
12080
12478
  case 0:
@@ -12133,30 +12531,23 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12133
12531
  modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12134
12532
  amount: minAmount
12135
12533
  }));
12136
- _t = dryRunInternal;
12137
- _t2 = api;
12138
12534
  _context.n = 4;
12139
12535
  return modifiedBuilder['buildInternal']();
12140
12536
  case 4:
12141
- _t3 = _context.v;
12142
- _t4 = chain;
12143
- _t5 = destination;
12144
- _t6 = senderAddress;
12145
- _t7 = address;
12146
- _t8 = _objectSpread2(_objectSpread2({}, currency), {}, {
12147
- amount: minAmount
12148
- });
12149
- _t9 = feeAsset;
12537
+ _yield$modifiedBuilde = _context.v;
12538
+ tx = _yield$modifiedBuilde.tx;
12150
12539
  _context.n = 5;
12151
- return _t({
12152
- api: _t2,
12153
- tx: _t3,
12154
- origin: _t4,
12155
- destination: _t5,
12156
- senderAddress: _t6,
12157
- address: _t7,
12158
- currency: _t8,
12159
- feeAsset: _t9
12540
+ return dryRunInternal({
12541
+ api: api,
12542
+ tx: tx,
12543
+ origin: chain,
12544
+ destination: destination,
12545
+ senderAddress: senderAddress,
12546
+ address: address,
12547
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
12548
+ amount: minAmount
12549
+ }),
12550
+ feeAsset: feeAsset
12160
12551
  });
12161
12552
  case 5:
12162
12553
  dryRunResult = _context.v;
@@ -12498,6 +12889,7 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
12498
12889
  refundFee = fees.refundFee,
12499
12890
  destFee = fees.destFee;
12500
12891
  var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
12892
+ var feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation);
12501
12893
  var asset = createAsset(version, assetInfo.amount, localizeLocation(dest.chain, assetInfo.location));
12502
12894
  var depositInstruction = {
12503
12895
  DepositAsset: {
@@ -12529,7 +12921,7 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
12529
12921
  };
12530
12922
  var buyExecution = {
12531
12923
  BuyExecution: {
12532
- fees: createAsset(version, buyExecutionAmount, feeAssetLocation),
12924
+ fees: createAsset(version, buyExecutionAmount, feeLocLocalized),
12533
12925
  weight_limit: 'Unlimited'
12534
12926
  }
12535
12927
  };
@@ -13032,6 +13424,54 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
13032
13424
  }]);
13033
13425
  }();
13034
13426
 
13427
+ var normalizeAmountAll = /*#__PURE__*/function () {
13428
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, buildTx, options) {
13429
+ var currency, isAmountAll, transferable;
13430
+ return _regenerator().w(function (_context) {
13431
+ while (1) switch (_context.n) {
13432
+ case 0:
13433
+ currency = options.currency;
13434
+ isAmountAll = !Array.isArray(currency) && currency.amount === AMOUNT_ALL;
13435
+ if (isAmountAll) {
13436
+ _context.n = 1;
13437
+ break;
13438
+ }
13439
+ return _context.a(2, _objectSpread2({
13440
+ api: api,
13441
+ isAmountAll: isAmountAll
13442
+ }, options));
13443
+ case 1:
13444
+ assertToIsString(options.to);
13445
+ assertSenderAddress(options.senderAddress);
13446
+ _context.n = 2;
13447
+ return getTransferableAmountInternal({
13448
+ api: api,
13449
+ buildTx: buildTx,
13450
+ origin: options.from,
13451
+ destination: options.to,
13452
+ senderAddress: options.senderAddress,
13453
+ feeAsset: options.feeAsset,
13454
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
13455
+ amount: MIN_AMOUNT
13456
+ })
13457
+ });
13458
+ case 2:
13459
+ transferable = _context.v;
13460
+ return _context.a(2, _objectSpread2(_objectSpread2({}, options), {}, {
13461
+ api: api,
13462
+ isAmountAll: isAmountAll,
13463
+ currency: _objectSpread2(_objectSpread2({}, currency), {}, {
13464
+ amount: transferable
13465
+ })
13466
+ }));
13467
+ }
13468
+ }, _callee);
13469
+ }));
13470
+ return function normalizeAmountAll(_x, _x2, _x3) {
13471
+ return _ref.apply(this, arguments);
13472
+ };
13473
+ }();
13474
+
13035
13475
  var BatchTransactionManager = /*#__PURE__*/function () {
13036
13476
  function BatchTransactionManager() {
13037
13477
  _classCallCheck(this, BatchTransactionManager);
@@ -13050,25 +13490,25 @@ var BatchTransactionManager = /*#__PURE__*/function () {
13050
13490
  }, {
13051
13491
  key: "buildBatch",
13052
13492
  value: function () {
13053
- var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, from) {
13493
+ var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, from) {
13054
13494
  var options,
13055
13495
  mode,
13056
13496
  sameFrom,
13057
- results,
13497
+ normalized,
13058
13498
  txs,
13059
- _args = arguments;
13060
- return _regenerator().w(function (_context) {
13061
- while (1) switch (_context.n) {
13499
+ _args2 = arguments;
13500
+ return _regenerator().w(function (_context2) {
13501
+ while (1) switch (_context2.n) {
13062
13502
  case 0:
13063
- options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {
13503
+ options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {
13064
13504
  mode: BatchMode.BATCH_ALL
13065
13505
  };
13066
- _context.n = 1;
13506
+ _context2.n = 1;
13067
13507
  return api.init(from, TX_CLIENT_TIMEOUT_MS);
13068
13508
  case 1:
13069
13509
  mode = options.mode;
13070
13510
  if (!(this.transactionOptions.length === 0)) {
13071
- _context.n = 2;
13511
+ _context2.n = 2;
13072
13512
  break;
13073
13513
  }
13074
13514
  throw new InvalidParameterError('No transactions to batch.');
@@ -13077,21 +13517,38 @@ var BatchTransactionManager = /*#__PURE__*/function () {
13077
13517
  return tx.from === from;
13078
13518
  });
13079
13519
  if (sameFrom) {
13080
- _context.n = 3;
13520
+ _context2.n = 3;
13081
13521
  break;
13082
13522
  }
13083
13523
  throw new InvalidParameterError('All transactions must have the same origin.');
13084
13524
  case 3:
13085
- results = this.transactionOptions.map(function (options) {
13086
- return send(options);
13087
- });
13088
- _context.n = 4;
13089
- return Promise.all(results);
13525
+ _context2.n = 4;
13526
+ return Promise.all(this.transactionOptions.map(/*#__PURE__*/function () {
13527
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(opts) {
13528
+ var buildTx;
13529
+ return _regenerator().w(function (_context) {
13530
+ while (1) switch (_context.n) {
13531
+ case 0:
13532
+ buildTx = opts.buildTx;
13533
+ return _context.a(2, normalizeAmountAll(api, buildTx, opts));
13534
+ }
13535
+ }, _callee);
13536
+ }));
13537
+ return function (_x3) {
13538
+ return _ref.apply(this, arguments);
13539
+ };
13540
+ }()));
13090
13541
  case 4:
13091
- txs = _context.v;
13092
- return _context.a(2, api.callBatchMethod(txs, mode));
13542
+ normalized = _context2.v;
13543
+ _context2.n = 5;
13544
+ return Promise.all(normalized.map(function (o) {
13545
+ return send(o);
13546
+ }));
13547
+ case 5:
13548
+ txs = _context2.v;
13549
+ return _context2.a(2, api.callBatchMethod(txs, mode));
13093
13550
  }
13094
- }, _callee, this);
13551
+ }, _callee2, this);
13095
13552
  }));
13096
13553
  function buildBatch(_x, _x2) {
13097
13554
  return _buildBatch.apply(this, arguments);
@@ -13284,9 +13741,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
13284
13741
  }, {
13285
13742
  key: "addToBatch",
13286
13743
  value: function addToBatch() {
13287
- this.batchManager.addTransaction(_objectSpread2({
13744
+ var buildTx = this.createTxFactory();
13745
+ this.batchManager.addTransaction(_objectSpread2(_objectSpread2({
13288
13746
  api: this.api
13289
- }, this._options));
13747
+ }, this._options), {}, {
13748
+ buildTx: buildTx
13749
+ }));
13290
13750
  return new GeneralBuilder(this.api, this.batchManager, {
13291
13751
  from: this._options.from
13292
13752
  });
@@ -13318,6 +13778,34 @@ var GeneralBuilder = /*#__PURE__*/function () {
13318
13778
  value: function buildInternal() {
13319
13779
  return this.buildCommon(true);
13320
13780
  }
13781
+ }, {
13782
+ key: "prepareNormalizedOptions",
13783
+ value: function () {
13784
+ var _prepareNormalizedOptions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
13785
+ var builder, buildTx, normalizedOptions;
13786
+ return _regenerator().w(function (_context2) {
13787
+ while (1) switch (_context2.n) {
13788
+ case 0:
13789
+ builder = this.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
13790
+ amount: MIN_AMOUNT.toString()
13791
+ }));
13792
+ buildTx = builder.createTxFactory();
13793
+ _context2.n = 1;
13794
+ return normalizeAmountAll(this.api, buildTx, options);
13795
+ case 1:
13796
+ normalizedOptions = _context2.v;
13797
+ return _context2.a(2, {
13798
+ normalizedOptions: normalizedOptions,
13799
+ buildTx: buildTx
13800
+ });
13801
+ }
13802
+ }, _callee2, this);
13803
+ }));
13804
+ function prepareNormalizedOptions(_x2) {
13805
+ return _prepareNormalizedOptions.apply(this, arguments);
13806
+ }
13807
+ return prepareNormalizedOptions;
13808
+ }()
13321
13809
  /**
13322
13810
  * Builds and returns the transfer extrinsic.
13323
13811
  *
@@ -13326,13 +13814,19 @@ var GeneralBuilder = /*#__PURE__*/function () {
13326
13814
  }, {
13327
13815
  key: "build",
13328
13816
  value: (function () {
13329
- var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
13330
- return _regenerator().w(function (_context2) {
13331
- while (1) switch (_context2.n) {
13817
+ var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
13818
+ var _yield$this$buildComm, tx;
13819
+ return _regenerator().w(function (_context3) {
13820
+ while (1) switch (_context3.n) {
13332
13821
  case 0:
13333
- return _context2.a(2, this.buildCommon());
13822
+ _context3.n = 1;
13823
+ return this.buildCommon();
13824
+ case 1:
13825
+ _yield$this$buildComm = _context3.v;
13826
+ tx = _yield$this$buildComm.tx;
13827
+ return _context3.a(2, tx);
13334
13828
  }
13335
- }, _callee2, this);
13829
+ }, _callee3, this);
13336
13830
  }));
13337
13831
  function build() {
13338
13832
  return _build.apply(this, arguments);
@@ -13342,42 +13836,50 @@ var GeneralBuilder = /*#__PURE__*/function () {
13342
13836
  }, {
13343
13837
  key: "buildCommon",
13344
13838
  value: function () {
13345
- var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
13839
+ var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
13346
13840
  var isCalledInternally,
13347
13841
  _this$_options,
13348
13842
  from,
13349
13843
  to,
13844
+ _yield$this$prepareNo,
13845
+ normalizedOptions,
13350
13846
  tx,
13351
- _args3 = arguments;
13352
- return _regenerator().w(function (_context3) {
13353
- while (1) switch (_context3.n) {
13847
+ _args4 = arguments;
13848
+ return _regenerator().w(function (_context4) {
13849
+ while (1) switch (_context4.n) {
13354
13850
  case 0:
13355
- isCalledInternally = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
13356
- if (this.batchManager.isEmpty()) {
13357
- _context3.n = 1;
13851
+ isCalledInternally = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : false;
13852
+ if (!(!this.batchManager.isEmpty() && !isCalledInternally)) {
13853
+ _context4.n = 1;
13358
13854
  break;
13359
13855
  }
13360
13856
  throw new InvalidParameterError('Transaction manager contains batched items. Use buildBatch() to process them.');
13361
13857
  case 1:
13362
13858
  _this$_options = this._options, from = _this$_options.from, to = _this$_options.to;
13363
13859
  if (!(!isTLocation(to) && isRelayChain(from) && isRelayChain(to) && from !== to)) {
13364
- _context3.n = 2;
13860
+ _context4.n = 2;
13365
13861
  break;
13366
13862
  }
13367
13863
  throw new InvalidParameterError('Transfers between relay chains are not yet supported.');
13368
13864
  case 2:
13369
- _context3.n = 3;
13370
- return send(_objectSpread2({
13371
- api: this.api
13372
- }, this._options));
13865
+ _context4.n = 3;
13866
+ return this.prepareNormalizedOptions(this._options);
13373
13867
  case 3:
13374
- tx = _context3.v;
13375
- _context3.n = 4;
13376
- return this.maybePerformXcmFormatCheck(tx, this._options, isCalledInternally);
13868
+ _yield$this$prepareNo = _context4.v;
13869
+ normalizedOptions = _yield$this$prepareNo.normalizedOptions;
13870
+ _context4.n = 4;
13871
+ return send(normalizedOptions);
13377
13872
  case 4:
13378
- return _context3.a(2, tx);
13873
+ tx = _context4.v;
13874
+ _context4.n = 5;
13875
+ return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
13876
+ case 5:
13877
+ return _context4.a(2, {
13878
+ tx: tx,
13879
+ options: normalizedOptions
13880
+ });
13379
13881
  }
13380
- }, _callee3, this);
13882
+ }, _callee4, this);
13381
13883
  }));
13382
13884
  function buildCommon() {
13383
13885
  return _buildCommon.apply(this, arguments);
@@ -13387,37 +13889,37 @@ var GeneralBuilder = /*#__PURE__*/function () {
13387
13889
  }, {
13388
13890
  key: "maybePerformXcmFormatCheck",
13389
13891
  value: function () {
13390
- var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(tx, options, isCalledInternally) {
13892
+ var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(tx, options, isCalledInternally) {
13391
13893
  var senderAddress, config, dryRunResult;
13392
- return _regenerator().w(function (_context4) {
13393
- while (1) switch (_context4.n) {
13894
+ return _regenerator().w(function (_context5) {
13895
+ while (1) switch (_context5.n) {
13394
13896
  case 0:
13395
13897
  senderAddress = options.senderAddress;
13396
13898
  config = this.api.getConfig();
13397
13899
  if (!(isConfig(config) && config.xcmFormatCheck && !isCalledInternally)) {
13398
- _context4.n = 2;
13900
+ _context5.n = 2;
13399
13901
  break;
13400
13902
  }
13401
13903
  assertSenderAddress(senderAddress);
13402
- _context4.n = 1;
13904
+ _context5.n = 1;
13403
13905
  return buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
13404
13906
  senderAddress: senderAddress
13405
13907
  }), {
13406
13908
  sentAssetMintMode: 'bypass'
13407
13909
  });
13408
13910
  case 1:
13409
- dryRunResult = _context4.v;
13911
+ dryRunResult = _context5.v;
13410
13912
  if (!dryRunResult.failureReason) {
13411
- _context4.n = 2;
13913
+ _context5.n = 2;
13412
13914
  break;
13413
13915
  }
13414
13916
  throw new DryRunFailedError(dryRunResult.failureReason, dryRunResult.failureChain);
13415
13917
  case 2:
13416
- return _context4.a(2);
13918
+ return _context5.a(2);
13417
13919
  }
13418
- }, _callee4, this);
13920
+ }, _callee5, this);
13419
13921
  }));
13420
- function maybePerformXcmFormatCheck(_x2, _x3, _x4) {
13922
+ function maybePerformXcmFormatCheck(_x3, _x4, _x5) {
13421
13923
  return _maybePerformXcmFormatCheck.apply(this, arguments);
13422
13924
  }
13423
13925
  return maybePerformXcmFormatCheck;
@@ -13425,18 +13927,20 @@ var GeneralBuilder = /*#__PURE__*/function () {
13425
13927
  }, {
13426
13928
  key: "dryRun",
13427
13929
  value: function () {
13428
- var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
13429
- var tx;
13430
- return _regenerator().w(function (_context5) {
13431
- while (1) switch (_context5.n) {
13930
+ var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
13931
+ var _yield$this$buildInte, tx, options;
13932
+ return _regenerator().w(function (_context6) {
13933
+ while (1) switch (_context6.n) {
13432
13934
  case 0:
13433
- _context5.n = 1;
13935
+ _context6.n = 1;
13434
13936
  return this.buildInternal();
13435
13937
  case 1:
13436
- tx = _context5.v;
13437
- return _context5.a(2, buildDryRun(this.api, tx, this._options));
13938
+ _yield$this$buildInte = _context6.v;
13939
+ tx = _yield$this$buildInte.tx;
13940
+ options = _yield$this$buildInte.options;
13941
+ return _context6.a(2, buildDryRun(this.api, tx, options));
13438
13942
  }
13439
- }, _callee5, this);
13943
+ }, _callee6, this);
13440
13944
  }));
13441
13945
  function dryRun() {
13442
13946
  return _dryRun.apply(this, arguments);
@@ -13446,23 +13950,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
13446
13950
  }, {
13447
13951
  key: "dryRunPreview",
13448
13952
  value: function () {
13449
- var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
13450
- var tx;
13451
- return _regenerator().w(function (_context6) {
13452
- while (1) switch (_context6.n) {
13953
+ var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(dryRunOptions) {
13954
+ var _yield$this$buildInte2, tx, options;
13955
+ return _regenerator().w(function (_context7) {
13956
+ while (1) switch (_context7.n) {
13453
13957
  case 0:
13454
- _context6.n = 1;
13958
+ _context7.n = 1;
13455
13959
  return this.buildInternal();
13456
13960
  case 1:
13457
- tx = _context6.v;
13458
- return _context6.a(2, buildDryRun(this.api, tx, this._options, {
13961
+ _yield$this$buildInte2 = _context7.v;
13962
+ tx = _yield$this$buildInte2.tx;
13963
+ options = _yield$this$buildInte2.options;
13964
+ return _context7.a(2, buildDryRun(this.api, tx, options, {
13459
13965
  sentAssetMintMode: 'preview',
13460
- mintFeeAssets: options === null || options === void 0 ? void 0 : options.mintFeeAssets
13966
+ mintFeeAssets: dryRunOptions === null || dryRunOptions === void 0 ? void 0 : dryRunOptions.mintFeeAssets
13461
13967
  }));
13462
13968
  }
13463
- }, _callee6, this);
13969
+ }, _callee7, this);
13464
13970
  }));
13465
- function dryRunPreview(_x5) {
13971
+ function dryRunPreview(_x6) {
13466
13972
  return _dryRunPreview.apply(this, arguments);
13467
13973
  }
13468
13974
  return dryRunPreview;
@@ -13485,21 +13991,27 @@ var GeneralBuilder = /*#__PURE__*/function () {
13485
13991
  }, {
13486
13992
  key: "getXcmFee",
13487
13993
  value: (function () {
13488
- var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(options) {
13994
+ var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(options) {
13489
13995
  var _options$disableFallb;
13490
- var _this$_options2, from, to, address, senderAddress, feeAsset, currency, disableFallback;
13491
- return _regenerator().w(function (_context7) {
13492
- while (1) switch (_context7.p = _context7.n) {
13996
+ var disableFallback, _yield$this$prepareNo2, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset;
13997
+ return _regenerator().w(function (_context8) {
13998
+ while (1) switch (_context8.p = _context8.n) {
13493
13999
  case 0:
13494
- _this$_options2 = this._options, from = _this$_options2.from, to = _this$_options2.to, address = _this$_options2.address, senderAddress = _this$_options2.senderAddress, feeAsset = _this$_options2.feeAsset, currency = _this$_options2.currency;
14000
+ disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
14001
+ _context8.n = 1;
14002
+ return this.prepareNormalizedOptions(this._options);
14003
+ case 1:
14004
+ _yield$this$prepareNo2 = _context8.v;
14005
+ normalizedOptions = _yield$this$prepareNo2.normalizedOptions;
14006
+ buildTx = _yield$this$prepareNo2.buildTx;
14007
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset;
13495
14008
  assertToIsString(to);
13496
14009
  assertAddressIsString(address);
13497
- disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
13498
- _context7.p = 1;
13499
- _context7.n = 2;
14010
+ _context8.p = 2;
14011
+ _context8.n = 3;
13500
14012
  return getXcmFee({
13501
- api: this.api,
13502
- buildTx: this.createTxFactory(),
14013
+ api: api,
14014
+ buildTx: buildTx,
13503
14015
  origin: from,
13504
14016
  destination: to,
13505
14017
  senderAddress: senderAddress,
@@ -13508,20 +14020,20 @@ var GeneralBuilder = /*#__PURE__*/function () {
13508
14020
  feeAsset: feeAsset,
13509
14021
  disableFallback: disableFallback
13510
14022
  });
13511
- case 2:
13512
- return _context7.a(2, _context7.v);
13513
14023
  case 3:
13514
- _context7.p = 3;
13515
- _context7.n = 4;
13516
- return this.api.disconnect();
14024
+ return _context8.a(2, _context8.v);
13517
14025
  case 4:
13518
- return _context7.f(3);
14026
+ _context8.p = 4;
14027
+ _context8.n = 5;
14028
+ return this.api.disconnect();
13519
14029
  case 5:
13520
- return _context7.a(2);
14030
+ return _context8.f(4);
14031
+ case 6:
14032
+ return _context8.a(2);
13521
14033
  }
13522
- }, _callee7, this, [[1,, 3, 5]]);
14034
+ }, _callee8, this, [[2,, 4, 6]]);
13523
14035
  }));
13524
- function getXcmFee$1(_x6) {
14036
+ function getXcmFee$1(_x7) {
13525
14037
  return _getXcmFee2.apply(this, arguments);
13526
14038
  }
13527
14039
  return getXcmFee$1;
@@ -13535,31 +14047,38 @@ var GeneralBuilder = /*#__PURE__*/function () {
13535
14047
  }, {
13536
14048
  key: "getOriginXcmFee",
13537
14049
  value: (function () {
13538
- var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
14050
+ var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
13539
14051
  var _ref,
13540
14052
  disableFallback,
13541
- _this$_options3,
14053
+ _yield$this$prepareNo3,
14054
+ normalizedOptions,
14055
+ buildTx,
14056
+ api,
13542
14057
  from,
13543
14058
  to,
13544
14059
  senderAddress,
13545
14060
  currency,
13546
14061
  feeAsset,
13547
- api,
13548
- _args8 = arguments;
13549
- return _regenerator().w(function (_context8) {
13550
- while (1) switch (_context8.p = _context8.n) {
14062
+ _args9 = arguments;
14063
+ return _regenerator().w(function (_context9) {
14064
+ while (1) switch (_context9.p = _context9.n) {
13551
14065
  case 0:
13552
- _ref = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {
14066
+ _ref = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {
13553
14067
  disableFallback: false
13554
14068
  }, disableFallback = _ref.disableFallback;
13555
- _this$_options3 = this._options, from = _this$_options3.from, to = _this$_options3.to, senderAddress = _this$_options3.senderAddress, currency = _this$_options3.currency, feeAsset = _this$_options3.feeAsset;
14069
+ _context9.n = 1;
14070
+ return this.prepareNormalizedOptions(this._options);
14071
+ case 1:
14072
+ _yield$this$prepareNo3 = _context9.v;
14073
+ normalizedOptions = _yield$this$prepareNo3.normalizedOptions;
14074
+ buildTx = _yield$this$prepareNo3.buildTx;
14075
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset;
13556
14076
  assertToIsString(to);
13557
- api = this.api;
13558
- _context8.p = 1;
13559
- _context8.n = 2;
14077
+ _context9.p = 2;
14078
+ _context9.n = 3;
13560
14079
  return getOriginXcmFee({
13561
14080
  api: api,
13562
- buildTx: this.createTxFactory(),
14081
+ buildTx: buildTx,
13563
14082
  origin: from,
13564
14083
  destination: to,
13565
14084
  senderAddress: senderAddress,
@@ -13567,18 +14086,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
13567
14086
  feeAsset: feeAsset,
13568
14087
  disableFallback: disableFallback
13569
14088
  });
13570
- case 2:
13571
- return _context8.a(2, _context8.v);
13572
14089
  case 3:
13573
- _context8.p = 3;
13574
- _context8.n = 4;
13575
- return this.api.disconnect();
14090
+ return _context9.a(2, _context9.v);
13576
14091
  case 4:
13577
- return _context8.f(3);
14092
+ _context9.p = 4;
14093
+ _context9.n = 5;
14094
+ return this.api.disconnect();
13578
14095
  case 5:
13579
- return _context8.a(2);
14096
+ return _context9.f(4);
14097
+ case 6:
14098
+ return _context9.a(2);
13580
14099
  }
13581
- }, _callee8, this, [[1,, 3, 5]]);
14100
+ }, _callee9, this, [[2,, 4, 6]]);
13582
14101
  }));
13583
14102
  function getOriginXcmFee$1() {
13584
14103
  return _getOriginXcmFee2.apply(this, arguments);
@@ -13594,22 +14113,28 @@ var GeneralBuilder = /*#__PURE__*/function () {
13594
14113
  }, {
13595
14114
  key: "getXcmFeeEstimate",
13596
14115
  value: (function () {
13597
- var _getXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
13598
- var _this$_options4, from, to, address, senderAddress, currency, tx;
13599
- return _regenerator().w(function (_context9) {
13600
- while (1) switch (_context9.p = _context9.n) {
14116
+ var _getXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
14117
+ var _yield$this$prepareNo4, normalizedOptions, buildTx, api, from, to, address, senderAddress, currency, tx;
14118
+ return _regenerator().w(function (_context0) {
14119
+ while (1) switch (_context0.p = _context0.n) {
13601
14120
  case 0:
13602
- _this$_options4 = this._options, from = _this$_options4.from, to = _this$_options4.to, address = _this$_options4.address, senderAddress = _this$_options4.senderAddress, currency = _this$_options4.currency;
14121
+ _context0.n = 1;
14122
+ return this.prepareNormalizedOptions(this._options);
14123
+ case 1:
14124
+ _yield$this$prepareNo4 = _context0.v;
14125
+ normalizedOptions = _yield$this$prepareNo4.normalizedOptions;
14126
+ buildTx = _yield$this$prepareNo4.buildTx;
14127
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency;
13603
14128
  assertToIsString(to);
13604
14129
  assertAddressIsString(address);
13605
- _context9.n = 1;
13606
- return this.buildInternal();
13607
- case 1:
13608
- tx = _context9.v;
13609
- _context9.p = 2;
13610
- _context9.n = 3;
14130
+ _context0.n = 2;
14131
+ return buildTx();
14132
+ case 2:
14133
+ tx = _context0.v;
14134
+ _context0.p = 3;
14135
+ _context0.n = 4;
13611
14136
  return getXcmFeeEstimate({
13612
- api: this.api,
14137
+ api: api,
13613
14138
  tx: tx,
13614
14139
  origin: from,
13615
14140
  destination: to,
@@ -13617,18 +14142,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
13617
14142
  senderAddress: senderAddress,
13618
14143
  currency: currency
13619
14144
  });
13620
- case 3:
13621
- return _context9.a(2, _context9.v);
13622
14145
  case 4:
13623
- _context9.p = 4;
13624
- _context9.n = 5;
13625
- return this.api.disconnect();
14146
+ return _context0.a(2, _context0.v);
13626
14147
  case 5:
13627
- return _context9.f(4);
14148
+ _context0.p = 5;
14149
+ _context0.n = 6;
14150
+ return this.api.disconnect();
13628
14151
  case 6:
13629
- return _context9.a(2);
14152
+ return _context0.f(5);
14153
+ case 7:
14154
+ return _context0.a(2);
13630
14155
  }
13631
- }, _callee9, this, [[2,, 4, 6]]);
14156
+ }, _callee0, this, [[3,, 5, 7]]);
13632
14157
  }));
13633
14158
  function getXcmFeeEstimate$1() {
13634
14159
  return _getXcmFeeEstimate2.apply(this, arguments);
@@ -13644,39 +14169,45 @@ var GeneralBuilder = /*#__PURE__*/function () {
13644
14169
  }, {
13645
14170
  key: "getOriginXcmFeeEstimate",
13646
14171
  value: (function () {
13647
- var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
13648
- var _this$_options5, from, to, senderAddress, currency, tx;
13649
- return _regenerator().w(function (_context0) {
13650
- while (1) switch (_context0.p = _context0.n) {
14172
+ var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
14173
+ var _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, senderAddress, currency, tx;
14174
+ return _regenerator().w(function (_context1) {
14175
+ while (1) switch (_context1.p = _context1.n) {
13651
14176
  case 0:
13652
- _this$_options5 = this._options, from = _this$_options5.from, to = _this$_options5.to, senderAddress = _this$_options5.senderAddress, currency = _this$_options5.currency;
13653
- assertToIsString(to);
13654
- _context0.n = 1;
13655
- return this.buildInternal();
14177
+ _context1.n = 1;
14178
+ return this.prepareNormalizedOptions(this._options);
13656
14179
  case 1:
13657
- tx = _context0.v;
13658
- _context0.p = 2;
13659
- _context0.n = 3;
14180
+ _yield$this$prepareNo5 = _context1.v;
14181
+ normalizedOptions = _yield$this$prepareNo5.normalizedOptions;
14182
+ buildTx = _yield$this$prepareNo5.buildTx;
14183
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency;
14184
+ assertToIsString(to);
14185
+ _context1.n = 2;
14186
+ return buildTx();
14187
+ case 2:
14188
+ tx = _context1.v;
14189
+ _context1.p = 3;
14190
+ _context1.n = 4;
13660
14191
  return getOriginXcmFeeEstimate({
13661
- api: this.api,
14192
+ api: api,
13662
14193
  tx: tx,
13663
14194
  origin: from,
13664
14195
  destination: to,
13665
14196
  currency: currency,
13666
14197
  senderAddress: senderAddress
13667
14198
  });
13668
- case 3:
13669
- return _context0.a(2, _context0.v);
13670
14199
  case 4:
13671
- _context0.p = 4;
13672
- _context0.n = 5;
13673
- return this.api.disconnect();
14200
+ return _context1.a(2, _context1.v);
13674
14201
  case 5:
13675
- return _context0.f(4);
14202
+ _context1.p = 5;
14203
+ _context1.n = 6;
14204
+ return this.api.disconnect();
13676
14205
  case 6:
13677
- return _context0.a(2);
14206
+ return _context1.f(5);
14207
+ case 7:
14208
+ return _context1.a(2);
13678
14209
  }
13679
- }, _callee0, this, [[2,, 4, 6]]);
14210
+ }, _callee1, this, [[3,, 5, 7]]);
13680
14211
  }));
13681
14212
  function getOriginXcmFeeEstimate$1() {
13682
14213
  return _getOriginXcmFeeEstimate2.apply(this, arguments);
@@ -13692,17 +14223,22 @@ var GeneralBuilder = /*#__PURE__*/function () {
13692
14223
  }, {
13693
14224
  key: "getTransferableAmount",
13694
14225
  value: (function () {
13695
- var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
13696
- var _this$_options6, from, to, senderAddress, currency, feeAsset, api;
13697
- return _regenerator().w(function (_context1) {
13698
- while (1) switch (_context1.n) {
14226
+ var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
14227
+ var _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, senderAddress, currency, feeAsset;
14228
+ return _regenerator().w(function (_context10) {
14229
+ while (1) switch (_context10.n) {
13699
14230
  case 0:
13700
- _this$_options6 = this._options, from = _this$_options6.from, to = _this$_options6.to, senderAddress = _this$_options6.senderAddress, currency = _this$_options6.currency, feeAsset = _this$_options6.feeAsset;
14231
+ _context10.n = 1;
14232
+ return this.prepareNormalizedOptions(this._options);
14233
+ case 1:
14234
+ _yield$this$prepareNo6 = _context10.v;
14235
+ normalizedOptions = _yield$this$prepareNo6.normalizedOptions;
14236
+ buildTx = _yield$this$prepareNo6.buildTx;
14237
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset;
13701
14238
  assertToIsString(to);
13702
- api = this.api;
13703
- return _context1.a(2, getTransferableAmount({
14239
+ return _context10.a(2, getTransferableAmount({
13704
14240
  api: api,
13705
- buildTx: this.createTxFactory(),
14241
+ buildTx: buildTx,
13706
14242
  origin: from,
13707
14243
  destination: to,
13708
14244
  senderAddress: senderAddress,
@@ -13710,7 +14246,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13710
14246
  currency: currency
13711
14247
  }));
13712
14248
  }
13713
- }, _callee1, this);
14249
+ }, _callee10, this);
13714
14250
  }));
13715
14251
  function getTransferableAmount$1() {
13716
14252
  return _getTransferableAmount2.apply(this, arguments);
@@ -13726,18 +14262,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
13726
14262
  }, {
13727
14263
  key: "getMinTransferableAmount",
13728
14264
  value: (function () {
13729
- var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
13730
- var _this$_options7, from, to, senderAddress, address, currency, feeAsset, api;
13731
- return _regenerator().w(function (_context10) {
13732
- while (1) switch (_context10.n) {
14265
+ var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
14266
+ var _yield$this$prepareNo7, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset;
14267
+ return _regenerator().w(function (_context11) {
14268
+ while (1) switch (_context11.n) {
13733
14269
  case 0:
13734
- _this$_options7 = this._options, from = _this$_options7.from, to = _this$_options7.to, senderAddress = _this$_options7.senderAddress, address = _this$_options7.address, currency = _this$_options7.currency, feeAsset = _this$_options7.feeAsset;
14270
+ _context11.n = 1;
14271
+ return this.prepareNormalizedOptions(this._options);
14272
+ case 1:
14273
+ _yield$this$prepareNo7 = _context11.v;
14274
+ normalizedOptions = _yield$this$prepareNo7.normalizedOptions;
14275
+ buildTx = _yield$this$prepareNo7.buildTx;
14276
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset;
13735
14277
  assertToIsString(to);
13736
14278
  assertAddressIsString(address);
13737
- api = this.api;
13738
- return _context10.a(2, getMinTransferableAmount({
14279
+ return _context11.a(2, getMinTransferableAmount({
13739
14280
  api: api,
13740
- buildTx: this.createTxFactory(),
14281
+ buildTx: buildTx,
13741
14282
  origin: from,
13742
14283
  destination: to,
13743
14284
  senderAddress: senderAddress,
@@ -13747,7 +14288,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13747
14288
  builder: this
13748
14289
  }));
13749
14290
  }
13750
- }, _callee10, this);
14291
+ }, _callee11, this);
13751
14292
  }));
13752
14293
  function getMinTransferableAmount$1() {
13753
14294
  return _getMinTransferableAmount2.apply(this, arguments);
@@ -13763,17 +14304,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
13763
14304
  }, {
13764
14305
  key: "verifyEdOnDestination",
13765
14306
  value: (function () {
13766
- var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
13767
- var _this$_options8, from, to, address, currency, senderAddress, feeAsset;
13768
- return _regenerator().w(function (_context11) {
13769
- while (1) switch (_context11.n) {
14307
+ var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
14308
+ var _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, address, currency, senderAddress, feeAsset;
14309
+ return _regenerator().w(function (_context12) {
14310
+ while (1) switch (_context12.n) {
13770
14311
  case 0:
13771
- _this$_options8 = this._options, from = _this$_options8.from, to = _this$_options8.to, address = _this$_options8.address, currency = _this$_options8.currency, senderAddress = _this$_options8.senderAddress, feeAsset = _this$_options8.feeAsset;
14312
+ _context12.n = 1;
14313
+ return this.prepareNormalizedOptions(this._options);
14314
+ case 1:
14315
+ _yield$this$prepareNo8 = _context12.v;
14316
+ normalizedOptions = _yield$this$prepareNo8.normalizedOptions;
14317
+ buildTx = _yield$this$prepareNo8.buildTx;
14318
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, currency = normalizedOptions.currency, senderAddress = normalizedOptions.senderAddress, feeAsset = normalizedOptions.feeAsset;
13772
14319
  assertToIsString(to);
13773
14320
  assertAddressIsString(address);
13774
- return _context11.a(2, verifyEdOnDestination({
13775
- api: this.api,
13776
- buildTx: this.createTxFactory(),
14321
+ return _context12.a(2, verifyEdOnDestination({
14322
+ api: api,
14323
+ buildTx: buildTx,
13777
14324
  origin: from,
13778
14325
  destination: to,
13779
14326
  address: address,
@@ -13782,7 +14329,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13782
14329
  currency: currency
13783
14330
  }));
13784
14331
  }
13785
- }, _callee11, this);
14332
+ }, _callee12, this);
13786
14333
  }));
13787
14334
  function verifyEdOnDestination$1() {
13788
14335
  return _verifyEdOnDestination2.apply(this, arguments);
@@ -13798,17 +14345,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
13798
14345
  }, {
13799
14346
  key: "getTransferInfo",
13800
14347
  value: (function () {
13801
- var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
13802
- var _this$_options9, from, to, address, currency, ahAddress, senderAddress, feeAsset;
13803
- return _regenerator().w(function (_context12) {
13804
- while (1) switch (_context12.n) {
14348
+ var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
14349
+ var _yield$this$prepareNo9, normalizedOptions, buildTx, api, from, to, address, currency, ahAddress, senderAddress, feeAsset;
14350
+ return _regenerator().w(function (_context13) {
14351
+ while (1) switch (_context13.n) {
13805
14352
  case 0:
13806
- _this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, ahAddress = _this$_options9.ahAddress, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
14353
+ _context13.n = 1;
14354
+ return this.prepareNormalizedOptions(this._options);
14355
+ case 1:
14356
+ _yield$this$prepareNo9 = _context13.v;
14357
+ normalizedOptions = _yield$this$prepareNo9.normalizedOptions;
14358
+ buildTx = _yield$this$prepareNo9.buildTx;
14359
+ api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, currency = normalizedOptions.currency, ahAddress = normalizedOptions.ahAddress, senderAddress = normalizedOptions.senderAddress, feeAsset = normalizedOptions.feeAsset;
13807
14360
  assertToIsString(to);
13808
14361
  assertAddressIsString(address);
13809
- return _context12.a(2, getTransferInfo({
13810
- api: this.api,
13811
- buildTx: this.createTxFactory(),
14362
+ return _context13.a(2, getTransferInfo({
14363
+ api: api,
14364
+ buildTx: buildTx,
13812
14365
  origin: from,
13813
14366
  destination: to,
13814
14367
  address: address,
@@ -13818,7 +14371,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13818
14371
  feeAsset: feeAsset
13819
14372
  }));
13820
14373
  }
13821
- }, _callee12, this);
14374
+ }, _callee13, this);
13822
14375
  }));
13823
14376
  function getTransferInfo$1() {
13824
14377
  return _getTransferInfo2.apply(this, arguments);