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