@paraspell/sdk 7.0.1 → 7.1.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
@@ -492,8 +492,8 @@ function _superPropBase(t, o) {
492
492
  return t;
493
493
  }
494
494
  function _superPropGet(t, o, e, r) {
495
- var p = _get(_getPrototypeOf(t.prototype ), o, e);
496
- return "function" == typeof p ? function (t) {
495
+ var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);
496
+ return 2 & r && "function" == typeof p ? function (t) {
497
497
  return p.apply(e, t);
498
498
  } : p;
499
499
  }
@@ -504,11 +504,11 @@ function _toPrimitive(t, r) {
504
504
  if ("object" != typeof t || !t) return t;
505
505
  var e = t[Symbol.toPrimitive];
506
506
  if (void 0 !== e) {
507
- var i = e.call(t, r);
507
+ var i = e.call(t, r || "default");
508
508
  if ("object" != typeof i) return i;
509
509
  throw new TypeError("@@toPrimitive must return a primitive value.");
510
510
  }
511
- return (String )(t);
511
+ return ("string" === r ? String : Number)(t);
512
512
  }
513
513
  function _toPropertyKey(t) {
514
514
  var i = _toPrimitive(t, "string");
@@ -8615,6 +8615,14 @@ var findParachainJunction = function findParachainJunction(multilocation) {
8615
8615
  };
8616
8616
 
8617
8617
  var DEFAULT_FEE_ASSET = 0;
8618
+ var ETH_CHAIN_ID = BigInt(1);
8619
+ var ETHEREUM_JUNCTION = {
8620
+ GlobalConsensus: {
8621
+ Ethereum: {
8622
+ chain_id: ETH_CHAIN_ID
8623
+ }
8624
+ }
8625
+ };
8618
8626
 
8619
8627
  var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
8620
8628
  var api = _ref.api,
@@ -8772,82 +8780,103 @@ var ParachainNode = /*#__PURE__*/function () {
8772
8780
  }, {
8773
8781
  key: "transfer",
8774
8782
  value: function transfer(options) {
8775
- var api = options.api,
8776
- currencySymbol = options.currencySymbol,
8777
- currencyId = options.currencyId,
8778
- amount = options.amount,
8779
- address = options.address,
8780
- destination = options.destination,
8781
- paraIdTo = options.paraIdTo,
8782
- overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
8783
- feeAsset = options.feeAsset,
8784
- _options$version = options.version,
8785
- version = _options$version === void 0 ? this.version : _options$version,
8786
- _options$serializedAp = options.serializedApiCallEnabled,
8787
- serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
8788
- var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
8789
- var paraId = destination !== undefined && _typeof(destination) !== 'object' && destination !== 'Ethereum' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
8790
- if (destination === 'Polimec' && this.node !== 'AssetHubPolkadot') {
8791
- throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
8792
- }
8793
- if (supportsXTokens(this) && this.canUseXTokens(options)) {
8794
- return this.transferXTokens({
8795
- api: api,
8796
- currency: currencySymbol,
8797
- currencyID: currencyId,
8798
- amount: amount,
8799
- addressSelection: generateAddressPayload(api, scenario, 'XTokens', address, version, paraId),
8800
- fees: getFees(scenario),
8801
- origin: this.node,
8802
- scenario: scenario,
8803
- paraIdTo: paraId,
8804
- destination: destination,
8805
- overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
8806
- feeAsset: feeAsset,
8807
- serializedApiCallEnabled: serializedApiCallEnabled
8808
- });
8809
- } else if (supportsXTransfer(this)) {
8810
- return this.transferXTransfer({
8811
- api: api,
8812
- currency: currencySymbol,
8813
- currencyID: currencyId,
8814
- amount: amount,
8815
- recipientAddress: address,
8816
- paraId: paraId,
8817
- origin: this.node,
8818
- destination: destination,
8819
- overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
8820
- serializedApiCallEnabled: serializedApiCallEnabled
8821
- });
8822
- } else if (supportsPolkadotXCM(this)) {
8823
- if (isTMultiLocation(overridedCurrencyMultiLocation) && !verifyMultiLocation(this.node, overridedCurrencyMultiLocation)) {
8824
- throw new InvalidCurrencyError('Provided Multi-location is not a valid currency.');
8825
- }
8826
- return this.transferPolkadotXCM({
8827
- api: api,
8828
- header: this.createPolkadotXcmHeader(scenario, version, destination, paraId),
8829
- addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, paraId),
8830
- address: address,
8831
- amount: amount,
8832
- currencySelection: this.createCurrencySpec(amount, scenario, version, currencyId, overridedCurrencyMultiLocation),
8833
- currencyId: currencyId,
8834
- scenario: scenario,
8835
- currencySymbol: currencySymbol,
8836
- feeAsset: feeAsset,
8837
- destination: destination,
8838
- paraIdTo: paraId,
8839
- overridedCurrency: overridedCurrencyMultiLocation,
8840
- serializedApiCallEnabled: serializedApiCallEnabled
8841
- });
8842
- } else {
8843
- throw new NoXCMSupportImplementedError(this._node);
8844
- }
8783
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8784
+ var api, currencySymbol, currencyId, amount, address, destination, paraIdTo, overridedCurrencyMultiLocation, feeAsset, version, ahAddress, _options$serializedAp, serializedApiCallEnabled, scenario, paraId, versionOrDefault;
8785
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8786
+ while (1) switch (_context.prev = _context.next) {
8787
+ case 0:
8788
+ api = options.api, currencySymbol = options.currencySymbol, currencyId = options.currencyId, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation, feeAsset = options.feeAsset, version = options.version, ahAddress = options.ahAddress, _options$serializedAp = options.serializedApiCallEnabled, serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
8789
+ scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
8790
+ paraId = destination !== undefined && _typeof(destination) !== 'object' && destination !== 'Ethereum' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
8791
+ if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
8792
+ _context.next = 5;
8793
+ break;
8794
+ }
8795
+ throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
8796
+ case 5:
8797
+ versionOrDefault = version !== null && version !== void 0 ? version : this.version;
8798
+ if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
8799
+ _context.next = 10;
8800
+ break;
8801
+ }
8802
+ return _context.abrupt("return", this.transferXTokens({
8803
+ api: api,
8804
+ currency: currencySymbol,
8805
+ currencyID: currencyId,
8806
+ amount: amount,
8807
+ addressSelection: generateAddressPayload(api, scenario, 'XTokens', address, versionOrDefault, paraId),
8808
+ fees: getFees(scenario),
8809
+ origin: this.node,
8810
+ scenario: scenario,
8811
+ paraIdTo: paraId,
8812
+ destination: destination,
8813
+ overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
8814
+ feeAsset: feeAsset,
8815
+ serializedApiCallEnabled: serializedApiCallEnabled
8816
+ }));
8817
+ case 10:
8818
+ if (!supportsXTransfer(this)) {
8819
+ _context.next = 14;
8820
+ break;
8821
+ }
8822
+ return _context.abrupt("return", this.transferXTransfer({
8823
+ api: api,
8824
+ currency: currencySymbol,
8825
+ currencyID: currencyId,
8826
+ amount: amount,
8827
+ recipientAddress: address,
8828
+ paraId: paraId,
8829
+ origin: this.node,
8830
+ destination: destination,
8831
+ overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
8832
+ serializedApiCallEnabled: serializedApiCallEnabled
8833
+ }));
8834
+ case 14:
8835
+ if (!supportsPolkadotXCM(this)) {
8836
+ _context.next = 22;
8837
+ break;
8838
+ }
8839
+ if (!(isTMultiLocation(overridedCurrencyMultiLocation) && !verifyMultiLocation(this.node, overridedCurrencyMultiLocation))) {
8840
+ _context.next = 17;
8841
+ break;
8842
+ }
8843
+ throw new InvalidCurrencyError('Provided Multi-location is not a valid currency.');
8844
+ case 17:
8845
+ _context.next = 19;
8846
+ return this.transferPolkadotXCM({
8847
+ api: api,
8848
+ header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraId),
8849
+ addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraId),
8850
+ address: address,
8851
+ amount: amount,
8852
+ currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrencyMultiLocation),
8853
+ currencyId: currencyId,
8854
+ scenario: scenario,
8855
+ currencySymbol: currencySymbol,
8856
+ feeAsset: feeAsset,
8857
+ destination: destination,
8858
+ paraIdTo: paraId,
8859
+ overridedCurrency: overridedCurrencyMultiLocation,
8860
+ serializedApiCallEnabled: serializedApiCallEnabled,
8861
+ version: version,
8862
+ ahAddress: ahAddress
8863
+ });
8864
+ case 19:
8865
+ return _context.abrupt("return", _context.sent);
8866
+ case 22:
8867
+ throw new NoXCMSupportImplementedError(this._node);
8868
+ case 23:
8869
+ case "end":
8870
+ return _context.stop();
8871
+ }
8872
+ }, _callee, this);
8873
+ }));
8845
8874
  }
