@paraspell/sdk 8.5.2 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,6 +3,8 @@
3
3
  var sdkCore = require('@paraspell/sdk-core');
4
4
  var polkadotSdkCompat = require('polkadot-api/polkadot-sdk-compat');
5
5
  var polkadotApi = require('polkadot-api');
6
+ var blake2b = require('@noble/hashes/blake2b');
7
+ var utils = require('@noble/hashes/utils');
6
8
 
7
9
  function _arrayLikeToArray(r, a) {
8
10
  (null == a || a > r.length) && (a = r.length);
@@ -33,7 +35,7 @@ function _asyncToGenerator(n) {
33
35
  function _throw(n) {
34
36
  asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
35
37
  }
36
- _next(undefined);
38
+ _next(void 0);
37
39
  });
38
40
  };
39
41
  }
@@ -355,7 +357,7 @@ function _regeneratorRuntime() {
355
357
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
356
358
  return this;
357
359
  }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
358
- undefined === i && (i = Promise);
360
+ void 0 === i && (i = Promise);
359
361
  var a = new AsyncIterator(wrap(t, r, n, o), i);
360
362
  return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
361
363
  return t.done ? t.value : a.next();
@@ -462,12 +464,12 @@ function _slicedToArray(r, e) {
462
464
  function _toPrimitive(t, r) {
463
465
  if ("object" != typeof t || !t) return t;
464
466
  var e = t[Symbol.toPrimitive];
465
- if (undefined !== e) {
467
+ if (void 0 !== e) {
466
468
  var i = e.call(t, r);
467
469
  if ("object" != typeof i) return i;
468
470
  throw new TypeError("@@toPrimitive must return a primitive value.");
469
471
  }
470
- return (String )(t);
472
+ return ("string" === r ? String : Number)(t);
471
473
  }
472
474
  function _toPropertyKey(t) {
473
475
  var i = _toPrimitive(t, "string");
@@ -486,7 +488,7 @@ function _unsupportedIterableToArray(r, a) {
486
488
  if (r) {
487
489
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
488
490
  var t = {}.toString.call(r).slice(8, -1);
489
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
491
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
490
492
  }
491
493
  }
492
494
 
@@ -545,6 +547,11 @@ var _transform = function transform(obj) {
545
547
  key: polkadotApi.FixedSizeBinary.fromHex(value.key)
546
548
  }
547
549
  };
550
+ } else if (key === 'SetTopic') {
551
+ return {
552
+ type: key,
553
+ value: polkadotApi.FixedSizeBinary.fromHex(value)
554
+ };
548
555
  } else if (key === 'X1' && Array.isArray(value)) {
549
556
  return {
550
557
  type: key,
@@ -632,6 +639,9 @@ var _transform = function transform(obj) {
632
639
  };
633
640
 
634
641
  var unsupportedNodes = ['ComposableFinance', 'Interlay', 'Parallel', 'CrustShadow', 'Kintsugi', 'ParallelHeiko', 'Picasso', 'RobonomicsKusama', 'Turing', 'Pendulum', 'Subsocial'];
642
+ var isHex = function isHex(str) {
643
+ return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
644
+ };
635
645
  var PapiApi = /*#__PURE__*/function () {
636
646
  function PapiApi() {
637
647
  _classCallCheck(this, PapiApi);
@@ -684,7 +694,7 @@ var PapiApi = /*#__PURE__*/function () {
684
694
  _context.next = 18;
685
695
  break;
686
696
  case 10:
687
- if (!((_this$_api = this._api) !== null && _this$_api !== undefined)) {
697
+ if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
688
698
  _context.next = 14;
689
699
  break;
690
700
  }
@@ -753,9 +763,6 @@ var PapiApi = /*#__PURE__*/function () {
753
763
  key: "accountToHex",
754
764
  value: function accountToHex(address) {
755
765
  var isPrefixed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
756
- var isHex = function isHex(str) {
757
- return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
758
- };
759
766
  if (isHex(address)) return address;
760
767
  var hex = polkadotApi.FixedSizeBinary.fromAccountId32(address).asHex();
761
768
  return isPrefixed ? hex : hex.slice(2);
@@ -780,92 +787,149 @@ var PapiApi = /*#__PURE__*/function () {
780
787
  });
781
788
  }
782
789
  }, {
783
- key: "calculateTransactionFee",
790
+ key: "objectToHex",
784
791
  value: function () {
785
- var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tx, address) {
792
+ var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(obj) {
793
+ var transformedObj, tx, removeFirst5Bytes, encodedData;
786
794
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
787
795
  while (1) switch (_context3.prev = _context3.next) {
788
796
  case 0:
789
- return _context3.abrupt("return", tx.getEstimatedFees(address));
790
- case 1:
797
+ transformedObj = _transform(obj);
798
+ tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
799
+ dest: {
800
+ type: sdkCore.Version.V4,
801
+ value: {
802
+ parents: sdkCore.Parents.ZERO,
803
+ interior: {
804
+ type: 'Here'
805
+ }
806
+ }
807
+ },
808
+ message: transformedObj
809
+ });
810
+ removeFirst5Bytes = function removeFirst5Bytes(hexString) {
811
+ return '0x' + hexString.slice(12);
812
+ };
813
+ _context3.next = 5;
814
+ return tx.getEncodedData();
815
+ case 5:
816
+ encodedData = _context3.sent;
817
+ return _context3.abrupt("return", removeFirst5Bytes(encodedData.asHex()));
818
+ case 7:
791
819
  case "end":
792
820
  return _context3.stop();
793
821
  }
794
- }, _callee3);
822
+ }, _callee3, this);
795
823
  }));
