@paraspell/sdk-core 9.1.0 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2945,6 +2945,41 @@ var padFee = function padFee(raw, origin, dest, side) {
2945
2945
  return mul(raw, 130n, 100n);
2946
2946
  };
2947
2947
 
2948
+ var getReverseTxFee = /*#__PURE__*/function () {
2949
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, currencyInput) {
2950
+ var api, origin, destination, senderAddress, address, currency, tx, rawFee;
2951
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2952
+ while (1) switch (_context.prev = _context.next) {
2953
+ case 0:
2954
+ api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
2955
+ if (!('multiasset' in currency)) {
2956
+ _context.next = 3;
2957
+ break;
2958
+ }
2959
+ throw new assets.InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
2960
+ case 3:
2961
+ _context.next = 5;
2962
+ return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
2963
+ amount: currency.amount
2964
+ })).build();
2965
+ case 5:
2966
+ tx = _context.sent;
2967
+ _context.next = 8;
2968
+ return api.calculateTransactionFee(tx, address);
2969
+ case 8:
2970
+ rawFee = _context.sent;
2971
+ return _context.abrupt("return", padFee(rawFee, origin, destination, 'destination'));
2972
+ case 10:
2973
+ case "end":
2974
+ return _context.stop();
2975
+ }
2976
+ }, _callee);
2977
+ }));
2978
+ return function getReverseTxFee(_x, _x2) {
2979
+ return _ref2.apply(this, arguments);
2980
+ };
2981
+ }();
2982
+
2948
2983
  var createOriginLocation = function createOriginLocation(origin, destination) {
2949
2984
  if (sdkCommon.isRelayChain(origin)) return DOT_MULTILOCATION;
2950
2985
  return {
@@ -2957,55 +2992,66 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
2957
2992
  };
2958
2993
  };
2959
2994
  var getFeeForDestNode = /*#__PURE__*/function () {
2960
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
2961
- var api, forwardedXcms, origin, destination, address, senderAddress, currency, disableFallback, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
2995
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
2996
+ var api, origin, destination, currency, forwardedXcms, disableFallback, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
2962
2997
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2963
2998
  while (1) switch (_context2.prev = _context2.next) {
2964
2999
  case 0:
2965
- api = _ref.api, forwardedXcms = _ref.forwardedXcms, origin = _ref.origin, destination = _ref.destination, address = _ref.address, senderAddress = _ref.senderAddress, currency = _ref.currency, disableFallback = _ref.disableFallback;
3000
+ api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, disableFallback = options.disableFallback;
2966
3001
  calcPaymentInfoFee = /*#__PURE__*/function () {
2967
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
2968
- var originAsset, currencyInput, tx, rawFee;
3002
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3003
+ var originAsset;
2969
3004
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2970
3005
  while (1) switch (_context.prev = _context.next) {
2971
3006
  case 0:
2972
- if (!('multiasset' in currency)) {
2973
- _context.next = 2;
2974
- break;
2975
- }
2976
- throw new assets.InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
2977
- case 2:
2978
3007
  originAsset = assets.findAsset(origin, currency, destination);
2979
3008
  if (originAsset) {
2980
- _context.next = 5;
3009
+ _context.next = 3;
2981
3010
  break;
2982
3011
  }
2983
3012
  throw new assets.InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
2984
- case 5:
2985
- currencyInput = originAsset.multiLocation ? {
3013
+ case 3:
3014
+ if (!originAsset.multiLocation) {
3015
+ _context.next = 17;
3016
+ break;
3017
+ }
3018
+ _context.prev = 4;
3019
+ _context.next = 7;
3020
+ return getReverseTxFee(options, {
2986
3021
  multilocation: originAsset.multiLocation
2987
- } : {
3022
+ });
3023
+ case 7:
3024
+ return _context.abrupt("return", _context.sent);
3025
+ case 10:
3026
+ _context.prev = 10;
3027
+ _context.t0 = _context["catch"](4);
3028
+ if (!(_context.t0 instanceof assets.InvalidCurrencyError)) {
3029
+ _context.next = 16;
3030
+ break;
3031
+ }
3032
+ _context.next = 15;
3033
+ return getReverseTxFee(options, {
3034
+ symbol: originAsset.symbol
3035
+ });
3036
+ case 15:
3037
+ return _context.abrupt("return", _context.sent);
3038
+ case 16:
3039
+ throw _context.t0;
3040
+ case 17:
3041
+ _context.next = 19;
3042
+ return getReverseTxFee(options, {
2988
3043
  symbol: originAsset.symbol
2989
- };
2990
- _context.next = 8;
2991
- return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
2992
- amount: currency.amount
2993
- })).build();
2994
- case 8:
2995
- tx = _context.sent;
2996
- _context.next = 11;
2997
- return api.calculateTransactionFee(tx, address);
2998
- case 11:
2999
- rawFee = _context.sent;
3000
- return _context.abrupt("return", padFee(rawFee, origin, destination, 'destination'));
3001
- case 13:
3044
+ });
3045
+ case 19:
3046
+ return _context.abrupt("return", _context.sent);
3047
+ case 20:
3002
3048
  case "end":
3003
3049
  return _context.stop();
3004
3050
  }