8846
8875
  }, {
8847
8876
  key: "transferRelayToPara",
8848
8877
  value: function transferRelayToPara(options) {
8849
- var _options$version2 = options.version,
8850
- version = _options$version2 === void 0 ? Version.V3 : _options$version2;
8878
+ var _options$version = options.version,
8879
+ version = _options$version === void 0 ? Version.V3 : _options$version;
8851
8880
  return {
8852
8881
  module: 'XcmPallet',
8853
8882
  section: 'reserve_transfer_assets',
@@ -8862,21 +8891,21 @@ var ParachainNode = /*#__PURE__*/function () {
8862
8891
  }, {
8863
8892
  key: "createApiInstance",
8864
8893
  value: function createApiInstance(api) {
8865
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8866
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8867
- while (1) switch (_context.prev = _context.next) {
8894
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
8895
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8896
+ while (1) switch (_context2.prev = _context2.next) {
8868
8897
  case 0:
8869
- return _context.abrupt("return", api.createApiInstance(this.getProvider()));
8898
+ return _context2.abrupt("return", api.createApiInstance(this.getProvider()));
8870
8899
  case 1:
8871
8900
  case "end":
8872
- return _context.stop();
8901
+ return _context2.stop();
8873
8902
  }
8874
- }, _callee, this);
8903
+ }, _callee2, this);
8875
8904
  }));
8876
8905
  }