796
- function calculateTransactionFee(_x3, _x4) {
797
- return _calculateTransactionFee.apply(this, arguments);
824
+ function objectToHex(_x3) {
825
+ return _objectToHex.apply(this, arguments);
798
826
  }
799
- return calculateTransactionFee;
827
+ return objectToHex;
800
828
  }()
801
829
  }, {
802
- key: "getBalanceNative",
830
+ key: "hexToUint8a",
831
+ value: function hexToUint8a(hex) {
832
+ return polkadotApi.Binary.fromHex(hex).asBytes();
833
+ }
834
+ }, {
835
+ key: "stringToUint8a",
836
+ value: function stringToUint8a(str) {
837
+ return polkadotApi.Binary.fromText(str).asBytes();
838
+ }
839
+ }, {
840
+ key: "blake2AsHex",
841
+ value: function blake2AsHex(data) {
842
+ return "0x".concat(utils.bytesToHex(blake2b.blake2b(data, {
843
+ dkLen: 32
844
+ })));
845
+ }
846
+ }, {
847
+ key: "calculateTransactionFee",
803
848
  value: function () {
804
- var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(address) {
805
- var res;
849
+ var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tx, address) {
806
850
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
807
851
  while (1) switch (_context4.prev = _context4.next) {
808
852
  case 0:
809
- _context4.next = 2;
810
- return this.api.getUnsafeApi().query.System.Account.getValue(address);
811
- case 2:
812
- res = _context4.sent;
813
- return _context4.abrupt("return", res.data.free);
814
- case 4:
853
+ return _context4.abrupt("return", tx.getEstimatedFees(address));
854
+ case 1:
815
855
  case "end":
816
856
  return _context4.stop();
817
857
  }
818
- }, _callee4, this);
858
+ }, _callee4);
819
859
  }));
820
- function getBalanceNative(_x5) {
821
- return _getBalanceNative.apply(this, arguments);
860
+ function calculateTransactionFee(_x4, _x5) {
861
+ return _calculateTransactionFee.apply(this, arguments);
822
862
  }
823
- return getBalanceNative;
863
+ return calculateTransactionFee;
824
864
  }()