3005
- }, _callee);
3051
+ }, _callee, null, [[4, 10]]);
3006
3052
  }));
3007
3053
  return function calcPaymentInfoFee() {
3008
- return _ref3.apply(this, arguments);
3054
+ return _ref2.apply(this, arguments);
3009
3055
  };
3010
3056
  }();
3011
3057
  if (!(!assets.hasDryRunSupport(destination) || !forwardedXcms)) {
@@ -3067,7 +3113,7 @@ var getFeeForDestNode = /*#__PURE__*/function () {
3067
3113
  }, _callee2);
3068
3114
  }));
3069
3115
  return function getFeeForDestNode(_x) {
3070
- return _ref2.apply(this, arguments);
3116
+ return _ref.apply(this, arguments);
3071
3117
  };
3072
3118
  }();
3073
3119
 
package/dist/index.mjs CHANGED
@@ -2946,6 +2946,41 @@ var padFee = function padFee(raw, origin, dest, side) {
2946
2946
  return mul(raw, 130n, 100n);
2947
2947
  };
2948
2948
 
2949
+ var getReverseTxFee = /*#__PURE__*/function () {
2950
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, currencyInput) {
2951
+ var api, origin, destination, senderAddress, address, currency, tx, rawFee;
2952
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2953
+ while (1) switch (_context.prev = _context.next) {
2954
+ case 0:
2955
+ api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
2956
+ if (!('multiasset' in currency)) {
2957
+ _context.next = 3;
2958
+ break;
2959
+ }
2960
+ throw new InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
2961
+ case 3:
2962
+ _context.next = 5;
2963
+ return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
2964
+ amount: currency.amount
2965
+ })).build();
2966
+ case 5:
2967
+ tx = _context.sent;
2968
+ _context.next = 8;
2969
+ return api.calculateTransactionFee(tx, address);
2970
+ case 8:
2971
+ rawFee = _context.sent;
2972
+ return _context.abrupt("return", padFee(rawFee, origin, destination, 'destination'));
2973
+ case 10:
2974
+ case "end":
2975
+ return _context.stop();
2976
+ }
2977
+ }, _callee);
2978
+ }));
2979
+ return function getReverseTxFee(_x, _x2) {
2980
+ return _ref2.apply(this, arguments);
2981
+ };
2982
+ }();
2983
+
2949
2984
  var createOriginLocation = function createOriginLocation(origin, destination) {
2950
2985
  if (isRelayChain(origin)) return DOT_MULTILOCATION;
2951
2986
  return {
@@ -2958,55 +2993,66 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
2958
2993
  };
2959
2994
  };