8877
8906
  }, {
8878
8907
  key: "createCurrencySpec",
8879
- value: function createCurrencySpec$1(amount, scenario, version, _, overridedMultiLocation) {
8908
+ value: function createCurrencySpec$1(amount, scenario, version, _currencyId, overridedMultiLocation) {
8880
8909
  return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO, overridedMultiLocation);
8881
8910
  }
8882
8911
  }, {
@@ -8960,6 +8989,7 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
8960
8989
  value: function transferXTokens(input, currencySelection) {
8961
8990
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
8962
8991
  var api = input.api,
8992
+ origin = input.origin,
8963
8993
  amount = input.amount,
8964
8994
  addressSelection = input.addressSelection,
8965
8995
  destination = input.destination,
@@ -8969,10 +8999,12 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
8969
8999
  if (isMultiLocationDestination) {
8970
9000
  throw new Error('Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.');
8971
9001
  }
8972
- var isAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
8973
- var modifiedCurrencySelection = getCurrencySelection(input, isAssetHub, currencySelection);
8974
- var section = isAssetHub ? feeAsset ? 'transfer_multiassets' : 'transfer_multiasset' : 'transfer';
8975
- var parameters = getXTokensParameters(isAssetHub, modifiedCurrencySelection, addressSelection, amount, fees, feeAsset);
9002
+ var isBifrostOrigin = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
9003
+ var isAssetHubDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
9004
+ var shouldUseMultiasset = isAssetHubDest && !isBifrostOrigin;
9005
+ var modifiedCurrencySelection = getCurrencySelection(input, shouldUseMultiasset, currencySelection);
9006
+ var section = shouldUseMultiasset ? feeAsset ? 'transfer_multiassets' : 'transfer_multiasset' : 'transfer';
9007
+ var parameters = getXTokensParameters(shouldUseMultiasset, modifiedCurrencySelection, addressSelection, amount, fees, feeAsset);
8976
9008
  var call = {
8977
9009
  module: 'XTokens',
8978
9010
  section: section,
@@ -9156,23 +9188,15 @@ var BifrostPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9156
9188
  var amount = input.amount,
9157
9189
  overridedCurrency = input.overridedCurrency,
9158
9190
  currencySymbol = input.currencySymbol;
9159
- var ETH_CHAIN_ID = BigInt(1);
9160
- var ethJunction = {
9161
- GlobalConsensus: {
9162
- Ethereum: {
9163
- chain_id: ETH_CHAIN_ID
9164
- }
9165
- }
9166
- };
9167
- return PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
9191
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
9168
9192
  currencySelection: createCurrencySpec(amount, this.version, currencySymbol === 'DOT' ? Parents.ONE : Parents.TWO, overridedCurrency, currencySymbol === 'WETH' ? {
9169
- X2: [ethJunction, {
9193
+ X2: [ETHEREUM_JUNCTION, {
9170
9194
  AccountKey20: {
9171
9195
  key: (_a = getAssetId('Ethereum', 'WETH')) !== null && _a !== void 0 ? _a : ''
9172
9196
  }
9173
9197
  }]
9174
9198
  } : undefined)
9175
- }), 'transfer_assets', 'Unlimited');
9199
+ }), 'transfer_assets', 'Unlimited'));
9176
9200
  }
9177
9201
  }, {
9178
9202
  key: "canUseXTokens",
@@ -9227,6 +9251,134 @@ var ComposableFinance$2 = /*#__PURE__*/function (_ParachainNode) {
9227
9251
  }]);
9228
9252
  }(ParachainNode);
9229
9253
 
9254
+ var calculateFee = function calculateFee(api) {
9255
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9256
+ var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
9257
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
9258
+ while (1) switch (_context.prev = _context.next) {
9259
+ case 0:
9260
+ DEFAULT_FEE = BigInt(2750872500000);
9261
+ _context.next = 3;
9262
+ return api.createApiForNode('AssetHubPolkadot');
9263
+ case 3:
9264
+ ahApi = _context.sent;
9265
+ _context.next = 6;
9266
+ return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
9267
+ case 6:
9268
+ feeStorageItem = _context.sent;
9269
+ leFeeHex = feeStorageItem.replace('0x', '');
9270
+ leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
9271
+ transfer_bridge_fee = leFee === BigInt(0) ? DEFAULT_FEE : BigInt(leFee.toString());
9272
+ transfer_assethub_execution_fee = BigInt(2200000000);
9273
+ return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
9274
+ case 12:
9275
+ case "end":
9276
+ return _context.stop();
9277
+ }
9278
+ }, _callee);
9279
+ }));
9280
+ };
9281
+ var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
9282
+ return {
9283
+ parents: Parents.TWO,
9284
+ interior: {
9285
+ X2: [ETHEREUM_JUNCTION, {
9286
+ AccountKey20: {
9287
+ key: currencyId
9288
+ }
9289
+ }]
9290
+ }
9291
+ };
9292
+ };
9293
+ var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
9294
+ var api = _ref.api,
9295
+ scenario = _ref.scenario,
9296
+ address = _ref.address;
9297
+ return _defineProperty({}, version, [{
9298
+ DepositAsset: {
9299
+ assets: {
9300
+ Wild: {
9301
+ AllCounted: 1
9302
+ }
9303
+ },
9304
+ beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
9305
+ }
9306
+ }]);
9307
+ };
9308
+ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref3, version) {
9309
+ var api = _ref3.api,
9310
+ address = _ref3.address,
9311
+ currencyId = _ref3.currencyId,
9312
+ scenario = _ref3.scenario,
9313
+ ahAddress = _ref3.ahAddress;
9314
+ return _defineProperty({}, version, [{
9315
+ SetAppendix: [{
9316
+ DepositAsset: {
9317
+ assets: {
9318
+ Wild: 'All'
9319
+ },
9320
+ beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', version, undefined))[0]
9321
+ }
9322
+ }]
9323
+ }, {
9324
+ InitiateReserveWithdraw: {
9325
+ assets: {
9326
+ Wild: {
9327
+ AllOf: {
9328
+ id: createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : ''),
9329
+ fun: 'Fungible'
9330
+ }
9331
+ }
9332
+ },
9333
+ reserve: {
9334
+ parents: Parents.TWO,
9335
+ interior: {
9336
+ X1: [ETHEREUM_JUNCTION]
9337
+ }
9338
+ },
9339
+ xcm: [{
9340
+ BuyExecution: {
9341
+ fees: {
9342
+ id: {
9343
+ parents: Parents.ZERO,
9344
+ interior: {
9345
+ X1: [{
9346
+ AccountKey20: {
9347
+ network: null,
9348
+ key: currencyId
9349
+ }
9350
+ }]
9351
+ }
9352
+ },
9353
+ fun: {
9354
+ Fungible: BigInt(1)
9355
+ }
9356
+ },
9357
+ weight_limit: 'Unlimited'
9358
+ }
9359
+ }, {
9360
+ DepositAsset: {
9361
+ assets: {
9362
+ Wild: {
9363
+ AllCounted: 1
9364
+ }
9365
+ },
9366
+ beneficiary: {
9367
+ parents: Parents.ZERO,
9368
+ interior: {
9369
+ X1: [{
9370
+ AccountKey20: {
9371
+ network: null,
9372
+ key: address
9373
+ }
9374
+ }]
9375
+ }
9376
+ }
9377
+ }
9378
+ }]
9379
+ }
9380
+ }]);
9381
+ };
9230
9382
  var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
