@paraspell/sdk 7.1.0 → 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.
@@ -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
  }
@@ -9290,19 +9290,34 @@ var createEthereumTokenLocation = function createEthereumTokenLocation(currencyI
9290
9290
  }
9291
9291
  };
9292
9292
  };
9293
- var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, versionOrDefault) {
9293
+ var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
9294
9294
  var api = _ref.api,
9295
- address = _ref.address,
9296
- currencyId = _ref.currencyId,
9297
9295
  scenario = _ref.scenario,
9298
- ahAddress = _ref.ahAddress;
9299
- return _defineProperty({}, versionOrDefault, [{
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, [{
9300
9315
  SetAppendix: [{
9301
9316
  DepositAsset: {
9302
9317
  assets: {
9303
9318
  Wild: 'All'
9304
9319
  },
9305
- beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', versionOrDefault, undefined))[0]
9320
+ beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', version, undefined))[0]
9306
9321
  }
9307
9322
  }]
9308
9323
  }, {
@@ -9369,11 +9384,10 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
9369
9384
  _classCallCheck(this, Hydration);
9370
9385
  return _callSuper(this, Hydration, ['Hydration', 'hydradx', 'polkadot', Version.V3]);
9371
9386
  }
9372
- // Handles WETH Ethereum transfers
9373
9387
  _inherits(Hydration, _ParachainNode);
9374
9388
  return _createClass(Hydration, [{
9375
- key: "transferPolkadotXCM",
9376
- value: function transferPolkadotXCM(input) {
9389
+ key: "transferToEthereum",
9390
+ value: function transferToEthereum(input) {
9377
9391
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
9378
9392
  var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
9379
9393
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -9428,6 +9442,59 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
9428
9442
  }, _callee2, this);
9429
9443
  }));
9430
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
+ }
9431
9498
  }, {
9432
9499
  key: "transferXTokens",
9433
9500
  value: function transferXTokens(input) {
@@ -9436,9 +9503,15 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
9436
9503
  }
9437
9504
  }, {
9438
9505
  key: "canUseXTokens",
9439
- value: function canUseXTokens(_ref3) {
9440
- var destination = _ref3.destination;
9441
- return destination !== 'Ethereum';
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)));
9442
9515
  }
9443
9516
  }]);
9444
9517
  }(ParachainNode);
@@ -9954,41 +10027,64 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
9954
10027
  });
9955
10028
  return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'limited_teleport_assets', 'Unlimited');
9956
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
+ }
9957
10064
  }, {
9958
10065
  key: "transferPolkadotXCM",
9959
10066
  value: function transferPolkadotXCM(input) {
9960
- var _a;
9961
10067
  var scenario = input.scenario,
9962
10068
  currencySymbol = input.currencySymbol,
9963
- currencyId = input.currencyId;
9964
- if (input.destination === 'AssetHubKusama') {
10069
+ currencyId = input.currencyId,
10070
+ destination = input.destination;
10071
+ if (destination === 'AssetHubKusama') {
9965
10072
  return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
9966
10073
  }
9967
- if (input.destination === 'Ethereum') {
10074
+ if (destination === 'Ethereum') {
9968
10075
  return Promise.resolve(this.handleEthBridgeTransfer(input));
9969
10076
  }
9970
- if (input.destination === 'Mythos') {
10077
+ if (destination === 'Mythos') {
9971
10078
  return Promise.resolve(this.handleMythosTransfer(input));
9972
10079
  }
9973
- if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined) {
10080
+ if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined && destination !== 'Hydration') {
9974
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.');
9975
10082
  }
9976
10083
  if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
9977
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>}.');
9978
10085
  }
9979
10086
  var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
9980
- var api = input.api,
9981
- destination = input.destination,
9982
- paraIdTo = input.paraIdTo,
9983
- address = input.address,
9984
- amount = input.amount,
9985
- overridedCurrency = input.overridedCurrency;
9986
- var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : Version.V2;
9987
- var modifiedInput = ((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot' ? Object.assign(Object.assign({}, input), {
9988
- header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
9989
- addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
9990
- currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
9991
- }) : input;
10087
+ var modifiedInput = this.patchInput(input);
9992
10088
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
9993
10089
  }
9994
10090
  }, {
@@ -10016,7 +10112,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
10016
10112
  };
10017
10113
  return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
10018
10114
  } else {
10019
- return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10115
+ return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
10020
10116
  }
10021
10117
  }
10022
10118
  }]);
@@ -10309,7 +10405,7 @@ var Darwinia$2 = /*#__PURE__*/function (_ParachainNode) {
10309
10405
  };
10310
10406
  return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
10311
10407
  } else {
10312
- return _superPropGet(Darwinia, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10408
+ return _superPropGet(Darwinia, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId, overridedMultiLocation]);
10313
10409
  }
10314
10410
  }
10315
10411
  }, {
@@ -10544,7 +10640,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
10544
10640
  if (scenario === 'ParaToPara') {
10545
10641
  return {};
10546
10642
  } else {
10547
- return _superPropGet(Collectives, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
10643
+ return _superPropGet(Collectives, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
10548
10644
  }
10549
10645
  }
10550
10646
  }]);