825
865
  }, {
826
- key: "getBalanceForeignPolkadotXcm",
866
+ key: "getBalanceNative",
827
867
  value: function () {
828
- var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address, id) {
868
+ var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address) {
829
869
  var res;
830
870
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
831
871
  while (1) switch (_context5.prev = _context5.next) {
832
872
  case 0:
833
873
  _context5.next = 2;
834
- return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
874
+ return this.api.getUnsafeApi().query.System.Account.getValue(address);
835
875
  case 2:
836
876
  res = _context5.sent;
837
- return _context5.abrupt("return", res && res.balance ? BigInt(res.balance) : 0n);
877
+ return _context5.abrupt("return", res.data.free);
838
878
  case 4:
839
879
  case "end":
840
880
  return _context5.stop();
841
881
  }
842
882
  }, _callee5, this);
843
883
  }));
844
- function getBalanceForeignPolkadotXcm(_x6, _x7) {
845
- return _getBalanceForeignPolkadotXcm.apply(this, arguments);
884
+ function getBalanceNative(_x6) {
885
+ return _getBalanceNative.apply(this, arguments);
846
886
  }
847
- return getBalanceForeignPolkadotXcm;
887
+ return getBalanceNative;
848
888
  }()
849
889
  }, {
850
- key: "getMythosForeignBalance",
890
+ key: "getBalanceForeignPolkadotXcm",
851
891
  value: function () {
852
- var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
892
+ var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address, id) {
853
893
  var res;
854
894
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
855
895
  while (1) switch (_context6.prev = _context6.next) {
856
896
  case 0:
857
897
  _context6.next = 2;
858
- return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
898
+ return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
859
899
  case 2:
860
900
  res = _context6.sent;
861
- return _context6.abrupt("return", res && res.free ? BigInt(res.free) : 0n);
901
+ return _context6.abrupt("return", res && res.balance ? BigInt(res.balance) : 0n);
862
902
  case 4:
863
903
  case "end":
864
904
  return _context6.stop();
865
905
  }
866
906
  }, _callee6, this);
867
907
  }));
868
- function getMythosForeignBalance(_x8) {
908
+ function getBalanceForeignPolkadotXcm(_x7, _x8) {
909
+ return _getBalanceForeignPolkadotXcm.apply(this, arguments);
910
+ }
911
+ return getBalanceForeignPolkadotXcm;
912
+ }()
913
+ }, {
914
+ key: "getMythosForeignBalance",
915
+ value: function () {
916
+ var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address) {
917
+ var res;
918
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
919
+ while (1) switch (_context7.prev = _context7.next) {
920
+ case 0:
921
+ _context7.next = 2;
922
+ return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
923
+ case 2:
924
+ res = _context7.sent;
925
+ return _context7.abrupt("return", res && res.free ? BigInt(res.free) : 0n);
926
+ case 4:
927
+ case "end":
928
+ return _context7.stop();
929
+ }
930
+ }, _callee7, this);
931
+ }));
932
+ function getMythosForeignBalance(_x9) {
869
933
  return _getMythosForeignBalance.apply(this, arguments);
870
934
  }
871
935
  return getMythosForeignBalance;
@@ -873,24 +937,24 @@ var PapiApi = /*#__PURE__*/function () {
873
937
  }, {
874
938
  key: "getAssetHubForeignBalance",
875
939
  value: function () {
876
- var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address, multiLocation) {
940
+ var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, multiLocation) {
877
941
  var transformedMultiLocation, res;
878
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
879
- while (1) switch (_context7.prev = _context7.next) {
942
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
943
+ while (1) switch (_context8.prev = _context8.next) {
880
944
  case 0:
881
945
  transformedMultiLocation = _transform(multiLocation);
882
- _context7.next = 3;
946
+ _context8.next = 3;
883
947
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
884
948
  case 3:
885
- res = _context7.sent;
886
- return _context7.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
949
+ res = _context8.sent;
950
+ return _context8.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
887
951
  case 5:
888
952
  case "end":
889
- return _context7.stop();
953
+ return _context8.stop();
890
954
  }
891
- }, _callee7, this);
955
+ }, _callee8, this);
892
956
  }));