9231
9383
  function Hydration() {
9232
9384
  _classCallCheck(this, Hydration);
@@ -9234,11 +9386,133 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
9234
9386
  }
9235
9387
  _inherits(Hydration, _ParachainNode);
9236
9388
  return _createClass(Hydration, [{
9389
+ key: "transferToEthereum",
9390
+ value: function transferToEthereum(input) {
9391
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
9392
+ var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
9393
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
9394
+ while (1) switch (_context2.prev = _context2.next) {
9395
+ case 0:
9396
+ api = input.api, address = input.address, currencySymbol = input.currencySymbol, scenario = input.scenario, version = input.version, destination = input.destination, amount = input.amount, currencyId = input.currencyId, ahAddress = input.ahAddress;
9397
+ if (ethers.isAddress(address)) {
9398
+ _context2.next = 3;
9399
+ break;
9400
+ }
9401
+ throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
9402
+ case 3:
9403
+ if (!((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) !== 'WETH')) {
9404
+ _context2.next = 5;
9405
+ break;
9406
+ }
9407
+ throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers from Hydration"));
9408
+ case 5:
9409
+ if (!(ahAddress === undefined)) {
9410
+ _context2.next = 7;
9411
+ break;
9412
+ }
9413
+ throw new Error('AssetHub address is required for Ethereum transfers');
9414
+ case 7:
9415
+ versionOrDefault = version !== null && version !== void 0 ? version : Version.V4;
9416
+ ethMultiAsset = Object.values(createCurrencySpec(amount, versionOrDefault, Parents.TWO, createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')))[0][0];
9417
+ _context2.next = 11;
9418
+ return calculateFee(api);
9419
+ case 11:
9420
+ fee = _context2.sent;
9421
+ call = {
9422
+ module: 'PolkadotXcm',
9423
+ section: 'transfer_assets_using_type_and_then',
9424
+ parameters: {
9425
+ dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
9426
+ assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
9427
+ assets_transfer_type: 'DestinationReserve',
9428
+ remote_fees_id: _defineProperty({}, versionOrDefault, {
9429
+ parents: Parents.ONE,
9430
+ interior: 'Here'
9431
+ }),
9432
+ fees_transfer_type: 'DestinationReserve',
9433
+ custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
9434
+ weight_limit: 'Unlimited'
9435
+ }
9436
+ };
9437
+ return _context2.abrupt("return", api.callTxMethod(call));
9438
+ case 14:
9439
+ case "end":
9440
+ return _context2.stop();
9441
+ }
9442
+ }, _callee2, this);
9443
+ }));
9444
+ }
9445
+ }, {
9446
+ key: "transferToAssetHub",
9447
+ value: function transferToAssetHub(input) {
9448
+ var api = input.api,
9449
+ scenario = input.scenario,
9450
+ version = input.version,
9451
+ destination = input.destination,
9452
+ amount = input.amount;
9453
+ var versionOrDefault = version !== null && version !== void 0 ? version : Version.V3;
9454
+ var call = {
9455
+ module: 'PolkadotXcm',
9456
+ section: 'transfer_assets_using_type_and_then',
9457
+ parameters: {
9458
+ dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
9459
+ assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(amount, 'ParaToRelay', versionOrDefault))[0][0]]),
9460
+ assets_transfer_type: 'DestinationReserve',
9461
+ remote_fees_id: _defineProperty({}, versionOrDefault, {
9462
+ Concrete: {
9463
+ parents: Parents.ONE,
9464
+ interior: 'Here'
9465
+ }
9466
+ }),
9467
+ fees_transfer_type: 'DestinationReserve',
9468
+ custom_xcm_on_dest: createCustomXcmAh(input, versionOrDefault),
9469
+ weight_limit: 'Unlimited'
9470
+ }
9471
+ };
9472
+ return api.callTxMethod(call);
9473
+ }
9474
+ // Handles WETH Ethereum transfers
9475
+ }, {
9476
+ key: "transferPolkadotXCM",
9477
+ value: function transferPolkadotXCM(input) {
9478
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
9479
+ var destination;
9480
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
9481
+ while (1) switch (_context3.prev = _context3.next) {
9482
+ case 0:
9483
+ destination = input.destination;
9484
+ if (!(destination === 'Ethereum')) {
9485
+ _context3.next = 3;
9486
+ break;
9487
+ }
9488
+ return _context3.abrupt("return", this.transferToEthereum(input));
9489
+ case 3:
9490
+ return _context3.abrupt("return", this.transferToAssetHub(input));
9491
+ case 4:
9492
+ case "end":
9493
+ return _context3.stop();
9494
+ }
9495
+ }, _callee3, this);
9496
+ }));
9497
+ }
9498
+ }, {
9237
9499
  key: "transferXTokens",
9238
9500
  value: function transferXTokens(input) {
9239
9501
  var currencyID = input.currencyID;
9240
9502
  return XTokensTransferImpl.transferXTokens(input, currencyID);
9241
9503
  }
9504
+ }, {
9505
+ key: "canUseXTokens",
9506
+ value: function canUseXTokens(_ref5) {
9507
+ var destination = _ref5.destination,
9508
+ currencySymbol = _ref5.currencySymbol,
9509
+ currencyId = _ref5.currencyId;
9510
+ var dotAsset = getOtherAssets(this.node).find(function (_ref6) {
9511
+ var symbol = _ref6.symbol;
9512
+ return symbol === 'DOT';
9513
+ });
9514
+ return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId)));
9515
+ }
9242
9516
  }]);
9243
9517
  }(ParachainNode);
9244
9518
 
@@ -9709,21 +9983,13 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9709
9983
  if (!ethAsset) {
9710
9984
  throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers"));
9711
9985
  }