2960
2995
  var getFeeForDestNode = /*#__PURE__*/function () {
2961
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
2962
- var api, forwardedXcms, origin, destination, address, senderAddress, currency, disableFallback, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
2996
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
2997
+ var api, origin, destination, currency, forwardedXcms, disableFallback, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
2963
2998
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2964
2999
  while (1) switch (_context2.prev = _context2.next) {
2965
3000
  case 0:
2966
- api = _ref.api, forwardedXcms = _ref.forwardedXcms, origin = _ref.origin, destination = _ref.destination, address = _ref.address, senderAddress = _ref.senderAddress, currency = _ref.currency, disableFallback = _ref.disableFallback;
3001
+ api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, disableFallback = options.disableFallback;
2967
3002
  calcPaymentInfoFee = /*#__PURE__*/function () {
2968
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
2969
- var originAsset, currencyInput, tx, rawFee;
3003
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3004
+ var originAsset;
2970
3005
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2971
3006
  while (1) switch (_context.prev = _context.next) {
2972
3007
  case 0:
2973
- if (!('multiasset' in currency)) {
2974
- _context.next = 2;
2975
- break;
2976
- }
2977
- throw new InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
2978
- case 2:
2979
3008
  originAsset = findAsset(origin, currency, destination);
2980
3009
  if (originAsset) {
2981
- _context.next = 5;
3010
+ _context.next = 3;
2982
3011
  break;
2983
3012
  }
2984
3013
  throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
2985
- case 5:
2986
- currencyInput = originAsset.multiLocation ? {
3014
+ case 3:
3015
+ if (!originAsset.multiLocation) {
3016
+ _context.next = 17;
3017
+ break;
3018
+ }
3019
+ _context.prev = 4;
3020
+ _context.next = 7;
3021
+ return getReverseTxFee(options, {
2987
3022
  multilocation: originAsset.multiLocation
2988
- } : {
3023
+ });
3024
+ case 7:
3025
+ return _context.abrupt("return", _context.sent);
3026
+ case 10:
3027
+ _context.prev = 10;
3028
+ _context.t0 = _context["catch"](4);
3029
+ if (!(_context.t0 instanceof InvalidCurrencyError)) {
3030
+ _context.next = 16;
3031
+ break;
3032
+ }
3033
+ _context.next = 15;
3034
+ return getReverseTxFee(options, {
3035
+ symbol: originAsset.symbol
3036
+ });
3037
+ case 15:
3038
+ return _context.abrupt("return", _context.sent);
3039
+ case 16:
3040
+ throw _context.t0;
3041
+ case 17:
3042
+ _context.next = 19;
3043
+ return getReverseTxFee(options, {
2989
3044
  symbol: originAsset.symbol
2990
- };
2991
- _context.next = 8;
2992
- return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
2993
- amount: currency.amount
2994
- })).build();
2995
- case 8:
2996
- tx = _context.sent;
2997
- _context.next = 11;
2998
- return api.calculateTransactionFee(tx, address);
2999
- case 11:
3000
- rawFee = _context.sent;
3001
- return _context.abrupt("return", padFee(rawFee, origin, destination, 'destination'));
3002
- case 13:
3045
+ });
3046
+ case 19:
3047
+ return _context.abrupt("return", _context.sent);
3048
+ case 20:
3003
3049
  case "end":
3004
3050
  return _context.stop();
3005
3051
  }
3006
- }, _callee);
3052
+ }, _callee, null, [[4, 10]]);
3007
3053
  }));
3008
3054
  return function calcPaymentInfoFee() {
3009
- return _ref3.apply(this, arguments);
3055
+ return _ref2.apply(this, arguments);
3010
3056
  };
3011
3057
  }();
3012
3058
  if (!(!hasDryRunSupport(destination) || !forwardedXcms)) {
@@ -3068,7 +3114,7 @@ var getFeeForDestNode = /*#__PURE__*/function () {
3068
3114
  }, _callee2);
3069
3115
  }));
3070
3116
  return function getFeeForDestNode(_x) {
3071
- return _ref2.apply(this, arguments);
3117
+ return _ref.apply(this, arguments);
3072
3118
  };
3073
3119
  }();
3074
3120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "9.1.0",
3
+ "version": "9.1.2",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "@scure/base": "^1.2.5",
28
28
  "ethers": "^6.13.7",
29
29
  "viem": "^2.28.1",
30
- "@paraspell/assets": "9.1.0",
31
- "@paraspell/pallets": "9.1.0",
32
- "@paraspell/sdk-common": "9.1.0"
30
+ "@paraspell/assets": "9.1.2",
31
+ "@paraspell/pallets": "9.1.2",
32
+ "@paraspell/sdk-common": "9.1.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/plugin-syntax-import-attributes": "^7.27.1",