893
- function getAssetHubForeignBalance(_x9, _x10) {
957
+ function getAssetHubForeignBalance(_x10, _x11) {
894
958
  return _getAssetHubForeignBalance.apply(this, arguments);
895
959
  }
896
960
  return getAssetHubForeignBalance;
@@ -898,23 +962,23 @@ var PapiApi = /*#__PURE__*/function () {
898
962
  }, {
899
963
  key: "getForeignAssetsByIdBalance",
900
964
  value: function () {
901
- var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, assetId) {
965
+ var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, assetId) {
902
966
  var res;
903
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
904
- while (1) switch (_context8.prev = _context8.next) {
967
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
968
+ while (1) switch (_context9.prev = _context9.next) {
905
969
  case 0:
906
- _context8.next = 2;
970
+ _context9.next = 2;
907
971
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
908
972
  case 2:
909
- res = _context8.sent;
910
- return _context8.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
973
+ res = _context9.sent;
974
+ return _context9.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
911
975
  case 4:
912
976
  case "end":
913
- return _context8.stop();
977
+ return _context9.stop();
914
978
  }
915
- }, _callee8, this);
979
+ }, _callee9, this);
916
980
  }));
917
- function getForeignAssetsByIdBalance(_x11, _x12) {
981
+ function getForeignAssetsByIdBalance(_x12, _x13) {
918
982
  return _getForeignAssetsByIdBalance.apply(this, arguments);
919
983
  }
920
984
  return getForeignAssetsByIdBalance;
@@ -922,26 +986,26 @@ var PapiApi = /*#__PURE__*/function () {
922
986
  }, {
923
987
  key: "getBalanceForeignBifrost",
924
988
  value: function () {
925
- var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, asset) {
989
+ var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, asset) {
926
990
  var currencySelection, transformedParameters, response, accountData;
927
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
928
- while (1) switch (_context9.prev = _context9.next) {
991
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
992
+ while (1) switch (_context10.prev = _context10.next) {
929
993
  case 0:
930
994
  currencySelection = sdkCore.getNode('BifrostPolkadot').getCurrencySelection(asset);
931
995
  transformedParameters = _transform(currencySelection);
932
- _context9.next = 4;
996
+ _context10.next = 4;
933
997
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
934
998
  case 4:
935
- response = _context9.sent;
999
+ response = _context10.sent;
936
1000
  accountData = response ? response : null;
937
- return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
1001
+ return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
938
1002
  case 7:
939
1003
  case "end":
940
- return _context9.stop();
1004
+ return _context10.stop();
941
1005
  }
942
- }, _callee9, this);
1006
+ }, _callee10, this);
943
1007
  }));
944
- function getBalanceForeignBifrost(_x13, _x14) {
1008
+ function getBalanceForeignBifrost(_x14, _x15) {
945
1009
  return _getBalanceForeignBifrost.apply(this, arguments);
946
1010
  }
947
1011
  return getBalanceForeignBifrost;
@@ -949,27 +1013,27 @@ var PapiApi = /*#__PURE__*/function () {
949
1013
  }, {
950
1014
  key: "getBalanceNativeAcala",
951
1015
  value: function () {
952
- var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, symbol) {
1016
+ var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address, symbol) {
953
1017
  var transformedParameters, response, accountData;
954
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
955
- while (1) switch (_context10.prev = _context10.next) {
1018
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1019
+ while (1) switch (_context11.prev = _context11.next) {
956
1020
  case 0:
957
1021
  transformedParameters = _transform({
958
1022
  Token: symbol
959
1023
  });
960
- _context10.next = 3;
1024
+ _context11.next = 3;
961
1025
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
962
1026
  case 3:
963
- response = _context10.sent;
1027
+ response = _context11.sent;
964
1028
  accountData = response ? response : null;
965
- return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
1029
+ return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
966
1030
  case 6:
967
1031
  case "end":
968
- return _context10.stop();
1032
+ return _context11.stop();
969
1033
  }
970
- }, _callee10, this);
1034
+ }, _callee11, this);
971
1035
  }));