9712
- var ETH_CHAIN_ID = BigInt(1);
9713
- var ethJunction = {
9714
- GlobalConsensus: {
9715
- Ethereum: {
9716
- chain_id: ETH_CHAIN_ID
9717
- }
9718
- }
9719
- };
9720
9986
  var modifiedInput = Object.assign(Object.assign({}, input), {
9721
- header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ethJunction, Parents.TWO),
9987
+ header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
9722
9988
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
9723
9989
  currencySelection: createCurrencySpec(input.amount, Version.V3, Parents.TWO, {
9724
9990
  parents: Parents.TWO,
9725
9991
  interior: {
9726
- X2: [ethJunction, {
9992
+ X2: [ETHEREUM_JUNCTION, {
9727
9993
  AccountKey20: {
9728
9994
  key: ethAsset.assetId
9729
9995
  }
@@ -9761,29 +10027,65 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9761
10027
  });
9762
10028
  return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'limited_teleport_assets', 'Unlimited');
9763
10029
  }
10030
+ }, {
10031
+ key: "patchInput",
10032
+ value: function patchInput(input) {
10033
+ var _a;
10034
+ var currencySymbol = input.currencySymbol,
10035
+ currencyId = input.currencyId,
10036
+ destination = input.destination,
10037
+ paraIdTo = input.paraIdTo,
10038
+ amount = input.amount,
10039
+ overridedCurrency = input.overridedCurrency,
10040
+ scenario = input.scenario,
10041
+ api = input.api,
10042
+ version = input.version,
10043
+ address = input.address;
10044
+ if (((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot') {
10045
+ var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : Version.V2;
10046
+ return Object.assign(Object.assign({}, input), {
10047
+ header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
10048
+ addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
10049
+ currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
10050
+ });
10051
+ }
10052
+ var dotAsset = getOtherAssets(this.node).find(function (_ref) {
10053
+ var symbol = _ref.symbol;
10054
+ return symbol === 'DOT';
10055
+ });
10056
+ if (destination === 'Hydration' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId))) {
10057
+ var _versionOrDefault = version !== null && version !== void 0 ? version : this.version;
10058
+ return Object.assign(Object.assign({}, input), {
10059
+ currencySelection: _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, 'ParaToRelay', _versionOrDefault, currencyId, overridedCurrency])
10060
+ });
10061
+ }
10062
+ return input;
10063
+ }
9764
10064
  }, {
9765
10065
  key: "transferPolkadotXCM",
9766
10066
  value: function transferPolkadotXCM(input) {
9767
10067
  var scenario = input.scenario,
9768
10068
  currencySymbol = input.currencySymbol,
9769
- currencyId = input.currencyId;
9770
- if (input.destination === 'AssetHubKusama') {
9771
- return this.handleBridgeTransfer(input, 'Kusama');
10069
+ currencyId = input.currencyId,
10070
+ destination = input.destination;
10071
+ if (destination === 'AssetHubKusama') {
10072
+ return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
9772
10073
  }
9773
- if (input.destination === 'Ethereum') {
9774
- return this.handleEthBridgeTransfer(input);
10074
+ if (destination === 'Ethereum') {
10075
+ return Promise.resolve(this.handleEthBridgeTransfer(input));
9775
10076
  }
9776
- if (input.destination === 'Mythos') {
9777
- return this.handleMythosTransfer(input);
10077
+ if (destination === 'Mythos') {
10078
+ return Promise.resolve(this.handleMythosTransfer(input));
9778
10079
  }
9779
- if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined) {
10080
+ if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined && destination !== 'Hydration') {
9780
10081
  throw new ScenarioNotSupportedError(this.node, scenario, 'Para to Para scenarios for DOT transfer from AssetHub are not supported, you have to transfer DOT to Relay chain and transfer to destination chain from Relay chain.');
9781
10082
  }
9782
10083
  if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
9783
10084
  throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
9784
10085
  }
9785
10086
  var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
9786
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10087
+ var modifiedInput = this.patchInput(input);
10088
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
9787
10089
  }
9788
10090
  }, {
9789
10091
  key: "transferRelayToPara",
@@ -9810,7 +10112,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9810
10112
  };
9811
10113
  return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
9812
10114
  } else {
9813
- return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10115
+ return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
9814
10116
  }
9815
10117
  }
9816
10118
  }]);
@@ -9832,7 +10134,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
9832
10134
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
9833
10135
  // TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
9834
10136
  if (destination === 'AssetHubPolkadot') {
9835
- return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
10137
+ return Promise.resolve(getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot'));
9836
10138
  }
9837
10139
  if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
9838
10140
  throw new ScenarioNotSupportedError(this.node, scenario, 'Para to Para scenarios for KSM transfer from AssetHub are not supported, you have to transfer KSM to Relay chain and transfer to destination chain from Relay chain.');
@@ -9841,7 +10143,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
9841
10143
  throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
9842
10144
  }
9843
10145
  var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
9844
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10146
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
9845
10147
  }
