@paraspell/sdk 10.10.11 → 10.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, findAsset, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, getAssetsObject, localizeLocation, isRelayChain, InvalidCurrencyError, padFeeBy, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
1
+ import { InvalidParameterError, isConfig, BatchMode, getNodeProviders, MissingChainApiError, NodeNotSupportedError, createApiInstanceForNode as createApiInstanceForNode$1, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, findAsset, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, getAssetsObject, localizeLocation, isRelayChain, InvalidCurrencyError, padFeeBy, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { blake2b } from '@noble/hashes/blake2';
4
4
  import { bytesToHex } from '@noble/hashes/utils';
@@ -547,7 +547,7 @@ function createClientCache(maxSize, onEviction) {
547
547
  // Call rpc.properties to keep the connection alive
548
548
  void _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
549
549
  return _regenerator().w(function (_context) {
550
- while (1) switch (_context.n) {
550
+ while (1) switch (_context.p = _context.n) {
551
551
  case 0:
552
552
  _context.p = 0;
553
553
  _context.n = 1;
@@ -784,21 +784,17 @@ var isHex = function isHex(str) {
784
784
  return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
785
785
  };
786
786
  var PapiApi = /*#__PURE__*/function () {
787
- function PapiApi() {
787
+ function PapiApi(config) {
788
788
  _classCallCheck(this, PapiApi);
789
789
  this._ttlMs = DEFAULT_TTL_MS;
790
790
  this.initialized = false;
791
791
  this.disconnectAllowed = true;
792
+ this._config = config;
792
793
  }
793
794
  return _createClass(PapiApi, [{
794
- key: "setApi",
795
- value: function setApi(api) {
796
- this._api = api;
797
- }
798
- }, {
799
- key: "getApiOrUrl",
800
- value: function getApiOrUrl() {
801
- return this._api;
795
+ key: "getConfig",
796
+ value: function getConfig() {
797
+ return this._config;
802
798
  }
803
799
  }, {
804
800
  key: "getApi",
@@ -808,57 +804,41 @@ var PapiApi = /*#__PURE__*/function () {
808
804
  }, {
809
805
  key: "init",
810
806
  value: function () {
811
- var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(node) {
807
+ var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
812
808
  var clientTtlMs,
813
- _this$_api,
814
- _args3 = arguments,
815
- _t3;
809
+ apiConfig,
810
+ _args3 = arguments;
816
811
  return _regenerator().w(function (_context3) {
817
812
  while (1) switch (_context3.n) {
818
813
  case 0:
819
814
  clientTtlMs = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : DEFAULT_TTL_MS;
820
- if (!(this.initialized || node === 'Ethereum')) {
815
+ if (!(this.initialized || chain === 'Ethereum')) {
821
816
  _context3.n = 1;
822
817
  break;
823
818
  }
824
819
  return _context3.a(2);
825
820
  case 1:
826
- if (!unsupportedNodes.includes(node)) {
821
+ if (!unsupportedNodes.includes(chain)) {
827
822
  _context3.n = 2;
828
823
  break;
829
824
  }
830
- throw new NodeNotSupportedError("The node ".concat(node, " is not yet supported by the Polkadot API."));
825
+ throw new NodeNotSupportedError("The node ".concat(chain, " is not yet supported by the Polkadot API."));
831
826
  case 2:
832
827
  this._ttlMs = clientTtlMs;
833
- if (!(typeof this._api === 'string' || this._api instanceof Array)) {
834
- _context3.n = 4;
828
+ this._node = chain;
829
+ apiConfig = this.getApiConfigForChain(chain); // For development mode, api for each used chain must be provided
830
+ if (!(isConfig(this._config) && this._config.development && !apiConfig)) {
831
+ _context3.n = 3;
835
832
  break;
836
833
  }
837
- _context3.n = 3;
838
- return this.createApiInstance(this._api);
834
+ throw new MissingChainApiError(chain);
839
835
  case 3:
840
- this.api = _context3.v;
841
- _context3.n = 8;
842
- break;
836
+ _context3.n = 4;
837
+ return this.resolveApi(apiConfig, chain);
843
838
  case 4:
844
- if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
845
- _context3.n = 5;
846
- break;
847
- }
848
- _t3 = _this$_api;
849
- _context3.n = 7;
850
- break;
851
- case 5:
852
- _context3.n = 6;
853
- return createApiInstanceForNode$1(this, node);
854
- case 6:
855
- _t3 = _context3.v;
856
- case 7:
857
- this.api = _t3;
858
- case 8:
859
- this._node = node;
839
+ this.api = _context3.v;
860
840
  this.initialized = true;
861
- case 9:
841
+ case 5:
862
842
  return _context3.a(2);
863
843
  }
864
844
  }, _callee3, this);
@@ -869,17 +849,54 @@ var PapiApi = /*#__PURE__*/function () {
869
849
  return init;
870
850
  }()
871
851
  }, {
872
- key: "createApiInstance",
852
+ key: "getApiConfigForChain",
853
+ value: function getApiConfigForChain(chain) {
854
+ if (isConfig(this._config)) {
855
+ var _this$_config$apiOver;
856
+ return (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[chain];
857
+ }
858
+ return this._config;
859
+ }
860
+ }, {
861
+ key: "resolveApi",
873
862
  value: function () {
874
- var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(wsUrl) {
863
+ var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(apiConfig, chain) {
875
864
  return _regenerator().w(function (_context4) {
876
865
  while (1) switch (_context4.n) {
877
866
  case 0:
878
- return _context4.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
867
+ if (apiConfig) {
868
+ _context4.n = 1;
869
+ break;
870
+ }
871
+ return _context4.a(2, createApiInstanceForNode$1(this, chain));
872
+ case 1:
873
+ if (!(typeof apiConfig === 'string' || apiConfig instanceof Array)) {
874
+ _context4.n = 2;
875
+ break;
876
+ }
877
+ return _context4.a(2, this.createApiInstance(apiConfig));
878
+ case 2:
879
+ return _context4.a(2, apiConfig);
879
880
  }
880
881
  }, _callee4, this);
881
882
  }));
882
- function createApiInstance(_x5) {
883
+ function resolveApi(_x5, _x6) {
884
+ return _resolveApi.apply(this, arguments);
885
+ }
886
+ return resolveApi;
887
+ }()
888
+ }, {
889
+ key: "createApiInstance",
890
+ value: function () {
891
+ var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(wsUrl) {
892
+ return _regenerator().w(function (_context5) {
893
+ while (1) switch (_context5.n) {
894
+ case 0:
895
+ return _context5.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
896
+ }
897
+ }, _callee5, this);
898
+ }));
899
+ function createApiInstance(_x7) {
883
900
  return _createApiInstance.apply(this, arguments);
884
901
  }
885
902
  return createApiInstance;
@@ -923,10 +940,10 @@ var PapiApi = /*#__PURE__*/function () {
923
940
  }, {
924
941
  key: "objectToHex",
925
942
  value: function () {
926
- var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(obj) {
943
+ var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(obj) {
927
944
  var transformedObj, tx, removeFirst5Bytes, encodedData;
928
- return _regenerator().w(function (_context5) {
929
- while (1) switch (_context5.n) {
945
+ return _regenerator().w(function (_context6) {
946
+ while (1) switch (_context6.n) {
930
947
  case 0:
931
948
  transformedObj = _transform(obj);
932
949
  tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
@@ -944,15 +961,15 @@ var PapiApi = /*#__PURE__*/function () {
944
961
  removeFirst5Bytes = function removeFirst5Bytes(hexString) {
945
962
  return '0x' + hexString.slice(12);
946
963
  };
947
- _context5.n = 1;
964
+ _context6.n = 1;
948
965
  return tx.getEncodedData();
949
966
  case 1:
950
- encodedData = _context5.v;
951
- return _context5.a(2, removeFirst5Bytes(encodedData.asHex()));
967
+ encodedData = _context6.v;
968
+ return _context6.a(2, removeFirst5Bytes(encodedData.asHex()));
952
969
  }
953
- }, _callee5, this);
970
+ }, _callee6, this);
954
971
  }));
955
- function objectToHex(_x6) {
972
+ function objectToHex(_x8) {
956
973
  return _objectToHex.apply(this, arguments);
957
974
  }
958
975
  return objectToHex;
@@ -982,15 +999,15 @@ var PapiApi = /*#__PURE__*/function () {
982
999
  }, {
983
1000
  key: "calculateTransactionFee",
984
1001
  value: function () {
985
- var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(tx, address) {
986
- return _regenerator().w(function (_context6) {
987
- while (1) switch (_context6.n) {
1002
+ var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(tx, address) {
1003
+ return _regenerator().w(function (_context7) {
1004
+ while (1) switch (_context7.n) {
988
1005
  case 0:
989
- return _context6.a(2, tx.getEstimatedFees(address));
1006
+ return _context7.a(2, tx.getEstimatedFees(address));
990
1007
  }
991
- }, _callee6);
1008
+ }, _callee7);
992
1009
  }));
993
- function calculateTransactionFee(_x7, _x8) {
1010
+ function calculateTransactionFee(_x9, _x0) {
994
1011
  return _calculateTransactionFee.apply(this, arguments);
995
1012
  }
996
1013
  return calculateTransactionFee;
@@ -998,27 +1015,27 @@ var PapiApi = /*#__PURE__*/function () {
998
1015
  }, {
999
1016
  key: "quoteAhPrice",
1000
1017
  value: function () {
1001
- var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(fromMl, toMl, amountIn) {
1018
+ var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(fromMl, toMl, amountIn) {
1002
1019
  var includeFee,
1003
1020
  transformedFromMl,
1004
1021
  transformedToMl,
1005
1022
  response,
1006
- _args7 = arguments;
1007
- return _regenerator().w(function (_context7) {
1008
- while (1) switch (_context7.n) {
1023
+ _args8 = arguments;
1024
+ return _regenerator().w(function (_context8) {
1025
+ while (1) switch (_context8.n) {
1009
1026
  case 0:
1010
- includeFee = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : true;
1027
+ includeFee = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : true;
1011
1028
  transformedFromMl = _transform(fromMl);
1012
1029
  transformedToMl = _transform(toMl);
1013
- _context7.n = 1;
1030
+ _context8.n = 1;
1014
1031
  return this.api.getUnsafeApi().apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
1015
1032
  case 1:
1016
- response = _context7.v;
1017
- return _context7.a(2, response ? BigInt(response) : undefined);
1033
+ response = _context8.v;
1034
+ return _context8.a(2, response ? BigInt(response) : undefined);
1018
1035
  }
1019
- }, _callee7, this);
1036
+ }, _callee8, this);
1020
1037
  }));
1021
- function quoteAhPrice(_x9, _x0, _x1) {
1038
+ function quoteAhPrice(_x1, _x10, _x11) {
1022
1039
  return _quoteAhPrice.apply(this, arguments);
1023
1040
  }
1024
1041
  return quoteAhPrice;
@@ -1026,20 +1043,20 @@ var PapiApi = /*#__PURE__*/function () {
1026
1043
  }, {
1027
1044
  key: "getBalanceNative",
1028
1045
  value: function () {
1029
- var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(address) {
1046
+ var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
1030
1047
  var res;
1031
- return _regenerator().w(function (_context8) {
1032
- while (1) switch (_context8.n) {
1048
+ return _regenerator().w(function (_context9) {
1049
+ while (1) switch (_context9.n) {
1033
1050
  case 0:
1034
- _context8.n = 1;
1051
+ _context9.n = 1;
1035
1052
  return this.api.getUnsafeApi().query.System.Account.getValue(address);
1036
1053
  case 1:
1037
- res = _context8.v;
1038
- return _context8.a(2, res.data.free);
1054
+ res = _context9.v;
1055
+ return _context9.a(2, res.data.free);
1039
1056
  }
1040
- }, _callee8, this);
1057
+ }, _callee9, this);
1041
1058
  }));
1042
- function getBalanceNative(_x10) {
1059
+ function getBalanceNative(_x12) {
1043
1060
  return _getBalanceNative.apply(this, arguments);
1044
1061
  }
1045
1062
  return getBalanceNative;
@@ -1047,20 +1064,20 @@ var PapiApi = /*#__PURE__*/function () {
1047
1064
  }, {
1048
1065
  key: "getBalanceForeignPolkadotXcm",
1049
1066
  value: function () {
1050
- var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address, id) {
1067
+ var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, id) {
1051
1068
  var res;
1052
- return _regenerator().w(function (_context9) {
1053
- while (1) switch (_context9.n) {
1069
+ return _regenerator().w(function (_context0) {
1070
+ while (1) switch (_context0.n) {
1054
1071
  case 0:
1055
- _context9.n = 1;
1072
+ _context0.n = 1;
1056
1073
  return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
1057
1074
  case 1:
1058
- res = _context9.v;
1059
- return _context9.a(2, res && res.balance ? BigInt(res.balance) : 0n);
1075
+ res = _context0.v;
1076
+ return _context0.a(2, res && res.balance ? BigInt(res.balance) : 0n);
1060
1077
  }
1061
- }, _callee9, this);
1078
+ }, _callee0, this);
1062
1079
  }));
1063
- function getBalanceForeignPolkadotXcm(_x11, _x12) {
1080
+ function getBalanceForeignPolkadotXcm(_x13, _x14) {
1064
1081
  return _getBalanceForeignPolkadotXcm.apply(this, arguments);
1065
1082
  }
1066
1083
  return getBalanceForeignPolkadotXcm;
@@ -1068,20 +1085,20 @@ var PapiApi = /*#__PURE__*/function () {
1068
1085
  }, {
1069
1086
  key: "getMythosForeignBalance",
1070
1087
  value: function () {
1071
- var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address) {
1088
+ var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address) {
1072
1089
  var res;
1073
- return _regenerator().w(function (_context0) {
1074
- while (1) switch (_context0.n) {
1090
+ return _regenerator().w(function (_context1) {
1091
+ while (1) switch (_context1.n) {
1075
1092
  case 0:
1076
- _context0.n = 1;
1093
+ _context1.n = 1;
1077
1094
  return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
1078
1095
  case 1:
1079
- res = _context0.v;
1080
- return _context0.a(2, res && res.free ? BigInt(res.free) : 0n);
1096
+ res = _context1.v;
1097
+ return _context1.a(2, res && res.free ? BigInt(res.free) : 0n);
1081
1098
  }
1082
- }, _callee0, this);
1099
+ }, _callee1, this);
1083
1100
  }));
1084
- function getMythosForeignBalance(_x13) {
1101
+ function getMythosForeignBalance(_x15) {
1085
1102
  return _getMythosForeignBalance.apply(this, arguments);
1086
1103
  }
1087
1104
  return getMythosForeignBalance;
@@ -1089,21 +1106,21 @@ var PapiApi = /*#__PURE__*/function () {
1089
1106
  }, {
1090
1107
  key: "getBalanceForeignAssetsPallet",
1091
1108
  value: function () {
1092
- var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, multiLocation) {
1109
+ var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, multiLocation) {
1093
1110
  var transformedMultiLocation, res;
1094
- return _regenerator().w(function (_context1) {
1095
- while (1) switch (_context1.n) {
1111
+ return _regenerator().w(function (_context10) {
1112
+ while (1) switch (_context10.n) {
1096
1113
  case 0:
1097
1114
  transformedMultiLocation = _transform(multiLocation);
1098
- _context1.n = 1;
1115
+ _context10.n = 1;
1099
1116
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
1100
1117
  case 1:
1101
- res = _context1.v;
1102
- return _context1.a(2, BigInt(res === undefined ? 0 : res.balance));
1118
+ res = _context10.v;
1119
+ return _context10.a(2, BigInt(res === undefined ? 0 : res.balance));
1103
1120
  }
1104
- }, _callee1, this);
1121
+ }, _callee10, this);
1105
1122
  }));
1106
- function getBalanceForeignAssetsPallet(_x14, _x15) {
1123
+ function getBalanceForeignAssetsPallet(_x16, _x17) {
1107
1124
  return _getBalanceForeignAssetsPallet.apply(this, arguments);
1108
1125
  }
1109
1126
  return getBalanceForeignAssetsPallet;
@@ -1111,20 +1128,20 @@ var PapiApi = /*#__PURE__*/function () {
1111
1128
  }, {
1112
1129
  key: "getForeignAssetsByIdBalance",
1113
1130
  value: function () {
1114
- var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, assetId) {
1131
+ var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, assetId) {
1115
1132
  var res;
1116
- return _regenerator().w(function (_context10) {
1117
- while (1) switch (_context10.n) {
1133
+ return _regenerator().w(function (_context11) {
1134
+ while (1) switch (_context11.n) {
1118
1135
  case 0:
1119
- _context10.n = 1;
1136
+ _context11.n = 1;
1120
1137
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
1121
1138
  case 1:
1122
- res = _context10.v;
1123
- return _context10.a(2, BigInt(res === undefined ? 0 : res.balance));
1139
+ res = _context11.v;
1140
+ return _context11.a(2, BigInt(res === undefined ? 0 : res.balance));
1124
1141
  }
1125
- }, _callee10, this);
1142
+ }, _callee11, this);
1126
1143
  }));
1127
- function getForeignAssetsByIdBalance(_x16, _x17) {
1144
+ function getForeignAssetsByIdBalance(_x18, _x19) {
1128
1145
  return _getForeignAssetsByIdBalance.apply(this, arguments);
1129
1146
  }
1130
1147
  return getForeignAssetsByIdBalance;
@@ -1132,23 +1149,23 @@ var PapiApi = /*#__PURE__*/function () {
1132
1149
  }, {
1133
1150
  key: "getBalanceForeignBifrost",
1134
1151
  value: function () {
1135
- var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, asset) {
1152
+ var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(address, asset) {
1136
1153
  var currencySelection, transformedParameters, response, accountData;
1137
- return _regenerator().w(function (_context11) {
1138
- while (1) switch (_context11.n) {
1154
+ return _regenerator().w(function (_context12) {
1155
+ while (1) switch (_context12.n) {
1139
1156
  case 0:
1140
1157
  currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
1141
1158
  transformedParameters = _transform(currencySelection);
1142
- _context11.n = 1;
1159
+ _context12.n = 1;
1143
1160
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
1144
1161
  case 1:
1145
- response = _context11.v;
1162
+ response = _context12.v;
1146
1163
  accountData = response ? response : null;
1147
- return _context11.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1164
+ return _context12.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1148
1165
  }
1149
- }, _callee11, this);
1166
+ }, _callee12, this);
1150
1167
  }));
1151
- function getBalanceForeignBifrost(_x18, _x19) {
1168
+ function getBalanceForeignBifrost(_x20, _x21) {
1152
1169
  return _getBalanceForeignBifrost.apply(this, arguments);
1153
1170
  }
1154
1171
  return getBalanceForeignBifrost;
@@ -1156,24 +1173,24 @@ var PapiApi = /*#__PURE__*/function () {
1156
1173
  }, {
1157
1174
  key: "getBalanceNativeAcala",
1158
1175
  value: function () {
1159
- var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(address, symbol) {
1176
+ var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, symbol) {
1160
1177
  var transformedParameters, response, accountData;
1161
- return _regenerator().w(function (_context12) {
1162
- while (1) switch (_context12.n) {
1178
+ return _regenerator().w(function (_context13) {
1179
+ while (1) switch (_context13.n) {
1163
1180
  case 0:
1164
1181
  transformedParameters = _transform({
1165
1182
  Token: symbol
1166
1183
  });
1167
- _context12.n = 1;
1184
+ _context13.n = 1;
1168
1185
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
1169
1186
  case 1:
1170
- response = _context12.v;
1187
+ response = _context13.v;
1171
1188
  accountData = response ? response : null;
1172
- return _context12.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1189
+ return _context13.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1173
1190
  }
1174
- }, _callee12, this);
1191
+ }, _callee13, this);
1175
1192
  }));
1176
- function getBalanceNativeAcala(_x20, _x21) {
1193
+ function getBalanceNativeAcala(_x22, _x23) {
1177
1194
  return _getBalanceNativeAcala.apply(this, arguments);
1178
1195
  }
1179
1196
  return getBalanceNativeAcala;
@@ -1181,19 +1198,30 @@ var PapiApi = /*#__PURE__*/function () {
1181
1198
  }, {
1182
1199
  key: "getBalanceForeignXTokens",
1183
1200
  value: function () {
1184
- var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(node, address, asset) {
1185
- var pallet, response, entry;
1186
- return _regenerator().w(function (_context13) {
1187
- while (1) switch (_context13.n) {
1201
+ var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(node, address, asset) {
1202
+ var pallet, currencyId, _response, response, entry;
1203
+ return _regenerator().w(function (_context14) {
1204
+ while (1) switch (_context14.n) {
1188
1205
  case 0:
1189
1206
  pallet = 'Tokens';
1190
1207
  if (node === 'Centrifuge' || node === 'Altair') {
1191
1208
  pallet = 'OrmlTokens';
1192
1209
  }
1193
- _context13.n = 1;
1194
- return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
1210
+ if (!(node === 'Hydration' && (asset.symbol === 'aUSDT' || asset.symbol === 'aUSDC' || asset.symbol === 'aDOT' || asset.symbol === 'atBTC' || asset.symbol === 'avDOT' || asset.symbol === 'aETH' || asset.symbol === 'aWBTC'))) {
1211
+ _context14.n = 2;
1212
+ break;
1213
+ }
1214
+ currencyId = asset.symbol === 'aUSDT' ? 1002 : asset.symbol === 'aUSDC' ? 1003 : asset.symbol === 'aDOT' ? 1001 : asset.symbol === 'atBTC' ? 1006 : asset.symbol === 'avDOT' ? 1005 : asset.symbol === 'aETH' ? 1007 : 1004;
1215
+ _context14.n = 1;
1216
+ return this.api.getUnsafeApi().apis.CurrenciesApi.account(currencyId, address);
1195
1217
  case 1:
1196
- response = _context13.v;
1218
+ _response = _context14.v;
1219
+ return _context14.a(2, _response ? BigInt(_response.free.toString()) : 0n);
1220
+ case 2:
1221
+ _context14.n = 3;
1222
+ return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
1223
+ case 3:
1224
+ response = _context14.v;
1197
1225
  entry = response.find(function (_ref5) {
1198
1226
  var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
1199
1227
  var keyArgs = _ref5.keyArgs;
@@ -1202,11 +1230,11 @@ var PapiApi = /*#__PURE__*/function () {
1202
1230
  var assetItem = _keyArgs[1];
1203
1231
  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());
1204
1232
  });
1205
- return _context13.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1233
+ return _context14.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1206
1234
  }
1207
- }, _callee13, this);
1235
+ }, _callee14, this);
1208
1236
  }));
1209
- function getBalanceForeignXTokens(_x22, _x23, _x24) {
1237
+ function getBalanceForeignXTokens(_x24, _x25, _x26) {
1210
1238
  return _getBalanceForeignXTokens.apply(this, arguments);
1211
1239
  }
1212
1240
  return getBalanceForeignXTokens;
@@ -1214,20 +1242,20 @@ var PapiApi = /*#__PURE__*/function () {
1214
1242
  }, {
1215
1243
  key: "getBalanceAssetsPallet",
1216
1244
  value: function () {
1217
- var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(address, assetId) {
1245
+ var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(address, assetId) {
1218
1246
  var response;
1219
- return _regenerator().w(function (_context14) {
1220
- while (1) switch (_context14.n) {
1247
+ return _regenerator().w(function (_context15) {
1248
+ while (1) switch (_context15.n) {
1221
1249
  case 0:
1222
- _context14.n = 1;
1250
+ _context15.n = 1;
1223
1251
  return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
1224
1252
  case 1:
1225
- response = _context14.v;
1226
- return _context14.a(2, BigInt(response === undefined ? 0 : response.balance));
1253
+ response = _context15.v;
1254
+ return _context15.a(2, BigInt(response === undefined ? 0 : response.balance));
1227
1255
  }
1228
- }, _callee14, this);
1256
+ }, _callee15, this);
1229
1257
  }));
1230
- function getBalanceAssetsPallet(_x25, _x26) {
1258
+ function getBalanceAssetsPallet(_x27, _x28) {
1231
1259
  return _getBalanceAssetsPallet.apply(this, arguments);
1232
1260
  }
1233
1261
  return getBalanceAssetsPallet;
@@ -1235,21 +1263,21 @@ var PapiApi = /*#__PURE__*/function () {
1235
1263
  }, {
1236
1264
  key: "getFromRpc",
1237
1265
  value: function () {
1238
- var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(module, method, key) {
1266
+ var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(module, method, key) {
1239
1267
  var toSS58, value;
1240
- return _regenerator().w(function (_context15) {
1241
- while (1) switch (_context15.n) {
1268
+ return _regenerator().w(function (_context16) {
1269
+ while (1) switch (_context16.n) {
1242
1270
  case 0:
1243
1271
  toSS58 = AccountId().dec;
1244
- _context15.n = 1;
1272
+ _context16.n = 1;
1245
1273
  return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? toSS58(key) : key]);
1246
1274
  case 1:
1247
- value = _context15.v;
1248
- return _context15.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
1275
+ value = _context16.v;
1276
+ return _context16.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
1249
1277
  }
1250
- }, _callee15, this);
1278
+ }, _callee16, this);
1251
1279
  }));
1252
- function getFromRpc(_x27, _x28, _x29) {
1280
+ function getFromRpc(_x29, _x30, _x31) {
1253
1281
  return _getFromRpc.apply(this, arguments);
1254
1282
  }
1255
1283
  return getFromRpc;
@@ -1257,25 +1285,25 @@ var PapiApi = /*#__PURE__*/function () {
1257
1285
  }, {
1258
1286
  key: "clone",
1259
1287
  value: function clone() {
1260
- return new PapiApi();
1288
+ return new PapiApi(isConfig(this._config) ? this._config : undefined);
1261
1289
  }
1262
1290
  }, {
1263
1291
  key: "createApiForNode",
1264
1292
  value: function () {
1265
- var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(node) {
1293
+ var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(node) {
1266
1294
  var api;
1267
- return _regenerator().w(function (_context16) {
1268
- while (1) switch (_context16.n) {
1295
+ return _regenerator().w(function (_context17) {
1296
+ while (1) switch (_context17.n) {
1269
1297
  case 0:
1270
1298
  api = new PapiApi();
1271
- _context16.n = 1;
1299
+ _context17.n = 1;
1272
1300
  return api.init(node);
1273
1301
  case 1:
1274
- return _context16.a(2, api);
1302
+ return _context17.a(2, api);
1275
1303
  }
1276
- }, _callee16);
1304
+ }, _callee17);
1277
1305
  }));
1278
- function createApiForNode(_x30) {
1306
+ function createApiForNode(_x32) {
1279
1307
  return _createApiForNode.apply(this, arguments);
1280
1308
  }
1281
1309
  return createApiForNode;
@@ -1283,16 +1311,16 @@ var PapiApi = /*#__PURE__*/function () {
1283
1311
  }, {
1284
1312
  key: "getDryRunCall",
1285
1313
  value: function () {
1286
- var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
1314
+ var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref6) {
1287
1315
  var _this = this;
1288
1316
  var tx, address, node, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasMultiLocation, xcmFee, fee;
1289
- return _regenerator().w(function (_context18) {
1290
- while (1) switch (_context18.n) {
1317
+ return _regenerator().w(function (_context19) {
1318
+ while (1) switch (_context19.n) {
1291
1319
  case 0:
1292
1320
  tx = _ref6.tx, address = _ref6.address, node = _ref6.node, feeAsset = _ref6.feeAsset;
1293
1321
  supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
1294
1322
  if (supportsDryRunApi) {
1295
- _context18.n = 1;
1323
+ _context19.n = 1;
1296
1324
  break;
1297
1325
  }
1298
1326
  throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
@@ -1306,21 +1334,21 @@ var PapiApi = /*#__PURE__*/function () {
1306
1334
  }
1307
1335
  };
1308
1336
  performDryRunCall = /*#__PURE__*/function () {
1309
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(includeVersion) {
1337
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(includeVersion) {
1310
1338
  var _this$api$getUnsafeAp;
1311
1339
  var callArgs;
1312
- return _regenerator().w(function (_context17) {
1313
- while (1) switch (_context17.n) {
1340
+ return _regenerator().w(function (_context18) {
1341
+ while (1) switch (_context18.n) {
1314
1342
  case 0:
1315
1343
  callArgs = [basePayload, tx.decodedCall];
1316
1344
  if (includeVersion) {
1317
1345
  callArgs.push(DEFAULT_XCM_VERSION);
1318
1346
  }
1319
- return _context17.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
1347
+ return _context18.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
1320
1348
  }
1321
- }, _callee17);
1349
+ }, _callee18);
1322
1350
  }));
1323
- return function performDryRunCall(_x32) {
1351
+ return function performDryRunCall(_x34) {
1324
1352
  return _ref7.apply(this, arguments);
1325
1353
  };
1326
1354
  }();
@@ -1343,25 +1371,25 @@ var PapiApi = /*#__PURE__*/function () {
1343
1371
  return JSON.stringify((_ref8 = (_result$value4 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value4 !== void 0 ? _result$value4 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure');
1344
1372
  };
1345
1373
  failureOutputReason = '';
1346
- _context18.n = 2;
1374
+ _context19.n = 2;
1347
1375
  return performDryRunCall(false);
1348
1376
  case 2:
1349
- result = _context18.v;
1377
+ result = _context19.v;
1350
1378
  isSuccess = getExecutionSuccessFromResult(result);
1351
1379
  if (isSuccess) {
1352
- _context18.n = 4;
1380
+ _context19.n = 4;
1353
1381
  break;
1354
1382
  }
1355
1383
  initialFailureReason = extractFailureReasonFromResult(result);
1356
1384
  failureOutputReason = initialFailureReason;
1357
1385
  if (!(initialFailureReason === 'VersionedConversionFailed')) {
1358
- _context18.n = 4;
1386
+ _context19.n = 4;
1359
1387
  break;
1360
1388
  }
1361
- _context18.n = 3;
1389
+ _context19.n = 3;
1362
1390
  return performDryRunCall(true);
1363
1391
  case 3:
1364
- result = _context18.v;
1392
+ result = _context19.v;
1365
1393
  isSuccess = getExecutionSuccessFromResult(result);
1366
1394
  if (!isSuccess) {
1367
1395
  failureOutputReason = extractFailureReasonFromResult(result);
@@ -1370,10 +1398,10 @@ var PapiApi = /*#__PURE__*/function () {
1370
1398
  }
1371
1399
  case 4:
1372
1400
  if (isSuccess) {
1373
- _context18.n = 5;
1401
+ _context19.n = 5;
1374
1402
  break;
1375
1403
  }
1376
- return _context18.a(2, Promise.resolve({
1404
+ return _context19.a(2, Promise.resolve({
1377
1405
  success: false,
1378
1406
  failureReason: failureOutputReason
1379
1407
  }));
@@ -1385,27 +1413,27 @@ var PapiApi = /*#__PURE__*/function () {
1385
1413
  } : undefined;
1386
1414
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1387
1415
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1388
- _context18.n = 6;
1416
+ _context19.n = 6;
1389
1417
  return this.calculateTransactionFee(tx, address);
1390
1418
  case 6:
1391
- executionFee = _context18.v;
1419
+ executionFee = _context19.v;
1392
1420
  nativeAsset = findAsset(node, {
1393
1421
  symbol: Native(getNativeAssetSymbol(node))
1394
1422
  }, null);
1395
1423
  hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.multiLocation);
1396
1424
  if (!(hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && nativeAsset && node !== 'AssetHubPolkadot' && node !== 'Kusama')) {
1397
- _context18.n = 8;
1425
+ _context19.n = 8;
1398
1426
  break;
1399
1427
  }
1400
- _context18.n = 7;
1428
+ _context19.n = 7;
1401
1429
  return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
1402
1430
  case 7:
1403
- xcmFee = _context18.v;
1431
+ xcmFee = _context19.v;
1404
1432
  if (!(typeof xcmFee === 'bigint')) {
1405
- _context18.n = 8;
1433
+ _context19.n = 8;
1406
1434
  break;
1407
1435
  }
1408
- return _context18.a(2, Promise.resolve({
1436
+ return _context19.a(2, Promise.resolve({
1409
1437
  success: true,
1410
1438
  fee: xcmFee,
1411
1439
  weight: weight,
@@ -1414,7 +1442,7 @@ var PapiApi = /*#__PURE__*/function () {
1414
1442
  }));
1415
1443
  case 8:
1416
1444
  fee = computeFeeFromDryRun(result, node, executionFee, !!feeAsset);
1417
- return _context18.a(2, Promise.resolve({
1445
+ return _context19.a(2, Promise.resolve({
1418
1446
  success: true,
1419
1447
  fee: fee,
1420
1448
  weight: weight,
@@ -1422,9 +1450,9 @@ var PapiApi = /*#__PURE__*/function () {
1422
1450
  destParaId: destParaId
1423
1451
  }));
1424
1452
  }
1425
- }, _callee18, this);
1453
+ }, _callee19, this);
1426
1454
  }));
1427
- function getDryRunCall(_x31) {
1455
+ function getDryRunCall(_x33) {
1428
1456
  return _getDryRunCall.apply(this, arguments);
1429
1457
  }
1430
1458
  return getDryRunCall;
@@ -1432,24 +1460,24 @@ var PapiApi = /*#__PURE__*/function () {
1432
1460
  }, {
1433
1461
  key: "getXcmWeight",
1434
1462
  value: function () {
1435
- var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(xcm) {
1463
+ var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(xcm) {
1436
1464
  var weightResult, _weightResult$value, ref_time, proof_size;
1437
- return _regenerator().w(function (_context19) {
1438
- while (1) switch (_context19.n) {
1465
+ return _regenerator().w(function (_context20) {
1466
+ while (1) switch (_context20.n) {
1439
1467
  case 0:
1440
- _context19.n = 1;
1468
+ _context20.n = 1;
1441
1469
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
1442
1470
  case 1:
1443
- weightResult = _context19.v;
1471
+ weightResult = _context20.v;
1444
1472
  _weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
1445
- return _context19.a(2, {
1473
+ return _context20.a(2, {
1446
1474
  refTime: ref_time,
1447
1475
  proofSize: proof_size
1448
1476
  });
1449
1477
  }
1450
- }, _callee19, this);
1478
+ }, _callee20, this);
1451
1479
  }));
1452
- function getXcmWeight(_x33) {
1480
+ function getXcmWeight(_x35) {
1453
1481
  return _getXcmWeight.apply(this, arguments);
1454
1482
  }
1455
1483
  return getXcmWeight;
@@ -1457,35 +1485,35 @@ var PapiApi = /*#__PURE__*/function () {
1457
1485
  }, {
1458
1486
  key: "getXcmPaymentApiFee",
1459
1487
  value: function () {
1460
- var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(node, xcm, asset) {
1488
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(node, xcm, asset) {
1461
1489
  var weight, transformedLocation, transformedPapiLocation, feeResult;
1462
- return _regenerator().w(function (_context20) {
1463
- while (1) switch (_context20.n) {
1490
+ return _regenerator().w(function (_context21) {
1491
+ while (1) switch (_context21.n) {
1464
1492
  case 0:
1465
- _context20.n = 1;
1493
+ _context21.n = 1;
1466
1494
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(xcm);
1467
1495
  case 1:
1468
- weight = _context20.v;
1496
+ weight = _context21.v;
1469
1497
  if (asset !== null && asset !== void 0 && asset.multiLocation) {
1470
- _context20.n = 2;
1498
+ _context21.n = 2;
1471
1499
  break;
1472
1500
  }
1473
1501
  throw new InvalidCurrencyError('This asset does not have a multiLocation defined. Cannot determine destination fee.');
1474
1502
  case 2:
1475
1503
  transformedLocation = node === 'AssetHubPolkadot' || node === 'AssetHubKusama' || isRelayChain(node) ? localizeLocation(node, asset.multiLocation) : asset.multiLocation;
1476
1504
  transformedPapiLocation = _transform(transformedLocation);
1477
- _context20.n = 3;
1505
+ _context21.n = 3;
1478
1506
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
1479
1507
  type: Version.V4,
1480
1508
  value: transformedPapiLocation
1481
1509
  });
1482
1510
  case 3:
1483
- feeResult = _context20.v;
1484
- return _context20.a(2, feeResult.value);
1511
+ feeResult = _context21.v;
1512
+ return _context21.a(2, feeResult.value);
1485
1513
  }
1486
- }, _callee20, this);
1514
+ }, _callee21, this);
1487
1515
  }));
1488
- function getXcmPaymentApiFee(_x34, _x35, _x36) {
1516
+ function getXcmPaymentApiFee(_x36, _x37, _x38) {
1489
1517
  return _getXcmPaymentApiFee.apply(this, arguments);
1490
1518
  }
1491
1519
  return getXcmPaymentApiFee;
@@ -1493,32 +1521,32 @@ var PapiApi = /*#__PURE__*/function () {
1493
1521
  }, {
1494
1522
  key: "getDryRunXcm",
1495
1523
  value: function () {
1496
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_ref9) {
1524
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(_ref9) {
1497
1525
  var _ref0, _processAssetsDeposit, _ref1, _ref10, _ref11, _ref12, _ref13;
1498
1526
  var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
1499
- return _regenerator().w(function (_context21) {
1500
- while (1) switch (_context21.n) {
1527
+ return _regenerator().w(function (_context22) {
1528
+ while (1) switch (_context22.n) {
1501
1529
  case 0:
1502
1530
  originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
1503
1531
  supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
1504
1532
  if (supportsDryRunApi) {
1505
- _context21.n = 1;
1533
+ _context22.n = 1;
1506
1534
  break;
1507
1535
  }
1508
1536
  throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1509
1537
  case 1:
1510
1538
  transformedOriginLocation = _transform(originLocation);
1511
- _context21.n = 2;
1539
+ _context22.n = 2;
1512
1540
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1513
1541
  case 2:
1514
- result = _context21.v;
1542
+ result = _context22.v;
1515
1543
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1516
1544
  if (isSuccess) {
1517
- _context21.n = 3;
1545
+ _context22.n = 3;
1518
1546
  break;
1519
1547
  }
1520
1548
  failureReason = result.value.execution_result.value.error.type;
1521
- return _context21.a(2, Promise.resolve({
1549
+ return _context22.a(2, Promise.resolve({
1522
1550
  success: false,
1523
1551
  failureReason: failureReason
1524
1552
  }));
@@ -1531,18 +1559,18 @@ var PapiApi = /*#__PURE__*/function () {
1531
1559
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1532
1560
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1533
1561
  if (!(hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot' && node !== 'Polkadot')) {
1534
- _context21.n = 5;
1562
+ _context22.n = 5;
1535
1563
  break;
1536
1564
  }
1537
- _context21.n = 4;
1565
+ _context22.n = 4;
1538
1566
  return this.getXcmPaymentApiFee(node, xcm, asset);
1539
1567
  case 4:
1540
- _fee = _context21.v;
1568
+ _fee = _context22.v;
1541
1569
  if (!(typeof _fee === 'bigint')) {
1542
- _context21.n = 5;
1570
+ _context22.n = 5;
1543
1571
  break;
1544
1572
  }
1545
- return _context21.a(2, {
1573
+ return _context22.a(2, {
1546
1574
  success: true,
1547
1575
  fee: _fee,
1548
1576
  weight: weight,
@@ -1590,10 +1618,10 @@ var PapiApi = /*#__PURE__*/function () {
1590
1618
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1591
1619
  });
1592
1620
  if (feeEvent) {
1593
- _context21.n = 6;
1621
+ _context22.n = 6;
1594
1622
  break;
1595
1623
  }
1596
- return _context21.a(2, Promise.resolve({
1624
+ return _context22.a(2, Promise.resolve({
1597
1625
  success: false,
1598
1626
  failureReason: 'Cannot determine destination fee. No fee event found'
1599
1627
  }));
@@ -1603,7 +1631,7 @@ var PapiApi = /*#__PURE__*/function () {
1603
1631
  fee = amount - originFee - feeEvent.value.value.amount;
1604
1632
  }
1605
1633
  processedFee = (isRelayChain(node) || node.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padFeeBy(fee, 30) : fee;
1606
- return _context21.a(2, Promise.resolve({
1634
+ return _context22.a(2, Promise.resolve({
1607
1635
  success: true,
1608
1636
  fee: processedFee,
1609
1637
  weight: weight,
@@ -1611,9 +1639,9 @@ var PapiApi = /*#__PURE__*/function () {
1611
1639
  destParaId: destParaId
1612
1640
  }));
1613
1641
  }
1614
- }, _callee21, this);
1642
+ }, _callee22, this);
1615
1643
  }));
1616
- function getDryRunXcm(_x37) {
1644
+ function getDryRunXcm(_x39) {
1617
1645
  return _getDryRunXcm.apply(this, arguments);
1618
1646
  }
1619
1647
  return getDryRunXcm;
@@ -1621,18 +1649,18 @@ var PapiApi = /*#__PURE__*/function () {
1621
1649
  }, {
1622
1650
  key: "getBridgeStatus",
1623
1651
  value: function () {
1624
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
1652
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
1625
1653
  var outboundOperatingMode;
1626
- return _regenerator().w(function (_context22) {
1627
- while (1) switch (_context22.n) {
1654
+ return _regenerator().w(function (_context23) {
1655
+ while (1) switch (_context23.n) {
1628
1656
  case 0:
1629
- _context22.n = 1;
1657
+ _context23.n = 1;
1630
1658
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1631
1659
  case 1:
1632
- outboundOperatingMode = _context22.v;
1633
- return _context22.a(2, outboundOperatingMode.type);
1660
+ outboundOperatingMode = _context23.v;
1661
+ return _context23.a(2, outboundOperatingMode.type);
1634
1662
  }
1635
- }, _callee22, this);
1663
+ }, _callee23, this);
1636
1664
  }));
1637
1665
  function getBridgeStatus() {
1638
1666
  return _getBridgeStatus.apply(this, arguments);
@@ -1652,19 +1680,21 @@ var PapiApi = /*#__PURE__*/function () {
1652
1680
  }, {
1653
1681
  key: "disconnect",
1654
1682
  value: function disconnect() {
1683
+ var _this$_config$apiOver2;
1655
1684
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1656
1685
  if (!this.initialized) return Promise.resolve();
1657
1686
  if (!force && !this.disconnectAllowed) return Promise.resolve();
1687
+ var api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._node] : this._config;
1658
1688
  // Own client provided, destroy only if force true
1659
- if (force && _typeof(this._api) === 'object') {
1689
+ if (force && _typeof(api) === 'object') {
1660
1690
  this.api.destroy();
1661
1691
  }
1662
1692
  // Client created automatically
1663
- if (typeof this._api === 'string' || Array.isArray(this._api) || this._api === undefined) {
1693
+ if (typeof api === 'string' || Array.isArray(api) || api === undefined) {
1664
1694
  if (force) {
1665
1695
  this.api.destroy();
1666
1696
  } else {
1667
- var key = this._api === undefined ? getNodeProviders(this._node) : this._api;
1697
+ var key = api === undefined ? getNodeProviders(this._node) : api;
1668
1698
  releasePolkadotClient(key);
1669
1699
  }
1670
1700
  }
@@ -1684,8 +1714,7 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
1684
1714
  return _regenerator().w(function (_context) {
1685
1715
  while (1) switch (_context.n) {
1686
1716
  case 0:
1687
- papiApi = new PapiApi();
1688
- papiApi.setApi(options.api);
1717
+ papiApi = new PapiApi(options.api);
1689
1718
  optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
1690
1719
  api: papiApi
1691
1720
  });
@@ -1896,8 +1925,7 @@ var EvmBuilder$1 = function EvmBuilder(api) {
1896
1925
  * @returns A new Builder instance.
1897
1926
  */
1898
1927
  var Builder = function Builder(api) {
1899
- var papiApi = new PapiApi();
1900
- papiApi.setApi(api);
1928
+ var papiApi = new PapiApi(api);
1901
1929
  return Builder$1(papiApi);
1902
1930
  };
1903
1931
  var EvmBuilder = function EvmBuilder() {
@@ -1919,8 +1947,7 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
1919
1947
  return _regenerator().w(function (_context) {
1920
1948
  while (1) switch (_context.n) {
1921
1949
  case 0:
1922
- papiApi = new PapiApi();
1923
- papiApi.setApi(ahApi);
1950
+ papiApi = new PapiApi(ahApi);
1924
1951
  _context.n = 1;
1925
1952
  return papiApi.init('AssetHubPolkadot');
1926
1953
  case 1:
@@ -1941,8 +1968,7 @@ var getBridgeStatus = /*#__PURE__*/function () {
1941
1968
  return _regenerator().w(function (_context2) {
1942
1969
  while (1) switch (_context2.n) {
1943
1970
  case 0:
1944
- papiApi = new PapiApi();
1945
- papiApi.setApi(ahApi);
1971
+ papiApi = new PapiApi(ahApi);
1946
1972
  return _context2.a(2, getBridgeStatus$1(papiApi));
1947
1973
  }
1948
1974
  }, _callee2);