972
- function getBalanceNativeAcala(_x15, _x16) {
1036
+ function getBalanceNativeAcala(_x16, _x17) {
973
1037
  return _getBalanceNativeAcala.apply(this, arguments);
974
1038
  }
975
1039
  return getBalanceNativeAcala;
@@ -977,35 +1041,35 @@ var PapiApi = /*#__PURE__*/function () {
977
1041
  }, {
978
1042
  key: "getBalanceForeignXTokens",
979
1043
  value: function () {
980
- var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(node, address, asset) {
1044
+ var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(node, address, asset) {
981
1045
  var pallet, response, entry;
982
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
983
- while (1) switch (_context11.prev = _context11.next) {
1046
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1047
+ while (1) switch (_context12.prev = _context12.next) {
984
1048
  case 0:
985
1049
  pallet = 'Tokens';
986
1050
  if (node === 'Centrifuge' || node === 'Altair') {
987
1051
  pallet = 'OrmlTokens';
988
1052
  }
989
- _context11.next = 4;
1053
+ _context12.next = 4;
990
1054
  return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
991
1055
  case 4:
992
- response = _context11.sent;
1056
+ response = _context12.sent;
993
1057
  entry = response.find(function (_ref2) {
994
1058
  var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
995
1059
  var keyArgs = _ref2.keyArgs;
996
1060
  var _keyArgs = _slicedToArray(keyArgs, 2);
997
1061
  _keyArgs[0];
998
1062
  var assetItem = _keyArgs[1];
999
- return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === undefined ? undefined : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === undefined ? undefined : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === undefined ? undefined : _asset$assetId2.toLowerCase());
1063
+ return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
1000
1064
  });
1001
- return _context11.abrupt("return", entry !== null && entry !== undefined && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1065
+ return _context12.abrupt("return", entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1002
1066
  case 7:
1003
1067
  case "end":
1004
- return _context11.stop();
1068
+ return _context12.stop();
1005
1069
  }
1006
- }, _callee11, this);
1070
+ }, _callee12, this);
1007
1071
  }));
1008
- function getBalanceForeignXTokens(_x17, _x18, _x19) {
1072
+ function getBalanceForeignXTokens(_x18, _x19, _x20) {
1009
1073
  return _getBalanceForeignXTokens.apply(this, arguments);
1010
1074
  }
1011
1075
  return getBalanceForeignXTokens;
@@ -1013,45 +1077,51 @@ var PapiApi = /*#__PURE__*/function () {
1013
1077
  }, {
1014
1078
  key: "getBalanceForeignAssetsAccount",
1015
1079
  value: function () {
1016
- var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address, assetId) {
1080
+ var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, assetId) {
1017
1081
  var response;
1018
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1019
- while (1) switch (_context12.prev = _context12.next) {
1082
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1083
+ while (1) switch (_context13.prev = _context13.next) {
1020
1084
  case 0:
1021
- _context12.next = 2;
1085
+ _context13.next = 2;
1022
1086
  return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
1023
1087
  case 2:
1024
- response = _context12.sent;
1025
- return _context12.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
1088
+ response = _context13.sent;
1089
+ return _context13.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
1026
1090
  case 4:
1027
1091
  case "end":
1028
- return _context12.stop();
1092
+ return _context13.stop();
1029
1093
  }
1030
- }, _callee12, this);
1094
+ }, _callee13, this);
1031
1095
  }));
1032
- function getBalanceForeignAssetsAccount(_x20, _x21) {
1096
+ function getBalanceForeignAssetsAccount(_x21, _x22) {
1033
1097
  return _getBalanceForeignAssetsAccount.apply(this, arguments);
1034
1098
  }
1035
1099
  return getBalanceForeignAssetsAccount;
1036
1100
  }()
1037
1101
  }, {
1038
- key: "getFromStorage",
1102
+ key: "getFromRpc",
1039
1103
  value: function () {
1040
- var _getFromStorage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(key) {
1041
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1042
- while (1) switch (_context13.prev = _context13.next) {
1104
+ var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(module, method, key) {
1105
+ var toSS58, value;
1106
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1107
+ while (1) switch (_context14.prev = _context14.next) {
1043
1108
  case 0:
1044
- return _context13.abrupt("return", this.api._request('state_getStorage', [key]));
1045
- case 1:
1109
+ toSS58 = polkadotApi.AccountId().dec;
1110
+ _context14.next = 3;
1111
+ return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) ? toSS58(key) : key]);
1112
+ case 3:
1113
+ value = _context14.sent;
1114
+ return _context14.abrupt("return", isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
1115
+ case 5:
1046
1116
  case "end":
1047
- return _context13.stop();
1117
+ return _context14.stop();
1048
1118
  }
1049
- }, _callee13, this);
1119
+ }, _callee14, this);
1050
1120
  }));