9846
10148
  }, {
9847
10149
  key: "transferRelayToPara",
@@ -9877,7 +10179,7 @@ var CoretimeKusama$2 = /*#__PURE__*/function (_ParachainNode) {
9877
10179
  // TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
9878
10180
  var scenario = input.scenario;
9879
10181
  var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
9880
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10182
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
9881
10183
  }
9882
10184
  }, {
9883
10185
  key: "transferRelayToPara",
@@ -9909,7 +10211,7 @@ var CoretimePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9909
10211
  value: function transferPolkadotXCM(input) {
9910
10212
  var scenario = input.scenario;
9911
10213
  var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
9912
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10214
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
9913
10215
  }
9914
10216
  }, {
9915
10217
  key: "transferRelayToPara",
@@ -9937,7 +10239,7 @@ var Encointer$2 = /*#__PURE__*/function (_ParachainNode) {
9937
10239
  // NO PARA TO PARA SCENARIOS ON SUBSCAN
9938
10240
  // TESTED https://encointer.subscan.io/xcm_message/kusama-418501e86e947b16c4e4e9040694017e64f9b162
9939
10241
  if (input.scenario === 'ParaToRelay') {
9940
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
10242
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
9941
10243
  }
9942
10244
  throw new ScenarioNotSupportedError(this.node, input.scenario);
9943
10245
  }
@@ -9964,7 +10266,7 @@ var RobonomicsKusama$2 = /*#__PURE__*/function (_ParachainNode) {
9964
10266
  return _createClass(RobonomicsKusama, [{
9965
10267
  key: "transferPolkadotXCM",
9966
10268
  value: function transferPolkadotXCM(input) {
9967
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
10269
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
9968
10270
  }
9969
10271
  }]);
9970
10272
  }(ParachainNode);
@@ -9978,7 +10280,7 @@ var RobonomicsPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9978
10280
  return _createClass(RobonomicsPolkadot, [{
9979
10281
  key: "transferPolkadotXCM",
9980
10282
  value: function transferPolkadotXCM(input) {
9981
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
10283
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
9982
10284
  }
9983
10285
  }]);
9984
10286
  }(ParachainNode);
@@ -9997,7 +10299,7 @@ var PeoplePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9997
10299
  throw new ScenarioNotSupportedError(this.node, scenario);
9998
10300
  }
9999
10301
  var section = 'limited_teleport_assets';
10000
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10302
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
10001
10303
  }
10002
10304
  }, {
10003
10305
  key: "transferRelayToPara",
@@ -10027,7 +10329,7 @@ var PeopleKusama$2 = /*#__PURE__*/function (_ParachainNode) {
10027
10329
  throw new ScenarioNotSupportedError(this.node, scenario);
10028
10330
  }
10029
10331
  var section = 'limited_teleport_assets';
10030
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10332
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
10031
10333
  }
10032
10334
  }, {
10033
10335
  key: "transferRelayToPara",
@@ -10054,7 +10356,7 @@ var Astar$2 = /*#__PURE__*/function (_ParachainNode) {
10054
10356
  value: function transferPolkadotXCM(input) {
10055
10357
  // TESTED https://polkadot.subscan.io/xcm_message/polkadot-f2b697df74ebe4b62853fe81b8b7d0522464972d
10056
10358
  var section = input.scenario === 'ParaToPara' ? 'reserve_transfer_assets' : 'reserve_withdraw_assets';
10057
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section);
10359
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section));
10058
10360
  }
10059
10361
  }, {
10060
10362
  key: "transferXTokens",
@@ -10103,7 +10405,7 @@ var Darwinia$2 = /*#__PURE__*/function (_ParachainNode) {
10103
10405
  };
10104
10406
  return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
10105
10407
  } else {
10106
- return _superPropGet(Darwinia, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10408
+ return _superPropGet(Darwinia, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId, overridedMultiLocation]);
10107
10409
  }
10108
10410
  }
10109
10411
  }, {
@@ -10126,7 +10428,7 @@ var Crab$2 = /*#__PURE__*/function (_ParachainNode) {
10126
10428
  value: function transferPolkadotXCM(input) {
10127
10429
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ce7396ec470ba0c6516a50075046ee65464572dc
10128
10430
  if (input.scenario === 'ParaToPara') {
10129
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
10431
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
10130
10432
  }
10131
10433
  throw new ScenarioNotSupportedError(this.node, input.scenario);
10132
10434
  }
@@ -10241,7 +10543,7 @@ var NeuroWeb$2 = /*#__PURE__*/function (_ParachainNode) {
10241
10543
  return _createClass(NeuroWeb, [{
10242
10544
  key: "transferPolkadotXCM",
10243
10545
  value: function transferPolkadotXCM(input) {
10244
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
10546
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
10245
10547
  }
10246
10548
  }]);
10247
10549
  }(ParachainNode);
@@ -10319,7 +10621,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
10319
10621
  if (scenario === 'ParaToPara') {
10320
10622
  throw new ScenarioNotSupportedError(this.node, scenario);
10321
10623
  }
10322
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
10624
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
10323
10625
  }
10324
10626
  }, {
10325
10627
  key: "transferRelayToPara",
@@ -10338,7 +10640,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
10338
10640
  if (scenario === 'ParaToPara') {
10339
10641
  return {};
10340
10642
  } else {
10341
- return _superPropGet(Collectives, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10643
+ return _superPropGet(Collectives, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
10342
10644
  }
10343
10645
  }
10344
10646
  }]);
@@ -10481,7 +10783,7 @@ var Subsocial$2 = /*#__PURE__*/function (_ParachainNode) {
10481
10783
  if (currencySymbol !== this.getNativeAssetSymbol()) {
10482
10784
  throw new InvalidCurrencyError("Asset ".concat(currencySymbol, " is not supported by node ").concat(this.node, "."));
10483
10785
  }
10484
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
10786
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
10485
10787
  }
10486
10788
  }]);
10487
10789
  }(ParachainNode);
@@ -10498,7 +10800,7 @@ var KiltSpiritnet$2 = /*#__PURE__*/function (_ParachainNode) {
10498
10800
  if (input.scenario !== 'ParaToPara') {
10499
10801
  throw new ScenarioNotSupportedError(this.node, input.scenario);
10500
10802
  }
10501
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
10803
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
10502
10804
  }
10503
10805
  }, {
10504
10806
  key: "transferRelayToPara",
@@ -10552,7 +10854,7 @@ var BridgeHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
10552
10854
  throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
10553
10855
  }
10554
10856
  var section = 'limited_teleport_assets';
10555
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10857
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
10556
10858
  }
10557
10859
  }, {
10558
10860
  key: "transferRelayToPara",
@@ -10585,7 +10887,7 @@ var BridgeHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
10585
10887
  throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
10586
10888
  }
10587
10889
  var section = 'limited_teleport_assets';
10588
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
10890
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
10589
10891
  }
10590
10892
  }, {
10591
10893
  key: "transferRelayToPara",
@@ -10629,7 +10931,7 @@ var Mythos$2 = /*#__PURE__*/function (_ParachainNode) {
10629
10931
  if (currencySymbol !== nativeSymbol) {
10630
10932
  throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency ").concat(currencySymbol));
10631
10933
  }
10632
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited');
10934
+ return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited'));
10633
10935
  }
10634
10936
  }, {
10635
10937
  key: "transferRelayToPara",
@@ -12281,8 +12583,9 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
12281
12583
  */
12282
12584
  }, {
12283
12585
  key: "address",
12284
- value: function address(_address) {
12586
+ value: function address(_address, ahAddress) {
12285
12587
  this._address = _address;
12588
+ this._ahAddress = ahAddress;
12286
12589
  return this;
12287
12590
  }
12288
12591
  /**
@@ -12322,7 +12625,8 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
12322
12625
  paraIdTo: this.paraIdTo,
12323
12626
  feeAsset: this._feeAsset,
12324
12627
  destApiForKeepAlive: this._destApi,
12325
- version: this._version
12628
+ version: this._version,
12629
+ ahAddress: this._ahAddress
12326
12630
  };
12327
12631
  }
12328
12632
  /**
@@ -13397,7 +13701,8 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
13397
13701
  });
13398
13702
  return [].concat(_toConsumableArray(polkadotAsset ? [polkadotAsset] : []), _toConsumableArray(kusamaAsset ? [kusamaAsset] : []));
13399
13703
  }
13400
- if (!isRelayChain(origin) && getDefaultPallet(origin) === 'XTokens' && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama')) {
13704
+ var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
13705
+ if (!isRelayChain(origin) && getDefaultPallet(origin) === 'XTokens' && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama') && !isBifrost) {
13401
13706
  return getOtherAssets(destination).filter(function (asset) {
13402
13707
  return originAssets.some(function (a) {
13403
13708
  return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
@@ -13554,11 +13859,11 @@ var sendCommon = function sendCommon(options_1) {
13554
13859
  return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
13555
13860
  var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
13556
13861
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13557
- var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, asset, nativeAssets, amountStr, currencyStr;
13862
+ var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, isBifrost, asset, nativeAssets, amountStr, currencyStr;
13558
13863
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13559
13864
  while (1) switch (_context.prev = _context.next) {
13560
13865
  case 0:
13561
- api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, feeAsset = options.feeAsset, version = options.version;
13866
+ api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, feeAsset = options.feeAsset, version = options.version, ahAddress = options.ahAddress;
13562
13867
  if (!((!('multiasset' in currency) || 'multilocation' in currency) && amount === null)) {
13563
13868
  _context.next = 3;
13564
13869
  break;
@@ -13608,11 +13913,11 @@ var sendCommon = function sendCommon(options_1) {
13608
13913
  }
13609
13914
  throw new InvalidCurrencyError('Fee asset index is out of bounds. Please provide a valid index.');
13610
13915
  case 17:
13611
- if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot')) {
13916
+ if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration')) {
13612
13917
  _context.next = 19;
13613
13918
  break;
13614
13919
  }
13615
- throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot.');
13920
+ throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
13616
13921
  case 19:
13617
13922
  isMultiLocationDestination = _typeof(destination) === 'object';
13618
13923
  isBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
@@ -13633,13 +13938,14 @@ var sendCommon = function sendCommon(options_1) {
13633
13938
  assetCheckEnabled = 'multilocation' in currency || 'multiasset' in currency || isBridge ? false : originNode.assetCheckEnabled;
13634
13939
  isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
13635
13940
  pallet = getDefaultPallet(origin);
13636
- if (!(!isBridge && isDestAssetHub && pallet === 'XTokens')) {
13637
- _context.next = 43;
13941
+ isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
13942
+ if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
13943
+ _context.next = 44;
13638
13944
  break;
13639
13945
  }
13640
13946
  asset = getAssetBySymbolOrId(destination, currency, false, destination);
13641
13947
  nativeAssets = getNativeAssets(destination);
13642
- if (origin === 'BifrostPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
13948
+ if (origin === 'Hydration') {
13643
13949
  nativeAssets = nativeAssets.filter(function (nativeAsset) {
13644
13950
  return nativeAsset.symbol !== 'DOT';
13645
13951
  });
@@ -13647,76 +13953,76 @@ var sendCommon = function sendCommon(options_1) {
13647
13953
  if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
13648
13954
  return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
13649
13955
  }))) {
13650
- _context.next = 37;
13956
+ _context.next = 38;
13651
13957
  break;
13652
13958
  }
13653
13959
  throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
13654
- case 37:
13960
+ case 38:
13655
13961
  if (!(assetCheckEnabled && asset === null)) {
13656
- _context.next = 39;
13962
+ _context.next = 40;
13657
13963
  break;
13658
13964
  }
13659
13965
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
13660
- case 39:
13966
+ case 40:
13661
13967
  if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
13662
- _context.next = 41;
13968
+ _context.next = 42;
13663
13969
  break;
13664
13970
  }
13665
13971
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
13666
- case 41:
13667
- _context.next = 48;
13972
+ case 42:
13973
+ _context.next = 49;
13668
13974
  break;
13669
- case 43:
13975
+ case 44:
13670
13976
  asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
13671
13977
  if (!(!isBridge && asset === null && assetCheckEnabled)) {
13672
- _context.next = 46;
13978
+ _context.next = 47;
13673
13979
  break;
13674
13980
  }
13675
13981
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
13676
- case 46:
13982
+ case 47:
13677
13983
  if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
13678
- _context.next = 48;
13984
+ _context.next = 49;
13679
13985
  break;
13680
13986
  }
13681
13987
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
13682
- case 48:
13683
- _context.next = 50;
13988
+ case 49:
13989
+ _context.next = 51;
13684
13990
  return api.init(origin);
13685
- case 50:
13991
+ case 51:
13686
13992
  amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
13687
13993
  if (!('multilocation' in currency || 'multiasset' in currency)) {
13688
- _context.next = 55;
13994
+ _context.next = 56;
13689
13995
  break;
13690
13996
  }
13691
13997
  console.warn('Keep alive check is not supported when using MultiLocation as currency.');
13692
- _context.next = 69;
13998
+ _context.next = 70;
13693
13999
  break;
13694
- case 55:
14000
+ case 56:
13695
14001
  if (!(_typeof(address) === 'object')) {
13696
- _context.next = 59;
14002
+ _context.next = 60;
13697
14003
  break;
13698
14004
  }
13699
14005
  console.warn('Keep alive check is not supported when using MultiLocation as address.');
13700
- _context.next = 69;
14006
+ _context.next = 70;
13701
14007
  break;
13702
- case 59:
14008
+ case 60:
13703
14009
  if (!(_typeof(destination) === 'object')) {
13704
- _context.next = 63;
14010
+ _context.next = 64;
13705
14011
  break;
13706
14012
  }
13707
14013
  console.warn('Keep alive check is not supported when using MultiLocation as destination.');
13708
- _context.next = 69;
14014
+ _context.next = 70;
13709
14015
  break;
13710
- case 63:
14016
+ case 64:
13711
14017
  if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
13712
- _context.next = 67;
14018
+ _context.next = 68;
13713
14019
  break;
13714
14020
  }
13715
14021
  console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
13716
- _context.next = 69;
14022
+ _context.next = 70;
13717
14023
  break;
13718
- case 67:
13719
- _context.next = 69;
14024
+ case 68:
14025
+ _context.next = 70;
13720
14026
  return checkKeepAlive({
13721
14027
  originApi: api,
13722
14028
  address: address,
@@ -13726,7 +14032,7 @@ var sendCommon = function sendCommon(options_1) {
13726
14032
  currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
13727
14033
  destNode: destination
13728
14034
  });
13729
- case 69:
14035
+ case 70:
13730
14036
  currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
13731
14037
  return _context.abrupt("return", originNode.transfer({
13732
14038
  api: api,
@@ -13740,9 +14046,10 @@ var sendCommon = function sendCommon(options_1) {
13740
14046
  feeAsset: feeAsset,
13741
14047
  version: version,
13742
14048
  destApiForKeepAlive: destApiForKeepAlive,
13743
- serializedApiCallEnabled: serializedApiCallEnabled
14049
+ serializedApiCallEnabled: serializedApiCallEnabled,
14050
+ ahAddress: ahAddress
13744
14051
  }));
13745
- case 71:
14052
+ case 72:
13746
14053
  case "end":
13747
14054
  return _context.stop();
13748
14055
  }
@@ -13917,21 +14224,32 @@ var PolkadotJsApi = /*#__PURE__*/function () {
13917
14224
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13918
14225
  while (1) switch (_context.prev = _context.next) {
13919
14226
  case 0:
14227
+ if (!(typeof this._api === 'string')) {
14228
+ _context.next = 6;
14229
+ break;
14230
+ }
14231
+ _context.next = 3;
14232
+ return this.createApiInstance(this._api);
14233
+ case 3:
14234
+ this.api = _context.sent;
14235
+ _context.next = 14;
14236
+ break;
14237
+ case 6:
13920
14238
  if (!((_a = this._api) !== null && _a !== void 0)) {
13921
- _context.next = 4;
14239
+ _context.next = 10;
13922
14240
  break;
13923
14241
  }
13924
14242
  _context.t0 = _a;
13925
- _context.next = 7;
14243
+ _context.next = 13;
13926
14244
  break;
13927
- case 4:
13928
- _context.next = 6;
14245
+ case 10:
14246
+ _context.next = 12;
13929
14247
  return createApiInstanceForNode$1(this, node);
13930
- case 6:
14248
+ case 12:
13931
14249
  _context.t0 = _context.sent;
13932
- case 7:
14250
+ case 13:
13933
14251
  this.api = _context.t0;
13934
- case 8:
14252
+ case 14:
13935
14253
  case "end":
13936
14254
  return _context.stop();
13937
14255
  }
@@ -14135,11 +14453,51 @@ var PolkadotJsApi = /*#__PURE__*/function () {
14135
14453
  }, _callee9, this);
14136
14454
  }));