@@ -13763,7 +13859,7 @@ var sendCommon = function sendCommon(options_1) {
13763
13859
  return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
13764
13860
  var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
13765
13861
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13766
- 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, 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;
13767
13863
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13768
13864
  while (1) switch (_context.prev = _context.next) {
13769
13865
  case 0:
@@ -13844,83 +13940,89 @@ var sendCommon = function sendCommon(options_1) {
13844
13940
  pallet = getDefaultPallet(origin);
13845
13941
  isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
13846
13942
  if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
13847
- _context.next = 42;
13943
+ _context.next = 44;
13848
13944
  break;
13849
13945
  }
13850
13946
  asset = getAssetBySymbolOrId(destination, currency, false, destination);
13851
- if (!('symbol' in currency && getNativeAssets(destination).some(function (nativeAsset) {
13947
+ nativeAssets = getNativeAssets(destination);
13948
+ if (origin === 'Hydration') {
13949
+ nativeAssets = nativeAssets.filter(function (nativeAsset) {
13950
+ return nativeAsset.symbol !== 'DOT';
13951
+ });
13952
+ }
13953
+ if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
13852
13954
  return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
13853
13955
  }))) {
13854
- _context.next = 36;
13956
+ _context.next = 38;
13855
13957
  break;
13856
13958
  }
13857
13959
  throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
13858
- case 36:
13960
+ case 38:
13859
13961
  if (!(assetCheckEnabled && asset === null)) {
13860
- _context.next = 38;
13962
+ _context.next = 40;
13861
13963
  break;
13862
13964
  }
13863
13965
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
13864
- case 38:
13966
+ case 40:
13865
13967
  if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
13866
- _context.next = 40;
13968
+ _context.next = 42;
13867
13969
  break;
13868
13970
  }
13869
13971
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
13870
- case 40:
13871
- _context.next = 47;
13872
- break;
13873
13972
  case 42:
13973
+ _context.next = 49;
13974
+ break;
13975
+ case 44:
13874
13976
  asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
13875
13977
  if (!(!isBridge && asset === null && assetCheckEnabled)) {
13876
- _context.next = 45;
13978
+ _context.next = 47;
13877
13979
  break;
13878
13980
  }
13879
13981
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
13880
- case 45:
13982
+ case 47:
13881
13983
  if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
13882
- _context.next = 47;
13984
+ _context.next = 49;
13883
13985
  break;
13884
13986
  }
13885
13987
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
13886
- case 47:
13887
- _context.next = 49;
13888
- return api.init(origin);
13889
13988
  case 49:
13989
+ _context.next = 51;
13990
+ return api.init(origin);
13991
+ case 51:
13890
13992
  amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
13891
13993
  if (!('multilocation' in currency || 'multiasset' in currency)) {
13892
- _context.next = 54;
13994
+ _context.next = 56;
13893
13995
  break;
13894
13996
  }
13895
13997
  console.warn('Keep alive check is not supported when using MultiLocation as currency.');
13896
- _context.next = 68;
13998
+ _context.next = 70;
13897
13999
  break;
13898
- case 54:
14000
+ case 56:
13899
14001
  if (!(_typeof(address) === 'object')) {
13900
- _context.next = 58;
14002
+ _context.next = 60;
13901
14003
  break;
13902
14004
  }
13903
14005
  console.warn('Keep alive check is not supported when using MultiLocation as address.');
13904
- _context.next = 68;
14006
+ _context.next = 70;
13905
14007
  break;
13906
- case 58:
14008
+ case 60:
13907
14009
  if (!(_typeof(destination) === 'object')) {
13908
- _context.next = 62;
14010
+ _context.next = 64;
13909
14011
  break;
13910
14012
  }
13911
14013
  console.warn('Keep alive check is not supported when using MultiLocation as destination.');
13912
- _context.next = 68;
14014
+ _context.next = 70;
13913
14015
  break;
13914
- case 62:
14016
+ case 64:
13915
14017
  if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
13916
- _context.next = 66;
14018
+ _context.next = 68;
13917
14019
  break;
13918
14020
  }
13919
14021
  console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
13920
- _context.next = 68;
14022
+ _context.next = 70;
13921
14023
  break;
13922
- case 66:
13923
- _context.next = 68;
14024
+ case 68:
14025
+ _context.next = 70;
13924
14026
  return checkKeepAlive({
13925
14027
  originApi: api,
13926
14028
  address: address,
@@ -13930,7 +14032,7 @@ var sendCommon = function sendCommon(options_1) {
13930
14032
  currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
13931
14033
  destNode: destination
13932
14034
  });
13933
- case 68:
14035
+ case 70:
13934
14036
  currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
13935
14037
  return _context.abrupt("return", originNode.transfer({
13936
14038
  api: api,
@@ -13947,7 +14049,7 @@ var sendCommon = function sendCommon(options_1) {
13947
14049
  serializedApiCallEnabled: serializedApiCallEnabled,
13948
14050
  ahAddress: ahAddress
13949
14051
  }));
13950
- case 70:
14052
+ case 72:
13951
14053
  case "end":
13952
14054
  return _context.stop();
13953
14055
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",