1051
- function getFromStorage(_x22) {
1052
- return _getFromStorage.apply(this, arguments);
1121
+ function getFromRpc(_x23, _x24, _x25) {
1122
+ return _getFromRpc.apply(this, arguments);
1053
1123
  }
1054
- return getFromStorage;
1124
+ return getFromRpc;
1055
1125
  }()
1056
1126
  }, {
1057
1127
  key: "clone",
@@ -1061,23 +1131,23 @@ var PapiApi = /*#__PURE__*/function () {
1061
1131
  }, {
1062
1132
  key: "createApiForNode",
1063
1133
  value: function () {
1064
- var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(node) {
1134
+ var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(node) {
1065
1135
  var api;
1066
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1067
- while (1) switch (_context14.prev = _context14.next) {
1136
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1137
+ while (1) switch (_context15.prev = _context15.next) {
1068
1138
  case 0:
1069
1139
  api = new PapiApi();
1070
- _context14.next = 3;
1140
+ _context15.next = 3;
1071
1141
  return api.init(node);
1072
1142
  case 3:
1073
- return _context14.abrupt("return", api);
1143
+ return _context15.abrupt("return", api);
1074
1144
  case 4:
1075
1145
  case "end":
1076
- return _context14.stop();
1146
+ return _context15.stop();
1077
1147
  }
1078
- }, _callee14);
1148
+ }, _callee15);
1079
1149
  }));