14137
14455
  }
14456
+ }, {
14457
+ key: "getFromStorage",
14458
+ value: function getFromStorage(key) {
14459
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
14460
+ var response;
14461
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
14462
+ while (1) switch (_context10.prev = _context10.next) {
14463
+ case 0:
14464
+ _context10.next = 2;
14465
+ return this.api.rpc.state.getStorage(key);
14466
+ case 2:
14467
+ response = _context10.sent;
14468
+ return _context10.abrupt("return", response.toHex());
14469
+ case 4:
14470
+ case "end":
14471
+ return _context10.stop();
14472
+ }
14473
+ }, _callee10, this);
14474
+ }));
14475
+ }
14138
14476
  }, {
14139
14477
  key: "clone",
14140
14478
  value: function clone() {
14141
14479
  return new PolkadotJsApi();
14142
14480
  }
14481
+ }, {
14482
+ key: "createApiForNode",
14483
+ value: function createApiForNode(node) {
14484
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
14485
+ var api;
14486
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
14487
+ while (1) switch (_context11.prev = _context11.next) {
14488
+ case 0:
14489
+ api = new PolkadotJsApi();
14490
+ _context11.next = 3;
14491
+ return api.init(node);
14492
+ case 3:
14493
+ return _context11.abrupt("return", api);
14494
+ case 4:
14495
+ case "end":
14496
+ return _context11.stop();
14497
+ }
14498
+ }, _callee11);
14499
+ }));
14500
+ }
14143
14501
  }]);
14144
14502
  }();
14145
14503