1080
- function createApiForNode(_x23) {
1150
+ function createApiForNode(_x26) {
1081
1151
  return _createApiForNode.apply(this, arguments);
1082
1152
  }
1083
1153
  return createApiForNode;
@@ -1085,20 +1155,20 @@ var PapiApi = /*#__PURE__*/function () {
1085
1155
  }, {
1086
1156
  key: "getDryRun",
1087
1157
  value: function () {
1088
- var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref3) {
1158
+ var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref3) {
1089
1159
  var tx, address, node, supportsDryRunApi, result, isSuccess, failureReason, executionFee, fee;
1090
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1091
- while (1) switch (_context15.prev = _context15.next) {
1160
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1161
+ while (1) switch (_context16.prev = _context16.next) {
1092
1162
  case 0:
1093
1163
  tx = _ref3.tx, address = _ref3.address, node = _ref3.node;
1094
1164
  supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
1095
1165
  if (supportsDryRunApi) {
1096
- _context15.next = 4;
1166
+ _context16.next = 4;
1097
1167
  break;
1098
1168
  }
1099
1169
  throw new Error("DryRunApi is not available on node ".concat(node));
1100
1170
  case 4:
1101
- _context15.next = 6;
1171
+ _context16.next = 6;
1102
1172
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_call({
1103
1173
  type: 'system',
1104
1174
  value: {
@@ -1107,34 +1177,34 @@ var PapiApi = /*#__PURE__*/function () {
1107
1177
  }
1108
1178
  }, tx.decodedCall);
1109
1179
  case 6:
1110
- result = _context15.sent;
1180
+ result = _context16.sent;
1111
1181
  isSuccess = result.success && result.value.execution_result.success;
1112
1182
  if (isSuccess) {
1113
- _context15.next = 11;
1183
+ _context16.next = 11;
1114
1184
  break;
1115
1185
  }
1116
1186
  failureReason = result.value.execution_result.value.error.value.value.type;
1117
- return _context15.abrupt("return", Promise.resolve({
1187
+ return _context16.abrupt("return", Promise.resolve({
1118
1188
  success: false,
1119
1189
  failureReason: failureReason
1120
1190
  }));
1121
1191
  case 11:
1122
- _context15.next = 13;
1192
+ _context16.next = 13;
1123
1193
  return this.calculateTransactionFee(tx, address);
1124
1194
  case 13:
1125
- executionFee = _context15.sent;
1195
+ executionFee = _context16.sent;
1126
1196
  fee = sdkCore.computeFeeFromDryRun(result, node, executionFee);
1127
- return _context15.abrupt("return", Promise.resolve({
1197
+ return _context16.abrupt("return", Promise.resolve({
1128
1198
  success: true,
1129
1199
  fee: fee
1130
1200
  }));
1131
1201
  case 16:
1132
1202
  case "end":
1133
- return _context15.stop();
1203
+ return _context16.stop();
1134
1204
  }
1135
- }, _callee15, this);
1205
+ }, _callee16, this);
1136
1206
  }));
1137
- function getDryRun(_x24) {
1207
+ function getDryRun(_x27) {
1138
1208
  return _getDryRun.apply(this, arguments);
1139
1209
  }
1140
1210
  return getDryRun;
@@ -1264,6 +1334,7 @@ var getOriginFeeDetails = createPapiApiCall(sdkCore.getOriginFeeDetails);
1264
1334
  var getMaxNativeTransferableAmount = createPapiApiCall(sdkCore.getMaxNativeTransferableAmount);
1265
1335
  var getMaxForeignTransferableAmount = createPapiApiCall(sdkCore.getMaxForeignTransferableAmount);
1266
1336
  var getTransferableAmount = createPapiApiCall(sdkCore.getTransferableAmount);
1337
+ var verifyEdOnDestination = createPapiApiCall(sdkCore.verifyEdOnDestination);
1267
1338
 
1268
1339
  var assets = /*#__PURE__*/Object.freeze({
1269
1340
  __proto__: null,
@@ -1294,7 +1365,8 @@ var assets = /*#__PURE__*/Object.freeze({
1294
1365
  getTransferInfo: getTransferInfo,
1295
1366
  getTransferableAmount: getTransferableAmount,
1296
1367
  hasSupportForAsset: sdkCore.hasSupportForAsset,
1297
- isNodeEvm: sdkCore.isNodeEvm
1368
+ isNodeEvm: sdkCore.isNodeEvm,
1369
+ verifyEdOnDestination: verifyEdOnDestination
1298
1370
  });
1299
1371
 
1300
1372
  /**
@@ -1344,8 +1416,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1344
1416
  */
1345
1417
  }, {
1346
1418
  key: "address",
1347
- value: function address(_address) {
1419
+ value: function address(_address, ahAddress) {
1348
1420
  this._options.address = _address;
1421
+ this._options.ahAddress = ahAddress;
1349
1422
  return this;
1350
1423
  }
1351
1424
  /**
@@ -1391,11 +1464,18 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1391
1464
  _context.next = 2;
1392
1465
  break;
1393
1466
  case 9:
1394
- _context.next = 11;
1467
+ sdkCore.validateAddress(this._options.address, this._options.to);
1468
+ if (!(this._options.from === 'Moonbeam' && this._options.to === 'Ethereum')) {
1469
+ _context.next = 12;
1470
+ break;
1471
+ }
1472
+ return _context.abrupt("return", sdkCore.transferMoonbeamToEth(this._options));
1473
+ case 12:
1474
+ _context.next = 14;
1395
1475
  return sdkCore.transferMoonbeamEvm(this._options);
1396
- case 11:
1476
+ case 14:
1397
1477
  return _context.abrupt("return", _context.sent);
1398
- case 12:
1478
+ case 15:
1399
1479
  case "end":
1400
1480
  return _context.stop();
1401
1481
  }
@@ -1452,6 +1532,7 @@ exports.getParaEthTransferFees = getParaEthTransferFees;
1452
1532
  exports.getTransferInfo = getTransferInfo;
1453
1533
  exports.getTransferableAmount = getTransferableAmount;
1454
1534
  exports.send = send;
1535
+ exports.verifyEdOnDestination = verifyEdOnDestination;
1455
1536
  exports.xcmPallet = transfer;
1456
1537
  Object.keys(sdkCore).forEach(function (k) {
1457
1538
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {